start refactoring shared code into modules, update the lock, do some other minor fixes
This commit is contained in:
parent
c2780184c2
commit
5527f50a3b
43 changed files with 2348 additions and 51 deletions
208
modules/nixos/preservation/default.nix
Normal file
208
modules/nixos/preservation/default.nix
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
{ lib, config, ...}:
|
||||
let cfg = config.preservationSetup; in {
|
||||
options = {
|
||||
preservationSetup.enable = lib.mkEnableOption "Enable setup of preservation of files in /persistent";
|
||||
global.desktop = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether or not we should make desktop preservation files.";
|
||||
};
|
||||
global.server = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether or not we should make server preservation files.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
preservation = {
|
||||
# the module doesn't do anything unless it is enabled
|
||||
enable = true;
|
||||
|
||||
preserveAt."/persistent" = {
|
||||
# preserve system directories
|
||||
directories = [
|
||||
#Shared
|
||||
"/var/lib/sbctl"
|
||||
"/var/lib/bluetooth"
|
||||
"/var/lib/fprint"
|
||||
"/var/lib/fwupd"
|
||||
"/var/lib/libvirt"
|
||||
"/var/lib/tpm2-tss"
|
||||
"/var/lib/tpm2-udev-trigger"
|
||||
"/var/lib/power-profiles-daemon"
|
||||
"/var/lib/systemd/coredump"
|
||||
"/var/lib/systemd/rfkill"
|
||||
"/var/lib/systemd/timers"
|
||||
"/var/log"
|
||||
{
|
||||
directory = "/var/lib/nixos";
|
||||
inInitrd = true;
|
||||
}
|
||||
{
|
||||
directory = "/var/secrets";
|
||||
inInitrd = true;
|
||||
}
|
||||
] ++ lib.mkIf (cfg.desktop == true) [
|
||||
#Desktop
|
||||
"/var/lib/decky-loader"
|
||||
"/var/lib/flatpak"
|
||||
] ++ lib.mkIf (cfg.server == true) [
|
||||
#Server
|
||||
"/var/lib/continuwuity"
|
||||
"/var/lib/dhcpcd"
|
||||
"/var/lib/docker"
|
||||
"/var/lib/dovecot"
|
||||
"/var/lib/forgejo"
|
||||
"/var/lib/gotosocial"
|
||||
"/var/lib/grafana"
|
||||
"/var/lib/jellyfin"
|
||||
"/var/lib/media"
|
||||
"/var/lib/mollysocket"
|
||||
"/var/lib/private"
|
||||
"/var/lib/mysql"
|
||||
"/var/lib/nextcloud"
|
||||
"/var/lib/onlyoffice"
|
||||
"/var/lib/postfix"
|
||||
"/var/lib/postgresql"
|
||||
"/var/lib/prometheus2"
|
||||
"/var/lib/rabbitmq"
|
||||
"/var/lib/redis-nextcloud"
|
||||
"/var/lib/redis-rspamd"
|
||||
"/var/lib/secrets"
|
||||
"/var/lib/writefreely"
|
||||
"/var/db"
|
||||
"/var/dkim"
|
||||
"/var/secrets"
|
||||
"/var/sieve"
|
||||
"/var/vmail"
|
||||
"/var/mysql"
|
||||
];
|
||||
|
||||
# preserve system files
|
||||
files = [
|
||||
{
|
||||
file = "/etc/machine-id";
|
||||
inInitrd = true;
|
||||
how = "symlink";
|
||||
}
|
||||
"/var/lib/usbguard/rules.conf"
|
||||
|
||||
# creates a symlink on the volatile root
|
||||
# creates an empty directory on the persistent volume, i.e. /persistent/var/lib/systemd
|
||||
# does not create an empty file at the symlink's target (would require `createLinkTarget = true`)
|
||||
{
|
||||
file = "/var/lib/systemd/random-seed";
|
||||
how = "symlink";
|
||||
inInitrd = true;
|
||||
configureParent = true;
|
||||
}
|
||||
"/var/lib/systemd/tpm2-srk-public-key.pem"
|
||||
"/var/lib/systemd/tpm2-srk-public-key.tpm2b_public"
|
||||
];
|
||||
|
||||
# preserve user-specific files, implies ownership
|
||||
users = {
|
||||
lillian = {
|
||||
commonMountOptions = [
|
||||
"x-gvfs-hide"
|
||||
];
|
||||
directories = [
|
||||
{
|
||||
directory = ".ssh";
|
||||
mode = "0700";
|
||||
}
|
||||
] ++ lib.mkIf (cfg.desktop == true) [
|
||||
#Desktop
|
||||
".local/state/wireplumber"
|
||||
".local/share/direnv"
|
||||
".local/state/nix"
|
||||
".local/state/comma"
|
||||
".local/state/home-manager"
|
||||
".local/share/PrismLauncher"
|
||||
".local/share/qBittorrent"
|
||||
".local/share/kwalletd"
|
||||
".local/share/kwin" #TODO: add the window script via nix instead of saving it imperatively and keeping it
|
||||
".local/share/lutris"
|
||||
".local/share/Nextcloud"
|
||||
".local/share/Steam"
|
||||
".local/share/zoxide"
|
||||
".local/share/flatpak"
|
||||
".local/share/applications"
|
||||
".local/share/firefoxpwa/"
|
||||
".local/share/zoxide"
|
||||
".mozilla"
|
||||
".steam"
|
||||
".zsh"
|
||||
".pki"
|
||||
".tldrc"
|
||||
".thunderbird"
|
||||
"Code"
|
||||
"Writing"
|
||||
"Games"
|
||||
".config/kdeconnect"
|
||||
".config/Nextcloud"
|
||||
".config/noisetorch"
|
||||
".config/qBittorrent"
|
||||
".config/r2modman"
|
||||
".config/r2modmanPlus-local"
|
||||
".config/Ryujinx"
|
||||
".config/Signal"
|
||||
".config/sops"
|
||||
".config/vesktop"
|
||||
".config/kde.org"
|
||||
];
|
||||
#Shared
|
||||
files = [
|
||||
".z"
|
||||
".zsh_history"
|
||||
];
|
||||
};
|
||||
root = {
|
||||
# specify user home when it is not `/home/${user}`
|
||||
home = "/root";
|
||||
directories = [
|
||||
{
|
||||
directory = ".ssh";
|
||||
mode = "0700";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
systemd.services.systemd-machine-id-commit = {
|
||||
unitConfig.ConditionPathIsMountPoint = [
|
||||
""
|
||||
"/persistent/etc/machine-id"
|
||||
];
|
||||
serviceConfig.ExecStart = [
|
||||
""
|
||||
"systemd-machine-id-setup --commit --root /persistent"
|
||||
];
|
||||
};
|
||||
systemd.tmpfiles.settings.preservation = {
|
||||
"/home/lillian/.config".d = {
|
||||
user = "lillian";
|
||||
group = "users";
|
||||
mode = "0755";
|
||||
};
|
||||
"/home/lillian/.local".d = {
|
||||
user = "lillian";
|
||||
group = "users";
|
||||
mode = "0755";
|
||||
};
|
||||
"/home/lillian/.local/share".d = {
|
||||
user = "lillian";
|
||||
group = "users";
|
||||
mode = "0755";
|
||||
};
|
||||
"/home/lillian/.local/state".d = {
|
||||
user = "lillian";
|
||||
group = "users";
|
||||
mode = "0755";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue