Sunday, November 8, 2020

One Week of NixOS

One week of NixOS

Reading time: 3 minutes.

As you may have saw I on Mastodon, I am testing NixOS for over a week now and here is a few comments about how the distro works and what doesn’t work for me.

First of all, everything is NixOS is declared in a configuration file located at /etc/nixos/configuration.nix where you declare packages you want to install, services to start, udev rules, ect, you get it.

This is the first very weird thing as you don’t really install packages with the cli directly (even if you can), instead you modify the config file and rebuild the system with nixos-rebuild switch.

NixOS is made in such a way that everything aims to be reproductible. An example: if you want to get the exact same setup as I have, you can just take my configs repo, clone it on your NixOS installation, run nixos-rebuild switch and voila, you will have the exact same programs as me installed in the same way with the same version (roughly).

In this distro, adding an user is really easy and goes like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{ config, pkgs, ... }:

{

    users.groups.plugdev = {};

    users.users.jae = {
        isNormalUser = true;
        extraGroups = [ "wheel" "docker" "adbusers" "plugdev" ];
        shell = pkgs.zsh;
        packages = with pkgs; [
            # Games
            minetest stepmania lutris-free pcsx2
            # Misc audio / video / image
            pulseeffects ffmpeg-full obs-studio inkscape krita
            # Useful software
            mumble qbittorrent libreoffice ledger-live-desktop
            # Dev
            jetbrains.idea-community lazygit gnome3.zenity insomnia jetbrains.rider mono msbuild dotnet-sdk_3 ganttproject-bin kubectx
            # SDR
            rtl-sdr gqrx gpredict noaa-apt welle-io
        ];
    };
    users.extraGroups.vboxusers.members = [ "jae" ];
}

Let’s see what everything does!

1
 users.groups.plugdev = {};

Creates a group named

plugdev

, don’t pay attention to it, it is just a test for the Ledger Live application.

Tells the os that the current user is a normal one. It will create a home folder and set the default shell.

1
 extraGroups = [ "wheel" "docker" "adbusers" "plugdev" ];

Here, we are setting the groups the user is in to grant special permissions.

As you may have guessed it, we are setting the default user shell to ZSH.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 packages = with pkgs; [
            # Games
            minetest stepmania lutris-free pcsx2
            # Misc audio / video / image
            pulseeffects ffmpeg-full obs-studio inkscape krita
            # Useful software
            mumble qbittorrent libreoffice ledger-live-desktop
            # Dev
            jetbrains.idea-community lazygit gnome3.zenity insomnia jetbrains.rider mono msbuild dotnet-sdk_3 ganttproject-bin kubectx
            # SDR
            rtl-sdr gqrx gpredict noaa-apt welle-io
        ];

There, we are installing per-user packages because yes, NixOS supports that, any user can have its own packages that others users can’t access.

This could be useful in a professional setting where only certain groups/users need a package. You could use the same config for everyone but only the right people access the right software.

Configuring NixOS for a daily use is at the end very easy (althrough I am getting some trouble to get Ledger Live working; which is the biggest problem I’ve had so far).

Now, let’s talk about where I got some trouble. As you may know it, I am a dev and every day I need to compile, test, run and so on. NixOS gave me some trouble to only run some programs from source such as Element Desktop or TeDomum IMG as the way the system is built, lots of directories are read-only and programs can’t be installed globally through NPM or PIP. I ended up using Docker to build the apps (even if it took a bit more time).

Needless to say, almost every other project worked. If you want NodeJS to start a project for instance, you can just do nix-shell -p nodejs and here you go, a shell with nodejs installed, ready to do what you want.

At the end, NixOS brings very interesting concepts such as a really great reproducibility but new users can feel lost as its way to work is really different from conventional Linux distributions. I’ll give NixOS more time and write a follow-up in some time to see how everything went.

That’s all for today, I’ll see you next time! If you like my content, don’t forget to subscribe throught RSS!



from Hacker News https://ift.tt/3n74vrk

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.