Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runInLinuxVM: fix createEmptyImage/preVM case #358705

Merged
merged 2 commits into from
Nov 24, 2024
Merged

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Nov 24, 2024

When this is used, the existance of $out is assumed, however this is not the case for structured attrs. This PR adds that.

Also, an obsolete, broken rmdir is removed from apptainer.tests.image-hello-cowsay.

Follows up on #354535.

cc @ShamrockLee @wolfgangwalther

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Copy link
Contributor

@wolfgangwalther wolfgangwalther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm this fixes it, however not directly for the reason we assumed ($out). Consider this:

nix-build -E 'with import ./. {}; vmTools.runInLinuxVM (hello.overrideAttrs { __structuredAttrs = false; preVM = "exit 1"; })'

This is without structuredAttrs and will fail as expected.

But, before this PR:

nix-build -E 'with import ./. {}; vmTools.runInLinuxVM (hello.overrideAttrs { __structuredAttrs = true; preVM = "exit 1"; })'

The same with structuredAttrs will not fail - because $preVM is not even set. Thus, it will just happily proceed.

After this PR, this will fail as expected.

Thus, you might want to adjust the commit message slightly.

This is required for `preVM` which can be arbitrary code: e.g.
`vmTools.createEmptyImage` assumes the presence of `$out` in its default
configuration.

Also, before this patch, `preVM` wasn't even set in the
`__structuredAttrs` case.
@Ma27
Copy link
Member Author

Ma27 commented Nov 24, 2024

Added a note to the commit message.

@Ma27 Ma27 merged commit 626d3e4 into NixOS:master Nov 24, 2024
16 of 17 checks passed
@Ma27 Ma27 deleted the fix-runInLinuxVM branch November 24, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants