From 10d79762f4d3bc995158c8ae5aaf9c1ceccb6a0f Mon Sep 17 00:00:00 2001 From: Dylan Simon Date: Sun, 16 Jan 2022 15:22:53 -0500 Subject: [PATCH] avoid hard-coded /bin paths based in part on #8 and addressing part of #10 --- default.nix | 4 +++- fi/default.nix | 4 +++- fi/lmod/builder.sh | 6 +++--- fi/lmod/default.nix | 4 ++-- fi/lmod/modules.nix | 4 ++-- packs/default.nix | 15 ++++++++------- packs/lmodCache.nix | 5 ++--- spack/bin.sh | 2 +- spack/config.nix | 3 ++- spack/config.sh | 2 +- spack/install.sh | 4 ++-- 11 files changed, 29 insertions(+), 24 deletions(-) diff --git a/default.nix b/default.nix index a641f9d..190bc0f 100644 --- a/default.nix +++ b/default.nix @@ -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. */ diff --git a/fi/default.nix b/fi/default.nix index c01e340..602f73c 100644 --- a/fi/default.nix +++ b/fi/default.nix @@ -33,7 +33,9 @@ corePacks = import ../packs { }; }; spackPython = "/usr/bin/python3"; - spackPath = "/bin:/usr/bin"; + spackEnv = { + PATH = "/bin:/usr/bin"; + }; nixpkgsSrc = { /* -------- upstream nixpkgs version -------- */ diff --git a/fi/lmod/builder.sh b/fi/lmod/builder.sh index 49e76a6..c00cb1e 100755 --- a/fi/lmod/builder.sh +++ b/fi/lmod/builder.sh @@ -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 diff --git a/fi/lmod/default.nix b/fi/lmod/default.nix index 936bfc8..66d6cbc 100644 --- a/fi/lmod/default.nix +++ b/fi/lmod/default.nix @@ -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; -} +}) diff --git a/fi/lmod/modules.nix b/fi/lmod/modules.nix index e6206b1..bdc2d91 100644 --- a/fi/lmod/modules.nix +++ b/fi/lmod/modules.nix @@ -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; -} +}) diff --git a/packs/default.nix b/packs/default.nix index c7a9a64..3b55a58 100644 --- a/packs/default.nix +++ b/packs/default.nix @@ -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; @@ -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 ? {} @@ -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 diff --git a/packs/lmodCache.nix b/packs/lmodCache.nix index e5ca70e..71e8120 100644 --- a/packs/lmodCache.nix +++ b/packs/lmodCache.nix @@ -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"; -} +}) diff --git a/spack/bin.sh b/spack/bin.sh index ec0e904..16e565a 100755 --- a/spack/bin.sh +++ b/spack/bin.sh @@ -21,4 +21,4 @@ EOF } gen > $out -/bin/chmod +x $out +chmod +x $out diff --git a/spack/config.nix b/spack/config.nix index b17a9b8..93edd0f 100644 --- a/spack/config.nix +++ b/spack/config.nix @@ -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) diff --git a/spack/config.sh b/spack/config.sh index 5ed8dc9..5b16205 100755 --- a/spack/config.sh +++ b/spack/config.sh @@ -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 diff --git a/spack/install.sh b/spack/install.sh index 9c3aeb7..c67802b 100755 --- a/spack/install.sh +++ b/spack/install.sh @@ -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