diff --git a/flake.nix b/flake.nix index af855a9..5801376 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,7 @@ inherit system; config = { }; overlays = builtins.attrValues self.overlays ++ [ - (prev: final: import ./nix/protobuf.nix {pkgs = prev;}) + (prev: final: import ./nix/protobuf.nix final) (prev: final: { # This plugin path won't work because it's relative to the pwd protoc-gen-purescript = prev.writeScriptBin "protoc-gen-purescript" '' diff --git a/nix/protobuf.nix b/nix/protobuf.nix index d50faeb..37e33fe 100644 --- a/nix/protobuf.nix +++ b/nix/protobuf.nix @@ -1,4 +1,5 @@ -{ pkgs ? import { } }: +{ stdenv, lib, fetchFromGitHub, autogen, automake, autoconf, libtool, rsync, cmake, ... }: +# pkgs ? import { } }: # The protobuf derivation in nixpkgs does not include the conformance test # runners. @@ -66,7 +67,7 @@ let }; protobuf_repo_v23_2 = rec { ref = "v23.2"; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "protocolbuffers"; repo = "protobuf"; rev = "v23.2"; @@ -76,7 +77,7 @@ let }; protobuf_repo_v24_4 = rec { ref = "v24.4"; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "protocolbuffers"; repo = "protobuf"; rev = "v24.4"; @@ -86,7 +87,7 @@ let }; protobuf_repo_v28_2= rec { ref = "v28.2"; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "protocolbuffers"; repo = "protobuf"; rev = "v28.2"; @@ -104,9 +105,9 @@ let # # See the Travis test runner script # https://github.com/protocolbuffers/protobuf/blob/master/tests.sh - mkProtobuf = repo: pkgs.stdenv.mkDerivation { + mkProtobuf = repo: stdenv.mkDerivation { name = "protobuf-${repo.ref}"; - nativeBuildInputs = with pkgs; [ autogen automake autoconf libtool rsync ]; + nativeBuildInputs = [ autogen automake autoconf libtool rsync ]; src = repo.src; # https://github.com/protocolbuffers/protobuf/blob/main/src/README.md#c-installation---unix configurePhase = '' @@ -139,21 +140,21 @@ let and conformance .proto definitions. ''; homepage = "https://github.com/xc-jp/purescript-protobuf"; - license = pkgs.lib.licenses.bsd3; + license = lib.licenses.bsd3; mainProgram = "protoc"; }; }; - cmakeProtobuf = repo: pkgs.stdenv.mkDerivation { + cmakeProtobuf = repo: stdenv.mkDerivation { name = "protobuf-${repo.ref}"; - nativeBuildInputs = with pkgs; [ cmake rsync ]; + nativeBuildInputs = [ cmake rsync ]; src = repo.src; # https://github.com/protocolbuffers/protobuf/blob/main/src/README.md#c-installation---unix cmakeFlags = [ "-Dprotobuf_BUILD_CONFORMANCE=ON" ]; postInstall = let - conformance_rpath = pkgs.lib.makeLibraryPath [ - pkgs.stdenv.cc.cc.lib + conformance_rpath = lib.makeLibraryPath [ + stdenv.cc.cc.lib ]; in '' @@ -165,11 +166,11 @@ let # Conformance test runner cp ./conformance_test_runner $out/bin/conformance_test_runner # https://nixos.wiki/wiki/Packaging/Binaries#Creating_the_Derivation_for_upstream_Packaging - patchelf --set-interpreter "${pkgs.stdenv.cc.bintools.dynamicLinker}" --set-rpath "$out/lib:${conformance_rpath}" $out/bin/conformance_test_runner + patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath "$out/lib:${conformance_rpath}" $out/bin/conformance_test_runner # Distribute the cpp conformance program as a test case cp ./conformance_cpp $out/bin/conformance_cpp - patchelf --set-interpreter "${pkgs.stdenv.cc.bintools.dynamicLinker}" --set-rpath "$out/lib:${conformance_rpath}" $out/bin/conformance_cpp + patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath "$out/lib:${conformance_rpath}" $out/bin/conformance_cpp ''; meta = { description = "Google’s Protobuf built for purescript-protobuf"; @@ -179,7 +180,7 @@ let and conformance .proto definitions. ''; homepage = "https://github.com/xc-jp/purescript-protobuf"; - license = pkgs.lib.licenses.bsd3; + license = lib.licenses.bsd3; mainProgram = "protoc"; }; };