My NixOS configuration using nix flakes.
Host | Machine | Description | Features |
---|---|---|---|
storvik-nixos-wsl | wsl | NixOS config used on Windows Subsystem for Linux | |
storvik-nixos-matebook | matebook | Config used on Huawei Matebook, my main Linux computer | hyprland emacs |
retronix | samsung-rc720 | Retro gaming computer using RetroArch | gnome retroarch |
kalinix | lenovo-e31 | Laptop set up with various forensics tooling | hyprland forensics |
storvik-nixos-nuc | intel-nuc | NUC used as home server for backup etc | |
storvik-live | live | Live USB with my config | |
PSTORVIK-MBP14 | macbook pro | Config for Macbook pro using nix-darwin | yabai skhd emacs alacritty |
│
├── flake.nix - flake
│
├── docs/ - documentation for modules
│
├── flake/ - helper stuff, mkSystem etc
│
├── hosts/ - host configurations
│ │
│ └── storvik-nixos-wsl/ - host computer
│ │
│ ├── secrets.yml - host specific secrets used by sops-nixs
│ │
│ ├── home.nix - home-manager configurations
│ │
│ └── nixos.nix - nixos configurations
│
├── modules/ - custom modules which turns on / off settings
│ │
│ ├── hm-module.nix - home-manager modules entrypoint
│ │
│ ├── module.nix - nixos modules entrypoint
│ │
│ ├── hm-module/ - home-manager modules
│ │
│ └── nixos/ - nixos modules
│
├── machines/ - hardware dependant config for different machines
│
├── overlays/ - overlays
│
└── pkgs/ - custom packages
Modules are divided into home-manager and nixos modules.
All module options can be seen in modules/hm-module/options.nix
and modules/nixos/options.nix
.
Each should contain home.nix
and / or nixos.nix
, which should define host configuration.
Non NixOS computer (home-manager)
- Install Nix on computer, nix manual
- Add nixpgks unstable channel
- Install unstable nix,
nix-env -iA nixpkgs.nixUnstable
- Add
experimental-features = nix-command flakes
to~/.config/nix/nix.conf
- Build config
nix build --impure .#storvik-ubuntu
- Backup conflicting files (
.bashrc
,.profile
) - Activate config with
./result/activate
- Install NixOS, nixos manual
- Switch to unstable channel
- Install nix-flakes by importing
./modules/nixos/nixsettings.nix
in/etc/nixos/configuration.nix
sudo nixos-rebuild switch --impure --flake .#storvik-nixos-lenovo
- Install dependencies
xcode-select --install
- Install Nix from Determinate system
- Build configuration and switch to it
nix run nix-darwin -- switch --flake .#PSTORVIK-MBP14
After initial build / switch system is rebuilt using darwin-rebuild switch --flake .
.
Apple Silicon Macs can install Rosetta in order to run Intel binaries.
Rosetta is installed by running, softwareupdate --install-rosetta --agree-to-license
.
Build ISO and copy it to USB:
nix build .#live-iso
fdisk -l # to figure out path of USB, lsblk could also be used
dd if=result/iso/nixos-*-linux.iso of=/dev/sdb status=progress
After setting up disks etc according to the NixOS manual, the system can be installed.
nixos-install --flake .#storvik-nixos-lenovo
In order to use package from pull request git revision must be found by running:
curl -sL https://github.com/NixOS/nixpkgs/pull/{number}.patch | head -n 1 | grep -o -E -e "[0-9a-f]{40}"
Then pull request has to be added as input.
pr{number}.url = "github:nixos/nixpkgs?rev={rev-from-above-command}";
And pull request pkgs must be setup.
pr{number}pkgs = import pr{number} {
inherit system;
};
After that the package that is needed can be added to packageOverrides
in nixpkgs.
This is typically done with:
pkgs = import nixpkgs {
inherit system;
config = {
packageOverrides = pkgs: {
somepackage = pr{number}pkgs.somepackage;
};
};
};
Easiest way to update docs is using:
nix build .#packages.nixos-docs && cat result > docs/options.md
nix build .#packages.hm-docs && cat result > docs/hm-options.md