NixOS Community Thread

As a new user to NixOS (Evaluating in a VM) I find it fascinating yet a little mind melting. I wanted to start a community thread to help each other on NixOS. I myself an Arch User. Love a lot of the features that NixOS offers. It is a different type of OS. I have seen a few neofetch posts of people using NixOS.

There is a lot going on here
-Nix Language
-Flakes
-Home Manager
-nix repl
-nix-shell
-nix-env
-/etc/nixos/configuration.nix
and so much more.

I am reinstalling this for the third time on 24.05 in a VM

fascinated by this distro.

Let the comments fly

I see this as a very strong Server distro.
I do have a devel server right now. I want to switch, the wife may get upset. :stuck_out_tongue:
I want to know more.

regards R-Savage

2 Likes

First Question:
Can you not have a multi user setup in the /etc/nixos/configuration.nix file? since this is a system level file. is this not allowed?

Yeah, I gave NixOS a good couple months try; Wasn’t for me. Back on Arch, happy as a clam.

That said, I’ll do my best to answer your question:

A bit more info is probably needed?

Let’s say you want ā€œbobā€ and ā€œaliceā€ users.

To do that, you’d do the following

{
  users.users.bob = {
    isNormalUser = true;
    extraGroups = [];
    packages = with pkgs; [
      firefox
      vim
      tmux
    ];
  };
  users.users.alice = {
    isNormalUser = true;
    extraGroups = [];
    packages = with pkgs; [
      chromium
      visual-studio-code
    ];
  };
}

This would give you two users. Alice would have access to chromium and vscode, where bob would have access to firefox and vim.

3 Likes

let me try this. I was thinking this but looking for docs on this always led me to installing flakes and home manager.

thank you very much.

got syntax errors. let me try again. does each user need separate packages?

Ok I got it to work here is my config

# Define a user account. Don't forget to set a password with ā€˜passwd’.

  users.users.username1 = {
    isNormalUser = true;
    description = "username1";
    extraGroups = [ "networkmanager" "wheel" ];
    password = "password";
    packages = with pkgs; [
      kdePackages.kate
      neovim
      git
      curl
      wget
    #  thunderbird
    ];
  };
  users.users.username2 = {
    isNormalUser = true;
    description = "username2";
    extraGroups = [ "networkmanager" "wheel" ];
    password = Password";
    packages = with pkgs; [
      kdePackages.kate
      git
      vim
      curl
      wget
    ];
  };

THANK YOU VERY MUCH

2 Likes

I found out a few weeks ago that SteamOS also supports the nix package manager (since some version). For those who don’t know: SteamOS is an arch based immutable distro. The only way to install software is in user mode, flatpaks/appimages but now also nix packages. So far they have been working great for me. Running emacs in a flatpak is a PITA, since your config directory is ā€˜somewhere’ and permissions on dev tools can be weird. On some machines (server with just user access) I’d just compile emacs, but the deck is a bit slow for that and doesn’t come with compilers. But the nix package works perfectly and integrates seamlessly in the system.

I should really look more into nix for my work purposes. We rely quite a bit on containers but nix offers another solution to the ā€˜it runs on my machine’ problem that might be more suitable sometimes.

2 Likes

flakes seems to be the answer for containers. like docker etc… still trying to experiment with it.

to mods. can we experiment with hello_world.nix flakes? if that is how it is done? since it is reproducible can we play?

Yeah, flakes are the go-to for containers, but containers arent really the primary goal of nix.

1 Like

I’m not really a huge fan of managing user packages through configuration.nix. Instead, I opted to use Home Manager without using NixOS module to manage my $HOME, and leave configuration.nix to only manage the system. The only packages I have on my configuration.nix are the ones that require system-level configuration (e.g. PolicyKit, pam, system daemon, etc.).

This means I have two repositories that I use to manage my Nix configuration:

https://git.sr.ht/~sirn/dotfiles

https://git.sr.ht/~sirn/nixos

