aboutsummaryrefslogtreecommitdiff
path: root/modules/scripts/zquota/default.nix
diff options
context:
space:
mode:
authortdback <tyler@tdback.net>2025-01-26 11:33:25 -0500
committertdback <tyler@tdback.net>2025-01-26 11:33:25 -0500
commitd4e6b5e506dd1e02c420807c3c3d5c975fce608f (patch)
treeb8791d5da9861bbcc4a52fbe3fe30abf5b61ad88 /modules/scripts/zquota/default.nix
parent3f33751dcb0cafb273eb868f230b1ae348437f89 (diff)
scripts: formatted scripts as modules
Diffstat (limited to 'modules/scripts/zquota/default.nix')
-rw-r--r--modules/scripts/zquota/default.nix42
1 files changed, 20 insertions, 22 deletions
diff --git a/modules/scripts/zquota/default.nix b/modules/scripts/zquota/default.nix
index bd35546..a4262eb 100644
--- a/modules/scripts/zquota/default.nix
+++ b/modules/scripts/zquota/default.nix
@@ -6,7 +6,8 @@
}:
with lib;
let
- cfg = config.services.zquota;
+ script = "zquota";
+ cfg = config.modules.scripts.${script};
zquota =
let
@@ -14,7 +15,7 @@ let
zfs = getExe pkgs.zfs;
hostname = config.networking.hostName;
in
- pkgs.writeShellScriptBin "zquota" ''
+ pkgs.writeShellScriptBin script ''
set -e
if [ "$#" -ne 2 ]; then
@@ -46,31 +47,28 @@ let
'';
in
{
- options = {
- services.zquota = {
- enable = mkEnableOption "zquota";
- quotas = mkOption {
- default = { };
- type = types.attrsOf types.int;
- description = "Attribute set of ZFS dataset and disk quota (in GB).";
- };
- dates = mkOption {
- default = "daily";
- type = types.str;
- description = ''
- How often quota checks are performed.
+ options.modules.scripts.${script} = {
+ enable = mkEnableOption script;
+ quotas = mkOption {
+ default = { };
+ type = types.attrsOf types.int;
+ description = "Attribute set of ZFS dataset and disk quota (in GB).";
+ };
+ dates = mkOption {
+ default = "daily";
+ type = types.str;
+ description = ''
+ How often quota checks are performed.
- This value must be a calendar event specified by
- {manpage}`systemd.time(7)`.
- '';
- };
+ This value must be a calendar event specified by
+ {manpage}`systemd.time(7)`.
+ '';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ zquota ];
-
- systemd.services."zquota" = {
+ systemd.services.${script} = {
description = "Perform and report scheduled quota checks on ZFS datasets.";
serviceConfig.Type = "oneshot";
script = strings.concatStringsSep "\n" (
@@ -79,7 +77,7 @@ in
) cfg.quotas
);
};
- systemd.timers."zquota" = {
+ systemd.timers.${script} = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = cfg.dates;