Compare commits
29 commits
5563a1718f
...
38268c61ea
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 38268c61ea | ||
Bruno BELANYI | 7b9a04ba86 | ||
Bruno BELANYI | 906299a1ef | ||
Bruno BELANYI | f41f974e5f | ||
Bruno BELANYI | 380991d5a7 | ||
Bruno BELANYI | 6091c0ccd6 | ||
Bruno BELANYI | 9fca6c2011 | ||
Bruno BELANYI | 53a0a1f613 | ||
Bruno BELANYI | d1521a4a85 | ||
Bruno BELANYI | a8f3a5b6cc | ||
Bruno BELANYI | 576f18e083 | ||
Bruno BELANYI | e5e9769f5c | ||
Bruno BELANYI | 740432cd90 | ||
Bruno BELANYI | 738c50c05e | ||
Bruno BELANYI | 2f0d9cf70d | ||
Bruno BELANYI | 2c51cb52c6 | ||
Bruno BELANYI | 74b1c5a83d | ||
Bruno BELANYI | 463aa0a80c | ||
Bruno BELANYI | 1d8c10ecf5 | ||
Bruno BELANYI | c108c04ff8 | ||
Bruno BELANYI | da9d84da3d | ||
Bruno BELANYI | 270c3a560d | ||
Bruno BELANYI | 136de66291 | ||
Bruno BELANYI | 04439f1d95 | ||
Bruno BELANYI | 0744d8ea86 | ||
Bruno BELANYI | a877570e4d | ||
Bruno BELANYI | aedd0798e8 | ||
Bruno BELANYI | 5a0197922e | ||
Bruno BELANYI | 26495fc8b2 |
17
flake.lock
17
flake.lock
|
@ -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": 1730785428,
|
||||
|
@ -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",
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
};
|
||||
};
|
||||
|
||||
impermanence = {
|
||||
type = "github";
|
||||
owner = "nix-community";
|
||||
repo = "impermanence";
|
||||
ref = "master";
|
||||
};
|
||||
|
||||
nixpkgs = {
|
||||
type = "github";
|
||||
owner = "NixOS";
|
||||
|
|
|
@ -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"
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# FIXME: persistence?
|
||||
|
||||
# NOTE: unfortunately aria2 does not log connection failures for fail2ban
|
||||
};
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# FIXME: persistence?
|
||||
|
||||
services.fail2ban.jails = {
|
||||
audiobookshelf = ''
|
||||
enabled = true
|
||||
|
|
|
@ -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"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -28,6 +28,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# FIXME: persistence?
|
||||
|
||||
# NOTE: unfortunately flood does not log connection failures for fail2ban
|
||||
};
|
||||
}
|
||||
|
|
|
@ -147,6 +147,11 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.gitea.lfs.contentDir
|
||||
config.services.gitea.repositoryRoot
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
forgejo = ''
|
||||
enabled = true
|
||||
|
|
|
@ -131,6 +131,11 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.gitea.lfs.contentDir
|
||||
config.services.gitea.repositoryRoot
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
gitea = ''
|
||||
enabled = true
|
||||
|
|
|
@ -37,6 +37,9 @@ in
|
|||
useACMEHost = config.networking.domain;
|
||||
};
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
|
||||
# NOTE: unfortunately grocy does not log connection failures for fail2ban
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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/${config.systemd.services.prowlarr.serviceConfig.StateDirectory}"
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
prowlarr = ''
|
||||
enabled = true
|
||||
|
|
|
@ -42,6 +42,10 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.systemd.services.jellyfin.serviceConfig.StateDirectory}"
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
jellyfin = ''
|
||||
enabled = true
|
||||
|
|
|
@ -107,5 +107,9 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.systemd.services.lohr.serviceConfig.StateDirectory}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -214,5 +214,9 @@ in
|
|||
config.services.matrix-synapse.dataDir
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.matrix-synapse.dataDir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -72,6 +72,9 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
|
||||
services.fail2ban.jails = {
|
||||
mealie = ''
|
||||
enabled = true
|
||||
|
|
|
@ -49,6 +49,9 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
|
||||
services.fail2ban.jails = {
|
||||
miniflux = ''
|
||||
enabled = true
|
||||
|
|
|
@ -130,5 +130,10 @@ in
|
|||
inherit (cfg.grafana) port;
|
||||
};
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.grafana.dataDir
|
||||
"/var/lib/${config.services.prometheus.stateDir}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/${config.systemd.services.navidrome.serviceConfig.StateDirectory}"
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
navidrome = ''
|
||||
enabled = true
|
||||
|
|
|
@ -88,6 +88,11 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.nextcloud.home
|
||||
config.services.nextcloud.datadir
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
nextcloud = ''
|
||||
enabled = true
|
||||
|
|
|
@ -457,5 +457,9 @@ in
|
|||
}
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.users.user.acme.home
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -166,5 +166,10 @@ in
|
|||
config.services.paperless.mediaDir
|
||||
];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.paperless-ng.dataDir
|
||||
config.services.paperless-ng.mediaDir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -51,5 +51,10 @@ in
|
|||
inherit (cfg) port;
|
||||
};
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.systemd.services.podgrab.environment.CONFIG
|
||||
config.systemd.services.podgrab.environment.DATA
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
environment.systemPackages =
|
||||
|
|
|
@ -53,6 +53,9 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
|
||||
# FIXME: fail2ban
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,5 +22,9 @@ in
|
|||
forceSSL = true;
|
||||
useACMEHost = config.networking.domain;
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.rss-bridge.dataDir
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
my.system.persist.files = [
|
||||
config.services.sabnzbd.configFile
|
||||
];
|
||||
|
||||
services.fail2ban.jails = {
|
||||
sabnzbd = ''
|
||||
enabled = true
|
||||
|
|
|
@ -19,6 +19,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: {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -83,6 +83,9 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# FIXME: backup
|
||||
# FIXME: persistence
|
||||
|
||||
# NOTE: unfortunately tandoor-recipes does not log connection failures for fail2ban
|
||||
};
|
||||
}
|
||||
|
|
|
@ -91,6 +91,10 @@ in
|
|||
allowedUDPPorts = [ cfg.peerPort ];
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
config.services.transmission.home
|
||||
];
|
||||
|
||||
# NOTE: unfortunately transmission does not log connection failures for fail2ban
|
||||
};
|
||||
}
|
||||
|
|
|
@ -100,6 +100,8 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
# FIXME: persistence
|
||||
|
||||
# NOTE: unfortunately vikunja does not log connection failures for fail2ban
|
||||
};
|
||||
}
|
||||
|
|
|
@ -61,5 +61,7 @@ in
|
|||
port = cfg.rpcPort;
|
||||
};
|
||||
};
|
||||
|
||||
# FIXME: persistence
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
./language
|
||||
./nix
|
||||
./packages
|
||||
./persist
|
||||
./podman
|
||||
./polkit
|
||||
./printing
|
||||
|
|
|
@ -23,5 +23,9 @@ in
|
|||
];
|
||||
};
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/docker"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
65
modules/nixos/system/persist/default.nix
Normal file
65
modules/nixos/system/persist/default.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
# 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/nixos"
|
||||
"/var/lib/systemd/coredump"
|
||||
]
|
||||
++ cfg.directories
|
||||
;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -44,5 +44,9 @@ in
|
|||
];
|
||||
};
|
||||
};
|
||||
|
||||
my.system.persist.directories = [
|
||||
"/var/lib/containers"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue