165: switch to flake-parts from flake-utils r=Mic92 a=Mic92



Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
This commit is contained in:
bors[bot] 2023-01-02 10:43:31 +00:00 committed by GitHub
commit f2315738db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 106 deletions

View file

@ -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 }}

View file

@ -1,9 +1,10 @@
name: "Development workflow" name: "Tests"
on: on:
pull_request: pull_request:
push: push:
branches: branches:
- main - main
- staging
- release-* - release-*
jobs: jobs:
tests: tests:
@ -17,6 +18,10 @@ jobs:
# Nix Flakes doesn't work on shallow clones # Nix Flakes doesn't work on shallow clones
fetch-depth: 0 fetch-depth: 0
- uses: cachix/install-nix-action@v18 - uses: cachix/install-nix-action@v18
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
accept-flake-config = true
- name: Build - name: Build
run: nix develop -c bash -c 'meson build && cd build && ninja' run: nix develop -c bash -c 'meson build && cd build && ninja'
- name: Run tests - name: Run tests

View file

@ -1,6 +1,2 @@
cut_body_after = "" # don't include text from the PR body in the merge commit message cut_body_after = "" # don't include text from the PR body in the merge commit message
status = [ status = ["tests (ubuntu-latest)", "tests (macos-latest)"]
"flake-checks",
"builds (treefmt, ubuntu-latest)",
"builds (treefmt, macos-latest)"
]

View file

@ -1,17 +1,22 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1667395993, "lastModified": 1672616755,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "narHash": "sha256-dvwU2ORLpiP6ZMXL3CJ/qrqmtLBLF6VAc+Fois7Qfew=",
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "rev": "87673d7c13a799d95ce25ff5dc7b9e15f01af2ea",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"type": "github" "type": "github"
} }
}, },
@ -33,7 +38,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View file

@ -2,45 +2,53 @@
description = "Hydra's builtin hydra-eval-jobs as a standalone"; description = "Hydra's builtin hydra-eval-jobs as a standalone";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 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 = nixConfig.extra-substituters = [
{ self "https://cache.garnix.io"
, nixpkgs ];
, flake-utils nixConfig.extra-trusted-public-keys = [
}: "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
flake-utils.lib.eachDefaultSystem ( ];
system:
let outputs = inputs @ { flake-parts, ... }:
nixVersion = nixpkgs.lib.fileContents ./.nix-version; let
pkgs = nixpkgs.legacyPackages.${system}; inherit (inputs.nixpkgs) lib;
inherit (pkgs) stdenv; inherit (inputs) self;
devShell = self.devShells.${system}.default; nixVersion = lib.fileContents ./.nix-version;
drvArgs = { in
srcDir = self; flake-parts.lib.mkFlake { inherit inputs; }
nix = if nixVersion == "unstable" then pkgs.nixUnstable else pkgs.nixVersions."nix_${nixVersion}";
};
in
{ {
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 { checks.treefmt = pkgs.stdenv.mkDerivation {
name = "treefmt-check"; name = "treefmt-check";
src = self; src = self;
nativeBuildInputs = devShell.nativeBuildInputs; nativeBuildInputs = devShell.nativeBuildInputs;
dontConfigure = true; dontConfigure = true;
inherit (devShell) NODE_PATH; inherit (devShell) NODE_PATH;
buildPhase = '' buildPhase = ''
env HOME=$(mktemp -d) treefmt --fail-on-change env HOME=$(mktemp -d) treefmt --fail-on-change
''; '';
installPhase = "touch $out"; installPhase = "touch $out";
}; };
packages.default = self.packages.${system}.nix-eval-jobs; packages.default = self'.packages.nix-eval-jobs;
devShells.default = pkgs.callPackage ./shell.nix drvArgs; devShells.default = pkgs.callPackage ./shell.nix drvArgs;
} };
); };
} }

View file

@ -16,16 +16,13 @@
let let
inherit (pkgs) lib stdenv; inherit (pkgs) lib stdenv;
nix-eval-jobs = pkgs.callPackage ./default.nix {
inherit srcDir nix;
};
in in
(pkgs.callPackage ./default.nix { pkgs.mkShell {
inherit srcDir nix; inherit (nix-eval-jobs) buildInputs;
}).overrideAttrs (old: { nativeBuildInputs = nix-eval-jobs.nativeBuildInputs ++ [
src = null;
nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.treefmt pkgs.treefmt
pkgs.llvmPackages.clang # clang-format pkgs.llvmPackages.clang # clang-format
pkgs.nixpkgs-fmt pkgs.nixpkgs-fmt
@ -37,10 +34,9 @@ in
])) ]))
]; ];
NODE_PATH = "${pkgs.nodePackages.prettier-plugin-toml}/lib/node_modules"; NODE_PATH = "${pkgs.nodePackages.prettier-plugin-toml}/lib/node_modules";
shellHook = lib.optionalString stdenv.isLinux '' 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}" export NIX_DEBUG_INFO_DIRS="${pkgs.curl.debug}/lib/debug:${nix.debug}/lib/debug''${NIX_DEBUG_INFO_DIRS:+:$NIX_DEBUG_INFO_DIRS}"
''; '';
}) }