From 6b6366eecd6dd97bbd58341352920b39a5951210 Mon Sep 17 00:00:00 2001 From: Steven Kalt Date: Sun, 2 Jun 2024 14:00:36 -0400 Subject: [PATCH] build: add version to nix flake build --- default.nix | 7 +++++-- flake.nix | 8 +++++--- gomod2nix.toml | 11 ++++------- .../{ => internal}/render_commercial_license/main.go | 0 4 files changed, 14 insertions(+), 12 deletions(-) rename scripts/{ => internal}/render_commercial_license/main.go (100%) diff --git a/default.nix b/default.nix index 9ebdc07..8e0094f 100644 --- a/default.nix +++ b/default.nix @@ -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}"]; } diff --git a/flake.nix b/flake.nix index 0eec2a4..3abc4dd 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "A very basic flake"; + description = "A git extension to help write conventional commits."; inputs = { flake-utils.url = "github:numtide/flake-utils"; gomod2nix = { @@ -7,7 +7,6 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.utils.follows = "flake-utils"; }; - }; outputs = { self, flake-utils, nixpkgs, gomod2nix }: @@ -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 diff --git a/gomod2nix.toml b/gomod2nix.toml index 57116f9..d81bb8e 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -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=" @@ -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=" @@ -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=" diff --git a/scripts/render_commercial_license/main.go b/scripts/internal/render_commercial_license/main.go similarity index 100% rename from scripts/render_commercial_license/main.go rename to scripts/internal/render_commercial_license/main.go