Skip to content

Commit

Permalink
Split resulting package to few outputs
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Aug 23, 2024
1 parent e51fa6a commit 6429a5f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
41 changes: 20 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@
};

outputs =
inputs@{
self,
flake-parts,
crane,
...
}:
inputs@{ flake-parts, crane, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
Expand Down Expand Up @@ -61,31 +56,35 @@
];
};
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; };
givc-admin-rs = pkgs.callPackage ./nixos/packages/givc-admin-rs.nix {
inherit crane;
src = ./.;
};
givc-cli = givc-admin-rs.cli;
};
};
flake = {
# NixOS Modules
nixosModules = {
admin-go = import ./nixos/modules/admin-go.nix { inherit self; };
admin = import ./nixos/modules/admin.nix { inherit self; };
host = import ./nixos/modules/host.nix { inherit self; };
sysvm = import ./nixos/modules/sysvm.nix { inherit self; };
appvm = import ./nixos/modules/appvm.nix { inherit self; };
};
flake =
{ self, ... }:
{
# NixOS Modules
nixosModules = {
admin-go = import ./nixos/modules/admin-go.nix { inherit self; };
admin = import ./nixos/modules/admin.nix { inherit self; };
host = import ./nixos/modules/host.nix { inherit self; };
sysvm = import ./nixos/modules/sysvm.nix { inherit self; };
appvm = import ./nixos/modules/appvm.nix { inherit self; };
};

# Overlays
overlays.default = _final: prev: {
src = ./.;
givc-app = prev.callPackage ./nixos/packages/givc-app.nix { pkgs = prev; };
# Overlays
overlays.default = _final: prev: {
src = ./.;
inherit (self.packages.${prev.stdenv.hostPlatform.system}) givc-app;
givc-cli = self.packages.${prev.stdenv.hostPlatform.system}.givc-admin-rs.cli;
};
};
};
};
}
10 changes: 10 additions & 0 deletions nixos/packages/givc-admin-rs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nixos/tests/admin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6429a5f

Please sign in to comment.