1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-27 11:36:29 +03:00

apptainer, singularity: prioritize original defaultPath

Prefix the upstream-given defalutPath value over the one constructed by
defaultPathInputs.

Make SUID'ed binaries searchable out-of-the-box non-NixOS platforms.
This commit is contained in:
Yueh-Shun Li 2024-04-24 04:05:24 +08:00
parent df2577c6a4
commit 409cbbe61a

View file

@ -196,8 +196,9 @@ in
# causes redefinition of _FORTIFY_SOURCE # causes redefinition of _FORTIFY_SOURCE
hardeningDisable = [ "fortify3" ]; hardeningDisable = [ "fortify3" ];
# Packages to prefix to the Apptainer/Singularity container runtime default PATH # Packages to provide fallback bin paths
# Use overrideAttrs to override # to the Apptainer/Singularity container runtime default PATHs.
# Override with `<pkg>.overrideAttrs`.
defaultPathInputs = [ defaultPathInputs = [
bash bash
coreutils coreutils
@ -228,7 +229,7 @@ in
lib.concatStringsSep " " [ lib.concatStringsSep " " [
"--replace-fail" "--replace-fail"
(addShellDoubleQuotes (lib.escapeShellArg originalDefaultPath)) (addShellDoubleQuotes (lib.escapeShellArg originalDefaultPath))
(addShellDoubleQuotes ''$inputsDefaultPath''${inputsDefaultPath:+:}${lib.escapeShellArg originalDefaultPath}'') (addShellDoubleQuotes ''${lib.escapeShellArg originalDefaultPath}''${inputsDefaultPath:+:}$inputsDefaultPath'')
] ]
) originalDefaultPaths ) originalDefaultPaths
} }
@ -267,8 +268,10 @@ in
postFixup = '' postFixup = ''
substituteInPlace "$out/bin/run-singularity" \ substituteInPlace "$out/bin/run-singularity" \
--replace "/usr/bin/env ${projectName}" "$out/bin/${projectName}" --replace "/usr/bin/env ${projectName}" "$out/bin/${projectName}"
# Respect PATH from the environment/the user.
# Fallback to bin paths provided by Nixpkgs packages.
wrapProgram "$out/bin/${projectName}" \ wrapProgram "$out/bin/${projectName}" \
--prefix PATH : "$inputsDefaultPath" --suffix PATH : "$inputsDefaultPath"
# Make changes in the config file # Make changes in the config file
${lib.optionalString forceNvcCli '' ${lib.optionalString forceNvcCli ''
substituteInPlace "$out/etc/${projectName}/${projectName}.conf" \ substituteInPlace "$out/etc/${projectName}/${projectName}.conf" \