aboutsummaryrefslogtreecommitdiff
path: root/modules/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'modules/scripts')
-rw-r--r--modules/scripts/motd/default.nix19
-rw-r--r--modules/scripts/pushover/default.nix10
-rw-r--r--modules/scripts/zquota/default.nix32
3 files changed, 41 insertions, 20 deletions
diff --git a/modules/scripts/motd/default.nix b/modules/scripts/motd/default.nix
index c4b0c6b..6d95119 100644
--- a/modules/scripts/motd/default.nix
+++ b/modules/scripts/motd/default.nix
@@ -1,4 +1,9 @@
-{ config, lib, pkgs, ... }:
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
with lib;
let
cfg = config.programs.motd;
@@ -35,9 +40,12 @@ let
printf "\n"
printf "''${BOLD}Good $TIME $(whoami), welcome to $(hostname)!$ENDCOLOR\n"
printf "\n"
- ${strings.concatStrings (lists.forEach cfg.networkInterfaces (
- int: "printf \"$BOLD * %-20s$ENDCOLOR %s\\n\" \"IPv4 ${int}\" \"$(ip -4 addr show ${int} | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}')\"\n"
- ))}
+ ${strings.concatStrings (
+ lists.forEach cfg.networkInterfaces (
+ int:
+ "printf \"$BOLD * %-20s$ENDCOLOR %s\\n\" \"IPv4 ${int}\" \"$(ip -4 addr show ${int} | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}')\"\n"
+ )
+ )}
printf "$BOLD * %-20s$ENDCOLOR %s\n" "Release" "$(awk -F= '/PRETTY_NAME/ { print $2 }' /etc/os-release | tr -d '"')"
printf "$BOLD * %-20s$ENDCOLOR %s\n" "Kernel" "$(uname -rs)"
printf "\n"
@@ -68,7 +76,8 @@ let
done <<< "$SERVICES"
printf "\n"
'';
-in {
+in
+{
options = {
programs.motd = {
enable = mkEnableOption "motd";
diff --git a/modules/scripts/pushover/default.nix b/modules/scripts/pushover/default.nix
index a5644e4..979e96b 100644
--- a/modules/scripts/pushover/default.nix
+++ b/modules/scripts/pushover/default.nix
@@ -1,4 +1,9 @@
-{ inputs, config, pkgs, ... }:
+{
+ inputs,
+ config,
+ pkgs,
+ ...
+}:
let
pushover = pkgs.writeShellScriptBin "pushover" ''
set -e
@@ -35,7 +40,8 @@ let
--form-string "message=$MESSAGE" \
https://api.pushover.net/1/messages.json
'';
-in {
+in
+{
age.secrets = {
pushoverAppToken.file = "${inputs.self}/secrets/pushoverAppToken.age";
pushoverUserToken.file = "${inputs.self}/secrets/pushoverUserToken.age";
diff --git a/modules/scripts/zquota/default.nix b/modules/scripts/zquota/default.nix
index 5741e0e..bd35546 100644
--- a/modules/scripts/zquota/default.nix
+++ b/modules/scripts/zquota/default.nix
@@ -1,13 +1,19 @@
-{ config, lib, pkgs, ... }:
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
with lib;
let
cfg = config.services.zquota;
- zquota = let
- bc = getExe pkgs.bc;
- zfs = getExe pkgs.zfs;
- hostname = config.networking.hostName;
- in
+ zquota =
+ let
+ bc = getExe pkgs.bc;
+ zfs = getExe pkgs.zfs;
+ hostname = config.networking.hostName;
+ in
pkgs.writeShellScriptBin "zquota" ''
set -e
@@ -38,7 +44,8 @@ let
"dataset $DATASET on ${hostname} has exceeded quota by ''${DIFF}GB"
fi
'';
-in {
+in
+{
options = {
services.zquota = {
enable = mkEnableOption "zquota";
@@ -66,12 +73,11 @@ in {
systemd.services."zquota" = {
description = "Perform and report scheduled quota checks on ZFS datasets.";
serviceConfig.Type = "oneshot";
- script =
- strings.concatStringsSep "\n" (
- mapAttrsToList (dataset: quota:
- "/run/current-system/sw/bin/zquota ${dataset} ${builtins.toString quota}"
- ) cfg.quotas
- );
+ script = strings.concatStringsSep "\n" (
+ mapAttrsToList (
+ dataset: quota: "/run/current-system/sw/bin/zquota ${dataset} ${builtins.toString quota}"
+ ) cfg.quotas
+ );
};
systemd.timers."zquota" = {
wantedBy = [ "timers.target" ];