modules: add common
This should define modules that are identical, or very similar. The driving force is to be able to use `my.profiles` on home-manager and NixOS without repeating myself. In the future I might migrate other modules, such as `nixos/system/nix`...
This commit is contained in:
parent
bddcab110d
commit
aa1336bb8d
31
modules/common/default.nix
Normal file
31
modules/common/default.nix
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Modules that are common to various module systems
|
||||||
|
# Usually with very small differences, if any, between them.
|
||||||
|
{ lib, type ? null, ... }:
|
||||||
|
let
|
||||||
|
allowedTypes = [
|
||||||
|
"nixos"
|
||||||
|
"home"
|
||||||
|
"darwin"
|
||||||
|
];
|
||||||
|
|
||||||
|
allowedTypesString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedTypes);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = type != null;
|
||||||
|
message = ''
|
||||||
|
You must provide `type` as part of specialArgs to use the common modules.
|
||||||
|
It must be one of ${allowedTypesString}.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = type != null -> builtins.elem type allowedTypes;
|
||||||
|
message = ''
|
||||||
|
`type` specialArgs must be one of ${allowedTypesString}.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue