Skip to content

samthepacman/IdempotentDots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.



System Default Apps

Shell: Zsh + Starship
DM: GreetD (tuigreet)
WM: Sway + Waybar
Editor: Neovim
Terminal: Alacritty / Kitty / Foot
Launcher: Wofi
Browser: Firefox
GTK Theme: Nordic

NVIM CONFIG


Lets Begin

Flashing the Iso

    • 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.
    • Setting up tmpfs

  • 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%

Step 2 - Creating the file systems

# /boot partition for legacy boot
mkfs.ext4 $DISK-part1

# /boot partition for EFI
mkfs.vfat $DISK-part1

# /nix partition
mkfs.ext4 $DISK-part2

Step 3 - Mounting the file systems

# 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


  1. 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/
  2. 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

  3. 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

  1. Install nixOS

    # nixos-install --no-root-passwd --flake /mnt/etc/nixos --impure
  • Then reboot

Management

/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
   

NOW TO THE DESKTOP PART

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

Some Helpful links