blob: c96aa8194223c158f04436efd826fdf00e5701c7 (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
{
pkgs,
}:
[
(pkgs.writeScriptBin "rbuild" ''
#!${pkgs.bash}/bin/bash
set -e
# Check if host argument is provided
if [ -z "$1" ]; then
echo "❌ Error: Please specify a host"
echo "Usage: rbuild <hostname>"
echo "Example: rbuild rivendell"
exit 1
fi
HOST="$1"
echo "> Running nixos-rebuild build for $HOST..."
${pkgs.nixos-rebuild}/bin/nixos-rebuild build \
--keep-going \
--flake ".#$HOST" \
--target-host "$HOST" \
--fast \
--use-remote-sudo \
--use-substitutes
echo "> nixos-rebuild build for $HOST was successful ✅"
'')
(pkgs.writeScriptBin "rswitch" ''
#!${pkgs.bash}/bin/bash
set -e
# Check if host argument is provided
if [ -z "$1" ]; then
echo "❌ Error: Please specify a host"
echo "Usage: rswitch <hostname>"
echo "Example: rswitch rivendell"
exit 1
fi
HOST="$1"
echo "> Running nixos-rebuild switch for $HOST..."
${pkgs.nixos-rebuild}/bin/nixos-rebuild switch \
--keep-going \
--flake ".#$HOST" \
--target-host "$HOST" \
--fast \
--use-remote-sudo \
--use-substitutes
echo "> NixOS config was successfully applied to $HOST 🚀"
'')
(pkgs.writeScriptBin "rdeploy" ''
#!${pkgs.bash}/bin/bash
set -e
# Check if host argument is provided
if [ -z "$1" ]; then
echo "❌ Error: Please specify a host"
echo "Usage: rdeploy <hostname>"
echo "Example: rdeploy rivendell"
exit 1
fi
HOST="$1"
echo "> Deploying NixOS configuration to $HOST..."
echo ""
# First build
echo "📦 Step 1/2: Building configuration..."
${pkgs.nixos-rebuild}/bin/nixos-rebuild build \
--keep-going \
--flake ".#$HOST" \
--target-host "$HOST" \
--fast \
--use-remote-sudo \
--use-substitutes
echo ""
echo "🔄 Step 2/2: Switching configuration..."
${pkgs.nixos-rebuild}/bin/nixos-rebuild switch \
--keep-going \
--flake ".#$HOST" \
--target-host "$HOST" \
--fast \
--use-remote-sudo \
--use-substitutes
echo ""
echo "> NixOS deployment to $HOST completed successfully! 🎉"
'')
(pkgs.writeScriptBin "rhosts" ''
#!${pkgs.bash}/bin/bash
echo "> Available NixOS hosts in your flake:"
echo ""
# This attempts to list nixosConfigurations from the flake
# You might need to adjust this based on your flake structure
nix flake show --json 2>/dev/null | \
${pkgs.jq}/bin/jq -r '.nixosConfigurations | keys[]' 2>/dev/null || \
echo "Unable to list hosts automatically. Check your flake/hosts.nix"
'')
(pkgs.writeScriptBin "rtest" ''
#!${pkgs.bash}/bin/bash
set -e
# Check if host argument is provided
if [ -z "$1" ]; then
echo "❌ Error: Please specify a host"
echo "Usage: rtest <hostname>"
echo "Example: rtest rivendell"
exit 1
fi
HOST="$1"
echo "> Running dry-run build for $HOST..."
${pkgs.nixos-rebuild}/bin/nixos-rebuild dry-build \
--keep-going \
--flake ".#$HOST" \
--target-host "$HOST" \
--fast \
--use-remote-sudo \
--use-substitutes
echo "> Dry-run build for $HOST completed ✅"
'')
]
|