refactor(lib): add lib output to flake
This is needed so we can use subattributes of flake.lib
This commit is contained in:
parent
1dc3f4bf44
commit
4e74db3938
6 changed files with 33 additions and 4 deletions
|
@ -1,70 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.flake;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in
|
||||
{
|
||||
flake.lib = {
|
||||
/**
|
||||
Return an attribute set for use with a option that needs to be used for all users.
|
||||
|
||||
# Inputs
|
||||
|
||||
`attrset`
|
||||
|
||||
: An attribute set to apply to all the users.
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
forAllUsers :: AttrSet -> AttrSet
|
||||
```
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `forAllUsers` usage example
|
||||
|
||||
```nix
|
||||
flake.manifest.users.rafiq = { ... };
|
||||
flake.modules.nixos.default.users = forAllUsers {
|
||||
isNormalUser = true;
|
||||
};
|
||||
=> flake.modules.nixos.default.users.rafiq.isNormalUser = true;
|
||||
```
|
||||
|
||||
:::
|
||||
*/
|
||||
forAllUsers = attrset: mapAttrs (_: _: attrset) cfg.manifest.users;
|
||||
|
||||
/**
|
||||
Like forAllUsers, but passes in the name and value from the manifest.
|
||||
|
||||
# Inputs
|
||||
|
||||
`f`
|
||||
|
||||
: A function that takes an attribute name and its value, and returns the new value for the attribute.
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
forAllUsers' :: (String -> Any -> Any) -> AttrSet
|
||||
```
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `forAllUsers'` usage example
|
||||
|
||||
```nix
|
||||
flake.manifest.users.rafiq = { ... };
|
||||
flake.modules.homeManager.users = forAllUsers' (name: value: {
|
||||
home.username = name;
|
||||
});
|
||||
=> flake.modules.homeManager.default.users.rafiq.home.username = "rafiq";
|
||||
```
|
||||
|
||||
:::
|
||||
*/
|
||||
forAllUsers' = f: mapAttrs f cfg.manifest.users;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue