mirror of
https://github.com/Smaug123/anki-decks
synced 2025-10-08 11:08:40 +00:00
Add flake
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
/result
|
15
build.sh
Executable file
15
build.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
input_folder=$1
|
||||
anki_bin=$2
|
||||
out=$3
|
||||
|
||||
mkdir -p "$out"
|
||||
|
||||
for item in "$input_folder"/*.json; do
|
||||
output_file=$(echo "$item" | sed 's/\.json$/.apkg/')
|
||||
# Invoke the binary command on the item
|
||||
echo "$item"
|
||||
echo "$out/$output_file"
|
||||
"$anki_bin" render --output "$out/$output_file" "$item"
|
||||
done
|
129
flake.lock
generated
Normal file
129
flake.lock
generated
Normal file
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"nodes": {
|
||||
"anki-compiler": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694219801,
|
||||
"narHash": "sha256-8KFSy+R0nwUeZ3U2WYvRRjEYEk8iLXwWM9onvz5pixE=",
|
||||
"owner": "Smaug123",
|
||||
"repo": "anki-dotnet",
|
||||
"rev": "8d1904d5cea06c8c20f5712ba865ace2d61b6255",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Smaug123",
|
||||
"repo": "anki-dotnet",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1692799911,
|
||||
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1694021185,
|
||||
"narHash": "sha256-v5Ie83yfsiQgp4GDRZFIsbkctEynfOdNOi67vBH12XM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3e233330d9f88f78c75c2a164a50807e44245007",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1688392541,
|
||||
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"anki-compiler": "anki-compiler",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
69
flake.nix
Normal file
69
flake.nix
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
description = "Anki decks hosted on patrickstevens.co.uk";
|
||||
|
||||
inputs = {
|
||||
flake-utils.url = github:numtide/flake-utils;
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||
anki-compiler.url = "github:Smaug123/anki-dotnet";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
anki-compiler,
|
||||
}: let
|
||||
commit = self.shortRev or "dirty";
|
||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||
version = "1.0.0+${builtins.substring 0 8 date}.${commit}";
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in let
|
||||
createShellScript = name: contents:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
__contentAddressed = true;
|
||||
pname = name;
|
||||
version = "0.1.0";
|
||||
src = contents;
|
||||
|
||||
buildInputs = [
|
||||
pkgs.shellcheck
|
||||
];
|
||||
|
||||
phases = ["configurePhase" "buildPhase" "installPhase"];
|
||||
|
||||
configurePhase = ''
|
||||
${pkgs.shellcheck}/bin/shellcheck "${contents}"
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
cp "${contents}" run.sh
|
||||
patchShebangs run.sh
|
||||
sed -i 's_"/bin/bash"_"${pkgs.bash}/bin/bash"_' run.sh
|
||||
sed -i 's_"/bin/sh"_"${pkgs.bash}/bin/bash"_' run.sh
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mv run.sh $out/run.sh
|
||||
'';
|
||||
};
|
||||
in let
|
||||
buildAnki = createShellScript "anki" ./build.sh;
|
||||
in {
|
||||
packages.default = pkgs.stdenv.mkDerivation {
|
||||
__contentAddressed = true;
|
||||
inherit version;
|
||||
pname = "patrickstevens.co.uk-anki";
|
||||
src = ./.;
|
||||
buildInputs = [];
|
||||
installPhase = ''
|
||||
${buildAnki}/run.sh . "${anki-compiler.packages.${system}.default}/bin/AnkiStatic" "$out"
|
||||
'';
|
||||
};
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [pkgs.alejandra pkgs.shellcheck];
|
||||
};
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user