refactor(ci): auto-discover nixosConfigurations from systems directory
Replace the hardcoded list of systems in flake.nix with automatic discovery of host directories under ./systems, and generate the CI build matrix dynamically by evaluating nixosConfigurations rather than maintaining a duplicate list in the workflow.
This commit is contained in:
@@ -8,16 +8,28 @@ on:
|
|||||||
- cron: "0 22 * * *"
|
- cron: "0 22 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
matrix:
|
||||||
|
name: generate-matrix
|
||||||
|
runs-on: self-hosted
|
||||||
|
outputs:
|
||||||
|
systems: ${{ steps.systems.outputs.systems }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Collect nixosConfigurations
|
||||||
|
id: systems
|
||||||
|
run: |
|
||||||
|
systems="$(nix eval --accept-flake-config --json \
|
||||||
|
'.#nixosConfigurations' \
|
||||||
|
--apply 'builtins.attrNames')"
|
||||||
|
echo "systems=$systems" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: build-${{ matrix.system }}
|
name: build-${{ matrix.system }}
|
||||||
|
needs: matrix
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
system:
|
system: ${{ fromJSON(needs.matrix.outputs.systems) }}
|
||||||
- "bob"
|
|
||||||
- "brain"
|
|
||||||
- "jeeves"
|
|
||||||
- "rhapsody-in-green"
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -95,37 +95,18 @@
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations =
|
||||||
bob = lib.nixosSystem {
|
let
|
||||||
modules = [
|
hosts = builtins.attrNames (
|
||||||
./systems/bob
|
lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./systems)
|
||||||
];
|
);
|
||||||
|
mkHost =
|
||||||
|
name:
|
||||||
|
lib.nixosSystem {
|
||||||
|
modules = [ ./systems/${name} ];
|
||||||
specialArgs = { inherit inputs outputs; };
|
specialArgs = { inherit inputs outputs; };
|
||||||
};
|
};
|
||||||
brain = lib.nixosSystem {
|
in
|
||||||
modules = [
|
lib.genAttrs hosts mkHost;
|
||||||
./systems/brain
|
|
||||||
];
|
|
||||||
specialArgs = { inherit inputs outputs; };
|
|
||||||
};
|
|
||||||
jeeves = lib.nixosSystem {
|
|
||||||
modules = [
|
|
||||||
./systems/jeeves
|
|
||||||
];
|
|
||||||
specialArgs = { inherit inputs outputs; };
|
|
||||||
};
|
|
||||||
rhapsody-in-green = lib.nixosSystem {
|
|
||||||
modules = [
|
|
||||||
./systems/rhapsody-in-green
|
|
||||||
];
|
|
||||||
specialArgs = { inherit inputs outputs; };
|
|
||||||
};
|
|
||||||
iso = lib.nixosSystem {
|
|
||||||
modules = [
|
|
||||||
./systems/iso
|
|
||||||
];
|
|
||||||
specialArgs = { inherit inputs outputs; };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user