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

manual: add "declarative package management" section #25955

Conversation

matthewbauer
Copy link
Member

This section gives some details on how to setup an "environment"
without having to go through NixOS (although it could be used there
too). I’ve tried to make it straightforward and have a kind of
"tutorial" feel. Not sure if that’s appropriate for the manual, so any
recommended changes would be helpful.

Also the section might not be totally appropriate, but this is a fairly general use case, I think.

This section gives some details on how to setup an "environment"
without having to go through NixOS (although it could be used there
too). I’ve tried to make it straightforward and have a kind of
"tutorial" feel. Not sure if that’s appropriate for the manual, so any
recommended changes would be helpful.
@Ericson2314
Copy link
Member

Ericson2314 commented May 21, 2017

Might there be a wiki migration issue this fixes?

@joachifm joachifm added the 8.has: documentation This PR adds or changes documentation label May 21, 2017
mkdir -p $out/etc/profile.d
cp ${myProfile} $out/etc/profile.d/my-profile.sh
'')
aspell
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be better to stick to 2 or 3 packages for the examples.

@vcunat
Copy link
Member

vcunat commented May 21, 2017

Just for record, I personally prefer using simple attrmaps instead of buildEnv; I find that more flexible and better working together with nix-env. Still, in general I do find it useful to document such howto/cookbook/best-practice stuff.

@matthewbauer
Copy link
Member Author

Just for record, I personally prefer using simple attrmaps instead of buildEnv

Do you have an example of your setup? My understanding was you could never get man pages/info pages setup correctly without extraOutputsToInstall.

@vcunat
Copy link
Member

vcunat commented May 23, 2017

Correct; I do consider #24717 a bug. It's still possible to map over the custom set and amend meta.outputsToInstall, as an example workaround.


<para>
<literal>pathsToLink</literal> tells Nixpkgs to only link the paths listed
which gets rid of the extra stuff in the profile.
Copy link
Contributor

Choose a reason for hiding this comment

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

not linking the extra stuff (like <insert concrete non-matching file path>) in the profile. (feel free to modify slightly if what I am saying is not correct, the point I want to make is that it's vague)

<literal>pathsToLink</literal> tells Nixpkgs to only link the paths listed
which gets rid of the extra stuff in the profile.
<filename>/bin</filename> and <filename>/share</filename> are good
defaults for a user environment, getting rid of the clutter. If you are
Copy link
Contributor

Choose a reason for hiding this comment

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

defaults for a clutter free user environment is shorter.


<para>
After building that new environment, look through
<filename>~/.nix-profile</filename> to make sure everything is there that
Copy link
Contributor

Choose a reason for hiding this comment

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

-that we wanted

<para>
After building that new environment, look through
<filename>~/.nix-profile</filename> to make sure everything is there that
we wanted. Discerning readers will note that some files are missing. Look
Copy link
Contributor

Choose a reason for hiding this comment

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

A fairly long paragraph to make a simple point. Spending words to tell the user is super smart, might be attractive to the latent narcissists , but I count them as waste.

</screen>

<para>
This provides us with some useful documentation for using our packages.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line doesn't add anything.


<para>
This provides us with some useful documentation for using our packages.
However, if we actually want those manpages to be detected by man, we need
Copy link
Contributor

Choose a reason for hiding this comment

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

To make man detect our written manpages...

<para>
This provides us with some useful documentation for using our packages.
However, if we actually want those manpages to be detected by man, we need
to set up our environment. This can also be managed within Nix
Copy link
Contributor

Choose a reason for hiding this comment

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

Overloading the word environment makes it harder to read.


<screen>
#!/bin/sh
if [ -d $HOME/.nix-profile/etc/profile.d ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Not quoting $HOME makes baby Jezus cry. It's better to replace it with ~.

<screen>
#!/bin/sh
if [ -d $HOME/.nix-profile/etc/profile.d ]; then
for i in $HOME/.nix-profile/etc/profile.d/*.sh; do
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

#!/bin/sh
if [ -d $HOME/.nix-profile/etc/profile.d ]; then
for i in $HOME/.nix-profile/etc/profile.d/*.sh; do
if [ -r $i ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Quotes

if [ -d $HOME/.nix-profile/etc/profile.d ]; then
for i in $HOME/.nix-profile/etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
Copy link
Contributor

Choose a reason for hiding this comment

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

Quotes

</screen>

<para>
Now just run <literal>source $HOME/.profile</literal> and you can starting
Copy link
Contributor

Choose a reason for hiding this comment

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

~

<title>GNU info setup</title>

<para>
Configuring GNU info is a little bit trickier than man pages. To work
Copy link
Contributor

Choose a reason for hiding this comment

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

Qualifications about difficulty are a waste of words.

To let GNU Info display our <info pages/documentation/whatever> it needs this information indexed in a database, which is done as followed:

extraOutputsToInstall = [ "man" "doc" "info" ];
postBuild = ''
if [ -x $out/bin/install-info -a -w $out/share/info ]; then
shopt -s nullglob
Copy link
Contributor

Choose a reason for hiding this comment

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

This is documentation, not a course in how to program shell, so please rewrite the code such that it doesn't need this.

if [ -x $out/bin/install-info -a -w $out/share/info ]; then
shopt -s nullglob
for i in $out/share/info/*.info $out/share/info/*.info.gz; do
$out/bin/install-info $i $out/share/info/dir
Copy link
Contributor

Choose a reason for hiding this comment

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

Quotes

</screen>

<para>
<literal>postBuild</literal> tells Nixpkgs to run a command after building
Copy link
Contributor

Choose a reason for hiding this comment

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

Nixpkgs doesn't really run anything. Please rewrite to be correct.

<para>
<literal>postBuild</literal> tells Nixpkgs to run a command after building
the environment. In this case, <literal>install-info</literal> adds the
installed info pages to <literal>dir</literal> which is GNU info's default
Copy link
Contributor

Choose a reason for hiding this comment

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

the environment. In this case, <literal>install-info</literal> adds the
installed info pages to <literal>dir</literal> which is GNU info's default
root node. Note that <literal>texinfoInteractive</literal> is added to the
environment to give the <literal>install-info</literal> command.
Copy link
Contributor

Choose a reason for hiding this comment

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

to give is unspecific language.

we wanted. Discerning readers will note that some files are missing. Look
inside <filename>~/.nix-profile/share/man/man1/</filename> to verify this.
There are no man pages for any of the Nix tools! This is because some
packages like Nix have multiple outputs for things like documentation (see
Copy link
Contributor

Choose a reason for hiding this comment

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

DocBook is a hyperlinked format, so just link to the section.


<section xml:id="sec-building-environment">
<title>Build an environment</title>

Copy link
Contributor

Choose a reason for hiding this comment

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

Please define what is understood by an environment.

Copy link
Contributor

@0xABAB 0xABAB left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to write documentation, but I have quite some comments.

@grahamc
Copy link
Member

grahamc commented Jul 16, 2017

Merging, this is better than what is there. Thank you.

@grahamc grahamc merged commit 6504df6 into NixOS:master Jul 16, 2017
@matthewbauer matthewbauer deleted the nixpkgs-manual-declarative-package-management branch February 22, 2019 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: documentation This PR adds or changes documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants