- Nix 90%
- Shell 10%
~/.dotfiles #
This is a Nix flake for managing dotfiles and NixOS system configurations across multiple machines. It uses flake-parts with import-tree to automatically import a modular structure of shared modules and machine-specific configurations.
Overview #
This flake provides a declarative, reproducible way to manage:
- NixOS system configurations for multiple machines
- User dotfiles via hjem
- Shared modules containing reusable NixOS configuration
- Disk management with disko
- Impermanence for declarative state on a tmpfs root
- Secret storage via the oo7 secret portal on workstations
- Custom packages built and exposed by the flake itself
Supported systems: x86_64-linux, aarch64-linux.
Structure #
│
├── flake.nix # Flake definition (flake-parts + import-tree)
├── flake.lock # Locked input versions
├── modules/
│ ├── flake/ # Flake-level wiring: systems, packages, devshell, disko, hjem, checks, treefmt
│ ├── nixos/
│ │ ├── headless/ # Base NixOS module bundle (boot, nix, network, security, ssh, persist, ...)
│ │ ├── workstation/ # Desktop bundle (niri, greetd, fsel launcher, monstar terminal, vivaldi, ...)
│ │ └── xtensions/ # Optional xt-* extensions (xt-core, xt-ai, xt-dev, xt-stateless, xt-udev, ...)
├── configs/
│ ├── nixos/ # NixOS machines: amorph (iso), basalt (server), graphite (laptop)
│ └── hjem/mkersten/ # hjem-managed user dotfiles (git, niri, starship, monstar, elio, gram)
├── packages/ # Custom packages: elio, flyline, fsel, monstar
└── assets/ # Wallpapers, profile picture, install/deploy scripts
Machines #
This flake manages configurations for three hosts:
- amorph - Minimal x86_64-linux ISO for rescue or installation (also exposed as
packages.amorph) - basalt - x86_64-linux server (headless +
xt-server) - graphite - x86_64-linux laptop (workstation, stateless tmpfs root, hjem user dotfiles)
Each machine configuration composes shared modules from modules/ and overrides them in its local _config/ directory as needed.
Usage #
Entering the shell #
nix develop
The dev shell provides nh, nixd, nil, disko and these helper commands:
.iso # Build the amorph iso
.boot <machine-name> # Deploy the configuration for next boot
.switch <machine-name> # Deploy the configuration now
Checking and formatting #
nix flake check # Run checks (nil lint on all nix files, treefmt check)
nix fmt # Format the tree with treefmt (nixfmt)
Architecture #
Modular design #
The flake uses import-tree to automatically import everything from:
./modules- Shared modules./configs- Machine configurations
Modules register themselves into flake outputs, which keeps a clean separation between:
- Reusable modules (in
modules/) that define common functionality and expose themselves asflake.nixosModules.*,flake.hjemConfigurations.*andflake.diskoConfigurations.* - Machine-specific configurations (in
configs/) that compose and override modules
Features #
Disk management (disko) #
The flake includes disko for declarative disk partitioning and filesystem management.
Two layouts are defined in modules/flake/disko.nix and accessible as config.flake.diskoConfigurations.<name>:
- default - plain GPT + btrfs with
@root,@nix,@persistent,@home,@snapshotssubvolumes - stateless - LUKS-encrypted (OPAL) btrfs on top of a tmpfs root, used by the
graphitelaptop
Declarative state (impermanence) #
impermanence provides declarative state on a tmpfs root:
- Fully defined in Nix via the
dotfiles.persist.systemPaths/dotfiles.persist.userPathsoptions (declared inxt-core) - Recreated on each boot;
xt-statelesswires it together with the stateless disko layout and an initrd@homesnapshot/rollback hook
Secret storage (oo7) #
NixOS workstations use the oo7 secret portal instead of gnome-keyring, with the keyring persisted via dotfiles.persist.
User dotfiles (hjem) #
hjem manages user-level dotfiles declaratively.
User configurations live in configs/hjem/ and are exposed as config.flake.hjemConfigurations.<name> (e.g. mkersten), applied on NixOS via the xt-home module.
Custom packages #
The flake builds and exposes its own packages from packages/ via perSystem:
- amorph - the bootable ISO image of the
amorphconfiguration - monstar - terminal emulator (Zig)
- fsel - TUI app launcher / fuzzy finder (used as the workstation launcher)
- elio, flyline - shell/CLI tools
Development environment (devshell) #
The dev shell (modules/flake/devshell.nix) provides a pre-configured environment with nh, nixd, nil, disko and the .iso / .boot / .switch deploy helpers.