Compare commits

...

49 commits

Author SHA1 Message Date
534cda6d91 WIP: add notes for missing persistence/backup
All checks were successful
ci/woodpecker/push/check Pipeline was successful
TODO:
* Look at for more inspiration https://github.com/nix-community/impermanence/pull/108
* Do home-manager
* Common files https://github.com/nix-community/impermanence/issues/10
2023-10-25 15:52:18 +00:00
4b6d332e9b modules: services: quassel: persist data 2023-10-25 15:52:18 +00:00
7c7eadbf45 modules: services: pirate: persist data 2023-10-25 15:52:18 +00:00
b83c917a9e modules: services: monitoring: persist data 2023-10-25 15:52:18 +00:00
9ebabb251b modules: services: nginx: persist SSL certificates 2023-10-25 15:52:18 +00:00
b48048aa5f modules: services: transmission: persist data 2023-10-25 15:52:18 +00:00
dbd33f7d62 modules: services: sabnzbd: persist data 2023-10-25 15:52:18 +00:00
30a632a261 modules: services: rss-bridge: persist data 2023-10-25 15:52:18 +00:00
1d23a6caa8 modules: services: podgrab: persist data 2023-10-25 15:52:18 +00:00
3328cf62d9 modules: services: nextcloud: persist data 2023-10-25 15:52:18 +00:00
b0622f5696 modules: services: navidrome: persist data 2023-10-25 15:52:18 +00:00
775ac42649 modules: services: lohr: persist data 2023-10-25 15:52:18 +00:00
993bdbd3e7 modules: services: jellyfin: persist data 2023-10-25 15:52:18 +00:00
843c4a8097 modules: services: indexers: persist data 2023-10-25 15:52:18 +00:00
3e28075906 modules: services: postgresql: persist data 2023-10-25 15:52:18 +00:00
72baa4e84f modules: services: postgresql-backup: persist data 2023-10-25 15:52:17 +00:00
706fad7e7f modules: services: paperless: persist data 2023-10-25 15:52:17 +00:00
4fcc69f34e modules: services: matrix: persist data 2023-10-25 15:52:17 +00:00
604d594dec modules: services: gitea: persist repositories 2023-10-25 15:52:17 +00:00
53af6d3fa6 modules: services: flood: persist data 2023-10-25 15:52:17 +00:00
a3b4b3072a modules: services: calibre-web: persist library 2023-10-25 15:52:17 +00:00
ea5f9d181f modules: services: blog: persist website data 2023-10-25 15:52:17 +00:00
e86ab34a62 modules: hardware: bluetooth: persist connections 2023-10-25 15:52:17 +00:00
86b42568ed modules: hardware: netowrking persist connections 2023-10-25 15:52:17 +00:00
5125ca329e modules: services: ssh-server: persist host keys 2023-10-25 15:52:17 +00:00
ab5ebae2cb WIP: modules: systems: 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
2023-10-25 15:52:17 +00:00
270f9f02a2 flake: add 'impermanence' 2023-10-25 15:52:17 +00:00
08212e49cd modules: services: matrix: add sliding sync
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2023-10-20 08:35:37 +00:00
e3a8d0e178 modules: services: matrix: register dummy vhosts
This is simply to make use of my infrastructure for port collision
detection.
2023-10-20 08:35:37 +00:00
ad976e2097 hosts: nixos: porthos: secrets: add matrix sync 2023-10-20 08:35:37 +00:00
31fbd7aa4f modules: services: matrix: refactor vhost 2023-10-20 08:35:37 +00:00
1398425b91 hosts: homes: cloudtop: disable gpg-agent
All checks were successful
ci/woodpecker/push/check Pipeline was successful
It doesn't work well in this environment anyway.
2023-10-19 10:42:22 +00:00
fcdb5ba593 modules: services: woodpecker: remove DNS hack
Some checks are pending
ci/woodpecker/push/check Pipeline is running
I'm not sure what changed, but it looks like I don't need it anymore.

Initially I wanted to apply the same DNS fix as [1].

