Skip to content

Commit 10d7976

Browse files
committed
avoid hard-coded /bin paths
based in part on #8 and addressing part of #10
1 parent 956d2fc commit 10d7976

File tree

11 files changed

+29
-24
lines changed

11 files changed

+29
-24
lines changed

default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ packs = import ./packs {
3232
etc. These can be string paths to the system or to packages/environments
3333
from nixpkgs or similar, but regardless need to be external to nixpacks. */
3434
spackPython = "/usr/bin/python3";
35-
spackPath = "/bin:/usr/bin";
35+
spackEnv = {
36+
PATH = "/bin:/usr/bin";
37+
};
3638

3739
/* packs can optionally include nixpkgs for additional packages or bootstrapping.
3840
omit to disable. */

fi/default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ corePacks = import ../packs {
3333
};
3434
};
3535
spackPython = "/usr/bin/python3";
36-
spackPath = "/bin:/usr/bin";
36+
spackEnv = {
37+
PATH = "/bin:/usr/bin";
38+
};
3739

3840
nixpkgsSrc = {
3941
/* -------- upstream nixpkgs version -------- */

fi/lmod/builder.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh -eu
2-
/bin/mkdir -p $out
3-
/bin/ln -s $mod $out/modules.lua
2+
mkdir -p $out
3+
ln -s $mod $out/modules.lua
44
# these are just temporary stubs until /etc/profile.d/modules.sh is updated everywhere:
55
for f in setup.sh setup.csh ; do
6-
/bin/cp $src/$f $out/$f
6+
cp $src/$f $out/$f
77
done

fi/lmod/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
gitrev: packs: mods:
22
# this just wraps modules.nix in a directory/symlink layer for nix-env
3-
derivation {
3+
derivation (packs.spackEnv // {
44
name = "lmodSite";
55
inherit (mods) system;
66
mod = import ./modules.nix gitrev packs mods;
77
src = ./.;
88
builder = ./builder.sh;
9-
}
9+
})

fi/lmod/modules.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
gitrev: packs: mods:
22
# a simple modules.lua meta-module for adding modules
3-
derivation {
3+
derivation (packs.spackEnv // {
44
name = "modules.lua";
55
inherit (mods) system;
66
mods = "${mods}/${packs.platform}-${packs.os}-${packs.target}";
77
src = ./modules.lua;
88
git = gitrev;
99
builder = ./modules.sh;
10-
}
10+
})

packs/default.nix

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ prefsUpdate = let
6060
spackSrc = scalar;
6161
spackConfig = lib.recursiveUpdate;
6262
spackPython = scalar;
63-
spackPath = scalar;
63+
spackEnv = a: b: a // b;
6464
nixpkgsSrc = scalar;
6565
verbose = scalar;
6666
repoPatch = a: b: a // b;
@@ -77,7 +77,9 @@ packsWithPrefs =
7777
, spackSrc ? {}
7878
, spackConfig ? {}
7979
, spackPython ? "/usr/bin/python3"
80-
, spackPath ? "/bin:/usr/bin"
80+
, spackEnv ? {
81+
PATH = "/bin:/usr/bin";
82+
}
8183
, nixpkgsSrc ? null
8284
, repos ? [ ../spack/repo ]
8385
, repoPatch ? {}
@@ -99,22 +101,21 @@ lib.fix (packs: with packs; {
99101

100102
makeSpackConfig = import ../spack/config.nix packs;
101103

102-
inherit spackPython spackPath;
104+
inherit spackPython spackEnv;
103105
spackConfig = makeSpackConfig (lib.recursiveUpdate defaultSpackConfig packPrefs.spackConfig);
104106

105-
spackNixLib = derivation {
107+
spackNixLib = derivation (spackEnv // {
106108
name = "nix-spack-py";
107109
inherit system;
108110
builder = ../spack/install.sh;
109111
src = ../spack/nixpack.py;
110-
};
112+
});
111113

112114
/* common attributes for running spack */
113-
spackBuilder = attrs: builtins.removeAttrs (derivation ({
115+
spackBuilder = attrs: builtins.removeAttrs (derivation (spackEnv // {
114116
inherit (packs) system os spackConfig;
115117
builder = spackPython;
116118
PYTHONPATH = "${spackNixLib}:${spack}/lib/spack:${spack}/lib/spack/external";
117-
PATH = spackPath;
118119
LC_ALL = "en_US.UTF-8"; # work around spack bugs processing log files
119120
repos = if attrs ? withRepos
120121
then if attrs.withRepos

packs/lmodCache.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
packs:
22
src:
3-
derivation {
3+
derivation (packs.spackEnv // {
44
inherit (packs) system;
55
name = "lmodCache";
66
builder = ./lmodCache.sh;
7-
PATH = packs.spackPath;
87
lmod = packs.pkgs.lmod;
98
MODULEPATH = "${src}/${packs.platform}-${packs.os}-${packs.target}/Core";
10-
}
9+
})

spack/bin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ EOF
2121

2222
}
2323
gen > $out
24-
/bin/chmod +x $out
24+
chmod +x $out

spack/config.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ packs: config: derivation ({
33
name = "spackConfig";
44
builder = ./config.sh;
55
sections = builtins.attrNames config;
6-
} // builtins.mapAttrs (n: v: builtins.toJSON { "${n}" = v; }) config)
6+
} // builtins.mapAttrs (n: v: builtins.toJSON { "${n}" = v; }) config
7+
// packs.spackEnv)

spack/config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -eu
22

3-
/bin/mkdir -p $out
3+
mkdir -p $out
44
for section in $sections ; do
55
eval "echo \"\$$section\"" > $out/$section.yaml
66
done

0 commit comments

Comments
 (0)