Juca's NixOS & Home Manager Configurations
This repository contains a Nix Flake for configuring my computers and home environment. These are the computers this configuration currently manages:
Hostname | OEM | Model | OS | Role | Status |
---|---|---|---|---|---|
nitro |
Acer | Nitro i5-8300H | Nixos | Desktop | WIP |
pi3 |
Raspberry Pi | Raspberry Pi 3b | Dietpi | Server | tbd |
MacbookPro |
Apple | Macbook Pro 2008 | Debian | Laptop | tbd |
MacbookAir |
Apple | Macbook Air 2011 | NixOS | Laptop | tbd |
- home-manager: Home Manager configurations
- Sane defaults for shell and desktop
- nixos: NixOS configurations
- Includes discrete hardware configurations which leverage the NixOS Hardware modules via flake.nix.
- scripts: Helper scripts
- examples_helper: Scripts and docs
The nixos/_mixins and home-manager/_mixins are a collection of generic configurations that are composited based on the arguments defined in flake.nix.
- Boot off a .iso image created by this flake using
rebuild-iso
(see below). - Put the .iso image on a USB drive
- Boot the target computer from the USB drive
- Run
install-system <hostname> <username>
from a terminal. - The install script uses Disko to automatically partition and format the disks then uses my flake via
nixos-install
to complete a full system installation - This flake is automatically copied to the target user's home directory as
~/Zero/nix-config
- Make a cuppa ๐ซ
- Reboot
- Login and run
rebuild-home
(see below) from a terminal to complete the Home Manager configuration.
If the target system is booted from something other than the .iso image created by this flake, you can still install the system using the following:
curl -sL https://raw.githubusercontent.com/JucaRei/my-nixfiles/main/scripts/install.sh | bash -s <hostname> <username>
- Run the install script ๐
- The install script uses Disko to automatically partition and format the disks then uses my flake via
nixos-install
to complete a full system installation
cd nix-config
scripts/install.sh <hostname> <username>
- Make a cuppa ๐ซ
- Reboot
I clone this repo to ~/Zero/nix-config
. Home Manager and NixOS changes can be applied separately because I am planning to add support for some non-NixOS hosts.
gh repo clone JucaRei/nixos-configs ~/Zero/nix-config
A rebuild-host
alias is provided, that does the following:
sudo nixos-rebuild switch --flake $HOME/Zero/nix-config
A rebuild-home
alias is provided, that does the following:
home-manager switch -b backup --flake $HOME/Zero/nix-config
A rebuild-iso
alias is provided, that does the following:
pushd $HOME/Zero/nix-config
nix build .#nixosConfigurations.iso.config.system.build.isoImage
popd
A live image will be left in ~/$HOME/Zero/nix-config/result/iso/
Install for single user:
sh <(curl -L https://nixos.org/nix/install) --no-daemon
. ~/.nix-profile/etc/profile.d/nix.sh
echo ". $HOME/.nix-profile/etc/profile.d/nix.sh" >> ~/.profile
echo ". $HOME/.nix-profile/etc/profile.d/nix.sh" >> ~/.bashrc
echo ". $HOME/.nix-profile/etc/profile.d/nix.sh" >> ~/.zprofile
# Open tempoary shell with nix and home-manager
nix-shell
# Remove nix (this is necessary, so home-manager can install nix)
nix-env -e nix
# Exit temporary shell
exit
# Set zsh (installed by nix) as default shell
echo ~/.nix-profile/bin/zsh | sudo tee -a /etc/shells
usermod -s ~/.nix-profile/bin/zsh $USER
Install for multi user:
sh <(curl -L https://nixos.org/nix/install) --daemon
nix environment :
nix-shell (legacy)
nix develop (new)
nix develop --extra-experimental-features nix-command --extra-experimental-features flakes
# Remove nix (this is necessary, so home-manager can install nix)
nix-env -e nix
Nix file:
mkdir -pv ~/.config/nix
touch ~/.config/nix/nix.conf
echo "experimental-features = nix-command flakes repl-flake" >> ~/.config/nix/nix.conf
Technical Details
nix-shell -p nix-info --run "nix-info -m"
Create flake file
nix flake init
Check info
nix flake metadata
Update nix flake lock file
nix flake update --recreate-lock-file
nix flake lock --update-input nixpkgs
nix flake update --commit-lock-file
Nix Repair
sudo nix-store --repair --verify --check-contents
Other :
# All as root
HOST=... # set host variable to use proper configuration
nix-shell
git clone https://this.repo.url/ /etc/nixos # or $HOME/.setup
cd /etc/nixos # or cd $HOME/.setup
nixos-install -v --root /mnt --impure --flake .#$HOST
nixos-install -v --root /mnt --impure --flake .#$HOST
# Reboot
Nix is configured with flake support and the unified CLI enabled.
This is the directory structure I'm using.
.
โโโ home-manager
โ โโโ _mixins
โ โ โโโ console
โ โ โโโ desktop
โ โโโ default.nix
โโโ nixos
โ โโโ _mixins
โ โ โโโ base
โ โ โโโ boxes
โ โ โโโ desktop
โ โ โโโ services
โ โ โโโ users
โ โโโ nitro
โ โโโ raspberry
โ โโโ oldmac
โ โโโ mcbair
โ โโโ default.nix
โโโ overlays
โโโ pkgs
โโโ scripts
โโโ flake.nix
Fish shell with powerline-go and a collection of tools that deliver a somewhat "Modern Unix" experience. The base system has a firewall enabled and also includes OpenSSH, Tailscale, Podman & Distrobox and, of course, a delightfully configured nano. (Fight me! ๐ฅ)
MATE Desktop ๐ง and Pantheon ๐๏ธ are the two desktop options available. The font configuration is common with both desktops using Work Sans and Fira Code. The usual creature comforts you'd expect to find in a Linux Desktop are integrated such as Pipewire, Bluetooth, Avahi, CUPS, SANE and NetworkManager.
Desktop | System | Configuration | Theme |
---|---|---|---|
MATE | MATE Install | MATE Configuration | Yaru Magenta (Dark) |
Pantheon | Pantheon Install | Pantheon Configuration | elementary Bubble Gum (Dark) |
- Add all computers to the table
- (WIP) Implement Disko partitioning
- Chasing the ideas outlined in these blog posts:
- Setting up my new laptop: nix style
- Setting up my machines: nix style
- Integrate .iso building
- Integrate OpenRGB
- Integrate OpenRazer
- Integrate StreamDeck
- Integrate Xone
- Migrate (maybe) to ZFS
- With backups via
zrepl
- With backups via
- Fix Magewell driver: nixpkgs#221209
- Integrate an Emoji picker
- Integrate AppCenter and Flathub
- Integrate Steam
- Integrate Borg Backups using Pika or Vorta for workstations and borgmatic or Embord for servers
- Integrate cockpit
- Integrate fwupd
- Integrate Keybase
- Integrate nullmailer
- Integrate Syncthing
- Integrate sshgaurd
- Integrate dotfiles
- Integrate agenix or sops-nix
- Integrate capabilities from nix-starter-configs
- Include image assets such as wallpapers and faces
- Include Serif fonts
- Create standard directories in
/home/martin
usingsystemd.user.tmpfiles.rules
. - Create
.envrc
files in/home/martin
. - Bind Syncthing GUI to ZeroTier.
- Config Plank.
- Include fallback fonts for Work Sans, Fira Code and Joypixels
- Create common user settings and discrete user settings
- Move application defaults out of the desktop defaults
- Fix Unfree in Home Manager
- Defold
- fzf
- tmate or tmux
- (WIP) micro
- nnn or broot or felix or ranger
Before preparing my NixOS and Home Manager configurations I took a look at what other Nix users are doing. My colleagues shared their configs and tips which included nome from Luc Perkins, nixos-config from Cole Helbling, flake from Ana Hoverbear and her Declarative GNOME configuration with NixOS blog post. A couple of friends also shared their configurations and here's Jon Seager's nixos-config and Aaron Honeycutt's nix-configs.
While learning Nix I watched some talks/interviews with Matthew Croughan and Will Taylor's Nix tutorials on Youtube. Will Taylor's dotfiles are worth a look, as are his videos, and Matthew Croughan's nixcfg is also a useful reference. After I created my initial flake I found nix-starter-configs by Gabriel Fontes which is an excellent starting point. I'll be incorporating many of the techniques it demonstrates in my nix-config.
I like the directory hierarchy in Jon Seager's nixos-config and the mixin pattern used in Matthew Croughan's nixcfg, so my initial Nix configuration is heavily influenced by both of those. Ana's excellent Declarative GNOME configuration with NixOS blog post was essential to get a personalised desktop. That said, there's plenty to learn from browsing other people's Nix configurations, not least for discovering cool software. I recommend a search of GitHub nixos configuration from time to time to see what interesting techniques you pick up and new tools you might discover. The disko implementation and automated installation is chasing the ideas outlined in these blog posts: