From b95196c3f6b282fd588d954d06147e0efb68c6be Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Mon, 29 Jan 2024 22:28:53 +0100
Subject: [PATCH] fix: update git-commit script, and test build #5

---
 Taskfile.yml                      |  9 ++++
 flake.lock                        | 79 +++----------------------------
 flake.nix                         | 17 +++----
 system/scripts/git-commit.nix     |  8 ++++
 system/scripts/update-version.nix |  4 +-
 5 files changed, 35 insertions(+), 82 deletions(-)
 create mode 100644 system/scripts/git-commit.nix

diff --git a/Taskfile.yml b/Taskfile.yml
index 42e7112..62a453a 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -23,6 +23,15 @@ tasks:
       - source/**/*.mod
       - dist/**
 
+  release:
+    desc: Commit changes (update version, hashes, etc.)
+    aliases:
+      - cc
+    cmds:
+      - update-hashes || true
+      - git-commit
+      - update-version
+
   update-code:
     desc: Update the code, calculate hashes and update version
     aliases:
diff --git a/flake.lock b/flake.lock
index 4123ba5..e138700 100644
--- a/flake.lock
+++ b/flake.lock
@@ -87,21 +87,6 @@
         "type": "github"
       }
     },
-    "git-commit": {
-      "inputs": {
-        "nixpkgs": "nixpkgs_2"
-      },
-      "locked": {
-        "lastModified": 1,
-        "narHash": "sha256-8hXrOA8SKy//ctoL1poIhJwuT7G4rvVu7FguROzEoDg=",
-        "path": "./git-commit",
-        "type": "path"
-      },
-      "original": {
-        "path": "./git-commit",
-        "type": "path"
-      }
-    },
     "gitignore": {
       "inputs": {
         "nixpkgs": [
@@ -179,25 +164,6 @@
         "type": "github"
       }
     },
-    "nix-templates": {
-      "inputs": {
-        "git-commit": "git-commit",
-        "nixpkgs": "nixpkgs_3"
-      },
-      "locked": {
-        "lastModified": 1704993617,
-        "narHash": "sha256-++u7I3KCDgP+JhW70k5tiLfBESWVSKdVK7aei0G+mR8=",
-        "ref": "refs/heads/master",
-        "rev": "e63b1d6ae5526158fa2a1f4cd53b0ea4f4c93573",
-        "revCount": 18,
-        "type": "git",
-        "url": "https://gitlab.schukai.com/schukai/entwicklung/nix-flakes"
-      },
-      "original": {
-        "type": "git",
-        "url": "https://gitlab.schukai.com/schukai/entwicklung/nix-flakes"
-      }
-    },
     "nixpkgs": {
       "locked": {
         "lastModified": 1678875422,
@@ -265,36 +231,6 @@
       }
     },
     "nixpkgs_2": {
-      "locked": {
-        "lastModified": 1704874635,
-        "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
-        "owner": "NixOS",
-        "repo": "nixpkgs",
-        "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
-        "type": "github"
-      },
-      "original": {
-        "id": "nixpkgs",
-        "ref": "nixos-23.11",
-        "type": "indirect"
-      }
-    },
-    "nixpkgs_3": {
-      "locked": {
-        "lastModified": 1706373441,
-        "narHash": "sha256-S1hbgNbVYhuY2L05OANWqmRzj4cElcbLuIkXTb69xkk=",
-        "owner": "NixOS",
-        "repo": "nixpkgs",
-        "rev": "56911ef3403a9318b7621ce745f5452fb9ef6867",
-        "type": "github"
-      },
-      "original": {
-        "id": "nixpkgs",
-        "ref": "nixos-23.11",
-        "type": "indirect"
-      }
-    },
-    "nixpkgs_4": {
       "locked": {
         "lastModified": 1706373441,
         "narHash": "sha256-S1hbgNbVYhuY2L05OANWqmRzj4cElcbLuIkXTb69xkk=",
@@ -310,7 +246,7 @@
         "type": "github"
       }
     },
-    "nixpkgs_5": {
+    "nixpkgs_3": {
       "locked": {
         "lastModified": 1705856552,
         "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=",
@@ -326,7 +262,7 @@
         "type": "github"
       }
     },
-    "nixpkgs_6": {
+    "nixpkgs_4": {
       "locked": {
         "lastModified": 1704145853,
         "narHash": "sha256-G/1AMt9ibpeMlcxvD1vNaC8imGaK+g7zZ99e29BLgWw=",
@@ -375,10 +311,9 @@
         "flake-parts": "flake-parts",
         "flake-root": "flake-root",
         "mk-shell-bin": "mk-shell-bin",
-        "nix-templates": "nix-templates",
-        "nixpkgs": "nixpkgs_4",
+        "nixpkgs": "nixpkgs_2",
         "treefmt-nix": "treefmt-nix",
-        "versionsTool": "versionsTool"
+        "versions-tool": "versions-tool"
       }
     },
     "systems": {
@@ -398,7 +333,7 @@
     },
     "treefmt-nix": {
       "inputs": {
-        "nixpkgs": "nixpkgs_5"
+        "nixpkgs": "nixpkgs_3"
       },
       "locked": {
         "lastModified": 1706462057,
@@ -414,9 +349,9 @@
         "type": "github"
       }
     },
-    "versionsTool": {
+    "versions-tool": {
       "inputs": {
-        "nixpkgs": "nixpkgs_6"
+        "nixpkgs": "nixpkgs_4"
       },
       "locked": {
         "lastModified": 1704542622,
diff --git a/flake.nix b/flake.nix
index 9d8dffe..2b64440 100644
--- a/flake.nix
+++ b/flake.nix
@@ -7,8 +7,7 @@
     mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin";
     flake-root.url = "github:srid/flake-root";
     treefmt-nix.url = "github:numtide/treefmt-nix";
-    versionsTool.url = "git+https://gitlab.schukai.com/oss/utilities/version.git";
-    nix-templates.url = "git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes";
+    versions-tool.url = "git+https://gitlab.schukai.com/oss/utilities/version.git";
   };
 
   nixConfig = {
@@ -19,8 +18,7 @@
   outputs = inputs @ {
     self,
     flake-parts,
-    versionsTool,
-    nix-templates,
+    versions-tool,
     ...
   }:
     flake-parts.lib.mkFlake {inherit inputs;} {
@@ -130,7 +128,7 @@
               name = projectDefinition.name;
 
               scripts = let
-                versionsTool = inputs.versionsTool.defaultPackage."${builtins.currentSystem}";
+                versions-tool = inputs.versions-tool.defaultPackage."${builtins.currentSystem}";
 
                 workingDirectory = builtins.getEnv "PWD";
               in {
@@ -155,7 +153,11 @@
                 };
 
                 update-version.exec = import ./system/scripts/update-version.nix {
-                  inherit pkgs config buildRoot projectDefinition versionsTool workingDirectory;
+                  inherit pkgs config buildRoot projectDefinition versions-tool workingDirectory;
+                };
+
+                git-commit.exec = import ./system/scripts/git-commit.nix {
+                  inherit pkgs;
                 };
               };
 
@@ -163,8 +165,7 @@
               ];
 
               packages = with pkgs; [
-                inputs.versionsTool.defaultPackage."${builtins.currentSystem}"
-                inputs.nix-templates.packages."${builtins.currentSystem}".git-commit
+                inputs.versions-tool.defaultPackage."${builtins.currentSystem}"
                 nodePackages.prettier-plugin-toml
                 nodePackages.prettier
                 go-task
diff --git a/system/scripts/git-commit.nix b/system/scripts/git-commit.nix
new file mode 100644
index 0000000..13341a1
--- /dev/null
+++ b/system/scripts/git-commit.nix
@@ -0,0 +1,8 @@
+{pkgs, ...}: let
+  common = import ./common.nix {inherit pkgs;};
+  nix-flakes = builtins.getFlake "git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes";
+in ''
+  #!${pkgs.bash}/bin/bash
+  ${common}
+  ${nix-flakes.packages.${builtins.currentSystem}.git-commit}/bin/git-commit
+''
diff --git a/system/scripts/update-version.nix b/system/scripts/update-version.nix
index 4c13134..8deb58a 100644
--- a/system/scripts/update-version.nix
+++ b/system/scripts/update-version.nix
@@ -2,7 +2,7 @@
   pkgs,
   buildRoot,
   projectDefinition,
-  versionsTool,
+  versions-tool,
   workingDirectory,
   ...
 }: let
@@ -14,7 +14,7 @@ in ''
   ${common}
 
 
-  cmd=${versionsTool}/bin/version
+  cmd=${versions-tool}/bin/version
 
   echo_step "Getting current commit hash"
   HASH=$(${pkgs.git}/bin/git  -C ${workingDirectory}/ rev-parse --short HEAD)
-- 
GitLab