Init
Initial commit, nodes are mostly done, panel is WIP
This commit is contained in:
commit
01b75b0584
73 files changed
+3406
No files matched your search
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
cd "$root"
|
||||
source "$root/scripts/select-node.sh"
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
node=$1
|
||||
else
|
||||
node=$(select_node)
|
||||
fi
|
||||
|
||||
SOPS_AGE_KEY_FILE=~/.config/sops/age/$node-key.txt \
|
||||
sops --config ~/Projects/vps-nixos/.sops.yaml \
|
||||
~/Projects/vps-nixos/hosts/$node/secrets.yaml
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
nix-collect-garbage -d
|
||||
|
||||
if [[ $(id -u) -ne 0 ]]; then
|
||||
sudo nix-collect-garbage -d
|
||||
fi
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "User profiles:"
|
||||
nix-collect-garbage --dry-run
|
||||
|
||||
if [[ $(id -u) -ne 0 ]]; then
|
||||
echo "System profiles:"
|
||||
sudo nix-collect-garbage --dry-run
|
||||
fi
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
cd "$root"
|
||||
source "$root/scripts/select-node.sh"
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
host=$1
|
||||
else
|
||||
host=$(select_node)
|
||||
fi
|
||||
|
||||
age_key="${VPS_AGE_KEY:-$HOME/.config/sops/age/$host-key.txt}"
|
||||
extra_dir=$(mktemp -d)
|
||||
trap 'rm -rf "$extra_dir"' EXIT
|
||||
|
||||
read -rp "Remote user: " user
|
||||
|
||||
install -d -m 0700 "$extra_dir/etc/age"
|
||||
install -m 0600 "$age_key" "$extra_dir/etc/age/key.txt"
|
||||
|
||||
nix run github:nix-community/nixos-anywhere -- \
|
||||
--no-disko-deps \
|
||||
--flake ".#$host" \
|
||||
--target-host "$user@$host" \
|
||||
--extra-files "$extra_dir"
|
||||
@@ -0,0 +1,33 @@
|
||||
select_node() {
|
||||
local raw choice
|
||||
local -a hosts
|
||||
|
||||
raw=$(
|
||||
nix eval --raw .#nixosConfigurations \
|
||||
--apply 'cfgs: builtins.concatStringsSep "\n" (builtins.sort builtins.lessThan (builtins.attrNames cfgs))'
|
||||
)
|
||||
|
||||
mapfile -t hosts <<< "$raw"
|
||||
if ((${#hosts[@]} == 0)) || [[ -z ${hosts[0]} ]]; then
|
||||
echo "No nixosConfigurations in this flake." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local i=1
|
||||
for node in "${hosts[@]}"; do
|
||||
printf '%d) %s\n' "$i" "$node" >&2
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
read -r -p "Host number: " choice
|
||||
if [[ ! $choice =~ ^[0-9]+$ ]]; then
|
||||
echo "Not a number: ${choice}" >&2
|
||||
return 1
|
||||
fi
|
||||
if ((10#$choice < 1 || 10#$choice > ${#hosts[@]})); then
|
||||
echo "Out of range: ${choice}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf '%s\n' "${hosts[10#$choice - 1]}"
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
cd "$root"
|
||||
source "$root/scripts/select-node.sh"
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
node=$1
|
||||
else
|
||||
node=$(select_node)
|
||||
fi
|
||||
|
||||
nix run nixpkgs#nixos-rebuild -- switch \
|
||||
--flake ".#$node" \
|
||||
--target-host "$node" \
|
||||
--sudo \
|
||||
--ask-elevate-password
|
||||
Reference in new issue
Block a user