diff --git a/pkgs/by-name/nc/ncps/package.nix b/pkgs/by-name/nc/ncps/package.nix index d50fe4676b88..9991c7c58dcb 100644 --- a/pkgs/by-name/nc/ncps/package.nix +++ b/pkgs/by-name/nc/ncps/package.nix @@ -15,25 +15,21 @@ python3, redis, writeShellScriptBin, + xz, }: -let - dbmate-real = writeShellScriptBin "dbmate.real" '' - exec ${dbmate}/bin/dbmate "$@" - ''; -in buildGoModule (finalAttrs: { pname = "ncps"; - version = "0.8.6"; + version = "0.9.0"; src = fetchFromGitHub { owner = "kalbasit"; repo = "ncps"; tag = "v${finalAttrs.version}"; - hash = "sha256-Ep83aGlwf8qq7fmSCCH9zUztlXf4D3vvs9jkBBoN6Yw="; + hash = "sha256-jZxh4y1bKHbSSGphN3TSR9TiQqfkNhdr8GQekldC1FM="; }; - vendorHash = "sha256-AcgC+zTS3eVsbcs0jim4zDBGc3lIjwPbdVT7/KQ9Lkc="; + vendorHash = "sha256-QZikr0kE/kvnI4RG02lxVpG4teTg3Uo68st9xLlbfm0="; ldflags = [ "-X github.com/kalbasit/ncps/pkg/ncps.Version=v${finalAttrs.version}" @@ -41,7 +37,11 @@ buildGoModule (finalAttrs: { subPackages = [ "." ]; + buildInputs = [ xz ]; + nativeBuildInputs = [ + makeWrapper # used for wrapping the binary so it can always find the xz binary + curl # used for checking MinIO health check dbmate # used for testing jq # used for testing by the init-minio @@ -51,16 +51,23 @@ buildGoModule (finalAttrs: { postgresql # PostgreSQL for integration tests python3 # used for generating the ports redis # Redis for distributed locking integration tests - makeWrapper # For wrapping dbmate. ]; postInstall = '' mkdir -p $out/share/ncps cp -r db $out/share/ncps/db + # ncps makes use of xz for decompression as it's 3-5x faster than + # using the native Go implementation of xz. By wrapping ncps, and + # setting the XZ_BINARY_PATH environment variable, we ensure that + # ncps can always find the xz binary. This environment variable is + # read by a flag in pkg/ncps and can be overriden by using calling + # ncps with the --xz-binary-path flag. + wrapProgram $out/bin/ncps --set XZ_BINARY_PATH ${lib.getExe' xz "xz"} + + # Wrap the dbmate-wrapper and set the NCPS_DB_MIGRATIONS_DIR environment variable makeWrapper ${finalAttrs.passthru.dbmate-wrapper}/bin/dbmate-wrapper \ $out/bin/dbmate-ncps \ - --prefix PATH : ${dbmate-real}/bin \ --set NCPS_DB_MIGRATIONS_DIR $out/share/ncps/db/migrations ''; @@ -94,6 +101,14 @@ buildGoModule (finalAttrs: { vendorHash = null; + buildInputs = lib.singleton dbmate; + nativeBuildInputs = lib.singleton makeWrapper; + + postInstall = '' + # the dbmate-wrapper needs access to the original dbmate executable, wrap it so it can find it correctly. + wrapProgram $out/bin/dbmate-wrapper --set DBMATE_BIN ${lib.getExe dbmate} + ''; + subPackages = [ "." ]; };