From bd617a28753dbab2fd3debcbc814242d8bf9bc38 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 7 Apr 2026 16:59:00 +0900 Subject: [PATCH] flake.nix: make update scripts runnable with `nix run` --- flake.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/flake.nix b/flake.nix index dd1a26a..c1f3c5d 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = [{