From e1f9d8f1612ae48bc36155ea1f734a87cc209438 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 23 Jul 2024 19:03:19 +0200 Subject: [PATCH] cluster/lib: implement config.lib.forService for better option filtering --- cluster/default.nix | 1 + cluster/lib/lib.nix | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 cluster/lib/lib.nix diff --git a/cluster/default.nix b/cluster/default.nix index 548c3af..54a8969 100644 --- a/cluster/default.nix +++ b/cluster/default.nix @@ -17,6 +17,7 @@ lib.evalModules { ./lib/mesh.nix ./lib/secrets.nix ./lib/testing.nix + ./lib/lib.nix ./import-services.nix ]; diff --git a/cluster/lib/lib.nix b/cluster/lib/lib.nix new file mode 100644 index 0000000..1aedf13 --- /dev/null +++ b/cluster/lib/lib.nix @@ -0,0 +1,12 @@ +{ config, lib, ... }: + +{ + options.lib = { + forService = lib.mkOption { + description = "Enable these definitions for a particular service only."; + type = lib.types.functionTo lib.types.raw; + readOnly = true; + default = service: lib.mkIf (!config.simulacrum || lib.any (s: s == service) config.testConfig.activeServices); + }; + }; +}