-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathjust.nix
More file actions
49 lines (47 loc) · 1.44 KB
/
just.nix
File metadata and controls
49 lines (47 loc) · 1.44 KB
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
{
lib,
pkgs,
config,
mkFormatterModule,
...
}:
let
# Search 'justfile' in subdirectories too. This isn't needed for filename starting with `*.`.
alsoSearchSubdirectory = lib.lists.concatMap (fileName: [ fileName ] ++ [ "*/${fileName}" ]);
cfg = config.programs.just;
in
{
meta.maintainers = [ "katexochen" ];
# Example contains store paths
meta.skipExample = true;
imports = [
(mkFormatterModule {
name = "just";
includes =
alsoSearchSubdirectory [
"[Jj][Uu][Ss][Tt][Ff][Ii][Ll][Ee]" # 'justfile', case insensitive
".[Jj][Uu][Ss][Tt][Ff][Ii][Ll][Ee]" # '.justfile', case insensitive
]
++ [
"*.[Jj][Uu][Ss][Tt]" # '.just' module, case insensitive
"*.[Jj][Uu][Ss][Tt][Ff][Ii][Ll][Ee]" # '.justfile' module, case insensitive
];
})
];
config = lib.mkIf cfg.enable {
settings.formatter.just = {
# just itself doesn't comply with the treefmt spec, as the --justfile flags expects a single argument
# the spec requires the formatter to accept multiple file names as arguments (see https://treefmt.com/latest/reference/formatter-spec/#1-files-passed-as-arguments).
command = pkgs.bash;
options = [
"-euc"
''
for f in "$@"; do
${lib.getExe cfg.package} --fmt --unstable --justfile "$f"
done
''
"--" # bash swallows the second argument when using -c
];
};
};
}