diff options
author | Justin Bedo <cu@cua0.org> | 2019-01-09 16:00:33 +1100 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2019-01-09 16:00:33 +1100 |
commit | 9fd618d0305d4927c8d86fc37238d1216e401967 (patch) | |
tree | 41ff4873c22e32054a21f53b9b32b525c4f9216c | |
parent | 4576eeeec4fc001c0c064e5d083d35c129ac367a (diff) |
split/join/each: introduce functions for splitting/joining drvs
-rw-r--r-- | default.nix | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/default.nix b/default.nix index 538ddf4..6ddcd1b 100644 --- a/default.nix +++ b/default.nix @@ -58,7 +58,24 @@ let fetchFastQGZ = attrs: with types; tagFiletype (filetype.gz (filetype.fq {})) (fetchurl attrs); fetchFastAGZ = attrs: with types; tagFiletype (filetype.gz (filetype.fa {})) (fetchurl attrs); - # Export nixpkgs' lib + # Export nixpkgs and standard library lib + pkgs = nixpkgs; lib = nixpkgs.lib; + stage = nixpkgs.stdenvNoCC.mkDerivation; + + # splitting/joining + splitFile = file: drv: stage { + name = "split-${file}"; + buildCommand = "ln -s ${drv}/${file} $out"; + }; + split = drv: lib.mapAttrs (p: _: splitFile p drv) (builtins.readDir drv); + join = drvs: stage { + name = "join"; + buildCommand = '' + mkdir $out + ${builtins.concatStringsSep "\n" (builtins.attrValues (lib.mapAttrs (n: d: "ln -s ${d} $out/${n}") drvs))} + ''; + }; + each = f: drv: join (lib.mapAttrs (_: f) (split drv)); }); in bionix |