mirror of
https://github.com/nix-community/flakelight.git
synced 2024-11-21 23:13:09 +01:00
Make direct and auto-loaded configuration consistent
Many attributes can take moduleArgs when auto-loaded in order to facilitate access to them from other files. Those same attributes could not take moduleArgs when included directly, which was inconsistent. With this change, all attributes that could take moduleArgs when auto-loaded can now always do so. Auto-loading no longer needs special cases.
This commit is contained in:
parent
bb0080c21c
commit
589ee5ba7a
@ -10,7 +10,7 @@ let
|
|||||||
inherit (lib.types) coercedTo functionTo lazyAttrsOf lines listOf nullOr
|
inherit (lib.types) coercedTo functionTo lazyAttrsOf lines listOf nullOr
|
||||||
package str submodule;
|
package str submodule;
|
||||||
inherit (flakelight) supportedSystem;
|
inherit (flakelight) supportedSystem;
|
||||||
inherit (flakelight.types) function optFunctionTo packageDef;
|
inherit (flakelight.types) function optCallWith optFunctionTo packageDef;
|
||||||
|
|
||||||
devShellModule.options = {
|
devShellModule.options = {
|
||||||
inputsFrom = mkOption {
|
inputsFrom = mkOption {
|
||||||
@ -59,7 +59,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
devShells = mkOption {
|
devShells = mkOption {
|
||||||
type = lazyAttrsOf packageDef;
|
type = optCallWith moduleArgs (lazyAttrsOf packageDef);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{ config, lib, flakelight, ... }:
|
{ config, lib, flakelight, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption mkIf mkMerge;
|
inherit (lib) mkOption mkIf mkMerge;
|
||||||
inherit (lib.types) lazyAttrsOf nullOr;
|
inherit (lib.types) lazyAttrsOf nullOr;
|
||||||
inherit (flakelight.types) module;
|
inherit (flakelight.types) module optCallWith;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@ -16,7 +16,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
flakelightModules = mkOption {
|
flakelightModules = mkOption {
|
||||||
type = lazyAttrsOf module;
|
type = optCallWith moduleArgs (lazyAttrsOf module);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.homeConfigurations = mkOption {
|
options.homeConfigurations = mkOption {
|
||||||
type = lazyAttrsOf (optCallWith moduleArgs attrs);
|
type = optCallWith moduleArgs (lazyAttrsOf (optCallWith moduleArgs attrs));
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{ config, lib, flakelight, ... }:
|
{ config, lib, flakelight, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption mkIf mkMerge;
|
inherit (lib) mkOption mkIf mkMerge;
|
||||||
inherit (lib.types) lazyAttrsOf nullOr;
|
inherit (lib.types) lazyAttrsOf nullOr;
|
||||||
inherit (flakelight.types) module;
|
inherit (flakelight.types) module optCallWith;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@ -16,7 +16,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
homeModules = mkOption {
|
homeModules = mkOption {
|
||||||
type = lazyAttrsOf module;
|
type = optCallWith moduleArgs (lazyAttrsOf module);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -2,14 +2,15 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{ config, lib, ... }:
|
{ config, lib, flakelight, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption mkIf;
|
inherit (lib) mkOption mkIf;
|
||||||
inherit (lib.types) attrsOf raw;
|
inherit (lib.types) attrsOf raw;
|
||||||
|
inherit (flakelight.types) optCallWith;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.lib = mkOption {
|
options.lib = mkOption {
|
||||||
type = attrsOf raw;
|
type = optCallWith moduleArgs (attrsOf raw);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,27 +23,27 @@ in
|
|||||||
perSystem = autoImport' "perSystem";
|
perSystem = autoImport' "perSystem";
|
||||||
withOverlays = autoImport' "withOverlays";
|
withOverlays = autoImport' "withOverlays";
|
||||||
package = autoImport' "package";
|
package = autoImport' "package";
|
||||||
packages = autoImportArgs' "packages";
|
packages = autoImport' "packages";
|
||||||
overlays = autoImportArgs' "overlays";
|
overlays = autoImport' "overlays";
|
||||||
devShell = autoImport' "devShell";
|
devShell = autoImport' "devShell";
|
||||||
devShells = autoImportArgs' "devShells";
|
devShells = autoImport' "devShells";
|
||||||
app = autoImport' "app";
|
app = autoImport' "app";
|
||||||
apps = autoImport' "apps";
|
apps = autoImport' "apps";
|
||||||
checks = autoImport' "checks";
|
checks = autoImport' "checks";
|
||||||
template = autoImportArgs' "template";
|
template = autoImport' "template";
|
||||||
templates = autoImportArgs' "templates";
|
templates = autoImport' "templates";
|
||||||
formatters = autoImport' "formatters";
|
formatters = autoImport' "formatters";
|
||||||
bundler = autoImport' "bundler";
|
bundler = autoImport' "bundler";
|
||||||
bundlers = autoImport' "bundlers";
|
bundlers = autoImport' "bundlers";
|
||||||
nixosModule = autoImport' "nixosModule";
|
nixosModule = autoImport' "nixosModule";
|
||||||
nixosModules = autoImportArgs' "nixosModules";
|
nixosModules = autoImport' "nixosModules";
|
||||||
nixosConfigurations = autoImportArgs' [ "nixosConfigurations" "nixos" ];
|
nixosConfigurations = autoImport' [ "nixosConfigurations" "nixos" ];
|
||||||
homeModule = autoImport' "homeModule";
|
homeModule = autoImport' "homeModule";
|
||||||
homeModules = autoImportArgs' "homeModules";
|
homeModules = autoImport' "homeModules";
|
||||||
homeConfigurations = autoImportArgs' [ "homeConfigurations" "home" ];
|
homeConfigurations = autoImport' [ "homeConfigurations" "home" ];
|
||||||
flakelightModule = autoImport' "flakelightModule";
|
flakelightModule = autoImport' "flakelightModule";
|
||||||
flakelightModules = autoImportArgs' "flakelightModules";
|
flakelightModules = autoImport' "flakelightModules";
|
||||||
lib = autoImportArgs' "lib";
|
lib = autoImport' "lib";
|
||||||
functor = autoImport' "functor";
|
functor = autoImport' "functor";
|
||||||
in
|
in
|
||||||
mkMerge [
|
mkMerge [
|
||||||
|
@ -28,7 +28,7 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.nixosConfigurations = mkOption {
|
options.nixosConfigurations = mkOption {
|
||||||
type = lazyAttrsOf (optCallWith moduleArgs attrs);
|
type = optCallWith moduleArgs (lazyAttrsOf (optCallWith moduleArgs attrs));
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{ config, lib, flakelight, ... }:
|
{ config, lib, flakelight, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption mkIf mkMerge;
|
inherit (lib) mkOption mkIf mkMerge;
|
||||||
inherit (lib.types) lazyAttrsOf nullOr;
|
inherit (lib.types) lazyAttrsOf nullOr;
|
||||||
inherit (flakelight.types) module;
|
inherit (flakelight.types) module optCallWith;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@ -16,7 +16,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
nixosModules = mkOption {
|
nixosModules = mkOption {
|
||||||
type = lazyAttrsOf module;
|
type = optCallWith moduleArgs (lazyAttrsOf module);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{ config, lib, flakelight, ... }:
|
{ config, lib, flakelight, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkMerge mkOption mkIf;
|
inherit (lib) mkMerge mkOption mkIf;
|
||||||
inherit (lib.types) lazyAttrsOf nullOr;
|
inherit (lib.types) lazyAttrsOf nullOr;
|
||||||
inherit (flakelight.types) overlay;
|
inherit (flakelight.types) optCallWith overlay;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@ -16,7 +16,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
overlays = mkOption {
|
overlays = mkOption {
|
||||||
type = lazyAttrsOf overlay;
|
type = optCallWith moduleArgs (lazyAttrsOf overlay);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{ config, lib, inputs, flakelight, genSystems, ... }:
|
{ config, lib, inputs, flakelight, genSystems, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) parseDrvName tryEval;
|
inherit (builtins) parseDrvName tryEval;
|
||||||
inherit (lib) filterAttrs findFirst mapAttrs mapAttrs' mkIf mkMerge mkOption
|
inherit (lib) filterAttrs findFirst mapAttrs mapAttrs' mkIf mkMerge mkOption
|
||||||
nameValuePair optionalAttrs;
|
nameValuePair optionalAttrs;
|
||||||
inherit (lib.types) lazyAttrsOf nullOr str uniq;
|
inherit (lib.types) lazyAttrsOf nullOr str uniq;
|
||||||
inherit (flakelight) supportedSystem;
|
inherit (flakelight) supportedSystem;
|
||||||
inherit (flakelight.types) overlay packageDef;
|
inherit (flakelight.types) optCallWith overlay packageDef;
|
||||||
|
|
||||||
genPkg = pkgs: pkg: pkgs.callPackage pkg { };
|
genPkg = pkgs: pkg: pkgs.callPackage pkg { };
|
||||||
genPkgs = pkgs: mapAttrs (_: genPkg pkgs) config.packages;
|
genPkgs = pkgs: mapAttrs (_: genPkg pkgs) config.packages;
|
||||||
@ -22,7 +22,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
packages = mkOption {
|
packages = mkOption {
|
||||||
type = lazyAttrsOf packageDef;
|
type = optCallWith moduleArgs (lazyAttrsOf packageDef);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{ config, lib, ... }:
|
{ config, lib, flakelight, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) isPath isString;
|
inherit (builtins) isPath isString;
|
||||||
inherit (lib) mkOption mkOptionType mkIf mkMerge;
|
inherit (lib) mkOption mkOptionType mkIf mkMerge;
|
||||||
inherit (lib.types) lazyAttrsOf nullOr;
|
inherit (lib.types) lazyAttrsOf nullOr;
|
||||||
inherit (lib.options) mergeEqualOption;
|
inherit (lib.options) mergeEqualOption;
|
||||||
|
inherit (flakelight.types) optCallWith;
|
||||||
|
|
||||||
template = mkOptionType {
|
template = mkOptionType {
|
||||||
name = "template";
|
name = "template";
|
||||||
@ -22,12 +23,12 @@ in
|
|||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
template = mkOption {
|
template = mkOption {
|
||||||
type = nullOr template;
|
type = nullOr (optCallWith moduleArgs template);
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
templates = mkOption {
|
templates = mkOption {
|
||||||
type = lazyAttrsOf template;
|
type = optCallWith moduleArgs (lazyAttrsOf template);
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
12
default.nix
12
default.nix
@ -9,7 +9,7 @@ let
|
|||||||
inherit (nixpkgs.lib) attrNames composeManyExtensions evalModules filter
|
inherit (nixpkgs.lib) attrNames composeManyExtensions evalModules filter
|
||||||
findFirst fix genAttrs getValues hasSuffix isFunction isList mapAttrs
|
findFirst fix genAttrs getValues hasSuffix isFunction isList mapAttrs
|
||||||
mapAttrsToList mkDefault mkOptionType pathExists pipe removePrefix
|
mapAttrsToList mkDefault mkOptionType pathExists pipe removePrefix
|
||||||
removeSuffix singleton;
|
removeSuffix singleton warn;
|
||||||
inherit (nixpkgs.lib.types) coercedTo functionTo listOf;
|
inherit (nixpkgs.lib.types) coercedTo functionTo listOf;
|
||||||
inherit (nixpkgs.lib.options) mergeEqualOption mergeOneOption;
|
inherit (nixpkgs.lib.options) mergeEqualOption mergeOneOption;
|
||||||
|
|
||||||
@ -126,9 +126,13 @@ let
|
|||||||
then importDir (dir + "/${name}")
|
then importDir (dir + "/${name}")
|
||||||
else null;
|
else null;
|
||||||
|
|
||||||
autoImportArgs = dir: args: name:
|
autoImportArgs = dir: args: name: warn
|
||||||
let v = autoImport dir name; in
|
("The autoImportArgs function is deprecated. " +
|
||||||
if isFunction v then v args else v;
|
"Wrap the target type in flakelight.types.optCallWith instead.")
|
||||||
|
(
|
||||||
|
let v = autoImport dir name; in
|
||||||
|
if isFunction v then v args else v
|
||||||
|
);
|
||||||
|
|
||||||
selectAttr = attr: mapAttrs (_: v: v.${attr} or { });
|
selectAttr = attr: mapAttrs (_: v: v.${attr} or { });
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user