diff options
author | tdback <tyler@tdback.net> | 2025-01-26 11:33:25 -0500 |
---|---|---|
committer | tdback <tyler@tdback.net> | 2025-01-26 11:33:25 -0500 |
commit | d4e6b5e506dd1e02c420807c3c3d5c975fce608f (patch) | |
tree | b8791d5da9861bbcc4a52fbe3fe30abf5b61ad88 | |
parent | 3f33751dcb0cafb273eb868f230b1ae348437f89 (diff) |
scripts: formatted scripts as modules
-rw-r--r-- | modules/scripts/motd/default.nix | 29 | ||||
-rw-r--r-- | modules/scripts/zquota/default.nix | 42 |
2 files changed, 34 insertions, 37 deletions
diff --git a/modules/scripts/motd/default.nix b/modules/scripts/motd/default.nix index 6d95119..5185797 100644 --- a/modules/scripts/motd/default.nix +++ b/modules/scripts/motd/default.nix @@ -6,9 +6,10 @@ }: with lib; let - cfg = config.programs.motd; + script = "motd"; + cfg = config.modules.scripts.${script}; - motd = pkgs.writeShellScriptBin "motd" '' + motd = pkgs.writeShellScriptBin script '' RED="\e[31m" GREEN="\e[32m" YELLOW="\e[33m" @@ -78,19 +79,17 @@ let ''; in { - options = { - programs.motd = { - enable = mkEnableOption "motd"; - networkInterfaces = mkOption { - default = [ ]; - type = types.listOf types.str; - description = "Network interfaces to monitor."; - }; - servicesToCheck = mkOption { - default = [ ]; - type = types.listOf types.str; - description = "Services to validate alongside podman containers."; - }; + options.modules.scripts.${script} = { + enable = mkEnableOption script; + networkInterfaces = mkOption { + default = [ ]; + type = types.listOf types.str; + description = "Network interfaces to monitor."; + }; + servicesToCheck = mkOption { + default = [ ]; + type = types.listOf types.str; + description = "Services to validate alongside podman containers."; }; }; 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; |