Skip to content

Commit

Permalink
fix(ci): alternative cachix
Browse files Browse the repository at this point in the history
  • Loading branch information
truelecter committed Sep 5, 2023
1 parent 6f62f52 commit 978b2c5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 10 deletions.
30 changes: 30 additions & 0 deletions .ci/list-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Credits to https://github.com/cachix/cachix-action/blob/master/dist/main/list-nix-store.sh

# Small utility to replace `nix path-info --all`
set -euo pipefail

for file in /nix/store/*; do
case "$file" in
*.drv)
# Avoid .drv as they are not generally useful
continue
;;
*.drv.chroot)
# Avoid .drv.chroot as they are not generally useful
continue
;;
*.check)
# Skip .check file produced by --keep-failed
continue
;;
*.lock)
# Skip .lock files
continue
;;
*)
echo "$file"
;;
esac
done
15 changes: 15 additions & 0 deletions .ci/push-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Credits to https://github.com/cachix/cachix-action/blob/master/dist/main/list-nix-store.sh
set -euo pipefail

cachix=$1 cachixArgs=${2:--j8} cache=$3 pathsToPush=$4 pushFilter=$5

if [[ $pathsToPush == "" ]]; then
pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh))

if [[ $pushFilter != "" ]]; then
pathsToPush=$(echo "$pathsToPush" | grep -vEe "$pushFilter")
fi
fi

echo "$pathsToPush" | "$cachix" push $cachixArgs "$cache"
26 changes: 16 additions & 10 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ env:
NIX: nix --extra-experimental-features nix-command --extra-experimental-features flakes
# CIRRUS_SHELL: "/bin/bash"

common_task_template: &REGULAR_TASK_TEMPLATE
common_task_template: &LINUX_TASK_TEMPLATE
timeout_in: 60m
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''

common_scripts_template: &REGULAR_SCRIPTS_TEMPLATE
common_scripts_template: &COMMON_SCRIPTS_TEMPLATE
# TODO add cache?
# nix_cache:

Expand All @@ -24,11 +24,15 @@ common_scripts_template: &REGULAR_SCRIPTS_TEMPLATE
- cachix use mic92
- cachix use nrdxp
- cachix use truelecter
- ./.ci/install-nix.sh > /tmp/store-path-pre-build

cachix_background_script: cachix watch-store --compression-method xz --compression-level 9 --jobs 2 truelecter
# cachix_background_script: cachix watch-store --compression-method xz --compression-level 9 --jobs 2 truelecter

common_finishing_script_template: &COMMON_FINISHING_SCRIPTS_TEMPLATE
upload_paths_to_cachix_script: .ci/push-paths.sh cachix "--compression-method xz --compression-level 9 --jobs 8" truelecter "" ""

linux_aarch64_task:
<< : *REGULAR_TASK_TEMPLATE
<< : *LINUX_TASK_TEMPLATE

name: Build NixOS aarch64 systems

Expand All @@ -46,13 +50,14 @@ linux_aarch64_task:
# try to overcome https://github.com/cirruslabs/cirrus-ci-docs/discussions/1225
use_in_memory_disk: true

<< : *REGULAR_SCRIPTS_TEMPLATE
<< : *COMMON_SCRIPTS_TEMPLATE

build_systems_script:
- $NIX build ".#nixosConfigurations.nixos-$NIXOS_HOST.config.system.build.toplevel"
- $NIX develop --command "menu"
# - $NIX develop --command "menu"
# for cachix to finish uploading things
- sleep 60

<< : *COMMON_FINISHING_SCRIPTS_TEMPLATE

matrix:
# - name: Build octoprint
Expand All @@ -63,7 +68,7 @@ linux_aarch64_task:
NIXOS_HOST: oracle

macos_task:
<< : *REGULAR_TASK_TEMPLATE
<< : *COMMON_TASK_TEMPLATE

name: Build Nix-Darwin system

Expand All @@ -80,13 +85,14 @@ macos_task:

install_nix_script: ./.ci/install-nix.sh

<< : *REGULAR_SCRIPTS_TEMPLATE
<< : *COMMON_SCRIPTS_TEMPLATE

build_script:
- nix build ".#darwinConfigurations.darwin-$NIXOS_HOST.config.system.build.toplevel"
- nix develop --command "menu"
# for cachix to finish uploading things
- sleep 60

<< : *COMMON_FINISHING_SCRIPTS_TEMPLATE

matrix:
- name: Build squadbook
Expand Down

0 comments on commit 978b2c5

Please sign in to comment.