- NixOS custom ISO for install per - https://bmcgee.ie/posts/2022/12/setting-up-my-new-laptop-nix-style/
- Linting/etc - https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#available-sources
git clone git@github.com:karlskewes/nixos.git
# update packages from nix and then system & home-manager
./run.sh update
Follow instructions at https://github.com/tpwrules/nixos-apple-silicon with the following variations.
Setup partitions with ext4 because zfs support on new kernels is spotty:
lsblk
fdisk /dev/nvme0n1
# confirm partition numbers before setting partition type
- `n`, enter, `+8G` -> `t`, `6`, `swap`
- `n`, enter, `+100G` -> `t`, `7`, `linux` - `/` root, nix store
- `n`, enter, enter -> `t`, `8`, `linux` - `/home`
- `p`
- `w`
Mount partitions:
# print partiion info
lsblk -o name,mountpoint,label,size,uuid
NAME MOUNTP LABEL SIZE UUID
nvme0n1 931.5G
├─nvme0n1p1 /boot 512M C0B8-20DA
├─nvme0n1p2 [SWAP] swap 7.5G b85bdf70-c212-4641-a96b-e2d0b9ad9f16
├─nvme0n1p3 rpool-desktop 492.7G 14791146668368940249
└─nvme0n1p7 data 329.4G 28385FE6385FB194
mount /dev/disk/by-id/.... /mnt/
mkdir -p /mnt/home mount /dev/disk/by-id/.... /mnt/home
mkswap -L swap /dev/disk/by-id/.... swapon -av
Generate config:
nixos-generate-config --root /mnt/
Add to `/etc/nixos/configuration.nix`:
nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = with pkgs; [ vim # edit files git # git clone this repo ];
Install:
nixos-install --root /mnt/
#### Flake installation
- scp or git clone this repo
- set nix-extra username to root, or mkdir /home/nixos
- increase tmpfs storage for /run/user/0 to 10G (less ok?)
### x86/arm64
#### Prepare USB stick
- [x86](https://nixos.org/download.html)
nix-shell -p zstd --run "unzstd .img.zst"
Burn to USB
lsblk
Boot machine with nixos minimal image.
Create a password so we can SCP and SSH:
passwd
### Create Disko declarative partition file
Upstream: https://github.com/nix-community/disko
** CAUTION: This wipes away existing partitions **
machine=new_machine cp ./hardware/tl-disko.nix ./hardware/"${machine}"-disko.nix
vim ./hardware/"${machine}"-disko.nix
Copy `disko` file to new machine:
host= scp ./hardware/"${machine}"-disko.nix "${host}":.
ssh to host and configure partitions:
ssh nixos@"${host}"
machine=
nix
--extra-experimental-features nix-command
--extra-experimental-features flakes
run github:nix-community/disko --no-write-lock-file --
--dry-run
--mode disko
./"${machine}-disko.nix"
Then if ready do a run for real:
#### Add machine to repository
Generate hardware:
nixos-generate-config --show-hardware-config
Copy into git repository:
vim ./hardware/${machine}.nix
Add machine to this repository:
scp nixos@<new_machine>:/mnt/etc/nixos/hardware-configuration.nix machines/.nix vim flake.nix git add . ...
Login and clone this repository on new machine:
nix-shell -p git
git clone https://github.com/karlskewes/nixos.git cd nixos
sudo mount -o remount,size=10G /nix/.rw-store
sudo swapon /dev/disk/by-id/-part2
vim flake.nix
./run.sh install
reboot
Login and install `home-manager`:
mkdir -p ~/src/github.com/karlskewes cd ~/src/github.com/karlskewes
git clone https://github.com/karlskewes/nixos.git
./run.sh nix-extra
./run.sh build
./run.sh switch
## Recovery
zpool import
zfs load-key -r rpool
mkdir -p /mnt/root mount -t zfs rpool/root /mnt/root