From 7a26c17e321986da362114d35d81f38f7ce96f76 Mon Sep 17 00:00:00 2001 From: Bryan Richter Date: Fri, 31 Jan 2025 11:39:10 +0200 Subject: [PATCH] Include runtime files in output --- flake.nix | 16 +++++++++++++++- package.nix | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index e68acd4..403c030 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,21 @@ (system: let pkgs = nixpkgs.legacyPackages.${system}; in { - defaultPackage = pkgs.callPackage ./package.nix {}; + packages.default = pkgs.callPackage ./package.nix {}; + + checks = { + # I used to put these into $out/lib, but justStaticExecutables + # removes that directory. Now I feel like I'm just getting lucky. So + # let's double check the files are there. + file-check = pkgs.runCommand "check-runtime-files" {} '' + if [ -e ${self.packages.${system}.default}/run/config/settings.yml ]; then + touch $out + else + 2>&1 echo "Runtime files are missing" + exit 1 + fi + ''; + }; } ); } diff --git a/package.nix b/package.nix index 59abd19..d474c23 100644 --- a/package.nix +++ b/package.nix @@ -9,6 +9,12 @@ let preConfigure = '' ${pkgs.hpack}/bin/hpack . ''; + # During build, static files are generated into the source tree's + # static/ dir. Plus, config/ is needed at runtime. + postInstall = '' + mkdir -p $out/run + cp -a {static,config} $out/run + ''; src = pkgs.lib.cleanSource old.src; });