Change:
The derivation is missing the directory to work properly. Steps to reproduce the behavior: A clear and concise description of what you expected to happen. is output without error. This can be fixed by creating the directory manually (). I guess this could be to the derivation. <!-- Please @ people who are in the list of the offending package or module. If in doubt, check for whoever last touched something. -- Please run and paste the result.
NixOS module provides those top-level directories. discussed with one of the main Apptainer developer in . He think it should be easy to specify a directory that will always exist at build time. Regalding this, I'm considering the possibility to put those dilectories under the derivation store path. Not sure if there would be potential problem using a store path as a mount point, but it seems to work without problem.
Could you help me take a look at ?
If you have time, please help me test the PR . It should fundamentally solve this issue. If applied, you no longer need the NixOS module or just to run images. It specifies the LOCALSTATEDIR as , making both Apptainer and Sylabs SingularityCE works without . (The image running still depends on and to run images, which might be the final obstacle to build images as a package without invoking a virtual machine. Other than that, it should not be an issue for most users, as are available on most of the UNIX/UNIX-like systems.)
I removed (the temporary fix for this issue) and ran the following and it seems to work fine: Thank you for this fix!
Glad to hear that! Would you mind ? I've heard that committers tend to merge PRs getting two approvals.
Done!

Discussion:
- A new option was added to the virtualisation module that enables specifying explicitly named network interfaces in QEMU VMs. The existing `virtualisation.vlans` is still supported for cases where the name of the network interface is irrelevant. <ins> - Apptainer/Singularity now defaults to using `"$out/var/lib"` for the `LOCALSTATEDIR` configuration option instead of the top-level `"/var/lib"`. This change impacts the `SESSIONDIR` (container-run-time mount point) configuration, which is set to `$LOCALSTATEDIR/<apptainer or singularity>/mnt/session`. This detaches the packages from the top-level directory, rendering the NixOS module optional. The default behavior of the NixOS module `programs.singularity` stays unchanged. We add a new option `programs.singularity.enableExternalSysConfDir` (default to `true`) to specify whether to set the top-level `"/var/lib"` as `LOCALSTATEDIR` or not. </ins> - DocBook option documentation is no longer supported, all module documentation now uses markdown. - `buildGoModule` `go-modules` attrs have been renamed to `goModules`.

Use `lib.mkForce` to forcefully specify the overridden package. ''; }; <ins> enableExternalLocalStateDir = mkOption { type = types.bool; default = true; example = false; description = mdDoc '' Whether to use top-level directories as LOCALSTATEDIR instead of the store path ones. This affects the SESSIONDIR of Apptainer/Singularity. If set to true, the SESSIONDIR will become `/var/lib/''${projectName}/mnt/session`. ''; }; </ins> enableFakeroot = mkOption { type = types.bool; default = true;

config = mkIf cfg.enable { programs.singularity.packageOverriden = (cfg.package.override ( <del> optionalAttrs cfg.enableFakeroot { </del> <ins> optionalAttrs cfg.enableExternalLocalStateDir { externalLocalStateDir = "/var/lib"; } // optionalAttrs cfg.enableFakeroot { </ins> newuidmapPath = "/run/wrappers/bin/newuidmap"; newgidmapPath = "/run/wrappers/bin/newgidmap"; } // optionalAttrs cfg.enableSuid {

group = "root"; source = "${cfg.packageOverriden}/libexec/${cfg.packageOverriden.projectName}/bin/starter-suid.orig"; }; <del> systemd.tmpfiles.rules = [ </del> <ins> systemd.tmpfiles.rules = mkIf cfg.enableExternalLocalStateDir [ </ins> "d /var/lib/${cfg.packageOverriden.projectName}/mnt/session 0770 root root -" <del> "d /var/lib/${cfg.packageOverriden.projectName}/mnt/final 0770 root root -" "d /var/lib/${cfg.packageOverriden.projectName}/mnt/overlay 0770 root root -" "d /var/lib/${cfg.packageOverriden.projectName}/mnt/container 0770 root root -" "d /var/lib/${cfg.packageOverriden.projectName}/mnt/source 0770 root root -" </del> ]; };

, newuidmapPath ? null # Path to SUID-ed newgidmap executable , newgidmapPath ? null <ins> # External LOCALSTATEDIR , externalLocalStateDir ? null </ins> # Remove the symlinks to `singularity*` when projectName != "singularity" , removeCompat ? false # Workaround #86349

inherit enableSeccomp enableSuid <ins> externalLocalStateDir </ins> projectName removeCompat starterSuidPath

configureScript = "./mconfig"; configureFlags = [ <del> "--localstatedir=/var/lib" </del> <ins> "--localstatedir=${if externalLocalStateDir != null then externalLocalStateDir else "${placeholder "out"}/var/lib"}" </ins> "--runstatedir=/var/run" ] ++ lib.optional (!enableSeccomp) "--without-seccomp"

touch .${projectName}.d/env/94-appsbase.sh cd .. <del> mkdir -p /var/lib/${projectName}/mnt/{container,final,overlay,session,source} </del> <ins> mkdir -p /var/lib/${projectName}/mnt/session </ins> echo "root:x:0:0:System administrator:/root:/bin/sh" > /etc/passwd echo > /etc/resolv.conf TMPDIR=$(pwd -P) ${projectName} build $out ./img