about summary refs log tree commit diff stats
path: root/nix/scripts.nix
diff options
context:
space:
mode:
authorAlan Pearce2024-04-20 18:29:18 +0200
committerAlan Pearce2024-04-20 18:29:18 +0200
commitcc2245f991ca0474e3d4db9fa213be4aa8ccccb7 (patch)
tree81dff8c64a1f1c5c81e6fe8a19e4172d6e77d930 /nix/scripts.nix
parent3da735c4e72f8de390e5f4f0df63476cac43b6b1 (diff)
downloadwebsite-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.tar.lz
website-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.tar.zst
website-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.zip
Use gitlab CI
commit 3bca937c9ff91852269a828de0c778db7d1423df
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 01:14:26 2024 +0200

    create gitlab CI configuration

commit ee9eeab17ac88f4020d857dcceb458c66418e2f6
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 16:07:01 2024 +0200

    make helpers for both building and streaming docker images

commit d8340ec8ff3e3f9c51b55e95e27e518330435b7c
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 00:20:34 2024 +0200

    use long git hashes for docker tags
Diffstat (limited to 'nix/scripts.nix')
-rw-r--r--nix/scripts.nix20
1 files changed, 12 insertions, 8 deletions
diff --git a/nix/scripts.nix b/nix/scripts.nix
index e48de76..b50ba16 100644
--- a/nix/scripts.nix
+++ b/nix/scripts.nix
@@ -5,12 +5,14 @@ let
      --watch flake.nix \
      --watch flake.lock \
   '';
-  image = (builtins.fromTOML (builtins.readFile ../fly.toml)).build.image;
+  imageName = (builtins.fromTOML (builtins.readFile ../fly.toml)).build.image;
   nonDarwinSystem = builtins.replaceStrings [ "darwin" ] [ "linux" ] pkgs.stdenv.system;
-  attr = "docker-${nonDarwinSystem}";
+  flySystem = "x86_64-linux";
+  mkAttr = type: system: ".#docker-${type}-${system}";
   sh = (pkgs.lib.optionalString pkgs.stdenv.isDarwin "ssh linux-builder ")
     + "sh";
-  stream = attr: "nix build --print-out-paths .#${attr} | ${sh}";
+  stream = system: "nix build --print-out-paths ${(mkAttr "stream") system} | ${sh}";
+  image = system: "nix build ${(mkAttr "image") system}";
 in
 with pkgs; [
   (writeShellScriptBin "watch-builder" ''
@@ -22,10 +24,12 @@ with pkgs; [
   (writeShellScriptBin "check-licenses" ''
     ${go-licenses}/bin/go-licenses check --include_tests ./... --disallowed_types=restricted,forbidden
   '')
-  (writeShellScriptBin "stream" "${stream attr}")
-  (writeShellScriptBin "stream-fly" "${stream "fly"}")
+  (writeShellScriptBin "stream" "${stream nonDarwinSystem}")
+  (writeShellScriptBin "stream-fly" "${stream flySystem}")
+  (writeShellScriptBin "image" "${image nonDarwinSystem}")
+  (writeShellScriptBin "image-fly" "${image flySystem}")
   (writeShellScriptBin "load-locally" ''
-    ${stream attr} | ${docker-client}/bin/docker load "$@"
+    stream | ${docker-client}/bin/docker load "$@"
   '')
   (writeShellScriptBin "push-to-registry" ''
     if test -z "''${1:-}"; then
@@ -39,12 +43,12 @@ with pkgs; [
       exit 1
     fi
     echo skopeo copy docker-archive:/dev/stdin "$@"
-    stream-fly | ${gzip}/bin/gzip --fast | ${skopeo}/bin/skopeo copy docker-archive:/dev/stdin "$@"
+    stream fly | ${gzip}/bin/gzip --fast | ${skopeo}/bin/skopeo copy docker-archive:/dev/stdin "$@"
   '')
   (writeShellScriptBin "deploy" ''
     set -eu
     TAG=$(git rev-parse HEAD)
-    IMAGE=${image}:$TAG
+    IMAGE=${imageName}:$TAG
     push-to-registry docker://$IMAGE
     ${pkgs.flyctl}/bin/flyctl deploy --image $IMAGE
   '')