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 00000000..92dd5311 --- /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 From afe16677affb35291fc64def0ccb0656a5c47647 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 4 Feb 2023 21:52:51 +0100 Subject: flameshot-once: add dev tools --- krebs/5pkgs/simple/flameshot-once/default.nix | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (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 index 92dd5311..3626409f 100644 --- a/krebs/5pkgs/simple/flameshot-once/default.nix +++ b/krebs/5pkgs/simple/flameshot-once/default.nix @@ -69,3 +69,81 @@ pkgs.symlinkJoin { }) ]; } +// { + dev = pkgs.write "flameshot-once-tools" { + "/bin/get-buttonTypes" = { + executable = true; + text = /* sh */ '' + #! ${pkgs.dash}/bin/dash + indent=$(${placeholder "out"}/bin/indent-of buttonTypes) + src=${cfg.package.src}/src/tools/capturetool.h + ${pkgs.coreutils}/bin/cat "$src" | + ${pkgs.gnused}/bin/sed -nr ' + s/^\s*(TYPE_\S+)\s*=\s*([0-9]+),/\1 = \2;/p + ' | + ${placeholder "out"}/bin/prefix " $indent" + ''; + }; + "/bin/get-iterableButtonTypes" = { + executable = true; + text = /* sh */ '' + #! ${pkgs.dash}/bin/dash + indent=$(${placeholder "out"}/bin/indent-of iterableButtonTypes) + src=${cfg.package.src}/src/widgets/capture/capturetoolbutton.cpp + ${pkgs.coreutils}/bin/cat "$src" | + ${pkgs.gnused}/bin/sed -n '/\