mirror of
https://github.com/divnix/digga.git
synced 2024-12-23 08:02:21 +03:00
re-add mkProfileAttrs with a deprecation message
This commit is contained in:
parent
f100c6dcf4
commit
271cfd0c18
@ -46,7 +46,7 @@
|
||||
inherit (attrs) mapFilterAttrs genAttrs' safeReadDir concatAttrs;
|
||||
inherit (lists) unifyOverlays;
|
||||
inherit (strings) rgxToString;
|
||||
inherit (importers) profileMap rakeLeaves maybeImportDevshellModule;
|
||||
inherit (importers) profileMap rakeLeaves mkProfileAttrs maybeImportDevshellModule;
|
||||
inherit (generators) mkSuites mkDeployNodes mkHomeConfigurations;
|
||||
}
|
||||
);
|
||||
|
@ -33,11 +33,13 @@
|
||||
extraConfig)
|
||||
hosts;
|
||||
|
||||
# DEPRECATED, suites no longer needs an explicit function after the importables generalization
|
||||
# deprecation message for suites is already in evalArgs
|
||||
mkSuites = { suites, profiles }:
|
||||
let
|
||||
profileSet = lib.genAttrs' profiles (path: {
|
||||
name = baseNameOf path;
|
||||
value = lib.rakeLeaves (toString path);
|
||||
value = lib.mkProfileAttrs (toString path);
|
||||
});
|
||||
|
||||
definedSuites = lib.mapAttrs (_: v: lib.profileMap v) (suites profileSet);
|
||||
|
@ -53,15 +53,61 @@ let
|
||||
in
|
||||
lib.mapAttrs' collect files;
|
||||
|
||||
# DEPRECATED, prefer rakeLeaves
|
||||
mkProfileAttrs =
|
||||
/**
|
||||
Synopsis: mkProfileAttrs _path_
|
||||
Recursively collect the subdirs of _path_ containing a default.nix into attrs.
|
||||
This sets a contract, eliminating ambiguity for _default.nix_ living under the
|
||||
profile directory.
|
||||
Example:
|
||||
let profiles = mkProfileAttrs ./profiles; in
|
||||
assert profiles ? core.default; 0
|
||||
**/
|
||||
dir:
|
||||
let
|
||||
imports =
|
||||
let
|
||||
files = lib.safeReadDir dir;
|
||||
|
||||
p = n: v:
|
||||
v == "directory"
|
||||
&& n != "profiles";
|
||||
in
|
||||
lib.filterAttrs p files;
|
||||
|
||||
f = n: _:
|
||||
lib.optionalAttrs
|
||||
(lib.pathExists "${dir}/${n}/default.nix")
|
||||
{ default = "${dir}/${n}"; }
|
||||
// mkProfileAttrs "${dir}/${n}";
|
||||
in
|
||||
lib.mapAttrs f imports;
|
||||
|
||||
getProfilePath = fallback: item:
|
||||
if lib.isString item then item else fallback;
|
||||
in
|
||||
{
|
||||
inherit rakeLeaves;
|
||||
|
||||
profileMap = list: map
|
||||
mkProfileAttrs = builtins.trace ''
|
||||
The function, mkProfileAttrs, has been deprecated, you can now create profile sets
|
||||
with the standard importer, rakeLeaves. The formmat of rakeLeaves is a little different,
|
||||
because it doesn't recurse into directories with `default.nix` files in them. So some
|
||||
of your sub-profiles might no longer be collected. Make sure to update your profiles
|
||||
with that in mind;
|
||||
See https://github.com/divnix/digga/pull/29 for more details
|
||||
''
|
||||
mkProfileAttrs;
|
||||
|
||||
# DEPRECATED, profiles in suites are type-checked in evalArgs
|
||||
# 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
|
||||
(p: getProfilePath (throw "passed profile ${builtins.toJSON p} isn't a path") p)
|
||||
(lib.flatten list);
|
||||
(lib.flatten list); **/
|
||||
profileMap = list: map (profile: profile.default) (lib.flatten list);
|
||||
|
||||
overlays = dir:
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user