BIJUTSU
λ Idempotent Dotfiles
SETTING UP NIXOS , MY WAY
NixOS with tmpfs (Sway WM)
Disclaimer: This is not a community framework or distribution. It's a private configuration and an ongoing experiment while I feel out NixOS. I make no guarantees that it will work out of the box for anyone but myself. It may also change drastically and without warning.
Shell: | Zsh + Starship |
DM: | GreetD (tuigreet) |
WM: | Sway + Waybar |
Editor: | Neovim |
Terminal: | Alacritty / Kitty / Foot |
Launcher: | Wofi |
Browser: | Firefox |
GTK Theme: | Nordic |
-
- Acquire NixOS 22.11 or newer here
- Write it to a flash drive
dd if=<ur-iso>.iso of=/dev/sdXXX bs=4k status=progress
-
- Boot into the installer.
- for legacy
# Defining a helper variable to make the following commands shorter.
DISK=/dev/disk/by-id/ata-VENDOR-ID-OF-THE-DRIVE
# Create partition table
parted $DISK -- mklabel msdos
# Create a /boot as $DISK-part1
parted $DISK -- mkpart primary ext4 1M 512M
parted $DISK -- set 1 boot on
# Create a /nix as $DISK-part2
parted $DISK -- mkpart primary ext4 512MiB 100%
- for efi
# Defining a helper variable to make the following commands shorter.
DISK=/dev/disk/by-id/ata-VENDOR-ID-OF-THE-DRIVE
# Create partition table
parted $DISK -- mklabel gpt
# Create a /boot as $DISK-part1
parted $DISK -- mkpart ESP fat32 1MiB 512MiB
parted $DISK -- set 1 boot on
# Create a /nix as $DISK-part2
parted $DISK -- mkpart Nix 512MiB 100%
# /boot partition for legacy boot
mkfs.ext4 $DISK-part1
# /boot partition for EFI
mkfs.vfat $DISK-part1
# /nix partition
mkfs.ext4 $DISK-part2
# Mount your root file system
mount -t tmpfs none /mnt
# Create directories
mkdir -p /mnt/{boot,nix,etc/nixos,var/log,etc/NetworkManager}
# Mount /boot and /nix
mount $DISK-part1 /mnt/boot
mount $DISK-part2 /mnt/nix
# Create a directory for persistent directories
mkdir -p /mnt/nix/persist/{etc/nixos,var/log,etc/NetworkManager}
# Bind mount the persistent configuration / logs
mount -o bind /mnt/nix/persist/etc/nixos /mnt/etc/nixos
mount -o bind /mnt/nix/persist/var/log /mnt/var/log
mount -o bind /mnt/nix/persist/etc/NetworkManager /mnt/etc/Networkmanager
-
Now go ahead and do a
nixos-generate-config --root /mnt
to get a basic configuration for your system. -
# git clone https://github.com/sam1431/idempotentdots /mnt/etc/nixos/repo
# mv /mnt/etc/nixos/repo/root/* /mnt/etc/nixos/
-
Cofigure your host under /mnt/etc/nixos/hosts with config you obtained from step 4 ( for a tmpfs layout check this out ). Also require the host file from config.nix
-
make flakes available to nixos -
nix-shell -p git nixFlakes ranger neovim
NOTE
- the machine won't remember your password after reboot if you use 'passwd'
- rather
users.mutableUsers = false;
# $ nix-shell --run 'mkpasswd -m SHA-512 -s' -p mkpasswd
users.users.root.initialHashedPassword = "the has you got from the above command"
also shown here
-
# nixos-install --no-root-passwd --flake /mnt/etc/nixos --impure
- Then reboot
/bin/znx
, Inspired by hlissner's /bin/hey ( but written in bash, way more messy and less functionality )
Usage: znx [flags]
# SYSTEM MANAGEMENT
rebase / switch - rebuild NixOS
upgrade - upgrade NixOS
conf-edit / conf-ed - list all System Config
# FLAKE MANAGEMENT
flake-edit / flk-ed - edit Flake config
flake-lock / flk-lc - recreate system flake lock [ not available ]
flake-update / flk-up - update root flake
# MANUAL GARBAGE COLLECTIONS
garbage-collect / gc - clean nix store home
garbage-collect -d / gcd - clean nix store root
- ~/.swayrc is the autostart script
- it is also used to set the waybar theme from here
- ~/.config/nvim , ~/.config/eww ~/.swayrc ~/any-dir-to-store-ur-files-and-wall need to persistent for config to work
- sway theme is declared at /etc/nixos/config/themes/generic.nix
- the main sway config is located at /etc/nixos/config/sway/sway.nix
PS neovim config doesn't work properly but will be fixed soon
- Why tmpfs? because I have something similar to a OCD for perfection and I want my system to be as clean as possible
I use tmpfs for /home as mentioned here by creating /home/sam under /nix/persist and giving the user read-write permission to that directory