From 887f7d33e04bc999838d9dcd87113d84dd0a48c2 Mon Sep 17 00:00:00 2001 From: phaer Date: Fri, 11 Apr 2025 11:54:19 +0200 Subject: [PATCH] virtualisation/openstack: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant openstack-zfs --flake .#my-host` --- .../virtualisation/openstack-config.nix | 26 +++++++++++-------- .../virtualisation/openstack-options.nix | 16 +++++++----- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/nixos/modules/virtualisation/openstack-config.nix b/nixos/modules/virtualisation/openstack-config.nix index caa3cbba6a6b..34031c303039 100644 --- a/nixos/modules/virtualisation/openstack-config.nix +++ b/nixos/modules/virtualisation/openstack-config.nix @@ -33,18 +33,22 @@ in ]; config = { - fileSystems."/" = mkIf (!cfg.zfs.enable) { - device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - autoResize = true; - }; + fileSystems."/" = mkIf (!cfg.zfs.enable) ( + lib.mkImageMediaOverride { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + autoResize = true; + } + ); - fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) { - # The ZFS image uses a partition labeled ESP whether or not we're - # booting with EFI. - device = "/dev/disk/by-label/ESP"; - fsType = "vfat"; - }; + fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) ( + lib.mkImageMediaOverride { + # The ZFS image uses a partition labeled ESP whether or not we're + # booting with EFI. + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + } + ); boot.growPartition = true; boot.kernelParams = [ "console=tty1" ]; diff --git a/nixos/modules/virtualisation/openstack-options.nix b/nixos/modules/virtualisation/openstack-options.nix index 9d1b1efd676d..751e1612e833 100644 --- a/nixos/modules/virtualisation/openstack-options.nix +++ b/nixos/modules/virtualisation/openstack-options.nix @@ -70,12 +70,14 @@ in _: value: ((value.mount or null) != null) ) config.openstack.zfs.datasets; in - lib.mapAttrs' ( - dataset: opts: - lib.nameValuePair opts.mount { - device = dataset; - fsType = "zfs"; - } - ) mountable; + lib.mkImageMediaOverride ( + lib.mapAttrs' ( + dataset: opts: + lib.nameValuePair opts.mount { + device = dataset; + fsType = "zfs"; + } + ) mountable + ); }; }