-
Notifications
You must be signed in to change notification settings - Fork 0
/
rbld.nix
46 lines (39 loc) · 1.08 KB
/
rbld.nix
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
{ pkgs, ... }:
pkgs.writeShellApplication
{
name = "rbld";
runtimeInputs = with pkgs;
[
nix-output-monitor # aka nom
nixos-rebuild
git
];
text =
''
set -e
directory="''${FLAKE:-/etc/nixos}" # Override default config directory value with $FLAKE
while getopts ":d:" opt; do # Or, if you just need to override the directory once, use `-d`
case $opt in
d)
directory=$OPTARG
;;
\?) # Undefined option like -q
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:) # Setting -d without an argument
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
cd "$directory"
git add -AN # Adds the existence of any new files, but not their contents
sudo -v || exit # Rather than having to verify sudo during rebuild, we do it before. works as long as rebuild is <5 minutes
nixos-rebuild switch \
--use-remote-sudo --fast \
--log-format internal-json \
--flake "$directory" \
|& nom --json || exit 1
'';
}