Fix everything.

This commit is contained in:
Jimbo 2025-02-28 13:32:11 -05:00
parent 11075719cb
commit 3d25d316fe
118 changed files with 180 additions and 244 deletions

View file

@ -0,0 +1,10 @@
{ ... }:
{
imports = [
./disko
./filesystems
./immutable
./impermanence
./snapper
];
}

View file

@ -0,0 +1,94 @@
{ config, disko, ... }:
{
imports = [ disko.nixosModules.disko ];
disko.devices = {
disk = {
"${config.networking.hostName}" = {
type = "disk";
device = "/dev/mmcblk1";
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
size = "2G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "${config.networking.hostName}-disk";
settings.allowDiscards = true;
passwordFile = "/tmp/secret.key";
content = {
type = "lvm_pv";
vg = "${config.networking.hostName}";
};
};
};
};
};
};
};
lvm_vg = {
"${config.networking.hostName}" = {
type = "lvm_vg";
lvs = {
root = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ];
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" "ssd" ];
};
"/prev" = {
mountpoint = "/prev";
mountOptions = [ "compress=zstd" "noatime" "ssd" "noexec" ];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" "ssd" ];
};
# Impermanence
"/persist" = {
mountpoint = "/persist";
mountOptions = [ "compress=zstd" "noatime" "ssd" ];
};
"/persist/.snapshots" = { };
"/persist/home/jules" = { };
"/persist/home/jules/.snapshots" = { };
"/persist/home/jimbo" = { };
"/persist/home/jimbo/.snapshots" = { };
};
};
};
swap = {
size = "4G";
content = {
type = "swap";
discardPolicy = "both";
};
};
};
};
};
};
# Needed for impermanence
fileSystems."/persist".neededForBoot = true;
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
{
boot.supportedFilesystems = {
btrfs = true;
ntfs = true;
zfs = true;
};
services = {
btrfs.autoScrub.enable = true;
fstrim.enable = true;
};
}

View file

@ -0,0 +1,5 @@
{ ... }:
{
system.etc.overlay.mutable = false;
boot.tmp.cleanOnBoot = true;
}

View file

@ -0,0 +1,10 @@
{ impermanence, ... }:
{
imports = [
./jules
./jimbo
./root
impermanence.nixosModules.impermanence
];
}

View file

@ -0,0 +1,26 @@
{ config, ... }:
{
environment.persistence."/persist" = {
hideMounts = true;
users.jimbo = {
directories = [
"Keepers"
"Documents"
"Pictures"
"Videos"
"Games"
"VMs"
".snapshots"
".cache/nix-index"
{ directory = ".ssh"; mode = "0700"; }
{ directory = ".gnupg"; mode = "0700"; }
];
files = [
".zsh_history"
".local/state/lazygit/state.yml"
];
};
};
}

View file

@ -0,0 +1,26 @@
{ config, ... }:
{
environment.persistence."/persist" = {
hideMounts = true;
users.jules = {
directories = [
"Keepers"
"Documents"
"Pictures"
"Videos"
"Games"
"VMs"
".snapshots"
".cache/nix-index"
{ directory = ".ssh"; mode = "0700"; }
{ directory = ".gnupg"; mode = "0700"; }
];
files = [
".zsh_history"
".local/state/lazygit/state.yml"
];
};
};
}

View file

@ -0,0 +1,15 @@
{ ... }:
{
environment.persistence."/persist" = {
hideMounts = true;
directories = [
"/etc/nixos"
"/etc/secureboot"
"/var/lib/nixos"
];
files = [
"/etc/machine-id"
"/root/.gitconfig"
];
};
}

View file

@ -0,0 +1,13 @@
{ ... }:
{
imports = [
./jules
./jimbo
./root
];
services.snapper = {
snapshotInterval = "0/6:00:00";
persistentTimer = true;
};
}

View file

@ -0,0 +1,12 @@
{ config, lib, ... }:
{
services.snapper.configs.jimbo = lib.mkIf config.environment.persistence."/persist".enable {
SUBVOLUME = "/persist/home/jimbo";
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
TIMELINE_LIMIT_DAILY = 1;
TIMELINE_LIMIT_WEEKLY = 1;
TIMELINE_LIMIT_MONTHLY = 0;
TIMELINE_LIMIT_YEARLY = 0;
};
}

View file

@ -0,0 +1,12 @@
{ config, lib, ... }:
{
services.snapper.configs.jules = lib.mkIf config.environment.persistence."/persist".enable {
SUBVOLUME = "/persist/home/jules";
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
TIMELINE_LIMIT_DAILY = 1;
TIMELINE_LIMIT_WEEKLY = 1;
TIMELINE_LIMIT_MONTHLY = 0;
TIMELINE_LIMIT_YEARLY = 0;
};
}

View file

@ -0,0 +1,12 @@
{ config, lib, ... }:
{
services.snapper.configs.root = lib.mkIf config.environment.persistence."/persist".enable {
SUBVOLUME = "/persist";
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
TIMELINE_LIMIT_DAILY = 1;
TIMELINE_LIMIT_WEEKLY = 0;
TIMELINE_LIMIT_MONTHLY = 0;
TIMELINE_LIMIT_YEARLY = 0;
};
}