From 4776108b4be4dadf25fac69f1faa2b43338b29be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Thu, 8 Sep 2022 16:29:53 +0200 Subject: [PATCH] Allow `modulesPath` in NixOS modules (#536) --- flake-info/src/commands/flake_info.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/flake-info/src/commands/flake_info.nix b/flake-info/src/commands/flake_info.nix index ec5db01..5bbf3cf 100644 --- a/flake-info/src/commands/flake_info.nix +++ b/flake-info/src/commands/flake_info.nix @@ -44,7 +44,7 @@ let ) ) apps; - readOptions = let + readNixOSOptions = let declarations = module: ( lib.evalModules { modules = (if lib.isList module then module else [ module ]) ++ [ @@ -54,6 +54,13 @@ let } ) ]; + specialArgs = { + # !!! NixOS-specific. Unfortunately, NixOS modules can rely on the `modulesPath` + # argument to import modules from the nixos tree. However, most of the time + # this is done to import *profiles* which do not declare any options, so we + # can allow it. + modulesPath = "${nixpkgs.path}/nixos/modules"; + }; } ).options; @@ -95,14 +102,14 @@ let readFlakeOptions = let nixosModulesOpts = builtins.concatLists (lib.mapAttrsToList (moduleName: module: - readOptions { + readNixOSOptions { inherit module; modulePath = [ flake moduleName ]; } ) (resolved.nixosModules or {})); nixosModuleOpts = lib.optionals (resolved ? nixosModule) ( - readOptions { + readNixOSOptions { module = resolved.nixosModule; modulePath = [ flake ]; }