aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/scripts/motd/default.nix5
-rw-r--r--modules/scripts/pushover/default.nix13
-rw-r--r--modules/scripts/zquota/default.nix19
3 files changed, 15 insertions, 22 deletions
diff --git a/modules/scripts/motd/default.nix b/modules/scripts/motd/default.nix
index 2b60ca3..c4b0c6b 100644
--- a/modules/scripts/motd/default.nix
+++ b/modules/scripts/motd/default.nix
@@ -4,8 +4,6 @@ let
cfg = config.programs.motd;
motd = pkgs.writeShellScriptBin "motd" ''
- #!/usr/bin/env bash
-
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
@@ -70,8 +68,7 @@ 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 cedfb20..a5644e4 100644
--- a/modules/scripts/pushover/default.nix
+++ b/modules/scripts/pushover/default.nix
@@ -1,9 +1,7 @@
{ inputs, config, pkgs, ... }:
let
pushover = pkgs.writeShellScriptBin "pushover" ''
- #!/bin/sh
-
- die() { echo "$0: $*" >&2; exit 111; }
+ set -e
APP=$(cat ${config.age.secrets.pushoverAppToken.path})
USER=$(cat ${config.age.secrets.pushoverUserToken.path})
@@ -14,10 +12,12 @@ let
TITLE="$OPTARG"
;;
:)
- die "missing option argument for -$OPTARG"
+ echo "missing option argument for -$OPTARG" >&2
+ exit 1
;;
*)
- die "invalid option -$OPTARG"
+ echo "invalid option -$OPTARG" >&2
+ exit 1
;;
esac
done
@@ -35,8 +35,7 @@ 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 cc0f08f..7bbe1b1 100644
--- a/modules/scripts/zquota/default.nix
+++ b/modules/scripts/zquota/default.nix
@@ -5,9 +5,7 @@ let
zquota = let hostname = config.networking.hostName; in
pkgs.writeShellScriptBin "zquota" ''
- #!/usr/bin/env bash
-
- set -eu
+ set -e
if [ "$#" -ne 2 ]; then
echo "failed to provide both a dataset and quota" >&2
@@ -19,12 +17,12 @@ let
if [ -n "$(echo "$QUOTA" | tr -d 0-9.)" ]; then
echo "failed to provide a valid quota" >&2
- exit 1
+ exit 1
fi
USED=$(${getExe pkgs.zfs} list -Hpo used "$DATASET" 2>/dev/null) || {
- echo "failed to provide a valid dataset" >&2
- exit 1
+ echo "failed to provide a valid dataset" >&2
+ exit 1
}
USAGE=$(${getExe pkgs.bc} <<< "scale=2; $USED / 1024^3")
@@ -32,11 +30,10 @@ let
DIFF=$(${getExe pkgs.bc} <<< "scale=2; $USAGE - $QUOTA")
(( $(awk '{ print ($1 > $2) }' <<< "$USAGE $QUOTA") )) &&
- /run/current-system/sw/bin/pushover -t "${hostname} quota exceeded" \
- "dataset $DATASET on ${hostname} has exceeded quota by ''${DIFF}GB"
- '';
-in
-{
+ /run/current-system/sw/bin/pushover -t "${hostname} quota exceeded" \
+ "dataset $DATASET on ${hostname} has exceeded quota by ''${DIFF}GB"
+ '';
+in {
options = {
services.zquota = {
enable = mkEnableOption "zquota";