Compare commits
3 Commits
cc181d1332
...
8e829637ac
| Author | SHA1 | Date | |
|---|---|---|---|
|
8e829637ac
|
|||
|
5597fd9c3b
|
|||
|
71d0c3e7e6
|
11
flake.nix
11
flake.nix
@@ -138,16 +138,18 @@
|
|||||||
serviceMountDeps = serviceName: dirs: pkgs: {
|
serviceMountDeps = serviceName: dirs: pkgs: {
|
||||||
systemd.services."${serviceName}_mounts" =
|
systemd.services."${serviceName}_mounts" =
|
||||||
let
|
let
|
||||||
|
lib = nixpkgs.lib;
|
||||||
zfslistmounted = pkgs.writeShellApplication {
|
zfslistmounted = pkgs.writeShellApplication {
|
||||||
name = "zfslistmounted";
|
name = "zfslistmounted";
|
||||||
runtimeInputs = with pkgs; [
|
runtimeInputs = with pkgs; [
|
||||||
zfs
|
zfs
|
||||||
gnugrep
|
gnugrep
|
||||||
gawk
|
gawk
|
||||||
|
coreutils
|
||||||
];
|
];
|
||||||
text = ''
|
text = ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
zfs get mounted | grep yes | awk '{print $1}' | while read -r i; do zfs get mountpoint "$i" | awk 'FNR==2 {print $3}'; done
|
zfs list -o mountpoint,mounted | awk 'FNR > 1 && $2 == "yes" {print $1}' | grep -c '${lib.strings.concatStringsSep "\|" dirs}' | grep -Fq ${toString (lib.length dirs)}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@@ -156,12 +158,7 @@
|
|||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
ExecStart =
|
ExecStart = nixpkgs.lib.getExe zfslistmounted;
|
||||||
let
|
|
||||||
lib = nixpkgs.lib;
|
|
||||||
contains_cmd = "${lib.getExe pkgs.gnugrep} '${lib.strings.concatStringsSep "\|" dirs}' | ${pkgs.coreutils}/bin/wc -l | ${lib.getExe pkgs.gnugrep} -q ${toString (lib.length dirs)}";
|
|
||||||
in
|
|
||||||
"${lib.getExe pkgs.bash} -c \"${lib.getExe zfslistmounted} | ${contains_cmd}\"";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,17 @@
|
|||||||
service_configs,
|
service_configs,
|
||||||
username,
|
username,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
serviceMountDeps,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(serviceMountDeps "caddy" [
|
||||||
|
"/var/lib/caddy"
|
||||||
|
service_configs.https.data_dir
|
||||||
|
] pkgs)
|
||||||
|
];
|
||||||
|
|
||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
email = "titaniumtown@proton.me";
|
email = "titaniumtown@proton.me";
|
||||||
@@ -23,6 +31,7 @@
|
|||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d ${service_configs.https.data_dir} 750 ${config.services.caddy.user} ${config.services.caddy.group}"
|
"d ${service_configs.https.data_dir} 750 ${config.services.caddy.user} ${config.services.caddy.group}"
|
||||||
|
"d /var/lib/caddy 750 ${config.services.caddy.user} ${config.services.caddy.group}"
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.packages = with pkgs; [ nssTools ];
|
systemd.packages = with pkgs; [ nssTools ];
|
||||||
|
|||||||
Reference in New Issue
Block a user