summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-04-24 14:57:08 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-04-24 14:57:08 +0200
commitf338ffd28de6af6b74ace1eb73c2ad9a542e6e98 (patch)
tree3a22ee3d93a64bec42e8aeb896b149dc9a9cba80
parent5069eaed874dd1b3a8f03abce8ffeba45b3d7fb5 (diff)
Expand nixos settings
-rw-r--r--data.d/etc-nixos/README.md110
-rw-r--r--data.d/etc-nixos/env/global.nix15
-rw-r--r--data.d/etc-nixos/env/workstation.nix17
3 files changed, 141 insertions, 1 deletions
diff --git a/data.d/etc-nixos/README.md b/data.d/etc-nixos/README.md
new file mode 100644
index 0000000..b88c989
--- /dev/null
+++ b/data.d/etc-nixos/README.md
@@ -0,0 +1,110 @@
+# Set variables
+
+```sh
+disk=...
+zfs_pool=...
+swap_ratio=1.5
+```
+
+# Partition disk
+
+```sh
+parted -s "$disk" mklabel gpt
+```
+
+## boot
+
+### MBR
+
+We don't do MBR anymore!
+
+### EFI
+
+```sh
+parted -a optimal "$disk" mkpart primary fat32 1MiB 1001MiB
+parted "$disk" set 1 esp on
+
+mkfs.vfat -F32 "${disk}1"
+```
+
+## swap
+
+```sh
+swap_end=$(awk '/MemTotal/ { print int($2 / 1000 * '"$swap_ratio"') + 1001 }' /proc/meminfo)
+parted -a optimal "$disk" mkpart primary linux-swap 1001MiB "$swap_end"
+
+mkswap "${disk}2"
+swapon "${disk}2"
+```
+
+## zpool
+
+```sh
+parted -a optimal "$disk" mkpart primary "$swap_end" 100%
+
+zpool create \
+ -O mountpoint=none \
+ -O encryption=on \
+ -O keyformat=passphrase \
+ -O keylocation=prompt \
+ -O acltype=posixacl \
+ -O xattr=sa \
+ -O compression=zstd \
+ -O dnodesize=auto \
+ -O normalization=formD \
+ -o ashift=12 \
+ -o autotrim=on \
+ -R /mnt \
+ "$zfs_pool" "${disk}3"
+```
+
+### zfs volumes
+
+```sh
+zfs create -o mountpoint=none "$zfs_pool/rootfs"
+zfs create -o mountpoint=legacy "$zfs_pool/rootfs/nixos"
+zfs create -o mountpoint=legacy "$zfs_pool/homefs"
+zfs create -o mountpoint=legacy "$zfs_pool/homefs/root"
+zfs create -o mountpoint=legacy "$zfs_pool/homefs/tyil"
+```
+
+# Mount partitions/volumes
+
+```sh
+mount -t zfs "$zfs_pool/rootfs/nixos" /mnt
+
+mkdir -pv -- /mnt/boot
+mount -t vfat "${disk}1" /mnt/boot
+
+mkdir -pv -- /mnt/home
+mount -t zfs "$zfs_pool/homefs" /mnt/home
+
+mkdir -pv -- /mnt/root
+mkdir -pv -- /mnt/home/tyil
+mount -t zfs "$zfs_pool/homefs/root" /mnt/root
+mount -t zfs "$zfs_pool/homefs/tyil" /mnt/home/tyil
+```
+
+# Install NixOS
+
+```sh
+nixos-generate-config --root /mnt
+```
+
+Apply configs in `/mnt/etc/nixos`
+
+```nix
+{
+ boot.supportedFilesystems = [ "zfs" ];
+ boot.zfs.forceImportRoot = false;
+ boot.zfs.devNodes = ...
+ networking.hostName = ...
+ networking.hostId = $(head -c4 /dev/urandom | od -A none -t x4)
+}
+```
+
+```sh
+cd /mnt && nixos-install
+umount -lR /mnt
+zpool export "$zfs_pool"
+```
diff --git a/data.d/etc-nixos/env/global.nix b/data.d/etc-nixos/env/global.nix
index 6ea9db4..608630d 100644
--- a/data.d/etc-nixos/env/global.nix
+++ b/data.d/etc-nixos/env/global.nix
@@ -9,6 +9,12 @@
};
environment = {
+ binsh = "${pkgs.dash}/bin/dash";
+ shells = with pkgs; [
+ bash
+ dash
+ zsh
+ ];
systemPackages = with pkgs; [
borgbackup
git
@@ -29,6 +35,12 @@
domain = "tyil.net";
};
+ programs = {
+ zsh = {
+ enable = true;
+ };
+ };
+
services = {
openssh = {
enable = true;
@@ -46,8 +58,9 @@
users = {
users = {
tyil = {
- isNormalUser = true;
extraGroups = [ "wheel" ];
+ isNormalUser = true;
+ shell = pkgs.zsh;
};
};
};
diff --git a/data.d/etc-nixos/env/workstation.nix b/data.d/etc-nixos/env/workstation.nix
index c8dcb29..f33c42f 100644
--- a/data.d/etc-nixos/env/workstation.nix
+++ b/data.d/etc-nixos/env/workstation.nix
@@ -19,6 +19,7 @@
physlock
redshift
rofi
+ sxhkd
xclip
xcompmgr
xdotool
@@ -38,6 +39,22 @@
];
};
+ services = {
+ xserver = {
+ enable = true;
+ displayManager = {
+ startx = {
+ enabled = true;
+ };
+ };
+ windowManager = {
+ awesome = {
+ enable = true;
+ };
+ };
+ };
+ };
+
users = {
users = {
tyil = {