Compare commits

...

45 commits

Author SHA1 Message Date
Bruno BELANYI 5abcc66191 WIP: add note about 'iwd'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2024-11-29 22:27:15 +00:00
Bruno BELANYI c7fc4c2c67 WIP: even more directories? Maybe? 2024-11-29 22:27:15 +00:00
Bruno BELANYI 489802efbe WIP: add notes for missing persistence/backup
TODO:
* Do home-manager
* Look at for more inspiration github.com:nix-community/impermanence/pull/108
* Common files github.com:nix-community/impermanence/issues/10
* Useful config: github.com:chayleaf/dotfiles/blob/f77271b249e0c08368573c22a5c34f0737d3a766/system/modules/impermanence.nix
2024-11-29 22:27:15 +00:00
Bruno BELANYI ac9eeea26d nixos: services: vikunja: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI a0b91a5d18 nixos: services: transmission: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 6b78d89065 nixos: services: tandoor-recipes: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 4c12fc0094 nixos: services: sabnzbd: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 217c69cc9f nixos: services: rss-bridge: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 31c20c5b1b nixos: services: quassel: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 795026e918 nixos: services: pyload: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI b376366d7b nixos: services: postgresql-backup: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 1f6c40c3eb nixos: services: postgresql: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI aa6baa82e8 nixos: services: podgrab: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI f860452c1c nixos: services: servarr: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI a1bc64cf48 nixos: services: pdf-edit: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI b8325e8ea7 nixos: services: paperless: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 0dccde9edf nixos: services: nextcloud: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 260f1e9b5c nixos: services: nginx: persist SSL certificates 2024-11-29 22:27:15 +00:00
Bruno BELANYI 178f6825c0 nixos: services: navidrome: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 629e5d99f5 nixos: services: monitoring: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 370c8354da nixos: services: matrix: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI c7cc887322 nixos: services: lohr: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 6f27b15781 nixos: services: komga: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI e4916ddb88 nixos: services: jellyfin: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 4569fe8a29 nixos: services: indexers: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI b8f4dd33ee nixos: services: grocy: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI fc98fe2b3e nixos: services: gitea: persist repositories 2024-11-29 22:27:15 +00:00
Bruno BELANYI 82e56bf80c nixos: services: forgejo: persist repositories 2024-11-29 22:27:15 +00:00
Bruno BELANYI bdc008d0fc nixos: services: flood: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 5f607efee8 nixos: services: fail2ban: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 5c5738e1d8 nixos: services: calibre-web: persist library 2024-11-29 22:27:15 +00:00
Bruno BELANYI 7d8a18c968 nixos: services: blog: persist website data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 4fb2447648 nixos: services: audiobookshelf: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI ef88c7561b nixos: services: aria: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 4e2055da7f nixos: services: ssh-server: persist host keys 2024-11-29 22:27:15 +00:00
Bruno BELANYI 2f3b9950e1 nixos: hardware: networking persist connections 2024-11-29 22:27:15 +00:00
Bruno BELANYI 8607b3c577 nixos: hardware: bluetooth: persist connections 2024-11-29 22:27:15 +00:00
Bruno BELANYI 257c0675e2 nixos: system: podman: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 55fd694c69 nixos: system: docker: persist data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 2a20ecbd1e nixos: system: persist: filter unique entries
To make sure that different modules configuring the same values don't
run into any issues (e.g: download clients sharing a download
directory).
2024-11-29 22:27:15 +00:00
Bruno BELANYI fa732c88e4 WIP: nixos: system: add persist
This is the module that takes care of configuring impermanence at the
system level.

WIP:
    * address FIXMEs
    * activate home-manager persistence?
        * set `programs.fuse.userAllowOther = true;` ?
    * point `age` to persisted paths [1] ?
    * make sure all services and modules are persisted correctly...

[1]: b1d18d25b8
2024-11-29 22:27:15 +00:00
Bruno BELANYI 99a3bd2587 flake: add 'impermanence' 2024-11-29 22:27:15 +00:00
Bruno BELANYI e40247ed81 nixos: services: tandoor-recipes: backup data 2024-11-29 22:27:15 +00:00
Bruno BELANYI 1dcf5a1f1c nixos: services: mealie: backup data 2024-11-29 21:38:08 +00:00
Bruno BELANYI 7b21943693 nixos: services: grocy: backup data 2024-11-29 19:21:14 +00:00
49 changed files with 316 additions and 0 deletions

View file

