From 9d1abc0bc8f342de08eb4092da3ef5e482d20a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Jan 2023 11:19:32 +0100 Subject: [PATCH 1/5] switch to flake-parts from flake-utils --- flake.lock | 23 +++++++++++------- flake.nix | 69 +++++++++++++++++++++++++++--------------------------- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/flake.lock b/flake.lock index 3cbf13e..a2240e7 100644 --- a/flake.lock +++ b/flake.lock @@ -1,17 +1,22 @@ { "nodes": { - "flake-utils": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "lastModified": 1672616755, + "narHash": "sha256-dvwU2ORLpiP6ZMXL3CJ/qrqmtLBLF6VAc+Fois7Qfew=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "87673d7c13a799d95ce25ff5dc7b9e15f01af2ea", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, @@ -33,7 +38,7 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 971dd6e..c934680 100644 --- a/flake.nix +++ b/flake.nix @@ -2,45 +2,46 @@ description = "Hydra's builtin hydra-eval-jobs as a standalone"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.flake-parts.url = "github:hercules-ci/flake-parts"; + inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; - outputs = - { self - , nixpkgs - , flake-utils - }: - flake-utils.lib.eachDefaultSystem ( - system: - let - nixVersion = nixpkgs.lib.fileContents ./.nix-version; - pkgs = nixpkgs.legacyPackages.${system}; - inherit (pkgs) stdenv; - devShell = self.devShells.${system}.default; - drvArgs = { - srcDir = self; - nix = if nixVersion == "unstable" then pkgs.nixUnstable else pkgs.nixVersions."nix_${nixVersion}"; - }; - in + outputs = inputs @ { flake-parts, ... }: + let + inherit (inputs.nixpkgs) lib; + inherit (inputs) self; + nixVersion = lib.fileContents ./.nix-version; + in + flake-parts.lib.mkFlake { inherit inputs; } { - packages.nix-eval-jobs = pkgs.callPackage ./default.nix drvArgs; + systems = inputs.nixpkgs.lib.systems.flakeExposed; + perSystem = { pkgs, self', ... }: + let + devShell = self'.devShells.default; + drvArgs = { + srcDir = self; + nix = if nixVersion == "unstable" then pkgs.nixUnstable else pkgs.nixVersions."nix_${nixVersion}"; + }; + in + { + packages.nix-eval-jobs = pkgs.callPackage ./default.nix drvArgs; - checks.treefmt = stdenv.mkDerivation { - name = "treefmt-check"; - src = self; - nativeBuildInputs = devShell.nativeBuildInputs; - dontConfigure = true; + checks.treefmt = pkgs.stdenv.mkDerivation { + name = "treefmt-check"; + src = self; + nativeBuildInputs = devShell.nativeBuildInputs; + dontConfigure = true; - inherit (devShell) NODE_PATH; + inherit (devShell) NODE_PATH; - buildPhase = '' - env HOME=$(mktemp -d) treefmt --fail-on-change - ''; + buildPhase = '' + env HOME=$(mktemp -d) treefmt --fail-on-change + ''; - installPhase = "touch $out"; - }; + installPhase = "touch $out"; + }; - packages.default = self.packages.${system}.nix-eval-jobs; - devShells.default = pkgs.callPackage ./shell.nix drvArgs; - } - ); + packages.default = self'.packages.nix-eval-jobs; + devShells.default = pkgs.callPackage ./shell.nix drvArgs; + }; + }; } From 0d5f97d6171d882749fc2f86095675c4f5ebd023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Jan 2023 11:31:28 +0100 Subject: [PATCH 2/5] switch to garnix --- .github/workflows/flake-check.yml | 46 ------------------- .../{test-develop-flakes.yml => tests.yml} | 6 ++- flake.nix | 7 +++ 3 files changed, 12 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/flake-check.yml rename .github/workflows/{test-develop-flakes.yml => tests.yml} (77%) diff --git a/.github/workflows/flake-check.yml b/.github/workflows/flake-check.yml deleted file mode 100644 index 3194ccb..0000000 --- a/.github/workflows/flake-check.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: "Flake checks" -on: - pull_request: - push: - branches: - - main - - release-* -jobs: - - flake-checks: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - steps: - - uses: actions/checkout@v3 - with: - # Nix Flakes doesn't work on shallow clones - fetch-depth: 0 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - - id: set-matrix - run: | - set -euo pipefail - - matrix="$(nix flake show --json | jq '.checks."x86_64-linux" | keys' | jq -rcM '{attr: ., os: ["ubuntu-latest", "macos-latest"]}')" - echo "::set-output name=matrix::$matrix" - - builds: - needs: flake-checks - runs-on: ${{ matrix.os }} - strategy: - matrix: ${{fromJSON(needs.flake-checks.outputs.matrix)}} - steps: - - uses: actions/checkout@v3 - with: - # Nix Flakes doesn't work on shallow clones - fetch-depth: 0 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - - run: | - set -euo pipefail - - system=$(nix-instantiate --eval --expr builtins.currentSystem | jq -r) - nix build -L .#checks.$system.${{ matrix.attr }} diff --git a/.github/workflows/test-develop-flakes.yml b/.github/workflows/tests.yml similarity index 77% rename from .github/workflows/test-develop-flakes.yml rename to .github/workflows/tests.yml index 080f0a0..6702da1 100644 --- a/.github/workflows/test-develop-flakes.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: "Development workflow" +name: "Tests" on: pull_request: push: @@ -17,6 +17,10 @@ jobs: # Nix Flakes doesn't work on shallow clones fetch-depth: 0 - uses: cachix/install-nix-action@v18 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + extra_nix_config: | + accept-flake-config = true - name: Build run: nix develop -c bash -c 'meson build && cd build && ninja' - name: Run tests diff --git a/flake.nix b/flake.nix index c934680..9259fab 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,13 @@ inputs.flake-parts.url = "github:hercules-ci/flake-parts"; inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; + nixConfig.extra-substituters = [ + "https://cache.garnix.io" + ]; + nixConfig.extra-trusted-public-keys = [ + "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" + ]; + outputs = inputs @ { flake-parts, ... }: let inherit (inputs.nixpkgs) lib; From 01369215dcecfdc41bebc4d54dff217573abebf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Jan 2023 11:21:55 +0100 Subject: [PATCH 3/5] bors: update toml --- bors.toml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bors.toml b/bors.toml index 4a9f23e..c9665f9 100644 --- a/bors.toml +++ b/bors.toml @@ -1,6 +1,2 @@ cut_body_after = "" # don't include text from the PR body in the merge commit message -status = [ - "flake-checks", - "builds (treefmt, ubuntu-latest)", - "builds (treefmt, macos-latest)" -] +status = ["tests (ubuntu-latest)", "tests (macos-latest)"] From d2c00b8c849eb93f103ba07b4a44034bb4d0c933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Jan 2023 11:35:39 +0100 Subject: [PATCH 4/5] fix build of devShell --- shell.nix | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/shell.nix b/shell.nix index f64215e..a4bda27 100644 --- a/shell.nix +++ b/shell.nix @@ -16,16 +16,13 @@ let inherit (pkgs) lib stdenv; - + nix-eval-jobs = pkgs.callPackage ./default.nix { + inherit srcDir nix; + }; in -(pkgs.callPackage ./default.nix { - inherit srcDir nix; -}).overrideAttrs (old: { - - src = null; - - nativeBuildInputs = old.nativeBuildInputs ++ [ - +pkgs.mkShell { + inherit (nix-eval-jobs) buildInputs; + nativeBuildInputs = nix-eval-jobs.nativeBuildInputs ++ [ pkgs.treefmt pkgs.llvmPackages.clang # clang-format pkgs.nixpkgs-fmt @@ -37,10 +34,9 @@ in ])) ]; - NODE_PATH = "${pkgs.nodePackages.prettier-plugin-toml}/lib/node_modules"; shellHook = lib.optionalString stdenv.isLinux '' export NIX_DEBUG_INFO_DIRS="${pkgs.curl.debug}/lib/debug:${nix.debug}/lib/debug''${NIX_DEBUG_INFO_DIRS:+:$NIX_DEBUG_INFO_DIRS}" ''; -}) +} From 24db95cbac615ebc84d57520e8d2b3821936fa85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Jan 2023 11:42:56 +0100 Subject: [PATCH 5/5] ci: also build github actions in staging --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6702da1..37a00b0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - staging - release-* jobs: tests: