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

nixos/manual: clarify declarative packages section #57617

Merged
merged 2 commits into from Mar 26, 2019

Conversation

aaronjanse
Copy link
Member

@aaronjanse aaronjanse commented Mar 14, 2019

Motivation for this change

The declarative package management gives a straightforward explaination of installing packages in NixOS, but assumes knowledge of Nix variables and knowledge of channels.

This leads to confusions such as #55556, where a user confused nixos and pkgs as almost interchangable.

This pull request elaborates on what the pkgs variable means (it's a reference to the root channel) and what the nixos prefix in a full package path means (it's the channel you are getting the package from).

This should allow a user to use the variable pkgs and the nixos prefix without needing an explaination of what they mean.

Although it doesn't explain what a channel is, it hopefully makes sense without knowing the full definition, and if a user is confused, they should have a clear question to ask (i.e. "what is a channel?").

Things done
  • Tested using sandboxing (nix.useSandbox
    on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@danbst
Copy link
Contributor

danbst commented Mar 15, 2019

Hm, what about this instead? After this code example:

$ nix-env -qaP '*' --description
nixos.firefox   firefox-23.0   Mozilla Firefox - the browser, reloaded
...

place

Note: the nixos prefix tells us that we want to get the package from the nixos channel and works only in CLI tools. In declarative configuration use pkgs prefix (variable).

A note about pkgs being a variable is fine, but it isn't root channel. It is root's nixos channel. Not sure how to communicate this better.

@aaronjanse
Copy link
Member Author

The HEAD commit formerly did not have the content it's description implied (rather it was just a revert commit iirc). I have force pushed [1] to make the commit match your suggestion @danbst

[1] I assume that's acceptable because as far as I know, I'm the only one checking out this branch

Copy link
Contributor

@danbst danbst left a comment

Choose a reason for hiding this comment

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

Looks OK to me, I wish @AMDphreak have verified that this indeed clarifies section.

@matthewbauer matthewbauer merged commit 38c6c7c into NixOS:master Mar 26, 2019
@AMDphreak
Copy link

AMDphreak commented Mar 26, 2019

Let me know if I read this right: the pkgs variable points to the nixos channel, but we can't access the nixos channel by name, because the user can only refer to variables passed into the scope of the Nix expression.

Suggested modification:

Note: the nixos prefix tells us that we want to get the package from the nixos channel and works only in CLI tools. In declarative configuration, use pkgs as a prefix, i.e. pkgs.app_name_goes_here. The reference, pkgs, is a variable name that refers to the nixos channel.

I'm thinking readers will interpret the word "variable" as the meaning of "variable" from the procedural programming paradigm (stored value), rather than the functional paradigm ("let" binding). The reader needs to be introduced to the nomenclature of let-bound variables when he/she first encounters the concept. The "alias" or "pointer" metaphor seems like a natural way to explain it. My sentence before my suggested modification would be a succinct way to let users know there's a difference. It's fairly unambiguous without getting too technical and jargony.

The use of "He-who-should-not-be-named" to refer to Voldemort in Harry Potter should be a good analogy, especially since Voldemort refers to another name, Tom Riddle, as well (the irony!).

It is root's nixos channel.

Is the nixos channel owned by root? This would seem to imply that there is a nixos channel not owned by root. What's the story here?

@danbst
Copy link
Contributor

danbst commented Mar 26, 2019

Is the nixos channel owned by root? This would seem to imply that there is a nixos channel not owned by root. What's the story here?

It's possible to define nixos channel in user's channels. It can be used by nixos-rebuild build, but won't be used by nixos-rebuild switch, because you call usually sudo nixos-rebuild switch, thus root's channel is active.

as for variable thing: I really really wish we had documentation with ability to add comments in-place to each section. Like Google Docs annotations, or Mercurial book (which has comments to each paragraph).

Let me know if I read this right:

correct!

I'm thinking readers will interpret the word "variable" as the meaning of "variable" in the procedural programming paradigm (stored value), rather than the functional paradigm ("let" binding).

That depends on reader. I like to think about let-bindings as immutable variables, because you can reassign them whenever you want. But I also like your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants