From 0a6516b44ec6889cfbd0ed557cd885060b89c375 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Wed, 16 Nov 2022 17:43:41 +0100 Subject: [PATCH] Add release target in nix --- default.nix | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/default.nix b/default.nix index 2a8e24a..b045f79 100644 --- a/default.nix +++ b/default.nix @@ -2,6 +2,7 @@ pkgsAttrs ? (import ./nix/pkgs.nix), bootstrap ? null, + releaseName ? "debug", }: let @@ -27,7 +28,7 @@ in rec { buildInputs = [ pkgs.git pkgs.go ]; src = ./.; - inherit bootstrap; + inherit bootstrap releaseName; nixPkgsVersion = pkgsAttrs.version; nixPkgsRev = pkgsAttrs.rev; builtByUser = builtins.getEnv "USER"; @@ -44,6 +45,7 @@ in rec { echo "Built for host: $hostName" >> "$versionFile" fi + echo "Release: $releaseName" >> "$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" @@ -95,24 +97,22 @@ in rec { source $stdenv/setup cp -rL "$src" cryptic-net chmod +w cryptic-net -R - mkdir $out - appimagetool cryptic-net "$out/cryptic-net" + appimagetool cryptic-net "$out" ''; }; - service = pkgs.writeText "cryptic-service" '' - [Unit] - Description=cryptic nebula - Requires=network.target - After=network.target + release = pkgs.stdenv.mkDerivation { + name = "cryptic-net-AppImage"; + inherit appImage releaseName; - [Service] - Restart=always - RestartSec=1s - User=root - ExecStart=${appImage}/cryptic-net + buildInputs = [ pkgs.coreutils ]; - [Install] - WantedBy=multi-user.target - ''; + builder = builtins.toFile "build.sh" '' + source $stdenv/setup + + mkdir -p "$out" + cp "$appImage" "$out"/cryptic-net-$releaseName-linux-amd64 + (cd "$out" && sha256sum * > sha256.txt) + ''; + }; }