summaryrefslogtreecommitdiffstats
path: root/pkgs/simple/flameshot-once/config.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
commitb540a7713c63e551670f1f0f0bc3d3f6d36c9654 (patch)
tree7cf121d2d2a677f7fd75feea97f49cb017ce5709 /pkgs/simple/flameshot-once/config.nix
parent6d895321d2614c4c8fbb88c4b7f61de2495e7831 (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/config.nix')
-rw-r--r--pkgs/simple/flameshot-once/config.nix515
1 files changed, 302 insertions, 213 deletions
diff --git a/pkgs/simple/flameshot-once/config.nix b/pkgs/simple/flameshot-once/config.nix
index 269f13a6..52a8a9f6 100644
--- a/pkgs/simple/flameshot-once/config.nix
+++ b/pkgs/simple/flameshot-once/config.nix
@@ -1,235 +1,324 @@
-{ config, pkgs }:
-with pkgs.stockholm.lib;
-with generators;
-let
+{ config, lib, mylib, pkgs, ... }:
- # Refs https://github.com/lupoDharkael/flameshot/blob/master/src/widgets/capture/capturebutton.h
- ButtonType = {
- PENCIL = 0;
- DRAWER = 1;
- ARROW = 2;
- SELECTION = 3;
- RECTANGLE = 4;
- CIRCLE = 5;
- MARKER = 6;
- SELECTIONINDICATOR = 7;
- MOVESELECTION = 8;
- UNDO = 9;
- COPY = 10;
- SAVE = 11;
- EXIT = 12;
- IMAGEUPLOADER = 13;
- OPEN_APP = 14;
- BLUR = 15;
- REDO = 16;
- PIN = 17;
- TEXT = 18;
- CIRCLECOUNT = 19;
- };
-
- cfg = eval.config;
-
- eval = evalModules {
- modules = singleton {
- _file = toString ./profile.nix;
- imports = singleton config;
- options = {
- buttons = mkOption {
- apply = map (name: ButtonType.${name});
- default = [
- "PENCIL"
- "DRAWER"
- "ARROW"
- "SELECTION"
- "RECTANGLE"
- "CIRCLE"
- "MARKER"
- "SELECTIONINDICATOR"
- "MOVESELECTION"
- "UNDO"
- "SAVE"
- "EXIT"
- "BLUR"
- "CIRCLECOUNT"
- ]
- ++ optional cfg.imgur.enable "IMAGEUPLOADER"
- ;
- type = types.listOf (types.enum (attrNames ButtonType));
+{
+ options = {
+ imgur = lib.mkOption {
+ default = {};
+ type = lib.types.submodule {
+ options = {
+ enable = lib.mkEnableOption "imgur";
+ createUrl = lib.mkOption {
+ example = "http://p.r/image";
+ type = lib.types.str;
+ };
+ deleteUrl = lib.mkOption {
+ example = "http://p.r/image/delete/%1";
+ type = lib.types.str;
+ };
+ xdg-open = lib.mkOption {
+ default = {};
+ type = lib.types.submodule {
+ options = {
+ enable = lib.mkEnableOption "imgur.xdg-open" // {
+ default = true;
+ };
+ browser = lib.mkOption {
+ default = "${pkgs.coreutils}/bin/false";
+ type = lib.types.str;
+ };
+ createPrefix = lib.mkOption {
+ default = config.imgur.createUrl;
+ type = lib.types.str;
+ };
+ deletePrefix = lib.mkOption {
+ default = lib.removeSuffix "/%1" config.imgur.deleteUrl;
+ type = lib.types.str;
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ package = lib.mkOption {
+ type = lib.types.package;
+ default = import ./flameshot pkgs pkgs;
+ };
+ settings = {
+ # Options without a description are not documented in flameshot's README.
+ # Compare with:
+ # nix-shell -p flameshot-once.dev --run get-recognizedGeneralOptions
+ General = lib.mapAttrs (_: lib.recursiveUpdate { default = null; }) {
+ allowMultipleGuiInstances = lib.mkOption {
+ description = ''
+ Allow multiple instances of `flameshot gui` to run at the same time
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ antialiasingPinZoom = lib.mkOption {
+ description = ''
+ Anti-aliasing image when zoom the pinned image
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ autoCloseIdleDaemon = lib.mkOption {
+ description = ''
+ Automatically close daemon when it's not needed
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ checkForUpdates = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
+ };
+ contrastOpacity = lib.mkOption {
+ description = ''
+ Opacity of area outside selection
+ '';
+ type = lib.types.nullOr (mylib.types.boundedInt 0 255);
};
- copyAndCloseAfterUpload = mkOption {
- default = false;
- type = types.bool;
+ contrastUiColor = lib.mkOption {
+ description = ''
+ Contrast UI color
+ '';
+ type = lib.types.nullOr mylib.types.flameshot.color;
+ };
+ copyAndCloseAfterUpload = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
+ };
+ copyOnDoubleClick = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
+ };
+ copyPathAfterSave = lib.mkOption {
+ description = ''
+ Copy path to image after save
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ copyURLAfterUpload = lib.mkOption {
+ description = ''
+ On successful upload, close the dialog and copy URL to clipboard
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ disabledTrayIcon = lib.mkOption {
+ description = ''
+ Whether the tray icon is disabled
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ drawColor = lib.mkOption {
+ description = ''
+ Last used color
+ '';
+ type = lib.types.nullOr mylib.types.flameshot.color;
};
- disabledTrayIcon = mkOption {
- default = true;
- type = types.bool;
+ drawFontSize = lib.mkOption {
+ type = lib.types.nullOr mylib.types.positive;
};
- drawColor = mkOption {
- default = "#ff0000";
+ drawThickness = lib.mkOption {
+ description = ''
+ Last used tool thickness
+ '';
+ type = lib.types.nullOr mylib.types.positive;
+ };
+ filenamePattern = lib.mkOption {
+ description = ''
+ Filename pattern using C++ strftime formatting
+ '';
type =
- types.addCheck types.str (test "#[0-9A-Fa-f]{6}");
+ lib.types.nullOr
+ # This is types.filename extended by [%:][%:+]*
+ (lib.types.addCheck
+ lib.types.str
+ (mylib.test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*"));
+ };
+ fontFamily = lib.mkOption {
+ type = lib.types.nullOr lib.types.str;
+ };
+ historyConfirmationToDelete = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
+ };
+ ignoreUpdateToVersion = lib.mkOption {
+ description = ''
+ Ignore updates to versions less than this value
+ '';
+ type = lib.types.nullOr lib.types.str;
+ };
+ keepOpenAppLauncher = lib.mkOption {
+ description = ''
+ Keep the App Launcher open after selecting an app
+ '';
+ type = lib.types.nullOr lib.types.bool;
};
- drawThickness = mkOption {
- default = 8;
- type = types.positive;
+ predefinedColorPaletteLarge = lib.mkOption {
+ description = ''
+ Use larger color palette as the default one
+ '';
+ type = lib.types.nullOr lib.types.bool;
};
- filenamePattern = mkOption {
- default = "%FT%T%z_flameshot";
+ saveAfterCopy = lib.mkOption {
+ description = ''
+ Save image after copy
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ saveAsFileExtension = lib.mkOption {
+ description = ''
+ Default file extension for screenshots
+ '';
type =
- # This is types.filename extended by [%:][%:+]*
- types.addCheck types.str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*");
+ lib.types.nullOr
+ (lib.types.addCheck
+ mylib.types.filename
+ (lib.hasPrefix "."));
};
- imgur = mkOption {
- default = {};
- type = types.submodule {
- options = {
- enable = mkEnableOption "imgur";
- createUrl = mkOption {
- example = "http://p.r/image";
- type = types.str;
- };
- deleteUrl = mkOption {
- example = "http://p.r/image/delete/%1";
- type = types.str;
- };
- xdg-open = mkOption {
- default = {};
- type = types.submodule {
- options = {
- enable = mkEnableOption "imgur.xdg-open" // {
- default = true;
- };
- browser = mkOption {
- default = "${pkgs.coreutils}/bin/false";
- type = types.str;
- };
- createPrefix = mkOption {
- default = cfg.imgur.createUrl;
- type = types.str;
- };
- deletePrefix = mkOption {
- default = removeSuffix "/%1" cfg.imgur.deleteUrl;
- type = types.str;
- };
- };
- };
- };
- };
- };
+ safeLastRegion = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
};
- savePath = mkOption {
- default = "/tmp";
- type = types.absolute-pathname;
+ savePath = lib.mkOption {
+ description = ''
+ Image Save Path
+ '';
+ type = lib.types.nullOr mylib.types.absolute-pathname;
+ };
+ savePathFixed = lib.mkOption {
+ description = ''
+ Whether the savePath is a fixed path
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ showDesktopNotification = lib.mkOption {
+ description = ''
+ Show desktop notifications
+ '';
+ type = lib.types.nullOr lib.types.bool;
};
- showDesktopNotification = mkOption {
- default = false;
- type = types.bool;
+ showHelp = lib.mkOption {
+ description = ''
+ Show the help screen on startup
+ '';
+ type = lib.types.nullOr lib.types.bool;
};
- showHelp = mkOption {
- default = false;
- type = types.bool;
+ showMagnifier = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
};
- showSidePanelButton = mkOption {
- default = false;
- type = types.bool;
+ showSelectionGeometry = lib.mkOption {
+ type = lib.types.nullOr (mylib.types.boundedInt 0 5);
};
- showStartupLaunchMessage = mkOption {
- default = false;
- type = types.bool;
+ showSelectionGeometryHideTime = lib.mkOption {
+ type = lib.types.nullOr mylib.types.uint;
};
- timeout = mkOption {
- default = 200;
+ showSidePanelButton = lib.mkOption {
description = ''
- Maximum time in milliseconds allowed for the flameshot daemon to
- react.
+ Show the side panel button
'';
- type = types.positive;
+ type = lib.types.nullOr lib.types.bool;
};
- };
- };
- };
-
- hexchars = stringToCharacters "0123456789abcdef";
-
- # Encode integer to C-escaped string of bytes, little endian / LSB 0
- le = rec {
- x1 = i: let
- i0 = mod i 16;
- i1 = i / 16;
- in
- "\\x${elemAt hexchars i1}${elemAt hexchars i0}";
-
- x2 = i: let
- i0 = mod i 256;
- i1 = i / 256;
- in
- "${x1 i0}${x1 i1}";
-
- x4 = i: let
- i0 = mod i 65536;
- i1 = i / 65536;
- in
- "${x2 i0}${x2 i1}";
- };
-
- toQList = t: xs:
- assert t == "int";
- "QList<${t}>${le.x4 0}${le.x4 (length xs)}${concatMapStrings le.x4 xs}";
-
- XDG_CONFIG_HOME = pkgs.write "flameshot-config" {
- "/flameshot/flameshot.ini".text =
- toINI {} {
- General = {
- buttons = ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons})'';
- disabledTrayIcon = cfg.disabledTrayIcon;
- checkForUpdates = false;
- copyAndCloseAfterUpload = cfg.copyAndCloseAfterUpload;
- drawColor = cfg.drawColor;
- drawThickness = cfg.drawThickness;
- filenamePattern = cfg.filenamePattern;
- savePath = cfg.savePath;
- showDesktopNotification = cfg.showDesktopNotification;
- showHelp = cfg.showHelp;
- showSidePanelButton = cfg.showSidePanelButton;
- showStartupLaunchMessage = cfg.showStartupLaunchMessage;
- startupLaunch = false;
+ showStartupLaunchMessage = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
+ };
+ squareMagnifier = lib.mkOption {
+ type = lib.types.nullOr lib.types.bool;
+ };
+ startupLaunch = lib.mkOption {
+ description = ''
+ Launch at startup
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ uiColor = lib.mkOption {
+ description = ''
+ Main UI color
+ '';
+ type = lib.types.nullOr mylib.types.flameshot.color;
+ };
+ undoLimit = lib.mkOption {
+ type = lib.types.nullOr (mylib.types.boundedInt 0 999);
};
- Shortcuts = {
- TYPE_COPY = "Return";
+ uploadClientSecret = lib.mkOption {
+ type = lib.types.nullOr lib.types.str;
+ };
+ uploadHistoryMax = lib.mkOption {
+ type = lib.types.nullOr mylib.types.uint;
+ };
+ uploadWithoutConfirmation = lib.mkOption {
+ description = ''
+ Upload to imgur without confirmation
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ useJpgForClipboard = lib.mkOption {
+ description = ''
+ Use JPG format instead of PNG
+ '';
+ type = lib.types.nullOr lib.types.bool;
+ };
+ userColors = lib.mkOption {
+ apply = value:
+ if value != null then
+ lib.concatStringsSep ", " value
+ else
+ null;
+ description = ''
+ List of colors for color picker
+ The colors are arranged counter-clockwise with the first being set
+ to the right of the cursor. "picker" adds a custom color picker.
+ '';
+ type =
+ lib.types.nullOr
+ (lib.types.listOf
+ (lib.types.either
+ mylib.types.flameshot.color
+ (lib.types.enum ["picker"])));
};
};
+ Shortcuts = lib.genAttrs [
+ # Generated with:
+ # nix-shell -p flameshot-once.dev --run get-Shortcuts
+ "TYPE_ACCEPT"
+ "TYPE_ARROW"
+ "TYPE_CIRCLE"
+ "TYPE_CIRCLECOUNT"
+ "TYPE_COMMIT_CURRENT_TOOL"
+ "TYPE_COPY"
+ "TYPE_DELETE_CURRENT_TOOL"
+ "TYPE_DRAWER"
+ "TYPE_EXIT"
+ "TYPE_IMAGEUPLOADER"
+ "TYPE_INVERT"
+ "TYPE_MARKER"
+ "TYPE_MOVESELECTION"
+ "TYPE_MOVE_DOWN"
+ "TYPE_MOVE_LEFT"
+ "TYPE_MOVE_RIGHT"
+ "TYPE_MOVE_UP"
+ "TYPE_OPEN_APP"
+ "TYPE_PENCIL"
+ "TYPE_PIN"
+ "TYPE_PIXELATE"
+ "TYPE_RECTANGLE"
+ "TYPE_REDO"
+ "TYPE_RESIZE_DOWN"
+ "TYPE_RESIZE_LEFT"
+ "TYPE_RESIZE_RIGHT"
+ "TYPE_RESIZE_UP"
+ "TYPE_SAVE"
+ "TYPE_SELECTION"
+ "TYPE_SELECTIONINDICATOR"
+ "TYPE_SELECT_ALL"
+ "TYPE_SIZEDECREASE"
+ "TYPE_SIZEINCREASE"
+ "TYPE_SYM_RESIZE_DOWN"
+ "TYPE_SYM_RESIZE_LEFT"
+ "TYPE_SYM_RESIZE_RIGHT"
+ "TYPE_SYM_RESIZE_UP"
+ "TYPE_TEXT"
+ "TYPE_TOGGLE_PANEL"
+ "TYPE_UNDO"
+ ] (name: lib.mkOption {
+ default = null;
+ type = lib.types.nullOr lib.types.str;
+ });
+ };
};
-
-in
-
- pkgs.writeDash "flameshot.profile" ''
- export FLAMESHOT_CAPTURE_PATH=${cfg.savePath}
- export FLAMESHOT_ONCE_TIMEOUT=${toString cfg.timeout}
- export XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
- ${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 */ ''
- PATH=$PATH:${makeBinPath [
- (pkgs.writeDashBin "xdg-open" ''
- 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
- '')
- ]}
- ''}
- ''}
- ''
+}