From bf6a465789e99fbc343c68ca779aedae2c24bda1 Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Fri, 21 May 2021 13:54:52 -0700 Subject: [PATCH] evalArgs: add devshell namespace for modules don't import modules --- src/mkFlake/evalArgs.nix | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/mkFlake/evalArgs.nix b/src/mkFlake/evalArgs.nix index 7509d7f..db89fc8 100644 --- a/src/mkFlake/evalArgs.nix +++ b/src/mkFlake/evalArgs.nix @@ -8,7 +8,7 @@ let inherit (config) self; maybeImport = obj: - if (builtins.typeOf obj == "path") || (builtins.typeOf obj == "string") then + if (builtins.isPath obj || builtins.isString obj) && lib.hasSuffix ".nix" obj then import obj else obj; @@ -22,7 +22,7 @@ let # to export modules we need paths to get the name exportModuleType = with types; - (addCheck path (x: moduleType.check (import x))) // { + (addCheck path (x: moduleType.check (maybeImport x))) // { description = "path to a module"; }; overlayType = pathTo (types.anything // { @@ -38,21 +38,9 @@ let # To simplify apply keys and improve type checking pathTo = elemType: with types; coercedTo path maybeImport elemType; - pathToListOf = elemType: with types; pathTo (listOf elemType); - coercedListOf = elemType: with types; coercedTo anything (x: flatten (singleton x)) (listOf elemType); - pathToDevshellModule = with types; (coercedTo path (path: - let pathstr = toString path; in - if lib.hasSuffix ".toml" pathstr then - { pkgs, ... }: { imports = [ (pkgs.devshell.importTOML path) ]; } - else - import path - ) moduleType) // { - description = "path to a devshell module(including .toml files)"; - }; - /* Submodules needed for API containers */ channelsModule = { name, ... }: { @@ -281,11 +269,17 @@ let hosts, modules, suites, and profiles for home-manager ''; }; - devshellModules = mkOption { - type = coercedListOf pathToDevshellModule; - default = [ ]; + devshell = mkOption { + type = submoduleWith { + modules = [ + (exportModulesModule "devshell") + externalModulesModule + ]; + }; + default = { }; description = '' - devshell modules(including .toml files) to add to the devshell + Modules to include in your devos shell. the `modules` argument + will be exported under the `devshellModules` output ''; }; };