diff --git a/nix/devshell.nix b/nix/devshell.nix index c6bea6b..42b276a 100644 --- a/nix/devshell.nix +++ b/nix/devshell.nix @@ -29,6 +29,10 @@ in package = pkgs.deploy; help = "build and deploy nix configurations"; } + { + package = pkgs.minify; + help = "build and deploy nix configurations"; + } { package = pkgs.agenix-rekey; help = "Edit and rekey repository secrets"; diff --git a/pkgs/default.nix b/pkgs/default.nix index 0640eea..ed32292 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,6 +4,7 @@ zsh-histdb-skim = super.callPackage ./zsh-histdb-skim.nix {}; zsh-histdb = super.callPackage ./zsh-histdb.nix {}; deploy = super.callPackage ./deploy.nix {}; + minify = super.callPackage ./minify {}; neovim-clean = super.neovim-unwrapped.overrideAttrs (_neovimFinal: neovimPrev: { nativeBuildInputs = (neovimPrev.nativeBuildInputs or []) ++ [super.makeWrapper]; postInstall = diff --git a/pkgs/minify/default.nix b/pkgs/minify/default.nix new file mode 100644 index 0000000..6bce50f --- /dev/null +++ b/pkgs/minify/default.nix @@ -0,0 +1,37 @@ +{writeShellApplication}: +writeShellApplication { + name = "minify"; + text = '' + set -euo pipefail + function die { echo "error: $*" >&2; exit 1;} + function print_help() { + echo ' Usage: minify [OPTION]' + } + + OPTIONS=() + POSITIONAL_ARGS=() + while [[ $# -gt 0 ]]; do + case "$1" in + "help"|"--help"|"-h") + show_help + exit 1 + ;; + -*) + OPTIONS+=("$1") + ;; + *) + POSITIONAL_ARGS+=("$1") + ;; + esac + shift + done + + [[ ! ''${#POSITIONAL_ARGS[@]} -lt 1 ]] \ + || die "Missing argument: " + [[ ! ''${#POSITIONAL_ARGS[@]} -gt 2 ]] \ + || die "Too many arguments" + + path=$(realpath "''${POSITIONAL_ARGS[0]}") + nix eval --impure --argstr path "$path" --file ${./minify.nix} "erg" + ''; +} diff --git a/pkgs/minify/minify.nix b/pkgs/minify/minify.nix new file mode 100644 index 0000000..26195c6 --- /dev/null +++ b/pkgs/minify/minify.nix @@ -0,0 +1,5 @@ +{path}: let + flake = builtins.getFlake path; +in { + erg = builtins.mapAttrs (name: value: builtins.mapAttrs (name: value: name) value.inputs) flake.inputs; +}