diff --git a/tidepool/src/builders/foundation/basic.nix b/tidepool/src/builders/foundation/basic.nix index 7e769db..2c29974 100644 --- a/tidepool/src/builders/foundation/basic.nix +++ b/tidepool/src/builders/foundation/basic.nix @@ -71,81 +71,84 @@ in (lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system).package }/bin/bash"; - built = builtins.derivation (package.vars // { - inherit (package) name env; - inherit script system; + built = builtins.derivation ( + package.vars + // { + inherit (package) name env; + inherit script system; - __structuredAttrs = true; + __structuredAttrs = true; - outputs = builtins.attrNames (lib.packages.getOutputs package); + outputs = builtins.attrNames (lib.packages.getOutputs package); - SHELL = executable; + SHELL = executable; - PATH = - let - bins = lib.paths.bin ( - (lib.packages.dependencies.get dependencies.build) - ++ (lib.packages.dependencies.get dependencies.host) - ++ lib.lists.when (system == "i686-linux") [ - foundation.stage2-bash - foundation.stage2-coreutils - ] - ++ lib.lists.when (system == "x86_64-linux") [ - (lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "i686-linux" system).package - (lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "i686-linux" system).package - ] - ++ lib.lists.when (system != "i686-linux" && system != "x86_64-linux") [ - (lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system).package - (lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "x86_64-linux" system) - .package - ] + PATH = + let + bins = lib.paths.bin ( + (lib.packages.dependencies.get dependencies.build) + ++ (lib.packages.dependencies.get dependencies.host) + ++ lib.lists.when (system == "i686-linux") [ + foundation.stage2-bash + foundation.stage2-coreutils + ] + ++ lib.lists.when (system == "x86_64-linux") [ + (lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "i686-linux" system).package + (lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "i686-linux" system).package + ] + ++ lib.lists.when (system != "i686-linux" && system != "x86_64-linux") [ + (lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system).package + (lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "x86_64-linux" system) + .package + ] + ); + in + builtins.concatStringsSep ":" ( + [ bins ] ++ (lib.lists.when (package.env ? PATH) [ package.env.PATH ]) ); - in - builtins.concatStringsSep ":" ( - [ bins ] ++ (lib.lists.when (package.env ? PATH) [ package.env.PATH ]) - ); - builder = executable; + builder = executable; - args = [ - "-e" - (builtins.toFile "bash-builder.sh" '' - set -eEuo pipefail + args = [ + "-e" + (builtins.toFile "bash-builder.sh" '' + set -eEuo pipefail - if [[ -e $NIX_ATTRS_SH_FILE ]]; then - source "$NIX_ATTRS_SH_FILE"; - else - echo "Failed to find structuredAttrs" - exit 1 - fi + if [[ -e $NIX_ATTRS_SH_FILE ]]; then + source "$NIX_ATTRS_SH_FILE"; + else + echo "Failed to find structuredAttrs" + exit 1 + fi - export CONFIG_SHELL=$SHELL + export CONFIG_SHELL=$SHELL - # With structuredAttrs each output var must be exported manually - for outputName in "''${!outputs[@]}"; do - # Need to set $out=/nix/store... - export "$outputName=''${outputs[$outputName]}" - done + # With structuredAttrs each output var must be exported manually + for outputName in "''${!outputs[@]}"; do + # Need to set $out=/nix/store... + export "$outputName=''${outputs[$outputName]}" + done - # Also need to export vars - for envVar in "''${!env[@]}"; do - export "$envVar=''${env[$envVar]}" - done + # Also need to export vars + for envVar in "''${!env[@]}"; do + export "$envVar=''${env[$envVar]}" + done - # Normalize the NIX_BUILD_CORES variable. The value might be 0, which - # means that we're supposed to try and auto-detect the number of - # available CPU cores at run-time. - NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}" - if ((NIX_BUILD_CORES <= 0)); then - guess=$(nproc 2>/dev/null || true) - ((NIX_BUILD_CORES = guess <= 0 ? 1 : guess)) - fi - export NIX_BUILD_CORES + # Normalize the NIX_BUILD_CORES variable. The value might be 0, which + # means that we're supposed to try and auto-detect the number of + # available CPU cores at run-time. + NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}" + if ((NIX_BUILD_CORES <= 0)); then + guess=$(nproc 2>/dev/null || true) + ((NIX_BUILD_CORES = guess <= 0 ? 1 : guess)) + fi + export NIX_BUILD_CORES - eval "$script" - '') - ]; - }); + eval "$script" + '') + ]; + } + ); result = built // { inherit package;