blob: 47b2c49d248bace710feec37fa735929f51e7b5c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
{
git,
jq,
nix,
openssh,
writeShellApplication,
}:
writeShellApplication {
name = "nixfiles";
runtimeInputs = [git jq nix openssh];
text = ''
cmd="$1"
shift
case "$cmd" in
update)
if (( $# )); then
args=()
for input do args+=(--update-input "$input"); done
exec nix flake lock "." "''${args[@]}"
else
exec nix flake update -v "."
fi
;;
rev)
nix flake metadata --json nixfiles |
if (( $# )); then
jq -r --arg input "$1" '.locks.nodes[$input].locked.rev'
else
jq -r '.revision // "dirty"'
fi
;;
repl|eval|build)
args=()
for arg do case $arg in
-w|--wip) args+=(--override-flake config ".")
;;
*) args+=("$arg")
esac done
set -- "''${args[@]}"
;;&
repl)
exec nix repl ~/.nix-defexpr "$@"
;;
eval)
exec nix eval -f ~/.nix-defexpr --json "$@" | jq -r .
;;
build)
exec nix build -f ~/.nix-defexpr --json "$@" | jq -r .
;;
home)
attr="nixosConfigurations.$HOSTNAME.config.hm.home.activationPackage"
export VERBOSE=1
exec nix shell --verbose ".#$attr" "$@" --command home-manager-generation
;;
specialise)
name="$1"
shift
exec sudo /run/current-system/specialisation/"$name"/bin/switch-to-configuration switch
;;
revert)
exec sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
;;
@*)
host="''${cmd#@}"
hostname="$(ssh -q "$host" 'echo "$HOSTNAME"')"
exec nixos-rebuild -v --flake ".#$hostname" --target-host "$host" --use-remote-sudo "$@"
;;
*)
exec nixos-rebuild -v --flake . --use-remote-sudo "$cmd" "$@"
;;
esac
'';
}
|