fix: NixOS | turn off btrfs wipe and move to hardware config

This commit is contained in:
2025-02-09 16:56:52 +05:00
committed by Shahab Dogar
parent 4bd3532cf6
commit 80890752b8
3 changed files with 28 additions and 67 deletions

View File

@@ -15,37 +15,12 @@ in {
boot = { boot = {
loader = { loader = {
# Set this to true on first install. This must be false for secure boot. # Set this to true on first install. This must be false for secure boot.
systemd-boot.enable = lib.mkForce false; systemd-boot.enable = true;
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
# initrd.postResumeCommands = lib.mkAfter ''
# mkdir /btrfs_tmp
# mount /dev/luks_vg/root /btrfs_tmp
# if [[ -e /btrfs_tmp/root ]]; then
# mkdir -p /btrfs_tmp/old_roots
# timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
# mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
# fi
#
# delete_subvolume_recursively() {
# IFS=$'\n'
# for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
# delete_subvolume_recursively "/btrfs_tmp/$i"
# done
# btrfs subvolume delete "$1"
# }
#
# for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
# delete_subvolume_recursively "$i"
# done
#
# btrfs subvolume create /btrfs_tmp/root
# umount /btrfs_tmp
# '';
lanzaboote = { lanzaboote = {
enable = true; enable = false;
pkiBundle = "/var/lib/sbctl"; pkiBundle = "/var/lib/sbctl";
}; };
}; };
@@ -145,7 +120,6 @@ in {
id = ["24353659"]; id = ["24353659"];
}; };
users.mutableUsers = false;
users.users.shahab = { users.users.shahab = {
shell = pkgs.zsh; shell = pkgs.zsh;
@@ -156,7 +130,13 @@ in {
description = "Shahab Dogar"; description = "Shahab Dogar";
extraGroups = ["networkmanager" "wheel" "input" "libvirtd"]; extraGroups = ["networkmanager" "wheel" "input" "libvirtd"];
initialPassword = "tempPass"; initialPassword = "tempPass";
hashedPasswordFile = config.sops.secrets."user_passwords/shahab".path; #hashedPasswordFile = config.sops.secrets."user_passwords/shahab".path;
openssh.authorizedKeys = {
keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPBijtTtb6UT5gssWolNGX1rcjAKsdtfz25fZMMnzq4v"
];
};
}; };
sops = { sops = {
@@ -201,35 +181,6 @@ in {
protonup-qt protonup-qt
]; ];
environment.persistence."/persistent" = {
hideMounts = true;
directories = [
"/var/log"
"/var/lib/bluetooth"
"/var/lib/nixos"
"/var/lib/sbctl"
"/var/lib/systemd/coredump"
"/etc/NetworkManager/system-connections"
];
files = [
"/etc/machine-id"
];
users.shahab = {
directories = [
"Downloads"
"Knowledge"
"nix-config"
"nix-secrets"
".config"
".local"
".1password"
".steam"
".mozilla"
{ directory = ".ssh"; mode = "0700"; }
];
};
};
# Enable steam for gaming # Enable steam for gaming
programs.steam = { programs.steam = {
enable = true; enable = true;

View File

@@ -38,7 +38,7 @@
}; };
content = { content = {
type = "lvm_pv"; type = "lvm_pv";
vg = "luks_vg"; vg = "crypt_vg";
}; };
}; };
}; };
@@ -47,7 +47,7 @@
}; };
}; };
lvm_vg = { lvm_vg = {
luks_vg = { crypt_vg = {
type = "lvm_vg"; type = "lvm_vg";
lvs = { lvs = {
swap = { swap = {
@@ -57,16 +57,27 @@
resumeDevice = true; resumeDevice = true;
}; };
}; };
root = { main = {
size = "100%"; size = "100%";
content = { content = {
type = "btrfs"; type = "btrfs";
extraArgs = ["-L" "nixos" "-f"]; extraArgs = ["-L" "nixos" "-f"];
subvolumes = { subvolumes = {
"/root" = { "@root" = {
mountpoint = "/"; mountpoint = "/";
mountOptions = [
"compress=zstd"
];
}; };
"/nix" = { "@home" = {
mountpoint = "/home";
mountOptions = [
"subvol=home"
"compress=zstd"
"noatime"
];
};
"@nix" = {
mountpoint = "/nix"; mountpoint = "/nix";
mountOptions = [ mountOptions = [
"subvol=nix" "subvol=nix"
@@ -74,10 +85,10 @@
"noatime" "noatime"
]; ];
}; };
"/persistent" = { "@var/log" = {
mountpoint = "/persistent"; mountpoint = "/var/log";
mountOptions = [ mountOptions = [
"subvol=persistent" "subvol=syslogs"
"compress=zstd" "compress=zstd"
"noatime" "noatime"
]; ];

View File

@@ -9,7 +9,6 @@
}: { }: {
imports = [(modulesPath + "/installer/scan/not-detected.nix")]; imports = [(modulesPath + "/installer/scan/not-detected.nix")];
fileSystems."/persistent".neededForBoot = true;
boot = { boot = {
initrd = { initrd = {
availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "thunderbolt" "usb_storage" "sd_mod"]; availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "thunderbolt" "usb_storage" "sd_mod"];