diff options
author | Philip Taron | 2024-08-30 15:57:50 -0700 |
---|---|---|
committer | GitHub | 2024-08-30 15:57:50 -0700 |
commit | ef0bb1fc69f0b37330e5a116c415436dba6e5156 (patch) | |
tree | f2c1bff0f350de7096489f15abccea123eb2b275 /pkgs | |
parent | 9916dc8728aa5d36dd9907e4b1e86ee80c209ca0 (diff) | |
parent | 51ef09110bf8fd18aac9885ec746552ce69a3c42 (diff) |
singularity-tools: make runscript modifiable (#334826)
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/singularity-tools/default.nix | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/pkgs/build-support/singularity-tools/default.nix b/pkgs/build-support/singularity-tools/default.nix index 249c3c8c85f1..2a6716962879 100644 --- a/pkgs/build-support/singularity-tools/default.nix +++ b/pkgs/build-support/singularity-tools/default.nix @@ -5,8 +5,9 @@ runCommand, vmTools, writeClosure, - writers, + writeDirectReferencesToFile, writeScript, + writeStringReferencesToFile, # Native build inputs buildPackages, e2fsprogs, @@ -69,10 +70,16 @@ lib.makeExtensible (final: { set -e ${runAsRoot} ''; - runScriptFile = writers.writeBash "run-script.sh" '' + runScriptFile = writeScript "run-script.sh" '' + #!/bin/sh set -e ${runScript} ''; + runScriptReferences = + if builtins ? getContext then + lib.splitString "\n" (writeStringReferencesToFile runScriptFile.text).text + else + [ (writeDirectReferencesToFile runScriptFile) ]; result = vmTools.runInLinuxVM ( runCommand "${projectName}-image-${name}.sif" { @@ -82,13 +89,7 @@ lib.makeExtensible (final: { util-linux ]; strictDeps = true; - layerClosure = writeClosure ( - [ - bashInteractive - runScriptFile - ] - ++ contents - ); + layerClosure = writeClosure ([ bashInteractive ] ++ runScriptReferences ++ contents); preVM = vmTools.createEmptyImage { size = diskSize; fullName = "${projectName}-run-disk"; @@ -134,12 +135,14 @@ lib.makeExtensible (final: { done done - # Create runScript and link shell + # Link /bin/sh if [ ! -e bin/sh ]; then ln -s ${lib.getExe bashInteractive} bin/sh fi mkdir -p .singularity.d - ln -s ${runScriptFile} .singularity.d/runscript + + # Create runscript + cp "${runScriptFile}" .singularity.d/runscript # Fill out .singularity.d mkdir -p .singularity.d/env |