flameshot: extend module with package-option

This commit is contained in:
Sebastian Sellmeier 2021-11-19 01:46:34 +01:00 committed by Robert Helgesson
parent 8230decb3f
commit 8a16d62e95
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -6,8 +6,6 @@ let
cfg = config.services.flameshot; cfg = config.services.flameshot;
package = pkgs.flameshot;
iniFormat = pkgs.formats.ini { }; iniFormat = pkgs.formats.ini { };
iniFile = iniFormat.generate "flameshot.ini" cfg.settings; iniFile = iniFormat.generate "flameshot.ini" cfg.settings;
@ -18,6 +16,13 @@ in {
options.services.flameshot = { options.services.flameshot = {
enable = mkEnableOption "Flameshot"; enable = mkEnableOption "Flameshot";
package = mkOption {
type = types.package;
default = pkgs.flameshot;
defaultText = literalExpression "pkgs.flameshot";
description = "Package providing <command>flameshot</command>.";
};
settings = mkOption { settings = mkOption {
type = iniFormat.type; type = iniFormat.type;
default = { }; default = { };
@ -41,7 +46,7 @@ in {
lib.platforms.linux) lib.platforms.linux)
]; ];
home.packages = [ package ]; home.packages = [ cfg.package ];
xdg.configFile = mkIf (cfg.settings != { }) { xdg.configFile = mkIf (cfg.settings != { }) {
"flameshot/flameshot.ini".source = iniFile; "flameshot/flameshot.ini".source = iniFile;
@ -60,7 +65,7 @@ in {
Service = { Service = {
Environment = "PATH=${config.home.profileDirectory}/bin"; Environment = "PATH=${config.home.profileDirectory}/bin";
ExecStart = "${package}/bin/flameshot"; ExecStart = "${cfg.package}/bin/flameshot";
Restart = "on-abort"; Restart = "on-abort";
# Sandboxing. # Sandboxing.