My dotfiles for my nixos machines and infra
1# deploy target:
2# nh os switch --file ./default.nix hosts.{{ target }} --target-host {{ target }} --build-host {{ target }}
3
4set shell := ["bash", "-c"]
5
6deploy target:
7 nixos-rebuild switch --file ./default.nix -A hosts.{{ target }} --target-host {{ target }} --build-host {{ target }} --sudo |& nom
8 # preview {{ target }}
9
10 # nixos-rebuild switch --store-path xxx --target-host {{ target }} --build-host {{ target }} --sudo &| nom
11
12preview target:
13 #!/usr/bin/env bash
14 nixos-rebuild build --file ./default.nix -A hosts.{{ target }} --target-host {{ target }} --build-host {{ target }} --no-flake | tee /tmp/build |& nom
15 export build=$(cat /tmp/build)
16 ssh {{ target }} "nix run nixpkgs#dix -- --color always /run/current-system $build"
17
18 read -p "Continue deploying? (y/n)\n" ans
19 if [[ "$ans" = "y" ]]; then
20 # ssh {{ target }} "nixos-rebuild switch --store-path $build --sudo"
21 nixos-rebuild switch --target-host {{ target }} --build-host {{ target }} --sudo
22 fi
23
24deploy-homelab:
25 nixos-rebuild switch --file ./default.nix -A hosts.home-server --target-host root@snowlab.local --build-host root@snowlab.local |& nom
26
27deploy-server:
28 nh os switch --file ./default.nix hosts.server --target-host server --build-host server
29
30wireguard_gen:
31 #!/usr/bin/env nix-shell
32 #!nix-shell -i bash -p wireguard-tools
33 key=$(wg genkey)
34 pub=$(echo $key | wg pubkey)
35 psk=$(wg genpsk)
36 echo -e "key: $key\npub: $pub\npsk: $psk"