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: nixos-generate-config: document all the common things #36274

Closed
wants to merge 1 commit into from

Conversation

oxij
Copy link
Member

@oxij oxij commented Mar 4, 2018

Motivation for this change

Combination of #17126 (comment) and #35292 (comment) got me over the edge.

Things done
  • It evaluates.

Feel free to point to typos I probably missed.

# To disable the firewall altogether use the following.
#
# Use only inside trusted networks behind IPv4 NAT and without IPv6
# support or else bad people across the galaxy will be able to
Copy link
Member

Choose a reason for hiding this comment

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

Only because the network has ipv6, does not mean your router does not block incoming connections to you IP.
And also NAT is not a firewall.

Suggestion:

Disable your firewall only in trusted networks with inbound firewalls or if your services are supposed to public on the internet.

# (Actually, not enabling this doesn't disable ALSA because ALSA is
# the Linux kernel default. But you won't get access to ALSA tools
# like alsamixer and your ALSA settings like volume won't get saved
# and restored between reboots without enabling the above.)
Copy link
Member

Choose a reason for hiding this comment

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

This can be shortened:

This option will add alsatools to your system and make ALSA settings such as volumes persistent across reboots.

@oxij oxij force-pushed the nixos/doc-generate-config branch from 03498de to 0cf210e Compare March 6, 2018 16:48
@oxij
Copy link
Member Author

oxij commented Mar 6, 2018

Both nitpicks fixed.

@mogorman
Copy link
Contributor

mogorman commented Mar 6, 2018

this file is getting huge, but i do think several the tips you recommend are good / useful

@oxij
Copy link
Member Author

oxij commented Mar 6, 2018 via email

@oxij oxij force-pushed the nixos/doc-generate-config branch from 0cf210e to 99e8d07 Compare March 8, 2018 21:35
@oxij
Copy link
Member Author

oxij commented Mar 8, 2018

Fixed a tiny typo/OCD thing.

What's holding this? While this ferments some people encounter the problem described in #17126, say "f*ck it" and drop NixOS while others unwittingly enable the PA daemon.

Unless there's a problem with this I would merge this ASAP and cherry-pick to 18.03 too.

/cc @grahamc @vcunat

Copy link
Member

@grahamc grahamc left a comment

Choose a reason for hiding this comment

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

I like a good bit of it and would merge most of it.

# You might want to enable this if you run a minimalistic desktop
# environment or work from bare linux ttys/framebuffers.

# sound.mediaKeys.enable = true;
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 removing this section about mediakeys would make it easier to merge, since mediakeys being an option is a bit contentious.

# (You might need to merge this line with the above mention of
# environment.systemPackages as you can't assign the same attribute
# multiple times in a single nix attribute set.)

Copy link
Member

Choose a reason for hiding this comment

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

Should probably drop this previous section, because the section about enabling sound explains it well enough I think.

# networking.hostName = "nixos";

# Enable wireless support via wpa_supplicant.
# networking.wireless.enable = true;
Copy link
Member

Choose a reason for hiding this comment

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

👍


# Select internationalisation properties.

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 these newlines confuse it, where without the newline it is clearly tied to the section.

# environment.systemPackages = with pkgs; [
# wget vim
# ];

# To search by name, run:
Copy link
Member

Choose a reason for hiding this comment

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

"To search packages"

#
# into your ~/.config/nixpkgs/config.nix file.
#
# Finally, note that if you don't use nixos channels, you can still use
Copy link
Member

Choose a reason for hiding this comment

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

the NixOS channels

# Finally, note that if you don't use nixos channels, you can still use
# nix-env by running it directly from the nixpkgs tree like so
#
# \$ nix-env -f ./default.nix -qaP | grep wget
Copy link
Member

Choose a reason for hiding this comment

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

-qaP '.*wget.*'

# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# started in user sessions. Those usually can be configured with
# options under programs.<name> subtree.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add See man configuration.nix.

# Use only inside trusted networks behind another firewall or else
# bad people across the galaxy will be able to access any ports you
# leave open.
#
Copy link
Member

Choose a reason for hiding this comment

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

Probably a bit much :)

Copy link
Member

Choose a reason for hiding this comment

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

I didn't say it was completely worthless, just a bit much.

# Enable the X11 windowing system.

# services.xserver.enable = true;
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";

# Enable touchpad support.
# services.xserver.libinput.enable = true;

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 all of the changes following here should probably be in the wiki instead.

@oxij
Copy link
Member Author

oxij commented Mar 9, 2018 via email

Copy link
Member

@grahamc grahamc left a comment

Choose a reason for hiding this comment

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

I can't speak to the docbook, but nixos.wiki is a happy and healthy source of pretty high quality information now, thanks to fadenb, lassalus, makefu, mic92, samueldr, and many many others. The risk of putting too much in this file is it is never updated again, making it drift further and further away from reality. I like the idea of putting more information here, but want it to lead to updatable sources.

# servers. You should change this only after NixOS release notes say you
# should.
system.stateVersion = "${\(qw(@release@))}"; # Did you read the comment?

Copy link
Member

Choose a reason for hiding this comment

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

👎 it shouldn't be near the top if they shouldn't touch it.

# List packages installed in system profile. To search by name, run:
# \$ nix-env -qaP | grep wget
# List of packages installed in system profile (by attribute name).
#
Copy link
Member

Choose a reason for hiding this comment

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

👍

# still use nix-env by running it directly from the nixpkgs tree like so
#
# \$ nix-env -f . -qaP '.*wget.*'

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

Given that the whole point of not showing unfree software by default is to not promote the use of unfree software, adding detailed instructions to the default configuration.nix is questionable IMHO.

Copy link
Member

Choose a reason for hiding this comment

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

@edolstra Well, it is half of the point — the other half is that we have too many different evaluation contexts to ever be sure that allowUnfree is not silently true in one of them.

(I do personally agree with the point you make, although I value the fail-safe part more and I am not sure if people stopping opening issues like #17126 is worth documenting this in more places)

# started in user sessions.
# started in user sessions. Those usually can be configured with
# options under programs.<name> subtree. See configuration.nix(5)
# man page.
Copy link
Member

Choose a reason for hiding this comment

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

👍

# Use only inside trusted networks behind another firewall or else
# bad people across the galaxy will be able to access any ports you
# leave open.
#
Copy link
Member

Choose a reason for hiding this comment

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

I didn't say it was completely worthless, just a bit much.

# Note that you don't need to enable PulseAudio daemon to get either
# of sound playback or software sound mixing. It will out of the box
# over ALSA. If you do want to run PulseAudio daemon, however, you
# may safely disable `sound.enable`.
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

How about "you may set `sound.enable` to `false`."?

# quality to be connected to untrusted data sources like the browser
# by default).
#
# environment.systemPackages = [ pkgs.apulse ];
Copy link
Member

Choose a reason for hiding this comment

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

👎 but would accept For more information, see nixos.wiki/something-about-sound...

Copy link
Member

Choose a reason for hiding this comment

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

Why refer to a wiki here? I agree with @oxij: this is unlikely to change for a long time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think "some people claim"-type information belongs here. I too would prefer a link to a deeper dive.

# };

# If you're in a hurry, you may stop editing your configuration.nix now
# and completely ignore everything below.
Copy link
Member

Choose a reason for hiding this comment

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

👎 this file will be immediately out of date because nothing can update it. We shouldn't be talking about best practices or general techniques. This belongs in other documentation elsewhere. The parts about unfree software are universally true. The remainder of this should definitely not be in this config file, but instead in the documentation or wiki.

Copy link
Member

Choose a reason for hiding this comment

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

I agree, this is the main problem with this PR. It's fine to install a small configuration.nix with some options to get people started, but it should not duplicate the manual or try to cover a gazillion use cases.

Copy link
Member

Choose a reason for hiding this comment

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

Well, experimental evidence shows that not enough people read the manual anyway…

Copy link
Contributor

@chreekat chreekat Jul 4, 2019

Choose a reason for hiding this comment

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

+1 to removing the following. Using a separate user to run e.g. firefox sounds like a great idea, but the boilerplate in configuration.nix is not the soapbox from which to broadcast this position. People approaching this file for the first time just want to get NixOS running, which already has enough mind-blowing paradigm shifts to absorb.

Copy link
Contributor

Choose a reason for hiding this comment

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

agree, 👎 on the somewhat niche and cumbersome desktop-only per-software user approach here. It would be better to a link to general information about running NixOS on the desktop with a section on per-software users.

# services.xserver.displayManager.sddm.enable = true;
# services.xserver.desktopManager.plasma5.enable = true;

# Or maybe you want to enable Xfce Desktop Environment and Slim
Copy link
Member

Choose a reason for hiding this comment

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

👎 on the addition of xfce / slim and the following, they'll need to find the full list of options somehow, and this file isn't in the business of describing every use case. We should be teaching them to fish here.

# services.xserver.displayManager.sddm.enable = true;
# services.xserver.desktopManager.plasma5.enable = true;
# Enable graphical acceleration for NVIDIA GPUs (requires unfree
# packages, see above).
Copy link
Member

Choose a reason for hiding this comment

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

👎 this information is too likely to get out of date, and really can't cover all the important cases. This should lead to external documentation.

@oxij
Copy link
Member Author

oxij commented Mar 9, 2018 via email

@7c6f434c
Copy link
Member

7c6f434c commented Mar 9, 2018

Eh? "nothing can update it"? What?

Once this file is generated, it is installed as configuration.nix on the user's system, and no automated tool ever touches it afterwards.

@7c6f434c
Copy link
Member

7c6f434c commented Mar 9, 2018

I think we already had a wiki before and saw what that turned itself into.

For the record: it turned out that a MediaWiki with an open registration requires either too much skill or too much effort to prevent from becoming a spam dump (with spam even overwriting content). Nixos.Wiki seems to hope that a unique CAPTCHA will delay this problem, and in the worst case GitHub login can be made the only option.

@makefu
Copy link
Contributor

makefu commented Mar 9, 2018

@7c6f434c you are only partly right. The first step to fight spam obviously is a technical measure (captchas), however the new wiki is watched over closely by by a number of volunteers. There is a wiki-update bot in #nixos-wiki and we at least sight changes to ensure quality.

Some time ago someone asked how the archlinux wiki can stay such a wealthy resource and the answer was simple, there were people who cared. Now that the wiki is lead by a number of people and not a single person i think we can do something similar for the nixos community.

If you would like to help the effort you can join nixos-wiki on freenode!

@7c6f434c
Copy link
Member

7c6f434c commented Mar 9, 2018

@makefu well, you still need technical foundation to match — I mean, at some point I tried to roll back a spam attack on the old NixOS MediaWiki and suddenly understood that I just cannot understand how to untangle this sequence of history-masking-redirection-tricks. Some people did try to care, it just turned out that the people who cared at any given moment didn't have a combination of skill (and maybe MediaWiki access level?) to maintain defense efficiently.

Of course I do not deny the main effort of the team — creating and maintaining high-quality content. I just say that you have enough technical options to guarantee avoidance of the despair event horizon that the old wiki had.

(As for me, I am a person who can entertain people by describing how non-trivially my system is configured, and how it is not fully NixOS — so I can help people debug via IRC, but writing useful Wiki content without immediate feedback would be hard)

# or
# services.xserver.videoDrivers = [ "nvidiaLegacy304" ];
# or
# services.xserver.videoDrivers = [ "nvidiaLegacy173" ];
Copy link
Member

Choose a reason for hiding this comment

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

All of this should be detected automatically and emitted in hardware-configuration.nix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. As discussed above.

# # but you probably don't want to give it direct DRI access
# # since OpenGL video drivers are pretty buggy and giving DRI
# # access to WebGL might not be the best of ideas.
# # ++ [ "video" ];
Copy link
Member

Choose a reason for hiding this comment

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

This instruction should be absolutely unnecessary: logged-in users should automatically have access to sound and video devices via loginctl / udev rules. If not, that's a bug that should be fixed.

Copy link
Member

Choose a reason for hiding this comment

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

And how not to give DRI access to a user even when logged in?

Copy link
Member Author

Choose a reason for hiding this comment

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

should automatically have access to sound and video devices via loginctl / udev rules

So you have a machine with a bunch of ssh accounts shared by a whole organization. Everyone should have access to sound and video devices by default? What about the "input" group that allows you to emulate key presses on evdev devices? I absolutely disagree.

Copy link
Contributor

Choose a reason for hiding this comment

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

@oxij in that case the loginctl/udev rules would definitely need adjusting. Only logging in on the console should give you these permissions.

# umask 077
#
# into your ~/.xsession file. You should probably put the above
# xhost line there too.
Copy link
Member

Choose a reason for hiding this comment

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

This absolutely does not belong in configuration.nix.

Copy link
Member Author

Choose a reason for hiding this comment

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

As noted above (#36274 (comment)), I disagree, but fine, if we leave the user setup and then point to the manual for the rest, I would be ok with that.

@oxij
Copy link
Member Author

oxij commented Apr 25, 2018

Updated.

Most frequently changing things are now gone to the configuration.nix(5). I left some of the DE setup in because xfce and slim are the most stable pieces of DE software ever, they are not going to change frequently (unlike Gnome and KDE). If you want to remove those lines I suggest we remove all DE setup then starting with KDE, since it's the most frequently changing thing in this config.

Unfree examples use "hello-unfree" package and so they are very un-corporate now.

I think I answered to all other nitpicks, feel free to reiterate if you disagree with the current state of the file.

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: hello-unfree

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: hello-unfree

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@oxij oxij force-pushed the nixos/doc-generate-config branch 2 times, most recently from 58993f8 to 3c61c27 Compare June 9, 2018 18:32
@oxij
Copy link
Member Author

oxij commented Jun 9, 2018

A tiny piece of this was already merged in 92265e8, I split other weakly-related parts into #41763 and #41764.

Ping!

@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: hello-unfree

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: hello-unfree

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@oxij oxij force-pushed the nixos/doc-generate-config branch from 3c61c27 to ec4dad8 Compare June 9, 2018 19:52
@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: hello-unfree

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: hello-unfree

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@oxij oxij force-pushed the nixos/doc-generate-config branch from ec4dad8 to 9841f05 Compare June 11, 2018 16:15
# \$ sudo -Hiu network firefox &disown
# \$ sudo -Hiu network qtox &disown
#
# from the account logged in into X11.
Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly this feels like it should be a whole new option,which will add the required wrappers and sudo configurations.
Also for desktop users you should probably point to programs.firejail

# Note that you don't need to enable PulseAudio daemon to get either
# of sound playback or software sound mixing. It will out of the box
# over ALSA. If you do want to run PulseAudio daemon, however, you
# may safely disable `sound.enable`.
Copy link
Contributor

Choose a reason for hiding this comment

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

How about "you may set `sound.enable` to `false`."?

# quality to be connected to untrusted data sources like the browser
# by default).
#
# environment.systemPackages = [ pkgs.apulse ];
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think "some people claim"-type information belongs here. I too would prefer a link to a deeper dive.

Comment on lines 707 to +763
# Enable the X11 windowing system.
#
# services.xserver.enable = true;
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";

#
# Enable touchpad support.
# services.xserver.libinput.enable = true;

# Enable graphical acceleration in X11. See configuration.nix(5) man
# page for possible options.
#
# services.xserver.videoDrivers = [ "<name-of-the-driver>" ];

# Enable support for 32-bit OpenGL libraries on x86_64 which is
# useful if you want to run 32-bit OpenGL applications
#
# hardware.opengl.driSupport32Bit = true;
#
# E.g., games under Wine
#
# environment.systemPackages = with pkgs; [ wine winetricks ];

# Some of the X11 drivers above might not work with the current Linux
# kernel, so you might end up overriding that too.
#
# boot.kernelPackages = pkgs.linuxPackages_4_9;

# Define a user account. Don't forget to set a password with ‘passwd’.
#
# users.users.me = {
# isNormalUser = true;
# uid = 1000;
# extraGroups = [ "input" "audio" "video" "cdrom" ]
# ++ [ "wheel" ]; # for sudo
# openssh.authorizedKeys.keyFiles = [ /etc/nixos/id_rsa.pub ];
# };

# Enable the KDE Desktop Environment.
#
# services.xserver.displayManager.sddm.enable = true;
# services.xserver.desktopManager.plasma5.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
# users.users.guest = {
# Or maybe you want to enable Xfce Desktop Environment and Slim
# display manager?
#
# services.xserver.displayManager.slim.enable = true;
# services.xserver.desktopManager.xfce.enable = true;

# Or maybe you just want to automatically login into your .xsession
# script? Then don't enable any desktopManagers and uncomment the
# following.
#
# services.xserver.displayManager.auto = {
# enable = true;
# user = "me";
# };
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this whole section could be marked as "for desktop use only"? Move the user stuff below it though.

# # but you probably don't want to give it direct DRI access
# # since OpenGL video drivers are pretty buggy and giving DRI
# # access to WebGL might not be the best of ideas.
# # ++ [ "video" ];
Copy link
Contributor

Choose a reason for hiding this comment

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

@oxij in that case the loginctl/udev rules would definitely need adjusting. Only logging in on the console should give you these permissions.

# };

# If you're in a hurry, you may stop editing your configuration.nix now
# and completely ignore everything below.
Copy link
Contributor

Choose a reason for hiding this comment

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

agree, 👎 on the somewhat niche and cumbersome desktop-only per-software user approach here. It would be better to a link to general information about running NixOS on the desktop with a section on per-software users.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/prs-already-reviewed/2617/128

@Mic92
Copy link
Member

Mic92 commented Mar 30, 2020

There some useful bits in here that could be cherry-picked into our configuration. However given that the author is no longer working on this pull request, I will close this one.

@Mic92 Mic92 closed this Mar 30, 2020
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