Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ den.oeiuwq.com
configurations den dendritic nix aspect oriented
at main 126 lines 4.5 kB view raw
1on: 2 push: 3 branches: [main] 4 pull_request: 5 types: [labeled, opened, synchronize, reopened, review_requested, ready_for_review] 6 pull_request_review: 7 types: [submitted] 8concurrency: 9 group: ${{ github.workflow }}-${{ github.ref }} 10 cancel-in-progress: true 11jobs: 12 non-draft: 13 runs-on: ubuntu-latest 14 if: ${{github.ref == 'refs/heads/main' || github.event.pull_request.draft == false}} 15 steps: 16 - uses: actions/checkout@v4 17 - run: | 18 git fetch --depth 1 origin refs/heads/main 19 test "refs/heads/main" == "${{github.ref}}" || (git diff --name-only origin/main..${{ github.sha }} -- | grep '.nix') 20 tests: 21 needs: [non-draft] 22 strategy: 23 matrix: 24 os: [ubuntu-latest, macos-latest] 25 name: Tests ${{matrix.os}} 26 runs-on: ${{matrix.os}} 27 steps: 28 - uses: wimpysworld/nothing-but-nix@main 29 - uses: cachix/install-nix-action@v31 30 - uses: DeterminateSystems/magic-nix-cache-action@v13 31 - run: nix flake init -t github:$GITHUB_REPOSITORY/$GITHUB_SHA#ci 32 - run: sed -i "s@\"github:vic/den\"@\"github:vic/den/$GITHUB_SHA\"@" flake.nix 33 if: matrix.os == 'ubuntu-latest' 34 - run: sed -i '' "s@\"github:vic/den\"@\"github:vic/den/$GITHUB_SHA\"@" flake.nix 35 if: matrix.os == 'macos-latest' 36 - run: | 37 cat <<-EOF > modules/ci-runtime.nix 38 { lib, ... }: 39 { 40 _module.args.CI = true; 41 } 42 EOF 43 - run: nix flake update den 44 - run: nix flake metadata 45 - run: nix flake check -L 46 flake-check: 47 needs: [non-draft] 48 name: nix flake check 49 runs-on: ubuntu-latest 50 steps: 51 - uses: cachix/install-nix-action@v31 52 - run: nix flake check -L github:vic/checkmate --override-input target github:$GITHUB_REPOSITORY/$GITHUB_SHA 53 approved: 54 needs: [non-draft] 55 name: approved 56 runs-on: ubuntu-latest 57 if: ${{github.ref == 'refs/heads/main' || contains( github.event.pull_request.labels.*.name, 'approved')}} 58 steps: 59 - run: true 60 noflake: 61 needs: [approved] 62 name: noflake 63 runs-on: ubuntu-latest 64 steps: 65 - uses: wimpysworld/nothing-but-nix@main 66 - uses: cachix/install-nix-action@v31 67 - uses: DeterminateSystems/magic-nix-cache-action@v13 68 - uses: actions/checkout@v4 69 - run: sed -i 's@# den.outPath@den.outPath@' templates/noflake/default.nix 70 - run: | 71 cat <<-EOF > templates/noflake/modules/ci-runtime.nix 72 { 73 _module.args.CI = true; 74 } 75 EOF 76 git add templates/noflake/modules/ci-runtime.nix 77 - run: cd templates/noflake && nix-build -A flake.nixosConfigurations.igloo.config.system.build.toplevel 78 template: 79 needs: [approved] 80 strategy: 81 matrix: 82 template: [bogus, minimal, microvm] 83 os: [ubuntu-latest] 84 name: Check template ${{matrix.template}} ${{matrix.os}} 85 runs-on: ${{matrix.os}} 86 steps: 87 - uses: wimpysworld/nothing-but-nix@main 88 - uses: cachix/install-nix-action@v31 89 - uses: DeterminateSystems/magic-nix-cache-action@v13 90 - uses: actions/checkout@v4 91 - run: | 92 cat <<-EOF > templates/${{matrix.template}}/modules/ci-runtime.nix 93 { 94 _module.args.CI = true; 95 } 96 EOF 97 git add templates/${{matrix.template}}/modules/ci-runtime.nix 98 - run: nix flake check -L ./templates/${{matrix.template}} --override-input den github:$GITHUB_REPOSITORY/$GITHUB_SHA 99 flake-file-template: 100 needs: [approved] 101 strategy: 102 # max-parallel: 1 103 matrix: 104 os: [ubuntu-latest] 105 template: [default, example] 106 name: Check template ${{matrix.template}} ${{matrix.os}} 107 runs-on: ${{matrix.os}} 108 steps: 109 - uses: wimpysworld/nothing-but-nix@main 110 if: matrix.os == 'ubuntu-latest' 111 - uses: cachix/install-nix-action@v31 112 # - uses: DeterminateSystems/magic-nix-cache-action@v13 113 - run: nix flake init -t github:$GITHUB_REPOSITORY/$GITHUB_SHA#${{matrix.template}} 114 - run: | 115 cat <<-EOF > modules/ci-runtime.nix 116 { lib, ... }: 117 { 118 flake-file.inputs.den.url = lib.mkForce "github:$GITHUB_REPOSITORY/$GITHUB_SHA"; 119 _module.args.CI = true; 120 } 121 EOF 122 - run: nix run .#write-flake --override-input den "github:$GITHUB_REPOSITORY/$GITHUB_SHA" 123 - run: nix flake update den 124 - run: nix run .#write-flake 125 - run: nix flake metadata 126 - run: nix flake check -L --no-build