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
74
75
76
77
|
{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,
use_nom: true
)
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,
use_nom: true
)
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,
use_nom: true
)
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,
use_nom: true
)
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,
use_nom: true
)
end
'';
env = pkgs.stdenv.mkDerivation {
name = "ruby-env";
src = ./.;
nativeBuildInputs = [pkgs.makeWrapper];
buildInputs = [pkgs.ruby pkgs.nix-output-monitor];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${pkgs.ruby}/bin/ruby $out/bin/ruby \
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.nix-output-monitor]}
'';
};
in
pkgs.writeShellScriptBin "yo" ''
exec ${env}/bin/ruby ${yo} "$@"
''
|