From 22c85f9506979e21bdf93a21847e69bfbcedd625 Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Wed, 5 Jul 2023 16:14:48 +0200 Subject: [PATCH] chore: packaging with nix --- .direnv/flake-profile | 2 +- .direnv/flake-profile-4-link | 1 + .direnv/flake-profile-5-link | 1 + .direnv/flake-profile-6-link | 1 + .direnv/flake-profile-7-link | 1 + .direnv/flake-profile-8-link | 1 + flake.nix | 25 ++++++++++++++++++++----- result | 1 + 8 files changed, 27 insertions(+), 6 deletions(-) create mode 120000 .direnv/flake-profile-4-link create mode 120000 .direnv/flake-profile-5-link create mode 120000 .direnv/flake-profile-6-link create mode 120000 .direnv/flake-profile-7-link create mode 120000 .direnv/flake-profile-8-link create mode 120000 result diff --git a/.direnv/flake-profile b/.direnv/flake-profile index 519b17b..81fbd58 120000 --- a/.direnv/flake-profile +++ b/.direnv/flake-profile @@ -1 +1 @@ -flake-profile-3-link \ No newline at end of file +flake-profile-8-link \ No newline at end of file diff --git a/.direnv/flake-profile-4-link b/.direnv/flake-profile-4-link new file mode 120000 index 0000000..58a3ce7 --- /dev/null +++ b/.direnv/flake-profile-4-link @@ -0,0 +1 @@ +/nix/store/s78r1i6ai1in42ybid66ra73z8ndpypi-bob-env \ No newline at end of file diff --git a/.direnv/flake-profile-5-link b/.direnv/flake-profile-5-link new file mode 120000 index 0000000..47fb33f --- /dev/null +++ b/.direnv/flake-profile-5-link @@ -0,0 +1 @@ +/nix/store/48xnpf2slkjsf61k6wpvcrpsbdhqjfwj-bob-env \ No newline at end of file diff --git a/.direnv/flake-profile-6-link b/.direnv/flake-profile-6-link new file mode 120000 index 0000000..31ab033 --- /dev/null +++ b/.direnv/flake-profile-6-link @@ -0,0 +1 @@ +/nix/store/k2b7cyr7j68qzx94yz3jgwixdgsfr8kg-bob-env \ No newline at end of file diff --git a/.direnv/flake-profile-7-link b/.direnv/flake-profile-7-link new file mode 120000 index 0000000..c48a801 --- /dev/null +++ b/.direnv/flake-profile-7-link @@ -0,0 +1 @@ +/nix/store/yk163kyn90q9axhmgn6b17fy2h1cmgqx-bob-env \ No newline at end of file diff --git a/.direnv/flake-profile-8-link b/.direnv/flake-profile-8-link new file mode 120000 index 0000000..aeb8fad --- /dev/null +++ b/.direnv/flake-profile-8-link @@ -0,0 +1 @@ +/nix/store/h3gvv220m3mpjnfai4lhd8qvmifzm4l6-bob-env \ No newline at end of file diff --git a/flake.nix b/flake.nix index c92d89c..28156d0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,3 @@ - { description = "Bob: The HTML and HTML fragment builder"; @@ -6,6 +5,10 @@ outputs = { self, nixpkgs }: let + rootPath = ./.; + releaseJson = builtins.fromJSON (builtins.readFile "${rootPath}/release.json"); + currentVersion = releaseJson.version; + systems = [ "x86_64-linux" "aarch64-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); makePackage = system: @@ -19,17 +22,29 @@ bob = final.buildGoModule { name = "bob"; src = ././application/source; - vendorSha256 = null; # Use "nix to-sri --type sha256" on the actual hash + vendorSha256 = "sha256-qiObIbA75kfkGzZoTtZbkm4zQqXokL+hiWrJdmL8oxU="; # Use "nix to-sri --type sha256" on the actual hash doCheck = false; + nativeBuildInputs = [ final.jq ]; + +# preBuild = '' +# jq -r '.version' ${rootPath}/release.json > $TMPDIR/version +# ''; - buildFlagsArray = [ - "-ldflags=-X main.Version=${self.lastModifiedDate}" - ]; + buildPhase = '' + buildFlagsArray=( + "-ldflags=-X main.version=${currentVersion} -X main.build=${self.lastModifiedDate}" + ) + buildPhase + ''; }; }; defaultPackage = forAllSystems makePackage; + packages = forAllSystems (system: { + bob = makePackage system; + }); + checks = { test = forAllSystems makePackage; }; diff --git a/result b/result new file mode 120000 index 0000000..607519d --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/nzn16jnc6wgd2p9bwrczn8wl4vysg7y8-bob \ No newline at end of file -- GitLab