Last active
July 24, 2023 15:10
-
-
Save XYenon/d3bc751d147f506e3456f9cb11b9670c to your computer and use it in GitHub Desktop.
Nix Config CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build and populate cache" | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- master | |
jobs: | |
build_nur: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
platform: x86_64-linux | |
- os: macos-latest | |
platform: x86_64-darwin | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@v4 | |
- uses: DeterminateSystems/magic-nix-cache-action@v2 | |
- name: Setup cachix | |
uses: cachix/cachix-action@v12 | |
with: | |
name: xyenon | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: Build NUR packages | |
run: ./scripts/nur_cachix.sh 'xyenon' 'xyenon' '${{ matrix.platform }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
nur_repo="$1" | |
cachix_name="$2" | |
platform="$3" | |
tmp_dir=$(mktemp -d) | |
packages_json="$tmp_dir/packages.json" | |
curl -o "$packages_json" 'https://raw.githubusercontent.com/nix-community/nur-search/master/data/packages.json' | |
my_nur_pkgs=$(cat "$packages_json" | jq -r 'keys | .[]' | grep -F "nur.repos.$nur_repo.") | |
declare -a pkgs_to_build=() | |
for pkg in $my_nur_pkgs; do | |
result=$(cat "$packages_json" | jq ".[\"$pkg\"].meta?.platforms? // [] | contains([\"$platform\"])") | |
echo "Checking $pkg for $platform, result: $result" | |
if [ $result == 'true' ]; then | |
pkgs_to_build+=(".#$pkg") | |
fi | |
done | |
echo "Packages to build: ${pkgs_to_build[@]}" | |
nix build --json ${pkgs_to_build[@]} | | |
jq -r '.[].outputs | to_entries[].value' | | |
cachix push "$cachix_name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment