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

100 lines
2.2 KiB
Nix
Raw Normal View History

2024-09-02 22:26:06 +02:00
{
inputs,
config,
lib,
sources,
2024-09-02 22:26:06 +02:00
...
}:
let
inherit (lib.modules) 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 = [
(sources.impermanence + "/nixos.nix")
2024-09-20 15:45:44 +02:00
];
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"
2025-04-06 22:09:17 +02:00
"/etc/secureboot"
2024-09-25 18:04:42 +02:00
];
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}") [
"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
}