Subject: bug#71674: guix pack: Cannot pass environment variables via apptainer

From: Lars Bilke <[email-masked]>
Date: Thu, 20 Jun 2024 13:36:57 +0200

I have created a squashfs image with e.g.

guix pack --format=squashfs bash coreutils

Then I run this image with apptainer / singularity and want to pass environment variables like this:

APPTAINERENV_VAR1=FOO apptainer exec --env "VAR2=BAR" /gnu/store/v27n3gwdl3hn01bmm1ad4z1jkw51cz1r-bash-coreutils-squashfs-pack.gz.squashfs env

Both VAR1 and VAR2 do not show up in the container but they should.

Passing regular environment varialbles work:

VAR3=BAZ APPTAINERENV_VAR1=FOO apptainer exec --env "VAR2=BAR" /gnu/store/v27n3gwdl3hn01bmm1ad4z1jkw51cz1r-bash-coreutils-squashfs-pack.gz.squashfs env
...
VAR3=BAZ
...

Any idea how to fix that? As I understand these variables are directly passed to the process (https://github.com/apptainer/apptainer/blob/317123280e39abcefb309716c07e0af85edbad88/internal/pkg/runtime/engine/apptainer/process_linux.go#L646 and https://github.com/apptainer/apptainer/blob/main/internal/pkg/runtime/engine/config/oci/generate/generate.go#L98) so they should work.

Thanks,
Lars