feat: scripts

This commit is contained in:
2026-06-17 20:58:50 -04:00
parent a1c5259b01
commit bee5c77ee6
3 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
echo "plan-disk-burns: placeholder"
echo "runtime tools available: smartctl, lsblk"

View File

@@ -0,0 +1,40 @@
{ lib
, pkgs
, config
, namespace
, ...
}:
let
inherit (lib) mkIf mkEnableOption mapAttrs' mapAttrsToList nameValuePair filterAttrs;
cfg = config.${namespace}.programs.terminal.scripts;
# Script Registry - Each entry declares its runtime dependencies. The script
# source lives in ./bin/<name>.sh and is exposed on PATH as <name> when enabled.
# Add a script by dropping ./bin/<name>.sh and a one-line entry here, e.g.:
# scriptDefs = {
# plan-disk-burns = { runtimeInputs = with pkgs; [ smartmontools util-linux ]; };
# my-new-thing = { runtimeInputs = with pkgs; [ jq curl ]; };
# };
scriptDefs = {
plan-disk-burns = { runtimeInputs = with pkgs; [ smartmontools util-linux ]; };
};
mkScript = name: def:
pkgs.writeShellApplication {
inherit name;
runtimeInputs = def.runtimeInputs or [ ];
text = builtins.readFile (./bin + "/${name}.sh");
};
in
{
options.${namespace}.programs.terminal.scripts =
mapAttrs'
(name: _: nameValuePair name { enable = mkEnableOption name; })
scriptDefs;
config = {
home.packages =
mapAttrsToList (name: def: mkScript name def)
(filterAttrs (name: _: cfg.${name}.enable) scriptDefs);
};
}