Nix Flake which contains configs for most of my more recent systems. Uses modules for high configurability between systems, organization, and encapsulation of configs for a specific program. Optimized so that adding hosts and programs is easy, and it should be enough to add a new file, then rebuild and everything will work. No need to specify any extra imports.
// ## Hosts
- clone dots
git clone https://github.com/sylk0s/dotfiles
- format with disko
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko hosts/<host-name>/disko.nix
- verify
lsblk
- Generate the hardware config file
sudo nixos-generate-config --no-filesystem --root /mnt
- Copy hardware config
sudo cp /mnt/etc/nixos/hardware-config.nix dotfiles/hosts/<host-name>
- Copy all dotfiles over to the root fs. I do this so I have it after reboot.
sudo cp -r dotfiles /mnt/etc/nixos/
- Change to the new dotfiles
cd /mnt/etc/nixos/dotfiles
- Install with the flake
sudo nixos-install --flake .#<host-name> --root /mnt
Notes:
- will need to create
/persist/home/<user>
and chmod for each
/* OLD THINGS
- copy and setup dots. will be easier now with some creature comforts
- copy uuids, copy hardware-config, write host file
- disable sops and sops-password #TODO auto
- reboot into new system
- impermanence
- create /persist/home/sylkos (and other users ofc)
- move in dots
- rebuild and reboot, ensure everything is where we expect and persists
- copy gpg key onto system and into gnupg
gpg --import public.key
gpg --import private.key
gpg --edit-key {KEY} trust quit
(this is to modify the permission level of the key)gpg --list-keys
- update sops with passwd
- get the ssh fingerprint using
nix-shell -p ssh-to-age --run "cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age"
- add to
.sops.yaml
- run
nix-shell -p sops --run "sops updatekeys secrets.yaml"
- re-enable sops
- get the ssh fingerprint using
- rebuild into final system :3
*/
I typically use the gnome install enviornment, since it's just a bit easier to use than minimal, but either are fine. With the gnome install, I install the minimal environment & partiton accordingly and then clone this repo and run the following command.
# nixos-rebuild switch --install-bootloader --flake .#host-name
Note: the --install-bootloader
arg may be omitted in certain cases depending on how you want the system to be setup.
- regenerate SSH keys
- setup folder structure (projects, tools)
This repo is designed to make it super easy to add a host!
- create a new folder under
hosts/
- copy the hardware config from
/etc/nixos/hardware-config.nix
- make any edits needed
- Drawing inspiration from
hosts/pc/default.nix
orhosts/laptop/default.nix
create a host config file- Typically, I like a space in the hosts file to quickly add programs to a host without the need to create a module
- This file is where you setup the modules and make any additional configs you want
- Rebuild into the new host using
nixos-rebuild switch --flake .#host-name
This repo is also designed to make it easy to add a program as a module!
- See table below for where to add programs
- If it's not a module, just add the program to a list
- Otherwise, at the appropriate place under
modules/
add a new file namedmodule-name.nix
and create a module (look to other modules similar for inspiration)
// Places programs are specified
- Hlissner's dotfiles
- Auyler's dotifles
- TODO more