Compare commits
26 commits
bcbcee5912
...
bd7fc9355a
| Author | SHA1 | Date | |
|---|---|---|---|
| bd7fc9355a | |||
| 21596a7c15 | |||
| ae84f7fef7 | |||
| dd8d514c3b | |||
| be2fbd0267 | |||
| 29a711ec44 | |||
| d4bd85f47c | |||
| d983524687 | |||
| eddc721e9b | |||
| 3ec701229e | |||
| 0482b8649b | |||
| ac2c1cf69f | |||
| e7a2b84821 | |||
| aa6ec00a40 | |||
| be58c8d8cd | |||
| 1e4ae91b44 | |||
| 4f269ee64f | |||
| 1739ed3158 | |||
| 9df74cbf08 | |||
| 25157000af | |||
| 9a7123a4ae | |||
| d141a86040 | |||
| b09449492f | |||
| 15119d97da | |||
| b980f14a88 | |||
| 641e93dc32 |
30 changed files with 205 additions and 0 deletions
|
|
@ -18,6 +18,13 @@ in
|
|||
services.blueman.enable = true;
|
||||
}
|
||||
|
||||
# Persist bluetooth files
|
||||
{
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/bluetooth"
|
||||
];
|
||||
}
|
||||
|
||||
# Support for additional bluetooth codecs
|
||||
(lib.mkIf cfg.loadExtraCodecs {
|
||||
hardware.pulseaudio = {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ in
|
|||
config = lib.mkMerge [
|
||||
(lib.mkIf cfg.wireless.enable {
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
# Persist NetworkManager files
|
||||
my.system.persist.directories = [
|
||||
"/etc/NetworkManager/system-connections"
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,5 +42,12 @@ in
|
|||
|
||||
# Those are all subdomains, no problem
|
||||
my.services.nginx.virtualHosts = hostsInfo;
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/www/blog"
|
||||
"/var/www/cv"
|
||||
"/var/www/dev"
|
||||
"/var/www/key"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.services.calibre-web.dataDir}"
|
||||
cfg.libraryPath
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
calibre-web = ''
|
||||
enabled = true
|
||||
|
|
|
|||
|
|
@ -46,5 +46,9 @@ in
|
|||
inherit (cfg) port;
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${cfg.stateDir}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,11 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.gitea.lfs.contentDir
|
||||
config.services.gitea.repositoryRoot
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
gitea = ''
|
||||
enabled = true
|
||||
|
|
|
|||
|
|
@ -36,5 +36,8 @@ in
|
|||
forceSSL = true;
|
||||
useACMEHost = config.networking.domain;
|
||||
};
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ in
|
|||
port = jackettPort;
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.jackett.dataDir
|
||||
];
|
||||
})
|
||||
|
||||
(lib.mkIf cfg.nzbhydra.enable {
|
||||
|
|
@ -47,6 +51,10 @@ in
|
|||
port = nzbhydraPort;
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.nzbhydra2.dataDir
|
||||
];
|
||||
})
|
||||
|
||||
(lib.mkIf cfg.prowlarr.enable {
|
||||
|
|
@ -61,6 +69,10 @@ in
|
|||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.systemd.services.prowlarr.serviceConfig.StateDirectory}"
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
prowlarr = ''
|
||||
enabled = true
|
||||
|
|
|
|||
|
|
@ -35,5 +35,9 @@ in
|
|||
};
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.systemd.services.jellyfin.serviceConfig.StateDirectory}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,5 +104,9 @@ in
|
|||
inherit (cfg) port;
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.systemd.services.lohr.serviceConfig.StateDirectory}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,5 +257,9 @@ in
|
|||
config.services.matrix-synapse.dataDir
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.matrix-synapse.dataDir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,5 +49,8 @@ in
|
|||
inherit (cfg) port;
|
||||
}
|
||||
];
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,5 +131,10 @@ in
|
|||
inherit (cfg.grafana) port;
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.grafana.dataDir
|
||||
"/var/lib/${config.services.prometheus.stateDir}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,5 +53,9 @@ in
|
|||
inherit (cfg) port;
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.systemd.services.navidrome.serviceConfig.StateDirectory}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,5 +82,10 @@ in
|
|||
"${config.services.nextcloud.home}/data/appdata_*/preview"
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.nextcloud.home
|
||||
config.services.nextcloud.datadir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -467,5 +467,9 @@ in
|
|||
}
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.users.user.acme.home
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,5 +164,10 @@ in
|
|||
config.services.paperless.mediaDir
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.paperless-ng.dataDir
|
||||
config.services.paperless-ng.mediaDir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ let
|
|||
enable = true;
|
||||
group = "media";
|
||||
};
|
||||
|
||||
# Thankfully those old style services all define users with homes
|
||||
my.system.persist.directories = [
|
||||
config.users.user.${service}.home
|
||||
];
|
||||
};
|
||||
|
||||
mkRedirection = service: {
|
||||
|
|
|
|||
|
|
@ -37,5 +37,10 @@ in
|
|||
inherit (cfg) port;
|
||||
}
|
||||
];
|
||||
|
||||
my.system.persist.directories =
|
||||
builtins.map
|
||||
(d: "/var/lib/${d}")
|
||||
config.systemd.services.podgrab.serviceConfig.StateDirectory;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,9 @@ in
|
|||
(config.services.postgresqlBackup.location + "/*.prev.sql.gz")
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.postgresqlBackup.location
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,13 @@ in
|
|||
};
|
||||
})
|
||||
|
||||
# Only persist directory if the actual service is enabled
|
||||
(lib.mkIf config.services.postgresql.enable {
|
||||
my.system.persist.directories = [
|
||||
config.services.postgresql.dataDir
|
||||
];
|
||||
})
|
||||
|
||||
# Taken from the manual
|
||||
(lib.mkIf cfg.upgradeScript {
|
||||
containers.temp-pg.config.services.postgresql = {
|
||||
|
|
|
|||
|
|
@ -46,5 +46,9 @@ in
|
|||
# Because Quassel does not use the socket, I simply trust its connection
|
||||
authentication = "host quassel quassel localhost trust";
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.quassel.dataDir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,5 +20,9 @@ in
|
|||
forceSSL = true;
|
||||
useACMEHost = config.networking.domain;
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.rss-bridge.dataDir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ in
|
|||
}
|
||||
];
|
||||
|
||||
my.system.persist.files = [
|
||||
config.services.sabnzbd.configFile
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
sabnzbd = ''
|
||||
enabled = true
|
||||
|
|
|
|||
|
|
@ -20,6 +20,14 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# Persist SSH keys
|
||||
my.system.persist.files = [
|
||||
"/etc/ssh/ssh_host_ed25519_key"
|
||||
"/etc/ssh/ssh_host_ed25519_key.pub"
|
||||
"/etc/ssh/ssh_host_rsa_key"
|
||||
"/etc/ssh/ssh_host_rsa_key.pub"
|
||||
];
|
||||
|
||||
# Opens the relevant UDP ports.
|
||||
programs.mosh.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -76,5 +76,8 @@ in
|
|||
inherit (cfg) port;
|
||||
}
|
||||
];
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,5 +91,9 @@ in
|
|||
allowedTCPPorts = [ cfg.peerPort ];
|
||||
allowedUDPPorts = [ cfg.peerPort ];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.transmission.home
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,5 +119,7 @@ in
|
|||
config.services.vikunja.settings.files.basepath
|
||||
];
|
||||
};
|
||||
|
||||
# FIXME: persistence
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
./language
|
||||
./nix
|
||||
./packages
|
||||
./persist
|
||||
./podman
|
||||
./printing
|
||||
./users
|
||||
|
|
|
|||
68
modules/system/persist/default.nix
Normal file
68
modules/system/persist/default.nix
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# Ephemeral root configuration
|
||||
{ config, inputs, lib, ... }:
|
||||
let
|
||||
cfg = config.my.system.persist;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
inputs.impermanence.nixosModules.impermanence
|
||||
];
|
||||
|
||||
options.my.system.persist = with lib; {
|
||||
enable = mkEnableOption "stateless system configuration";
|
||||
|
||||
mountPoint = lib.mkOption {
|
||||
type = types.str;
|
||||
default = "/persistent";
|
||||
example = "/etc/nix/persist";
|
||||
description = ''
|
||||
Which mount point should be used to persist this system's files and
|
||||
directories.
|
||||
'';
|
||||
};
|
||||
|
||||
files = lib.mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [ ];
|
||||
example = [
|
||||
"/etc/nix/id_rsa"
|
||||
];
|
||||
description = ''
|
||||
Additional files in the root to link to persistent storage.
|
||||
'';
|
||||
};
|
||||
|
||||
directories = lib.mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [ ];
|
||||
example = [
|
||||
"/var/lib/libvirt"
|
||||
];
|
||||
description = ''
|
||||
Additional directories in the root to link to persistent storage.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.persistence."${cfg.mountPoint}" = {
|
||||
files = [
|
||||
"/etc/machine-id"
|
||||
]
|
||||
++ cfg.files
|
||||
;
|
||||
|
||||
directories = [
|
||||
"/etc/nixos"
|
||||
"/var/log"
|
||||
"/var/lib/systemd/coredump"
|
||||
]
|
||||
++ (lib.optionals config.virtualisation.docker.enable [
|
||||
"/var/lib/docker"
|
||||
])
|
||||
# FIXME: podman
|
||||
++ cfg.directories
|
||||
;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue