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

Test nested sandboxing, and make nicer error #8696

Merged
merged 1 commit into from
Jul 14, 2023

Conversation

cidkidnix
Copy link
Contributor

Motivation

We were bedeviled by sandboxing issues when working on the layered store. The problem ended up being that when we have nested nix builds, and the inner store is inside the build dir (e.g. store is /build/nix-test/$name/store, build dir is /build) bind mounts clobber each other and store paths cannot be found.

After thoroughly cleaning up local-derivation-goal.cc, we might be able to make that work. But that is a lot of work. For now, we just fail earlier with a proper error message.

Finally, test this: nested sandboxing without the problematic store dir should work, and with should fail with the expected error message.

Context

Came from work on NixOS/rfcs#152, but not actually part of that feature, good to merge either way.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Jul 13, 2023
src/libstore/build/local-derivation-goal.cc Outdated Show resolved Hide resolved
tests/nested-sandboxing.sh Show resolved Hide resolved
local storeFun=$1
local count=$2
nix-build \
--no-substitute --no-out-link \
Copy link
Member

Choose a reason for hiding this comment

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

OT: nix should detect that it's in the non-FOD sandbox and turn these things off by itself.

We were bedeviled by sandboxing issues when working on the layered
store. The problem ended up being that when we have nested nix builds,
and the inner store is inside the build dir (e.g. store is
`/build/nix-test/$name/store`, build dir is `/build`) bind mounts
clobber each other and store paths cannot be found.

After thoroughly cleaning up `local-derivation-goal.cc`, we might be
able to make that work. But that is a lot of work. For now, we just fail
earlier with a proper error message.

Finally, test this: nested sandboxing without the problematic store dir
should work, and with should fail with the expected error message.

Co-authored-by: Dylan Green <[email protected]>
Co-authored-by: Robert Hensing <[email protected]>
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

🐰 ⬇️ 🕳️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
with-tests Issues related to testing. PRs with tests have some priority
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants