mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
ahoviewer: add module
This commit is contained in:
parent
9a2dc0efbc
commit
366b60b8a0
10 changed files with 177 additions and 0 deletions
73
modules/programs/ahoviewer.nix
Normal file
73
modules/programs/ahoviewer.nix
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
types
|
||||
mkIf
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
;
|
||||
|
||||
cfg = config.programs.ahoviewer;
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||
options.programs.ahoviewer = {
|
||||
enable = mkEnableOption "ahoviewer";
|
||||
package = mkPackageOption pkgs "ahoviewer" { nullable = true; };
|
||||
config = mkOption {
|
||||
type = with types; either str path;
|
||||
default = "";
|
||||
example = ''
|
||||
ZoomMode = "M";
|
||||
Geometry :
|
||||
{
|
||||
x = 964;
|
||||
y = 574;
|
||||
w = 948;
|
||||
h = 498;
|
||||
};
|
||||
BooruWidth = 382;
|
||||
TagViewPosition = 318;
|
||||
SmartNavigation = true;
|
||||
StoreRecentFiles = false;
|
||||
RememberLastFile = false;
|
||||
SaveThumbnails = false;
|
||||
AutoOpenArchive = false;
|
||||
BooruBrowserVisible = true;
|
||||
'';
|
||||
description = ''
|
||||
Configuration settings for ahoviewer. All the available options
|
||||
can be found editing the preferences in the GUI and looking at
|
||||
$XDG_CONFIG_HOME/ahoviewer/ahoviewer.cfg
|
||||
'';
|
||||
};
|
||||
plugins = mkOption {
|
||||
type = with types; listOf package;
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of plugins for ahoviewer.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "programs.ahoviewer" pkgs lib.platforms.linux)
|
||||
];
|
||||
|
||||
xdg.configFile."ahoviewer/ahoviewer.cfg" = mkIf (cfg.config != "") {
|
||||
source = if lib.isPath cfg.config then cfg.config else pkgs.writeText "ahoviewer.cfg" cfg.config;
|
||||
};
|
||||
xdg.dataFile = mkIf (cfg.plugins != [ ]) (
|
||||
lib.listToAttrs (
|
||||
map (p: lib.nameValuePair "ahoviewer/plugins/${p.pname}" { source = p; }) cfg.plugins
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
16
tests/modules/programs/ahoviewer/ahoviewer.cfg
Normal file
16
tests/modules/programs/ahoviewer/ahoviewer.cfg
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
ZoomMode = "M";
|
||||
Geometry :
|
||||
{
|
||||
x = 964;
|
||||
y = 574;
|
||||
w = 948;
|
||||
h = 498;
|
||||
};
|
||||
BooruWidth = 382;
|
||||
TagViewPosition = 318;
|
||||
SmartNavigation = true;
|
||||
StoreRecentFiles = false;
|
||||
RememberLastFile = false;
|
||||
SaveThumbnails = false;
|
||||
AutoOpenArchive = false;
|
||||
BooruBrowserVisible = true;
|
||||
5
tests/modules/programs/ahoviewer/default.nix
Normal file
5
tests/modules/programs/ahoviewer/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
ahoviewer-example-config = ./example-config.nix;
|
||||
}
|
||||
41
tests/modules/programs/ahoviewer/example-config.nix
Normal file
41
tests/modules/programs/ahoviewer/example-config.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.ahoviewer = {
|
||||
enable = true;
|
||||
config = ''
|
||||
ZoomMode = "M";
|
||||
Geometry :
|
||||
{
|
||||
x = 964;
|
||||
y = 574;
|
||||
w = 948;
|
||||
h = 498;
|
||||
};
|
||||
BooruWidth = 382;
|
||||
TagViewPosition = 318;
|
||||
SmartNavigation = true;
|
||||
StoreRecentFiles = false;
|
||||
RememberLastFile = false;
|
||||
SaveThumbnails = false;
|
||||
AutoOpenArchive = false;
|
||||
BooruBrowserVisible = true;
|
||||
'';
|
||||
plugins = [
|
||||
(pkgs.callPackage ./plugins/a.nix { })
|
||||
(pkgs.callPackage ./plugins/b.nix { })
|
||||
];
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/ahoviewer/ahoviewer.cfg
|
||||
assertFileContent home-files/.config/ahoviewer/ahoviewer.cfg \
|
||||
${./ahoviewer.cfg}
|
||||
|
||||
assertFileExists home-files/.local/share/ahoviewer/plugins/plugin-a/plugin-a.plugin
|
||||
assertFileExists home-files/.local/share/ahoviewer/plugins/plugin-a/plugin-a.py
|
||||
|
||||
assertFileExists home-files/.local/share/ahoviewer/plugins/plugin-a/plugin-a.plugin
|
||||
assertFileExists home-files/.local/share/ahoviewer/plugins/plugin-a/plugin-a.py
|
||||
'';
|
||||
}
|
||||
13
tests/modules/programs/ahoviewer/plugins/a.nix
Normal file
13
tests/modules/programs/ahoviewer/plugins/a.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
stdenvNoCC,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "plugin-a";
|
||||
version = "1.0.0";
|
||||
src = ./plugin-a;
|
||||
buildPhase = ''
|
||||
mkdir -p $out
|
||||
cp $src/* $out/
|
||||
'';
|
||||
}
|
||||
13
tests/modules/programs/ahoviewer/plugins/b.nix
Normal file
13
tests/modules/programs/ahoviewer/plugins/b.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
stdenvNoCC,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "plugin-b";
|
||||
version = "1.0.0";
|
||||
src = ./plugin-b;
|
||||
buildPhase = ''
|
||||
mkdir -p $out
|
||||
cp $src/* $out/
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
[Plugin]
|
||||
Module=plugin-a
|
||||
Loader=python3
|
||||
Name=Test
|
||||
Description=Test
|
||||
Hidden=false
|
||||
X-ActionName=TestPlugin
|
||||
|
|
@ -0,0 +1 @@
|
|||
print("Hello world")
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
[Plugin]
|
||||
Module=plugin-b
|
||||
Loader=python3
|
||||
Name=Test
|
||||
Description=Test
|
||||
Hidden=false
|
||||
X-ActionName=TestPlugin
|
||||
|
|
@ -0,0 +1 @@
|
|||
print("Hello world")
|
||||
Loading…
Add table
Add a link
Reference in a new issue