RFD: Remove recursive-nix
#767
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
8 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#767
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We want to remove the
recursive-nix
experimental feature and all associated code. Recursive Nix is a feature where the derivation builder creates a Nix daemon socket that through a complex series of operations which is running against the host Nix store. The purpose of this is that you can do nix evaluations and nix builds inside of a derivation and have the results appear in the outer nix store.It's used for dynamic derivations, where a derivation produces a build plan which references other store paths, which currently have to use recursive-nix to create said store paths. This is not the final design and CppNix is driving the dev process of dyndrvs, not us; it would be replaced with varlink or something else before stabilization.
Here's why:
recursive-nix
, so there is no compat hazard to removing it except for people who are trying to do dyndrvs on lix (haven't heard of anyone).Is anyone using recursive-nix on Lix? What are you using it for? Is there some way that we can accommodate your use case?
CL: https://gerrit.lix.systems/c/lix/+/2872
This issue was mentioned on Gerrit on the following CLs:
recursive-nix
")recursive-nix
")considering that it's still disabled as it is on CppNix, and even if it wasn't it's still probably bugged, honestly we could remove both at this point. Bit of a hot take though, but I suspect we'll want to do something different for dyndrvs anyway.
recursive nix has been such a huge pain in our tail for anything async-related, it isn't (can't be?) implemented an platforms that aren't linux without completely disabling the sandbox (and thus invalidating the entire concept). let's get rid of it.
For me it's always a this (recursive-nix) feature looks interesting, and somehow teaching tools to create smaller derivation to cache through nix derivations sounds interesting. But never actually used it as there is not really tooling around it and so never got around to it. So sad to see it go, but also will not actually miss anything
Since I'm not very active in community spaces I only noticed this because my pipelines against Lix main started failing all of a sudden, so I don't really know where else to ask; with the removal of this feature is there still a way to run tools like nix-diff (generally everything that has to query the store to produce its output) inside a derivation?
I've been using this for a while now with recursive-nix to diff two
.drv
s, which I did struggle to emulate otherwise before opting for recursive-nix.yes, you can use --store local or NIX_REMOTE=local or similar, theoretically, which should convince the lix to not try the daemon. i haven't tested this though. it might blow up for bad reasons.
nixos itself uses nix in the sandbox with a store to build its option docs:
3afc8f4712/nixos/modules/misc/documentation.nix (L131)
Thanks everyone for the input.
After taking a stab at it again I remember what wall I ran into back then; while nix-diff seems to work just fine without recursive-nix (as long as you throw it against the
.drv
files directly), nvd calls the Nix CLI to query about references. Since /nix/var doesn't exist to begin with thore are parts of the tooling which fall face flat with EPERM trying to create it, and bending NIX_STATE_DIR yields a writable but empty storedb giving either "not in store" or "invalid" for the store paths and their.drv
files respectively.Moving the entire NIX_STORE_DIR as per № 3 of the OP of course would mean rebuilding which is not feasible in that scenario.
So the workaround for all of this is a mix of direct
.drv
files for nix-diff and loading the store path from the closure info in the same way NixOS ISO/squashfs builds rebuild the store from the closure info paths embedded in the squashfs for nvd (though I guess this'd also work for nix-diff.…?).(just in case anyone opens this issue trying to achieve something similar; using NIX_STATE_DIR and
nix-store --load-db
should be able to get you most of the way for a lot of applications)With this change I can actually rip recursive-nix out of my cursed setup making it ever so slightly less cursed.
Thanks everyone.
This was finally done, feel free to comment after this issue is closed if you want to add your remarks. We are aware of a distribution in https://discourse.nixos.org/t/opinionated-patchset-with-recursive-nix-planned-for-lix/63494 that plans to offer
recursive-nix
back.Check them out if you really need that feature on the top of Lix.
I'm in the process of switching my organization over to lix now, and we a have been actively using recursive-nix. We evaluate a large number of configurations in CI to check that they still evaluate for a PR and I was using recursive-nix to offload that work to our farm of remote builders, in a way that integrates nicely with our CI and it simplifies managing resources on our builders because it just uses build slots like everything else.
@bacchanalia wrote in #767 (comment):
I'm not deeply familiar with your CI system, but would you know why one of the following two options are not feasible in your case:
nix build
in the entrypoint of your CI so that you only run the innernix build
wrapped in the derivations?/etc/nix/nix.conf
pointing to the Nix's ambient daemon so that you can runnix build
inside will reuse the parent daemon socket, this is similar to whatrecursive-nix
does without all the store paths restriction and special casing that you do not seem to be usingLet us know if we are still missing a story in our understanding of your usage.
@raito I was trying to get eval working within a build by exposing the socket to the sandbox as you suggested, but I'm getting
error: creating directory '/nix/var': Permission denied
even if I include all the way up to/nix/var
as an extra-sandbox-path.(also, I'm not sure what you mean by the first suggestion?)
/nix/var should be something that's overridable by environment variable, check the hastily written environment variable list in testing.md
I managed to get it working after removing the group check in daemon.cc, setting
noChroot = true;
on the derivation. I was unable to get it to work withextra-sandbox-paths
, I think due to paths required for eval not being available in the chroot.