summaryrefslogtreecommitdiffstats
path: root/pkgs/simple/flameshot-once/default.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-02 02:18:54 +0000
committertv <tv@krebsco.de>2026-12-02 02:18:54 +0000
commite1b4d6373e96ab22b36119ac689d72ced9164c47 (patch)
tree7e590e95ba5b0323f4c3bc8c6d0c7ca340945491 /pkgs/simple/flameshot-once/default.nix
parente69079eb1ecd2c779dfec93b66e3bd180889dd68 (diff)
flameshot-once: flameshot 13.3.0, configured by a module
flameshot-once starts flameshot's daemon and its GUI, with flameshot.ini from config.nix's settings, and with imgur, uploads to its createUrl and an xdg-open that opens or deletes them. flameshot gets the history and applauncher patches, too. The buttons option, which was commented out, is left out, and with it the tools that listed the button types for it.
Diffstat (limited to 'pkgs/simple/flameshot-once/default.nix')
-rw-r--r--pkgs/simple/flameshot-once/default.nix138
1 files changed, 118 insertions, 20 deletions
diff --git a/pkgs/simple/flameshot-once/default.nix b/pkgs/simple/flameshot-once/default.nix
index 0524c2cf..20a69c74 100644
--- a/pkgs/simple/flameshot-once/default.nix
+++ b/pkgs/simple/flameshot-once/default.nix
@@ -1,28 +1,126 @@
-{ pkgs, stockholm, ... }@args:
-with stockholm.lib;
+{ name ? "flameshot-once", lib, mylib, pkgs, ... }@args:
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 = (lib.evalModules {
+ specialArgs = {
+ inherit mylib;
+ };
+ modules = lib.singleton {
+ _file = toString ./default.nix;
+ _module.args.pkgs = pkgs;
+ imports = [
+ config
+ ./config.nix
+ ];
+ };
+ }).config;
in
- pkgs.symlinkJoin {
- name = "flameshot-once-wrapper";
- paths = [
- (pkgs.writeDashBin "flameshot-once" ''
- export PATH=${makeBinPath [
- pkgs.flameshot
- pkgs.qt5.qtbase
- pkgs.xclip
- pkgs.xwaitforwindow
- ]}
- ${optionalString (config != null) /* sh */ ''
- . ${import ./profile.nix { inherit config pkgs; }}
- ''}
- exec ${pkgs.haskellPackages.flameshot-once}/bin/flameshot-once "$@"
- '')
- pkgs.haskellPackages.flameshot-once
- ];
- }
+pkgs.symlinkJoin {
+ inherit name;
+ paths = [
+ (pkgs.write "flameshot-once" {
+ "/bin/flameshot-once" = {
+ executable = true;
+ text = /* sh */ ''
+ #! ${pkgs.dash}/bin/dash
+ export PATH=${lib.makeBinPath [
+ pkgs.qt5.qtbase
+ ]}:''${PATH+:$PATH}
+ ${lib.optionalString (config != null) /* sh */ ''
+ export XDG_CONFIG_HOME=${placeholder "out"}/etc
+ ${lib.optionalString cfg.imgur.enable /* sh */ ''
+ export IMGUR_CREATE_URL=${mylib.shell.escape cfg.imgur.createUrl}
+ export IMGUR_DELETE_URL=${mylib.shell.escape cfg.imgur.deleteUrl}
+ ${lib.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 {} (mylib.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
+ (${mylib.shell.escape cfg.imgur.xdg-open.createPrefix})
+ echo "opening image in browser: $uri" >&2
+ exec ${config.imgur.xdg-open.browser} "$uri"
+ ;;
+ (${mylib.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
+ '';
+ };
+ })
+ ];
+}
+// {
+ dev = pkgs.write "flameshot-once-tools" {
+ "/bin/get-recognizedGeneralOptions" = {
+ executable = true;
+ text = /* sh */ ''
+ #! ${pkgs.dash}/bin/dash
+ src=${cfg.package.src}/src/utils/confighandler.cpp
+ ${pkgs.coreutils}/bin/cat "$src" |
+ ${pkgs.gnused}/bin/sed -n '/\<recognizedGeneralOptions = {/,/^};/p' |
+ ${pkgs.gcc}/bin/cpp |
+ ${pkgs.gnugrep}/bin/grep -F OPTION |
+ ${pkgs.coreutils}/bin/sort
+ '';
+ };
+ "/bin/get-Shortcuts" = {
+ executable = true;
+ text = /* sh */ ''
+ #! ${pkgs.dash}/bin/dash
+ indent=$(${placeholder "out"}/bin/indent-of Shortcuts)
+ src=${cfg.package.src}/src/utils/confighandler.cpp
+ ${pkgs.coreutils}/bin/cat "$src" |
+ ${pkgs.gnused}/bin/sed -n '/recognizedShortcuts = {/,/^};/p ' |
+ ${pkgs.gcc}/bin/cpp |
+ ${pkgs.gnused}/bin/sed -nr 's/^\s*SHORTCUT\("(TYPE_[^"]+).*/"\1"/p' |
+ ${pkgs.coreutils}/bin/sort |
+ ${placeholder "out"}/bin/prefix " $indent"
+ '';
+ };
+ "/bin/indent-of" = {
+ executable = true;
+ text = /* sh */ ''
+ #! ${pkgs.dash}/bin/dash
+ # usage: indent-of NAME NIX_FILE
+ exec ${pkgs.gawk}/bin/awk -v name="$1" '
+ $1 == name && $2 == "=" {
+ sub("[^ ].*", "")
+ print
+ }
+ ' ${./config.nix}
+ '';
+ };
+ "/bin/prefix" = {
+ executable = true;
+ text = /* sh */ ''
+ #! ${pkgs.dash}/bin/dash
+ ${pkgs.gawk}/bin/awk -v prefix="$1" '{ print prefix $0 }'
+ '';
+ };
+ };
+}
[cgit] Unable to lock slot /tmp/cgit/9d300000.lock: Permission denied (13)