1
1
mirror of https://github.com/divnix/digga.git synced 2024-12-23 16:11:51 +03:00

fix: maybImport to also classic imports that peak for defualt.nix

such as `import ./pkgs`, actually loading `./pkgs/default.nix`
This commit is contained in:
David Arnold 2021-06-14 20:40:27 -05:00 committed by Parthiv Seetharaman
parent 1fb87138c7
commit 2eb6f83262
6 changed files with 21 additions and 28 deletions

View File

@ -184,11 +184,11 @@
"flake-utils": "flake-utils" "flake-utils": "flake-utils"
}, },
"locked": { "locked": {
"lastModified": 1623691375, "lastModified": 1623776596,
"narHash": "sha256-y5XQGJpLFfBTFj+vu5ZQgeeyAI6Wjbr/6pe3SzITvG0=", "narHash": "sha256-+5+fx76ucxUffw3AtzG56U/xTFk65RV+qIsBzBHjXzg=",
"owner": "gytis-ivaskevicius", "owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus", "repo": "flake-utils-plus",
"rev": "38f0103feadf93f949ca72579607a37601e34178", "rev": "e9cfad74a79430bfdd391a6073cc581c1b1504c8",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -41,7 +41,6 @@
importers = import ./src/importers.nix { importers = import ./src/importers.nix {
lib = combinedLib; lib = combinedLib;
inherit devshell;
}; };
generators = import ./src/generators.nix { generators = import ./src/generators.nix {
@ -51,7 +50,10 @@
mkFlake = { mkFlake = {
__functor = import ./src/mkFlake { lib = combinedLib; }; __functor = import ./src/mkFlake { lib = combinedLib; };
evalArgs = import ./src/mkFlake/evalArgs.nix { lib = combinedLib; }; evalArgs = import ./src/mkFlake/evalArgs.nix {
lib = combinedLib;
inherit devshell;
};
}; };
pkgs-lib = import ./src/pkgs-lib { pkgs-lib = import ./src/pkgs-lib {

View File

@ -1,4 +1,4 @@
{ lib, devshell }: { lib }:
let let
flattenTree = flattenTree =
/** /**
@ -189,13 +189,5 @@ in
(flattenTree (rakeLeaves dir)); (flattenTree (rakeLeaves dir));
}; };
maybeImportDevshellModule = item:
let isPath = builtins.isPath item || builtins.isString item; in
if isPath && lib.hasSuffix ".toml" item then
devshell.lib.importTOML item
else if isPath && lib.hasSuffix ".nix" then
import item
else item;
} }

View File

@ -81,10 +81,7 @@ lib.systemFlake (lib.mergeAny
homeModules = lib.exporters.modulesFromList cfg.home.modules; homeModules = lib.exporters.modulesFromList cfg.home.modules;
devshellModules = lib.exporters.modulesFromList { devshellModules = lib.exporters.modulesFromList cfg.devshell.modules;
paths = cfg.devshell.modules;
_import = lib.maybeImportDevshellModule;
};
overlays = lib.exporters.internalOverlays { overlays = lib.exporters.internalOverlays {
# since we can't detect overlays owned by self # since we can't detect overlays owned by self

View File

@ -1,4 +1,4 @@
{ lib }: { lib, devshell }:
{ args }: { args }:
let let
@ -7,9 +7,16 @@ let
cfg = config; cfg = config;
inherit (args) self; inherit (args) self;
maybeImportDevshellModule = path:
if lib.hasSuffix ".toml" path then
devshell.lib.importTOML path
else import path;
maybeImport = obj: maybeImport = obj:
if (builtins.isPath obj || builtins.isString obj) && lib.hasSuffix ".nix" obj then if (builtins.isPath obj || builtins.isString obj) then
import obj maybeImportDevshellModule obj
else else
obj; obj;
@ -20,11 +27,6 @@ let
description = "valid module"; description = "valid module";
}); });
# to export modules we need paths to get the name
exportModuleType = with types;
(addCheck path (x: moduleType.check (maybeImport x))) // {
description = "path to a module";
};
overlayType = pathTo (types.anything // { overlayType = pathTo (types.anything // {
check = builtins.isFunction; check = builtins.isFunction;
description = "valid Nixpkgs overlay"; description = "valid Nixpkgs overlay";
@ -128,7 +130,7 @@ let
exportModulesModule = name: { exportModulesModule = name: {
options = { options = {
modules = mkOption { modules = mkOption {
type = with types; pathTo (coercedListOf exportModuleType); type = with types; pathTo (coercedListOf moduleType);
default = [ ]; default = [ ];
description = '' description = ''
modules to include in all hosts and export to ${name}Modules output modules to include in all hosts and export to ${name}Modules output

View File

@ -29,7 +29,7 @@ let
configuration = { configuration = {
imports = [ (pkgs'.devshell.importTOML ./devshell.toml) ] imports = [ (pkgs'.devshell.importTOML ./devshell.toml) ]
++ (map lib.maybeImportDevshellModule extraModules); ++ extraModules;
packages = with installPkgs; [ packages = with installPkgs; [
nixos-install nixos-install