diff --git a/nix/modules/flake-parts/extra/default.nix b/nix/modules/flake-parts/extra/default.nix new file mode 100644 index 00000000..1e34ad19 --- /dev/null +++ b/nix/modules/flake-parts/extra/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./small-closure.nix + ]; +} diff --git a/nix/modules/flake-parts/extra/small-closure.nix b/nix/modules/flake-parts/extra/small-closure.nix new file mode 100644 index 00000000..e9ac62d3 --- /dev/null +++ b/nix/modules/flake-parts/extra/small-closure.nix @@ -0,0 +1,40 @@ +{ root, inputs, ... }: +{ + perSystem = { pkgs, lib, config, system, ... }: { + haskellProjects.default = { + settings = { + emanote = { name, pkgs, self, super, ... }: { + separateBinOutput = false; # removeReferencesTo.nix doesn't work otherwise + justStaticExecutables = true; + removeReferencesTo = [ + self.ghc + self.pandoc + self.pandoc-types + self.warp + ]; + }; + }; + }; + + apps.check-closure-size = rec { + inherit (program) meta; + program = pkgs.writeShellApplication { + name = "emanote-check-closure-size"; + runtimeInputs = [ pkgs.jq pkgs.bc pkgs.nix ]; + meta.description = "Check that emanote's nix closure size remains reasonably small"; + text = '' + MAX_CLOSURE_SIZE=$(echo "600 * 1000000" | bc) + CLOSURE_SIZE=$(nix path-info --json -S .#default | jq 'first(.[])'.closureSize) + echo "Emanote closure size: $CLOSURE_SIZE" + echo " Max closure size: $MAX_CLOSURE_SIZE" + if [ "$CLOSURE_SIZE" -gt "$MAX_CLOSURE_SIZE" ]; then + echo "ERROR: Emanote's nix closure size has increased" + exit 3 + else + echo "OK: Emanote's nix closure size is within limits" + fi + ''; + }; + }; + }; +} diff --git a/nix/modules/flake-parts/haskell.nix b/nix/modules/flake-parts/haskell.nix index b924095c..1618e83f 100644 --- a/nix/modules/flake-parts/haskell.nix +++ b/nix/modules/flake-parts/haskell.nix @@ -44,13 +44,6 @@ emanote = { name, pkgs, self, super, ... }: { check = false; extraBuildDepends = [ pkgs.stork ]; - separateBinOutput = false; # removeReferencesTo.nix doesn't work otherwise - justStaticExecutables = true; - removeReferencesTo = [ - self.pandoc - self.pandoc-types - self.warp - ]; custom = pkg: pkg.overrideAttrs (lib.addMetaAttrs { # https://github.com/NixOS/cabal2nix/issues/608 longDescription = '' @@ -68,25 +61,5 @@ packages.default = config.packages.emanote; apps.default = config.apps.emanote; - apps.check-closure-size = rec { - inherit (program) meta; - program = pkgs.writeShellApplication { - name = "emanote-check-closure-size"; - runtimeInputs = [ pkgs.jq pkgs.bc pkgs.nix ]; - meta.description = "Check that emanote's nix closure size remains reasonably small"; - text = '' - MAX_CLOSURE_SIZE=$(echo "600 * 1000000" | bc) - CLOSURE_SIZE=$(nix path-info --json -S .#default | jq 'first(.[])'.closureSize) - echo "Emanote closure size: $CLOSURE_SIZE" - echo " Max closure size: $MAX_CLOSURE_SIZE" - if [ "$CLOSURE_SIZE" -gt "$MAX_CLOSURE_SIZE" ]; then - echo "ERROR: Emanote's nix closure size has increased" - exit 3 - else - echo "OK: Emanote's nix closure size is within limits" - fi - ''; - }; - }; }; }