Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update go flake for current efishery workflow #20

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ In this section is require nix installed in your system, here steps to install:
> available templates or development environments.


| NAME | Lang/Framework/Tools |
| ------------- | ------------- |
| [node](./node) | `nodejs@v18`, `[email protected]`, `pnpm@7` |
| [node14](./node14) | `nodejs@v14`, `[email protected]`, `pnpm@5` |
| [go](./go) | `go@v1.19`, `gotools`, `golangci-lint` |
| [react-native](./react-native) | [See Details](./react-native/flake.nix#L192-L212) |
| NAME | Lang/Framework/Tools |
| ------------- | ------------- |
| [node](./node) | `nodejs@v18`, `[email protected]`, `pnpm@7` |
| [node14](./node14) | `nodejs@v14`, `[email protected]`, `pnpm@5` |
| [go](./go) | `go@v1.21`, `gotools`, `golangci-lint`, `go-swagger-0.3` |
| [react-native](./react-native) | [See Details](./react-native/flake.nix#L192-L212) |

* using as development environment: `nix develop "github:efishery/dvt?dir=<NAME>"`

Expand Down
17 changes: 17 additions & 0 deletions go/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 55 additions & 2 deletions go/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,55 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";

go-swagger = {
url = "github:MAAF72/go-swagger";
flake = false;
};
};

outputs = { self, nixpkgs, utils }:
outputs = { self, nixpkgs, utils, go-swagger }:

utils.lib.eachDefaultSystem (system:
let
goVersion = 21;
overlays = [ (final: prev: { go = prev."go_1_${toString goVersion}"; }) ];
pkgs = import nixpkgs { inherit overlays system; };

# common dependency

# custom fork of swagger used by efishery
# due to its ability to add custom tag on generated code
# the nix package did not expose any param to override
# thus we make a separate package for this flake
# ref: https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/development/tools/go-swagger/default.nix
maaf72-go-swagger = with pkgs; buildGoModule rec {
pname = "go-swagger-custom";
version = "0.30.6-maaf72.1";

src = go-swagger;

doCheck = false;
subPackages = [ "cmd/swagger" ];
ldflags = [
"-s"
"-w"
"-X github.com/MAAF72/go-swagger/cmd/swagger/commands.Version=${version}"
"-X github.com/MAAF72/go-swagger/cmd/swagger/commands.Commit=${src.rev}"
];


vendorHash = "sha256-TqoTzxPGF0BBUfLtYWkljRcmr08m4zo5iroWMklxL7U=";


meta = with nixpkgs.lib;{
homepage = "https://github.com/MAAF72/go-swagger";
license = licenses.asl20; # apache license 2.0
maintainers = with maintainers; [ MAAF72 ];
};
};
in
{
rec {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# go 1.21 (specified by overlay)
Expand All @@ -32,8 +69,24 @@
];

shellHook = ''
# allow for external dependency to be
# install on nix os imperatively
# using `go install` when certain
# dependencies not available/outdated
# on nixpkgs
export GOPATH="$(${pkgs.go}/bin/go env GOPATH)"
export PATH="$PATH:$GOPATH/bin"

${pkgs.go}/bin/go version
'';
};

devShells.go-swagger = pkgs.mkShell {
buildInputs = [
maaf72-go-swagger
] ++ devShells.default.buildInputs;

shellHook = devShells.default.shellHook;
};
});
}
Loading