Skip to content

nixos-container: use chattr from e2fsprogs - #574683

Merged
numinit merged 1 commit into
NixOS:masterfrom
extra-container:nixos-container-chattr
Nov 1, 2026
Merged

numinit merged 1 commit into
NixOS:masterfrom
extra-container:nixos-container-chattr

Conversation

@stevelr

@stevelr stevelr commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

nixos-container destroy runs chattr -i on the container's immutable /var/empty before removing the container directory, but got chattr from user's PATH and ignored failures. On systems without e2fsprogs (e.g. systems without ext filesystems that use systemd in stage 1), the immutable flag was not removed and destroy left the container directory behind:

rm: cannot remove '/var/lib/nixos-containers/demo/var/empty': Operation not permitted

Refer to chattr by store path, like nsenter and su.

Reported in extra-container/extra-container#4

Things done

`nixos-container destroy` runs `chattr -i` on the container's immutable
/var/empty before removing the container directory, but looked up chattr
in PATH and ignored failures. On systems without e2fsprogs (e.g. systems
without ext filesystems that use systemd in stage 1), the immutable flag
was not removed and destroy left the container directory behind:

  rm: cannot remove '/var/lib/nixos-containers/demo/var/empty': Operation not permitted

Refer to chattr by store path, like nsenter and su.

Reported in extra-container/extra-container#4

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: stevelr <[email protected]>
@nixpkgs-ci nixpkgs-ci Bot added 12.first-time contribution This PR is the author's first one; please be gentle! 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! labels Oct 16, 2026
@stevelr

stevelr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Testing note: I ran nix-build -A nixos-container.passthru.tests x86_64-linux:
containers-imperative, containers-ipv4-ipv6, containers-tmpfs, containers-ephemeral and
containers-unified-hierarchy all pass, however, the test VMs have e2fsprogs installed, so they
don't reproduce the bug.

I reproduced it and verified the fix with a VM test for extra-container that removes e2fsprogs from the system: extra-container/extra-container#4

@nixpkgs-ci nixpkgs-ci Bot removed the 12.first-time contribution This PR is the author's first one; please be gentle! label Oct 17, 2026
@GraysonTinker GraysonTinker added the 6.topic: nixos-container Imperative and declarative systemd-nspawn containers label Oct 18, 2026
@msgilligan msgilligan added this to the 26.11 milestone Nov 1, 2026
@nixpkgs-ci nixpkgs-ci Bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Nov 1, 2026
@numinit

numinit commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Looks simple enough.

@numinit
numinit added this pull request to the merge queue Nov 1, 2026
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Nov 1, 2026
Merged via the queue into NixOS:master with commit 854a8c3 Nov 1, 2026
37 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos-container Imperative and declarative systemd-nspawn containers 7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants