lets try it out i001 bcache
This commit is contained in:
parent
daa1188f38
commit
f6d01063b2
5 changed files with 100 additions and 1255 deletions
|
|
@ -1,111 +1,33 @@
|
|||
# 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, ... }:
|
||||
let
|
||||
NIXBOOT = "/dev/disk/by-uuid/641A-6BDB";
|
||||
NIXROOT ="/dev/disk/by-uuid/ae94db42-ec46-4e2f-a98a-118359428a68";
|
||||
cryptroot = "/dev/disk/by-uuid/49f11bf1-d4b7-4188-9203-4d7a42569afa";
|
||||
|
||||
USB_KEY = "/dev/disk/by-uuid/9985-EBD1";
|
||||
in
|
||||
{
|
||||
imports =
|
||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
|
||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" "sdhci_pci" "ehci_pci" "uas" ];
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci"
|
||||
"ahci"
|
||||
"usb_storage"
|
||||
"usbhid"
|
||||
"sd_mod"
|
||||
"sdhci_pci"
|
||||
"ehci_pci"
|
||||
"uas"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/boot" =
|
||||
{ device = NIXBOOT;
|
||||
fsType = "vfat";
|
||||
options = [ "fmask=0077" "dmask=0077" ];
|
||||
};
|
||||
|
||||
boot.initrd.luks.devices."cryptroot" = {
|
||||
device = NIXROOT;
|
||||
|
||||
# Auto decrypt
|
||||
keyFile = USB_KEY;
|
||||
keyFileSize = 5000;
|
||||
keyFileOffset = 5443;
|
||||
|
||||
tryEmptyPassphrase = true;
|
||||
fallbackToPassword = true;
|
||||
crypttabExtraOpts = [ "tries=2" ];
|
||||
};
|
||||
|
||||
fileSystems."/" =
|
||||
{ device = cryptroot;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@root" "compress=zstd" ];
|
||||
};
|
||||
|
||||
fileSystems."/nix" =
|
||||
{ device = cryptroot;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@nix" "compress=zstd" "noatime" ];
|
||||
};
|
||||
|
||||
fileSystems."/persist" =
|
||||
{ device = cryptroot;
|
||||
neededForBoot = true;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@persist" "compress=zstd" ];
|
||||
};
|
||||
|
||||
fileSystems."/.swap" =
|
||||
{ device = cryptroot;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@swap" "noatime" ];
|
||||
};
|
||||
|
||||
fileSystems."/.snapshots" =
|
||||
{ device = cryptroot;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@snapshots" "compress=zstd" "noatime"];
|
||||
};
|
||||
|
||||
services.btrfs.autoScrub = {
|
||||
enable = true;
|
||||
# syntax as defined by https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Event s
|
||||
interval = "monthly";
|
||||
fileSystems = ["/"];
|
||||
};
|
||||
|
||||
swapDevices = [{
|
||||
device = "/.swap/swapfile";
|
||||
size = 8*1024; # Creates an 8GB swap file
|
||||
}];
|
||||
|
||||
boot.initrd.postResumeCommands = lib.mkAfter ''
|
||||
mkdir /btrfs_tmp
|
||||
mount ${cryptroot} /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
|
||||
'';
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue