69
hosts/common/configs/user/gui/clipbook/options.nix
Normal file
69
hosts/common/configs/user/gui/clipbook/options.nix
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.clipbook;
|
||||
in
|
||||
{
|
||||
options.programs.clipbook =
|
||||
with lib;
|
||||
with types;
|
||||
{
|
||||
enable = mkEnableOption "Clipbook";
|
||||
|
||||
bookmarks =
|
||||
let
|
||||
bookmarksOptions =
|
||||
{ config, ... }:
|
||||
{
|
||||
options = {
|
||||
source = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Path to the file to copy.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
text = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Text to copy.";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
mkOption {
|
||||
type = attrsOf (submodule bookmarksOptions);
|
||||
description = "Clipboard Bookmarks.";
|
||||
default = { };
|
||||
};
|
||||
|
||||
finalPackage = mkOption {
|
||||
type = package;
|
||||
description = "The clipbook rofi package.";
|
||||
default = pkgs.callPackage ./rofi.nix {
|
||||
rofi = config.programs.rofi.finalPackage;
|
||||
bookmarks = builtins.mapAttrs (_: bookmark: {
|
||||
type = if bookmark.source != null then "file" else "text";
|
||||
content = if bookmark.source != null then bookmark.source else bookmark.text;
|
||||
}) cfg.bookmarks;
|
||||
};
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
assertions = [
|
||||
{
|
||||
assertion = builtins.all (
|
||||
bookmark:
|
||||
(bookmark.source == null || bookmark.text == null)
|
||||
&& (bookmark.source != null || bookmark.text != null)
|
||||
) (builtins.attrValues cfg.bookmarks);
|
||||
message = "Each bookmark must have one of 'source' or 'text' set.";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user