diff --git a/modules/scripts/datepath.nix b/modules/scripts/datepath.nix new file mode 100644 index 00000000..fa2b4e4d --- /dev/null +++ b/modules/scripts/datepath.nix @@ -0,0 +1,26 @@ +{ withSystem, ... }: + +let + name = "datepath"; +in +{ + perSystem = + { pkgs, ... }: + { + packages.${name} = pkgs.writeShellApplication { + inherit name; + + runtimeInputs = with pkgs; [ coreutils ]; + + text = ''date "+%4Y/%m/%d" "-d ''${*:-now}"''; + }; + }; + + flake.modules.homeManager.base = + { pkgs, ... }: + { + home.packages = [ + (withSystem pkgs.system (psArgs: psArgs.config.packages.${name})) + ]; + }; +} diff --git a/modules/scripts/onchange.nix b/modules/scripts/onchange.nix new file mode 100644 index 00000000..78e36bf4 --- /dev/null +++ b/modules/scripts/onchange.nix @@ -0,0 +1,35 @@ +{ withSystem, ... }: + +let + name = "onchange"; +in +{ + perSystem = + { pkgs, ... }: + with pkgs; + { + packages.${name} = writeShellApplication { + inherit name; + + runtimeInputs = [ + coreutils + entr + ]; + + text = '' + PATTERN="$1" + shift 1 + + find . -path "$PATTERN" -type f | entr -cs "$@" + ''; + }; + }; + + flake.modules.homeManager.base = + { pkgs, ... }: + { + home.packages = [ + (withSystem pkgs.system (psArgs: psArgs.config.packages.${name})) + ]; + }; +} diff --git a/modules/scripts/ptest.nix b/modules/scripts/ptest.nix new file mode 100644 index 00000000..a0cfa6eb --- /dev/null +++ b/modules/scripts/ptest.nix @@ -0,0 +1,42 @@ +{ withSystem, ... }: + +let + name = "ptest"; +in +{ + perSystem = + psArgs@{ pkgs, ... }: + with pkgs; + { + packages.${name} = writeShellApplication { + inherit name; + + runtimeInputs = [ + psArgs.config.packages.onchange + ]; + + text = '' + command="phpunit" + args=("--colors") + + bin="vendor/bin" + + if [[ -x "$bin/pest" ]]; then + command="pest" + args=() + fi + + onchange "**/*.php" \ + "$bin/$command ''${args[*]} $*" + ''; + }; + }; + + flake.modules.homeManager.base = + { pkgs, ... }: + { + home.packages = [ + (withSystem pkgs.system (psArgs: psArgs.config.packages.${name})) + ]; + }; +} diff --git a/packages/create-script.nix b/packages/create-script.nix index 1753e45f..840018fd 100755 --- a/packages/create-script.nix +++ b/packages/create-script.nix @@ -7,9 +7,7 @@ pkgs.writeShellApplication { cat > "$1" << EOF #!/usr/bin/env bash - set -o errexit - set -o nounset - set -o pipefail + set -euo pipefail EOF