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