diff --git a/flake.nix b/flake.nix index 5da87e9..9572c20 100644 --- a/flake.nix +++ b/flake.nix @@ -28,10 +28,9 @@ rec { }; in { formatter = pkgs.alejandra; - packages = rec { + packages = { headplane = pkgs.callPackage ./nix/package.nix {}; headplane-agent = pkgs.callPackage ./nix/agent.nix {}; - default = headplane; }; devShell = pkgs.devshell.mkShell rec { name = description; diff --git a/nix/agent.nix b/nix/agent.nix index 2ac815f..6948b0a 100644 --- a/nix/agent.nix +++ b/nix/agent.nix @@ -1,8 +1,7 @@ {buildGoModule}: buildGoModule { pname = "hp_agent"; - # TODO: take the latest `git tag`, if commits do not match, append `-SNAPSHOT`. - version = "0.5.3"; + version = builtins.replaceStrings ["\n"] [""] (builtins.readFile ../version); src = ../.; vendorHash = "sha256-G0kahv3mPTL/mxU2U+0IytJaFVPXMbMBktbLMfM0BO8="; ldflags = ["-s" "-w"]; diff --git a/nix/package.nix b/nix/package.nix index 7dbb035..7e5d9a3 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -9,11 +9,7 @@ }: stdenv.mkDerivation (finalAttrs: { pname = "headplane"; - - # TODO: take the latest `git tag`, if commits do not match, append `-SNAPSHOT`. - version = "0.5.3"; - - # TODO: requires `.git` directory. + version = builtins.replaceStrings ["\n"] [""] (builtins.readFile ../version); src = ../.; nativeBuildInputs = [ diff --git a/version b/version new file mode 100644 index 0000000..f5633c8 --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.5.3-SNAPSHOT diff --git a/vite.config.ts b/vite.config.ts index 1f6ca48..e59bb8a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,7 +2,7 @@ import { reactRouter } from '@react-router/dev/vite'; import { defineConfig } from 'vite'; import babel from 'vite-plugin-babel'; import tsconfigPaths from 'vite-tsconfig-paths'; -import { execSync } from 'node:child_process'; +import fs from 'node:fs'; import tailwindcss from 'tailwindcss'; import autoprefixer from 'autoprefixer'; @@ -11,8 +11,7 @@ if (prefix.endsWith('/')) { throw new Error('Prefix must not end with a slash'); } -// Load the version via git tags -const version = execSync('git describe --tags --always').toString().trim(); +const version = fs.readFileSync("version", "utf8"); if (!version) { throw new Error('Unable to execute git describe'); }