From 1fcc8e3ba21e8605ec1229383f3f7ca2e5177d4b Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Fri, 23 Aug 2024 18:02:20 +0300 Subject: [PATCH] Split resulting package to few outputs Signed-off-by: Alexander V. Nikolaev --- flake.nix | 7 ++++--- nixos/packages/givc-admin-rs.nix | 10 ++++++++++ nixos/tests/admin.nix | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index b89f37f..c87dc6d 100644 --- a/flake.nix +++ b/flake.nix @@ -61,7 +61,7 @@ ]; }; in - { + rec { givc-app = pkgs.callPackage ./nixos/packages/givc-app.nix { inherit src; }; givc-agent = pkgs.callPackage ./nixos/packages/givc-agent.nix { inherit src; }; givc-admin = pkgs.callPackage ./nixos/packages/givc-admin.nix { inherit src; }; @@ -69,6 +69,7 @@ inherit crane; src = ./.; }; + givc-cli = givc-admin-rs.cli; }; }; flake = { @@ -83,8 +84,8 @@ # Overlays overlays.default = _final: prev: { - src = ./.; - givc-app = prev.callPackage ./nixos/packages/givc-app.nix { pkgs = prev; }; + inherit (self.packages.${prev.stdenv.hostPlatform.system}) givc-app; + givc-cli = self.packages.${prev.stdenv.hostPlatform.system}.givc-admin-rs.cli; }; }; }; diff --git a/nixos/packages/givc-admin-rs.nix b/nixos/packages/givc-admin-rs.nix index bb8fb08..af7c7df 100644 --- a/nixos/packages/givc-admin-rs.nix +++ b/nixos/packages/givc-admin-rs.nix @@ -30,6 +30,11 @@ let givc = craneLib.buildPackage ( commonArgs // { + outputs = [ + "out" + "cli" + "agent" + ]; cargoArtifacts = craneLib.buildDepsOnly commonArgs; # Additional environment variables or build phases/hooks can be set @@ -39,6 +44,11 @@ let # Avoid issue with source filtering, put symlink back into source tree ln -sf ../api $sourceRoot/common/api ''; + postInstall = '' + mkdir -p $cli/bin $agent/bin + mv $out/bin/givc-cli $cli/bin/givc-cli + mv $out/bin/givc-agent $agent/bin/givc-agent + ''; } ); in diff --git a/nixos/tests/admin.nix b/nixos/tests/admin.nix index 1cd1db1..eb539f2 100644 --- a/nixos/tests/admin.nix +++ b/nixos/tests/admin.nix @@ -207,7 +207,7 @@ in testScript = { nodes, ... }: let - cli = "${self'.packages.givc-admin-rs}/bin/givc-cli"; + cli = "${self'.packages.givc-admin-rs.cli}/bin/givc-cli"; expected = "givc-ghaf-host.service"; # Name which we _expect_ to see registered in admin server's registry in # FIXME: why it so bizzare? (derived from name in cert)