For containers and flake, if we’re talking about nixos-container (which is NixOS’ wrapper on top of systemd-nspawn), then I don’t think you can configure nixos-container through flake at all (which defeat its usefulness in workstation context, since all containers must be configured at system-level; still useful for servers though).

If we’re talking about using flake as a replacement for containers, then I don’t think flake is a substitute for a container. While flakes are self-contained, the runtime is not isolated (as with containers and cgroups), which may or may not be a dealbreaker for many scenarios. It’s still very useful to distribute the same packages to every machine, though (even more so with nix-direnv).

3 Likes

I am having problems enabling flakes on 24.05 here is the config. i don’t know what I am doing wrong.

this is the link I am following. nothing seems to work

{ config, pkgs, … }:

{
# Import other configuration modules
# (hardware-configuration.nix is autogenerated upon installation)
# paths in nix expressions are always relative the file which defines them
imports =
[
./hardware-configuration.nix
./my-dev-tools.nix
./my-desktop-env.nix
./etc.nix
];

# Name your host machine
networking.hostName = "mymachine"; 

# Set your time zone.
time.timeZone = "Europe/Utrecht";

# Enter keyboard layout
services.xserver.layout = "us";
services.xserver.xkbVariant = "altgr-intl";

# Define user accounts
users.extraUsers = 
    { 
        myuser = 
        {
            extraGroups = [ "wheel" "networkmanager" ];
            isNormalUser = true;
        };
    };

# Install some packages
environment.systemPackages = 
        with pkgs; 
        [
            ddate
            testdisk
            zsh
        ]; 

# Enable the OpenSSH daemon
services.openssh.enable = true;

}

I always get an error on line 9 which is the beginning of the code.
and my braces always seem to be correct. what am i missing to get flakes enabled?

where do you put this in configuration.nix?

Could you explain why you didn’t like NixOS and why you prefer Arch?

Sure.

NixOS is really cool and unique, but it’s not easy to use and getting things done is slow. It’s fine if you really need to worry about reproduceability and change management, like you might in the enterprise, but for desktop use, it’s just massive overkill.

My desktop installs usually last about 4-5 years, so I’m generally not too worried about needing to start from scratch, and when I do, I’ve got shell scripts to pull down the needed packages and gnu stow to reinstall the dotfiles.

2 Likes

Hey! I been driving that NixOS on homelab as my primary server, Mac and WSL for the past two months and change. Weird that this probably is my first time posting instead of lurking but wanted to say hi to others also taking the plunge into this wonderful world of not having to remember what you did.

1 Like

Well After I have thought things through and took a step back. I am slowly starting to understand (sort of) how it works. lots of rabbit holes to go down. I am really intrigued on how you could take advantage of this distro as a development platform. I really love the feature of ephemeral shells. take ventoy as an example. no need to install this one time app. just run a nix-shell, do what you need to do then exit the shell. there it is gone.

i am not one for whatsapp, zoom etc … so for christmas I can install zoom or whatsapp in a nix-shell , talk to my mother at christmas, then exit the shell, or create a script, keep in my home folder or wherever I want for a later date if I need that app again. this is what I love about it.

flakes I had a hard time with, everyting seems to be a module of some sorts. still learning this…

anywhooo …

still researching. been running for two months. I am on the 24.11 beta. I miss my hyprland on arch. but to gain knowledge, sometimes sacrifices have to be made.

my goal is to have nixos as a development server in my homelab via ssh. this I think would be a fantastic back end R and D server. Then have arch as a front end, then I can have the best of both worlds.

been busy have not had time to come in and say hello. well here I am again. ā€œHelloā€

I have a bit of a better understanding of nixOS. I am getting there.

Regards

R-Savage

Reposting here since I might consider it, bazzite, or steam os

Playing around with Nixos. I have been looking for a powerful Neovim config. I stumbled across this Nixvim (Neovim) Setup. I have been playing around with it. It is setup as a flake.

Very Impressed with it so far.

regards

R-Savage