-
Notifications
You must be signed in to change notification settings - Fork 1
/
scripts.nix
76 lines (60 loc) · 1.58 KB
/
scripts.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
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
{ lib, pkgs, self, ... }:
let
checkflake = ''
if ! [ -f flake.nix ]; then
echo "No flake.nix found in the current directory"
exit 1
fi
'';
in
rec {
update = ''
#!${pkgs.bash}/bin/bash
set -euxo pipefail
${checkflake}
${pkgs.nix}/bin/nix flake update --commit-lock-file
'';
mkiso = ''
#!${pkgs.bash}/bin/bash
set -euxo pipefail
subconfig=""
if [ -n "''${1:-}" ]; then
subconfig=".$1"
fi
${checkflake}
${pkgs.nix}/bin/nix build ".#nixosConfigurations.live''${subconfig}.config.system.build.isoImage" -vL
'';
toplevel = ''
#!${pkgs.bash}/bin/bash
set -euxo pipefail
${checkflake}
${pkgs.nix}/bin/nix build ".#nixosConfigurations.''${1}.config.system.build.toplevel" -vL
'';
vm = ''
#!${pkgs.bash}/bin/bash
set -euxo pipefail
${checkflake}
${pkgs.nix}/bin/nix build ".#nixosConfigurations.''${1}.config.system.build.vm" -vL
mkdir -p /tmp/nixvm
if [ -f /tmp/nixvm/hostname ]; then
if [ "''${2:-}" == "-c" ] || ! [ "$(cat /tmp/nixvm/hostname)" == "$1" ]; then
rm -f /tmp/nixvm/root.qcow2
fi
fi
printf $1 >/tmp/nixvm/hostname
export QEMU_OPTS="-m 4096 -vga qxl ''${QEMU_OPTS:-}"
export NIX_DISK_IMAGE=/tmp/nixvm/root.qcow2
result/bin/run-live-vm
'';
wifiedit = ''
#!${pkgs.bash}/bin/bash
set -euxo pipefail
FILE="asset/iwd/$(echo -n $1 | sha256sum | awk '{print $1;}').age"
if ! [ -f "$FILE" ]; then
NOEXT="''${FILE%.*}"
touch "$NOEXT"
enrage "$NOEXT"
fi
${pkgs.agenix}/bin/agenix -e "$FILE"
'';
}