@ -150,6 +150,22 @@
"type": "github"
}
},
"impermanence": {
"locked": {
"lastModified": 1697303681,
"narHash": "sha256-caJ0rXeagaih+xTgRduYtYKL1rZ9ylh06CIrt1w5B4g=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "0f317c2e9e56550ce12323eb39302d251618f5b5",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "master",
"repo": "impermanence",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1732521221,
@ -214,6 +230,7 @@
"flake-parts": "flake-parts",
"futils": "futils",
"home-manager": "home-manager",
"impermanence": "impermanence",
"nixpkgs": "nixpkgs",
"nur": "nur",
"pre-commit-hooks": "pre-commit-hooks",

View file

@ -43,6 +43,13 @@
};
};
impermanence = {
type = "github";
owner = "nix-community";
repo = "impermanence";
ref = "master";
};
nixpkgs = {
type = "github";
owner = "NixOS";

View file

@ -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 = {

View file

@ -22,6 +22,18 @@ in
config = lib.mkMerge [
(lib.mkIf cfg.wireless.enable {
networking.networkmanager.enable = true;
# IWD needs persistence if enabled
# Persist NetworkManager files
my.system.persist.files = [
"/var/lib/NetworkManager/secret_key"
"/var/lib/NetworkManager/seen-bssids"
"/var/lib/NetworkManager/timestamps"
];
my.system.persist.directories = [
"/etc/NetworkManager/system-connections"
];
})
];
}

View file

@ -69,6 +69,11 @@ in
};
};
my.system.persist.directories = [
cfg.downloadDir
"/var/lib/aria2"
];
# NOTE: unfortunately aria2 does not log connection failures for fail2ban
};
}

View file

@ -34,6 +34,10 @@ in
};
};
my.system.persist.directories = [
"/var/lib/${config.services.audiobookshelf.dataDir}"
];
services.fail2ban.jails = {
audiobookshelf = ''
enabled = true

View file

@ -41,5 +41,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"
];
};
}

View file

@ -53,6 +53,11 @@ in
];
};
my.system.persist.directories = [
"/var/lib/${config.services.calibre-web.dataDir}"
cfg.libraryPath
];
services.fail2ban.jails = {
calibre-web = ''
enabled = true

View file

@ -39,5 +39,7 @@ in
extraGroups = [ "docker" ]; # Give access to the daemon
};
users.groups.drone-runner-docker = { };
# FIXME: persistence?
};
}

View file

@ -63,5 +63,7 @@ in
group = "drone-runner-exec";
};
users.groups.drone-runner-exec = { };
# FIXME: persistence?
};
}

View file

@ -50,5 +50,7 @@ in
inherit (cfg) port;
};
};
# FIXME: persistence?
};
}

View file

@ -33,5 +33,9 @@ in
bantime = "10m";
};
};
my.system.persist.directories = [
"/var/lib/fail2ban"
];
};
}

View file

@ -28,6 +28,10 @@ in
};
};
my.system.persist.directories = [
"/var/lib/flood"
];
# NOTE: unfortunately flood does not log connection failures for fail2ban
};
}

View file

@ -147,6 +147,11 @@ in
];
};
my.system.persist.directories = [
config.services.forgejo.lfs.contentDir
config.services.forgejo.repositoryRoot
];
services.fail2ban.jails = {
forgejo = ''
enabled = true

View file

@ -131,6 +131,11 @@ in
];
};
my.system.persist.directories = [
config.services.gitea.lfs.contentDir
config.services.gitea.repositoryRoot
];
services.fail2ban.jails = {
gitea = ''
enabled = true

View file

@ -37,6 +37,16 @@ in
useACMEHost = config.networking.domain;
};
my.services.backup = {
paths = [
config.services.grocy.dataDir
];
};
my.system.persist.directories = [
config.services.grocy.dataDir
];
# NOTE: unfortunately grocy does not log connection failures for fail2ban
};
}

View file

@ -33,6 +33,10 @@ in
port = jackettPort;
};
};
my.system.persist.directories = [
config.services.jackett.dataDir
];
})
(lib.mkIf cfg.nzbhydra.enable {
@ -45,6 +49,10 @@ in
port = nzbhydraPort;
};
};
my.system.persist.directories = [
config.services.nzbhydra2.dataDir
];
})
(lib.mkIf cfg.prowlarr.enable {
@ -58,6 +66,10 @@ in
};
};
my.system.persist.directories = [
"/var/lib/prowlarr"
];
services.fail2ban.jails = {
prowlarr = ''
enabled = true

View file

@ -38,6 +38,10 @@ in
};
};
my.system.persist.directories = [
"/var/lib/jellyfin"
];
services.fail2ban.jails = {
jellyfin = ''
enabled = true

View file

@ -36,6 +36,10 @@ in
};
};
my.system.persist.directories = [
config.services.komga.stateDir
];
services.fail2ban.jails = {
komga = ''
enabled = true

View file

@ -107,5 +107,9 @@ in
};
};
};
my.system.persist.directories = [
"/var/lib/lohr"
];
};
}

View file

@ -214,5 +214,9 @@ in
config.services.matrix-synapse.dataDir
];
};
my.system.persist.directories = [
config.services.matrix-synapse.dataDir
];
};
}

View file

@ -72,6 +72,12 @@ in
};
};
my.services.backup = {
paths = [
"/var/lib/mealie"
];
};
services.fail2ban.jails = {
mealie = ''
enabled = true

View file

@ -130,5 +130,10 @@ in
inherit (cfg.grafana) port;
};
};
my.system.persist.directories = [
config.services.grafana.dataDir
"/var/lib/${config.services.prometheus.stateDir}"
];
};
}

View file

