Does my first-ever configuration.nix look alright?

@jonringer Is Home-Manager easy to use? I’ve heard mixed results.

@trusktr I don’t see any obvious errors, except Los_Angeles. :rofl: If you wish, you can combine some of those more, but that’s a personal preference.

1 Like

I’ve only ever heard people rant about how wonderful it is. Blog posts, discourse, IRC?

1 Like

My config has my wheel user with these extraGroups also

extraGroups = [ 
  "networkmanager" # this is actually in the nixos documentation on networkmanager

The useDHCP part is interesting to me, why did you need it?
IIRC, the networkmanager module in NixOS explicitly does useDHCP = false and handles that stuff itself.

1 Like

I’m pretty sure this should work totally perfect in 19.09. Have you had problems using wayland and Gnome on 19.09?

I’m curious about how I’ve written the config rather than what stuff I’ve actually installed. Would you recommend writing any parts differently?

I saw that. Looks interesting and I’d like to check it out after I get the hang of vanilla stuff first, before it “fails catastrophically” (as it says in the README) on me without me knowing what happened.

For now, I have a script that builds my home folder and dotfiles on Windows, Linux flavors (the normal FHS type), and macOS. So for now I’d like to learn about Nix by using it at the system level, and not worry about managing my home folder with just yet.

Haha, funny. (That’s a joke right?). I’m in Oakland. :slight_smile:

Ah, I knew someone would say this. Mind showing an example?

Ah thanks, I missed that part. That explains why it asked me to enter my sudo password when trying to connect to WiFi.

Ah, nice to know. See, as a brand new first-time NixOS user, I simply had no idea. It isn’t obvious for a total beginner.

What I had done was take the default config generated by nixos-generate-config, which already had those DHCP lines, then I simply added the networkmanager line, but I didn’t know that network manager would do that.

So basically, if I add networkmanager, should I just remove all the DHCP-related lines?

I haven’t tried it yet. The thing is, if my system and all the programs I need work great on X11, why should I switch to Wayland? If you don’t mind going into more detail on this, I opened another thread specifically about this at Newb question: Any caveats with Gnome + Wayland? Is it worth moving to Wayland instead of X11?

EDIT: You already replied there. Thanks. :slight_smile:

Other than what other people have commented, not really. Nix is pretty declarative, so there’s usually one obvious way to configure your stuff.

One think i did notice is that you’re using vim_configurable directly, but its usually meant to be used like this

{ config, pkgs, ... }:
 my_vim = pkgs.vim_configurable.customize {
  # `name` specifies the name of the executable and package
  name = "vim-with-plugins";

  vimrcConfig.customRC = ''
    set hidden
environment.systemPackages [ ... my_vim .. ];

again, home-manager has a nice way to declare this

He’s just being modest and giving no expectation of being responsible if something goes wrong. It’s worked wonderfully for myself and many othoers

If it works, it works.
However, most distributions have very specific ways of installing packages (apt, yum, etc.), and doesn’t work well on other flavors, nixos included. I would still recommend a nix native solution

1 Like

There are several you COULD combine more, but it’s really personal preference. :man_shrugging: Here’s an example:

services.xserver = {
  enable = true;
  layout = "us";
  libinput.enable = true;
  desktopManager = {
    plasma5.enable = true;
    gnome3.enable = true;
  displayManager.gdm = {
    enable = true;
    wayland = false;

That’s interesting, though at the moment I’m relying heavily on my dotfiles and .vimrc to work across Windows, Linux, and macOS, and my vimrc is almost 2k lines long so it may be a while before I try to port that (if ever).

Nix isn’t hard to install in any Linux distro, right? It might be something for me to look into later, if I can run it in Linux, Windows, and macOS. Running inside of Termux for Android (a Debian-like apt-managed environment) might be nice too.

1 Like

Fair, but this would also probably pair well with home-manager again. Here’s my setup:

# home.nix
{ config, lib, pkgs, ... }:
  programs.neovim = (import ./vim.nix) pkgs;
# vim .nix
  enable = true;
  viAlias = true;
  vimAlias = true;
  plugins = with pkgs.vimPlugins; [

    # themes

    # language packages
    # Haskell

    # Nix

    # Csharp

    # Powershell

    # Python

  extraConfig = ''
   " bashrc content

you could do:

    extraConfig = builtins.readFile ./.bashrc;

and still re-use your bashrc

yes, after doing curl | sh, you should have access to the nix commands. But you can’t use modules (configuration.nix by extension) on other distro’s. However, I think home-manager still works, but I can’t confirm as I use NixOS for everything :frowning: (or :slight_smile:)

When I write something like that, is it concatenating new options into the existing options?

What do you mean by “you can’t use modules (configuration.nix by extension) on other distro’s.”? (I’m still too new to understand). So using nix on other distros has certain limitations that I don’t have in NixOS?

configuration.nix is used to configure your system as a whole (systemd services, users, groups, kernel version, etc.), it’s not really targeted as “user-level” configuration (shells, user-specific utilities, dotfiles, etc.) which is why home-manager exists :slight_smile:

Most distro’s and NixOS configurations will be very opinionated about what services are running, so they are mutually exclusive.

NixOS → uses configuration.nix → configures the machine
home-manager → uses ~/.config/nixpkgs/home.nix → configures a user’s environment.

further reading: NixOS 23.11 manual | Nix & NixOS

So you mean, we can not use nix to install system-wide stuff on other distros, only to manage the home folder?

I don’t have much experience in this area, as I use NixOS as my daily driver. But you should be able to use the nix cli which includes nix-env to install packages in a similar manner to apt and other package managers.

The main benefit to using nix over other package managers is the ability to specify your system and settings in a declarative manner. And the abstractions in the configuration generally compose well in which you have a high assurance that your system “works”. Not to mention that these get “checkpointed” in profiles which allows you to iterate setups and not brick your system.

The options get set, and when generating the necessary configuration these values get referenced to create the desired environment, here’s what the gdm settings are actually doing:

For concatenating values, yes, this is exactly what it’s doing. values are “safely” merged NixOS 23.11 manual | Nix & NixOS


Functionally, there’s zero difference between how you wrote it, and how I wrote it. It’s exactly the same thing. It’s a personal style thing. :man_shrugging:

1 Like

My audio and video seems to work in Gnome desktop. What are those groups for?

The following from " = true" vs "systemPackages=[foo]" is confusing - #9 by jonringer was helpful:

So, that’s something I need to do, is figure which things I have in systemPackages that I should instead install with configuration options like = true.

You can use nix, the package manager, to install system wide packages on all operating systems which support nix and are supported by a given package. Don‘t forget that you also get nix-shell for temporary environments and portable scripts. With home-manager, an independent software package working with nix, you get the additional ability to manage user environments declaratively through nix, with configuration modules, rollbacks and what not. OS compatibility for a given package is obviously a requirement here, too.

However, you cannot use features from NixOS, the Linux distribution relying on nix for self-configuration, anywhere else than NixOS. These include system services and OS-level declarative, modular configuration. For macOS/Darwin there exists nix-darwin, which can control some significant amount of system properties.

I believe that being in the audio group allows you to access and make changes to the audio system when it is not being run by your user account and the video group is similar.

If you want to see exactly what they provide access to, you can look at the udev rules.

I don’t think being in those groups is broadly required because normally you are running audio and video processes under your user account so you have access regardless.