flameshot: add settings option
This commit is contained in:
parent
32285d8fe6
commit
0b47ded208
|
@ -5,12 +5,35 @@ with lib;
|
|||
let
|
||||
|
||||
cfg = config.services.flameshot;
|
||||
|
||||
package = pkgs.flameshot;
|
||||
|
||||
iniFormat = pkgs.formats.ini { };
|
||||
|
||||
iniFile = iniFormat.generate "flameshot.ini" cfg.settings;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ maintainers.hamhut1066 ];
|
||||
|
||||
options = { services.flameshot = { enable = mkEnableOption "Flameshot"; }; };
|
||||
options.services.flameshot = {
|
||||
enable = mkEnableOption "Flameshot";
|
||||
|
||||
settings = mkOption {
|
||||
type = iniFormat.type;
|
||||
default = { };
|
||||
example = {
|
||||
General = {
|
||||
disabledTrayIcon = true;
|
||||
showStartupLaunchMessage = false;
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Configuration to use for Flameshot. See
|
||||
<link xlink:href="https://github.com/flameshot-org/flameshot/blob/master/flameshot.example.ini"/>
|
||||
for available options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
|
@ -20,12 +43,17 @@ in {
|
|||
|
||||
home.packages = [ package ];
|
||||
|
||||
xdg.configFile = mkIf (cfg.settings != { }) {
|
||||
"flameshot/flameshot.ini".source = iniFile;
|
||||
};
|
||||
|
||||
systemd.user.services.flameshot = {
|
||||
Unit = {
|
||||
Description = "Flameshot screenshot tool";
|
||||
Requires = [ "tray.target" ];
|
||||
After = [ "graphical-session-pre.target" "tray.target" ];
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
X-Restart-Triggers = mkIf (cfg.settings != { }) [ "${iniFile}" ];
|
||||
};
|
||||
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
|
|
|
@ -124,6 +124,7 @@ import nmt {
|
|||
./modules/services/devilspie2
|
||||
./modules/services/dropbox
|
||||
./modules/services/emacs
|
||||
./modules/services/flameshot
|
||||
./modules/services/fluidsynth
|
||||
./modules/services/fnott
|
||||
./modules/services/git-sync
|
||||
|
|
4
tests/modules/services/flameshot/default.nix
Normal file
4
tests/modules/services/flameshot/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
flameshot-empty-settings = ./empty-settings.nix;
|
||||
flameshot-example-settings = ./example-settings.nix;
|
||||
}
|
13
tests/modules/services/flameshot/empty-settings.nix
Normal file
13
tests/modules/services/flameshot/empty-settings.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
services.flameshot = { enable = true; };
|
||||
|
||||
test.stubs.flameshot = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/flameshot/flameshot.ini
|
||||
'';
|
||||
};
|
||||
}
|
30
tests/modules/services/flameshot/example-settings.nix
Normal file
30
tests/modules/services/flameshot/example-settings.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
services.flameshot = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
General = {
|
||||
disabledTrayIcon = true;
|
||||
showStartupLaunchMessage = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.flameshot = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/flameshot/flameshot.ini \
|
||||
${
|
||||
builtins.toFile "expected.ini" ''
|
||||
[General]
|
||||
disabledTrayIcon=true
|
||||
showStartupLaunchMessage=false
|
||||
''
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue