Refactor default sops override config

This commit is contained in:
Manuel Thalmann 2024-05-02 13:16:42 +02:00
parent 9e3fad7501
commit b8c3cbc2b1
2 changed files with 11 additions and 11 deletions

View file

@ -78,17 +78,10 @@ in {
virtualisation =
let
extendVMConfig =
vmVariant: overrideSops: {
vmVariant: {
# Prevent GRUB2 errors in `nixos-rebuild build-vm-with-bootloader`
boot.loader.efi.efiSysMountPoint = lib.mkVMOverride "/boot";
# Override passwords backed by `sops-nix` as `nixos-rebuild build-vm-with-bootloader`
# does not seem to play along well with `sops-nix`
users.sopsPasswordOverride = lib.mkIf overrideSops {
enable = true;
password = "admin";
};
virtualisation = {
# Enable root permissions to get access to the `/etc/ssh` directory
runAsRoot = lib.mkIf vmVariant.virtualisation.sharedHostKeys true;

View file

@ -32,7 +32,14 @@
virtualisation =
let
extendVMConfig =
vmVariant: {
vmVariant: overrideSops: {
# Override passwords backed by `sops-nix` as `nixos-rebuild build-vm-with-bootloader`
# does not seem to play along well with `sops-nix`
users.sopsPasswordOverride = lib.mkIf overrideSops {
enable = lib.mkDefault true;
password = lib.mkDefault "admin";
};
users.users =
with { inherit (vmVariant.users) sopsPasswordOverride; };
(lib.mkIf
@ -67,8 +74,8 @@
vmVariantWithBootLoader
;
in {
vmVariant = extendVMConfig vmVariant;
vmVariantWithBootLoader = extendVMConfig vmVariantWithBootLoader;
vmVariant = extendVMConfig vmVariant false;
vmVariantWithBootLoader = extendVMConfig vmVariantWithBootLoader true;
};
};
}