From 31f4850ca2fb8d40bb327ba0943719586c690dee Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Fri, 17 Nov 2023 15:39:31 +0000 Subject: [PATCH] Full CI --- .gitea/workflows/ci.yaml | 14 +++++++++----- flake.nix | 24 +++++++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 3951b60..58c88bf 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -6,7 +6,7 @@ on: jobs: check: - name: Check Nix flake + name: Check, build and cache Nix flake runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -27,10 +27,14 @@ jobs: nix run .#nixpkgs.mine.x86_64-linux.attic-client -- \ login --set-default colony https://nix-cache.nul.ie "${{ secrets.NIX_CACHE_TOKEN }}" - # - name: Check flake - # run: nix flake check + - name: Check and build flake + id: build + run: | + # nix flake check + + path=$(nix build --no-link .#ci.x86_64-linux --json | jq -r .[0].outputs.out) + echo "path=$path" >> "$GITHUB_OUTPUT" - name: Push to cache run: | - path=$(nix build --no-link .#nixosConfigurations.middleman.config.system.build.toplevel --json | jq -r .[0].outputs.out) nix run .#nixpkgs.mine.x86_64-linux.attic-client -- \ - push main $path + push main ${{ steps.build.outputs.path }} diff --git a/flake.nix b/flake.nix index c7bdac1..0ea042c 100644 --- a/flake.nix +++ b/flake.nix @@ -51,8 +51,8 @@ ... }: let - inherit (builtins) mapAttrs; - inherit (lib) genAttrs recurseIntoAttrs evalModules; + inherit (builtins) mapAttrs replaceStrings; + inherit (lib) mapAttrs' filterAttrs nameValuePair recurseIntoAttrs evalModules; inherit (lib.flake) flattenTree eachDefaultSystem; inherit (lib.my) mkDefaultSystemsPkgs flakePackageOverlay; @@ -164,16 +164,30 @@ pkgs = pkgs'.mine.${system}; lib = pkgs.lib; + filterSystem = filterAttrs (_: c: c.config.nixpkgs.system == system); + homeConfigurations = recurseIntoAttrs (mapAttrs (_: h: h.activationPackage) + (filterSystem self.homeConfigurations)); + nixosConfigurations = recurseIntoAttrs (mapAttrs (_: h: h.config.system.build.toplevel) + (filterSystem self.nixosConfigurations)); shell = pkgs.devshell.mkShell ./devshell; in # Stuff for each platform - { + rec { checks = flattenTree { - homeConfigurations = recurseIntoAttrs (mapAttrs (_: h: h.activationPackage) - (lib.filterAttrs (_: h: h.config.nixpkgs.system == system) self.homeConfigurations)); + inherit homeConfigurations; deploy = recurseIntoAttrs (pkgs.deploy-rs.lib.deployChecks self.deploy); }; + ci = + let + homes = + mapAttrs' + (n: v: nameValuePair ''home-${replaceStrings ["@"] ["-at-"] n}'' v) + homeConfigurations; + systems = mapAttrs' (n: v: nameValuePair "system-${n}" v) nixosConfigurations; + in + pkgs.linkFarm "ci" (homes // systems); + packages = flattenTree (import ./pkgs { inherit lib pkgs; }); devShells.default = shell;