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

clarify definition of "installable" #7376

Merged
merged 3 commits into from
Mar 6, 2023

Conversation

fricklerhandwerk
Copy link
Contributor

@fricklerhandwerk fricklerhandwerk commented Dec 1, 2022

the term was hard to discover, as its definition and explanation were in
a very long document lacking an overview section.
search did not help because it occurs so often.

  • clarify wording in the definition
  • add an overview of installable types
  • add "installable" to glossary
  • link to definition from occurrences of the term

the first commit makes descriptions of each installable type its own subsection.
it makes for a messy diff but does not change contents. read the second commit to see the actual changes.

This work is sponsored by Antithesis

doc/manual/src/glossary.md Outdated Show resolved Hide resolved
doc/manual/src/glossary.md Outdated Show resolved Hide resolved
src/libcmd/command.hh Outdated Show resolved Hide resolved
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2022-12-02-nix-team-meeting-minutes-13/23731/1

doc/manual/src/glossary.md Outdated Show resolved Hide resolved
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

I think that trying to mash together "anything accepted by any nix command is an installable and vice versa" is not only confusing but also incorrect. See below, a lot of nix commands which "take installables" reject some kinds of installables.

We shouldn't try to hide the difference between an outpath and its deriver from users.

This "everything is an installable and there is nothing but installables" papers over the many-to-one (Edit: many-to-many!) relationship between derivers and store objects. That will come back to bite us later, just like the "referring to a derivation always means referring to its realisation, except when it doesn't" problem that led to the --derivation flag did.

doc/manual/src/glossary.md Outdated Show resolved Hide resolved
src/nix/nix.md Show resolved Hide resolved
src/nix/nix.md Outdated Show resolved Hide resolved
src/nix/nix.md Outdated Show resolved Hide resolved
src/nix/log.md Outdated Show resolved Hide resolved
src/nix/eval.md Outdated Show resolved Hide resolved
@fricklerhandwerk
Copy link
Contributor Author

@amjoseph-nixpkgs I think you're right, and all this hints at is that the CLI has some design issues. We should try to be as precise as possible, but I feel it's only worthwhile up to a point. Saying "it doesn't actually work for all the commands" has to suffice for now. Indeed we'd have to untangle the underlying issues first, which here is the overloading of argument types, but this is not the PR and, in my opinion, not yet the time to do so.

I'll fix up what seems reasonable and would then try to get closer to merging.

@fricklerhandwerk fricklerhandwerk changed the title add "installable" to glossary, link from occurrences clarify definition of "installable" Jan 19, 2023
@fricklerhandwerk fricklerhandwerk requested a review from a user January 19, 2023 11:35
@fricklerhandwerk
Copy link
Contributor Author

@amjoseph-nixpkgs updated according to your suggestions. @Nixos/nix-team ready for review.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Your identification of the installables which "can be evaluated, that is, a flake or Nix expression, but not a store path or store derivation path" is a very important clarification -- so much so that I think it deserves a name (I used evaluatable below, but if you have another one you like better go ahead and change it).

With definitions for the terms installable and evaluatable we can give accurate and very succinct specifications for the arguments of every command except nix show-derivation. I think that's a sign that we've got the right taxonomy.

I think if you add a definition for evaluatable the result is pretty coherent.

src/nix/nix.md Show resolved Hide resolved
src/nix/nix.md Show resolved Hide resolved
src/nix/nix.md Outdated Show resolved Hide resolved
src/nix/run.md Show resolved Hide resolved
src/nix/run.md Show resolved Hide resolved
src/nix/nix.md Show resolved Hide resolved
src/nix/search.md Show resolved Hide resolved
src/nix/show-derivation.md Show resolved Hide resolved
src/nix/nix.md Show resolved Hide resolved
@ghost
Copy link

ghost commented Jan 23, 2023

So it turns out that nix copy foo.drv doesn't do the same thing as nix copy $(nix-store -r foo.drv).

In other words, "operations on derivations operate on their realisation except when --derivation is used" isn't correct. There is a third behavior.

@Ericson2314
Copy link
Member

Ericson2314 commented Jan 27, 2023

@amjoseph-nixpkgs the one difference for nix copy I know of is CA derivation realizations. Is that what you hit?

@ghost
Copy link

ghost commented Jan 28, 2023

the one difference for nix-copy I know of is CA derivation realizations. Is that what you hit?

I don't think so; I don't have them in my experimental-features at the moment.

I think the problem is actually in the $(nix-store -r). Here is an example that doesn't need nix copy, both in prose and bash. It breaks the "using a derivation as an installable produces exactly the same result as using its realisation as an installable" rule.

Prose

If your local store has neither particular outpath (say, /nix/store/outpath) nor its deriver (say, /nix/store/deriver.drv), then running

nix-store -r /nix/store/outpath

will copy the outpath, but not its deriver, to your local machine.

If you instead run

nix-store -r /nix/store/deriver.drv

then both the outpath and the deriver will be copied to your local machine.

This contradicts the rule "using a derivation as an installable produces exactly the same result as using its realisation as an installable".

Bash

$ nix-store -r /nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools
this path will be fetched (122.16 MiB download, 122.16 MiB unpacked):
  /nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools
copying path '/nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools' from 'http://substituter'...
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools

$ ls $(nix-store -qd /nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools)
ls: cannot access '/nix/store/iqwd30cadrajfampslvykwbv8wps1jsx-bootstrap-tools.drv': No such file or directory

$ nix-store -r $(nix-store -qd /nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools)
don't know how to build these paths:
  /nix/store/iqwd30cadrajfampslvykwbv8wps1jsx-bootstrap-tools.drv
copying path '/nix/store/iqwd30cadrajfampslvykwbv8wps1jsx-bootstrap-tools.drv' from 'http://substituter'...
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools

$ ls $(nix-store -qd /nix/store/dhkv3d1a4hjkfabhi91m6kzpp9x40vpp-bootstrap-tools)
/nix/store/iqwd30cadrajfampslvykwbv8wps1jsx-bootstrap-tools.drv

@fricklerhandwerk
Copy link
Contributor Author

@amjoseph-nixpkgs I also encountered this inconsistency and think it's a valid point we should address with a design decision. Please open an issue.

@thufschmitt While it's still not perfect, I think it's ready to merge. Could you please take look?

@Ericson2314
Copy link
Member

@amjoseph-nixpkgs is this just the old CLI? Or also nix copy?

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

This is looking very nice!

fricklerhandwerk and others added 2 commits March 5, 2023 01:46
this is easier to edit, provides anchors for free, and renders correctly
on the terminal without additional effort.
the term was hard to discover, as its definition and explanation were in
a very long document lacking an overview section.
search did not help because it occurs so often.

- clarify wording in the definition
- add an overview of installable types
- add "installable" to glossary
- link to definition from occurrences of the term
- be more precise about where store derivation outputs are processed
- installable Nix expressions must evaluate to a derivation

Co-authored-by: Adam Joseph <[email protected]>
@fricklerhandwerk
Copy link
Contributor Author

@thufschmitt please take a look.

src/nix/nix.md Outdated Show resolved Hide resolved
@thufschmitt thufschmitt merged commit 2fbb256 into NixOS:master Mar 6, 2023
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/this-month-in-nix-docs-1-march-2023/26913/1

@fricklerhandwerk fricklerhandwerk deleted the installable branch October 9, 2023 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants