diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4580d90d..a9bd9b87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,55 @@ on: workflow_dispatch: jobs: - test: + eval: + name: Evaluate packages + + runs-on: ubuntu-latest + + outputs: + matrix: ${{ steps.evaluate.outputs.matrix }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@V27 + + - name: Setup cache + uses: DeterminateSystems/magic-nix-cache-action@v8 + + - name: Evaluate & output matrix + id: evaluate + run: | + echo "matrix=$(nix run .#eval-matrix -- 'hydraJobs.packages')" >> "$GITHUB_OUTPUT" + + packages: + name: Build packages.${{ matrix.attr }} + needs: eval + + strategy: + matrix: ${{ fromJSON(needs.eval.outputs.matrix) }} + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@V27 + + - name: Setup cache + uses: DeterminateSystems/magic-nix-cache-action@v8 + + - name: Run build + run: | + nix build --print-build-logs --show-trace '.#${{ matrix.attr }}' + + modules: name: Test Modules + needs: packages strategy: fail-fast: false @@ -40,3 +87,14 @@ jobs: github:Mic92/nix-fast-build -- \ --no-nom \ --flake ".#checks.$(nix eval --raw --impure --expr builtins.currentSystem)" + + release-gate: + name: Release Gate + needs: [ eval, packages, modules ] + + runs-on: ubuntu-latest + + steps: + - name: Exit with error + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: exit 1 diff --git a/.gitignore b/.gitignore index b272df7c..591b2ba3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ result result-* repl-result-* - +gcroot/ diff --git a/flake.nix b/flake.nix index fe06cbae..e4a57607 100644 --- a/flake.nix +++ b/flake.nix @@ -84,6 +84,69 @@ in { apps = { + eval-matrix = { + type = "app"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "nix-eval-matrix"; + + runtimeInputs = [ + pkgs.jq + pkgs.nix-eval-jobs + ]; + + text = '' + usage="Usage: $0 " + + attribute="''${1:-}" + if [ -z "$attribute" ]; then + echo -n "$usage" + exit 1 + fi + + filter=' + { + includes: [ + .[] | { + attr, + system, + os: ( + if .system == "x86_64-linux" then + "ubuntu-latest" + elif .system == "aarch64-darwin" then + "macos-latest" + elif .system == "x86_64-darwin" then + "macos-13" + else + null + end + ) + } + ] + } + ' + + gcroot_dir="$(mktemp -d)" + trap 'rm -r "$gcroot_dir"' EXIT + + eval_jobs_args=( + "--gc-roots-dir" "$gcroot_dir" + "--force-recurse" + "--flake" "${self.outPath}#$attribute" + ) + + jq_args=( + "--compact-output" + "--slurp" + "$filter" + ) + + nix-eval-jobs "''${eval_jobs_args[@]}" | jq "''${jq_args[@]}" + ''; + } + ); + }; + serve = { type = "app"; program = lib.getExe self.packages.${system}.site.serve; @@ -149,6 +212,23 @@ )) { + hydraJobs = + let + supportedSystems = [ + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + in + { + checks = lib.getAttrs [ + "x86_64-linux" + "aarch64-darwin" + ] self.checks; + + packages = lib.getAttrs supportedSystems self.packages; + }; + homeManagerModules.catppuccin = mkModule { type = "homeManager"; file = ./modules/home-manager;