Skip to content

#1046 fix (devel) in Nix derivations#1163

Merged
jamietanna merged 6 commits intooapi-codegen:masterfrom
Dafaque:1046-fix-version-devel-no-vcs
Aug 29, 2023
Merged

#1046 fix (devel) in Nix derivations#1163
jamietanna merged 6 commits intooapi-codegen:masterfrom
Dafaque:1046-fix-version-devel-no-vcs

Conversation

@Dafaque
Copy link
Contributor

@Dafaque Dafaque commented Jul 31, 2023

FIxes #1046
This commit allows override oapi-codegen -version output build-time

POC:

  1. create default.nix with content below
  2. create oapi.nix with content below
  3. run nix-shell
  4. run oapi-codegen -version
  5. ????

@Dafaque
Copy link
Contributor Author

Dafaque commented Jul 31, 2023

default.nix content:

{ pkgs ? import <nixpkgs> {} }:
    let oapi-codegen = pkgs.callPackage ./oapi.nix {};
    in
    pkgs.mkShell {
        nativeBuildInputs = [ oapi-codegen ];
    }

@Dafaque
Copy link
Contributor Author

Dafaque commented Jul 31, 2023

oapi.nix content:

{ lib, buildGoModule }:
  buildGoModule rec {
    pname = "oapi-codegen";
    version = "1046-fix-version-devel-no-vcs";

    src = builtins.fetchGit {
      url = "https://github.com/dafaque/oapi-codegen.git";
      ref = "refs/heads/${version}";
    };

    subPackages = [ "cmd/oapi-codegen" ];
    vendorHash = "sha256-tNK197/sgfWNIg8sMFaVQfsdYPlqoM0w5AL4NiKgU8s=";
    proxyVendor = true;
    ldflags = ["-X main.noVcsVersionOverride=${version}"];

    # Tests use network
    doCheck = false;

    meta = with lib; {
      description = "Go client and server OpenAPI 3 generator";
      homepage    = "https://github.com/deepmap/oapi-codegen";
      license     = licenses.asl20;
      maintainers = with maintainers; [ j4m3s ];
    };
  }

@Dafaque
Copy link
Contributor Author

Dafaque commented Jul 31, 2023

recomended .nix file:

{ lib, buildGoModule }:
buildGoModule rec {
  pname = "oapi-codegen";
  version = <tag>;

  src = builtins.fetchGit {
    url = "https://github.com/deepmap/oapi-codegen.git";
    ref = "refs/tags/${version}";
  };

  subPackages = [ "cmd/oapi-codegen" ];
  vendorHash = <hash>;
  proxyVendor = true;
  ldflags = ["-X main.noVcsVersionOverride=v${version}"];

  # Tests use network
  doCheck = false;

  meta = with lib; {
    description = "Go client and server OpenAPI 3 generator";
    homepage    = "https://github.com/deepmap/oapi-codegen";
    license     = licenses.asl20;
    maintainers = with maintainers; [ j4m3s ];
  };
}

OR
Just add line ldflags = ["-X main.noVcsVersionOverride=v${version}"]; to current .nix file.

@Dafaque Dafaque marked this pull request as ready for review July 31, 2023 17:40
@jamietanna
Copy link
Member

Thanks for your patience @Dafaque this will be released as part of v1.14.0 this week 👏

@jamietanna
Copy link
Member

⚠️ Note that the flag is now noVCSVersionOverride (capitalised VCS) opposed to the original version proposed!

@jamietanna jamietanna merged commit beb29bb into oapi-codegen:master Aug 29, 2023
@Dafaque
Copy link
Contributor Author

Dafaque commented Aug 29, 2023

Thak you for editing some text for me!

debuggerpk pushed a commit to breuHQ/oapi-codegen that referenced this pull request Sep 18, 2023
…gen#1163)

As mentioned in oapi-codegen#1046, for environments, like Nix, that build without a
Version Control System (VCS) available, we output `(devel)` as the
version of oapi-codegen even when it's building from source from a Git
tag.

We can therefore provide a `noVCSVersionOverride` build-time flag to
allow us to override this with an arbitrary string.

Closes oapi-codegen#1046.

Co-authored-by: Jamie Tanna <jamie@jamietanna.co.uk>
danicc097 pushed a commit to danicc097/oapi-codegen that referenced this pull request Aug 31, 2024
…gen#1163)

As mentioned in oapi-codegen#1046, for environments, like Nix, that build without a
Version Control System (VCS) available, we output `(devel)` as the
version of oapi-codegen even when it's building from source from a Git
tag.

We can therefore provide a `noVCSVersionOverride` build-time flag to
allow us to override this with an arbitrary string.

Closes oapi-codegen#1046.

Co-authored-by: Jamie Tanna <jamie@jamietanna.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nix issues

2 participants