mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-23 21:18:27 +01:00
Compare commits
No commits in common. "ec0d5b839ed7cf9ca9cff24180821cfd636b5248" and "a96b31d4e1802ac33d69842165164983ff509cc3" have entirely different histories.
ec0d5b839e
...
a96b31d4e1
5 changed files with 16 additions and 60 deletions
|
|
@ -30,7 +30,6 @@ _: {
|
||||||
pkgs.nebula
|
pkgs.nebula
|
||||||
pkgs.bitwarden-cli
|
pkgs.bitwarden-cli
|
||||||
self'.packages.nebula-regen-host-cert
|
self'.packages.nebula-regen-host-cert
|
||||||
self'.packages.nebula-regen-all-host-certs
|
|
||||||
];
|
];
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,13 @@
|
||||||
{ self, ... }:
|
{ self, ... }:
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{
|
{ pkgs, lib, ... }:
|
||||||
self',
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
{
|
||||||
packages =
|
packages =
|
||||||
"${self}/scripts"
|
"${self}/scripts"
|
||||||
|> builtins.readDir
|
|> builtins.readDir
|
||||||
|> lib.attrNames
|
|> lib.attrNames
|
||||||
|> lib.map (name: name |> lib.removeSuffix ".nix")
|
|> lib.map (name: name |> lib.removeSuffix ".nix")
|
||||||
|> self.lib.genAttrs (name: import "${self}/scripts/${name}.nix" { inherit self' pkgs lib; });
|
|> self.lib.genAttrs (name: import "${self}/scripts/${name}.nix" { inherit pkgs; });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs }:
|
||||||
pkgs.writeShellApplication {
|
pkgs.writeShellApplication {
|
||||||
name = "install-anywhere";
|
name = "install-anywhere";
|
||||||
|
|
||||||
|
|
@ -17,7 +17,6 @@ pkgs.writeShellApplication {
|
||||||
host="$1"
|
host="$1"
|
||||||
destination="$2"
|
destination="$2"
|
||||||
root="$(mktemp --directory)"
|
root="$(mktemp --directory)"
|
||||||
trap 'rm -rf "$root"' EXIT
|
|
||||||
|
|
||||||
impermanence="$(nix eval ".#nixosConfigurations.$host.config.custom.persistence.enable")"
|
impermanence="$(nix eval ".#nixosConfigurations.$host.config.custom.persistence.enable")"
|
||||||
if [ "$impermanence" = true ]; then
|
if [ "$impermanence" = true ]; then
|
||||||
|
|
@ -52,5 +51,7 @@ pkgs.writeShellApplication {
|
||||||
--extra-files "$root" \
|
--extra-files "$root" \
|
||||||
--flake ".#$host" \
|
--flake ".#$host" \
|
||||||
--target-host "$destination"
|
--target-host "$destination"
|
||||||
|
|
||||||
|
rm -rf "$root"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
self',
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = "nebula-regen-all-host-certs";
|
|
||||||
|
|
||||||
runtimeInputs = [
|
|
||||||
pkgs.bitwarden-cli
|
|
||||||
pkgs.jq
|
|
||||||
];
|
|
||||||
|
|
||||||
text = ''
|
|
||||||
hosts="$(nix eval .#nixosConfigurations --apply 'builtins.attrNames' --json | jq -r '.[]')"
|
|
||||||
|
|
||||||
if ! declare -px BW_SESSION >/dev/null 2>&1; then
|
|
||||||
BW_SESSION="$(bw unlock --raw || bw login --raw)"
|
|
||||||
export BW_SESSION
|
|
||||||
fi
|
|
||||||
|
|
||||||
ca_key="$(mktemp)"
|
|
||||||
chmod 600 "$ca_key"
|
|
||||||
trap 'rm -f "$ca_key"' EXIT
|
|
||||||
bw get notes 'nebula ca-key' > "$ca_key"
|
|
||||||
|
|
||||||
for host in $hosts; do
|
|
||||||
echo "Regenerating certificate for $host..."
|
|
||||||
${lib.getExe self'.packages.nebula-regen-host-cert} "$host" "$ca_key"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Done!"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs }:
|
||||||
pkgs.writeShellApplication {
|
pkgs.writeShellApplication {
|
||||||
name = "nebula-regen-host-cert";
|
name = "nebula-regen-host-cert";
|
||||||
|
|
||||||
|
|
@ -8,8 +8,8 @@ pkgs.writeShellApplication {
|
||||||
];
|
];
|
||||||
|
|
||||||
text = ''
|
text = ''
|
||||||
if [[ $# -lt 1 ]] || [[ $# -gt 2 ]]; then
|
if [[ $# -ne 1 ]]; then
|
||||||
echo "Usage: $0 <host> [<ca-key-path>]"
|
echo "Usage: $0 <host>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -20,20 +20,16 @@ pkgs.writeShellApplication {
|
||||||
host_cert="$(nix eval --raw ".#nixosConfigurations.$host.config.custom.services.nebula.certificatePath")"
|
host_cert="$(nix eval --raw ".#nixosConfigurations.$host.config.custom.services.nebula.certificatePath")"
|
||||||
host_cert="''${host_cert#*-source/}"
|
host_cert="''${host_cert#*-source/}"
|
||||||
|
|
||||||
if [[ $# -eq 2 ]]; then
|
if ! declare -px BW_SESSION >/dev/null 2>&1; then
|
||||||
ca_key="$2"
|
BW_SESSION="$(bw unlock --raw || bw login --raw)"
|
||||||
else
|
export BW_SESSION
|
||||||
if ! declare -px BW_SESSION >/dev/null 2>&1; then
|
|
||||||
BW_SESSION="$(bw unlock --raw || bw login --raw)"
|
|
||||||
export BW_SESSION
|
|
||||||
fi
|
|
||||||
|
|
||||||
ca_key="$(mktemp)"
|
|
||||||
chmod 600 "$ca_key"
|
|
||||||
trap 'rm -f "$ca_key"' EXIT
|
|
||||||
bw get notes 'nebula ca-key' > "$ca_key"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ca_key="$(mktemp)"
|
||||||
|
chmod 600 "$ca_key"
|
||||||
|
trap 'rm -f "$ca_key"' EXIT
|
||||||
|
bw get notes 'nebula ca-key' > "$ca_key"
|
||||||
|
|
||||||
rm -f "$host_cert"
|
rm -f "$host_cert"
|
||||||
nebula-cert sign -name "$host" -networks "$address" -ca-crt "$ca_cert" -ca-key "$ca_key" -in-pub "$host_pub" -out-crt "$host_cert"
|
nebula-cert sign -name "$host" -networks "$address" -ca-crt "$ca_cert" -ca-key "$ca_key" -in-pub "$host_pub" -out-crt "$host_cert"
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue