forked from extern/flakelight
Deprecate autoImport lib function
As all options are now automatically used for nixDir, modules no longer need to set up their own autoImports.
This commit is contained in:
parent
4e9f53ff4e
commit
3b7188863d
@ -5,10 +5,23 @@
|
||||
{ config, options, src, lib, flakelight, ... }:
|
||||
let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) genAttrs mkIf mkOption subtractLists;
|
||||
inherit (lib) findFirst genAttrs isList mkIf mkOption pathExists
|
||||
subtractLists;
|
||||
inherit (lib.types) attrsOf listOf str;
|
||||
inherit (flakelight) autoImport;
|
||||
inherit (flakelight) importDir;
|
||||
inherit (flakelight.types) path;
|
||||
|
||||
autoImport = dir: name:
|
||||
if isList name
|
||||
then findFirst (x: x != null) null (map (autoImport dir) name)
|
||||
else
|
||||
if pathExists (dir + "/${name}.nix")
|
||||
then import (dir + "/${name}.nix")
|
||||
else if pathExists (dir + "/${name}/default.nix")
|
||||
then import (dir + "/${name}")
|
||||
else if pathExists (dir + "/${name}")
|
||||
then importDir (dir + "/${name}")
|
||||
else null;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
12
default.nix
12
default.nix
@ -36,8 +36,8 @@ let
|
||||
};
|
||||
|
||||
flakelight = {
|
||||
inherit autoImport autoImportArgs mkFlake selectAttr supportedSystem
|
||||
types;
|
||||
inherit autoImport autoImportArgs importDir mkFlake selectAttr
|
||||
supportedSystem types;
|
||||
};
|
||||
|
||||
types = {
|
||||
@ -114,8 +114,10 @@ let
|
||||
else if pathExists (path + "/${p}.nix") then "/${p}.nix"
|
||||
else "/${p}")));
|
||||
|
||||
autoImport = dir: name:
|
||||
if isList name
|
||||
autoImport = dir: name: warn
|
||||
("The autoImport function is deprecated. " +
|
||||
"All options are now automatically auto-loaded.")
|
||||
(if isList name
|
||||
then findFirst (x: x != null) null (map (autoImport dir) name)
|
||||
else
|
||||
if pathExists (dir + "/${name}.nix")
|
||||
@ -124,7 +126,7 @@ let
|
||||
then import (dir + "/${name}")
|
||||
else if pathExists (dir + "/${name}")
|
||||
then importDir (dir + "/${name}")
|
||||
else null;
|
||||
else null);
|
||||
|
||||
autoImportArgs = dir: args: name: warn
|
||||
("The autoImportArgs function is deprecated. " +
|
||||
|
Loading…
Reference in New Issue
Block a user