Refactoring

This commit is contained in:
2026-03-12 23:38:13 +00:00
parent 95740b26bf
commit 69232abb6c
13 changed files with 117 additions and 106 deletions

View File

@@ -57,8 +57,7 @@
mkHost = hostname: nixpkgs.lib.nixosSystem { mkHost = hostname: nixpkgs.lib.nixosSystem {
modules = [ modules = [
./hosts/${hostname}/hardware-configuration.nix ./hardware
./hosts/${hostname}/disko.nix
./system ./system
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {

View File

@@ -1,7 +1,9 @@
{ ... }: { hostname, ... }:
{ {
imports = [ imports = [
./disko.nix ./disko.nix
./filesystem.nix
./${hostname}-hardware-configuration.nix
]; ];
} }

View File

@@ -1,14 +1,10 @@
{ disko, ... }: { disko, ... }:
# nix --extra-experimental-features "nix-command flakes" run github:nix-community/disko/latest#disko-install -- --flake ./#stationette --disk stationette --write-efi-boot-entries /dev/sda let
{ mkDisk = { hostname, drive }: {
imports = [ disko.nixosModules.disko ];
disko.devices = {
disk = {
stationette = {
type = "disk"; type = "disk";
# Check this with lsblk # Check this with lsblk
device = "/dev/sda"; device = drive;
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@@ -26,7 +22,7 @@
size = "100%"; size = "100%";
content = { content = {
type = "btrfs"; type = "btrfs";
# Force overwrite # Force overwrite
extraArgs = [ "-f" ]; extraArgs = [ "-f" ];
subvolumes = { subvolumes = {
"/root" = { "/root" = {
@@ -50,7 +46,16 @@
}; };
}; };
}; };
}; };
in
# nix --extra-experimental-features "nix-command flakes" run github:nix-community/disko/latest#disko-install -- --flake ./#${hostname} --disk stationette --write-efi-boot-entries ${drive}
{
imports = [ disko.nixosModules.disko ];
disko.devices = {
disk = {
station = mkDisk { hostname = "station"; drive = "/dev/nvme0n1"; };
stationette= mkDisk { hostname = "stationette"; drive = "/dev/sda"; };
}; };
}; };
} }

View File

@@ -1,25 +1,14 @@
# Do not modify this file! It was generated by nixos-generate-config { config, lib, pkgs, modulesPath, hostname, ... }:
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. let
{ config, lib, pkgs, modulesPath, ... }: rootDisk = "/dev/disk/by-partlabel/disk-${hostname}-root";
bootDisk = "/dev/disk/by-partlabel/disk-${hostname}-ESP";
in
{ {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-partlabel/disk-stationette-root";
fsType = "btrfs";
options = [ "subvol=root" ];
};
boot.initrd.postDeviceCommands = lib.mkAfter '' boot.initrd.postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp mkdir /btrfs_tmp
mount /dev/disk/by-partlabel/disk-stationette-root /btrfs_tmp mount ${rootDisk} /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then if [[ -e /btrfs_tmp/root ]]; then
mkdir -p /btrfs_tmp/old_roots mkdir -p /btrfs_tmp/old_roots
timestamp=$(date +%Y-%m-%d_%H-%M-%S) timestamp=$(date +%Y-%m-%d_%H-%M-%S)
@@ -42,22 +31,28 @@
umount /btrfs_tmp umount /btrfs_tmp
''; '';
fileSystems."/" = {
device = rootDisk;
fsType = "btrfs";
options = [ "subvol=root" ];
};
fileSystems."/persist" = { fileSystems."/persist" = {
device = "/dev/disk/by-partlabel/disk-stationette-root"; device = rootDisk;
neededForBoot = true; neededForBoot = true;
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=persist" ]; options = [ "subvol=persist" ];
}; };
fileSystems."/nix" = { fileSystems."/nix" = {
device = "/dev/disk/by-partlabel/disk-stationette-root"; device = rootDisk;
neededForBoot = true; neededForBoot = true;
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=nix" ]; options = [ "subvol=nix" ];
}; };
fileSystems."/boot" = { fileSystems."/boot" = {
device = "/dev/disk/by-partlabel/disk-stationette-ESP"; device = bootDisk;
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" "umask=0077" ]; options = [ "fmask=0022" "dmask=0022" "umask=0077" ];
}; };
@@ -65,7 +60,4 @@
swapDevices = [ { swapDevices = [ {
device = "/.swapvol/swapfile"; device = "/.swapvol/swapfile";
} ]; } ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View File

@@ -0,0 +1,16 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@@ -16,6 +16,7 @@
".config/nixos" ".config/nixos"
".config/sinew.in" ".config/sinew.in"
".config/chromium" ".config/chromium"
".config/superProductivity"
".local/share/direnv" ".local/share/direnv"
".local/share/nvim" ".local/share/nvim"
".local/share/voxtype" ".local/share/voxtype"

View File

@@ -37,12 +37,14 @@
obsidian # Notes software obsidian # Notes software
signal-desktop # Messaging signal-desktop # Messaging
spotify # Music spotify # Music
super-productivity # Task app
sxiv # Minimal image viewer sxiv # Minimal image viewer
tenacity # Audio software tenacity # Audio software
try-cli.packages.${pkgs.system}.default # Try CLI tool try-cli.packages.${pkgs.system}.default # Try CLI tool
wally-cli # Keyboard flasher wally-cli # Keyboard flasher
wiremix # Audio mixer TUI wiremix # Audio mixer TUI
xournalpp # Handwriting note-taking software xournalpp # Handwriting note-taking software
zenity # For creating dialogs during install script
zathura # Minimal PDF viewer zathura # Minimal PDF viewer
]; ];
} }

View File

@@ -32,8 +32,8 @@
chromium = { chromium = {
enable = true; enable = true;
extensions = [ extensions = [
"cjpalhdlnbpafiamejdnhcphjbkeiagm" "cjpalhdlnbpafiamejdnhcphjbkeiagm" # uBlock Origin
"kmcfomidfpdkfieipokbalgegidffkal" "kmcfomidfpdkfieipokbalgegidffkal" # Enpass
]; ];
}; };
firefox = { firefox = {
@@ -62,7 +62,7 @@
/* ---- EXTENSIONS ---- */ /* ---- EXTENSIONS ---- */
ExtensionSettings = { ExtensionSettings = {
"*".installation_mode = "allowed"; # blocks all addons except the ones specified below "*".installation_mode = "allowed"; # blocks all addons except the ones specified below
# Enpass # Enpass
"firefox-enpass@enpass.io" = { "firefox-enpass@enpass.io" = {
install_url = "https://dl.enpass.io/stable/extensions/firefox/versions/v6.11.10.2/enpass_password_manager-6.11.10.2.xpi"; install_url = "https://dl.enpass.io/stable/extensions/firefox/versions/v6.11.10.2/enpass_password_manager-6.11.10.2.xpi";
installation_mode = "force_installed"; installation_mode = "force_installed";
@@ -70,7 +70,6 @@
}; };
/* ---- PREFERENCES ---- */ /* ---- PREFERENCES ---- */
# Set preferences shared by all profiles.
Preferences = { Preferences = {
"browser.contentblocking.category" = { Value = "strict"; Status = "locked"; }; "browser.contentblocking.category" = { Value = "strict"; Status = "locked"; };
"extensions.pocket.enabled" = lock-false; "extensions.pocket.enabled" = lock-false;

View File

@@ -1,15 +0,0 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
fileSystems."/persist" = {
device = "/dev/disk/by-partlabel/disk-station-root";
neededForBoot = true;
fsType = "btrfs";
options = [ "subvol=persist" ];
};
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@@ -1,5 +1,14 @@
{ pkgs, hostname, ... }: { pkgs, hostname, ... }:
let
# Found by running sudo btrfs inspect-internal map-swapfile -r /.swapvol/swapfile
hibernateBootOffsets = {
stationette = "533760";
station = "533760";
};
resumeOffset = hibernateBootOffsets."${hostname}" or "0";
in
{ {
boot = { boot = {
loader = { loader = {
@@ -26,8 +35,9 @@
''; '';
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
# timeout = 0; # timeout = 0; # Skips the menu and uses default entry
}; };
# Creates a cool animation for booting
plymouth = { plymouth = {
enable = true; enable = true;
theme = "black_hud"; theme = "black_hud";
@@ -39,9 +49,8 @@
}; };
initrd.verbose = false; initrd.verbose = false;
# Found by running sudo btrfs inspect-internal map-swapfile -r /.swapvol/swapfile
kernelParams = [ kernelParams = [
"resume_offset=533760" "resume_offset=${hibernateBootOffset}"
"quiet" "quiet"
"udev.log_level=3" "udev.log_level=3"
"systemd.show_status=auto" "systemd.show_status=auto"

View File

@@ -1,5 +1,6 @@
{ impermanence, ... }: { impermanence, ... }:
# Define which files and directories should persist between boots
{ {
imports = [ impermanence.nixosModules.impermanence ]; imports = [ impermanence.nixosModules.impermanence ];
@@ -10,9 +11,9 @@
"/var/lib/bluetooth" "/var/lib/bluetooth"
"/var/lib/networkmanager" "/var/lib/networkmanager"
"/var/lib/nixos" "/var/lib/nixos"
"/etc/ssh"
"/var/lib/systemd/coredump" "/var/lib/systemd/coredump"
"/etc/NetworkManager/system-connections" "/etc/NetworkManager/system-connections"
"/etc/ssh"
]; ];
files = [ files = [
"/etc/machine-id" "/etc/machine-id"