mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 17:17:22 +01:00
feat: optional impermanence and encryption
This commit is contained in:
parent
c6f64d8764
commit
c3e606a759
5 changed files with 149 additions and 47 deletions
|
|
@ -10,6 +10,8 @@ in
|
|||
{
|
||||
_module.args = {
|
||||
withSwap = false;
|
||||
withImpermanence = true;
|
||||
withEncryption = false;
|
||||
};
|
||||
}
|
||||
./hardware-configuration.nix
|
||||
|
|
@ -72,7 +74,7 @@ in
|
|||
|
||||
swarselsystems = {
|
||||
wallpaper = self + /wallpaper/lenovowp.png;
|
||||
impermanence = false;
|
||||
impermanence = true;
|
||||
isBtrfs = false;
|
||||
initialSetup = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
# NOTE: ... is needed because dikso passes diskoFile
|
||||
{ lib
|
||||
, pkgs
|
||||
, withSwap ? false
|
||||
, swapSize
|
||||
, withSwap ? true
|
||||
, withEncryption ? true
|
||||
, withImpermanence ? true
|
||||
, ...
|
||||
}:
|
||||
{
|
||||
|
|
@ -26,7 +28,47 @@
|
|||
mountOptions = [ "defaults" ];
|
||||
};
|
||||
};
|
||||
luks = {
|
||||
root = lib.mkIf (!withEncryption) {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-f" ]; # force overwrite
|
||||
postCreateHook = lib.mkIf withImpermanence ''
|
||||
MNTPOINT=$(mktemp -d)
|
||||
mount "/dev/mapper/root" "$MNTPOINT" -o subvol=/
|
||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
||||
btrfs subvolume snapshot -r $MNTPOINT/root $MNTPOINT/root-blank
|
||||
'';
|
||||
subvolumes = {
|
||||
"@root" = {
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"@persist" = lib.mkIf withImpermanence {
|
||||
mountpoint = "/persist";
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"@nix" = {
|
||||
mountpoint = "/nix";
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"@swap" = lib.mkIf withSwap {
|
||||
mountpoint = "/.swapvol";
|
||||
swap.swapfile.size = "${swapSize}G";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
luks = lib.mkIf withEncryption {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "luks";
|
||||
|
|
@ -45,6 +87,12 @@
|
|||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-f" ]; # force overwrite
|
||||
postCreateHook = lib.mkIf withImpermanence ''
|
||||
MNTPOINT=$(mktemp -d)
|
||||
mount "/dev/mapper/cryptroot" "$MNTPOINT" -o subvol=/
|
||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
||||
btrfs subvolume snapshot -r $MNTPOINT/root $MNTPOINT/root-blank
|
||||
'';
|
||||
subvolumes = {
|
||||
"@root" = {
|
||||
mountpoint = "/";
|
||||
|
|
@ -53,13 +101,13 @@
|
|||
"noatime"
|
||||
];
|
||||
};
|
||||
# "@persist" = {
|
||||
# mountpoint = "${config.hostSpec.persistFolder}";
|
||||
# mountOptions = [
|
||||
# "compress=zstd"
|
||||
# "noatime"
|
||||
# ];
|
||||
# };
|
||||
"@persist" = lib.mkIf withImpermanence {
|
||||
mountpoint = "/persist";
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"@nix" = {
|
||||
mountpoint = "/nix";
|
||||
mountOptions = [
|
||||
|
|
@ -81,6 +129,8 @@
|
|||
};
|
||||
};
|
||||
|
||||
fileSystems."/persist".neededForBoot = lib.mkIf withImpermanence true;
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.yubikey-manager # For luks fido2 enrollment before full install
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue