mirror of
https://github.com/nix-community/flakelight.git
synced 2025-02-08 13:39:29 +01:00
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, ... }:
|
{ config, options, src, lib, flakelight, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) attrNames;
|
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 (lib.types) attrsOf listOf str;
|
||||||
inherit (flakelight) autoImport;
|
inherit (flakelight) importDir;
|
||||||
inherit (flakelight.types) path;
|
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
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
12
default.nix
12
default.nix
@ -36,8 +36,8 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
flakelight = {
|
flakelight = {
|
||||||
inherit autoImport autoImportArgs mkFlake selectAttr supportedSystem
|
inherit autoImport autoImportArgs importDir mkFlake selectAttr
|
||||||
types;
|
supportedSystem types;
|
||||||
};
|
};
|
||||||
|
|
||||||
types = {
|
types = {
|
||||||
@ -114,8 +114,10 @@ let
|
|||||||
else if pathExists (path + "/${p}.nix") then "/${p}.nix"
|
else if pathExists (path + "/${p}.nix") then "/${p}.nix"
|
||||||
else "/${p}")));
|
else "/${p}")));
|
||||||
|
|
||||||
autoImport = dir: name:
|
autoImport = dir: name: warn
|
||||||
if isList name
|
("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)
|
then findFirst (x: x != null) null (map (autoImport dir) name)
|
||||||
else
|
else
|
||||||
if pathExists (dir + "/${name}.nix")
|
if pathExists (dir + "/${name}.nix")
|
||||||
@ -124,7 +126,7 @@ let
|
|||||||
then import (dir + "/${name}")
|
then import (dir + "/${name}")
|
||||||
else if pathExists (dir + "/${name}")
|
else if pathExists (dir + "/${name}")
|
||||||
then importDir (dir + "/${name}")
|
then importDir (dir + "/${name}")
|
||||||
else null;
|
else null);
|
||||||
|
|
||||||
autoImportArgs = dir: args: name: warn
|
autoImportArgs = dir: args: name: warn
|
||||||
("The autoImportArgs function is deprecated. " +
|
("The autoImportArgs function is deprecated. " +
|
||||||
|
Loading…
Reference in New Issue
Block a user