diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-07-08 12:01:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 12:01:04 +0000 |
commit | 3ab86b3cfac7bcecf031f1e9b8ef312a7540a2c1 (patch) | |
tree | 813e71a23d95c5b28fc7c2b6b8dcdcaac911c9e1 /pkgs/build-support | |
parent | cc1af72ece3d6cc4143a6941016e08acd93091e0 (diff) | |
parent | 49413e25e09cb35cde536087daebc542f3f34d72 (diff) |
Merge master into staging-next
Diffstat (limited to 'pkgs/build-support')
4 files changed, 56 insertions, 30 deletions
diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix index 2d927c7df7317..3e6fc922906f9 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix @@ -12,6 +12,7 @@ , profile ? "" , targetPkgs ? pkgs: [] , multiPkgs ? pkgs: [] +, multiArch ? false # Whether to include 32bit packages , extraBuildCommands ? "" , extraBuildCommandsMulti ? "" , extraOutputsToInstall ? [] @@ -35,8 +36,8 @@ let inherit (stdenv) is64bit; - # use of glibc_multi is only supported on x86_64-linux - isMultiBuild = multiPkgs != null && stdenv.isx86_64 && stdenv.isLinux; + # "use of glibc_multi is only supported on x86_64-linux" + isMultiBuild = multiArch && stdenv.system == "x86_64-linux"; isTargetBuild = !isMultiBuild; # list of packages (usually programs) which are only be installed for the @@ -51,21 +52,34 @@ let # these match the host's architecture, glibc_multi is used for multilib # builds. glibcLocales must be before glibc or glibc_multi as otherwiese # the wrong LOCALE_ARCHIVE will be used where only C.UTF-8 is available. - basePkgs = with pkgs; - [ glibcLocales - (if isMultiBuild then glibc_multi else glibc) - (toString gcc.cc.lib) bashInteractiveFHS coreutils less shadow su - gawk diffutils findutils gnused gnugrep - gnutar gzip bzip2 xz - ]; - baseMultiPkgs = with pkgsi686Linux; - [ (toString gcc.cc.lib) - ]; + basePkgs = with pkgs; [ + glibcLocales + (if isMultiBuild then glibc_multi else glibc) + (toString gcc.cc.lib) + bashInteractiveFHS + coreutils + less + shadow + su + gawk + diffutils + findutils + gnused + gnugrep + gnutar + gzip + bzip2 + xz + ]; + baseMultiPkgs = with pkgsi686Linux; [ + (toString gcc.cc.lib) + ]; ldconfig = writeShellScriptBin "ldconfig" '' # due to a glibc bug, 64-bit ldconfig complains about patchelf'd 32-bit libraries, so we're using 32-bit ldconfig - exec ${if stdenv.isx86_64 && stdenv.isLinux then pkgsi686Linux.glibc.bin else pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@" + exec ${if stdenv.system == "x86_64-linux" then pkgsi686Linux.glibc.bin else pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@" ''; + etcProfile = writeText "profile" '' export PS1='${name}-chrootenv:\u@\h:\w\$ ' export LOCALE_ARCHIVE='/usr/lib/locale/locale-archive' @@ -104,7 +118,7 @@ let # Compose /etc for the chroot environment etcPkg = runCommandLocal "${name}-chrootenv-etc" { } '' mkdir -p $out/etc - cd $out/etc + pushd $out/etc # environment variables ln -s ${etcProfile} profile @@ -172,13 +186,18 @@ let ln -s lib64 lib # copy glibc stuff - cp -rsHf ${staticUsrProfileTarget}/lib/32/* lib32/ && chmod u+w -R lib32/ + cp -rsHf ${staticUsrProfileTarget}/lib/32/* lib32/ + chmod u+w -R lib32/ # copy content of multiPaths (32bit libs) - [ -d ${staticUsrProfileMulti}/lib ] && cp -rsHf ${staticUsrProfileMulti}/lib/* lib32/ && chmod u+w -R lib32/ + if [ -d ${staticUsrProfileMulti}/lib ]; then + cp -rsHf ${staticUsrProfileMulti}/lib/* lib32/ + chmod u+w -R lib32/ + fi # copy content of targetPaths (64bit libs) - cp -rsHf ${staticUsrProfileTarget}/lib/* lib64/ && chmod u+w -R lib64/ + cp -rsHf ${staticUsrProfileTarget}/lib/* lib64/ + chmod u+w -R lib64/ # symlink 32-bit ld-linux.so ln -Ls ${staticUsrProfileTarget}/lib/32/ld-linux.so.2 lib/ @@ -191,13 +210,15 @@ let # the target profile is the actual profile that will be used for the chroot setupTargetProfile = '' mkdir -m0755 usr - cd usr + pushd usr + ${setupLibDirs} - ${lib.optionalString isMultiBuild '' + + '' + lib.optionalString isMultiBuild '' if [ -d "${staticUsrProfileMulti}/share" ]; then cp -rLf ${staticUsrProfileMulti}/share share fi - ''} + '' + '' if [ -d "${staticUsrProfileTarget}/share" ]; then if [ -d share ]; then chmod -R 755 share @@ -223,18 +244,19 @@ let ln -s "$i" fi done + + popd ''; in runCommandLocal "${name}-fhs" { passthru = { - inherit args multiPaths targetPaths; + inherit args multiPaths targetPaths ldconfig; }; } '' mkdir -p $out - cd $out + pushd $out + ${setupTargetProfile} - cd $out ${extraBuildCommands} - cd $out ${lib.optionalString isMultiBuild extraBuildCommandsMulti} '' diff --git a/pkgs/build-support/node/build-npm-package/default.nix b/pkgs/build-support/node/build-npm-package/default.nix index 1c3fb6a74efca..357a0bd073228 100644 --- a/pkgs/build-support/node/build-npm-package/default.nix +++ b/pkgs/build-support/node/build-npm-package/default.nix @@ -22,7 +22,7 @@ , npmBuildScript ? "build" # Flags to pass to all npm commands. , npmFlags ? [ ] - # Flags to pass to `npm ci` and `npm prune`. + # Flags to pass to `npm ci`. , npmInstallFlags ? [ ] # Flags to pass to `npm rebuild`. , npmRebuildFlags ? [ ] @@ -30,6 +30,10 @@ , npmBuildFlags ? [ ] # Flags to pass to `npm pack`. , npmPackFlags ? [ ] + # Flags to pass to `npm prune`. +, npmPruneFlags ? npmInstallFlags + # Value for npm `--workspace` flag and directory in which the files to be installed are found. +, npmWorkspace ? null , ... } @ args: diff --git a/pkgs/build-support/node/build-npm-package/hooks/npm-build-hook.sh b/pkgs/build-support/node/build-npm-package/hooks/npm-build-hook.sh index b712e3a0543a2..c341f672363a4 100644 --- a/pkgs/build-support/node/build-npm-package/hooks/npm-build-hook.sh +++ b/pkgs/build-support/node/build-npm-package/hooks/npm-build-hook.sh @@ -14,7 +14,7 @@ npmBuildHook() { exit 1 fi - if ! npm run "$npmBuildScript" $npmBuildFlags "${npmBuildFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}"; then + if ! npm run ${npmWorkspace+--workspace=$npmWorkspace} "$npmBuildScript" $npmBuildFlags "${npmBuildFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}"; then echo echo 'ERROR: `npm build` failed' echo diff --git a/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh b/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh index 4282419d5d6b7..b17fb552cc6b5 100644 --- a/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh +++ b/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh @@ -13,8 +13,8 @@ npmInstallHook() { while IFS= read -r file; do local dest="$packageOut/$(dirname "$file")" mkdir -p "$dest" - cp "$file" "$dest" - done < <(@jq@ --raw-output '.[0].files | map(.path) | join("\n")' <<< "$(npm pack --json --dry-run $npmPackFlags "${npmPackFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}")") + cp "${npmWorkspace-.}/$file" "$dest" + done < <(@jq@ --raw-output '.[0].files | map(.path) | join("\n")' <<< "$(npm pack --json --dry-run ${npmWorkspace+--workspace=$npmWorkspace} $npmPackFlags "${npmPackFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}")") while IFS=" " read -ra bin; do mkdir -p "$out/bin" @@ -22,13 +22,13 @@ npmInstallHook() { done < <(@jq@ --raw-output '(.bin | type) as $typ | if $typ == "string" then .name + " " + .bin elif $typ == "object" then .bin | to_entries | map(.key + " " + .value) | join("\n") - else "invalid type " + $typ | halt_error end' package.json) + else "invalid type " + $typ | halt_error end' "${npmWorkspace-.}/package.json") local -r nodeModulesPath="$packageOut/node_modules" if [ ! -d "$nodeModulesPath" ]; then if [ -z "${dontNpmPrune-}" ]; then - npm prune --omit dev --no-save $npmInstallFlags "${npmInstallFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}" + npm prune --omit=dev --no-save ${npmWorkspace+--workspace=$npmWorkspace} $npmPruneFlags "${npmPruneFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}" fi find node_modules -maxdepth 1 -type d -empty -delete |