aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2019-07-04 14:26:52 +1000
committerJustin Bedo <cu@cua0.org>2019-07-08 15:06:58 +1000
commitbe187bfeb074e5c2b65f25f3dcdb82a98b15570d (patch)
tree692f706f37a13f3a4026d5a560a6973c09065bfd /default.nix
parente7a6aef11516c1330ae21610b4e14321b137fd04 (diff)
linkOutputs: refactor output linking expression
The existing linkDrv only has a singular output, making it difficult to separate the various types of output. The new functionality replaces the old with attribute sets defining the outputs. The old linkDrv is deprecated.
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix24
1 files changed, 12 insertions, 12 deletions
diff --git a/default.nix b/default.nix
index 3077470..36dbe44 100644
--- a/default.nix
+++ b/default.nix
@@ -51,19 +51,19 @@ let
def = f: defs: attrs: f (defs // attrs);
pipe = let g = fs: with builtins; let h = head fs; t = tail fs; in if t != [] then x: (g t (h x)) else h; in g;
- link = {src, dst}: ''
- d=$(dirname ${dst})
- if [ ! -e $out/$d ] ; then
- mkdir -p $out/$d
- fi
- ln -s ${src} $out/${dst}
- '';
- mkLinks = nixpkgs.lib.concatMapStringsSep "\n" link;
- linkDrv = x: nixpkgs.stdenvNoCC.mkDerivation {
- name = "link";
- buildCommand = mkLinks x;
+ linkOutputs = x: with lib; nixpkgs.stdenvNoCC.mkDerivation {
+ name = "link-outputs";
+ outputs = [ "out" ] ++ attrNames x;
+ nativeBuildInputs = [ pkgs.perl ];
+ buildCommand = let
+ recurse = x: if x ? type && x.type == "derivation" then x else
+ if builtins.typeOf x == "set" then linkOutputs x
+ else error "linkOutputs: unsupported type";
+ link = dst: src: ''
+ ln -s ${recurse src} $(perl -e 'print $ENV{"${dst}"}') ; ln -s ${recurse src} $out/${dst}
+ '';
+ in "mkdir $out \n" + (concatStringsSep "\n" (mapAttrsToList link x));
};
- ln = x: y: { src = x; dst = y; };
# Fetching files of specific type
fetchFastQ = attrs: with types; tagFiletype (filetype.fq {}) (fetchurl attrs);