Skip to content

Commit cd87afb

Browse files
authored
Merge pull request #65 from cachix/20.09
NixOS 20.09
2 parents 4dd50ef + 9ef0d41 commit cd87afb

11 files changed

+184
-216
lines changed

bors.toml

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

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
let pkgs = import ./nix {}; in pkgs.packages
1+
let pkgs = import ./nix { }; in pkgs.packages

modules/hooks.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ in
1212
mkOption {
1313
type = types.listOf types.str;
1414
description = "Haskell language extensions to enable";
15-
default = [];
15+
default = [ ];
1616
};
1717
};
1818
nix-linter =
@@ -22,7 +22,7 @@ in
2222
type = types.listOf types.str;
2323
description =
2424
"Available checks (See `nix-linter --help-for [CHECK]` for more details)";
25-
default = [];
25+
default = [ ];
2626
};
2727
};
2828
};

modules/pre-commit.nix

Lines changed: 110 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{ config, lib, pkgs, ... }:
2-
32
let
4-
53
inherit (lib)
64
attrNames
75
concatStringsSep
@@ -21,122 +19,123 @@ let
2119
hookType =
2220
types.submodule (
2321
{ config, name, ... }:
24-
{
25-
options =
26-
{
27-
enable =
28-
mkOption {
29-
type = types.bool;
30-
description = "Whether to enable this pre-commit hook.";
31-
default = false;
32-
};
33-
raw =
34-
mkOption {
35-
type = types.attrsOf types.unspecified;
36-
description =
37-
''
38-
Raw fields of a pre-commit hook. This is mostly for internal use but
39-
exposed in case you need to work around something.
22+
{
23+
options =
24+
{
25+
enable =
26+
mkOption {
27+
type = types.bool;
28+
description = "Whether to enable this pre-commit hook.";
29+
default = false;
30+
};
31+
raw =
32+
mkOption {
33+
type = types.attrsOf types.unspecified;
34+
description =
35+
''
36+
Raw fields of a pre-commit hook. This is mostly for internal use but
37+
exposed in case you need to work around something.
4038
41-
Default: taken from the other hook options.
42-
'';
43-
};
44-
name =
45-
mkOption {
46-
type = types.str;
47-
default = name;
48-
defaultText = literalExample "internal name, same as id";
49-
description =
50-
''
51-
The name of the hook - shown during hook execution.
52-
'';
53-
};
54-
entry =
55-
mkOption {
56-
type = types.str;
57-
description =
58-
''
59-
The entry point - the executable to run. entry can also contain arguments that will not be overridden such as entry: autopep8 -i.
60-
'';
61-
};
62-
language =
63-
mkOption {
64-
type = types.str;
65-
description =
66-
''
67-
The language of the hook - tells pre-commit how to install the hook.
68-
'';
69-
default = "system";
70-
};
71-
files =
72-
mkOption {
73-
type = types.str;
74-
description =
75-
''
76-
The pattern of files to run on.
77-
'';
78-
default = "";
79-
};
80-
types =
81-
mkOption {
82-
type = types.listOf types.str;
83-
description =
84-
''
85-
List of file types to run on. See Filtering files with types (https://pre-commit.com/#plugins).
86-
'';
87-
default = [ "file" ];
88-
};
89-
description =
90-
mkOption {
91-
type = types.str;
92-
description =
93-
''
94-
Description of the hook. used for metadata purposes only.
95-
'';
96-
default = "";
97-
};
98-
excludes =
99-
mkOption {
100-
type = types.listOf types.str;
101-
description =
102-
''
103-
Exclude files that were matched by these patterns.
104-
'';
105-
default = [];
106-
};
107-
pass_filenames =
108-
mkOption {
109-
type = types.bool;
110-
description = "Whether to pass filenames as arguments to the entry point.";
111-
default = true;
112-
};
113-
};
114-
config =
115-
{
116-
raw =
117-
{
118-
inherit (config) name entry language files types pass_filenames;
119-
id = name;
120-
exclude = mergeExcludes config.excludes;
121-
};
122-
};
123-
}
39+
Default: taken from the other hook options.
40+
'';
41+
};
42+
name =
43+
mkOption {
44+
type = types.str;
45+
default = name;
46+
defaultText = literalExample "internal name, same as id";
47+
description =
48+
''
49+
The name of the hook - shown during hook execution.
50+
'';
51+
};
52+
entry =
53+
mkOption {
54+
type = types.str;
55+
description =
56+
''
57+
The entry point - the executable to run. entry can also contain arguments that will not be overridden such as entry: autopep8 -i.
58+
'';
59+
};
60+
language =
61+
mkOption {
62+
type = types.str;
63+
description =
64+
''
65+
The language of the hook - tells pre-commit how to install the hook.
66+
'';
67+
default = "system";
68+
};
69+
files =
70+
mkOption {
71+
type = types.str;
72+
description =
73+
''
74+
The pattern of files to run on.
75+
'';
76+
default = "";
77+
};
78+
types =
79+
mkOption {
80+
type = types.listOf types.str;
81+
description =
82+
''
83+
List of file types to run on. See Filtering files with types (https://pre-commit.com/#plugins).
84+
'';
85+
default = [ "file" ];
86+
};
87+
description =
88+
mkOption {
89+
type = types.str;
90+
description =
91+
''
92+
Description of the hook. used for metadata purposes only.
93+
'';
94+
default = "";
95+
};
96+
excludes =
97+
mkOption {
98+
type = types.listOf types.str;
99+
description =
100+
''
101+
Exclude files that were matched by these patterns.
102+
'';
103+
default = [ ];
104+
};
105+
pass_filenames =
106+
mkOption {
107+
type = types.bool;
108+
description = "Whether to pass filenames as arguments to the entry point.";
109+
default = true;
110+
};
111+
};
112+
config =
113+
{
114+
raw =
115+
{
116+
inherit (config) name entry language files types pass_filenames;
117+
id = name;
118+
exclude = mergeExcludes config.excludes;
119+
};
120+
};
121+
}
124122
);
125123

126124
mergeExcludes =
127125
excludes:
128-
if excludes == [] then "^$" else "(${concatStringsSep "|" excludes})";
126+
if excludes == [ ] then "^$" else "(${concatStringsSep "|" excludes})";
129127

130128
enabledHooks = filterAttrs (id: value: value.enable) cfg.hooks;
131129
processedHooks =
132130
mapAttrsToList (id: value: value.raw // { inherit id; }) enabledHooks;
133131

134132
configFile =
135-
runCommand "pre-commit-config.json" {
136-
buildInputs = [ pkgs.jq ];
137-
passAsFile = [ "rawJSON" ];
138-
rawJSON = builtins.toJSON cfg.rawConfig;
139-
} ''
133+
runCommand "pre-commit-config.json"
134+
{
135+
buildInputs = [ pkgs.jq ];
136+
passAsFile = [ "rawJSON" ];
137+
rawJSON = builtins.toJSON cfg.rawConfig;
138+
} ''
140139
{
141140
echo '# DO NOT MODIFY';
142141
echo '# This file was generated by nix-pre-commit-hooks';
@@ -200,7 +199,7 @@ in
200199
'';
201200
# This default is for when the module is the entry point rather than
202201
# /default.nix. /default.nix will override this for efficiency.
203-
default = (import ../nix { inherit (pkgs) system; }).callPackage ../nix/tools.nix {};
202+
default = (import ../nix { inherit (pkgs) system; }).callPackage ../nix/tools.nix { };
204203
defaultText =
205204
literalExample ''nix-pre-commit-hooks-pkgs.callPackage tools-dot-nix { inherit (pkgs) system; }'';
206205
};
@@ -212,7 +211,7 @@ in
212211
''
213212
The hook definitions.
214213
'';
215-
default = {};
214+
default = { };
216215
};
217216

218217
run =
@@ -255,7 +254,7 @@ in
255254
''
256255
Exclude files that were matched by these patterns.
257256
'';
258-
default = [];
257+
default = [ ];
259258
};
260259

261260
rawConfig =
@@ -284,7 +283,7 @@ in
284283
hooks = processedHooks;
285284
}
286285
];
287-
} // lib.optionalAttrs (cfg.excludes != []) {
286+
} // lib.optionalAttrs (cfg.excludes != [ ]) {
288287
exclude = mergeExcludes cfg.excludes;
289288
};
290289