@ -53,6 +53,10 @@ in
};
};
my.system.persist.directories = [
"/var/lib/navidrome"
];
services.fail2ban.jails = {
navidrome = ''
enabled = true

View file

@ -46,5 +46,7 @@ in
];
};
};
# FIXME: persistence?
};
}

View file

@ -92,6 +92,10 @@ in
];
};
my.system.persist.directories = [
config.services.nextcloud.home
];
services.fail2ban.jails = {
nextcloud = ''
enabled = true

View file

@ -486,5 +486,9 @@ in
}
];
};
my.system.persist.directories = [
"/var/lib/acme"
];
};
}

View file

@ -146,5 +146,10 @@ in
config.services.paperless.mediaDir
];
};
my.system.persist.directories = [
config.services.paperless.dataDir
config.services.paperless.mediaDir
];
};
}

View file

@ -54,6 +54,10 @@ in
};
};
my.system.persist.directories = [
"/var/lib/stirling-pdf"
];
services.fail2ban.jails = {
stirling-pdf = ''
enabled = true

View file

@ -51,5 +51,10 @@ in
inherit (cfg) port;
};
};
my.system.persist.directories = [
config.systemd.services.podgrab.environment.CONFIG
config.systemd.services.podgrab.environment.DATA
];
};
}

View file

@ -24,5 +24,9 @@ in
(config.services.postgresqlBackup.location + "/*.prev.sql.gz")
];
};
my.system.persist.directories = [
config.services.postgresqlBackup.location
];
};
}

View file

@ -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 {
environment.systemPackages =

View file

@ -53,6 +53,11 @@ in
};
};
my.system.persist.directories = [
cfg.downloadDirectory
"/var/lib/pyload"
];
services.fail2ban.jails = {
pyload = ''
enabled = true

View file

@ -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
];
};
}

View file

@ -22,5 +22,9 @@ in
forceSSL = true;
useACMEHost = config.networking.domain;
};
my.system.persist.directories = [
config.services.rss-bridge.dataDir
];
};
}

View file

@ -24,6 +24,10 @@ in
};
};
my.system.persist.files = [
config.services.sabnzbd.configFile
];
services.fail2ban.jails = {
sabnzbd = ''
enabled = true

View file

@ -19,6 +19,16 @@ let
enable = true;
group = "media";
};
my.system.persist.directories =
let
# Bazarr breaks the mold unfortunately
dataDir =
if service != "bazarr"
then config.services.${service}.dataDir
else "/var/lib/bazarr";
in
[ dataDir ];
};
mkRedirection = service: {

View file

@ -20,6 +20,13 @@ in
};
};
# Persist SSH keys
my.system.persist.files =
let
pubAndPrivKey = key: [ key.path "${key.path}.pub" ];
in
lib.concatMap pubAndPrivKey config.services.openssh.hostKeys;
# Opens the relevant UDP ports.
programs.mosh.enable = true;
};

View file

@ -83,6 +83,16 @@ in
};
};
my.services.backup = {
paths = [
"/var/lib/tandoor-recipes"
];
};
my.system.persist.directories = [
"/var/lib/tandoor-recipes"
];
# NOTE: unfortunately tandoor-recipes does not log connection failures for fail2ban
};
}

View file

@ -91,6 +91,11 @@ in
allowedUDPPorts = [ cfg.peerPort ];
};
my.system.persist.directories = [
cfg.downloadBase
config.services.transmission.home
];
# NOTE: unfortunately transmission does not log connection failures for fail2ban
};
}

View file

@ -100,6 +100,10 @@ in
];
};
my.system.persist.directories = [
config.services.vikunja.settings.files.basepath
];
# NOTE: unfortunately vikunja does not log connection failures for fail2ban
};
}

View file

@ -38,5 +38,7 @@ in
];
};
};
# FIXME: persistence?
};
}

View file

@ -62,5 +62,7 @@ in
];
};
};
# FIXME: persistence?
};
}

View file

@ -61,5 +61,7 @@ in
port = cfg.rpcPort;
};
};
# FIXME: persistence
};
}

View file

@ -9,6 +9,7 @@
./language
./nix
./packages
./persist
./podman
./polkit
./printing

View file

@ -23,5 +23,9 @@ in
];
};
};
my.system.persist.directories = [
"/var/lib/docker"
];
};
}

View file

@ -0,0 +1,70 @@
# 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" # Machine-specific ID
"/etc/adjtime" # Clock drift factor and offsets
]
++ lib.unique cfg.files
;
directories = [
"/etc/nixos" # In case it's storage directory of our configuration
"/var/log" # Logs
"/var/lib/nixos" # UID/GID maps
"/var/lib/systemd/coredump" # Coredumps
"/var/lib/systemd" # FIXME: needed?
"/var/spool" # FIXME: needed?
"/var/tmp" # FIXME: needed?
]
++ lib.unique cfg.directories
;
};
};
}

View file

@ -44,5 +44,9 @@ in
];
};
};
my.system.persist.directories = [
"/var/lib/containers"
];
};
}

View file

@ -65,5 +65,7 @@ in
# Allow resolution of '.local' addresses
nssmdns4 = true;
};
# FIXME: persistence?
};
}