1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat: use more tmpfiles.d

This commit is contained in:
2022-04-10 19:38:41 +02:00
parent 4932c7c08a
commit 98cf188a17
3 changed files with 64 additions and 28 deletions

View File

@@ -7,9 +7,8 @@
stateLocation = "/var/lib/codimd/state.sqlite";
nixpkgs-unstable = import <nixpkgs-unstable> {};
domain = "pad.kmein.de";
inherit (import <niveum/lib>) tmpfilesConfig;
in {
imports = [<stockholm/krebs/3modules/permown.nix>];
services.nginx.virtualHosts.${domain} = {
enableACME = true;
forceSSL = true;
@@ -49,11 +48,15 @@ in {
};
};
krebs.permown.${backupLocation} = {
owner = "codimd";
group = "codimd";
umask = "0002";
};
systemd.tmpfiles.rules = [
(tmpfilesConfig {
user = "codimd";
group = "codimd";
mode = "0755";
type = "d";
path = backupLocation;
})
];
systemd.services.hedgedoc-backup = {
description = "Hedgedoc backup service";

View File

@@ -5,6 +5,7 @@
...
}: let
firewall = (import <niveum/lib>).firewall lib;
inherit (import <niveum/lib>) tmpfilesConfig;
streams = import <niveum/lib/streams.nix> {
di-fm-key = lib.strings.fileContents <secrets/di.fm/key>;
@@ -71,22 +72,31 @@ in {
extraStopCommands = firewall.removeRules rules;
};
system.activationScripts.mpd-playlists = let
makePlaylist = name: streams: pkgs.writeText "name.m3u" (lib.concatMapStringsSep "\n" (lib.getAttr "stream") streams);
systemd.tmpfiles.rules = let
tags = lib.lists.unique (lib.concatMap ({tags ? [], ...}: tags) streams);
in ''
rm -rf /var/lib/mpd/playlists
install -d /var/lib/mpd/playlists
ln -sfn "${toString (makePlaylist "all" streams)}" "/var/lib/mpd/playlists/all.m3u"
${lib.concatMapStringsSep "\n" (
tag: let
playlistStreams = lib.filter ({tags ? [], ...}: lib.elem tag tags) streams;
in ''
ln -sfn "${toString (makePlaylist tag playlistStreams)}" "/var/lib/mpd/playlists/${tag}.m3u"
''
)
tags}
'';
tagStreams = tag: map (lib.getAttr "stream") (lib.filter ({tags ? [], ...}: lib.elem tag tags) streams);
makePlaylist = name: urls: pkgs.writeText "${name}.m3u" (lib.concatStringsSep "\n" urls);
in
map (tag:
tmpfilesConfig {
type = "L+";
path = "/var/lib/mpd/playlists/${tag}.m3u";
mode = "0644";
user = "mpd";
group = "mpd";
argument = makePlaylist tag (tagStreams tag);
})
tags
+ [
(tmpfilesConfig {
type = "L+";
mode = "0644";
user = "mpd";
group = "mpd";
path = "/var/lib/mpd/playlist/all.m3u";
argument = makePlaylist "all" streams;
})
];
services.tuna = {
enable = true;