nix/default.nix

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
{ sources ? import ./sources.nix
22
, system ? builtins.currentSystem
33
}:
4-
54
let
65
overlay =
76
_: pkgs:
8-
let
9-
cabal-fmt =
10-
pkgs.haskellPackages.callCabal2nix "cabal-fmt" sources.cabal-fmt {};
11-
in
12-
{
13-
inherit (pkgs) nixfmt niv ormolu nixpkgs-fmt nix-linter;
14-
hindent =
15-
pkgs.haskellPackages.callCabal2nix "hindent" sources.hindent {};
16-
cabal-fmt =
17-
cabal-fmt.overrideScope (
18-
self: super:
19-
{
20-
Cabal = self.Cabal_3_0_0_0;
21-
}
22-
);
23-
packages = pkgs.callPackages ./packages.nix {};
24-
};
7+
{
8+
inherit (pkgs) nixfmt niv ormolu nixpkgs-fmt nix-linter;
9+
cabal-fmt = pkgs.haskellPackages.cabal-fmt;
10+
hindent = pkgs.haskellPackages.callCabal2nix "hindent" sources.hindent { };
11+
packages = pkgs.callPackages ./packages.nix { };
12+
};
2513
in
2614
import sources.nixpkgs {
2715
overlays = [ overlay ];
28-
config = {};
16+
config = { };
2917
inherit system;
3018
}

0 commit comments

Comments
 (0)