Skip to content

Commit

Permalink
build: add version to nix flake build
Browse files Browse the repository at this point in the history
  • Loading branch information
SKalt committed Jun 2, 2024
1 parent 0c0925f commit 6b6366e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
7 changes: 5 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
),
version,
rev,
}:

pkgs.buildGoApplication {
pname = "git-cc";
version = "0.0.17";
version = version + "+" + rev;
pwd = ./.;
src = ./.;
modules = ./gomod2nix.toml;
ldflags = ["-X" "main.version=${version}"];
}
8 changes: 5 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
description = "A very basic flake";
description = "A git extension to help write conventional commits.";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
gomod2nix = {
url = "github:tweag/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};

};

outputs = { self, flake-utils, nixpkgs, gomod2nix }:
Expand All @@ -17,8 +16,11 @@
inherit system;
overlays = [ gomod2nix.overlays.default ];
};
version = (builtins.fromJSON (builtins.readFile ./package.json)).version;
rev = if (self ? rev) then self.rev else "dirty";

in {
packages.default = pkgs.callPackage ./. { };
packages.default = pkgs.callPackage ./. { inherit version; inherit rev; };
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
go # 1.20.x
Expand Down
11 changes: 4 additions & 7 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ schema = 3
version = "v1.1.1"
hash = "sha256-nhzSUrE1fCkN0+RL04N4h8jWmRFPPPWbCuDc7Ss0akI="
[mod."github.com/inconshreveable/mousetrap"]
version = "v1.0.0"
hash = "sha256-ogTuLrV40FwS4ueo4hh6hi1wPywOI+LyIqfNjsibwNY="
version = "v1.1.0"
hash = "sha256-XWlYH0c8IcxAwQTnIi6WYqq44nOKUylSWxWO/vi+8pE="
[mod."github.com/kr/text"]
version = "v0.2.0"
hash = "sha256-fadcWxZOORv44oak3jTxm6YcITcFxdGt4bpn869HxUE="
Expand Down Expand Up @@ -80,8 +80,8 @@ schema = 3
version = "v2.1.0"
hash = "sha256-R+84l1si8az5yDqd5CYcFrTyNZ1eSYlpXKq6nFt4OTQ="
[mod."github.com/spf13/cobra"]
version = "v1.5.0"
hash = "sha256-rcyHWrxshA5DVpxrSba5X4NjppqOGrJ64QkUKKnfW2E="
version = "v1.7.0"
hash = "sha256-bom9Zpnz8XPwx9IVF+GAodd3NVQ1dM1Uwxn8sy4Gmzs="
[mod."github.com/spf13/pflag"]
version = "v1.0.5"
hash = "sha256-w9LLYzxxP74WHT4ouBspH/iQZXjuAh2WQCHsuvyEjAw="
Expand All @@ -103,9 +103,6 @@ schema = 3
[mod."gopkg.in/check.v1"]
version = "v1.0.0-20200227125254-8fa46927fb4f"
hash = "sha256-nGV66SlDrpDfhkzlr9h52JybsCioW3ix5bKmbkEfoDs="
[mod."gopkg.in/yaml.v2"]
version = "v2.4.0"
hash = "sha256-uVEGglIedjOIGZzHW4YwN1VoRSTK8o0eGZqzd+TNdd0="
[mod."gopkg.in/yaml.v3"]
version = "v3.0.1"
hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU="
File renamed without changes.

0 comments on commit 6b6366e

Please sign in to comment.