Skip to content

Commit

Permalink
avoid hard-coded /bin paths
Browse files Browse the repository at this point in the history
based in part on #8 and addressing part of #10
  • Loading branch information
dylex committed Jan 16, 2022
1 parent 956d2fc commit 10d7976
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 24 deletions.
4 changes: 3 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ packs = import ./packs {
etc. These can be string paths to the system or to packages/environments
from nixpkgs or similar, but regardless need to be external to nixpacks. */
spackPython = "/usr/bin/python3";
spackPath = "/bin:/usr/bin";
spackEnv = {
PATH = "/bin:/usr/bin";
};

/* packs can optionally include nixpkgs for additional packages or bootstrapping.
omit to disable. */
Expand Down
4 changes: 3 additions & 1 deletion fi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ corePacks = import ../packs {
};
};
spackPython = "/usr/bin/python3";
spackPath = "/bin:/usr/bin";
spackEnv = {
PATH = "/bin:/usr/bin";
};

nixpkgsSrc = {
/* -------- upstream nixpkgs version -------- */
Expand Down
6 changes: 3 additions & 3 deletions fi/lmod/builder.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh -eu
/bin/mkdir -p $out
/bin/ln -s $mod $out/modules.lua
mkdir -p $out
ln -s $mod $out/modules.lua
# these are just temporary stubs until /etc/profile.d/modules.sh is updated everywhere:
for f in setup.sh setup.csh ; do
/bin/cp $src/$f $out/$f
cp $src/$f $out/$f
done
4 changes: 2 additions & 2 deletions fi/lmod/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
gitrev: packs: mods:
# this just wraps modules.nix in a directory/symlink layer for nix-env
derivation {
derivation (packs.spackEnv // {
name = "lmodSite";
inherit (mods) system;
mod = import ./modules.nix gitrev packs mods;
src = ./.;
builder = ./builder.sh;
}
})
4 changes: 2 additions & 2 deletions fi/lmod/modules.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
gitrev: packs: mods:
# a simple modules.lua meta-module for adding modules
derivation {
derivation (packs.spackEnv // {
name = "modules.lua";
inherit (mods) system;
mods = "${mods}/${packs.platform}-${packs.os}-${packs.target}";
src = ./modules.lua;
git = gitrev;
builder = ./modules.sh;
}
})
15 changes: 8 additions & 7 deletions packs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ prefsUpdate = let
spackSrc = scalar;
spackConfig = lib.recursiveUpdate;
spackPython = scalar;
spackPath = scalar;
spackEnv = a: b: a // b;
nixpkgsSrc = scalar;
verbose = scalar;
repoPatch = a: b: a // b;
Expand All @@ -77,7 +77,9 @@ packsWithPrefs =
, spackSrc ? {}
, spackConfig ? {}
, spackPython ? "/usr/bin/python3"
, spackPath ? "/bin:/usr/bin"
, spackEnv ? {
PATH = "/bin:/usr/bin";
}
, nixpkgsSrc ? null
, repos ? [ ../spack/repo ]
, repoPatch ? {}
Expand All @@ -99,22 +101,21 @@ lib.fix (packs: with packs; {

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

inherit spackPython spackPath;
inherit spackPython spackEnv;
spackConfig = makeSpackConfig (lib.recursiveUpdate defaultSpackConfig packPrefs.spackConfig);

spackNixLib = derivation {
spackNixLib = derivation (spackEnv // {
name = "nix-spack-py";
inherit system;
builder = ../spack/install.sh;
src = ../spack/nixpack.py;
};
});

/* common attributes for running spack */
spackBuilder = attrs: builtins.removeAttrs (derivation ({
spackBuilder = attrs: builtins.removeAttrs (derivation (spackEnv // {
inherit (packs) system os spackConfig;
builder = spackPython;
PYTHONPATH = "${spackNixLib}:${spack}/lib/spack:${spack}/lib/spack/external";
PATH = spackPath;
LC_ALL = "en_US.UTF-8"; # work around spack bugs processing log files
repos = if attrs ? withRepos
then if attrs.withRepos
Expand Down
5 changes: 2 additions & 3 deletions packs/lmodCache.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
packs:
src:
derivation {
derivation (packs.spackEnv // {
inherit (packs) system;
name = "lmodCache";
builder = ./lmodCache.sh;
PATH = packs.spackPath;
lmod = packs.pkgs.lmod;
MODULEPATH = "${src}/${packs.platform}-${packs.os}-${packs.target}/Core";
}
})
2 changes: 1 addition & 1 deletion spack/bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EOF

}
gen > $out
/bin/chmod +x $out
chmod +x $out
3 changes: 2 additions & 1 deletion spack/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ packs: config: derivation ({
name = "spackConfig";
builder = ./config.sh;
sections = builtins.attrNames config;
} // builtins.mapAttrs (n: v: builtins.toJSON { "${n}" = v; }) config)
} // builtins.mapAttrs (n: v: builtins.toJSON { "${n}" = v; }) config
// packs.spackEnv)
2 changes: 1 addition & 1 deletion spack/config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh -eu

/bin/mkdir -p $out
mkdir -p $out
for section in $sections ; do
eval "echo \"\$$section\"" > $out/$section.yaml
done
4 changes: 2 additions & 2 deletions spack/install.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh -e
/bin/mkdir -p $out
/bin/cp $src $out/nixpack.py
mkdir -p $out
cp $src $out/nixpack.py

0 comments on commit 10d7976

Please sign in to comment.