Skip to content

libstore: use pasta for FODs if available#15959

Open
lisanna-dettwyler wants to merge 1 commit into
masterfrom
pasta
Open

libstore: use pasta for FODs if available#15959
lisanna-dettwyler wants to merge 1 commit into
masterfrom
pasta

Conversation

@lisanna-dettwyler

Copy link
Copy Markdown
Contributor

Motivation

This allows using a userspace program, pasta, to handle comms between the build sandbox, and the outside world; allowing for full isolation including the network namespace, closing the "fixed-output derivation talks to the host over an abstract domain socket" hole for good.

Context

Prior branch: https://github.com/NixOS/nix/tree/pasta-old
Lix implementation: https://git.lix.systems/lix-project/lix/commit/a959290f4


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

This allows using a userspace program, pasta, to handle comms between
the build sandbox, and the outside world; allowing for full isolation
including the network namespace, closing the "fixed-output derivation
talks to the host over an abstract domain socket" hole for good.

Co-authored-by: Puck Meerburg <puck@puckipedia.com>
Co-authored-by: eldritch horrors <pennae@lix.systems>
Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
Signed-off-by: Lisanna Dettwyler <lisanna.dettwyler@gmail.com>
@github-actions github-actions Bot added the with-tests Issues related to testing. PRs with tests have some priority label Jun 2, 2026

@ysndr ysndr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Been curious and left some thoughts.

nsInSandbox += fmt("nameserver %s\n", PASTA_HOST_IPV6);
}
return std::regex_replace(fromHost, lineRegex, "") + nsInSandbox;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this appears unused?
https://github.com/NixOS/nix/pull/15959/changes#diff-51cde72b51cf1ba7c7759e7e43654bed525b3db1d382ec9f41ecabd1add6a76aR657 calls pasta::rewriteResolvConf nothing calls this method.

"--quiet",
"--config-net",
"--gateway", PASTA_HOST_IPV4,
"--address", PASTA_CHILD_IPV4, "--netmask", PASTA_IPV4_NETMASK,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe?

Suggested change
"--address", PASTA_CHILD_IPV4, "--netmask", PASTA_IPV4_NETMASK,
"--address", PASTA_CHILD_IPV4,
"--netmask", PASTA_IPV4_NETMASK,


AutoCloseFD userns;
if (usingUserNamespace) {
userns = AutoCloseFD(open(fmt("/proc/%i/ns/user", pid).c_str(), O_RDONLY | O_CLOEXEC));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

question: if this ought to be stdout, why doesnt this need to be opened writable?

Comment on lines +62 to +68
/**
* Kill the pasta process.
*
* @param pastaPid The pasta process to kill
* @throws Error if pasta exits with unexpected status
*/
void killPasta(Pid & pastaPid);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this remain unimplemented?

Comment on lines +45 to +50
/**
* Wait for pasta to set up the network interface.
*
* @throws Error if the interface doesn't appear within the timeout period
*/
void waitForPastaInterface();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this remain unimplemented?

Comment on lines 147 to +153
// Output = error code + "standard out" output stream
std::pair<int, std::string> runProgram(RunOptions && options);

void runProgram2(const RunOptions & options);

Pid startProgram(const RunOptions & options, std::shared_ptr<Pipe> out);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Question: Is it generally considered trivial what these do internally?
specifically startProgram also seems to gain error cases for dup'ing and handling CAPs.


// we do the capability dance like this to avoid a dependency
// on libcap, which has a rather large build closure and many
// more features that we need for now. maybe some other time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// more features that we need for now. maybe some other time.
// more features than we need for now. maybe some other time.

Comment on lines +122 to +126
PASTA_COUNT_BEFORE=$(pgrep -c pasta || echo 0)
NIX_CONFIG="pasta-path = $PASTA_PATH
sandbox-paths = $NIX_SANDBOX_PATHS" \
nix-build pasta-cleanup-test.nix --no-out-link
PASTA_COUNT_AFTER=$(pgrep -c pasta || echo 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this potentially flaky on a machine using pasta, outside of this test process?
I imagine more so once this PR lands and FODs are built with pasta in the background.

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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants