-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add 'store add-gc-root' command to manually add indirect roots #11505
base: master
Are you sure you want to change the base?
Conversation
src/nix/add-root.md
Outdated
```console | ||
$ readlink foo | ||
/nix/store/xxx | ||
$ nix add-root foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intuitively I would have expected such as subcommand here:
$ nix add-root foo | |
$ nix store add-gc-root foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to add it in nix gc add-root
, but nix gc
seems mostly unused and intended to start a gc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently don't have a top-level nix gc
subcommand group, but a nix store gc
command.
To help keep some consistency between commands, the subcommands are ideally nix <noun> <verb>
with the exception of a small number of frequently used commands.
gc
is a verb, since the "garbage" part is subordinate to the "collect" part (as a noun adjunct to be technical).
Since our commands end in verbs, this would create the expectation that nix gc
is not a subcommand group, but a single action.
I think nix store add-root
would be ok, but perhaps nix store add-gc-root
would be better, as I think the hint about gc would be welcomed when reading scripts that call this command.
Interactive use should not be common, because that would usually come after nix build
, which already produces a root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who makes final decisions about that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nix team members, I would say. Often happens in those regular meetings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we discussed this during the meeting:
Our question: Does the nix build
command work for you instead of this nix store add-gc-root
?
It also works with store paths, but also with installables:
$ nix build --out-link /tmp/result /nix/store/yb84nwgvixzi9sx9nxssq581pc0cc8p3-hello-2.12.1
$ ls -la /tmp/result
lrwxrwxrwx joerg users 56 B now /tmp/result@ ⇒ /nix/store/yb84nwgvixzi9sx9nxssq581pc0cc8p3-hello-2.12.1
The advantage of adding gcroot in general as part of the build is that it race-free.
Changed name, added tests. |
Triaged in Nix meeting 181: We think that by improving the documentation we can solve the problem of the discoverability of the @layus, are you aware of a use case that is not already covered by |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-09-25-nix-team-meeting-minutes-181-180/52712/1 |
@roberth I should have been more explicit, but the whole point of #7138 is to add gc roots for .drv files themselves. There is currently no way to do that at all. Of course #11506 would be a cleaner solution, but I think this one can still be useful in many a case. If only because it is very fast and efficient. |
Ah, you are right. nix-build will actually tries to build them:
|
It does work when you remove $ nix build --out-link /tmp/foo '/nix/store/af3rc6phyv80h7aq4y3d08awnq2ja8fp-hello-2.12.1.drv'
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/af3rc6phyv80h7aq4y3d08awnq2ja8fp-hello-2.12.1.drv^*'
$ readlink /tmp/foo
/nix/store/af3rc6phyv80h7aq4y3d08awnq2ja8fp-hello-2.12.1.drv
So while this works, in practice this still has problems though:
And then we have a more design related issue:
So in conclusion, we could make |
Okay, it seems I have been living in the past at work, being stuck at 2.14, but not on my own machine which brought some confusion. @roberth, @Mic92 Passing a .drv path on the command line is not the only way to call nix build. I think nix build was initially designed to receive flake+attr path. And there is still no way to directly add a gc-root to the derivation of a flake output. Summarizing, there is no difference between
I did not take part in the discussions about the new cli, but my understanding was always that the verb was about what we want to build. For consistency, I think nix build --out-link /tmp/foo '/nix/store/af3rc6phyv80h7aq4y3d08awnq2ja8fp-hello-2.12.1.drv' should build hello and add a root to the result (yes, despite the new meaning of .drv) because that is what
I thought the point was to avoid having a For
Now I am really confused. Not to mention
|
The Zooming out from the CLI a bit, instantiation and realisation are both creation operations, and which one(s) it turns out to be is controlled by the structure of the installable as a flowchart BT
realise["realise"]
instantiate["instantiate"]
build --> realise
substitute --> realise
realise --> create
instantiate --> create
|
I don't like to further disturb such a fundamental thing as @layus I'm glad you got this conversation started from a different angle, but I can imagine you didn't come here for this kind of conversation, or maybe you do? We could move this elsewhere if you prefer. |
@roberth I like deep discussions, and I think the cli deserves a good design, but I came here to address #7138 (which you opened apparently :-) ). Right now I am actually using the hack I describe in #7138 (comment), which is not safe and pretty ugly. I need a way to eval a flake output, and get a gc-root on the .drv file in return. This is a basic feature given how the cli warns about missing roots for all the produced paths, but not for .drv. Right now, I want a cli entry point to get a rooted .drv for a given flake output (The whole point of #11506). This one is just a cherry on top, as I was working on the CLI anyway, and it felt simple enough to implement, fixing the ticket you opened. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-09-30-nix-team-meeting-minutes-182/53814/1 |
What I want out of this functionality is to be able to create a root on a remote store using |
This PR does not enable that. The biggest question is where you want to create the remote indirect root. Because rn the command takes a symlink to a store path.
Remote roots need a proper design and a robust implementation.
Le 2 octobre 2024 22:38:44 GMT+02:00, Jeremy Kolb ***@***.***> a écrit :
…What I want out of this functionality is to be able to create a root on a remote store using `--store`
--
Reply to this email directly or view it on GitHub:
#11505 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Motivation
This is a PoC fix for #7138. Now that I implemented it, I do not think it is the most elegant way to do it, as there is no way to ensure that the paths are not deleted during this operation. The command could fail however if not all the paths were successfully rooted.
Context
#7138
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.