1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

foliate: init (#7049)

This commit is contained in:
awwpotato 2025-05-13 10:05:32 -07:00 committed by GitHub
parent df556f2a17
commit 8d832ddfda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 172 additions and 0 deletions

1
.github/labeler.yml vendored
View file

@ -160,6 +160,7 @@
- modules/programs/cmus.nix - modules/programs/cmus.nix
- modules/programs/ncspot.nix - modules/programs/ncspot.nix
- modules/programs/spotify-player.nix - modules/programs/spotify-player.nix
- modules/programs/foliate.nix
- modules/programs/freetube.nix - modules/programs/freetube.nix
- modules/programs/yt-dlp.nix - modules/programs/yt-dlp.nix
- modules/programs/kodi.nix - modules/programs/kodi.nix

View file

@ -0,0 +1,10 @@
{ pkgs, ... }:
{
time = "2025-05-12T22:21:57+00:00";
condition = pkgs.stdenv.hostPlatform.isLinux;
message = ''
A new module is available: `programs.foliate`
Foliate is a modern e-book reader tailored for GNOME.
'';
}

View file

@ -362,6 +362,7 @@ let
./services/flameshot.nix ./services/flameshot.nix
./services/fluidsynth.nix ./services/fluidsynth.nix
./services/fnott.nix ./services/fnott.nix
./programs/foliate.nix
./services/fusuma.nix ./services/fusuma.nix
./services/getmail.nix ./services/getmail.nix
./services/git-sync.nix ./services/git-sync.nix

View file

@ -0,0 +1,111 @@
{
lib,
pkgs,
config,
...
}:
let
inherit (lib)
mkEnableOption
mkPackageOption
mkOption
mkIf
types
mapAttrs'
nameValuePair
;
cfg = config.programs.foliate;
jsonFormat = pkgs.formats.json { };
in
{
meta.maintainers = [ lib.maintainers.awwpotato ];
options.programs.foliate = {
enable = mkEnableOption "Foliate";
package = mkPackageOption pkgs "foliate" { nullable = true; };
settings = mkOption {
type = with types; attrsOf (either lib.hm.types.gvariant (attrsOf lib.hm.types.gvariant));
default = { };
description = ''
Added to `config.dconf.settings` under `com/github/johnfactotum/Foliate`,
the scheme is defined at
<https://github.com/johnfactotum/foliate/blob/gtk4/data/com.github.johnfactotum.Foliate.gschema.xml>
'';
example = lib.literalExpression ''
{
myTheme = {
color-scheme = 0;
library = {
view-mode = "grid";
show-covers = true;
};
"viewer/view" = {
theme = "My Theme";
};
"viewer/font" = {
monospace = "Maple Mono";
default-size = 12;
};
};
}
'';
};
themes = mkOption {
type = types.attrsOf (
types.oneOf [
jsonFormat.type
types.str
types.path
]
);
description = ''
Each theme is written to
{file}`$XDG_CONFIG_HOME/com.github.johnfactotum.Foliate/themes/NAME.json`.
See <https://github.com/johnfactotum/foliate/blob/gtk4/src/themes.js>
for implementation of themes in Foliate.
'';
default = { };
example = lib.literalExpression ''
{
label = "My Theme";
light = {
fg = "#89b4fa";
bg = "#1e1e2e";
link = "#89b4fa";
};
dark = { };
}
'';
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "programs.foliate" pkgs lib.platforms.linux)
];
home.packages = mkIf (cfg.package != null) [ cfg.package ];
dconf.settings = mapAttrs' (
name: value:
if builtins.isAttrs value then
nameValuePair "com/github/johnfactotum/Foliate/${name}" value
else
nameValuePair "com/github/johnfactotum/Foliate" { ${name} = value; }
) cfg.settings;
xdg.configFile = mapAttrs' (
name: value:
nameValuePair "com.github.johnfactotum.Foliate/themes/${name}.json" {
source =
if lib.isString value then
pkgs.writeText "foliate-theme-${name}" value
else if builtins.isPath value || lib.isStorePath value then
value
else
jsonFormat.generate "foliate-theme-${name}" value;
}
) cfg.themes;
};
}

View file

@ -365,6 +365,7 @@ import nmtSrc {
./modules/programs/distrobox ./modules/programs/distrobox
./modules/programs/element-desktop/linux.nix ./modules/programs/element-desktop/linux.nix
./modules/programs/eww ./modules/programs/eww
./modules/programs/foliate
./modules/programs/foot ./modules/programs/foot
./modules/programs/freetube ./modules/programs/freetube
./modules/programs/fuzzel ./modules/programs/fuzzel

View file

@ -0,0 +1,45 @@
{ pkgs, ... }:
{
programs.foliate = {
enable = true;
settings = {
color-scheme = 0;
library = {
view-mode = "grid";
show-covers = true;
};
"viewer/view" = {
theme = "My Theme";
};
"viewer/font" = {
monospace = "Maple Mono";
default-size = 12;
};
};
themes.myTheme = {
label = "My Theme";
light = {
fg = "#89b4fa";
bg = "#1e1e2e";
link = "#89b4fa";
};
dark = { };
};
};
nmt.script = ''
assertFileExists home-files/.config/com.github.johnfactotum.Foliate/themes/myTheme.json
assertFileContent home-files/.config/com.github.johnfactotum.Foliate/themes/myTheme.json \
${pkgs.writeText "expected-foliate-theme" ''
{
"dark": {},
"label": "My Theme",
"light": {
"bg": "#1e1e2e",
"fg": "#89b4fa",
"link": "#89b4fa"
}
}
''}
'';
}

View file

@ -0,0 +1,3 @@
{
foliate-basic-theme = ./basic-theme.nix;
}