aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2019-05-14 14:19:18 +1000
committerJustin Bedo <cu@cua0.org>2019-05-14 15:45:08 +1000
commit1a160f714516ae4d6d8af92380b0713fdd2eadf6 (patch)
tree4099644753c45bd22f55b7807ce87cc751850408 /default.nix
parent6137d292d8d721490bf6ded2695cdc71755aff59 (diff)
strip: remove store paths from outputs to minimise closures
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix23
1 files changed, 22 insertions, 1 deletions
diff --git a/default.nix b/default.nix
index 25834a9..03869bc 100644
--- a/default.nix
+++ b/default.nix
@@ -75,7 +75,28 @@ let
# Export nixpkgs and standard library lib
pkgs = nixpkgs;
lib = nixpkgs.lib // { types = types; shard = callBionix ./lib/shard.nix {};};
- stage = x@{ name, ... }: { multicore = false; } // nixpkgs.stdenvNoCC.mkDerivation (x // {name = "bionix-" + name;});
+ stage = x@{ name, stripStorePaths ? true, ... }:
+ (if stripStorePaths then strip else x: x) ({ multicore = false; } // nixpkgs.stdenvNoCC.mkDerivation (x // {name = "bionix-" + name; }));
+ strip = drv: drv.overrideAttrs (attrs: {
+ buildCommand = attrs.buildCommand + ''
+
+ function rewrite {
+ sed -i 's|/nix/store/[^-]*|/nix/store/00000000000000000000000000000000|g' $1
+ }
+ function rewriteOutput {
+ if [ -f ''${!1} ] ; then
+ rewrite ''${!1}
+ else
+ for f in $(find ''${!1} -type f) ; do
+ rewrite $f
+ done
+ fi
+ }
+ for o in $outputs ; do
+ rewriteOutput $o
+ done
+ '';
+ });
# splitting/joining
splitFile = file: drv: stage {