diff --git a/default.nix b/default.nix index 473778c..bda28df 100644 --- a/default.nix +++ b/default.nix @@ -1,2 +1,34 @@ { pkgs ? import ./nix {} }: -pkgs.callPackage ./nix/packages.nix {} +rec +{ niv = pkgs.snack-lib.executable ./package.yaml; + readme = pkgs.writeText "README.md" + (with + { template = builtins.readFile ./README.tpl.md; + niv_help = builtins.readFile + (pkgs.runCommand "niv_help" { buildInputs = [ niv ]; } + "niv --help > $out" + ); + niv_cmd_help = cmd: builtins.readFile + (pkgs.runCommand "niv_${cmd}_help" { buildInputs = [ niv ]; } + "niv ${cmd} --help > $out" + ); + cmds = [ "add" "update" "drop" "init" "show" ]; + }; + pkgs.lib.replaceStrings + ([ "replace_niv_help" ] ++ (map (cmd: "replace_niv_${cmd}_help") cmds)) + ([ niv_help ] ++ (map niv_cmd_help cmds)) + template + ); + readme-test = pkgs.runCommand "README-test" {} + '' + err() { + echo + echo -e "\e[31mERR\e[0m: README.md out of date" + echo -e "please run \e[1m./script/gen\e[0m" + echo + exit 1 + } + + diff ${./README.md} ${readme} && echo dummy > $out || err ; + ''; +} diff --git a/nix/packages.nix b/nix/packages.nix deleted file mode 100644 index 0439fbe..0000000 --- a/nix/packages.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ writeText -, runCommand -, lib -, snack-lib -}: -rec -{ niv = snack-lib.executable ../package.yaml; - readme = writeText "README.md" - (with - { template = builtins.readFile ../README.tpl.md; - niv_help = builtins.readFile - (runCommand "niv_help" { buildInputs = [ niv ]; } - "niv --help > $out" - ); - niv_cmd_help = cmd: builtins.readFile - (runCommand "niv_${cmd}_help" { buildInputs = [ niv ]; } - "niv ${cmd} --help > $out" - ); - cmds = [ "add" "update" "drop" "init" "show" ]; - }; - lib.replaceStrings - ([ "replace_niv_help" ] ++ (map (cmd: "replace_niv_${cmd}_help") cmds)) - ([ niv_help ] ++ (map niv_cmd_help cmds)) - template - ); - readme-test = runCommand "README-test" {} - '' - err() { - echo - echo -e "\e[31mERR\e[0m: README.md out of date" - echo -e "please run \e[1m./script/gen\e[0m" - echo - exit 1 - } - - diff ${../README.md} ${readme} && echo dummy > $out || err ; - ''; -}