Merge pull request #239 from Pacman99/evalargs-next
Update evalArgs to match the new planned API
This commit is contained in:
commit
8d0c036b6b
|
@ -1,65 +1,162 @@
|
||||||
{ self, dev, nixos, inputs, ... }:
|
{ self, dev, nixos, inputs, utils, ... }:
|
||||||
|
|
||||||
{ args }:
|
{ args }:
|
||||||
let
|
let
|
||||||
argOpts = with nixos.lib; { config, options, ... }:
|
argOpts = with nixos.lib; { config, ... }:
|
||||||
let
|
let
|
||||||
inherit (dev) os;
|
inherit (dev) os;
|
||||||
|
|
||||||
inherit (config) self;
|
inherit (config) self;
|
||||||
|
|
||||||
inputAttrs = with types; functionTo attrs;
|
maybeImport = obj:
|
||||||
|
if (builtins.typeOf obj == "path") || (builtins.typeOf obj == "string") then
|
||||||
|
import obj
|
||||||
|
else
|
||||||
|
obj;
|
||||||
|
|
||||||
|
/* Custom types needed for arguments */
|
||||||
|
|
||||||
moduleType = with types; anything // {
|
moduleType = with types; anything // {
|
||||||
inherit (submodule { }) check;
|
inherit (submodule { }) check;
|
||||||
description = "valid module";
|
description = "valid module";
|
||||||
};
|
};
|
||||||
in
|
overlayType = types.anything // {
|
||||||
{
|
check = builtins.isFunction;
|
||||||
options = with types; {
|
description = "valid Nixpkgs overlay";
|
||||||
self = mkOption {
|
|
||||||
type = addCheck attrs nixos.lib.isStorePath;
|
|
||||||
description = "The flake to create the devos outputs for";
|
|
||||||
};
|
};
|
||||||
hosts = mkOption {
|
systemType = types.enum (builtins.attrValues config.supportedSystems);
|
||||||
type = path;
|
flakeType = with types; (addCheck attrs nixos.lib.isStorePath) // {
|
||||||
default = "${self}/hosts";
|
description = "nix flake";
|
||||||
defaultText = "\${self}/hosts";
|
};
|
||||||
apply = toString;
|
|
||||||
|
# Applys maybeImport during merge and before check
|
||||||
|
# To simplify apply keys and improve type checking
|
||||||
|
pathTo = elemType: mkOptionType {
|
||||||
|
name = "pathTo";
|
||||||
|
description = "path that evaluates to a(n) ${elemType.name}";
|
||||||
|
check = x: elemType.check (maybeImport x);
|
||||||
|
merge = loc: defs:
|
||||||
|
(mergeDefinitions loc elemType (map
|
||||||
|
(x: {
|
||||||
|
inherit (x) file;
|
||||||
|
value = maybeImport x.value;
|
||||||
|
})
|
||||||
|
defs)).mergedValue;
|
||||||
|
getSubOptions = elemType.getSubOptions;
|
||||||
|
getSubModules = elemType.getSubModules;
|
||||||
|
substSubModules = m: pathTo (elemType.substSubModules m);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Submodules needed for API containers */
|
||||||
|
|
||||||
|
channelsModule = {
|
||||||
|
options = with types; {
|
||||||
|
input = mkOption {
|
||||||
|
type = flakeType;
|
||||||
|
default = inputs.nixos;
|
||||||
description = ''
|
description = ''
|
||||||
Path to directory containing host configurations that will be exported
|
nixpkgs flake input to use for this channel
|
||||||
to the 'nixosConfigurations' output.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
packages = mkOption {
|
overlays = mkOption {
|
||||||
# functionTo changes arg names which breaks flake check
|
type = pathTo (listOf overlayType);
|
||||||
type = types.anything // {
|
default = [ ];
|
||||||
check = builtins.isFunction;
|
|
||||||
description = "Nixpkgs overlay";
|
|
||||||
};
|
|
||||||
default = (final: prev: { });
|
|
||||||
defaultText = "(final: prev: {})";
|
|
||||||
description = ''
|
description = ''
|
||||||
Overlay for custom packages that will be included in treewide 'pkgs'.
|
overlays to apply to this channel
|
||||||
This should follow the standard nixpkgs overlay format - two argument function
|
these will get exported under the 'overlays' flake output as <channel>/<name>
|
||||||
that returns an attrset.
|
'';
|
||||||
These packages will be exported to the 'packages' and 'legacyPackages' outputs.
|
};
|
||||||
|
externalOverlays = mkOption {
|
||||||
|
type = pathTo (listOf overlayType);
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
overlays to apply to the channel that don't get exported to the flake output
|
||||||
|
useful to include overlays from inputs
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
config = mkOption {
|
||||||
|
type = pathTo attrs;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
nixpkgs config for this channel
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
configModule = { name, ... }: {
|
||||||
|
options = with types; {
|
||||||
|
system = mkOption {
|
||||||
|
type = systemType;
|
||||||
|
default = "x86_64-linux";
|
||||||
|
description = ''
|
||||||
|
system for this config
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
channelName = mkOption {
|
||||||
|
type = types.enum (builtins.attrValues self.channels);
|
||||||
|
default = "nixpkgs";
|
||||||
|
description = ''
|
||||||
|
Channel this config should follow
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
modules = mkOption {
|
modules = mkOption {
|
||||||
type = listOf moduleType;
|
type = pathTo moduleType;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
apply = dev.pathsToImportedAttrs;
|
|
||||||
description = ''
|
description = ''
|
||||||
list of modules to include in confgurations and export in 'nixosModules' output
|
The configuration for this config
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
userModules = mkOption {
|
externalmodules = mkOption {
|
||||||
type = listOf moduleType;
|
type = pathTo moduleType;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
The configuration for this config
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Home-manager's configs get exported automatically from nixos.hosts
|
||||||
|
# So there is no need for a config options in the home namespace
|
||||||
|
# This is only needed for nixos
|
||||||
|
includeConfigsModule = {
|
||||||
|
options = with types; {
|
||||||
|
configDefaults = mkOption {
|
||||||
|
type = submodule configModule;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
defaults for all configs
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
configs = mkOption {
|
||||||
|
type = pathTo (attrsOf (submodule configModule));
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
configurations to include in the ${name}Configurations output
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Options to import: modules, profiles, suites
|
||||||
|
importsModule = { name, ... }: {
|
||||||
|
options = with types; {
|
||||||
|
modules = mkOption {
|
||||||
|
type = pathTo (listOf moduleType);
|
||||||
default = [ ];
|
default = [ ];
|
||||||
apply = dev.pathsToImportedAttrs;
|
apply = dev.pathsToImportedAttrs;
|
||||||
description = ''
|
description = ''
|
||||||
list of modules to include in home-manager configurations and export in
|
list of modules to include in confgurations and export in '${name}Modules' output
|
||||||
'homeModules' output
|
'';
|
||||||
|
};
|
||||||
|
externalModules = mkOption {
|
||||||
|
type = pathTo (listOf moduleType);
|
||||||
|
default = [ ];
|
||||||
|
apply = dev.pathsToImportedAttrs;
|
||||||
|
description = ''
|
||||||
|
list of modules to include in confguration but these are not exported to the '${name}Modules' output
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
profiles = mkOption {
|
profiles = mkOption {
|
||||||
|
@ -69,82 +166,64 @@ let
|
||||||
apply = x: os.mkProfileAttrs (toString x);
|
apply = x: os.mkProfileAttrs (toString x);
|
||||||
description = "path to profiles folder that can be collected into suites";
|
description = "path to profiles folder that can be collected into suites";
|
||||||
};
|
};
|
||||||
userProfiles = mkOption {
|
suites = mkOption {
|
||||||
type = path;
|
type = pathTo (functionTo attrs);
|
||||||
default = "${self}/users/profiles";
|
default = _: { };
|
||||||
defaultText = "\${self}/users/profiles";
|
apply = suites: os.mkSuites {
|
||||||
apply = x: os.mkProfileAttrs (toString x);
|
|
||||||
description = "path to user profiles folder that can be collected into userSuites";
|
|
||||||
};
|
|
||||||
suites =
|
|
||||||
let
|
|
||||||
defaults = { user = { }; system = { }; };
|
|
||||||
in
|
|
||||||
mkOption {
|
|
||||||
type = inputAttrs;
|
|
||||||
default = { ... }: defaults;
|
|
||||||
defaultText = "{ user = {}; system = {}; }";
|
|
||||||
apply = suites: defaults // os.mkSuites {
|
|
||||||
inherit suites;
|
inherit suites;
|
||||||
inherit (config) profiles users userProfiles;
|
inherit (config) profiles;
|
||||||
};
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Function with inputs 'users' and 'profiles' that returns attribute set
|
Function with the input of 'profiles' that returns an attribute set
|
||||||
with user and system suites. The former for Home Manager and the latter
|
with the suites for this config system.
|
||||||
for nixos configurations.
|
These can be accessed through the 'suites' special argument.
|
||||||
These can be accessed through the 'suites' specialArg in each config system.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
users = mkOption {
|
};
|
||||||
type = path;
|
};
|
||||||
default = "${self}/users";
|
in
|
||||||
defaultText = "\${self}/users";
|
{
|
||||||
apply = x: os.mkProfileAttrs (toString x);
|
options = with types; {
|
||||||
|
self = mkOption {
|
||||||
|
type = flakeType;
|
||||||
|
description = "The flake to create the devos outputs for";
|
||||||
|
};
|
||||||
|
supportedSystems = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = utils.lib.defaultSystems;
|
||||||
description = ''
|
description = ''
|
||||||
path to folder containing profiles that define system users
|
The systems supported by this flake
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
extern =
|
channels =
|
||||||
let
|
let
|
||||||
defaults = {
|
default = {
|
||||||
modules = [ ];
|
nixpkgs = {
|
||||||
overlays = [ ];
|
input = inputs.nixos;
|
||||||
specialArgs = { };
|
};
|
||||||
userModules = [ ];
|
|
||||||
userSpecialArgs = { };
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
mkOption {
|
mkOption {
|
||||||
type = inputAttrs;
|
type = attrsOf (submodule channelsModule);
|
||||||
default = { ... }: defaults;
|
inherit default;
|
||||||
defaultText = ''
|
|
||||||
{ modules = []; overlays = []; specialArgs = []; userModules = []; userSpecialArgs = []; }
|
|
||||||
'';
|
|
||||||
# So unneeded extern attributes can safely be deleted
|
|
||||||
apply = x: defaults // (x { inputs = inputs // self.inputs; });
|
|
||||||
description = ''
|
|
||||||
Function with argument 'inputs' that contains all devos and ''${self}'s inputs.
|
|
||||||
The function should return an attribute set with modules, overlays, and
|
|
||||||
specialArgs to be included across nixos and home manager configurations.
|
|
||||||
Only attributes that are used should be returned.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
overlays = mkOption {
|
|
||||||
type = path;
|
|
||||||
default = "${self}/overlays";
|
|
||||||
defaultText = "\${self}/overlays";
|
|
||||||
apply = x: dev.pathsToImportedAttrs (dev.pathsIn (toString x));
|
|
||||||
description = ''
|
|
||||||
path to folder containing overlays which will be applied to pkgs and exported in
|
|
||||||
the 'overlays' output
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
overrides = mkOption rec {
|
|
||||||
type = attrs;
|
|
||||||
default = { modules = [ ]; disabledModules = [ ]; packages = _: _: _: { }; };
|
|
||||||
defaultText = "{ modules = []; disabledModules = []; packages = {}; }";
|
|
||||||
apply = x: default // x;
|
apply = x: default // x;
|
||||||
description = "attrset of packages and modules that will be pulled from nixpkgs master";
|
description = ''
|
||||||
|
nixpkgs channels to create
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
nixos = mkOption {
|
||||||
|
type = submodule [ includeConfigsModule importsModule ];
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
hosts, modules, suites, and profiles for nixos
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
home = mkOption {
|
||||||
|
type = submodule importsModule;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
hosts, modules, suites, and profiles for home-manager
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue