From 9fd618d0305d4927c8d86fc37238d1216e401967 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Wed, 9 Jan 2019 16:00:33 +1100 Subject: split/join/each: introduce functions for splitting/joining drvs --- default.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3