Skip to content

Commit 81da0bc

Browse files
authored
Merge pull request #10 from Lassulus/mod_checks
add module checks & fix notmuch module
2 parents e71e41b + a720da7 commit 81da0bc

7 files changed

Lines changed: 70 additions & 10 deletions

File tree

flake.nix

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
system:
2424
let
2525
pkgs = nixpkgs.legacyPackages.${system};
26+
27+
# Load checks from checks/ directory
2628
checkFiles = builtins.readDir ./checks;
2729
importCheck = name: {
2830
name = nixpkgs.lib.removeSuffix ".nix" name;
@@ -31,12 +33,34 @@
3133
self = self;
3234
};
3335
};
36+
checksFromDir = builtins.listToAttrs (
37+
map importCheck (
38+
builtins.filter (name: nixpkgs.lib.hasSuffix ".nix" name) (builtins.attrNames checkFiles)
39+
)
40+
);
41+
42+
# Load checks from modules/**/check.nix
43+
moduleFiles = builtins.readDir ./modules;
44+
importModuleCheck =
45+
name: type:
46+
let
47+
checkPath = ./modules + "/${name}/check.nix";
48+
in
49+
if type == "directory" && builtins.pathExists checkPath then
50+
{
51+
name = "module-${name}";
52+
value = import checkPath {
53+
inherit pkgs;
54+
self = self;
55+
};
56+
}
57+
else
58+
null;
59+
checksFromModules = builtins.listToAttrs (
60+
nixpkgs.lib.filter (x: x != null) (nixpkgs.lib.mapAttrsToList importModuleCheck moduleFiles)
61+
);
3462
in
35-
builtins.listToAttrs (
36-
map importCheck (
37-
builtins.filter (name: nixpkgs.lib.hasSuffix ".nix" name) (builtins.attrNames checkFiles)
38-
)
39-
)
63+
checksFromDir // checksFromModules
4064
);
4165
};
4266
}

modules.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{ wlib, lib }:
22
lib.mapAttrs' (
3-
name: _:
4-
lib.nameValuePair (lib.removeSuffix ".nix" name) (import ./modules/${name} { inherit wlib lib; })
5-
) (builtins.readDir ./modules)
3+
name: type: lib.nameValuePair name (import ./modules/${name}/module.nix { inherit wlib lib; })
4+
) (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./modules))

modules/mpv/check.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
pkgs,
3+
self,
4+
}:
5+
6+
let
7+
mpvWrapped = self.wrapperModules.mpv.apply {
8+
inherit pkgs;
9+
"mpv.conf".content = ''
10+
ao=null
11+
vo=null
12+
'';
13+
};
14+
15+
in
16+
pkgs.runCommand "mpv-test" { } ''
17+
"${mpvWrapped}/bin/mpv" --version | grep -q "mpv"
18+
touch $out
19+
''
File renamed without changes.

modules/notmuch/check.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
pkgs,
3+
self,
4+
}:
5+
6+
let
7+
notmuchWrapped = self.wrapperModules.notmuch.apply {
8+
inherit pkgs;
9+
settings = {
10+
database.path = "/tmp/test-mail";
11+
};
12+
};
13+
14+
in
15+
pkgs.runCommand "notmuch-test" { } ''
16+
"${notmuchWrapped}/bin/notmuch" --version | grep -q "notmuch"
17+
touch $out
18+
''
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ wlib.wrapModule (
1111
in
1212
{
1313
options = {
14-
config = lib.mkOption {
14+
settings = lib.mkOption {
1515
type = iniFmt.type;
1616
default = {
1717
database = {
@@ -22,7 +22,7 @@ wlib.wrapModule (
2222
};
2323
configFile = lib.mkOption {
2424
type = wlib.types.file config.pkgs;
25-
default.path = toString (writeNotmuchConfig config.config);
25+
default.path = toString (writeNotmuchConfig config.settings);
2626
};
2727
};
2828
config.package = config.pkgs.notmuch;

0 commit comments

Comments
 (0)