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"
},
"locked": {
"lastModified": 1623691375,
"narHash": "sha256-y5XQGJpLFfBTFj+vu5ZQgeeyAI6Wjbr/6pe3SzITvG0=",
"lastModified": 1623776596,
"narHash": "sha256-+5+fx76ucxUffw3AtzG56U/xTFk65RV+qIsBzBHjXzg=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "38f0103feadf93f949ca72579607a37601e34178",
"rev": "e9cfad74a79430bfdd391a6073cc581c1b1504c8",
"type": "github"
},
"original": {

View File

@ -41,7 +41,6 @@
importers = import ./src/importers.nix {
lib = combinedLib;
inherit devshell;
};
generators = import ./src/generators.nix {
@ -51,7 +50,10 @@
mkFlake = {
__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 {

View File

@ -1,4 +1,4 @@
{ lib, devshell }:
{ lib }:
let
flattenTree =
/**
@ -189,13 +189,5 @@ in
(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;
devshellModules = lib.exporters.modulesFromList {
paths = cfg.devshell.modules;
_import = lib.maybeImportDevshellModule;
};
devshellModules = lib.exporters.modulesFromList cfg.devshell.modules;
overlays = lib.exporters.internalOverlays {
# since we can't detect overlays owned by self

View File

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

View File

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