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
|
{pkgs, ...}: let
yo = pkgs.writeText "yo.rb" ''
require '${./nixos.rb}'
FLAKE_PATH = "/home/collin/nixos"
case ARGV[0]
when "deploy", "dep"
hostname = ARGV[1] or abort "must specify hostname to build"
ssh_host = ARGV[2] or abort "must specify ssh host to target"
store_path = Nix.build_configuration(
flake_path: FLAKE_PATH,
hostname: hostname
)
Nix.switch_to_configuration_remote(store_path: store_path, ssh_host: ssh_host, use_magic_rollback: true)
when "switch", "sw"
store_path = Nix.build_configuration(
flake_path: FLAKE_PATH,
hostname: `hostname`.chomp
)
Nix.switch_to_configuration(
store_path: store_path,
verb: "switch",
sudo_cmd: "run0 --background="
)
when "boot"
store_path = Nix.build_configuration(
flake_path: FLAKE_PATH,
hostname: `hostname`.chomp
)
Nix.switch_to_configuration(
store_path: store_path,
verb: "boot",
sudo_cmd: "run0 --background="
)
when "test"
store_path = Nix.build_configuration(
flake_path: FLAKE_PATH,
hostname: `hostname`.chomp
)
Nix.switch_to_configuration(
store_path: store_path,
verb: "test",
sudo_cmd: "run0 --background="
)
when "build"
hostname = ARGV[1] or `hostname`.chomp
Nix.build_configuration(
flake_path: FLAKE_PATH,
hostname: hostname
)
end
'';
in
pkgs.writeShellScriptBin "yo" ''
exec ${pkgs.ruby}/bin/ruby ${yo} "$@"
''
|