nichts/modules/system/os/impermanence/module.nix

80 lines
2.1 KiB
Nix
Raw Normal View History

2024-09-02 22:26:06 +02:00
{
inputs,
config,
lib,
...
}: let
2024-09-25 18:04:42 +02:00
inherit (lib) mkIf mkForce;
2024-09-20 15:45:44 +02:00
inherit (builtins) map;
2024-09-02 22:26:06 +02:00
cfg = config.modules.system.impermanence;
in {
2024-09-20 15:45:44 +02:00
imports = [
inputs.impermanence.nixosModules.impermanence
];
2024-09-25 18:04:42 +02:00
config = mkIf cfg.enable {
2024-09-20 22:57:15 +02:00
users = {
2025-01-07 19:54:27 +01:00
mutableUsers = true;
2024-09-25 18:04:42 +02:00
users = {
cr = {
hashedPasswordFile = "/persist/passwords/cr";
};
root.hashedPasswordFile = "/persist/passwords/root";
2024-09-20 22:57:15 +02:00
};
};
2024-09-02 22:26:06 +02:00
2024-09-25 18:04:42 +02:00
environment.persistence."/persist" = {
enable = true;
2024-09-25 18:04:42 +02:00
hideMounts = true;
directories = [
"/etc/nixos"
"/etc/nix"
"/etc/NetworkManager/system-connections"
"/var/db/sudo"
"/var/log"
"/var/lib/bluetooth"
"/var/lib/nixos"
"/var/lib/pipewire"
"/var/lib/systemd/coredump"
];
2024-09-20 15:45:44 +02:00
2024-09-25 18:04:42 +02:00
users.cr = {
directories =
[
"cloud"
"repos"
]
++ map (
dir: ".config/${dir}"
) ["nicotine" "Signal" "Nextcloud" "emacs" "doom"]
++ map (
dir: ".cache/${dir}"
) ["tealdeer" "keepassxc" "nix" "starship" "nix-index" "mozilla" "zsh" "nvim"]
++ map (
dir: ".local/share/${dir}"
2024-11-01 13:49:59 +01:00
) ["direnv" "Steam" "TelegramDesktop" "PrismLauncher" "nicotine" "zoxide" ".keepass"];
2024-09-25 18:04:42 +02:00
};
2024-09-20 15:45:44 +02:00
};
2024-09-25 18:04:42 +02:00
# for some reason *this* is what makes networkmanager not get screwed completely instead of the impermanence module
systemd.tmpfiles.rules = [
"L /var/lib/NetworkManager/secret_key - - - - /persist/var/lib/NetworkManager/secret_key"
"L /var/lib/NetworkManager/seen-bssids - - - - /persist/var/lib/NetworkManager/seen-bssids"
"L /var/lib/NetworkManager/timestamps - - - - /persist/var/lib/NetworkManager/timestamps"
];
2024-09-20 15:45:44 +02:00
2024-09-25 18:04:42 +02:00
services.openssh.hostKeys = mkForce [
{
bits = 4096;
path = "/persist/etc/ssh/ssh_host_rsa_key";
type = "rsa";
}
{
bits = 4096;
path = "/persist/etc/ssh/ssh_host_ed25519_key";
type = "ed25519";
}
];
};
2024-09-02 22:26:06 +02:00
}