style: reformat with nixfmt-rfc-style
This commit is contained in:
parent
5ad8bc1d56
commit
1c5d83d81e
99 changed files with 2247 additions and 1334 deletions
|
@ -1,9 +1,15 @@
|
|||
{ pkgs, lib, inputs, ... }:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
flakes = lib.filterAttrs (name: value: value ? outputs) inputs;
|
||||
nixRegistry = builtins.mapAttrs (name: v: { flake = v; }) flakes;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Let 'nixos-version --json' know about the Git revision
|
||||
# of this flake.
|
||||
system.configurationRevision = lib.mkIf (inputs.self ? rev) inputs.self.rev;
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types mkIf;
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkOption
|
||||
types
|
||||
mkIf
|
||||
;
|
||||
cfg = config.services.inadyn;
|
||||
|
||||
mkConfig = ipCfg: domain: ''
|
||||
|
@ -17,7 +27,8 @@ let
|
|||
${cfg.extraConfig}
|
||||
${ipCfg.extraConfig}
|
||||
'';
|
||||
in {
|
||||
in
|
||||
{
|
||||
# NixOS 24.05 introduced an official module, but it works somewhat differently.
|
||||
# For now I'll continue using my own module.
|
||||
disabledModules = [ "services/networking/inadyn.nix" ];
|
||||
|
@ -132,8 +143,9 @@ in {
|
|||
startAt = "*:0/5";
|
||||
serviceConfig = rec {
|
||||
Type = "simple";
|
||||
LoadCredential = lib.optionalString (cfg.passwordFile != null)
|
||||
"INADYN_PASSWORD:${cfg.passwordFile}";
|
||||
LoadCredential = lib.optionalString (
|
||||
cfg.passwordFile != null
|
||||
) "INADYN_PASSWORD:${cfg.passwordFile}";
|
||||
ExecStart = pkgs.writeScript "run-inadyn.sh" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
export PATH=$PATH:${pkgs.bash}/bin/bash # idk if that helps
|
||||
|
@ -148,18 +160,23 @@ in {
|
|||
${lib.optionalString cfg.ipv6.enable ''
|
||||
allow-ipv6 = true
|
||||
''}
|
||||
${lib.concatImapStrings (i: domain:
|
||||
(lib.optionalString cfg.ipv4.enable ''
|
||||
# ipv4
|
||||
provider ${cfg.provider}:${toString (i * 2)} {
|
||||
${mkConfig cfg.ipv4 domain}
|
||||
}
|
||||
'' + lib.optionalString cfg.ipv6.enable ''
|
||||
# ipv6
|
||||
provider ${cfg.provider}:${toString (i * 2 + 1)} {
|
||||
${mkConfig cfg.ipv6 domain}
|
||||
}
|
||||
'')) cfg.domains}
|
||||
${lib.concatImapStrings (
|
||||
i: domain:
|
||||
(
|
||||
lib.optionalString cfg.ipv4.enable ''
|
||||
# ipv4
|
||||
provider ${cfg.provider}:${toString (i * 2)} {
|
||||
${mkConfig cfg.ipv4 domain}
|
||||
}
|
||||
''
|
||||
+ lib.optionalString cfg.ipv6.enable ''
|
||||
# ipv6
|
||||
provider ${cfg.provider}:${toString (i * 2 + 1)} {
|
||||
${mkConfig cfg.ipv6 domain}
|
||||
}
|
||||
''
|
||||
)
|
||||
) cfg.domains}
|
||||
EOF
|
||||
exec ${cfg.package}/bin/inadyn -n ${cfg.cacheDir} -f /run/${RuntimeDirectory}/inadyn.cfg
|
||||
'';
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
systemd.services = mapAttrs' (name: backup:
|
||||
systemd.services = mapAttrs' (
|
||||
name: backup:
|
||||
nameValuePair "restic-backups-${name}" {
|
||||
serviceConfig = {
|
||||
CPUWeight = 25;
|
||||
|
@ -14,6 +20,7 @@ with lib;
|
|||
IOSchedulingClass = "idle";
|
||||
IOSchedulingPriority = 7;
|
||||
};
|
||||
}) config.services.restic.backups;
|
||||
}
|
||||
) config.services.restic.backups;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
|
@ -21,7 +26,8 @@ let
|
|||
$(systemctl status --full "$1")
|
||||
ERRMAIL
|
||||
'';
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
systemd.notify = {
|
||||
enable = mkOption {
|
||||
|
@ -31,7 +37,10 @@ in {
|
|||
};
|
||||
|
||||
method = mkOption {
|
||||
type = types.enum [ "libnotify" "email" ];
|
||||
type = types.enum [
|
||||
"libnotify"
|
||||
"email"
|
||||
];
|
||||
default = "libnotify";
|
||||
description = "The method for sending notifications.";
|
||||
};
|
||||
|
@ -45,20 +54,19 @@ in {
|
|||
email.mailTo = mkOption {
|
||||
type = types.str;
|
||||
default = null;
|
||||
description =
|
||||
"Email address to which the service status will be mailed.";
|
||||
description = "Email address to which the service status will be mailed.";
|
||||
};
|
||||
|
||||
email.mailFrom = mkOption {
|
||||
type = types.str;
|
||||
default = null;
|
||||
description =
|
||||
"Email address from which the service status will be mailed.";
|
||||
description = "Email address from which the service status will be mailed.";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services = mkOption {
|
||||
type = with types;
|
||||
type =
|
||||
with types;
|
||||
attrsOf (submodule {
|
||||
config.onFailure = optional cfg.enable "notify@%n.service";
|
||||
});
|
||||
|
@ -72,37 +80,39 @@ in {
|
|||
message = "You need to specify a user";
|
||||
}
|
||||
{
|
||||
assertion = cfg.method != "email"
|
||||
|| (cfg.email.mailTo != null && cfg.email.mailFrom != null);
|
||||
assertion = cfg.method != "email" || (cfg.email.mailTo != null && cfg.email.mailFrom != null);
|
||||
message = "You need to specify a sender and a receiver";
|
||||
}
|
||||
];
|
||||
|
||||
systemd.services."notify@" = {
|
||||
onFailure = lib.mkForce [ ];
|
||||
} // optionalAttrs (cfg.method == "libnotify") {
|
||||
description = "Desktop notifications for %i service failure";
|
||||
environment = {
|
||||
DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/${
|
||||
systemd.services."notify@" =
|
||||
{
|
||||
onFailure = lib.mkForce [ ];
|
||||
}
|
||||
// optionalAttrs (cfg.method == "libnotify") {
|
||||
description = "Desktop notifications for %i service failure";
|
||||
environment = {
|
||||
DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/${
|
||||
toString config.users.users.${cfg.libnotify.user}.uid
|
||||
}/bus";
|
||||
INSTANCE = "%i";
|
||||
INSTANCE = "%i";
|
||||
};
|
||||
script = ''
|
||||
${pkgs.libnotify}/bin/notify-send --urgency=critical \
|
||||
"Service '$INSTANCE' failed" \
|
||||
"$(journalctl -n 6 -o cat -u $INSTANCE)"
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = cfg.libnotify.user;
|
||||
};
|
||||
}
|
||||
// optionalAttrs (cfg.method == "email") {
|
||||
description = "E-Mail notifications for %i service failure";
|
||||
serviceConfig = {
|
||||
ExecStart = "${sendmail} %i";
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
script = ''
|
||||
${pkgs.libnotify}/bin/notify-send --urgency=critical \
|
||||
"Service '$INSTANCE' failed" \
|
||||
"$(journalctl -n 6 -o cat -u $INSTANCE)"
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = cfg.libnotify.user;
|
||||
};
|
||||
} // optionalAttrs (cfg.method == "email") {
|
||||
description = "E-Mail notifications for %i service failure";
|
||||
serviceConfig = {
|
||||
ExecStart = "${sendmail} %i";
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue