30 KiB
NixOS
This document contains general notes about NixOS that are independent of my NixOS configuration.
Table of Contents
- NixOS
- Table of Contents
- Misc
- Upgrade from 23.05 to 23.11
- niv: Dependency management
- Garbage collection
- System information
- Search for packages
- Search for options
- Search which package owns a file
- List files of package
- Package runtime dependency report
- Compare two versions of NixOS system profile
- NixOS configuration debugging
- Show Nix configuration
- Evaluate NixOS configuration to JSON
- Evaluate expressions
- Escape strings
- Run AppImages
- Graphic drivers
- Additional resources
Misc
- There is controversy about flakes, rather use channels (e.g. with niv)
- Prins, P., Suresh, J. and Dolstra, E., "Nix fixes dependency hell on all Linux distributions," Archived December 26, 2008, at the Wayback Machine linux.com, December 22, 2008
Upgrade from 23.05 to 23.11
Change the tracking branch of nixpkgs from 23.05 to 23.11:
niv modify nixpkgs --branch nixos-23.11
niv modify home-manager --branch release-23.11
Update home.stateVersion
to home.stateVersion = "23.11";
in order to match the NixOS channel. Read the corresponding release notes: https://nix-community.github.io/home-manager/release-notes.xhtml#sec-release-23.11
Read the release notes. GNOME 45: Notably, Loupe has replaced Eye of GNOME as the default image viewer, Snapshot has replaced Cheese as the default camera application, and Photos will no longer be installed.
Updating with nixos-rebuild boot and rebooting is recommended.
niv update && colmena build --on yodaTux -v --show-trace && colmena apply-local --sudo boot
niv update && colmena build --on remoteTab -v --show-trace && colmena apply --on remoteTab boot
niv update && colmena build --on @server -v --show-trace && colmena apply --on @server boot
Update channel (for nix-shell
usage in a terminal):
sudo nix-channel --list
#=> nixos https://nixos.org/channels/nixos-23.05
sudo nix-channel --add https://nixos.org/channels/nixos-23.11 nixos
sudo nix-channel --update
niv: Dependency management
niv:
Easy dependency management for Nix projects.
Nix is a very powerful tool for building code and setting up environments. niv complements it by making it easy to describe and update remote dependencies (URLs, GitHub repos, etc). It is a simple, practical alternative to Nix flakes.
Niv is an easy dependency management for Nix projects with package pinning.
Initialize:
niv init
Change the tracking branch of nixpkgs from unstable to 23.05:
niv modify nixpkgs --branch nixos-23.05
Add nixpkgs unstable:
niv add NixOS/nixpkgs -n unstable -b nixpkgs-unstable
Add Home Manager with niv
Home Manager:
[Home Manager] allows declarative configuration of user specific (non-global) packages and dotfiles.
To avoid breaking users' configurations, Home Manager is released in branches corresponding to NixOS releases ( e.g.
release-23.05
).Home Manager provides both the channel-based setup and the flake-based one.
Check your channel:
sudo nix-channel --list
#=> nixos https://nixos.org/channels/nixos-23.05
Use the corresponding branch:
niv add nix-community/home-manager -n home-manager -b release-23.05
Add NUR with niv
The Nix User Repository (NUR) is community-driven meta repository for Nix packages.
... packages are built from source and are not reviewed by any Nixpkgs member.
niv add nix-community/NUR -n NUR
Garbage collection
- https://nixos.org/manual/nix/stable/package-management/garbage-collection.html
- https://discourse.nixos.org/t/why-doesnt-nix-collect-garbage-remove-old-generations-from-efi-menu/17592/4
This is automated in base.nix with the nix.gc
option.
Run manually for all profiles:
sudo nix-collect-garbage --delete-older-than 14d
Remove leftover EFI entries of removed generations:
sudo /run/current-system/bin/switch-to-configuration boot
System information
nix-info -m
- system: `"x86_64-linux"`
- host os: `Linux 6.1.51, NixOS, 23.05 (Stoat), 23.05.3242.da5adce0ffaf`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.13.5`
- channels(root): `"nixos-23.05"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Search for packages
Search for options
- https://search.nixos.org/options?channel=23.05
- Or
man configuration.nix
- Or
- https://mipmip.github.io/home-manager-option-search
- Or
man home-configuration.nix
- Or
Search which package owns a file
# Note how your shell prefix changes.
nix-shell -p nix-index
# Either build the index manually (requires >12GB RAM):
nix-index
# Or download weekly build:
mkdir -p ~/.cache/nix-index/ && wget -q -N https://github.com/nix-community/nix-index-database/releases/latest/download/index-x86_64-linux -O ~/.cache/nix-index/files
# Then search for a file
nix-locate --whole-name '/bash'
List files of package
Example for nano
:
find $(nix-build '<nixpkgs>' -A nano --no-link)
Excerpt of the result:
/nix/store/jqvxmx65mfinbsm6db9kmcqmphl44xhp-nano-7.2/share/nano
/nix/store/jqvxmx65mfinbsm6db9kmcqmphl44xhp-nano-7.2/share/nano/asm.nanorc
/nix/store/jqvxmx65mfinbsm6db9kmcqmphl44xhp-nano-7.2/share/nano/autoconf.nanorc
Package runtime dependency report
- https://github.com/nix-how/nix-demos#runtimereport -> https://www.nmattia.com/posts/2019-10-08-runtime-dependencies/
Example: Licenses and maintainers of runtime dependencies of package hello
:
nix --extra-experimental-features flakes --extra-experimental-features nix-command bundle --bundler github:nix-how/nix-demos#runtimeReport nixpkgs#hello
cat hello-*-report
---------------------------------
| OFFICIAL REPORT |
| requested by: the lawyers |
| written by: yours truly |
| TOP SECRET - TOP SECRET |
---------------------------------
runtime dependencies of hello-2.12.1:
- libunistring-1.1 (lgpl3Plus) maintained by
- xgcc-13.2.0 (gpl3Plus) maintained by Patrick Hilhorst, Vladimír Čunát, John Ericson
- hello-2.12.1 (gpl3Plus) maintained by Eelco Dolstra
- libidn2-2.3.4 (lgpl3Plus, gpl2Plus, gpl3Plus) maintained by Franz Pletz
- glibc-2.38-27 (lgpl2Plus) maintained by Eelco Dolstra, Maximilian Bosch, Connor Baker
Example: nano
---------------------------------
| OFFICIAL REPORT |
| requested by: the lawyers |
| written by: yours truly |
| TOP SECRET - TOP SECRET |
---------------------------------
runtime dependencies of nano-7.2:
- libunistring-1.1 (lgpl3Plus) maintained by
- file-5.45 (bsd2) maintained by Doron Behar
- xgcc-13.2.0 (gpl3Plus) maintained by Patrick Hilhorst, Vladimír Čunát, John Ericson
- nano-7.2 (gpl3Plus) maintained by Joachim Fasting, Tim Steinbach
- libidn2-2.3.4 (lgpl3Plus, gpl2Plus, gpl3Plus) maintained by Franz Pletz
- zlib-1.3 (zlib) maintained by nobody
- glibc-2.38-27 (lgpl2Plus) maintained by Eelco Dolstra, Maximilian Bosch, Connor Baker
- ncurses-6.4 (mit) maintained by nobody
Example: firefox
---------------------------------
| OFFICIAL REPORT |
| requested by: the lawyers |
| written by: yours truly |
| TOP SECRET - TOP SECRET |
---------------------------------
runtime dependencies of firefox-121.0.1:
- libunistring-1.1 (lgpl3Plus) maintained by
- perl5.38.2-WWW-RobotRules-6.02 (artistic1, gpl1Plus) maintained by nobody
- gdbm-1.23 (gpl3Plus) maintained by Rahul Gopinath
- perl5.38.2-HTTP-CookieJar-0.014 (asl20) maintained by nobody
- gmp-with-cxx-6.3.0 (lgpl3Only, gpl2Only) maintained by Rahul Gopinath
- libXdamage-1.1.6 (no license) maintained by nobody
- expat-2.5.0 (mit) maintained by nobody
- gnutls-3.8.2 (lgpl21Plus) maintained by Vladimír Čunát
- dbus-1.14.10 (gpl2Plus) maintained by Jan Tojnar
- systemd-minimal-libs-254.6 (lgpl21Plus) maintained by Florian Klink, Finn Behrens
- gnutar-1.35 (gpl3Plus) maintained by
- util-linux-minimal-2.39.3 (gpl2Only, gpl2Plus, gpl3Plus, lgpl21Plus, bsd3, bsdOriginalUC, publicDomain) maintained by nobody
- gdk-pixbuf-2.42.10 (lgpl21Plus) maintained by Eelco Dolstra, Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey
- tracker-3.6.0 (gpl2Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey
- libXext-1.3.5 (no license) maintained by nobody
- openssl-3.0.12 (asl20) maintained by Markus Theil
- at-spi2-core-2.50.0 (lgpl21Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey, Michael Raskin
- libXtst-1.2.4 (no license) maintained by nobody
- gcc-13.2.0 (gpl3Plus) maintained by Patrick Hilhorst, Vladimír Čunát, John Ericson
- bzip2-1.0.8 (bsdOriginal) maintained by Jörg Thalheim
- perl5.38.2-TimeDate-2.33 (artistic1, gpl1Plus) maintained by nobody
- libsoup-3.4.4 (lgpl2Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey, Jason O'Conal, Michael Raskin
- dconf-0.40.0 (lgpl21Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey
- cairo-1.18.0 (lgpl2Plus, mpl10) maintained by nobody
- libxcrypt-4.4.36 (lgpl21Plus) maintained by Misha Gusarov, Martin Weinelt
- libxml2-2.12.3-unstable-2023-12-14 (mit) maintained by Eelco Dolstra, Jan Tojnar
- libffi-3.4.4 (mit) maintained by Matthew Bauer
- perl5.38.2-Test-Fatal-0.017 (artistic1, gpl1Plus) maintained by nobody
- gcc-13.2.0 (gpl3Plus) maintained by Patrick Hilhorst, Vladimír Čunát, John Ericson
- libnetfilter_conntrack-1.0.9 (gpl2Plus) maintained by nobody
- shadow-4.14.2 (bsd3) maintained by nobody
- util-linux-minimal-2.39.3 (gpl2Only, gpl2Plus, gpl3Plus, lgpl21Plus, bsd3, bsdOriginalUC, publicDomain) maintained by nobody
- zstd-1.5.5 (bsd3) maintained by Orivej Desh
- libyaml-0.2.5 (mit) maintained by nobody
- db-4.8.30 (sleepycat) maintained by nobody
- json-c-0.17 (mit) maintained by Jason O'Conal
- avahi-0.8 (lgpl2Plus) maintained by Jason O'Conal, Robin Gloster
- libXfixes-6.0.1 (no license) maintained by nobody
- libsoup-2.74.3 (lgpl2Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey, Jason O'Conal, Michael Raskin
- libapparmor-3.1.6 (gpl2Only, lgpl21Only) maintained by Julien Moutinho, Austin Seipp, Andreas Schrägle, Janne Heß
- cups-2.4.7 (asl20) maintained by Matthew Bauer
- wayland-1.22.0 (mit) maintained by Michael Weiss, Cody Opel, Alyssa Ross
- libXrandr-1.5.4 (no license) maintained by nobody
- cryptsetup-2.6.1 (gpl2) maintained by Ryan Lahfa
- nghttp2-1.57.0 (mit) maintained by Renaud
- file-5.45 (bsd2) maintained by Doron Behar
- gtk+3-3.24.39 (lgpl2Plus) maintained by Michael Raskin, Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey
- giflib-5.2.1 (mit) maintained by
- gmp-with-cxx-6.3.0 (lgpl3Only, gpl2Only) maintained by Rahul Gopinath
- libselinux-3.3 (gpl2Plus) maintained by
- freetype-2.13.2 (gpl2Plus) maintained by Thomas Tuegel
- graphite2-1.3.14 (lgpl21) maintained by Michael Raskin
- bash-5.2-p21 (gpl3Plus) maintained by Will Dietz
- perl5.38.2-Net-HTTP-6.23 (artistic1, gpl1Plus) maintained by nobody
- xkeyboard-config-2.40 (no license) maintained by nobody
- audit-3.1.2 (gpl2Plus) maintained by Anderson Torres
- libXrender-0.9.11 (no license) maintained by nobody
- gnum4-1.4.19 (gpl3Plus) maintained by nobody
- libdeflate-1.19 (mit) maintained by Orivej Desh, Dmitry Bogatov
- perl5.38.2-HTTP-Cookies-6.10 (artistic1, gpl1Plus) maintained by nobody
- fribidi-1.0.13 (lgpl21) maintained by nobody
- libfido2-1.14.0 (bsd2) maintained by Will Dietz, Pavol Rusnak
- libuv-1.47.0 (mit, isc, bsd2, bsd3, cc-by-40) maintained by Mario Rodas
- python3-3.11.7 (psfl) maintained by Frederik Rietdijk
- xgcc-13.2.0 (gpl3Plus) maintained by Patrick Hilhorst, Vladimír Čunát, John Ericson
- libmnl-1.0.5 (lgpl21Plus) maintained by nobody
- util-linux-minimal-2.39.3 (gpl2Only, gpl2Plus, gpl3Plus, lgpl21Plus, bsd3, bsdOriginalUC, publicDomain) maintained by nobody
- libthai-0.1.29 (lgpl21Plus) maintained by
- gawk-5.2.2 (gpl3Plus) maintained by
- libXmu-1.1.4 (no license) maintained by nobody
- unbound-1.19.0 (bsd3) maintained by Andreas Schrägle, Janne Heß
- perl5.38.2-HTTP-Message-6.45 (artistic1, gpl1Plus) maintained by nobody
- libbpf-1.3.0 (lgpl21, bsd2) maintained by Austin Seipp, Vladimír Čunát, Sascha Grunert, Dominique Martinet
- pixman-0.42.2 (mit) maintained by nobody
- libXft-2.3.8 (no license) maintained by nobody
- libGL-1.7.0 (mit, bsd1, bsd3, gpl3Only, asl20) maintained by nobody
- firefox-121.0.1 (mpl20) maintained by Bernardo Meurer, Martin Weinelt
- util-linux-minimal-2.39.3 (gpl2Only, gpl2Plus, gpl3Plus, lgpl21Plus, bsd3, bsdOriginalUC, publicDomain) maintained by nobody
- perl5.38.2-Clone-0.46 (artistic1, gpl1Plus) maintained by nobody
- iptables-1.8.10 (gpl2) maintained by Franz Pletz
- libssh2-1.11.0 (bsd3, libssh2) maintained by Sandro Jäckel
- systemd-minimal-254.6 (lgpl21Plus) maintained by Florian Klink, Finn Behrens
- icu4c-73.2 (no license) maintained by Michael Raskin
- pango-1.51.0 (lgpl2Plus) maintained by Michael Raskin, Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey
- libmicrohttpd-0.9.71 (lgpl2Plus) maintained by Eelco Dolstra, Rahul Gopinath, Franz Pletz
- libcbor-unstable-2023-01-29 (mit) maintained by Will Dietz
- attr-2.5.1 (gpl2Plus) maintained by nobody
- perl5.38.2-HTML-Parser-3.81 (artistic1, gpl1Plus) maintained by nobody
- libSM-1.2.4 (no license) maintained by nobody
- libpng-apng-1.6.40 (libpng2) maintained by Vladimír Čunát
- glib-2.78.3 (lgpl21Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey, Jason O'Conal, Michael Raskin
- gsettings-desktop-schemas-45.0 (lgpl21Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey
- nettle-3.9.1 (gpl2Plus) maintained by Vladimír Čunát
- perl5.38.2-HTTP-Date-6.06 (artistic1, gpl1Plus) maintained by nobody
- libusb-1.0.26 (lgpl21Plus) maintained by Pavol Rusnak, Ido Samuelson
- libargon2-20190702 (asl20, cc0) maintained by Taeer Bar-Yam, Owen Lynch
- brotli-1.1.0 (mit) maintained by freezeboy
- glibc-2.38-27 (lgpl2Plus) maintained by Eelco Dolstra, Maximilian Bosch, Connor Baker
- libcap-ng-0.8.3 (lgpl21) maintained by nobody
- libnftnl-1.2.6 (gpl2Plus) maintained by Franz Pletz, Andreas Schrägle, Janne Heß
- libxcb-1.16 (no license) maintained by nobody
- glibc-2.38-27 (lgpl2Plus) maintained by Eelco Dolstra, Maximilian Bosch, Connor Baker
- libpcap-1.10.4 (bsd3) maintained by Franz Pletz
- libXt-1.3.0 (no license) maintained by nobody
- publicsuffix-list-unstable-2023-02-16 (mpl20) maintained by Renaud
- libepoxy-1.5.10 (mit) maintained by Cillian de Róiste
- libX11-1.8.7 (no license) maintained by nobody
- keyutils-1.6.3 (gpl2Plus) maintained by nobody
- libXcursor-1.2.1 (no license) maintained by nobody
- fontconfig-2.14.2 (bsd2) maintained by Jan Tojnar
- tzdata-2023d (bsd3, publicDomain) maintained by Andreas Schrägle, Franz Pletz
- tpm2-tss-4.0.1 (bsd2) maintained by Arthur Gautier
- libxkbcommon-1.5.0 (mit) maintained by Michael Weiss, Thomas Tuegel
- bash-interactive-5.2-p21 (gpl3Plus) maintained by Will Dietz
- sqlite-3.44.2 (publicDomain) maintained by Eelco Dolstra, Nicolas Pouillard
- perl5.38.2-XML-Parser-2.46 (artistic1, gpl1Plus) maintained by nobody
- perl5.38.2-HTTP-Daemon-6.16 (artistic1, gpl1Plus) maintained by nobody
- getent-glibc-2.38-27 (no license) maintained by nobody
- libcap-2.69 (bsd3) maintained by nobody
- xz-5.4.5 (gpl2Plus, lgpl21Plus) maintained by Sander van der Burg
- perl5.38.2-Test-Needs-0.002010 (artistic1, gpl1Plus) maintained by nobody
- perl5.38.2-File-Listing-6.16 (artistic1, gpl1Plus) maintained by nobody
- libdatrie-2019-12-20 (lgpl21Plus) maintained by
- readline-8.2p7 (gpl3Plus) maintained by Will Dietz
- libXcomposite-0.4.6 (no license) maintained by nobody
- perl5.38.2-IO-HTML-1.004 (artistic1, gpl1Plus) maintained by nobody
- coreutils-9.4 (gpl3Plus) maintained by Janne Heß
- dejavu-fonts-minimal-2.37 (free) maintained by nobody
- glib-2.78.3 (lgpl21Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey, Jason O'Conal, Michael Raskin
- libpsl-0.21.2 (mit) maintained by Renaud
- libgpg-error-1.47 (lgpl2Plus) maintained by Rahul Gopinath
- libnl-3.8.0 (lgpl21) maintained by Franz Pletz
- openssl-3.0.12 (asl20) maintained by Markus Theil
- pcre-8.45 (bsd3) maintained by
- perl5.38.2-Try-Tiny-0.31 (mit) maintained by nobody
- libidn2-2.3.4 (lgpl3Plus, gpl2Plus, gpl3Plus) maintained by Franz Pletz
- libtool-2.4.7 (gpl2Plus) maintained by
- p11-kit-0.25.3 (bsd3) maintained by nobody
- harfbuzz-7.3.0 (mit) maintained by Eelco Dolstra
- gnugrep-3.11 (gpl3Plus) maintained by Janne Heß, Moritz Lumme
- zlib-1.3 (zlib) maintained by nobody
- gnused-4.9 (gpl3Plus) maintained by Jörg Thalheim
- libXdmcp-1.1.4 (no license) maintained by nobody
- libnfnetlink-1.0.2 (gpl2) maintained by nobody
- libevent-2.1.12 (bsd3) maintained by nobody
- libICE-1.1.1 (no license) maintained by nobody
- libmd-1.1.0 (bsd3, bsd2, isc, beerware, publicDomain) maintained by Michael Weiss
- lvm2-2.03.22 (gpl2, bsd2, lgpl21) maintained by Michael Raskin, Andreas Schrägle, Janne Heß
- lz4-1.9.4 (bsd2, gpl2Plus) maintained by nobody
- glibc-2.38-27 (lgpl2Plus) maintained by Eelco Dolstra, Maximilian Bosch, Connor Baker
- libdaemon-0.14 (lgpl2Plus) maintained by nobody
- elfutils-0.190 (gpl2Only, lgpl3Plus, gpl3Plus) maintained by Eelco Dolstra, Ryan Burns
- libwebp-1.3.2 (bsd3) maintained by Andreas Schrägle
- libXi-1.8.1 (no license) maintained by nobody
- gobject-introspection-1.78.1 (gpl2, lgpl2) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey, Jason O'Conal, Artturi N
- json-glib-1.8.0 (lgpl21Plus) maintained by Bobby Rong, Tor Hedin Brønner, Jan Tojnar, Daniel Șerbănescu, Maxine Aubrey
- xz-5.4.5 (gpl2Plus, lgpl21Plus) maintained by Sander van der Burg
- tcb-1.2 (bsd3) maintained by Yurii Izorkin
- pcre2-10.42 (bsd3) maintained by Thomas Tuegel
- kexec-tools-2.0.26 (gpl2) maintained by nobody
- kmod-31 (lgpl21Plus, gpl2Plus) maintained by Artturi N
- libunwind-1.6.2 (mit) maintained by Orivej Desh
- perl-5.38.2 (artistic1) maintained by Eelco Dolstra
- libseccomp-2.5.5 (lgpl21Only) maintained by Austin Seipp
- perl5.38.2-Encode-Locale-1.05 (artistic1, gpl1Plus) maintained by nobody
- perl5.38.2-Test-RequiresInternet-0.05 (artistic1, gpl1Plus) maintained by nobody
- ncurses-6.4 (mit) maintained by nobody
- zstd-1.5.5 (bsd3) maintained by Orivej Desh
- curl-8.4.0 (curl) maintained by Jason O'Conal
- perl5.38.2-HTTP-Negotiate-6.01 (artistic1, gpl1Plus) maintained by nobody
- perl5.38.2-libwww-perl-6.72 (artistic1, gpl1Plus) maintained by nobody
- systemd-254.6 (lgpl21Plus) maintained by Florian Klink, Finn Behrens
- popt-1.19 (mit) maintained by Alyssa Ross
- kmod-31 (lgpl21Plus, gpl2Plus) maintained by Artturi N
- libXinerama-1.1.5 (no license) maintained by nobody
- libgcrypt-1.10.3 (lgpl2Plus) maintained by Rahul Gopinath
- acl-2.3.1 (gpl2Plus) maintained by nobody
- libtasn1-4.19.0 (lgpl2Plus) maintained by nobody
- perl5.38.2-HTML-Tagset-3.20 (artistic1, gpl1Plus) maintained by nobody
- pcsclite-2.0.1 (bsd3) maintained by Anthony Roussel
- libtiff-4.6.0 (libtiff) maintained by nobody
- bzip2-1.0.8 (bsdOriginal) maintained by Jörg Thalheim
- libbsd-unstable-2023-04-29 (beerware, bsd2, bsd3, bsdOriginal, isc, mit) maintained by Matthew Bauer
- libkrb5-1.21.2 (mit) maintained by nobody
- iso-codes-4.15.0 (lgpl21) maintained by nobody
- fontconfig-2.14.2 (bsd2) maintained by Jan Tojnar
- gzip-1.13 (gpl3Plus) maintained by nobody
- linux-pam-1.5.2 (bsd3) maintained by nobody
- libjpeg-turbo-2.1.5.1 (ijg) maintained by Vladimír Čunát, Cole Mickens, Kevin Amado
- perl5.38.2-URI-5.21 (artistic1, gpl1Plus) maintained by nobody
- dav1d-1.2.1 (bsd2) maintained by Michael Weiss
- perl5.38.2-LWP-MediaTypes-6.04 (artistic1, gpl1Plus) maintained by nobody
- libXau-1.0.11 (no license) maintained by nobody
Compare two versions of NixOS system profile
Get latest system profile. This is the profile (usually) being active after booting the system:
ls -1 /nix/var/nix/profiles/ | sort -t'-' -n -k2 | tail -n 1
#=> 120
Compare current with previous profile:
# https://discourse.nixos.org/t/how-to-know-what-nixpkgs-changes-affect-me/18142/6
prev="$(ls -r /nix/var/nix/profiles/ | grep -E 'system\-' | sed -n '2 p')"
curr=/nix/var/nix/profiles/system
nix --extra-experimental-features nix-command store diff-closures /nix/var/nix/profiles/"${prev}" "${curr}"
# https://stackoverflow.com/a/36641298
prev="$(ls -1 /nix/var/nix/profiles/ | sort -t'-' -n -k2 | tail -n 2 | head -n 1)"
curr="$(ls -1 /nix/var/nix/profiles/ | sort -t'-' -n -k2 | tail -n 1)"
nix --extra-experimental-features nix-command store diff-closures /nix/var/nix/profiles/"${prev}" /nix/var/nix/profiles/"${curr}"
Compare two arbitrary system profiles:
nix --extra-experimental-features nix-command store diff-closures /nix/var/nix/profiles/system-110-link /nix/var/nix/profiles/system-116-link
cpupower: 6.1.47 → 6.1.51
element-desktop: 1.11.38 → 1.11.40, +2218.9 KiB
element-web: 1.11.38 → 1.11.40, -73.1 KiB
exempi: 2.6.3 → 2.6.4
firefox: 116.0.3 → 117.0
firefox-unwrapped: 116.0.3 → 117.0, -292.6 KiB
gnome-shell-extension-openweather: ∅ → 121, +590.5 KiB
hm_fontconfigconf.d10hmfonts.conf: ∅ → ε
initrd: ∅ → ε
initrd-linux: 6.1.47 → 6.1.51
libcap: 2.68 → 2.69
linux: 6.1.47, 6.1.47-modules → 6.1.51, 6.1.51-modules, -11.8 KiB
meld: ∅ → 3.22.0, +3858.5 KiB
net-snmp: 5.9.3 → 5.9.4
nixos-system-yodaTab: 23.05.3085.2ab91c8d65c0 → 23.05.3242.da5adce0ffaf
openjdk: +19.5 KiB
python3.10-pygobject: +27.0 KiB
stage: ∅ → 1-init.sh, +29.5 KiB
tor-browser-bundle-bin: 12.5.2 → 12.5.3, +18.1 KiB
user: +2885.0 KiB
NixOS configuration debugging
Evaluating parts of the configuration.
First, start nix repl
:
nix repl --file '<nixpkgs/nixos>' -I nixos-config=hosts/$(hostname)/configuration.nix
Example: config.home-manager
config.home-manager.
# Press `TAB`
#=> config.home-manager.backupFileExtension config.home-manager.useUserPackages
#=> config.home-manager.extraSpecialArgs config.home-manager.users
#=> config.home-manager.sharedModules config.home-manager.verbose
#=> config.home-manager.useGlobalPkgs
Example: The home
variable:
config.home-manager.users.yoda.home
Example: The value of one config option
# The following option is set to `"${config.xdg.dataHome}/.histfile";`
# where `config` is the Home Manager configuration.
config.home-manager.users.yoda.programs.zsh.history.path
#=> "/home/yoda/.local/share/.histfile"
Show Nix configuration
nix --extra-experimental-features nix-command show-config
Evaluate NixOS configuration to JSON
See also section "NixOS Configuration Debugging"!
This evaluates configuration.nix
(single module):
NIXPKGS_ALLOW_UNFREE=1 nix-instantiate --strict --json --eval -E '
import ./hosts/yodaTab/configuration.nix {
config = {};
pkgs = import <nixpkgs> {};
lib = import <nixpkgs/lib>;
}
' > evaluated-config.json
Then open evaluated-config.json
.
Evaluate expressions
nix-instantiate --eval -E 'with import <nixpkgs> { }; vscode.version'
#=> "1.78.2"
Shell wrapper:
nix-eval() { nix-instantiate --eval -E "with import <nixpkgs> {}; ${*}"; }
Examples:
nix-eval 'vscode.version'
#=> "1.78.2"
nix-eval 'lib.forEach [ 1 2 ] (x: toString x)'
#=> [ "1" "2" ]
nix-eval 'lib.head [1 2]'
#=> 1
nix-eval 'lib.head (
lib.forEach [ 1 2 ] (x: toString x)
)'
#=> "1"
nix-eval 'lib.head (
lib.forEach [ {a=1;} {a=2;} ] (x: x.a)
)'
#=> 1
nix-eval 'lib.attrsets.mergeAttrsList [{a=1;} {b=2;}]'
#=> { a = 1; b = 2; }
nix-eval '{ a=1; }.b or 2'
#=> 2
nix-eval '{ a=false; }.a or true'
#=> false
nix-eval '{ a=1; }?a'
#=> true
nix-eval 'with lib.strings; concatMapStrings (x: " -a " + x + " -i 600") ["sda" "sdc"]'
#=> " -a sda -i 600 -a sdc -i 600"
Escape strings
Double-quoted strings (e.g. "foo bar"
):
" -> \"
\ -> \\
${ -> \${
Indented strings (e.g. ''foo bar''
):
${
->''${
''
->'''
URIs can be written without quotes (e.g. http://example.org/foo.bar
).
Run AppImages
# Note how your shell prefix changes.
nix-shell -p appimage-run
# Inside the shell, you can run an AppImage:
appimage-run ~/Downloads/ubports-installer_0.10.0_linux_x86_64.AppImage
Graphic drivers
Usually most of this should work out of the box on NixOS.
Vulkan:
- Verification:
- If
vulkaninfo
returns information about your GPU, Vulkan is working. https://wiki.archlinux.org/title/Vulkan#Verification - If running
vkcube
(X11) orvkcube-wayland
(Wayland) views a spinning 3D cube
- If
OpenGL:
- Verification: https://wiki.archlinux.org/title/OpenGL#Verification
Video acceleration:
- VA-API
- Verifying:
vainfo
-> E.g.Driver version: Mesa Gallium driver 23.1.9 for AMD Radeon Graphics
. https://wiki.archlinux.org/title/Hardware_video_acceleration#Verifying_VA-API - Driver comparison chart. https://wiki.archlinux.org/title/Hardware_video_acceleration#VA-API_drivers
- With
libva-mesa-driver
on "Radeon RX 7900 and higher/newer" a codec for encoding AV1 8 and 10 bit is available.
- With
- Verifying:
- VDPAU
- Video Decode and Presentation API for Unix (VDPAU).
- Verifying:
vdpauinfo
. https://wiki.archlinux.org/title/Hardware_video_acceleration#Verifying_VDPAU
Verify video driver in use:
lspci -k | grep -EA3 'VGA|3D|Display'
. Example:Kernel driver in use: amdgpu
Verification in general:
- Encode a video or play a game and watch AMD GPU usage with
radeontop
.
Configuration example to disable integrated GUP: See ./hosts/yodaGaming/configuration.nix
Configuration example for an AMD GPU (https://github.com/tolgaerok/nixos-kde/blob/main/core/gpu/amd/default.nix): See ./modules/gpu-amd.nix
Additional resources
- Simple NixOS flake template for NixOS with HomeManager. https://github.com/Misterio77/nix-starter-configs#readme
- NixOS guide (development environment, gaming, etc). https://github.com/mikeroyal/NixOS-Guide#table-of-contents
- nix function cheatsheet: https://nix-cheatsheet.pixie.homes/
- Documenting the Journey of Learning and Mastering Nix. https://ianthehenry.com/posts/how-to-learn-nix/
- Nix language basics. https://nix.dev/tutorials/nix-language.html
- Nix data types. https://nixos.org/manual/nix/stable/language/values
- MkIfElse. https://discourse.nixos.org/t/mkif-vs-if-then/28521/4
- Nix language basics - a one-pager. https://github.com/tazjin/nix-1p#nix---a-one-pager
Nix Pills
It provides a tutorial introduction into the Nix package manager and Nixpkgs package collection, in the form of short chapters called 'pills'.
Papers
Papers about Nix:
- The Purely Functional Software Deployment Model (2006). http://nixos.org/~eelco/pubs/phd-thesis.pdf, https://edolstra.github.io/pubs/phd-thesis.pdf, https://github.com/edolstra/edolstra.github.io/blob/master/pubs/phd-thesis.pdf
- May 2023: Some insights from the thesis in short form. https://jonathanlorimer.dev/posts/nix-thesis.html
- NixOS: A Purely Functional Linux Distribution (2008): https://github.com/edolstra/edolstra.github.io/blob/master/pubs/nixos-icfp2008-final.pdf, https://github.com/edolstra/edolstra.github.io/blob/master/pubs/nixos-jfp-final.pdf
- Nix: A Safe and Policy-Free System for Software Deployment (2004): https://edolstra.github.io/pubs/nspfssd-lisa2004-final.pdf