modify bootstrap script and change btrfsMountDevice in merlin
This commit is contained in:
parent
ef393ba038
commit
2208bcf968
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
device ? throw "Must define a device, e.g. /dev/sda",
|
||||||
|
fsModule ? "Must specify submodule"
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
main = {
|
||||||
|
type = "disk";
|
||||||
|
inherit device;
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
ESP = {
|
||||||
|
priority = 1;
|
||||||
|
name = "ESP";
|
||||||
|
start = "1M";
|
||||||
|
end = "128M";
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
mountOptions = ["umask=0077"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
size = "100%";
|
||||||
|
content = import "${fsModule}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,11 +1,8 @@
|
||||||
{ device, fsType, encrypted, impermanence, ... }:
|
{ device, fsType, encrypted, impermanence, ... }:
|
||||||
let
|
let
|
||||||
fsModule = if impermanence then ./${fsType}/persist.nix else ./${fsType}/standard.nix;
|
fsModule = if impermanence then ./${fsType}/persist.nix else ./${fsType}/standard.nix;
|
||||||
basic = import ./${fsType}/basic.nix { inherit device; };
|
basic = import ./basic.nix { inherit device; fsModule = fsModule; };
|
||||||
lvm = import ./lvm.nix { inherit device; fsModule = fsModule; };
|
|
||||||
luks = import ./luks.nix { inherit device; fsModule = fsModule; };
|
luks = import ./luks.nix { inherit device; fsModule = fsModule; };
|
||||||
in
|
in
|
||||||
if fsType == "ext4" then basic
|
if fsType == "btrfs" && encrypted then luks
|
||||||
else if fsType == "btrfs" && encrypted then luks
|
else basic
|
||||||
else if fsType == "btrfs" then lvm
|
|
||||||
else null
|
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
fsType = "btrfs"; # one of ext4 or btrfs. Use btrfs if using impermanence
|
fsType = "btrfs"; # one of ext4 or btrfs. Use btrfs if using impermanence
|
||||||
dev = "/dev/disk/by-id/wwn-0x5001b448b5f7cc7f";
|
dev = "/dev/disk/by-id/wwn-0x5001b448b5f7cc7f";
|
||||||
encrypted = false; # currrently only applies to btrfs
|
encrypted = false; # currrently only applies to btrfs
|
||||||
btrfsMountDevice = "/dev/root_vg/root";
|
btrfsMountDevice = "/dev/disk/by-id/wwn-0x5001b448b5f7cc7f-part2";
|
||||||
impermanence = true;
|
impermanence = true;
|
||||||
|
|
||||||
piholeIp = configVars.networking.addresses.pihole.ip;
|
piholeIp = configVars.networking.addresses.pihole.ip;
|
||||||
gatewayIp = configVars.networking.addresses.gateway.ip;
|
gatewayIp = configVars.networking.addresses.gateway.ip;
|
||||||
merlinIp = configVars.networking.addresses.merlin.ip;
|
merlinIp = configVars.networking.addresses.merlin.ip;
|
||||||
|
|
|
@ -40,33 +40,40 @@ trap cleanup EXIT
|
||||||
# Create the directory for target host keys
|
# Create the directory for target host keys
|
||||||
install -d -m755 "$temp$persist/etc/ssh"
|
install -d -m755 "$temp$persist/etc/ssh"
|
||||||
|
|
||||||
# Create ssh keys
|
# Extract ssh keys from secrets
|
||||||
echo "Creating '$hostname' ssh keys"
|
echo "Extracting ssh keys"
|
||||||
ssh-keygen -t ed25519 -f "$temp$persist/etc/ssh/ssh_host_ed25519_key" -C root@"$hostname" -N ""
|
ssh_private_key=$(nix-shell -p sops --run "SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt sops -d --extract '[""\"ssh_keys""\"][""\"$hostname""\"][""\"id_ed25519""\"]' ~/.local/share/src/nix-secrets/secrets.yaml")
|
||||||
|
echo "$ssh_private_key" > $temp$persist/etc/ssh/ssh_host_ed25519_key
|
||||||
|
ssh_pub_key=$(nix-shell -p sops --run "SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt sops -d --extract '[""\"ssh_keys""\"][""\"$hostname""\"][""\"id_ed25519.pub""\"]' ~/.local/share/src/nix-secrets/secrets.yaml")
|
||||||
|
echo "$ssh_pub_key" > $temp$persist/etc/ssh/ssh_host_ed25519_key.pub
|
||||||
|
|
||||||
# Extract luks key from secrets
|
# # Extract luks key from secrets
|
||||||
luks_secret=$(nix-shell -p sops --run "SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt sops -d --extract '[""\"luks_passphrase""\"][""\"$hostname""\"]' ~/.local/share/src/nix-secrets/secrets.yaml")
|
# luks_secret=$(nix-shell -p sops --run "SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt sops -d --extract '[""\"luks_passphrase""\"][""\"$hostname""\"]' ~/.local/share/src/nix-secrets/secrets.yaml")
|
||||||
echo "$luks_secret" > /tmp/luks_secret.key
|
# echo "$luks_secret" > /tmp/luks_secret.key
|
||||||
|
|
||||||
# Generate age key from target host and user public ssh key
|
# # Create ssh keys
|
||||||
echo "Generating age key from target host and user ssh key"
|
# echo "Creating '$hostname' ssh keys"
|
||||||
HOST_AGE_KEY=$(nix-shell -p ssh-to-age --run "cat $temp$persist/etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age")
|
# ssh-keygen -t ed25519 -f "$temp$persist/etc/ssh/ssh_host_ed25519_key" -C root@"$hostname" -N ""
|
||||||
echo -e "Host age key:\n$HOST_AGE_KEY\n"
|
|
||||||
|
|
||||||
# Update .sops.yaml with new age key:
|
# # Generate age key from target host and user public ssh key
|
||||||
SOPS_FILE="$HOME/.local/share/src/nix-secrets/.sops.yaml"
|
# echo "Generating age key from target host and user ssh key"
|
||||||
sed -i "{
|
# HOST_AGE_KEY=$(nix-shell -p ssh-to-age --run "cat $temp$persist/etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age")
|
||||||
# Remove any * and & entries for this host
|
# echo -e "Host age key:\n$HOST_AGE_KEY\n"
|
||||||
/[*&]$hostname/ d;
|
|
||||||
# Inject a new age: entry
|
|
||||||
# n matches the first line following age: and p prints it, then we transform it while reusing the spacing
|
|
||||||
/age:/{n; p; s/\(.*- \*\).*/\1$hostname/};
|
|
||||||
# Inject a new hosts: entry
|
|
||||||
/&hosts:/{n; p; s/\(.*- &\).*/\1$hostname $HOST_AGE_KEY/}
|
|
||||||
}" "$SOPS_FILE"
|
|
||||||
|
|
||||||
# Commit and push changes to sops file
|
# # Update .sops.yaml with new age key:
|
||||||
just update-sops-secrets && just update-flake-secrets && just update-flake
|
# SOPS_FILE="$HOME/.local/share/src/nix-secrets/.sops.yaml"
|
||||||
|
# sed -i "{
|
||||||
|
# # Remove any * and & entries for this host
|
||||||
|
# /[*&]$hostname/ d;
|
||||||
|
# # Inject a new age: entry
|
||||||
|
# # n matches the first line following age: and p prints it, then we transform it while reusing the spacing
|
||||||
|
# /age:/{n; p; s/\(.*- \*\).*/\1$hostname/};
|
||||||
|
# # Inject a new hosts: entry
|
||||||
|
# /&hosts:/{n; p; s/\(.*- &\).*/\1$hostname $HOST_AGE_KEY/}
|
||||||
|
# }" "$SOPS_FILE"
|
||||||
|
|
||||||
|
# # Commit and push changes to sops file
|
||||||
|
# just update-sops-secrets && just update-flake-secrets && just update-flake
|
||||||
|
|
||||||
# Copy current nix config over to target
|
# Copy current nix config over to target
|
||||||
echo "copying current nix config to host"
|
echo "copying current nix config to host"
|
||||||
|
|
Loading…
Reference in New Issue