From 0fb671023c0571d936a568721c67819a23cf63c0 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Thu, 5 Sep 2024 14:50:51 +0200 Subject: [PATCH] feat(services): introduce structured bundles Structured bundles keep their original contents as a `passthru` field named `components`. This enable users to depend on a specific piece of the bundle instead of the whole bundle. Signed-off-by: Raito Bezarius --- modules/bridge/members.nix | 6 +++--- pkgs/liminix-tools/services/default.nix | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/bridge/members.nix b/modules/bridge/members.nix index 78c64e2..560ba14 100644 --- a/modules/bridge/members.nix +++ b/modules/bridge/members.nix @@ -7,7 +7,7 @@ { members, primary } : let - inherit (liminix.services) bundle oneshot; + inherit (liminix.services) structuredBundle oneshot; inherit (lib) mapAttrs; addif = name: { dependencies ? [ ], member }: oneshot { name = "${primary.name}.member.${name}"; @@ -22,7 +22,7 @@ let dependencies = [ primary member ] ++ dependencies; }; -in bundle { +in structuredBundle { name = "${primary.name}.members"; - contents = builtins.attrValues (mapAttrs addif members); + contents = mapAttrs addif members; } diff --git a/pkgs/liminix-tools/services/default.nix b/pkgs/liminix-tools/services/default.nix index c0dbaf0..466a978 100644 --- a/pkgs/liminix-tools/services/default.nix +++ b/pkgs/liminix-tools/services/default.nix @@ -39,6 +39,7 @@ let , contents ? [] , buildInputs ? [] , isTrigger ? false + , passthru ? {} } @ args: stdenvNoCC.mkDerivation { # we use stdenvNoCC to avoid generating derivations with names @@ -50,6 +51,8 @@ let dependencies = builtins.map (d: d.name) dependencies; contents = builtins.map (d: d.name) contents; builder = ./builder.sh; + + inherit passthru; }; longrun = { @@ -100,7 +103,18 @@ let serviceType = "bundle"; inherit contents dependencies; }); + structuredBundle = { + name + , contents ? {} + , dependencies ? [] + , ... + } @ args: service (args // { + serviceType = "bundle"; + contents = builtins.attrValues contents; + inherit dependencies; + passthru.components = contents; + }); target = bundle; in { - inherit target bundle oneshot longrun output; + inherit target bundle oneshot longrun output structuredBundle; }