marleyos/Justfile
2025-06-03 19:44:24 -07:00

95 lines
2.1 KiB
Makefile

default:
@just --list
defhost := `hostname`
defuser := env_var('USER')
date := `date '+%F %R'`
branch := `git branch 2>/dev/null | sed -n '/^\* / { s|^\* ||; p; }'`
revision := shell('expr substr "$(git rev-parse HEAD)" 1 7')
export NIXOS_LABEL_VERSION := date + " on " + branch + "@" + revision
test:
echo $NIXOS_LABEL_VERSION
alias dh := deployhome
[group('home')]
deployhome user=defuser host=defhost:
nh home switch -c {{user}}@{{host}} -b bak .
[group('home')]
refreshhome user=defuser host=defhost:
nh home switch -c {{user}}@{{host}} -b bak . -- --refresh
alias do := deployos
[group('nixos')]
deployos host=defhost:
nh os switch -H {{host}} .
alias dro := deployRemoteOs
[group('nixos')]
deployRemoteOs host:
nixos-rebuild switch --flake .#{{host}} \
--target-host root@{{host}} \
--verbose --log-format internal-json |& nom --json
[group('nixos')]
deployAll:
#!/usr/bin/env fish
set -l systems (nix flake show --all-systems --json \
| jq '.nixosConfigurations | keys[]' \
# Remove literal quotes from values so that contains works.
| string trim --chars \"\'\")
# Remove the current system.
set -l currentSysI (contains --index (hostname) $systems)
if set -q currentSysI[1]
set -e systems[$currentSysI]
end
just deployos
for system in $systems
just deployRemoteOs $system
end
alias dd := deploydarwin
[group('darwin')]
deploydarwin host=defhost:
darwin-rebuild switch --flake .#{{host}}
alias up := update
[group('update')]
update:
nix flake update
[group('update')]
updatejust this:
nix flake update {{this}}
alias gc := collectgarbage
[group('maintainence')]
collectgarbage:
nh clean all
[group('maintainence')]
genFirefoxAddons:
nix run git+https://git.sr.ht/~rycee/mozilla-addons-to-nix/ -- \
overlays/firefox-addons/addons.json \
overlays/firefox-addons/addons.nix
[group('maintainence')]
secret name:
cd secrets && agenix --edit {{name}}.age --identity ~/.ssh/marley@nyx && cd -
[group('maintainence')]
check:
nix flake check
[group('maintainence')]
checkall:
nix flake check --all-systems
alias s := search
search this:
nh search {{this}}