aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2021-10-29 17:39:01 +1100
committerJustin Bedo <cu@cua0.org>2021-10-29 17:39:01 +1100
commitbac9248a5e08e8afdf5485a6e27cfe72e1ca5090 (patch)
tree8719a280b56122017d46b582cd3da8547dd3f548 /default.nix
parentab809b8c77efdad9fb54d3591a0193a1cbe888d1 (diff)
treewide reformatting and simplification
- simplify with statix - reformat with nixpkgs-fmt
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix87
1 files changed, 48 insertions, 39 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