From 96140dfd065efc0d3a6e99a066592cd6f8f59047 Mon Sep 17 00:00:00 2001 From: Lord-Valen Date: Thu, 5 Jan 2023 21:57:57 -0500 Subject: [PATCH] :recycle: `env` Add flake update commands --- shell/default.nix | 42 ++++++++++++++++++++++++++++++++++-------- shell/pre-commit.sh | 3 --- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/shell/default.nix b/shell/default.nix index aaa0841..4d68318 100644 --- a/shell/default.nix +++ b/shell/default.nix @@ -39,8 +39,8 @@ help = "Checks ${name} ${type}"; command = '' set -e - # set -x + flake="$PRJ_ROOT/${type}/${name}" tempdigga=path:$PRJ_ROOT trap_err() { @@ -57,8 +57,33 @@ cd $PRJ_ROOT/${type}/${name} - ${nixBin} flake show "$@" --override-input digga $tempdigga - ${nixBin} flake check "$@" --override-input digga $tempdigga + ${nixBin} flake show $flake "$@" --override-input digga $tempdigga + ${nixBin} flake check $flake "$@" --override-input digga $tempdigga + ''; + }; + + update = type: name: + withCategory "updates" { + name = "update-${name}"; + help = "Updates ${name} ${type}"; + command = '' + set -e + + flake="$PRJ_ROOT/${type}/${name}" + + trap_err() { + local ret=$? + echo -e \ + "\033[1m\033[31m""exit $ret: \033[0m\033[1m""command [$BASH_COMMAND] failed""\033[0m" + } + + is () { [ "$1" -eq "0" ]; } + + trap 'trap_err' ERR + + # -------------------------------------------------------------------------------- + + ${nixBin} flake update $flake "$@" ''; }; in @@ -87,11 +112,6 @@ in ]; commands = [ - (utils { - command = "git rm --ignore-unmatch -f $PRJ_ROOT/{tests,examples}/*/flake.lock"; - help = "Remove all lock files"; - name = "rm-locks"; - }) (utils { name = "fmt"; help = "Check formatting"; @@ -107,6 +127,12 @@ in (test "examples" "groupByConfig") (test "examples" "hmOnly") (test "examples" "all" // {command = "check-devos && check-groupByConfig && check-hmOnly";}) + + (update "examples" "devos") + (update "examples" "groupByConfig") + (update "examples" "hmOnly") + (update "examples" "all" // {command = "update-devos && update-groupByConfig && update-hmOnly";}) + (docs {package = pkgs.mdbook;}) (docs makeDocs) ]; diff --git a/shell/pre-commit.sh b/shell/pre-commit.sh index b57e426..210590c 100755 --- a/shell/pre-commit.sh +++ b/shell/pre-commit.sh @@ -11,9 +11,6 @@ diff="git diff-index --name-only --cached $against --diff-filter d" all_files=($($diff)) -# Remove example lock files. -rm-locks - # Format staged files. if ((${#all_files[@]} != 0)); then fmt "${all_files[@]}" &&