Skip to content

Commit

Permalink
feat: simplify flake structure (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-gelinas authored May 15, 2024
1 parent 18f60fe commit 2c43bcb
Show file tree
Hide file tree
Showing 112 changed files with 673 additions and 2,304 deletions.
6 changes: 0 additions & 6 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
"group:all",
"schedule:weekly"
],
lockFileMaintenance: {
enabled: true
},
dependencyDashboard: true,
nix: {
enabled: true
},
"github-actions": {
enabled: true
}
Expand Down
55 changes: 20 additions & 35 deletions .github/workflows/build-attributes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ name: Build attributes

on:
workflow_call:
inputs:
cache-name:
required: true
type: string
pin:
type: boolean
default: false
cache:
type: boolean
default: false
extra-caches:
type: string
default: ""

permissions: {}

Expand All @@ -36,39 +23,37 @@ jobs:
set -Eeu
echo "matrix=$(nix eval --json '.#githubActions.matrix')" >> "$GITHUB_OUTPUT"
attribute-build:
build-attribute:
name: "${{ matrix.attr }}"
needs: attribute-matrix
permissions:
contents: read
strategy:
fail-fast: false
fail-fast: true
matrix: ${{ fromJson(needs.attribute-matrix.outputs.matrix) }}
runs-on: "${{ matrix.os }}"
steps:
- uses: actions/checkout@v4.1.5
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
- uses: cachix/cachix-action@v14
with:
name: '${{ inputs.cache-name }}'
authToken: '${{ secrets.CACHIX_TOKEN }}'
skipPush: true

- name: Build "${{ matrix.attr }}"
id: build-attribute
run: |
nix build .#${{ matrix.attr }}
NIXPKGS_ALLOW_UNFREE=1 nix build .#${{ matrix.attr }} --impure
outPath=$(nix path-info .#${{ matrix.attr }})
echo "outPath=$outPath" >> "$GITHUB_OUTPUT"
- name: Cache "${{ matrix.attr }}"
if: ${{ inputs.cache }}
run: |
cachix push ${{ inputs.cache-name }} ${{ steps.build-attribute.outputs.outPath }}
- name: Pin "${{ matrix.attr }}"
if: ${{ inputs.pin }}
run: |
cachix pin ${{ inputs.cache-name }} ${{ matrix.attr }} ${{ steps.build-attribute.outputs.outPath }} \
--keep-revisions 1
collect:
# see https://github.saobby.my.eu.orgmunity/t/status-check-for-a-matrix-jobs/127354/7
needs: [build-attribute]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Check all matrix job status
# see https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}
run: exit 1
38 changes: 0 additions & 38 deletions .github/workflows/cache-latest.yaml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: CI

env:
CACHIX_CACHE_NAME: remi-gelinas-nix
NIXPKGS_INPUT_KEYS: nixpkgs-unstable
EXTRA_SUBSTITUTERS: nix-community

on:
pull_request:
branches:
Expand All @@ -17,60 +12,8 @@ concurrency:
cancel-in-progress: true

jobs:
set-env:
runs-on: ubuntu-latest
outputs:
CACHIX_CACHE_NAME: ${{ steps.set-env.outputs.CACHIX_CACHE_NAME }}
EXTRA_SUBSTITUTERS: ${{ steps.set-env.outputs.EXTRA_SUBSTITUTERS }}
steps:
- id: set-env
run: |
echo "CACHIX_CACHE_NAME=${{ env.CACHIX_CACHE_NAME }}" >> "$GITHUB_OUTPUT"
echo "EXTRA_SUBSTITUTERS=${{ env.EXTRA_SUBSTITUTERS }}" >> "$GITHUB_OUTPUT"
nixpkgs-inputs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4.1.5
- name: Check nixpkgs inputs
uses: DeterminateSystems/flake-checker-action@v5
with:
send-statistics: false
nixpkgs-keys: "${{ env.NIXPKGS_INPUT_KEYS }}"

lint:
needs: set-env
uses: ./.github/workflows/lint.yaml
permissions:
contents: read
secrets: inherit

build-attributes:
name: Build attributes
needs: set-env
uses: ./.github/workflows/build-attributes.yaml
permissions:
contents: read
with:
cache-name: ${{ needs.set-env.outputs.CACHIX_CACHE_NAME }}
secrets: inherit

attributes-built:
# see https://github.saobby.my.eu.orgmunity/t/status-check-for-a-matrix-jobs/127354/7
name: Attributes built
needs: [build-attributes]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Check all matrix job status
# see https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}
run: exit 1
34 changes: 0 additions & 34 deletions .github/workflows/flake-inputs.yaml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/lint.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
push:
branches:
- trunk

permissions: {}

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
build-attributes:
uses: ./.github/workflows/build-attributes.yaml
permissions:
contents: read
secrets: inherit
24 changes: 3 additions & 21 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,9 @@
"nix.serverSettings": {
"nixd": {
"formatting": {
"command": "nixfmt"
},
"eval": {
"target": {
"args": [
"-f",
"default.nix"
],
"installable": "debug",
},
"depth": 10
},
"options": {
"enable": true,
"target": {
"args": [
"-f",
"default.nix"
],
"installable": "debug.options"
}
"command": [
"nixfmt"
]
}
}
}
Expand Down
42 changes: 0 additions & 42 deletions _sources/generated.json

This file was deleted.

Loading

0 comments on commit 2c43bcb

Please sign in to comment.