-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
flake.nix
99 lines (93 loc) · 3.51 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
description = "Hydra's builtin hydra-eval-jobs as a standalone";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
outputs =
inputs@{ flake-parts, ... }:
let
inherit (inputs.nixpkgs) lib;
inherit (inputs) self;
nixVersion = lib.fileContents ./.nix-version;
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.treefmt-nix.flakeModule ];
flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
platforms = {
"x86_64-linux" = [
"nscloud-ubuntu-22.04-amd64-4x16-with-cache"
"nscloud-cache-size-20gb"
"nscloud-cache-tag-nix-eval-jobs"
];
"x86_64-darwin" = "macos-13";
"aarch64-darwin" = "macos-latest";
"aarch64-linux" = [
"nscloud-ubuntu-22.04-arm64-4x16-with-cache"
"nscloud-cache-size-20gb"
"nscloud-cache-tag-nix-eval-jobs"
];
};
checks = {
inherit (self.checks) x86_64-linux aarch64-linux aarch64-darwin;
x86_64-darwin = builtins.removeAttrs self.checks.x86_64-darwin [ "treefmt" ];
};
};
perSystem =
{ pkgs, self', ... }:
let
drvArgs = {
srcDir = self;
nix =
if nixVersion == "latest" then pkgs.nixVersions.latest else pkgs.nixVersions."nix_${nixVersion}";
};
in
{
treefmt.imports = [ ./dev/treefmt.nix ];
packages.nix-eval-jobs = pkgs.callPackage ./default.nix drvArgs;
packages.clangStdenv-nix-eval-jobs = pkgs.callPackage ./default.nix (
drvArgs // { stdenv = pkgs.clangStdenv; }
);
packages.default = self'.packages.nix-eval-jobs;
devShells.default = pkgs.callPackage ./shell.nix drvArgs;
devShells.clang = pkgs.callPackage ./shell.nix (drvArgs // { stdenv = pkgs.clangStdenv; });
checks = builtins.removeAttrs self'.packages [ "default" ] // {
shell = self'.devShells.default;
clang-tidy-fix = self'.packages.nix-eval-jobs.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.git
(lib.hiPrio pkgs.llvmPackages_latest.clang-tools)
];
buildPhase = ''
export HOME=$TMPDIR
cat > $HOME/.gitconfig <<EOF
[user]
name = Nix
email = nix@localhost
[init]
defaultBranch = main
EOF
pushd ..
git init
git add .
git commit -m init --quiet
popd
ninja clang-tidy-fix
git status
if ! git --no-pager diff --exit-code; then
echo "clang-tidy-fix failed, please run `ninja clang-tidy-fix` and commit the changes"
exit 1
fi
'';
installPhase = ''
touch $out
'';
});
};
};
};
}