diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 72768d09607d..da9dd0a18274 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -126,6 +126,8 @@ - `singularity-tools` have the `storeDir` argument removed from its override interface and use `builtins.storeDir` instead. +- Two build helpers in `singularity-tools`, i.e., `mkLayer` and `shellScript`, are deprecated, as they are no longer involved in image-building. Maintainers will remove them in future releases. + - The `budgie` and `budgiePlugins` scope have been removed and their packages moved into the top level scope (i.e., `budgie.budgie-desktop` is now `budgie-desktop`) diff --git a/pkgs/build-support/singularity-tools/default.nix b/pkgs/build-support/singularity-tools/default.nix index 010ed0db9fda..ef8ca167b336 100644 --- a/pkgs/build-support/singularity-tools/default.nix +++ b/pkgs/build-support/singularity-tools/default.nix @@ -5,8 +5,10 @@ runCommand, vmTools, writeClosure, + writers, writeScript, # Native build inputs + buildPackages, e2fsprogs, util-linux, # Build inputs @@ -19,27 +21,37 @@ let defaultSingularity = singularity; in rec { + # TODO(@ShamrockLee): Remove after Nixpkgs 24.11 branch-off. shellScript = - name: text: - writeScript name '' - #!${runtimeShell} - set -e - ${text} - ''; + lib.warn + "`singularity-tools.shellScript` is deprecated. Use `writeScript`, `writeShellScripts` or `writers.writeBash` instead." + ( + name: text: + writeScript name '' + #!${runtimeShell} + set -e + ${text} + '' + ); + # TODO(@ShamrockLee): Remove after Nixpkgs 24.11 branch-off. mkLayer = - { - name, - contents ? [ ], - # May be "apptainer" instead of "singularity" - projectName ? (singularity.projectName or "singularity"), - }: - runCommand "${projectName}-layer-${name}" { inherit contents; } '' - mkdir $out - for f in $contents ; do - cp -ra $f $out/ - done - ''; + lib.warn + "`singularity-tools.mkLayer` is deprecated, as it is no longer used to implement `singularity-tools.buildImages`." + ( + { + name, + contents ? [ ], + # May be "apptainer" instead of "singularity" + projectName ? (singularity.projectName or "singularity"), + }: + runCommand "${projectName}-layer-${name}" { inherit contents; } '' + mkdir $out + for f in $contents ; do + cp -ra $f $out/ + done + '' + ); buildImage = { @@ -53,8 +65,14 @@ rec { }: let projectName = singularity.projectName or "singularity"; - runAsRootFile = shellScript "run-as-root.sh" runAsRoot; - runScriptFile = shellScript "run-script.sh" runScript; + runAsRootFile = buildPackages.writers.writeBash "run-as-root.sh" '' + set -e + ${runAsRoot} + ''; + runScriptFile = writers.writeBash "run-script.sh" '' + set -e + ${runScript} + ''; result = vmTools.runInLinuxVM ( runCommand "${projectName}-image-${name}.sif" {