diff --git a/flake.nix b/flake.nix index 506d209..75c2bb1 100644 --- a/flake.nix +++ b/flake.nix @@ -22,10 +22,7 @@ { overlays.default = import ./overlays/default.nix; - lib = { - go = import ./lib/go/go.nix; - nix = import ./lib/nix/nix.nix; - }; + lib = import ./lib/lib.nix; } // flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { diff --git a/lib/go/example/flake.lock b/lib/go/example/flake.lock index 376743f..fa2e7d9 100644 --- a/lib/go/example/flake.lock +++ b/lib/go/example/flake.lock @@ -41,12 +41,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-iXhStvlczm1hQDU+TbxGEqYzyo86pQ8L07Hea+PXL3s=", - "path": "/nix/store/kwqvwdwrb9w03s75hw6s8dhggqh927pq-source", + "narHash": "sha256-SfFzLdA2CQgwVF0BMKVfTP0RlZ6nkWp1sKQWIdOzaqU=", + "path": "/nix/store/xphp9yws1aipy2aw8x4xv9fpn8aibvz3-source", "type": "path" }, "original": { - "path": "/nix/store/kwqvwdwrb9w03s75hw6s8dhggqh927pq-source", + "path": "/nix/store/xphp9yws1aipy2aw8x4xv9fpn8aibvz3-source", "type": "path" } }, diff --git a/lib/go/example/flake.nix b/lib/go/example/flake.nix index fe473ca..de001d4 100644 --- a/lib/go/example/flake.nix +++ b/lib/go/example/flake.nix @@ -14,7 +14,7 @@ inherit system overlays; }; - nixops-go = nixops.lib.go { inherit pkgs; }; + nixops-lib = nixops.lib { inherit pkgs; }; src = nix-filter.lib.filter { root = ./.; @@ -38,24 +38,28 @@ in { checks = { - go-checks = nixops-go.check { + go-checks = nixops-lib.go.check { inherit src ldflags tags buildInputs nativeBuildInputs checkDeps; }; }; devShells = flake-utils.lib.flattenTree rec { - default = nixops-go.devShell { + default = nixops-lib.go.devShell { buildInputs = with pkgs; [ + mockgen + gqlgen + gqlgenc + oapi-codegen ]; }; }; packages = flake-utils.lib.flattenTree rec { - example = nixops-go.package { + example = nixops-lib.go.package { inherit name src version ldflags buildInputs nativeBuildInputs; }; - docker-image = nixops-go.docker-image { + docker-image = nixops-lib.go.docker-image { inherit name version buildInputs; package = example; diff --git a/lib/lib.nix b/lib/lib.nix new file mode 100644 index 0000000..df0ee40 --- /dev/null +++ b/lib/lib.nix @@ -0,0 +1,5 @@ +{ pkgs }: +{ + go = import ./go/go.nix { inherit pkgs; }; + nix = import ./nix/nix.nix { inherit pkgs; }; +} diff --git a/overlays/default.nix b/overlays/default.nix index 2a2b40a..083e210 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -2,3 +2,4 @@ final: prev: { nhost-cli = final.callPackage ./nhost-cli.nix { inherit final; }; } // import ./go.nix final prev + // import ./postgres.nix final prev diff --git a/overlays/go.nix b/overlays/go.nix index 2988738..d9a23fc 100644 --- a/overlays/go.nix +++ b/overlays/go.nix @@ -34,37 +34,122 @@ final: prev: rec { }); }; - govulncheck = prev.govulncheck.override rec { - buildGoModule = args: prev.buildGoModule.override { go = go; } (args // rec { }); - }; - - gqlgenc = prev.gqlgenc.override rec { - buildGoModule = args: prev.buildGoModule.override { go = go; } (args // rec { - version = "0.16.2"; - src = prev.fetchFromGitHub { - owner = "Yamashou"; - repo = "gqlgenc"; - rev = "v${version}"; - sha256 = "sha256-XNmCSkgJJ2notrv0Din4jlU9EoHJcznjEUiXQgQ5a7I="; - }; - - vendorHash = "sha256-6iwNykvW1m+hl6FzMNbvvPpBNp8OQn2/vfJLmAj60Mw="; - }); - }; - mockgen = prev.mockgen.override rec { buildGoModule = args: final.buildGoModule (args // rec { - version = "0.3.0"; + version = "0.4.0"; src = final.fetchFromGitHub { owner = "uber-go"; repo = "mock"; rev = "v${version}"; - sha256 = "sha256-pwlssqk/2aXTOwchePJK7CqEQ6lkQv7E+aT3HzUhvpE="; + sha256 = "sha256-3nt70xrZisK5vgQa+STZPiY4F9ITKw8PbBWcKoBn4Vc="; }; vendorHash = "sha256-mcNVud2jzvlPPQEaar/eYZkP71V2Civz+R5v10+tewA="; }); }; + golines = final.buildGoModule rec { + name = "golines"; + version = "0.11.0"; + src = final.fetchFromGitHub { + owner = "dbarrosop"; + repo = "golines"; + rev = "b7e767e781863a30bc5a74610a46cc29485fb9cb"; + sha256 = "sha256-pxFgPT6J0vxuWAWXZtuR06H9GoGuXTyg7ue+LFsRzOk="; + }; + vendorHash = "sha256-rxYuzn4ezAxaeDhxd8qdOzt+CKYIh03A9zKNdzILq18="; -} + meta = with final.lib; { + description = "A golang formatter that fixes long lines"; + homepage = "https://github.com/segmentio/golines"; + maintainers = [ "nhost" ]; + platforms = platforms.linux ++ platforms.darwin; + }; + }; + + govulncheck = final.buildGoModule rec { + name = "govulncheck"; + version = "v1.0.1"; + src = final.fetchFromGitHub { + owner = "golang"; + repo = "vuln"; + rev = "${version}"; + sha256 = "sha256-wAZJruDyAavfqS/+7yDaT4suE4eivCbL7g4tQoqUDlQ="; + }; + vendorHash = "sha256-LqKDQPOXOF+A2G3e483jeV7ziUb87ePnk8VMkLAms74="; + + doCheck = false; + + meta = with final.lib; { + description = "the database client and tools for the Go vulnerability database"; + homepage = "https://github.com/golang/vuln"; + maintainers = [ "nhost" ]; + platforms = platforms.linux ++ platforms.darwin; + }; + }; + + gqlgen = final.buildGoModule rec { + pname = "gqlgen"; + version = "0.17.42"; + + src = final.fetchFromGitHub { + owner = "99designs"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-Rqet3wLRtyts493yUdUHNgEKkfKR9YuHGINT8IRXSpk="; + }; + + vendorHash = "sha256-0Yo2oqKGHDbMuqqjwO/CN/pApSZcVcPF3T//k5ogHM0="; + + doCheck = false; + subPackages = [ "./." ]; + + meta = with final.lib; { + description = "go generate based graphql server library"; + homepage = "https://gqlgen.com"; + license = licenses.mit; + maintainers = [ "@nhost" ]; + }; + }; + + gqlgenc = final.buildGoModule rec { + pname = "gqlgenc"; + version = "0.16.2"; + + src = final.fetchFromGitHub { + owner = "Yamashou"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-XNmCSkgJJ2notrv0Din4jlU9EoHJcznjEUiXQgQ5a7I="; + }; + + vendorHash = "sha256-6iwNykvW1m+hl6FzMNbvvPpBNp8OQn2/vfJLmAj60Mw="; + + doCheck = false; + + subPackages = [ "./." ]; + + meta = with final.lib; { + description = "This is Go library for building GraphQL client with gqlgen"; + homepage = "https://github.com/Yamashou/gqlgenc"; + license = licenses.mit; + maintainers = [ "@nhost" ]; + }; + }; + + oapi-codegen = prev.oapi-codegen.override rec { + buildGoModule = args: final.buildGoModule (args // rec { + version = "2.0.0"; + src = final.fetchFromGitHub { + owner = "deepmap"; + repo = "oapi-codegen"; + rev = "v${version}"; + sha256 = "sha256-LZaNuT2JMWYXllKxAOciKT9ybBFuCV1LyIP2MwxbJ2M="; + }; + + subPackages = [ "cmd/oapi-codegen" ]; + vendorHash = "sha256-d5PvdxQCAwMPi1Oh2E7p4dVRukED26N+3cU8FMcT16U="; + }); + }; + +} diff --git a/overlays/postgres.nix b/overlays/postgres.nix new file mode 100644 index 0000000..cee3341 --- /dev/null +++ b/overlays/postgres.nix @@ -0,0 +1,43 @@ +final: prev: rec { + postgresql_146 = prev.postgresql_14.overrideAttrs + (finalAttrs: previousAttrs: rec { + pname = "postgresql"; + version = "14.6"; + + src = final.fetchurl { + url = "mirror://postgresql/source/v${version}/${pname}-${version}.tar.bz2"; + hash = "sha256-UIhA/BgJ05q3InTV8Tfau5/X+0+TPaQWiu67IAae3yI="; + }; + }); + + postgresql_146-client = postgresql_146.overrideAttrs + (finalAttrs: previousAttrs: { + buildInputs = with final.pkgs; [ zlib openssl ]; + configureFlags = [ + "--with-openssl" + "--without-readline" + "--sysconfdir=/etc" + "--libdir=$(lib)/lib" + "--with-system-tzdata=${final.pkgs.tzdata}/share/zoneinfo" + ]; + + separateDebugInfo = false; + buildFlags = [ ]; + installTargets = [ "-C src/bin install" "-C ../interfaces install" ]; + + postInstall = + '' + cp src/bin/pg_dump/pg_dump $out/bin + cp src/bin/pg_dump/pg_restore $out/bin + cp src/bin/psql/psql $out/bin + moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it + moveToOutput "lib/libpgcommon*.a" "$out" + moveToOutput "lib/libpgport*.a" "$out" + moveToOutput "lib/libecpg*" "$out" + ''; + + postFixup = ""; + outputs = [ "out" "lib" ]; + }); +} +