[1]: https://blog.kotatsu.dev/posts/2023-04-21-woodpecker-nix-caching/
2023-10-18 21:38:22 +02:00
f8a0eef4dd hosts: nixos: porthos: services: disable lidarr 2023-10-18 21:38:22 +02:00
3b3e7093be modules: services: pirate: make more fine-grained 2023-10-18 21:38:22 +02:00
dae1a434d5 modules: services: transmission: bump to 4
Not sure why exactly this isn't the default, I'll have to watch out for
when upstream catches up.
2023-10-18 21:38:22 +02:00
2d36ffd96d pkgs: comma: rename 'COMMA_{,NIX}PKGS_FLAKE'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
This aligns with the rust implementation of this tool [1].

[1]: 17a4f33849
2023-10-12 15:21:06 +00:00
a5febc40e4 home: comma: remove 'COMMA_PKGS_FLAKE' definition
Now that my configurations also set `nixpkgs` in `NIX_PATH`, there's
isn't a need for this to be defined anymore.
2023-10-12 15:21:06 +00:00
ce19887f77 treewide: update 'nix-direnv' bootstrapping 2023-10-12 15:17:26 +00:00
aca743dea7 templates: simplify direnv configurations
All checks were successful
ci/woodpecker/push/check Pipeline was successful
This was mostly a copy-paste error (the `watch_file` calls).

As for the shell hooks, it looks like `nix-direnv` takes care of that
automatically.
2023-10-12 13:47:43 +00:00
e09899d59c direnv: fix 'watch_file' directives
I should use `nix_direnv_watch_file` and call it _before_ `use_flake`.
2023-10-12 13:45:49 +00:00
fd09346526 direnv: remove explicit 'shellHooks' evaluation
I _think_ nix-direnv does it automatically, so no need to do it myself.
2023-10-12 13:40:22 +00:00
f9541cbc33 hosts: homes: mousqueton: disable 'git' package
All checks were successful
ci/woodpecker/push/check Pipeline was successful
I had some troubles with `git` once again...

This reverts commit 13769429f6.
2023-10-12 12:56:41 +00:00
6ef0abd596 home: xdg: set 'REPO_CONFIG_DIR'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
Unfortunately, it will create a `.repoconfig` inside that directory. But
that's still better than littering my $HOME.
2023-10-10 15:36:14 +00:00
24d41e829e modules: system: users: fix deprecated option name
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2023-09-28 15:57:14 +00:00
03a1f704aa flake: bump inputs
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2023-09-27 19:22:04 +02:00
e81de7faad pkgs: rbw-pass: fix program name in usage string
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2023-09-26 16:51:46 +00:00
61fe480e6b home: calibre: remove obsolete NOTE 2023-09-26 16:38:27 +00:00
7b56c342ad modules: services: paperless: beef-up workers
All checks were successful
ci/woodpecker/push/check Pipeline was successful
This should parallelize the number of documents ingested at once
(workers), as well as the speed of the ingestion per document (threads).
2023-09-18 13:43:37 +00:00
46 changed files with 368 additions and 71 deletions

12
.envrc
View file

@ -1,10 +1,8 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
if ! has nix_direnv_version || ! nix_direnv_version 2.4.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.4.0/direnvrc" "sha256-XQzUAvL6pysIJnRJyR7uVpmUSZfc7LSgWQwq/4mBr1U="
fi
nix_direnv_watch_file ./flake/checks.nix
nix_direnv_watch_file ./flake/dev-shells.nix
use flake
watch_file ./flake/checks.nix
watch_file ./flake/dev-shells.nix
eval "$shellHooks"

47
flake.lock generated
View file

