Skip to content

nikolarobottesla/infra-nix-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

infra-nix-config

my nixos configurations, setup to use flakes

hosts

  • desktops: 15TH-TURTLE, dark-desk, shialt
  • darwin: mcfruit1, cinnamon-ice
  • servers: coconut, oak*
  • WSL: nixos

usage

# navigate to this folder, then (assumes host name matches flake)
# if remote TMUX first!!!
sudo nixos-rebuild switch --flake '.#'

# update the flake.lock
nix flake update

# edit secrets example
sops hosts/coconut-2/secrets.yaml 

# untested
# To switch a remote configuration, use:
NIX_SSHOPTS="-o RequestTTY=force" \
nixos-rebuild --flake .#oak-1 \
  --target-host deer@oak-1 --fast --use-remote-sudo \
  switch

# remote build and target, getting broken pipe error
NIX_SSHOPTS="-o RequestTTY=force" \
nixos-rebuild --flake .#coconut-2 \
  --build-host nixos@coconut-2 \
  --target-host nixos@coconut-2 --fast --use-remote-sudo \
  switch

setup local

  1. boot nixos
  2. setup disk using disko (setup remote step 3)
  3. install nixos, skip setting a root password
sudo nixos-install --flake --no-root-passwd .#dark-desk
  1. enter-nixos and set user password
  2. make sure any repo changes persist
  3. reboot

setup remote

  1. build iso image with root ssh access
nix build .#image.oak
  1. boot image, connect ethernet and ssh in
  2. use disko to format and mount
# https://github.com/nix-community/disko/blob/master/docs/quickstart.md
# fresh install (disks overwrite)
nano /tmp/disko-config.nix  # paste config
nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode destroy,format,mount /tmp/disko-config.nix
  1. comment in/modify disko-config as necessary e.g. USB disk location and keyFile usage
  2. run nix config, check hardware-configuration.nix and update your build config if necessary
nixos-generate-config --no-filesystems --root /mnt
cat /mnt/etc/nixos/hardware-configuration.nix
  1. build config for remote, copy it over and install
# To install a remote configuration, use: 
# https://github.com/NixOS/nixpkgs/issues/217891
# https://codeberg.org/kotatsuyaki/rpi4-usb-uefi-nixos-config
nixos-rebuild build --flake .#oak-1
nix-copy-closure --to root@oak result
readlink -f ./result
# returns <nix store path>
# (on remote, as root) nixos-install --system <nix store path> --root /mnt
nixos-install --system /nix/store/ndcw24fkf9m6hipqwq6x1xj9g8bmp0my-nixos-system-oak-1-23.11.20240120.1b64fc1 --root /mnt
# change root and set user password
nixos-enter  # assumes the /mnt contains the new root
passwd <user name>
  1. generate and add any luks keys

setup pi

# build SDimage on a x86 box
nix build .#image.rpi4

# 1st time setup
ssh root@device
passwd nixos
su nixos
cd ~
git clone https://github.com/nikolarobottesla/infra-nix-config.git
cd infra-nix-config/
nix build .#

# on pi, build
nix build .#build.rpi4
# on pi, build and switch
sudo nixos-rebuild switch --flake '.#rpi4'

About

my nixos configurations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages