-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevenv.nix
295 lines (265 loc) · 8.25 KB
/
devenv.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
{
pkgs,
lib,
config,
inputs,
...
}:
with pkgs; let
# nixos-generate = inputs.nixos-generators.packages."${pkgs.system}".nixos-generate;
# agenix-rekey = inputs.agenix-rekey.packages."${pkgs.system}".agenix-rekey;
_mbufferSend = writeShellScriptBin "_mbufferSend" ''
mbuffer -I pegasus:8000 -m 1G | zstd -e - -19 | > pegasus-bak-2.tar.zst
ssh [email protected] "tar chf - /home/media | mbuffer -m 100M -O euro-mir-2:8000"
'';
write-script = writeShellScriptBin "write-script" ''
set -x
echo "pv $1 $2"
pv $1 -cN in -B 500M -pterbT | zstd -d - | pv -cN out -B 500M -pterbT > $2
'';
deployment = writeShellScriptBin "deployment" ''
${pkgs.deploy-rs}/bin/deploy --skip-checks --targets $@ -- --log-format internal-json -v |& ${pkgs.nix-output-monitor}/bin/nom --json
'';
deploy-all = writeShellScriptBin "deploy-all" ''
${pkgs.deploy-rs}/bin/deploy --skip-checks -- --log-format internal-json -v |& ${pkgs.nix-output-monitor}/bin/nom --json
'';
deploy-machine = writeShellScriptBin "deploy-machine" ''
set -x
${pkgs.deploy-rs}/bin/deploy --skip-checks ".#$@" -- --log-format internal-json -v |& ${pkgs.nix-output-monitor}/bin/nom --json
'';
# reencrypt = writeShellScriptBin "reencrypt" ''
# cd secrets;
# agenix -r
# '';
mkiso = writeShellScriptBin "mkiso" ''
LINK="./out/install.iso";
nom build '.#nixosConfigurations.hyperv-nixos.config.formats.install-iso' --out-link $LINK
pv $LINK -cN in -B 100M -pterbT | xz -T4 -9 | pv -cN out -B 100M -pterbT > ./out/install.iso.xz
'';
remote-deploy = writeShellScriptBin "remote-deploy" ''
remote deployment '.#arthur' '.#enzian'
'';
upload-all = writeShellScriptBin "upload-all" ''
FILES="/nix/store/*"
for f in $FILES
do
echo "Processing $f file..."
attic push tomas "$f"
done
'';
nix-update-all = writeShellScriptBin "nix-update-all" ''
update_path="${inputs.nixpkgs}/maintainers/scripts/update.nix"
echo $update_path
exec nix-shell "$update_path"
'';
update-pkgs = writeShellScriptBin "update-pkgs" ''
set -x
nixPath="$(nix eval -f . inputs.nixpkgs.outPath --json | jq -r)"
echo "found $nixPath"
nixUpdate="$nixPath/maintainers/scripts/update.nix"
echo "found $nixUpdate"
overlayExpr="(import {./.} {{ }}).outputs.overlays"
nix-shell $nixUpdate --arg include-overlays $overlayExpr --arg predicate '(path: pkg: true)' --verbose --show-trace $@
'';
test-installer = writeShellScriptBin "test-installer" ''
VM_PATH="$(nix build '.#nixosConfigurations.installer-x86.config.system.build.vm' --print-out-paths)"
QEMU_KERNEL_PARAMS=console=ttyS0 $VM_PATH/bin/run-nixos-vm -nographic; reset
'';
# cachix-deploy = writeShellScriptBin "cachix-deploy" ''
# set -x
# set -e
# spec=$(nom build --print-out-paths)
# echo $spec
# cat $spec
# cachix push tomasharkema $spec
# '';
# example: `cachix-reploy-pin "darwinConfigurations.euro-mir.config.system.build.toplevel" "darwin-0.1"`
# cachix-reploy-pin = writeShellScriptBin "cachix-reploy-pin" ''
# set -x
# set -e
# res="$(nom build ".#$1" --json | jq '.[0].outputs.out' -r)"
# cachix push tomasharkema $res
# cachix pin tomasharkema $2 $res
# '';
dconf-update = writeShellScriptBin "dconf-update" ''
${lib.getExe pkgs.dconf} dump / > dconf.settings
${lib.getExe pkgs.dconf2nix} -i dconf.settings -o dconf.nix
'';
dconf-save = writeShellScriptBin "dconf-save" ''
current_hostname="$(hostname)"
echo "Saving dconf for $current_hostname"
${lib.getExe pkgs.dconf} dump / > "dconf/$current_hostname.conf"
'';
test-remote = writeShellScriptBin "test-remote" ''
SERVER="$1"
echo "test remote $SERVER..."
exec ${lib.getExe pkgs.buildPackages.nixos-rebuild} test --flake ".#$SERVER" --target-host "$SERVER" --use-remote-sudo --verbose --show-trace -L --use-substitutes
'';
upload-to-installer = writeShellScriptBin "upload-to-installer" ''
configuration="$1"
host="$2"
flake="nixosConfigurations.\"$configuration\".config.system.build.toplevel"
echo "Copy $flake to $host"
nix copy --to "ssh-ng://$host?remote-store=local?root=/mnt" ".#$flake" --derivation --no-check-sigs
nix build ".#$flake" --eval-store auto --store "ssh-ng://$host?remote-store=local?root=/mnt"
'';
dp = writeShellScriptBin "dp" ''
configuration="$1"
host="$2"
flake="nixosConfigurations.\"$configuration\".config.system.build.toplevel"
echo "Copy $flake to $host"
exec nixos-rebuild test --flake ".#$configuration" --verbose --target-host $host --use-remote-sudo --use-substitutes
'';
# diffs = import ../diffs attrs;
# packages-json = diffs.packages-json;
# gum = lib.getExe pkgs.gum;
# packages-json = writeShellScriptBin "packages-json" ''
# export DIR="$(mktemp -d)"
# SYSTEM_PKGS=".#$1.config.environment.systemPackages"
# # gum spin --spinner line --title "Evaluating $SYSTEM_PKGS to $DIR/first.json" --
# nix eval "$SYSTEM_PKGS" --json | tee "$DIR/first.json"
# HOME_PKGS=".#$1.config.home-manager.users.tomas.home.packages"
# # gum spin --spinner line --title "Evaluating $HOME_PKGS to $DIR/second.json" --
# nix eval "$HOME_PKGS" --json | tee "$DIR/second.json"
# cat "$DIR/first.json" "$DIR/second.json" | jq -s add | tee "$DIR/out.json" | gum pager
# '';
upload-all-store = writeShellScriptBin "upload-all-store" ''
NPATHS=50
NPROCS=4
exec nix path-info --all | xargs -n$NPATHS -P$NPROCS attic push tomas -j 1
'';
build-host-pkgs = writeShellScriptBin "build-host-pkgs" ''
PACKAGE="$1"
echo "Build $PACKAGE"
exec nom build ".#nixosConfigurations.$HOSTNAME.pkgs.$PACKAGE" --out-link ./out/$PACKAGE
'';
nixos-system = writeShellScriptBin "nixos-system" ''
HOST="$1"
echo "Build $HOST"
exec nom build ".#nixosConfigurations.$HOST.config.system.build.toplevel" --out-link ./out/$HOST
'';
darwin-system = writeShellScriptBin "darwin-system" ''
HOST="$1"
echo "Build $HOST"
exec nom build ".#darwinConfigurations.$HOST.config.system.build.toplevel" --out-link ./out/$HOST
'';
in {
# starship.enable = true;
languages.nix = {
enable = true;
lsp.package = nil;
};
pre-commit.hooks = {
alejandra.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
nil.enable = true;
stylua.enable = true;
# treefmt.enable = true;
# statix.enable = true;
# deadnix.enable = true;
gptcommit.enable = true;
check-added-large-files.enable = true;
ripsecrets.enable = true;
"by-name" = {
enable = true;
entry = "sh ./by-name.sh";
pass_filenames = false;
};
# "flake-show" = {
# enable = true;
# entry = "nix flake show";
# pass_filenames = false;
# };
};
devcontainer = {
enable = true;
settings.customizations.vscode.extensions = [
"Catppuccin.catppuccin-vsc-pack"
"jnoortheen.nix-ide"
"mkhl.direnv"
"kamadorueda.alejandra"
];
};
difftastic.enable = true;
# dotenv.enable = true;
processes = {
attic.exec = "attic watch-store tomas -j1";
};
# enterShell = ''
# nix flake update && devenv update
# '';
packages = with pkgs; [
actionlint
#pkgs.nixVersions.latest
nixos-system
darwin-system
build-host-pkgs
nix-update-all
# # snowfallorg.flake
# agenix
# cachix
# cachix-deploy
# cachix-reploy-pin
# cntr
flake-checker
autoflake
nix-init
# nix-serve
# nixci
# nixos-shell
# pkgs.custom.remote-cli
# pkgs.custom.rundesk
ack
age
alejandra
attic-client
bash
bfg-repo-cleaner
colima
dconf-save
dconf-update
dconf2nix
deadnix
deploy-all
deploy-machine
deployment
direnv
dp
git
gnupg
gum
manix
mkiso
netdiscover
# nil
# nix-eval-jobs
nix-output-monitor
nix-output-monitor
nix-prefetch-scripts
nix-prefetch-scripts
nix-tree
nixd
nixfmt-rfc-style
nixpkgs-fmt
nixpkgs-lint
nurl
deploy-rs
# reencrypt
remote-deploy
sops
ssh-to-age
statix
statix
test-installer
test-remote
tydra
update-pkgs
upload-all
upload-all-store
# upload-local
upload-to-installer
write-script
zsh
];
}