feat: improve justfiles
This commit is contained in:
parent
8da8f78ea4
commit
ccef5caba0
3 changed files with 58 additions and 51 deletions
|
|
@ -1,11 +1,14 @@
|
||||||
@_default: list
|
set unstable := true
|
||||||
|
set quiet := true
|
||||||
|
|
||||||
|
_default: list
|
||||||
|
|
||||||
[doc('List machines')]
|
[doc('List machines')]
|
||||||
@list:
|
list:
|
||||||
ls -1 ../systems/x86_64-linux/
|
ls -1 ../systems/x86_64-linux/
|
||||||
|
|
||||||
[no-exit-message]
|
|
||||||
[doc('Update the target machine')]
|
[doc('Update the target machine')]
|
||||||
@update machine:
|
[no-exit-message]
|
||||||
|
update machine:
|
||||||
just assert '-d "../systems/x86_64-linux/{{ machine }}"' "Machine {{ machine }} does not exist, must be one of: $(ls ../systems/x86_64-linux/ | tr '\n' ' ')"
|
just assert '-d "../systems/x86_64-linux/{{ machine }}"' "Machine {{ machine }} does not exist, must be one of: $(ls ../systems/x86_64-linux/ | tr '\n' ' ')"
|
||||||
nixos-rebuild switch --use-remote-sudo --target-host {{ machine }} --flake ..#{{ machine }}
|
nixos-rebuild switch --use-remote-sudo --target-host {{ machine }} --flake ..#{{ machine }}
|
||||||
|
|
@ -1,36 +1,33 @@
|
||||||
set unstable
|
set unstable := true
|
||||||
|
set quiet := true
|
||||||
|
|
||||||
base_path := invocation_directory() / "systems/x86_64-linux"
|
base_path := invocation_directory() / "systems/x86_64-linux"
|
||||||
# sops := "nix shell nixpkgs#sops --command sops"
|
|
||||||
# yq := "nix shell nixpkgs#yq --command yq"
|
|
||||||
sops := "sops"
|
|
||||||
yq := "yq"
|
|
||||||
|
|
||||||
@_default:
|
_default:
|
||||||
just --list
|
just --list
|
||||||
|
|
||||||
[doc('list all vars of the target machine')]
|
[doc('list all vars of the target machine')]
|
||||||
list machine:
|
list machine:
|
||||||
sops decrypt {{ base_path }}/{{ machine }}/secrets.yml
|
sops decrypt {{ base_path }}/{{ machine }}/secrets.yml
|
||||||
|
|
||||||
@edit machine:
|
edit machine:
|
||||||
sops edit {{ base_path }}/{{ machine }}/secrets.yml
|
sops edit {{ base_path }}/{{ machine }}/secrets.yml
|
||||||
|
|
||||||
@set machine key value:
|
@set machine key value:
|
||||||
sops set {{ base_path }}/{{ machine }}/secrets.yml "$(printf '%s\n' '["{{ key }}"]' | sed -E 's#/#"]["#g; s/\["([0-9]+)"\]/[\1]/g')" "\"$(echo '{{ value }}' | sed 's/\"/\\\"/g')\""
|
sops set {{ base_path }}/{{ machine }}/secrets.yml "$(printf '%s\n' '["{{ key }}"]' | sed -E 's#/#"]["#g; s/\["([0-9]+)"\]/[\1]/g')" "\"$(echo '{{ value }}' | sed 's/\"/\\\"/g')\""
|
||||||
|
|
||||||
git add {{ base_path }}/{{ machine }}/secrets.yml
|
git add {{ base_path }}/{{ machine }}/secrets.yml
|
||||||
git commit -m 'chore(secrets): set secret "{{ key }}" for machine "{{ machine}}"' -- {{ base_path }}/{{ machine }}/secrets.yml > /dev/null
|
git commit -m 'chore(secrets): set secret "{{ key }}" for machine "{{ machine }}"' -- {{ base_path }}/{{ machine }}/secrets.yml > /dev/null
|
||||||
|
|
||||||
echo "Done"
|
echo "Done"
|
||||||
|
|
||||||
@get machine key:
|
get machine key:
|
||||||
sops decrypt {{ base_path }}/{{ machine }}/secrets.yml | yq ".$(echo "{{ key }}" | sed -E 's/\//./g')"
|
sops decrypt {{ base_path }}/{{ machine }}/secrets.yml | yq ".$(echo "{{ key }}" | sed -E 's/\//./g')"
|
||||||
|
|
||||||
@remove machine key:
|
remove machine key:
|
||||||
sops unset {{ base_path }}/{{ machine }}/secrets.yml "$(printf '%s\n' '["{{ key }}"]' | sed -E 's#/#"]["#g; s/\["([0-9]+)"\]/[\1]/g')"
|
sops unset {{ base_path }}/{{ machine }}/secrets.yml "$(printf '%s\n' '["{{ key }}"]' | sed -E 's#/#"]["#g; s/\["([0-9]+)"\]/[\1]/g')"
|
||||||
|
|
||||||
git add {{ base_path }}/{{ machine }}/secrets.yml
|
git add {{ base_path }}/{{ machine }}/secrets.yml
|
||||||
git commit -m 'chore(secrets): removed secret "{{ key }}" from machine "{{ machine}}"' -- {{ base_path }}/{{ machine }}/secrets.yml > /dev/null
|
git commit -m 'chore(secrets): removed secret "{{ key }}" from machine "{{ machine }}"' -- {{ base_path }}/{{ machine }}/secrets.yml > /dev/null
|
||||||
|
|
||||||
echo "Done"
|
echo "Done"
|
||||||
31
.justfile
31
.justfile
|
|
@ -1,33 +1,40 @@
|
||||||
@_default:
|
_default:
|
||||||
just --list --list-submodules
|
just --list --list-submodules
|
||||||
|
|
||||||
[doc('Manage vars')]
|
set unstable
|
||||||
mod vars '.just/vars.just'
|
set quiet
|
||||||
|
|
||||||
[doc('Manage machines')]
|
mod vars '.just/vars.just'
|
||||||
mod machine '.just/machine.just'
|
mod machine '.just/machine.just'
|
||||||
|
|
||||||
[doc('Show information about project')]
|
[doc('Show information about project')]
|
||||||
@show:
|
show:
|
||||||
echo "show"
|
echo "show"
|
||||||
|
|
||||||
[doc('update the flake dependencies')]
|
[doc('update the flake dependencies')]
|
||||||
@update:
|
update:
|
||||||
nix flake update
|
nix flake update
|
||||||
git commit -m 'chore: update dependencies' -- ./flake.lock > /dev/null
|
git commit -m 'chore: update dependencies' -- ./flake.lock > /dev/null
|
||||||
echo "Done"
|
echo "Done"
|
||||||
|
|
||||||
|
[doc('Rebase branch on main')]
|
||||||
|
rebase:
|
||||||
|
git stash -q \
|
||||||
|
&& git fetch \
|
||||||
|
&& git rebase origin/main \
|
||||||
|
&& git stash pop -q
|
||||||
|
|
||||||
|
echo "Done"
|
||||||
|
|
||||||
[doc('Introspection on flake output')]
|
[doc('Introspection on flake output')]
|
||||||
@select key:
|
select key:
|
||||||
nix eval --json .#{{ key }} | jq .
|
nix eval --json .#{{ key }} | jq .
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================================
|
#===============================================================================================
|
||||||
# Utils
|
# Utils
|
||||||
#===============================================================================================
|
# ===============================================================================================
|
||||||
[no-exit-message]
|
|
||||||
[no-cd]
|
[no-cd]
|
||||||
|
[no-exit-message]
|
||||||
[private]
|
[private]
|
||||||
@assert condition message:
|
assert condition message:
|
||||||
[ {{ condition }} ] || { echo -e 1>&2 "\n\x1b[1;41m Error \x1b[0m {{ message }}\n"; exit 1; }
|
[ {{ condition }} ] || { echo -e 1>&2 "\n\x1b[1;41m Error \x1b[0m {{ message }}\n"; exit 1; }
|
||||||
Loading…
Add table
Add a link
Reference in a new issue