aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-12-19 09:55:29 +1100
committerJustin Bedo <cu@cua0.org>2018-12-19 09:55:29 +1100
commit0808fc803e3226d2f478229832bb827d7dfcbd0d (patch)
tree6048e23151a9c0e183e59b964fd9ec5fa32df823 /default.nix
parent8501b505c9cec5768b2f1dfcb49f13e0f0611011 (diff)
link: introduce high-level linking functions
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix14
1 files changed, 14 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 84bb3c8..1e647dd 100644
--- a/default.nix
+++ b/default.nix
@@ -37,6 +37,20 @@ 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;
+ };
+ ln = x: y: { src = x; dst = y; };
+
# Fetching files of specific type
fetchFastQ = attrs: with types; tagFiletype (filetype.fq {}) (fetchurl attrs);
fetchFastA = attrs: with types; tagFiletype (filetype.fa {}) (fetchurl attrs);