From 9288d8cf4880630f3428e93552b17b7f3fa9e644 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Thu, 20 Oct 2022 22:30:30 +0200 Subject: [PATCH] Fix and improve version string --- default.nix | 21 ++++++++++++++++----- docs/shell.nix | 2 +- nix/pkgs.nix | 12 ++++++++---- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/default.nix b/default.nix index a524792..903334f 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,13 @@ { - pkgs ? (import ./nix/pkgs.nix).stable, + pkgsAttrs ? (import ./nix/pkgs.nix), bootstrap ? null, -}: rec { +}: let + + pkgs = pkgsAttrs.pkgs; + +in rec { rootedBootstrap = pkgs.stdenv.mkDerivation { name = "cryptic-net-rooted-bootstrap"; @@ -21,23 +25,30 @@ name = "cryptic-net-version"; buildInputs = [ pkgs.git pkgs.go ]; + src = ./.; inherit bootstrap; + nixPkgsVersion = pkgsAttrs.version; + nixPkgsRev = pkgsAttrs.rev; + builtByUser = builtins.getEnv "USER"; builder = builtins.toFile "builder.sh" '' source $stdenv/setup versionFile=version + cp -r "$src" srcCp + if [ "$bootstrap" != "" ]; then hostName=$(tar -xzf "$bootstrap" --to-stdout ./hostname) echo "Built for host: $hostName" >> "$versionFile" fi - echo "Build date: $(date)" >> "$versionFile" - echo "Git status: $(cd "$src" && git describe --always --long --dirty=' (dirty)')" >> "$versionFile" + echo "Build date: $(date) ($(date +%s))" >> "$versionFile" + echo "Built by: $builtByUser" >> "$versionFile" + echo "Git rev: $(cd srcCp && git describe --always --long --dirty=' (dirty)')" >> "$versionFile" echo "Go version: $(go version)" >> "$versionFile" - echo "Build host info: $(uname -srvm)" >> "$versionFile" + echo "Nixpkgs version: $nixPkgsVersion ($nixPkgsRev)" >> "$versionFile" mkdir -p "$out"/share cp "$versionFile" "$out"/share diff --git a/docs/shell.nix b/docs/shell.nix index aec6302..14d9253 100644 --- a/docs/shell.nix +++ b/docs/shell.nix @@ -1,6 +1,6 @@ { - pkgs ? (import ../nix/pkgs.nix).stable, + pkgs ? (import ../nix/pkgs.nix).pkgs, }: pkgs.mkShell { name = "cryptic-net-build-docs"; diff --git a/nix/pkgs.nix b/nix/pkgs.nix index 9bf4561..b7ceca5 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -16,6 +16,7 @@ rec { in { + go = prev.go_1_18; buildGoModule = args: prev.buildGoModule (buildArgs // args); buildGo118Module = args: prev.buildGo118Module (buildArgs // args); @@ -31,11 +32,14 @@ rec { ]; - stableSrc = fetchTarball { - name = "nixpkgs-22-05"; - url = "https://github.com/NixOS/nixpkgs/archive/2aec372cdcd4d73b94863611fea70e0884270fdc.tar.gz"; + version = "22-05"; + rev = "2aec372cdcd4d73b94863611fea70e0884270fdc"; + + src = fetchTarball { + name = "nixpkgs-${version}"; + url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; sha256 = "1pbfhlh4v8l70p44gspsci3i6w0wk70vaisiawg3jhka2nxb8367"; }; - stable = import stableSrc { inherit overlays; }; + pkgs = import src { inherit overlays; }; }