diff --git a/.ci/list-paths.sh b/.ci/list-paths.sh new file mode 100644 index 00000000..dfe907e3 --- /dev/null +++ b/.ci/list-paths.sh @@ -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 diff --git a/.ci/push-paths.sh b/.ci/push-paths.sh new file mode 100644 index 00000000..6ba53cb8 --- /dev/null +++ b/.ci/push-paths.sh @@ -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" diff --git a/.cirrus.yml b/.cirrus.yml index 43ddf022..c4e85360 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,11 +4,11 @@ env: NIX: nix --extra-experimental-features nix-command --extra-experimental-features flakes # CIRRUS_SHELL: "/bin/bash" -common_task_template: ®ULAR_TASK_TEMPLATE +common_task_template: &LINUX_TASK_TEMPLATE timeout_in: 60m only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != '' -common_scripts_template: ®ULAR_SCRIPTS_TEMPLATE +common_scripts_template: &COMMON_SCRIPTS_TEMPLATE # TODO add cache? # nix_cache: @@ -24,11 +24,15 @@ common_scripts_template: ®ULAR_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 @@ -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 @@ -63,7 +68,7 @@ linux_aarch64_task: NIXOS_HOST: oracle macos_task: - << : *REGULAR_TASK_TEMPLATE + << : *COMMON_TASK_TEMPLATE name: Build Nix-Darwin system @@ -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