NixOS 23.05 is a really impressive Linux distro, it is stable as Debian stable and updated as Archlinux.
NixOS Linux killer features
- Declarative: in normal Linux distro you configure the operating system with a sequence of commands, in NixOS you describe the configuration state in a
configuration.nix
file. It means that you can recreate and kept update the same OS configuration easly in VMs or bare metal servers. No more exotic bugs because you forget a step. - Rollback without BTRFS: NixOS keep old libraries and software in the OS via symlinks so if something bad happens you can rollback to a previous working configuration. No more inconsistent updates, just atomic updates! NB: it isn't a full backup alternative, if the updates execute a database migration you have to use a backup of the previous version to do the rollback
- Rolling release or point release? NixOS has a huge list of packages supported and you can choose as base the stable channel like
nixos-23.05
ornixos-unstable
.
Nix flake is magic
There is a lot of documentation in the official website or NixOS Wiki, but all the hype is towards Nix Flakes, the new way to install and update the system, it is available by default but it is marked as experimental so it's quite confusing the first set up, but it is the way to go.
Basically you need to move once /etc/nixos/configuration.nix
, which was generated by the graphical installer, in a new directory. flake.nix
is the entrypoint, while flake.lock
keep track the exact commit of your system packages and dependencies.
It's like in NodeJS with packages.json
and packages.lock
, you can have multiple projects/machine under git with the exact dependencies.
Real world usage
Let's start updating the packages index, the equivalent of apt update
is nix flake update
which updates the flake.lock
to the latest version available as package base.
$ nix flake update
warning: updating lock file '/home/user/mysystem/flake.lock':
• Updated input 'nixpkgs':
'github:nixos/nixpkgs/d8bb6c681cf86265fdcf3cc3119f757bbb085835' (2023-07-07)
→ 'github:nixos/nixpkgs/8df7a67abaf8aefc8a2839e0b48f92fdcf69a38b' (2023-07-09)
Then you can update configure.nix
if you want add or remove some software.
When you are satisfied with the changes you can preview and or apply the changes with nix-rebuild
. Check the video for more details.
Using sudo
is important for nix-rebuild
, because you can have both system and user packages on Nix.
$ sudo nixos-rebuild dry-run --flake .#myNixos
building the system configuration...
these 40 derivations will be built:
/nix/store/wjp7ipnxsy17jamaa1alxgdx1by9r200-linux-6.1.38-modules.drv
/nix/store/s9py3zs9gn1zmzxy8xj13vn5ky2824g1-linux-6.1.38-modules-shrunk.drv
/nix/store/0zx07nj6v3a1anwgi2jicgcbib948ymi-stage-1-init.sh.drv
/nix/store/1qkn5is6i0kdh77nkcvwk37z38zrhxva-issue.drv
...
these 70 paths will be fetched (217.38 MiB download, 659.00 MiB unpacked):
/nix/store/0pb1yvcbs51nyivlgx9mrrkq7w1bq4cs-gnome-weather-44.0
/nix/store/15d9rzya7sadawpff5mnm4sfcw3ynadq-NetworkManager-fortisslvpn-gnome-1.4.0
/nix/store/1s962a4ca62h04vrmv2d2ac94n50g4mf-gnome-software-44.1
/nix/store/1szj5vy0ab8dbdkgxfspvxv3sz9gj1kj-gnome-settings-daemon-44.1
/nix/store/3adm2l7z920wdiyr2l734zappd1g1n77-spidermonkey-102.13.0
/nix/store/4391dn2xcxbrsix4jjnpha3lir3b5d5k-gnome-session-44.0
...
OK, these are the changes will be applied you can proceed with nixos-rebuild switch
$ sudo nixos-rebuild switch --flake .#myNixos
building the system configuration...
stopping the following units: accounts-daemon.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket, systemd-udevd.service
NOT restarting the following changed units: display-manager.service, systemd-fsck@dev-disk-by\x2duuid-C3C0\x2dB94C.service
activating the configuration...
setting up /etc...
reloading user units for user...
setting up tmpfiles
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket
Conclusion, will NixOS replace Debian/Ubuntu/RedHat/OpenSuse and other "standard" Linux distros ?
Server: "Atomic updates", "immutability" are the new buzzwords also for the Linux mainstream distros, Fedora has Silverblue, Debian has Endless/Vanilla, OpenSuse has MicroSomething, but honestly it's another paradigm, new stuff to learn, and if Debian stable + Docker Compose works for you (or another mature approch like Ansible,..) maybe you don't see an urgency, but it's worth to try NixOS for new projects.
Desktop: Archlinux AUR is fantastic, but unreliable, sometimes the software compiles, sometimes not. PPA repositories work on Debian but sometimes not. NixOS has a great balance between new software and stability but a desktop user do expect to write lines in a text file to make the Bluetooth audio work.
NixOS is a very different Linux distro, it has already benefits over classical Linux distros, stability, packages and atomic updates, but currently it's for "pro users", maybe nix flake
once stable will speed up the adoption in the server space and for the desktop more GUIs are needed to enable NixOS powers also to non techie users.
from Hacker News https://ift.tt/WkuzSlv
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.