diff --git a/nix/nixos-modules/assertions/default.nix b/nix/nixos-modules/assertions/default.nix index 1d4b0d9..b117dd4 100644 --- a/nix/nixos-modules/assertions/default.nix +++ b/nix/nixos-modules/assertions/default.nix @@ -1,6 +1,7 @@ { imports = [ # files + ./efi.nix ./fileSystems.nix ./mdns.nix ./nixos.nix diff --git a/nix/nixos-modules/assertions/efi.nix b/nix/nixos-modules/assertions/efi.nix new file mode 100644 index 0000000..6dc6d1b --- /dev/null +++ b/nix/nixos-modules/assertions/efi.nix @@ -0,0 +1,39 @@ +{ + config, + lib, + options, + ... +}: +let + inherit (lib.strings) escapeNixString; + cfg = config.boot.loader; + fs = config.fileSystems; + efiIndicator = builtins.any (x: x) [ + (cfg.grub.enable && cfg.grub.efiSupport) + (cfg.systemd-boot.enable) + ]; + efiMountPath = escapeNixString cfg.efi.efiSysMountPoint; + efiMount = fs.${cfg.efi.efiSysMountPoint} or null; +in +# TODO check cfg.grub.mirroredBoots as well +# TODO enable disko checks (optional i.e. when disko options are available) +{ + config = lib.mkIf efiIndicator { + + assertions = [ + { + assertion = efiMount != null; + message = '' + There is no filesystem declaration for EFI System Partition ${efiMountPath} + ''; + } + { + assertion = efiMount != null -> efiMount.fsType == "vfat"; + message = '' + EFI System Partition ${efiMountPath} has not fsType "vfat" + ''; + } + ]; + + }; +}