From 23b63bfdfb5ed2700441f13429cbd1cd0c2ea870 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 4 Feb 2023 21:52:14 +0100 Subject: flameshot-once: reinit with flameshot 12.1.0-pre --- krebs/5pkgs/simple/flameshot-once/default.nix | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 krebs/5pkgs/simple/flameshot-once/default.nix (limited to 'krebs/5pkgs/simple/flameshot-once/default.nix') diff --git a/krebs/5pkgs/simple/flameshot-once/default.nix b/krebs/5pkgs/simple/flameshot-once/default.nix new file mode 100644 index 000000000..92dd5311f --- /dev/null +++ b/krebs/5pkgs/simple/flameshot-once/default.nix @@ -0,0 +1,71 @@ +{ name ? "flameshot-once", pkgs, ... }@args: +with pkgs.stockholm.lib; + +let + # config cannot be declared in the input attribute set because that would + # cause callPackage to inject the wrong config. Instead, get it from ... + # via args. + config = args.config or {}; + + cfg = evalModulesConfig (singleton { + _file = toString ./default.nix; + _module.args.pkgs = pkgs; + imports = [ + config + ./config.nix + ]; + }); +in + +pkgs.symlinkJoin { + inherit name; + paths = [ + (pkgs.write "flameshot-once" { + "/bin/flameshot-once" = { + executable = true; + text = /* sh */ '' + #! ${pkgs.dash}/bin/dash + export PATH=${makeBinPath [ + pkgs.qt5.qtbase + ]}:''${PATH+:$PATH} + ${optionalString (config != null) /* sh */ '' + export XDG_CONFIG_HOME=${placeholder "out"}/etc + ${optionalString cfg.imgur.enable /* sh */ '' + export IMGUR_CREATE_URL=${shell.escape cfg.imgur.createUrl} + export IMGUR_DELETE_URL=${shell.escape cfg.imgur.deleteUrl} + ${optionalString cfg.imgur.xdg-open.enable /* sh */ '' + export PATH=${placeholder "out"}/lib/imgur/bin''${PATH+:$PATH} + ''} + ''} + ''} + ${cfg.package}/bin/flameshot & + exec ${cfg.package}/bin/flameshot gui + ''; + }; + "/etc/flameshot/flameshot.ini".text = + lib.generators.toINI {} (stripAttr cfg.settings); + ${if cfg.imgur.enable then "/lib/imgur/bin/xdg-open" else null} = { + executable = true; + text = /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + uri=$1 + prefix=$(${pkgs.coreutils}/bin/dirname "$uri") + case $prefix in + (${shell.escape cfg.imgur.xdg-open.createPrefix}) + echo "opening image in browser: $uri" >&2 + exec ${config.imgur.xdg-open.browser} "$uri" + ;; + (${shell.escape cfg.imgur.xdg-open.deletePrefix}) + echo "deleting image: $uri" >&2 + exec ${pkgs.curl}/bin/curl -fsS -X DELETE "$uri" + ;; + (*) + echo "don't know how to open URI: $uri" >&2 + exit 1 + esac + ''; + }; + }) + ]; +} -- cgit v1.2.3