From 19c3c0d835bebbcd357b6ebbc4b8f4b01f408e8d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:49:19 +0000 Subject: [PATCH] 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`... --- modules/common/default.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/common/default.nix diff --git a/modules/common/default.nix b/modules/common/default.nix new file mode 100644 index 0000000..ce6840c --- /dev/null +++ b/modules/common/default.nix @@ -0,0 +1,31 @@ +# Modules that are common to various module systems +# Usually with very small differences, if any, between them. +{ lib, _class, ... }: +let + allowedClass = [ + "darwin" + "home" + "nixos" + ]; + + allowedClassString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedClass); +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 ${allowedClassString}. + ''; + } + { + assertion = type != null -> builtins.elem type allowedClass; + message = '' + `type` specialArgs must be one of ${allowedClassString}. + ''; + } + ]; + }; +}