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 {
modules = [
./hosts/${hostname}/hardware-configuration.nix
./hosts/${hostname}/disko.nix
./hardware
./system
home-manager.nixosModules.home-manager
{

View File

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

View File

@@ -1,56 +1,61 @@
{ 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
{
imports = [ disko.nixosModules.disko ];
disko.devices = {
disk = {
stationette = {
type = "disk";
# Check this with lsblk
device = "/dev/sda";
let
mkDisk = { hostname, drive }: {
type = "disk";
# Check this with lsblk
device = drive;
content = {
type = "gpt";
partitions = {
ESP = {
size = "512M";
type = "EF00";
content = {
type = "gpt";
partitions = {
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "fmask=0022" "dmask=0022" "umask=0077" ];
};
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "fmask=0022" "dmask=0022" "umask=0077" ];
};
};
root = {
size = "100%";
content = {
type = "btrfs";
# Force overwrite
extraArgs = [ "-f" ];
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" ];
};
root = {
size = "100%";
content = {
type = "btrfs";
# Force overwrite
extraArgs = [ "-f" ];
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/persist" = {
mountpoint = "/persist";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/swap" = {
mountpoint = "/.swapvol";
swap.swapfile.size = "8G";
};
};
};
"/nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/persist" = {
mountpoint = "/persist";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/swap" = {
mountpoint = "/.swapvol";
swap.swapfile.size = "8G";
};
};
};
};
};
};
};
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
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ config, lib, pkgs, modulesPath, hostname, ... }:
let
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 ''
mkdir /btrfs_tmp
mount /dev/disk/by-partlabel/disk-stationette-root /btrfs_tmp
mount ${rootDisk} /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date +%Y-%m-%d_%H-%M-%S)
@@ -42,22 +31,28 @@
umount /btrfs_tmp
'';
fileSystems."/" = {
device = rootDisk;
fsType = "btrfs";
options = [ "subvol=root" ];
};
fileSystems."/persist" = {
device = "/dev/disk/by-partlabel/disk-stationette-root";
device = rootDisk;
neededForBoot = true;
fsType = "btrfs";
options = [ "subvol=persist" ];
};
fileSystems."/nix" = {
device = "/dev/disk/by-partlabel/disk-stationette-root";
device = rootDisk;
neededForBoot = true;
fsType = "btrfs";
options = [ "subvol=nix" ];
};
fileSystems."/boot" = {
device = "/dev/disk/by-partlabel/disk-stationette-ESP";
device = bootDisk;
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" "umask=0077" ];
};
@@ -65,7 +60,4 @@
swapDevices = [ {
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/sinew.in"
".config/chromium"
".config/superProductivity"
".local/share/direnv"
".local/share/nvim"
".local/share/voxtype"

View File

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

View File

@@ -32,8 +32,8 @@
chromium = {
enable = true;
extensions = [
"cjpalhdlnbpafiamejdnhcphjbkeiagm"
"kmcfomidfpdkfieipokbalgegidffkal"
"cjpalhdlnbpafiamejdnhcphjbkeiagm" # uBlock Origin
"kmcfomidfpdkfieipokbalgegidffkal" # Enpass
];
};
firefox = {
@@ -62,7 +62,7 @@
/* ---- EXTENSIONS ---- */
ExtensionSettings = {
"*".installation_mode = "allowed"; # blocks all addons except the ones specified below
# Enpass
# Enpass
"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";
installation_mode = "force_installed";
@@ -70,7 +70,6 @@
};
/* ---- PREFERENCES ---- */
# Set preferences shared by all profiles.
Preferences = {
"browser.contentblocking.category" = { Value = "strict"; Status = "locked"; };
"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, ... }:
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 = {
loader = {
@@ -26,22 +35,22 @@
'';
};
efi.canTouchEfiVariables = true;
# timeout = 0;
# timeout = 0; # Skips the menu and uses default entry
};
# Creates a cool animation for booting
plymouth = {
enable = true;
theme = "black_hud";
themePackages = with pkgs; [
(adi1090x-plymouth-themes.override {
selected_themes = [ "black_hud" ];
})
selected_themes = [ "black_hud" ];
})
];
};
initrd.verbose = false;
# Found by running sudo btrfs inspect-internal map-swapfile -r /.swapvol/swapfile
kernelParams = [
"resume_offset=533760"
"resume_offset=${hibernateBootOffset}"
"quiet"
"udev.log_level=3"
"systemd.show_status=auto"

View File

@@ -4,7 +4,7 @@
fonts = {
packages = with pkgs; [
nerd-fonts.jetbrains-mono
nerd-fonts.fira-code
nerd-fonts.fira-code
];
};
}

View File

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

View File

@@ -8,8 +8,8 @@
shell = pkgs.zsh;
extraGroups = [
"chris"
"wheel"
"networkmanager"
"wheel"
"networkmanager"
];
};
}