flake.nix: make update scripts runnable with nix run

This commit is contained in:
2026-04-07 16:59:00 +09:00
parent aee22b6b52
commit bd617a2875

View File

@@ -15,6 +15,31 @@
forAllSystems = f: lib.genAttrs systems (system: f system nixpkgs.legacyPackages.${system});
in {
apps = forAllSystems (system: pkgs: let
wrapUpdateScript = name: path: {
type = "app";
meta.description = "A script to update the ${name} data";
program = let
drv = pkgs.writeShellApplication {
name = "update-${name}";
text = lib.readFile path;
runtimeInputs = lib.pipe path [
lib.readFile
(lib.splitString "\n")
(x: lib.elemAt x 1)
(lib.splitString " ")
(lib.drop 4) # "#!nix-shell -i bash -p"
(map (dep: pkgs.${dep}))
];
};
in lib.getExe drv;
};
in {
update-jmdict = wrapUpdateScript "jmdict" ./scripts/update-jmdict.sh;
update-kanjidic2 = wrapUpdateScript "kanjidic2" ./scripts/update-kanjidic2.sh;
update-radkfile = wrapUpdateScript "radkfile" ./scripts/update-radkfile.sh;
});
packages = let
edrdgMetadata = {
license = [{