From b70362bf9bdefcf1042af3848f7311171b07a7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Tue, 7 Feb 2023 11:35:12 +0100 Subject: [PATCH] nix: fix package assertion Sync it with the condition for generating nix.conf so that it triggers if `extraOptions` is set but `package` isn't. --- modules/misc/nix.nix | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/modules/misc/nix.nix b/modules/misc/nix.nix index 6ae28157a..785a7c044 100644 --- a/modules/misc/nix.nix +++ b/modules/misc/nix.nix @@ -212,29 +212,28 @@ in { }; }; - config = mkIf cfg.enable { - assertions = [{ - assertion = cfg.settings == { } || cfg.package != null; - message = '' - A corresponding Nix package must be specified via `nix.package` for generating - nix.conf. - ''; - }]; - - xdg.configFile = { - "nix/registry.json" = mkIf (cfg.registry != { }) { - source = jsonFormat.generate "registry.json" { + config = mkIf cfg.enable (mkMerge [ + (mkIf (cfg.registry != { }) { + xdg.configFile."nix/registry.json".source = + jsonFormat.generate "registry.json" { version = cfg.registryVersion; flakes = mapAttrsToList (n: v: { inherit (v) from to exact; }) cfg.registry; }; - }; + }) - "nix/nix.conf" = mkIf (cfg.settings != { } || cfg.extraOptions != "") { - source = nixConf; - }; - }; - }; + (mkIf (cfg.settings != { } || cfg.extraOptions != "") { + assertions = [{ + assertion = cfg.package != null; + message = '' + A corresponding Nix package must be specified via `nix.package` for generating + nix.conf. + ''; + }]; + + xdg.configFile."nix/nix.conf".source = nixConf; + }) + ]); meta.maintainers = [ maintainers.polykernel ]; }