aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorQyriad <qyriad@qyriad.me>2024-05-07 22:14:22 +0000
committerGerrit Code Review <gerrit@lix-systems>2024-05-07 22:14:22 +0000
commit8715a0ac4e5621fe48ddf6d3712c35cc08e347b2 (patch)
tree69704b09ebabba9f83dd89b7f5b6e0b784876196 /flake.nix
parente8a603fb2f6418307c3521785b3c8d73396792d8 (diff)
parent7e940cc1706397787c66aa8a52b3b8f96cfc2b5a (diff)
Merge changes If1077a7b,I62da3161,Iebb4667b into main
* changes: flake: fix devShell on i686-linux by disabling ClangBuildAnalyzer on it flake: fix eval of checks & devshell on i686-linux flake: move the pre-commit definition to its own file
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix102
1 files changed, 15 insertions, 87 deletions
diff --git a/flake.nix b/flake.nix
index 1c090cadf..79ac9caea 100644
--- a/flake.nix
+++ b/flake.nix
@@ -96,6 +96,10 @@
];
forAllSystems = lib.genAttrs systems;
+ # Same as forAllSystems, but removes nulls, in case something is broken
+ # on that system.
+ forAvailableSystems =
+ f: lib.filterAttrs (name: value: value != null && value != { }) (forAllSystems f);
forAllCrossSystems = lib.genAttrs crossSystems;
@@ -282,99 +286,21 @@
);
};
- pre-commit = forAllSystems (
+ pre-commit = forAvailableSystems (
system:
let
pkgs = nixpkgsFor.${system}.native;
- # Import pre-commit bypassing the flake because flakes don't let
- # you have overlays. Also their implementation forces an
- # unnecessary reimport of nixpkgs for our use cases.
- tools = import (pre-commit-hooks + "/nix/call-tools.nix") pkgs;
- pre-commit-run = pkgs.callPackage (pre-commit-hooks + "/nix/run.nix") {
- inherit tools;
- isFlakes = true;
- # unused!
- gitignore-nix-src = builtins.throw "gitignore-nix-src is unused";
- };
+ pre-commit-check = import ./misc/pre-commit.nix { inherit self pkgs pre-commit-hooks; };
+ # dotnet-sdk_6, a nativeBuildInputs of pre-commit, is broken on i686-linux.
+ available = lib.meta.availableOn { inherit system; } pkgs.dotnet-sdk_6;
in
- pre-commit-run {
- src = self;
- hooks = {
- no-commit-to-branch = {
- enable = true;
- settings.branch = [ "main" ];
- };
- check-case-conflicts.enable = true;
- check-executables-have-shebangs = {
- enable = true;
- stages = [ "commit" ];
- };
- check-shebang-scripts-are-executable = {
- enable = true;
- stages = [ "commit" ];
- };
- check-symlinks = {
- enable = true;
- excludes = [ "^tests/functional/lang/symlink-resolution/broken$" ];
- };
- check-merge-conflicts.enable = true;
- end-of-file-fixer = {
- enable = true;
- excludes = [
- "\\.drv$"
- "^tests/functional/lang/"
- ];
- };
- mixed-line-endings = {
- enable = true;
- excludes = [ "^tests/functional/lang/" ];
- };
- release-notes = {
- enable = true;
- package = pkgs.build-release-notes;
- files = "^doc/manual/rl-next(-dev)?";
- pass_filenames = false;
- entry = ''
- ${lib.getExe pkgs.build-release-notes} doc/manual/rl-next doc/manual/rl-next-dev
- '';
- };
- check-headers = {
- enable = true;
- package = pkgs.check-headers;
- files = "^src/";
- types = [
- "c++"
- "file"
- "header"
- ];
- # generated files; these will never actually be seen by this
- # check, and are left here as documentation
- excludes = [
- "(parser|lexer)-tab\\.hh$"
- "\\.gen\\.hh$"
- ];
- entry = lib.getExe pkgs.check-headers;
- };
- # TODO: Once the test suite is nicer, clean up and start
- # enforcing trailing whitespace on tests that don't explicitly
- # check for it.
- trim-trailing-whitespace = {
- enable = true;
- stages = [ "commit" ];
- excludes = [ "^tests/functional/lang/" ];
- };
- treefmt = {
- enable = true;
- settings.formatters = [ pkgs.nixfmt ];
- };
- };
- }
+ lib.optionalAttrs available pre-commit-check
);
};
# NOTE *do not* add fresh derivations to checks, always add them to
# hydraJobs first (so CI will pick them up) and only link them here
- checks = forAllSystems (
+ checks = forAvailableSystems (
system:
{
binaryTarball = self.hydraJobs.binaryTarball.${system};
@@ -382,6 +308,7 @@
nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system};
rl-next = self.hydraJobs.rl-next.${system}.user;
rl-next-dev = self.hydraJobs.rl-next.${system}.dev;
+ # Will be empty attr set on i686-linux, and filtered out by forAvailableSystems.
pre-commit = self.hydraJobs.pre-commit.${system};
}
// (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
@@ -481,9 +408,10 @@
pkgs.buildPackages.meson
pkgs.buildPackages.ninja
pkgs.buildPackages.cmake
-
- pkgs.buildPackages.clangbuildanalyzer
- ];
+ ]
+ ++
+ lib.optionals (lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.buildPackages.clangbuildanalyzer)
+ [ pkgs.buildPackages.clangbuildanalyzer ];
src = null;