forked from extern/flakelight
Enable all options to be auto-loaded from nixDir
This removes the manual configuration of which options are auto-loaded. Now all options are eligible except for "nixDir" and "_module" as those would cause inf recursions. Additionally, instead of setting name aliases in the nixDir module, a config option is added, enabling other modules to extend the aliases lists.
This commit is contained in:
parent
11e65b623d
commit
4e9f53ff4e
@ -38,7 +38,8 @@ in
|
||||
default = { };
|
||||
};
|
||||
|
||||
config.outputs = mkIf (config.homeConfigurations != { }) {
|
||||
config = {
|
||||
outputs = mkIf (config.homeConfigurations != { }) {
|
||||
homeConfigurations = configs;
|
||||
checks = foldl recursiveUpdate { } (mapAttrsToList
|
||||
(n: v: {
|
||||
@ -46,4 +47,6 @@ in
|
||||
})
|
||||
configs);
|
||||
};
|
||||
nixDirAliases.homeConfigurations = [ "home" ];
|
||||
};
|
||||
}
|
||||
|
@ -2,76 +2,35 @@
|
||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
{ config, src, lib, flakelight, moduleArgs, ... }:
|
||||
{ config, options, src, lib, flakelight, ... }:
|
||||
let
|
||||
inherit (lib) mkOption mkIf mkMerge;
|
||||
inherit (flakelight) autoImport autoImportArgs;
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) genAttrs mkIf mkOption subtractLists;
|
||||
inherit (lib.types) attrsOf listOf str;
|
||||
inherit (flakelight) autoImport;
|
||||
inherit (flakelight.types) path;
|
||||
|
||||
autoImport' = autoImport config.nixDir;
|
||||
autoImportArgs' = autoImportArgs config.nixDir moduleArgs;
|
||||
in
|
||||
{
|
||||
options.nixDir = mkOption {
|
||||
options = {
|
||||
nixDir = mkOption {
|
||||
type = path;
|
||||
default = src + /nix;
|
||||
};
|
||||
|
||||
config =
|
||||
nixDirAliases = mkOption {
|
||||
type = attrsOf (listOf str);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = genAttrs (subtractLists [ "_module" "nixDir" ] (attrNames options))
|
||||
(name:
|
||||
let
|
||||
outputs = autoImport' "outputs";
|
||||
perSystem = autoImport' "perSystem";
|
||||
withOverlays = autoImport' "withOverlays";
|
||||
package = autoImport' "package";
|
||||
packages = autoImport' "packages";
|
||||
overlays = autoImport' "overlays";
|
||||
devShell = autoImport' "devShell";
|
||||
devShells = autoImport' "devShells";
|
||||
app = autoImport' "app";
|
||||
apps = autoImport' "apps";
|
||||
checks = autoImport' "checks";
|
||||
template = autoImport' "template";
|
||||
templates = autoImport' "templates";
|
||||
formatters = autoImport' "formatters";
|
||||
bundler = autoImport' "bundler";
|
||||
bundlers = autoImport' "bundlers";
|
||||
nixosModule = autoImport' "nixosModule";
|
||||
nixosModules = autoImport' "nixosModules";
|
||||
nixosConfigurations = autoImport' [ "nixosConfigurations" "nixos" ];
|
||||
homeModule = autoImport' "homeModule";
|
||||
homeModules = autoImport' "homeModules";
|
||||
homeConfigurations = autoImport' [ "homeConfigurations" "home" ];
|
||||
flakelightModule = autoImport' "flakelightModule";
|
||||
flakelightModules = autoImport' "flakelightModules";
|
||||
lib = autoImport' "lib";
|
||||
functor = autoImport' "functor";
|
||||
internal = options.${name}.internal or false;
|
||||
val = autoImport config.nixDir
|
||||
(if name == "nixDirAliases" then name else
|
||||
([ name ] ++ config.nixDirAliases.${name} or [ ]));
|
||||
cond = !internal && (val != null);
|
||||
in
|
||||
mkMerge [
|
||||
(mkIf (outputs != null) { inherit outputs; })
|
||||
(mkIf (perSystem != null) { inherit perSystem; })
|
||||
(mkIf (withOverlays != null) { inherit withOverlays; })
|
||||
(mkIf (package != null) { inherit package; })
|
||||
(mkIf (packages != null) { inherit packages; })
|
||||
(mkIf (overlays != null) { inherit overlays; })
|
||||
(mkIf (devShell != null) { inherit devShell; })
|
||||
(mkIf (devShells != null) { inherit devShells; })
|
||||
(mkIf (app != null) { inherit app; })
|
||||
(mkIf (apps != null) { inherit apps; })
|
||||
(mkIf (checks != null) { inherit checks; })
|
||||
(mkIf (template != null) { inherit template; })
|
||||
(mkIf (templates != null) { inherit templates; })
|
||||
(mkIf (formatters != null) { inherit formatters; })
|
||||
(mkIf (bundler != null) { inherit bundler; })
|
||||
(mkIf (bundlers != null) { inherit bundlers; })
|
||||
(mkIf (nixosModule != null) { inherit nixosModule; })
|
||||
(mkIf (nixosModules != null) { inherit nixosModules; })
|
||||
(mkIf (nixosConfigurations != null) { inherit nixosConfigurations; })
|
||||
(mkIf (homeModule != null) { inherit homeModule; })
|
||||
(mkIf (homeModules != null) { inherit homeModules; })
|
||||
(mkIf (homeConfigurations != null) { inherit homeConfigurations; })
|
||||
(mkIf (flakelightModule != null) { inherit flakelightModule; })
|
||||
(mkIf (flakelightModules != null) { inherit flakelightModules; })
|
||||
(mkIf (lib != null) { inherit lib; })
|
||||
(mkIf (functor != null) { inherit functor; })
|
||||
];
|
||||
mkIf cond (if cond then val else { }));
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ in
|
||||
default = { };
|
||||
};
|
||||
|
||||
config.outputs = mkIf (config.nixosConfigurations != { }) {
|
||||
config = {
|
||||
outputs = mkIf (config.nixosConfigurations != { }) {
|
||||
nixosConfigurations = configs;
|
||||
checks = foldl recursiveUpdate { } (mapAttrsToList
|
||||
(n: v: {
|
||||
@ -44,4 +45,6 @@ in
|
||||
})
|
||||
configs);
|
||||
};
|
||||
nixDirAliases.nixosConfigurations = [ "nixos" ];
|
||||
};
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ let
|
||||
inherit (flakelight.types) module;
|
||||
in
|
||||
{
|
||||
options.propagationModule = mkOption { type = module; };
|
||||
options.propagationModule = mkOption { type = module; internal = true; };
|
||||
|
||||
config.propagationModule =
|
||||
{ lib, pkgs, options, ... }:
|
||||
|
Loading…
Reference in New Issue
Block a user