From 6472461ab0da467bab7dac8e4899ae8d16b8a75c Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Wed, 13 Mar 2024 12:19:22 -0700 Subject: [PATCH] nix configuration for CLI plugin --- flake.nix | 11 +++++++++++ nix/docker-cli-plugin.nix | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 nix/docker-cli-plugin.nix diff --git a/flake.nix b/flake.nix index 4f35db9b..04b064e7 100644 --- a/flake.nix +++ b/flake.nix @@ -89,6 +89,7 @@ # arion-compose.nix. mongodb-connector-workspace = final.callPackage ./nix/mongodb-connector-workspace.nix { }; # builds all packages in this repo mongodb-connector = final.mongodb-connector-workspace.override { package = "mongodb-connector"; }; # override `package` to build one specific crate + mongodb-cli-plugin = final.mongodb-connector-workspace.override { package = "mongodb-cli-plugin"; }; v3-engine = final.callPackage ./nix/v3-engine.nix { src = v3-engine-source; }; v3-e2e-testing = final.callPackage ./nix/v3-e2e-testing.nix { src = v3-e2e-testing-source; database-to-test = "mongodb"; }; inherit v3-e2e-testing-source; # include this source so we can read files from it in arion-compose configs @@ -170,6 +171,16 @@ architecture = "arm64"; }; + # CLI plugin packages with cross-compilation options + mongodb-cli-plugin = pkgs.mongodb-cli-plugin.override { staticallyLinked = true; }; + mongodb-cli-plugin-x86_64-linux = pkgs.pkgsCross.x86_64-linux.mongodb-cli-plugin.override { staticallyLinked = true; }; + mongodb-cli-plugin-aarch64-linux = pkgs.pkgsCross.aarch64-linux.mongodb-cli-plugin.override { staticallyLinked = true; }; + + # CLI plugin docker images + mongodb-cli-plugin-docker = pkgs.callPackage ./nix/docker-cli-plugin.nix { }; + mongodb-cli-plugin-docker-x86_64-linux = pkgs.pkgsCross.x86_64-linux.callPackage ./nix/docker-cli-plugin.nix { }; + mongodb-cli-plugin-docker-aarch64-linux = pkgs.pkgsCross.aarch64-linux.callPackage ./nix/docker-cli-plugin.nix { }; + publish-docker-image = pkgs.writeShellApplication { name = "publish-docker-image"; runtimeInputs = with pkgs; [ coreutils skopeo ]; diff --git a/nix/docker-cli-plugin.nix b/nix/docker-cli-plugin.nix new file mode 100644 index 00000000..e28ae550 --- /dev/null +++ b/nix/docker-cli-plugin.nix @@ -0,0 +1,12 @@ +{ name ? "ghcr.io/hasura/mongodb-cli-plugin" +, mongodb-cli-plugin +, dockerTools +}: + +dockerTools.buildLayeredImage { + inherit name; + created = "now"; + config = { + Entrypoint = [ "${mongodb-cli-plugin}/bin/hasura-mongodb" ]; + }; +}