diff options
104 files changed, 936 insertions, 802 deletions
diff --git a/default.nix b/default.nix index 1944de0..59357b2 100644 --- a/default.nix +++ b/default.nix @@ -5,10 +5,11 @@ let bionix = nixpkgs.lib.makeExtensible (self: let callBionix = file: attrs: import file ({ bionix = self; } // attrs); - in with self; { - callBionix = callBionix; + in + with self; { + inherit callBionix; id = x: x; - exec = f: x: y: f x y; + exec = id; exec' = f: exec (_: f) { }; exec'' = f: exec' (_: f) { }; callBionixE = p: exec (callBionix p); @@ -52,15 +53,17 @@ let slurm-run = callPackage ./lib/slurm.nix { }; slurm-exec = f: x: y: - slurm-run x (f (builtins.removeAttrs x [ - "ppn" - "mem" - "walltime" - "partition" - "slurmFlags" - "salloc" - "srun" - ]) y); + slurm-run x (f + (builtins.removeAttrs x [ + "ppn" + "mem" + "walltime" + "partition" + "slurmFlags" + "salloc" + "srun" + ]) + y); slurm = bionix.extend (self: super: { exec = super.slurm-run; }); qsub = attrs: bionix.extend (self: super: @@ -78,7 +81,8 @@ let qsub = attrs: (callPackage ./lib/qsub.nix { }) (qsubDefs // attrs); exec = f: x: y: qsub (builtins.intersectAttrs qsubDefs x) (super.exec f - (builtins.removeAttrs x (builtins.attrNames qsubDefs)) y); + (builtins.removeAttrs x (builtins.attrNames qsubDefs)) + y); }); def = f: defs: attrs: f (defs // attrs); @@ -88,22 +92,24 @@ let 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 - abort "linkOutputs: unsupported type"; - link = dst: src: '' - ln -s ${recurse src} $(perl -e 'print $ENV{"${dst}"}') ; ln -s ${ - recurse src - } $out/${dst} - ''; - in '' - mkdir $out - '' + (concatStringsSep "\n" (mapAttrsToList link x)); + buildCommand = + let + recurse = x: + if x ? type && x.type == "derivation" then + x + else if builtins.typeOf x == "set" then + linkOutputs x + else + abort "linkOutputs: unsupported type"; + link = dst: src: '' + ln -s ${recurse src} $(perl -e 'print $ENV{"${dst}"}') ; ln -s ${ + recurse src + } $out/${dst} + ''; + in + '' + mkdir $out + '' + (concatStringsSep "\n" (mapAttrsToList link x)); passthru.linkInputs = x; }; @@ -127,15 +133,15 @@ let # Export nixpkgs and standard library lib pkgs = nixpkgs; lib = nixpkgs.lib // { - types = types; + inherit types; shard = callBionix ./lib/shard.nix { }; }; stage = x@{ name, stripStorePaths ? true, multicore ? false, ... }: (if stripStorePaths then strip else x: x) - (nixpkgs.stdenvNoCC.mkDerivation (x // { - name = "bionix-" + name; - inherit multicore; - })); + (nixpkgs.stdenvNoCC.mkDerivation (x // { + name = "bionix-" + name; + inherit multicore; + })); strip = drv: let stripCommand = '' @@ -156,7 +162,8 @@ let rewriteOutput $o done ''; - in drv.overrideAttrs (attrs: + in + drv.overrideAttrs (attrs: if attrs ? buildCommand then { buildCommand = attrs.buildCommand + stripCommand; } else { @@ -186,13 +193,15 @@ let overlayByType = { lambda = bionix: overlay: bionix.extend - (self: super: nixpkgs.lib.recursiveUpdate super (overlay self super)); + (self: super: nixpkgs.lib.recursiveUpdate super (overlay self super)); path = bionix: path: overlay bionix (import path); }; overlay = bionix: overlay: let overlayType = builtins.typeOf overlay; - in if overlayByType ? ${overlayType} then - overlayByType.${overlayType} bionix overlay + in + if overlayByType ? "${overlayType}" then + overlayByType."${overlayType}" bionix overlay else builtins.throw ("cannot overlay type " + overlayType); -in with nixpkgs.lib; foldl overlay bionix overlays +in +with nixpkgs.lib; foldl overlay bionix overlays diff --git a/doc/default.nix b/doc/default.nix index d68a6b1..ac8bfeb 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -1,4 +1,4 @@ -{ bionix ? import ./.. {} }: +{ bionix ? import ./.. { } }: with bionix; diff --git a/examples/call.nix b/examples/call.nix index 8a38fdb..81a112e 100644 --- a/examples/call.nix +++ b/examples/call.nix @@ -2,9 +2,10 @@ # with the Platypus variant caller. Each input is preprocessed by aligning # against a reference genome (defaults to GRCH38), fixing mate information, and # marking duplicates. Finally platypus is called over all samples. -{bionix ? import <bionix> {} -,inputs -,ref ? bionix.ref.grch38.seq }: +{ bionix ? import <bionix> { } +, inputs +, ref ? bionix.ref.grch38.seq +}: with bionix; with lib; @@ -13,9 +14,10 @@ let preprocess = flip pipe [ (bwa.align { inherit ref; }) (samtools.sort { nameSort = true; }) - (samtools.fixmate {}) - (samtools.sort {}) - (samtools.markdup {}) + (samtools.fixmate { }) + (samtools.sort { }) + (samtools.markdup { }) ]; -in platypus.call {} (map preprocess inputs) +in +platypus.call { } (map preprocess inputs) diff --git a/examples/default.nix b/examples/default.nix index 9aace38..ef57341 100644 --- a/examples/default.nix +++ b/examples/default.nix @@ -1,6 +1,6 @@ # This example uses the pipelines specified in the call.nix file on the # synthetic data in this directory. -{bionix ? import <bionix> {}}: +{ bionix ? import <bionix> { } }: with bionix; @@ -15,7 +15,7 @@ let sha256 = "0kh29i6fg14dn0fb1xj6pkpk6d83y7zg7aphkbvjrhm82braqkm8"; }; - input2 = fetchFastQ { + input2 = fetchFastQ { url = "https://github.com/PapenfussLab/bionix/raw/master/examples/sample1-2.fq"; sha256 = "0czk85km6a91y0fn4b7f9q7ps19b5jf7jzwbly4sgznps7ir2kdk"; }; @@ -28,7 +28,7 @@ let sha256 = "08gixavfklqvk1m2ic6v56z82vl00qnpsd9xb64z6zl03nz98mcy"; }; - input2 = fetchFastQ { + input2 = fetchFastQ { url = "https://github.com/PapenfussLab/bionix/raw/master/examples/sample2-2.fq"; sha256 = "1xxwm2vq52axpdhm14rh5mg5nzzpxaqnvhzrqhajm27fqksgzjjw"; }; @@ -41,4 +41,5 @@ let sha256 = "0sy9hq8n55knfkiblam50dzaiwhrx6pv8b8l1njdn6kfj4wflz2p"; }; -in import ./call.nix {inherit inputs ref bionix;} +in +import ./call.nix { inherit inputs ref bionix; } |