2021-04-19 06:29:28 +03:00
|
|
|
{ lib }:
|
|
|
|
|
2021-04-24 04:13:03 +03:00
|
|
|
{ self, inputs, args }:
|
2021-04-13 21:24:10 +03:00
|
|
|
let
|
2021-04-02 05:10:24 +03:00
|
|
|
argOpts = with lib; { config, options, ... }:
|
2021-04-13 21:24:10 +03:00
|
|
|
let
|
2021-04-18 04:35:05 +03:00
|
|
|
inherit (lib) os;
|
2021-04-13 21:24:10 +03:00
|
|
|
|
|
|
|
inherit (config) self;
|
|
|
|
|
|
|
|
inputAttrs = with types; functionTo attrs;
|
|
|
|
moduleType = with types; anything // {
|
|
|
|
inherit (submodule { }) check;
|
|
|
|
description = "valid module";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = with types; {
|
|
|
|
self = mkOption {
|
2021-04-02 05:10:24 +03:00
|
|
|
type = addCheck attrs lib.isStorePath;
|
2021-04-13 21:24:10 +03:00
|
|
|
description = "The flake to create the devos outputs for";
|
|
|
|
};
|
2021-04-19 07:48:19 +03:00
|
|
|
nixos = mkOption {
|
|
|
|
type = addCheck attrs lib.isStorePath;
|
|
|
|
description = "The default nixpkgs channel of the devos";
|
|
|
|
};
|
|
|
|
inputs = mkOption {
|
|
|
|
type = addCheck attrs lib.isStorePath;
|
|
|
|
description = "All inptus of the devos";
|
|
|
|
};
|
2021-04-13 21:24:10 +03:00
|
|
|
hosts = mkOption {
|
|
|
|
type = path;
|
2021-04-24 04:13:03 +03:00
|
|
|
default = "${self}/hosts";
|
|
|
|
defaultText = "\${self}/hosts";
|
2021-04-13 21:24:10 +03:00
|
|
|
apply = toString;
|
|
|
|
description = ''
|
|
|
|
Path to directory containing host configurations that will be exported
|
|
|
|
to the 'nixosConfigurations' output.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
packages = mkOption {
|
|
|
|
# functionTo changes arg names which breaks flake check
|
|
|
|
type = types.anything // {
|
|
|
|
check = builtins.isFunction;
|
|
|
|
description = "Nixpkgs overlay";
|
|
|
|
};
|
|
|
|
default = (final: prev: { });
|
|
|
|
defaultText = "(final: prev: {})";
|
|
|
|
description = ''
|
|
|
|
Overlay for custom packages that will be included in treewide 'pkgs'.
|
|
|
|
This should follow the standard nixpkgs overlay format - two argument function
|
|
|
|
that returns an attrset.
|
|
|
|
These packages will be exported to the 'packages' and 'legacyPackages' outputs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
modules = mkOption {
|
|
|
|
type = listOf moduleType;
|
|
|
|
default = [ ];
|
2021-04-18 04:35:05 +03:00
|
|
|
apply = lib.pathsToImportedAttrs;
|
2021-04-13 21:24:10 +03:00
|
|
|
description = ''
|
|
|
|
list of modules to include in confgurations and export in 'nixosModules' output
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
userModules = mkOption {
|
|
|
|
type = listOf moduleType;
|
|
|
|
default = [ ];
|
2021-04-18 04:35:05 +03:00
|
|
|
apply = lib.pathsToImportedAttrs;
|
2021-04-13 21:24:10 +03:00
|
|
|
description = ''
|
|
|
|
list of modules to include in home-manager configurations and export in
|
|
|
|
'homeModules' output
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
profiles = mkOption {
|
|
|
|
type = path;
|
2021-04-24 04:13:03 +03:00
|
|
|
default = "${self}/profiles";
|
|
|
|
defaultText = "\${self}/profiles";
|
2021-04-13 21:24:10 +03:00
|
|
|
apply = x: os.mkProfileAttrs (toString x);
|
|
|
|
description = "path to profiles folder that can be collected into suites";
|
|
|
|
};
|
|
|
|
userProfiles = mkOption {
|
|
|
|
type = path;
|
2021-04-24 04:13:03 +03:00
|
|
|
default = "${self}/users/profiles";
|
|
|
|
defaultText = "\${self}/users/profiles";
|
2021-04-13 21:24:10 +03:00
|
|
|
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 (config) profiles users userProfiles;
|
|
|
|
};
|
|
|
|
description = ''
|
|
|
|
Function with inputs 'users' and 'profiles' that returns attribute set
|
|
|
|
with user and system suites. The former for Home Manager and the latter
|
|
|
|
for nixos configurations.
|
|
|
|
These can be accessed through the 'suites' specialArg in each config system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
users = mkOption {
|
|
|
|
type = path;
|
2021-04-24 04:13:03 +03:00
|
|
|
default = "${self}/users";
|
|
|
|
defaultText = "\${self}/users";
|
2021-04-13 21:24:10 +03:00
|
|
|
apply = x: os.mkProfileAttrs (toString x);
|
|
|
|
description = ''
|
|
|
|
path to folder containing profiles that define system users
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
extern =
|
|
|
|
let
|
|
|
|
defaults = {
|
|
|
|
modules = [ ];
|
|
|
|
overlays = [ ];
|
|
|
|
specialArgs = { };
|
|
|
|
userModules = [ ];
|
|
|
|
userSpecialArgs = { };
|
|
|
|
};
|
|
|
|
in
|
|
|
|
mkOption {
|
|
|
|
type = inputAttrs;
|
|
|
|
default = { ... }: defaults;
|
|
|
|
defaultText = ''
|
|
|
|
{ modules = []; overlays = []; specialArgs = []; userModules = []; userSpecialArgs = []; }
|
|
|
|
'';
|
|
|
|
# So unneeded extern attributes can safely be deleted
|
2021-04-24 04:13:03 +03:00
|
|
|
apply = x: defaults // (x { inputs = inputs // self.inputs; });
|
2021-04-13 21:24:10 +03:00
|
|
|
description = ''
|
2021-04-24 04:13:03 +03:00
|
|
|
Function with argument 'inputs' that contains all devos and ''${self}'s inputs.
|
2021-04-13 21:24:10 +03:00
|
|
|
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;
|
2021-04-24 04:13:03 +03:00
|
|
|
default = "${self}/overlays";
|
|
|
|
defaultText = "\${self}/overlays";
|
2021-04-18 04:35:05 +03:00
|
|
|
apply = x: lib.pathsToImportedAttrs (lib.pathsIn (toString x));
|
2021-04-13 21:24:10 +03:00
|
|
|
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;
|
|
|
|
description = "attrset of packages and modules that will be pulled from nixpkgs master";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2021-04-02 05:10:24 +03:00
|
|
|
lib.evalModules {
|
2021-04-13 21:24:10 +03:00
|
|
|
modules = [ argOpts args ];
|
|
|
|
}
|