From 2955f685624d7ec4df35bbc499d1a40838974b14 Mon Sep 17 00:00:00 2001 From: Nikos Papadakis Date: Thu, 12 Oct 2023 16:40:38 +0300 Subject: [PATCH] CI: Use caching for nix --- .woodpecker/agent-release.yml | 16 +++++++++++----- nix/rust.nix | 9 ++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.woodpecker/agent-release.yml b/.woodpecker/agent-release.yml index b4324b9..dd0ec19 100644 --- a/.woodpecker/agent-release.yml +++ b/.woodpecker/agent-release.yml @@ -1,7 +1,7 @@ -depends_on: - - build - - test - - lint +#depends_on: +# - build +# - test +# - lint when: - event: push @@ -17,9 +17,15 @@ steps: build: image: nixos/nix:latest commands: - - nix --extra-experimental-features "nix-command flakes" build ".#agent.${BUILD_TARGET}" + - export AWS_ACCESS_KEY_ID="$${R2_CACHE_ACCESS_KEY}" + - export AWS_SECRET_ACCESS_KEY="$${R2_CACHE_SECRET_KEY}" + - echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf + - echo "substituters = s3://prymn-cache?endpoint=75178f9eca227dea51b3db4db2c15a5a.r2.cloudflarestorage.com®ion=auto https://cache.nixos.org/" >> /etc/nix/nix.conf + - nix build -L ".#agent.${BUILD_TARGET}" - mkdir -p "dist/${BUILD_TARGET}-unknown-linux-musl" - cp result/bin/prymn_agent "dist/${BUILD_TARGET}-unknown-linux-musl/" + - nix copy --to 's3://prymn-cache?endpoint=75178f9eca227dea51b3db4db2c15a5a.r2.cloudflarestorage.com®ion=auto' ".#agent.${BUILD_TARGET}" + secrets: [ R2_CACHE_ACCESS_KEY, R2_CACHE_SECRET_KEY ] release: image: woodpeckerci/plugin-s3 diff --git a/nix/rust.nix b/nix/rust.nix index ba74de6..ffbcc84 100644 --- a/nix/rust.nix +++ b/nix/rust.nix @@ -5,8 +5,7 @@ let craneLib = (crane.mkLib pkgs).overrideToolchain pkgs.rustToolchain; - buildInputs = [ pkgs.protobuf ]; - doCheck = false; + nativeBuildInputs = [ pkgs.protobuf ]; src = pkgs.lib.cleanSourceWith { src = craneLib.path ../.; filter = path: type: @@ -15,8 +14,12 @@ let }; in craneLib.buildPackage { - inherit src doCheck buildInputs; + inherit src nativeBuildInputs; + pname = "prymn_agent"; + version = "0.1.0"; + doCheck = false; # FIXME: Tests need to run on the native architecture + strictDeps = true; CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static -C linker=rust-lld"; CARGO_BUILD_TARGET = buildTarget; }