Linux Day Prato 2025: NixOS spiegato ammiocuggino - NixOS for Human Beings
bittner
12 views
36 slides
Oct 25, 2025
Slide 1 of 36
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
26
27
28
29
30
31
32
33
34
35
36
About This Presentation
NixOS è una bellissima distribuzione che ti permette di ricreare il tuo sistema configurato come attualmente da zero entro solo minuti. È 'Linux with configuration management', tutto integrato. È utile per noi privati ma anche per le aziende. Perché non lo usano ancora tutti? Eh, già!
...
NixOS è una bellissima distribuzione che ti permette di ricreare il tuo sistema configurato come attualmente da zero entro solo minuti. È 'Linux with configuration management', tutto integrato. È utile per noi privati ma anche per le aziende. Perché non lo usano ancora tutti? Eh, già!
NixOS è facile da installare ma il suo linguaggio Nix è oscenamente difficile da capire e gestire. In questo talk cerco di spiegarlo in parole semplici con concetti conosciuti da altre distribuzioni Linux, e dando soluzioni concrete per i problemi comuni.
Vieni a imparare le basi, vedere una demo funzionante, generarne una tu stesso in pochi minuti e portare la configurazione con te da questa conferenza.
Size: 5.35 MB
Language: en
Added: Oct 25, 2025
Slides: 36 pages
Slide Content
NixOS for Human
Beings
Image stolen from:
bmcgee.ie
1. You know The Language
2. You know Your Use Case
·
@peterbittner @bittner @bittner@bittner
Peter Bittner. Developer.
Of People, Companies and Code. Painless Software
Source: (p. 81)Nix: A Safe and Policy-Free System for Software Deployment
“
6 lambdas that form
a snowflake
Source: (2025)NixOS Logo and Branding Update
_ _ _ _ _ _
_ _
_ _ _
_
NixOS for the Impatient
??????
$ tree /etc/nixos
/etc/nixos
|-- configuration.nix
`-- hardware-configuration.nix # Edit this configuration file to define what should
{ config, pkgs, ... }:
environment.systemPackages = with pkgs; [
vim
];
}1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# Do not modify this file! It was generated by ‘nixo
{ config, lib, pkgs, modulesPath, ... }:
{
boot.kernelModules = [ "kvm-intel" ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/5a42e090-37b7" ;
fsType = "ext4";
};
networking.useDHCP = lib.mkDefault true;
}1 2 3 4 5 6 7 8 9 10 11 How strict are you in not editing
`hardware-configuration.nix`?
??????
$ nixos-rebuild --sudo {switch|boot| test} [--file ...|--flake ...]
...
Done. The new configuration is /nix/store/j6a42... Add more systemPackages
Configure more programs (system-wide)
Add more users and set their (initial) passwords
Manage user-specific config & programs ( )
Move config away from /etc/nixos/ (e.g. your home directory)
Split up config file when it gets too big
Start using Git, maybe ... m
Home Manager
$ ls -lAF --color /nix/store
total 7355364
dr-xr-xr-x 1 root root 6 1 Jan 1970 000bmy9k246z4bdywjkdi6hbybah9z0j-user/
dr-xr-xr-x 1 root root 0 1 Jan 1970 000fdw5ijqc8nhgnnawfy11vxf1hi8rw-system-generators/
-r--r--r-- 2 root root 3599 1 Jan 1970 000hxqh70ck7sjhdvcn66zdsyp2yprpb-source.drv
-r--r--r-- 2 root root 2221 1 Jan 1970 000hy9cqahi1rwy2mx3yak8dq02pa5ih-gst-devtools-1.26.5-vendor.drv
-r--r--r-- 2 root root 3146 1 Jan 1970 000nzak0hrcsl7d2kf3l6d544p7kyrf2-crate-num_threads-0.1.7.tar.gz.drv
-r--r--r-- 2 root root 2223 1 Jan 1970 000skmmf43a4vnxnc775s78psjr96d54-001-fix-rpath.patch.drv
-r--r--r-- 2 root root 4493 1 Jan 1970 000x39hj0g61mkp15xgkz27j7fkzkh8h-CVE-2022-48174.patch.drv
-r--r--r-- 2 root root 3615 1 Jan 1970 0010xx2b5k2kxq0c5b3pwq3bby9rdk94-source.drv
-r--r--r-- 2 root root 3314 1 Jan 1970 0015pxy9jsaxgq729bfc5ikn9n1wssbi-gnome-font-viewer-48.0.drv
... Folders = package data (build result)
.drv files = package build actions (derivation)
“
All packages are uniquely kept in the Nix Store.
There are no /bin, /sbin, /usr, etc. directories!
??????
# list concatenation
l = [ 1 2 3 ] ++ [ "four" "five"];
# logical and, logical or
m = true && false; n = true || false;
# update attribute set
s = { x = 1; } // { y = 1; x = 2; };
# has attribute (attribute set member)
h = { x = 42; } ? x;
} operators {
# numbers
a = 1; f = 3.14;
# strings
text = "Hello Pi! ${f}";
multi_line = ''
Very long text ... with ${a}
'';
# paths
x = /absolute/path/to
y = ./relative/path
z = ~/.config # path in home dir
} datatype features {
# available = builtins;
yes = true; no = false; nothing = null;
system = builtins.currentSystem;
epoch = builtins.currentTime;
packages = builtins.storeDir;
paths = builtins.nixPath;
language = builtins.langVersion;
version = builtins.nixVersion;
} built-in constants {
d = builtins.readDir;
f = builtins.readFile;
e = builtins.getEnv "HOME";
s = builtins.substring 0 3 "nixos";
...
} built-in functions
$ nixos-rebuild --sudo --file ~/.config/nixos/default.nix
...
Done. The new configuration is /nix/store/j6a42... Add more software (systemPackages, programs)
Split up config file when it gets too big
Start using Git, maybe ... m (... after breaking the setup)
$ nix run nixpkgs#git
...
$ nix shell nixpkgs#cowsay nixpkgs#lolcat
$ cowsay 'Hello Linuxday!' | lolcat
_________________
< Hello Linuxday! >
-----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| || Install and run programs ad-hoc ("because I can!")
Split up config file when it gets too big
Switch to Flake-based NixOS setup (to fight flaky updates)
Maybe put configuration under version control (Git)
$ nixos-rebuild switch --sudo --flake gitlab:painless-software/nixos-config
...
Done. The new configuration is /nix/store/j6a42...
$ nixos-rebuild test --sudo --flake .
building the system configuration...
Place your finger on the fingerprint reader
activating the configuration...
$ nix flake check
$ nix flake show
$ nix flake update Split up config file when it gets too big
Use Flake-based setup (for more control about what is installed)
Manage nixos-config with Git, install using remote URL
Automate system updates (e.g. system.autoUpgrade)
$ uvx pyclean
$ uvx copier update Install only uv (but not any Python!) via systemPackages
Manage Python versions (and tools) locally using uv
Use nix-ld to fix the dynamic linking problem {
environment = {
localBinInPath = true; # ~/.local/bin in PATH
systemPackages = with pkgs; [
uv # install Pythons in user-space using uv
];
};
$ nix build nixpkgs#hello
$ ls -l
lrwxrwxrwx 1 peter users 56 25 Ott 15:42 result -> /nix/store/9mj...as2fis-hello-2.12.2
$ ./result/bin/hello
Hello, world! Create Nix packages by writing them like a God
Maybe use tooling such as nix-init for "nixification"
Use nix build to build and locally verify a package setup
hosts/ – managed machines
roles/ – classes of machines (abstraction layer)
system/ – system-global configuration
home/ – user configuration
user/ – common user configuration gitlab.com/painless-software/nixos-config
Manage user-specific software and settings ("dotfiles")
standalone vs. NixOS module
has own (most matching with nixpkgs)configuration options
Declarative disk partitioning
“
disko-config.nix $ sudo nix run github:nix-community/disko /latest -- \
--mode destroy,format,mount \
--flake gitlab:painless-software/nixos-config# example ??????
Flake
Establish execution
entrypoint (e.g.
integrate hosts/).
Consider integrating
QA tools, pre-commit
and CI/CD early.
1.
Home Manager
Allow configuring
settings and installing
software for individual
users.
Consider using LDAP
for a flexible, host-
independent setup.
3.
Disko
Integrate Disko
configuration. Verify
installation process
end-to-end.
Consider setting up
functional tests with
VMs.
2.
Refine
Delegate host setup to
system/ configuration.
Consider introducing
roles/.
Consolitate home/
features in common
user/ modules.
4.
??????
Most static backgrounds from Unsplash (CC BY-SA)
Animated backgrounds from GIPHY (CC BY-SA)
Decorative icons are unicode (CC-0)
Less pain, more fun.
“
Wow!
This presentation
was made entirely
without any AI!