@ -11,11 +11,11 @@
]
},
"locked": {
"lastModified": 1690228878,
"narHash": "sha256-9Xe7JV0krp4RJC9W9W9WutZVlw6BlHTFMiUP/k48LQY=",
"lastModified": 1695384796,
"narHash": "sha256-TYlE4B0ktPtlJJF9IFxTWrEeq+XKG8Ny0gc2FGEAdj0=",
"owner": "ryantm",
"repo": "agenix",
"rev": "d8c973fd228949736dedf61b7f8cc1ece3236792",
"rev": "1f677b3e161d3bdbfd08a939e8f25de2568e0ef4",
"type": "github"
},
"original": {
@ -131,11 +131,11 @@
]
},
"locked": {
"lastModified": 1694585439,
"narHash": "sha256-70BlfEsdURx5f8sioj8JuM+R4/SZFyE8UYrULMknxlI=",
"lastModified": 1695738267,
"narHash": "sha256-LTNAbTQ96xSj17xBfsFrFS9i56U2BMLpD0BduhrsVkU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a0ddf43b6268f1717afcda54133dea30435eb178",
"rev": "0f4e5b4999fd6a42ece5da8a3a2439a50e48e486",
"type": "github"
},
"original": {
@ -145,13 +145,29 @@
"type": "github"
}
},
"impermanence": {
"locked": {
"lastModified": 1694622745,
"narHash": "sha256-z397+eDhKx9c2qNafL1xv75lC0Q4nOaFlhaU1TINqb8=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "e9643d08d0d193a2e074a19d4d90c67a874d932e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "master",
"repo": "impermanence",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1694422566,
"narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=",
"lastModified": 1695644571,
"narHash": "sha256-asS9dCCdlt1lPq0DLwkVBbVoEKuEuz+Zi3DG7pR/RxA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb",
"rev": "6500b4580c2a1f3d0f980d32d285739d8e156d92",
"type": "github"
},
"original": {
@ -163,11 +179,11 @@
},
"nur": {
"locked": {
"lastModified": 1694601892,
"narHash": "sha256-rGK2Y9vQJQ+v729LfpvTuxDfTE7ns2g34XAPSr9+Z0E=",
"lastModified": 1695824843,
"narHash": "sha256-c1Z+y9oUXOkcU8gVBCyaujUqYLpYoI2b6L9Cq4ywOcA=",
"owner": "nix-community",
"repo": "NUR",
"rev": "71a739d93f1e95967e9d641623cbb97d0c8b801a",
"rev": "8349f3e37cf21a9da032a2fdb8e7ac45366d01f3",
"type": "github"
},
"original": {
@ -192,11 +208,11 @@
]
},
"locked": {
"lastModified": 1694364351,
"narHash": "sha256-oadhSCqopYXxURwIA6/Anpe5IAG11q2LhvTJNP5zE6o=",
"lastModified": 1695576016,
"narHash": "sha256-71KxwRhTfVuh7kNrg3/edNjYVg9DCyKZl2QIKbhRggg=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "4f883a76282bc28eb952570afc3d8a1bf6f481d7",
"rev": "cb770e93516a1609652fa8e945a0f310e98f10c0",
"type": "github"
},
"original": {
@ -212,6 +228,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

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

View file

@ -9,7 +9,7 @@ in
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
calibre # NOTE: relies on my overlay to add necessary plug-in dependencies
calibre
];
};
}

View file

@ -5,25 +5,11 @@ in
{
options.my.home.comma = with lib; {
enable = my.mkDisableOption "comma configuration";
pkgsFlake = mkOption {
type = types.str;
default = "pkgs";
example = "nixpkgs";
description = ''
Which flake from the registry should be used with
<command>nix shell</command>.
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
ambroisie.comma
];
home.sessionVariables = {
COMMA_PKGS_FLAKE = cfg.pkgsFlake;
};
};
}

View file

@ -47,6 +47,7 @@ in
LESSHISTFILE = "${dataHome}/less/history";
LESSKEY = "${configHome}/less/lesskey";
PSQL_HISTORY = "${dataHome}/psql_history";
REPO_CONFIG_DIR = "${configHome}/repo";
REDISCLI_HISTFILE = "${dataHome}/redis/rediscli_history";
XCOMPOSECACHE = "${dataHome}/X11/xcompose";
};

View file

@ -1,5 +1,5 @@
# Google Cloudtop configuration
{ ... }:
{ lib, pkgs, ... }:
{
# Google specific configuration
home.homeDirectory = "/usr/local/google/home/ambroisie";
@ -13,6 +13,10 @@
LD_PRELOAD = "/lib/x86_64-linux-gnu/libnss_cache.so.2\${LD_PRELOAD:+:}$LD_PRELOAD";
};
programs.git.package = lib.mkForce pkgs.emptyDirectory;
services.gpg-agent.enable = lib.mkForce false;
# I use scripts that use the passthrough sequence often on this host
my.home.tmux.enablePassthrough = true;
}

View file

