Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
34 changes: 29 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
);
};
}
5 changes: 2 additions & 3 deletions modules.nix
Original file line number Diff line number Diff line change
@@ -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))
19 changes: 19 additions & 0 deletions modules/mpv/check.nix
Original file line number Diff line number Diff line change
@@ -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
''
File renamed without changes.
18 changes: 18 additions & 0 deletions modules/notmuch/check.nix
Original file line number Diff line number Diff line change
@@ -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
''
4 changes: 2 additions & 2 deletions modules/notmuch.nix → modules/notmuch/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wlib.wrapModule (
in
{
options = {
config = lib.mkOption {
settings = lib.mkOption {
type = iniFmt.type;
default = {
database = {
Expand All @@ -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;
Expand Down