swayimg: add programs.swayimg module

This commit is contained in:
Adithya Nair 2024-07-20 17:47:35 +05:30
parent afd2021bed
commit a1bfbab6b3
No known key found for this signature in database
GPG key ID: B8857BFBA2C47B9C
9 changed files with 112 additions and 0 deletions

View file

@ -1703,6 +1703,17 @@ in {
one place. See https://github.com/glanceapp/glance for more. one place. See https://github.com/glanceapp/glance for more.
''; '';
} }
{
time = "2024-07-20T12:05:41+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'programs.swayimg'.
Swayimg is a lightweight image viewer for Wayland display servers.
See https://github.com/artemsen/swayimg for more.
'';
}
]; ];
}; };
} }

View file

@ -221,6 +221,7 @@ let
./programs/sqls.nix ./programs/sqls.nix
./programs/ssh.nix ./programs/ssh.nix
./programs/starship.nix ./programs/starship.nix
./programs/swayimg.nix
./programs/swaylock.nix ./programs/swaylock.nix
./programs/swayr.nix ./programs/swayr.nix
./programs/taskwarrior.nix ./programs/taskwarrior.nix

View file

@ -0,0 +1,39 @@
{ pkgs, config, lib, ... }:
let
cfg = config.programs.swayimg;
iniFormat = pkgs.formats.ini { };
in {
meta.maintainers = [ lib.maintainers.adtya ];
options.programs.swayimg = {
enable = lib.mkEnableOption "swayimg";
package = lib.mkPackageOption pkgs "swayimg" { };
settings = lib.mkOption {
type = iniFormat.type;
default = { };
example = lib.literalExpression ''
{
general = {
scale = "optimal";
fullscreen = "no";
};
};
'';
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/swayimg/config`. See
{manpage}`swayimgrc(5)` for a list of available options.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "programs.swayimg" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ];
xdg.configFile."swayimg/config" = lib.mkIf (cfg.settings != { }) {
text = lib.generators.toINI { } cfg.settings;
};
};
}

View file

@ -209,6 +209,7 @@ in import nmtSrc {
./modules/programs/rbw ./modules/programs/rbw
./modules/programs/rofi ./modules/programs/rofi
./modules/programs/rofi-pass ./modules/programs/rofi-pass
./modules/programs/swayimg
./modules/programs/swaylock ./modules/programs/swaylock
./modules/programs/swayr ./modules/programs/swayr
./modules/programs/terminator ./modules/programs/terminator

View file

@ -0,0 +1,12 @@
[font]
name=monospace
size=14
[general]
antialiasing=no
fixed=yes
fullscreen=no
position=parent
scale=optimal
size=parent
transparency=grid

View file

@ -0,0 +1,5 @@
{
swayimg-disabled = import ./disabled.nix;
swayimg-enabled = import ./enabled.nix;
swayimg-settings = import ./settings.nix;
}

View file

@ -0,0 +1,6 @@
{ ... }: {
nmt.script = ''
assertPathNotExists home-files/.config/swayimg/config
'';
}

View file

@ -0,0 +1,10 @@
{ config, ... }: {
programs.swayimg = {
enable = true;
package = config.lib.test.mkStubPackage { };
};
nmt.script = ''
assertPathNotExists home-files/.config/swayimg/config
'';
}

View file

@ -0,0 +1,27 @@
{ config, ... }: {
programs.swayimg = {
enable = true;
package = config.lib.test.mkStubPackage { };
settings = {
general = {
scale = "optimal";
fullscreen = "no";
antialiasing = "no";
fixed = "yes";
transparency = "grid";
position = "parent";
size = "parent";
};
font = {
name = "monospace";
size = 14;
};
};
};
nmt.script = let homeConfig = "home-files/.config/swayimg/config";
in ''
assertFileExists ${homeConfig}
assertFileContents ${homeConfig} ${./config}
'';
}