mirror of
https://github.com/divnix/digga.git
synced 2024-12-23 16:11:51 +03:00
Replace profiles/suites with general importables
profiles and suites is created with the old mkProfileAttrs, this makes the new auto-importing strategies backwards compatible. But warnings are printed when using profiles and suites instructing you on how to switch your profiles folder format and add suites to importables
This commit is contained in:
parent
271cfd0c18
commit
e838f60e29
@ -100,8 +100,7 @@ in
|
||||
''
|
||||
mkProfileAttrs;
|
||||
|
||||
# DEPRECATED, profiles in suites are type-checked in evalArgs
|
||||
# both versions of `profileMap` are no longer necessary
|
||||
# DEPRECATED, both versions of `profileMap` are no longer necessary
|
||||
# paths are type-checked for suites in evalArgs
|
||||
# and `.default` isn't special with `rakeLeaves`
|
||||
/** profileMap = list: map
|
||||
|
@ -16,7 +16,7 @@ let
|
||||
|
||||
defaultModules = with lib.modules; [
|
||||
(hmDefaults {
|
||||
inherit (cfg.home) suites;
|
||||
specialArgs = cfg.home.importables;
|
||||
modules = cfg.home.modules ++ cfg.home.externalModules;
|
||||
})
|
||||
(globalDefaults {
|
||||
@ -63,7 +63,7 @@ lib.systemFlake (lib.mergeAny
|
||||
})
|
||||
];
|
||||
hostDefaults = lib.mergeAny hostDefaults {
|
||||
specialArgs.suites = cfg.nixos.suites;
|
||||
specialArgs = cfg.nixos.importables;
|
||||
modules = cfg.nixos.hostDefaults.externalModules ++ defaultModules;
|
||||
builder = args: args.specialArgs.channel.input.lib.nixosSystem (lib.mergeAny args {
|
||||
# So modules and functions can create their own version of the build
|
||||
|
@ -168,29 +168,62 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
# profiles and suites - which are profile collections
|
||||
profilesModule = { config, ... }: {
|
||||
suitesDeprecationMessage = ''
|
||||
WARNING: The 'suites' and `profiles` options have been deprecated, you can now create
|
||||
both with the importables option. `rakeLeaves` can be used to create profiles and
|
||||
by passing a module or `rec` set to `importables`, suites can access profiles.
|
||||
Example:
|
||||
```
|
||||
importables = rec {
|
||||
profiles = digga.lib.importers.rakeLeaves ./profiles;
|
||||
suites = with profiles; { };
|
||||
}
|
||||
```
|
||||
See https://github.com/divnix/digga/pull/30 for more details
|
||||
'';
|
||||
importablesModule = { config, options, ... }: {
|
||||
config = {
|
||||
importables = mkIf options.suites.isDefined {
|
||||
suites = builtins.trace suitesDeprecationMessage config.suites;
|
||||
};
|
||||
};
|
||||
options = with types; {
|
||||
profiles = mkOption {
|
||||
type = listOf path;
|
||||
default = [ ];
|
||||
description = ''
|
||||
profile folders that can be collected into suites
|
||||
the name of the argument passed to suites is based
|
||||
on the folder name.
|
||||
[ ./profiles ] => { profiles }:
|
||||
'';
|
||||
description = suitesDeprecationMessage;
|
||||
};
|
||||
suites = mkOption {
|
||||
type = pathTo (functionTo attrs);
|
||||
default = _: { };
|
||||
apply = suites: lib.mkSuites {
|
||||
inherit suites;
|
||||
inherit (config) profiles;
|
||||
};
|
||||
description = suitesDeprecationMessage;
|
||||
};
|
||||
importables = mkOption {
|
||||
type = submoduleWith {
|
||||
modules = [{
|
||||
freeformType = attrs;
|
||||
options = {
|
||||
suites = mkOption {
|
||||
type = attrsOf (listOf path);
|
||||
# add `allProfiles` to it here
|
||||
apply = suites: suites // {
|
||||
allProfiles = lib.foldl
|
||||
(lhs: rhs: lhs ++ rhs) [ ]
|
||||
(builtins.attrValues suites);
|
||||
};
|
||||
description = ''
|
||||
Function that takes profiles and returns suites for this config system
|
||||
These can be accessed through the 'suites' special argument.
|
||||
collections of profiles
|
||||
'';
|
||||
};
|
||||
};
|
||||
}];
|
||||
};
|
||||
default = { };
|
||||
description = ''
|
||||
Packages of paths to be passed to modules as `specialArgs`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
@ -248,7 +281,7 @@ let
|
||||
nixos = mkOption {
|
||||
type = submoduleWith {
|
||||
# allows easy use of the `imports` key
|
||||
modules = [ (includeHostsModule "nixos") profilesModule ];
|
||||
modules = [ (includeHostsModule "nixos") importablesModule ];
|
||||
};
|
||||
default = { };
|
||||
description = ''
|
||||
@ -259,7 +292,7 @@ let
|
||||
type = submoduleWith {
|
||||
# allows easy use of the `imports` key
|
||||
modules = [
|
||||
profilesModule
|
||||
importablesModule
|
||||
(exportModulesModule "home")
|
||||
externalModulesModule
|
||||
];
|
||||
|
@ -1,13 +1,13 @@
|
||||
{ lib }:
|
||||
{
|
||||
hmDefaults = { suites, modules }:
|
||||
hmDefaults = { specialArgs, modules }:
|
||||
{ options, ... }: {
|
||||
config = lib.optionalAttrs (options ? home-manager) {
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
|
||||
extraSpecialArgs = { inherit suites; };
|
||||
extraSpecialArgs = specialArgs;
|
||||
sharedModules = modules;
|
||||
};
|
||||
};
|
||||
|
@ -52,20 +52,26 @@ let
|
||||
/* set host specific properties here */
|
||||
NixOS = { };
|
||||
};
|
||||
profiles = [ ./profiles ./users ];
|
||||
suites = { profiles, users, ... }: with profiles; {
|
||||
importables = rec {
|
||||
profiles = lib.importers.rakeLeaves ./profiles // {
|
||||
users = lib.importers.rakeLeaves ./users;
|
||||
};
|
||||
suites = with profiles; {
|
||||
base = [ cachix core users.nixos users.root ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
home = {
|
||||
modules = ./users/modules/module-list.nix;
|
||||
externalModules = [ ];
|
||||
profiles = [ ./users/profiles ];
|
||||
suites = { profiles, ... }: with profiles; {
|
||||
importables = rec {
|
||||
profiles = lib.importers.rakeLeaves ./profiles;
|
||||
suites = with profiles; {
|
||||
base = [ direnv git ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
deploy.nodes = lib.mkDeployNodes self.nixosConfigurations { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user