From 5fdd56f0900f05ef5bf1b8a348fabbd280f0c60b Mon Sep 17 00:00:00 2001 From: Shivaraj B H Date: Thu, 31 Aug 2023 13:00:06 +0530 Subject: [PATCH] mkPackageFor in test flake (#44) --- test/flake.nix | 64 ++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/test/flake.nix b/test/flake.nix index a9ed2e0a..cdf9f43c 100644 --- a/test/flake.nix +++ b/test/flake.nix @@ -18,44 +18,32 @@ # Required for elastic search config.allowUnfree = true; }; - process-compose = { - postgres = { - imports = [ - inputs.services-flake.processComposeModules.default - ../nix/postgres_test.nix - ]; - }; - redis = { - imports = [ - inputs.services-flake.processComposeModules.default - ../nix/redis_test.nix - ]; - }; - redis-cluster = { - imports = [ - inputs.services-flake.processComposeModules.default - ../nix/redis-cluster_test.nix - ]; - }; - elasticsearch = { - imports = [ - inputs.services-flake.processComposeModules.default - ../nix/elasticsearch_test.nix - ]; - }; - apache-kafka = { - imports = [ - inputs.services-flake.processComposeModules.default - ../nix/apache-kafka_test.nix - ]; - }; - zookeeper = { - imports = [ - inputs.services-flake.processComposeModules.default - ../nix/zookeeper_test.nix - ]; - }; - }; + process-compose = + let + mkPackageFor = mod: + let + # Derive name from filename + name = lib.pipe mod [ + builtins.baseNameOf + (builtins.match "(.*)_test.nix") + builtins.head + ]; + in + lib.nameValuePair name { + imports = [ + inputs.services-flake.processComposeModules.default + mod + ]; + }; + in + builtins.listToAttrs (builtins.map mkPackageFor [ + ../nix/apache-kafka_test.nix + ../nix/elasticsearch_test.nix + ../nix/postgres_test.nix + ../nix/redis_test.nix + ../nix/redis-cluster_test.nix + ../nix/zookeeper_test.nix + ]); }; }; }