singularity-tools: deprecate build helpers mkLayer and shellScript

Deprecate singularity-tools.mkLayer and singularity-tools.shellScript,
for they are no longer related to image building.

Use writers.writeBash instead of singularity-tools.shellScript.
This commit is contained in:
Yueh-Shun Li 2024-08-05 16:36:56 +08:00
parent d3692ddf54
commit a1318915d3
2 changed files with 40 additions and 20 deletions

View File

@ -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`)

View File

@ -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"
{