Skip to content

Commit 746d5c8

Browse files
committed
Remove flake-parts dependency
1 parent 530c34c commit 746d5c8

File tree

5 files changed

+100
-153
lines changed

5 files changed

+100
-153
lines changed

flake.lock

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
88

99
# dev tooling
10-
inputs.flake-parts.url = "https://flakehub.com/f/hercules-ci/flake-parts/0.1";
1110
inputs.git-hooks-nix.url = "https://flakehub.com/f/cachix/git-hooks.nix/0.1.941";
1211
# work around https://github.com/NixOS/nix/issues/7730
13-
inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
1412
inputs.git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
1513
# work around 7730 and https://github.com/NixOS/nix/issues/7807
1614
inputs.git-hooks-nix.inputs.gitignore.follows = "";
@@ -75,17 +73,21 @@
7573

7674
forAllStdenvs = lib.genAttrs stdenvs;
7775

78-
# We don't apply flake-parts to the whole flake so that non-development attributes
79-
# load without fetching any development inputs.
80-
devFlake = inputs.flake-parts.lib.mkFlake { inherit inputs; } {
81-
imports = [ ./maintainers/flake-module.nix ];
82-
systems = lib.subtractLists crossSystems systems;
83-
perSystem =
84-
{ system, ... }:
85-
{
86-
_module.args.pkgs = nixpkgsFor.${system}.native;
76+
# Pre-commit hooks configuration
77+
preCommitHooksFor =
78+
system:
79+
let
80+
pkgs = nixpkgsFor.${system}.native;
81+
hooksSettings = import ./packaging/pre-commit-hook-settings.nix {
82+
inherit lib pkgs;
83+
src = self;
8784
};
88-
};
85+
git-hooks = inputs.git-hooks-nix.lib.${system};
86+
in
87+
{
88+
check = git-hooks.run hooksSettings;
89+
settings = hooksSettings;
90+
};
8991

9092
# Memoize nixpkgs for different platforms for efficiency.
9193
nixpkgsFor = forAllSystems (
@@ -345,7 +347,9 @@
345347
}
346348
)).componentTests
347349
)
348-
// devFlake.checks.${system} or { }
350+
// {
351+
pre-commit-check = (preCommitHooksFor system).check;
352+
}
349353
);
350354

351355
packages = forAllSystems (
@@ -494,7 +498,7 @@
494498

495499
devShells =
496500
let
497-
makeShell = import ./packaging/dev-shell.nix { inherit lib devFlake; };
501+
makeShell = import ./packaging/dev-shell.nix { inherit lib preCommitHooksFor; };
498502
prefixAttrs = prefix: lib.concatMapAttrs (k: v: { "${prefix}-${k}" = v; });
499503
in
500504
forAllSystems (

maintainers/flake-module.nix

Lines changed: 0 additions & 114 deletions
This file was deleted.

packaging/dev-shell.nix

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
lib,
3-
devFlake,
3+
preCommitHooksFor,
44
}:
55

66
{ pkgs }:
@@ -11,7 +11,7 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
1111
let
1212
stdenv = pkgs.nixDependencies2.stdenv;
1313
buildCanExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
14-
modular = devFlake.getSystem stdenv.buildPlatform.system;
14+
modular = preCommitHooksFor stdenv.buildPlatform.system;
1515
transformFlag =
1616
prefix: flag:
1717
assert builtins.isString flag;
@@ -74,7 +74,7 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
7474
env = {
7575
# For `make format`, to work without installing pre-commit
7676
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
77-
modular.pre-commit.settings.rawConfig
77+
modular.settings
7878
}";
7979
}
8080
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
@@ -115,8 +115,7 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
115115
pkgs.buildPackages.gnused
116116
pkgs.buildPackages.shellcheck
117117
pkgs.buildPackages.changelog-d
118-
modular.pre-commit.settings.package
119-
(pkgs.writeScriptBin "pre-commit-hooks-install" modular.pre-commit.settings.installationScript)
118+
pkgs.buildPackages.pre-commit
120119
pkgs.buildPackages.nixfmt-rfc-style
121120
pkgs.buildPackages.shellcheck
122121
pkgs.buildPackages.gdb
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
pkgs,
3+
lib,
4+
src,
5+
}:
6+
7+
{
8+
hooks = {
9+
check-merge-conflicts.enable = true;
10+
check-merge-conflicts-2 = {
11+
enable = true;
12+
entry = "${pkgs.writeScript "check-merge-conflicts" ''
13+
#!${pkgs.runtimeShell}
14+
conflicts=false
15+
for file in "$@"; do
16+
if grep --with-filename --line-number -E '^>>>>>>> ' -- "$file"; then
17+
conflicts=true
18+
fi
19+
done
20+
if $conflicts; then
21+
echo "ERROR: found merge/patch conflicts in files"
22+
exit 1
23+
fi
24+
''}";
25+
};
26+
meson-format =
27+
let
28+
meson = pkgs.meson.overrideAttrs {
29+
doCheck = false;
30+
doInstallCheck = false;
31+
patches = [
32+
(pkgs.fetchpatch {
33+
url = "https://github.com/mesonbuild/meson/commit/38d29b4dd19698d5cad7b599add2a69b243fd88a.patch";
34+
hash = "sha256-PgPBvGtCISKn1qQQhzBW5XfknUe91i5XGGBcaUK4yeE=";
35+
})
36+
];
37+
};
38+
in
39+
{
40+
enable = true;
41+
files = "(meson.build|meson.options)$";
42+
entry = "${pkgs.writeScript "format-meson" ''
43+
#!${pkgs.runtimeShell}
44+
for file in "$@"; do
45+
${lib.getExe meson} format -ic ${./meson.format} "$file"
46+
done
47+
''}";
48+
};
49+
nixfmt-rfc-style = {
50+
enable = true;
51+
excludes = [
52+
''^tests/functional/lang/parse-.*\.nix$''
53+
''^tests/functional/lang/eval-okay-curpos\.nix$''
54+
''^tests/functional/lang/.*comment.*\.nix$''
55+
''^tests/functional/lang/.*newline.*\.nix$''
56+
''^tests/functional/lang/.*eol.*\.nix$''
57+
''^tests/functional/shell.shebang\.nix$''
58+
''^tests/functional/lang/eval-okay-ind-string\.nix$''
59+
''^tests/functional/lang/eval-okay-deprecate-cursed-or\.nix$''
60+
''^tests/functional/lang/eval-okay-attrs5\.nix$''
61+
''^tests/functional/lang/eval-fail-eol-2\.nix$''
62+
''^tests/functional/lang/eval-fail-path-slash\.nix$''
63+
''^tests/functional/lang/eval-fail-toJSON-non-utf-8\.nix$''
64+
''^tests/functional/lang/eval-fail-set\.nix$''
65+
];
66+
};
67+
clang-format = {
68+
enable = true;
69+
package = pkgs.llvmPackages_latest.clang-tools;
70+
excludes = [
71+
''^src/[^/]*-tests/data/.*$''
72+
''^doc/manual/redirects\.js$''
73+
''^doc/manual/theme/highlight\.js$''
74+
];
75+
};
76+
shellcheck.enable = true;
77+
};
78+
}

0 commit comments

Comments
 (0)