diff --git a/checks/module-flags.nix b/checks/flags-module.nix similarity index 100% rename from checks/module-flags.nix rename to checks/flags-module.nix diff --git a/flake.nix b/flake.nix index 04da6e5..fdfe33d 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,8 @@ system: let pkgs = nixpkgs.legacyPackages.${system}; + + # Load checks from checks/ directory checkFiles = builtins.readDir ./checks; importCheck = name: { name = nixpkgs.lib.removeSuffix ".nix" name; @@ -31,12 +33,34 @@ self = self; }; }; + checksFromDir = builtins.listToAttrs ( + map importCheck ( + builtins.filter (name: nixpkgs.lib.hasSuffix ".nix" name) (builtins.attrNames checkFiles) + ) + ); + + # Load checks from modules/**/check.nix + moduleFiles = builtins.readDir ./modules; + importModuleCheck = + name: type: + let + checkPath = ./modules + "/${name}/check.nix"; + in + if type == "directory" && builtins.pathExists checkPath then + { + name = "module-${name}"; + value = import checkPath { + inherit pkgs; + self = self; + }; + } + else + null; + checksFromModules = builtins.listToAttrs ( + nixpkgs.lib.filter (x: x != null) (nixpkgs.lib.mapAttrsToList importModuleCheck moduleFiles) + ); in - builtins.listToAttrs ( - map importCheck ( - builtins.filter (name: nixpkgs.lib.hasSuffix ".nix" name) (builtins.attrNames checkFiles) - ) - ) + checksFromDir // checksFromModules ); }; } diff --git a/modules.nix b/modules.nix index 800c65b..7319680 100644 --- a/modules.nix +++ b/modules.nix @@ -1,5 +1,4 @@ { wlib, lib }: lib.mapAttrs' ( - name: _: - lib.nameValuePair (lib.removeSuffix ".nix" name) (import ./modules/${name} { inherit wlib lib; }) -) (builtins.readDir ./modules) + name: type: lib.nameValuePair name (import ./modules/${name}/module.nix { inherit wlib lib; }) +) (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./modules)) diff --git a/modules/mpv/check.nix b/modules/mpv/check.nix new file mode 100644 index 0000000..3ceeffb --- /dev/null +++ b/modules/mpv/check.nix @@ -0,0 +1,19 @@ +{ + pkgs, + self, +}: + +let + mpvWrapped = self.wrapperModules.mpv.apply { + inherit pkgs; + "mpv.conf".content = '' + ao=null + vo=null + ''; + }; + +in +pkgs.runCommand "mpv-test" { } '' + "${mpvWrapped}/bin/mpv" --version | grep -q "mpv" + touch $out +'' diff --git a/modules/mpv.nix b/modules/mpv/module.nix similarity index 100% rename from modules/mpv.nix rename to modules/mpv/module.nix diff --git a/modules/notmuch/check.nix b/modules/notmuch/check.nix new file mode 100644 index 0000000..0d025f0 --- /dev/null +++ b/modules/notmuch/check.nix @@ -0,0 +1,18 @@ +{ + pkgs, + self, +}: + +let + notmuchWrapped = self.wrapperModules.notmuch.apply { + inherit pkgs; + settings = { + database.path = "/tmp/test-mail"; + }; + }; + +in +pkgs.runCommand "notmuch-test" { } '' + "${notmuchWrapped}/bin/notmuch" --version | grep -q "notmuch" + touch $out +'' diff --git a/modules/notmuch.nix b/modules/notmuch/module.nix similarity index 84% rename from modules/notmuch.nix rename to modules/notmuch/module.nix index cc8f260..254d4ba 100644 --- a/modules/notmuch.nix +++ b/modules/notmuch/module.nix @@ -11,7 +11,7 @@ wlib.wrapModule ( in { options = { - config = lib.mkOption { + settings = lib.mkOption { type = iniFmt.type; default = { database = { @@ -22,7 +22,7 @@ wlib.wrapModule ( }; configFile = lib.mkOption { type = wlib.types.file config.pkgs; - default.path = toString (writeNotmuchConfig config.config); + default.path = toString (writeNotmuchConfig config.settings); }; }; config.package = config.pkgs.notmuch;