@ -0,0 +1,9 @@
age-encryption.org/v1
-> ssh-ed25519 cKojmg N182xey8TWRVUWTRP16rT0zlhYZNr/pOZVR7YRnlIkk
HVqAag55z1cKLgjR3WsUj2wvaVjxm169JcDRJGRvCVU
-> ssh-ed25519 jPowng Dc+aaUTxDsMTY+oOst0SC3ldq1e6zX8F5A5uBL5RHhc
JWZou6+VaFc5f2OLRIrmFFWg3Er6WSY+TloXU0mP1K8
-> |9_9Aqh%-grease $ X8Mn|5 aKnl' fl<D{T-
+fAc0cajqxhYWu55HCY
--- SrmtWXQXGYxNTabSrb5tBRXHnK1F22Qoiy7hKYrrF+0
ñD·û²: ,õn0i<>½Àß^ÆŠ`üÔ2Æ#y'ý9ÖñÓÒŽéÿæ<C3BF>r]Àعx“³S=ú°ˆôuJéEÛóc€lH Ê~ ŸKtévo'êv+

View file

@ -35,6 +35,9 @@ in
owner = "matrix-synapse";
publicKeys = all;
};
"matrix/sliding-sync-secret.age" = {
publicKeys = all;
};
"miniflux/credentials.age".publicKeys = all;

View file

@ -64,6 +64,9 @@ in
mailConfigFile = secrets."matrix/mail".path;
# Only necessary when doing the initial registration
secretFile = secrets."matrix/secret".path;
slidingSync = {
secretFile = secrets."matrix/sliding-sync-secret".path;
};
};
miniflux = {
enable = true;
@ -116,7 +119,13 @@ in
secretKeyFile = secrets."paperless/secret-key".path;
};
# The whole *arr software suite
pirate.enable = true;
pirate = {
enable = true;
# ... But not Lidarr because I don't care for music that much
lidarr = {
enable = false;
};
};
# Podcast automatic downloader
podgrab = {
enable = true;

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,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"
];
})
];
}

View file

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

View file

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

View file

@ -46,5 +46,9 @@ in
inherit (cfg) port;
}
];
my.system.persist.directories = [
"/var/lib/${cfg.stateDir}"
];
};
}

View file

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

View file

@ -36,5 +36,8 @@ in
forceSSL = true;
useACMEHost = config.networking.domain;
};
# FIXME: backup
# FIXME: persistence
};
}

View file

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

View file

@ -35,5 +35,9 @@ in
};
}
];
my.system.persist.directories = [
"/var/lib/${config.systemd.services.jellyfin.serviceConfig.StateDirectory}"
];
};
}

View file

@ -104,5 +104,9 @@ in
inherit (cfg) port;
}
];
my.system.persist.directories = [
"/var/lib/${config.systemd.services.lohr.serviceConfig.StateDirectory}"
];
};
}

View file

@ -13,6 +13,7 @@ let
federationPort = { public = 8448; private = 11338; };
clientPort = { public = 443; private = 11339; };
domain = config.networking.domain;
matrixDomain = "matrix.${domain}";
in
{
options.my.services.matrix = with lib; {
@ -25,6 +26,21 @@ in
description = "Shared secret to register users";
};
slidingSync = {
port = mkOption {
type = types.port;
default = 8009;
example = 8084;
description = "Port used by sliding sync server";
};
secretFile = mkOption {
type = types.str;
example = "/var/lib/matrix/sliding-sync-secret-file.env";
description = "Secret file which contains SYNCV3_SECRET definition";
};
};
mailConfigFile = mkOption {
type = types.str;
example = "/var/lib/matrix/email-config.yaml";
@ -52,7 +68,7 @@ in
settings = {
server_name = domain;
public_baseurl = "https://matrix.${domain}";
public_baseurl = "https://${matrixDomain}";
enable_registration = false;
@ -88,6 +104,17 @@ in
extraConfigFiles = [
cfg.mailConfigFile
] ++ lib.optional (cfg.secretFile != null) cfg.secretFile;
sliding-sync = {
enable = true;
settings = {
SYNCV3_SERVER = "https://${matrixDomain}";
SYNCV3_BINDADDR = "127.0.0.1:${toString cfg.slidingSync.port}";
};
environmentFile = cfg.slidingSync.secretFile;
};
};
my.services.nginx.virtualHosts = [
@ -98,12 +125,15 @@ in
conf = {
default_server_config = {
"m.homeserver" = {
"base_url" = "https://matrix.${domain}";
"base_url" = "https://${matrixDomain}";
"server_name" = domain;
};
"m.identity_server" = {
"base_url" = "https://vector.im";
};
"org.matrix.msc3575.proxy" = {
"url" = "https://matrix-sync.${domain}";
};
};
showLabsSettings = true;
defaultCountryCode = "FR"; # cocorico
@ -116,11 +146,25 @@ in
};
};
}
# Dummy VHosts for port collision detection
{
subdomain = "matrix-federation";
port = federationPort.private;
}
{
subdomain = "matrix-client";
port = clientPort.private;
}
# Sliding sync
{
subdomain = "matrix-sync";
inherit (cfg.slidingSync) port;
}
];
# Those are too complicated to use my wrapper...
services.nginx.virtualHosts = {
"matrix.${domain}" = {
${matrixDomain} = {
onlySSL = true;
useACMEHost = domain;
@ -138,6 +182,11 @@ in
"/_matrix" = proxyToClientPort;
"/_synapse/client" = proxyToClientPort;
# Sliding sync
"~ ^/(client/|_matrix/client/unstable/org.matrix.msc3575/sync)" = {
proxyPass = "http://${config.services.matrix-synapse.sliding-sync.settings.SYNCV3_BINDADDR}";
};
};
listen = [
@ -148,9 +197,9 @@ in
};
# same as above, but listening on the federation port
"matrix.${domain}_federation" = {
"${matrixDomain}_federation" = {
onlySSL = true;
serverName = "matrix.${domain}";
serverName = matrixDomain;
useACMEHost = domain;
locations."/".return = "404";
@ -171,7 +220,7 @@ in
locations."= /.well-known/matrix/server".extraConfig =
let
server = { "m.server" = "matrix.${domain}:${toString federationPort.public}"; };
server = { "m.server" = "${matrixDomain}:${toString federationPort.public}"; };
in
''
add_header Content-Type application/json;
@ -181,8 +230,9 @@ in
locations."= /.well-known/matrix/client".extraConfig =
let
client = {
"m.homeserver" = { "base_url" = "https://matrix.${domain}"; };
"m.homeserver" = { "base_url" = "https://${matrixDomain}"; };
"m.identity_server" = { "base_url" = "https://vector.im"; };
"org.matrix.msc3575.proxy" = { "url" = "https://matrix-sync.${domain}"; };
};
# ACAO required to allow element-web on any URL to request this json file
in
@ -207,5 +257,9 @@ in
config.services.matrix-synapse.dataDir
];
};
my.system.persist.directories = [
config.services.matrix-synapse.dataDir
];
};
}

View file

@ -49,5 +49,8 @@ in
inherit (cfg) port;
}
];
# FIXME: backup
# FIXME: persistence
};
}

View file

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

View file

@ -53,5 +53,9 @@ in
inherit (cfg) port;
}
];
my.system.persist.directories = [
"/var/lib/${config.systemd.services.navidrome.serviceConfig.StateDirectory}"
];
};
}

View file

@ -83,5 +83,10 @@ in
"${config.services.nextcloud.home}/data/appdata_*/preview"
];
};
my.system.persist.directories = [
config.services.nextcloud.home
config.services.nextcloud.datadir
];
};
}

View file

@ -470,5 +470,9 @@ in
}
];
};
my.system.persist.directories = [
config.users.user.acme.home
];
};
}

View file

@ -73,6 +73,10 @@ in
# OCR settings
PAPERLESS_OCR_LANGUAGE = "fra+eng";
# Workers
PAPERLESS_TASK_WORKERS = 3;
PAPERLESS_THREADS_PER_WORKER = 4;
# Misc
PAPERLESS_TIME_ZONE = config.time.timeZone;
PAPERLESS_ADMIN_USER = cfg.username;
@ -160,5 +164,10 @@ in
config.services.paperless.mediaDir
];
};
my.system.persist.directories = [
config.services.paperless-ng.dataDir
config.services.paperless-ng.mediaDir
];
};
}

View file

@ -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: {
@ -29,7 +34,7 @@ let
];
};
mkFail2Ban = service: {
mkFail2Ban = service: lib.mkIf cfg.${service}.enable {
services.fail2ban.jails = {
${service} = ''
enabled = true
@ -47,14 +52,30 @@ let
};
};
mkFullConfig = service: lib.mkMerge [
mkFullConfig = service: lib.mkIf cfg.${service}.enable (lib.mkMerge [
(mkService service)
(mkRedirection service)
];
]);
in
{
options.my.services.pirate = {
enable = lib.mkEnableOption "Media automation";
bazarr = {
enable = lib.my.mkDisableOption "Bazarr";
};
lidarr = {
enable = lib.my.mkDisableOption "Lidarr";
};
radarr = {
enable = lib.my.mkDisableOption "Radarr";
};
sonarr = {
enable = lib.my.mkDisableOption "Sonarr";
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [

View file

@ -37,5 +37,10 @@ in
inherit (cfg) port;
}
];
my.system.persist.directories =
builtins.map
(d: "/var/lib/${d}")
config.systemd.services.podgrab.serviceConfig.StateDirectory;
};
}

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 {
containers.temp-pg.config.services.postgresql = {

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

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

View file

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

View file

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

View file

@ -75,5 +75,8 @@ in
inherit (cfg) port;
}
];
# FIXME: backup
# FIXME: persistence
};
}

View file

@ -3,7 +3,7 @@
# Inspired by [1]
#
# [1]: https://github.com/delroth/infra.delroth.net/blob/master/roles/seedbox.nix
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.my.services.transmission;
in
@ -45,6 +45,7 @@ in
config = lib.mkIf cfg.enable {
services.transmission = {
enable = true;
package = pkgs.transmission_4;
group = "media";
downloadDirPermissions = "775";
@ -90,5 +91,9 @@ in
allowedTCPPorts = [ cfg.peerPort ];
allowedUDPPorts = [ cfg.peerPort ];
};
my.system.persist.directories = [
config.services.transmission.home
];
};
}

View file

@ -119,5 +119,7 @@ in
config.services.vikunja.settings.files.basepath
];
};
# FIXME: persistence
};
}

View file

@ -27,9 +27,6 @@ in
# Make sure it is activated in that case
my.system.docker.enable = true;
# FIXME: figure out the issue
services.unbound.resolveLocalQueries = false;
# Adjust runner service for nix usage
systemd.services.woodpecker-agent-docker = {
after = [ "docker.socket" ]; # Needs the socket to be available

View file

@ -9,6 +9,7 @@
./language
./nix
./packages
./persist
./podman
./users
];

View 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
;
};
};
}

View file

@ -17,11 +17,11 @@ in
users = {
root = {
passwordFile = secrets."users/root/hashed-password".path;
hashedPasswordFile = secrets."users/root/hashed-password".path;
};
${config.my.user.name} = {
passwordFile = secrets."users/ambroisie/hashed-password".path;
hashedPasswordFile = secrets."users/ambroisie/hashed-password".path;
description = "Bruno BELANYI";
isNormalUser = true;
shell = pkgs.zsh;

View file

@ -30,4 +30,4 @@ if [ -z "$PROGRAM" ]; then
exit 1
fi
nix shell "${COMMA_PKGS_FLAKE:-nixpkgs}#$PROGRAM" -c "$@"
nix shell "${COMMA_NIXPKGS_FLAKE:-nixpkgs}#$PROGRAM" -c "$@"

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
usage() {
printf '%s\n' "Usage: bw-pass [directory name] <account name>" >&2
printf '%s\n' "Usage: rbw-pass [directory name] <account name>" >&2
}
error_out() {

View file

@ -1,10 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
if ! has nix_direnv_version || ! nix_direnv_version 2.4.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.4.0/direnvrc" "sha256-XQzUAvL6pysIJnRJyR7uVpmUSZfc7LSgWQwq/4mBr1U="
fi
use flake
watch_file ./flake/checks.nix
watch_file ./flake/dev-shells.nix
eval "$shellHooks"

View file

@ -1,10 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
if ! has nix_direnv_version || ! nix_direnv_version 2.4.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.4.0/direnvrc" "sha256-XQzUAvL6pysIJnRJyR7uVpmUSZfc7LSgWQwq/4mBr1U="
fi
use flake
watch_file ./flake/checks.nix
watch_file ./flake/dev-shells.nix
eval "$shellHooks"