- Powered by NixOS and four partitions:
/
, ephemeral, deleted at EVERY boot/boot
/home
, persistent, where my important home lives in/nix
, persistent, but mounted as read-only
-
(Optional) if you want to dual-boot with Windows, install Windows first and then continue this tutorial.
-
Download
NixOS minimal ISO image
from the NixOS's download page. -
Burn it into a USB stick.
lsblk umount "${partition}" parted "${device}" -- mktable msdos dd bs=1MiB if="${iso}" of="${device}" oflag=direct status=progress
-
Boot from the USB stick, start the installation and then
sudo su
. -
Allocate some empty disk space for NixOS to live in.
Use the following commands as needed, replace "${device}" by the address of the main disk:- List block devices:
lsblk -f
- Managing partitions:
parted "${device}"
- Create a partition table:
(parted) mktable gpt
- Remove a partition:
(parted) rm "${number}"
- Create a partition table:
- List block devices:
-
Setup the NixOS file system in the free space allocated in the previous step.
parted "${device}" # Generic setup (parted) unit GiB (parted) print # Setup boot partition (parted) rm "${number}" # Remove existing boot partitions (parted) mkpart ESP fat32 1MiB 0.5 (parted) set "${number}" esp on # Setup other partitions (parted) mkpart home "${start}" "${end}" # 50 GiB (parted) mkpart nix "${start}" "${end}" # 100 GiB (parted) mkpart root "${start}" "${end}" # 50 GiB
-
Finish NixOS installation.
cryptsetup luksFormat /dev/disk/by-partlabel/home cryptsetup luksFormat /dev/disk/by-partlabel/nix cryptsetup luksFormat /dev/disk/by-partlabel/root cryptsetup luksOpen /dev/disk/by-partlabel/home crypthome cryptsetup luksOpen /dev/disk/by-partlabel/nix cryptnix cryptsetup luksOpen /dev/disk/by-partlabel/root cryptroot mkfs.fat -F 32 -n boot /dev/disk/by-partlabel/ESP mkfs.ext4 -L home /dev/mapper/crypthome mkfs.ext4 -L nix /dev/mapper/cryptnix mkfs.ext4 -L root /dev/mapper/cryptroot mount /dev/disk/by-label/root /mnt mkdir /mnt/boot mkdir /mnt/home mkdir /mnt/nix mount /dev/disk/by-partlabel/ESP /mnt/boot mount /dev/disk/by-label/home /mnt/home mount /dev/disk/by-label/nix /mnt/nix nixos-generate-config --root /mnt cat << EOF >> /mnt/etc/nixos/configuration.nix // { boot.loader.efi.canTouchEfiVariables = true; boot.loader.systemd-boot.enable = true; environment.systemPackages = [ pkgs.wpa_supplicant ]; services.nscd.enable = true; } EOF if not_connected_to_the_internet; then ip a wpa_supplicant -B -i "${interface}" -c <(wpa_passphrase "${ssid}" "{psk}") fi nixos-install reboot
-
Clone this repository and rebuild.
if not_connected_to_the_internet; then ip a wpa_supplicant -B -i "${interface}" -c <(wpa_passphrase "${ssid}" "{psk}") fi cd "$(mktemp -d)" nix-shell -p git just git clone https://github.com/drestrepom/machine cd machine just rebuild switch reboot
-
Get your GitHub API token from the secrets file and export it into the terminal.
-
Setup the state.
-
github/drestrepom/machine
mkdir -p /home/github/drestrepom \ && pushd /home/github/drestrepom \ && git clone "https://drestrepom:${GITHUB_API_TOKEN}@github.com/drestrepom/machine" \ && popd
-
github/drestrepom/secrets
mkdir -p /home/github/drestrepom \ && pushd /home/github/drestrepom \ && git clone --depth 1 "https://drestrepom:${GITHUB_API_TOKEN}@github.com/drestrepom/secrets" \ && cd secrets/machine \ && ./install.sh \ && popd
-
github/fluidattacks
mkdir -p /home/github/drestrepom \ && pushd /home/github/drestrepom \ && git clone [email protected]:drestrepom/makes \ && git -C makes remote add upstream [email protected]:fluidattacks/makes \ && popd
-
github/nixos
mkdir -p /home/github/nixos \ && pushd /home/github/nixos \ && git clone [email protected]:drestrepom/nixpkgs \ && git -C nixpkgs remote add upstream [email protected]:nixos/nixpkgs \ && popd
-
gitlab/fluidattacks
mkdir -p /home/gitlab/fluidattacks \ && pushd /home/gitlab/fluidattacks \ && git clone [email protected]:fluidattacks/product \ && git -C product config user.email [email protected] \ && git clone [email protected]:fluidattacks/services \ && git -C services config user.email [email protected] \ && popd
-
-
Enjoy!
You may find useful to install Timedoctor via Nix.
-
$ NIXPKGS_ALLOW_UNFREE=1 nix-build -A timedoctor https://github.com/nixos/nixpkgs/archive/7310407d493ee1c7caf38f8181507d7ac9c90eb8.tar.gz
-
$ ./result/bin/timedoctor*
Source: Pull 127590
Caveats:
- It does not work with Gnome Display Manager (gdm), use LightDM (lightdm)
- It only works with X.org server, not Wayland, etc.