From c3fa0ce6cee8b3f9a30c7a746577e39065e82019 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 28 Jul 2025 02:00:52 +0100 Subject: [PATCH] Move bookmarkthis configuration --- home-manager/opdavies/PW05CH3L.nix | 1 - home-manager/opdavies/t480.nix | 1 - modules/home-manager/bookmarkthis.nix | 68 --------------------------- modules/home-manager/default.nix | 1 - modules2/bookmarkthis.nix | 57 ++++++++++++++++++++++ 5 files changed, 57 insertions(+), 71 deletions(-) delete mode 100644 modules/home-manager/bookmarkthis.nix create mode 100644 modules2/bookmarkthis.nix diff --git a/home-manager/opdavies/PW05CH3L.nix b/home-manager/opdavies/PW05CH3L.nix index f2548364..d581f5d0 100644 --- a/home-manager/opdavies/PW05CH3L.nix +++ b/home-manager/opdavies/PW05CH3L.nix @@ -5,7 +5,6 @@ features = { cli = { - bookmarkthis.enable = true; starship.enable = true; zsh.enable = true; }; diff --git a/home-manager/opdavies/t480.nix b/home-manager/opdavies/t480.nix index 9e0a5c83..2a3b806f 100644 --- a/home-manager/opdavies/t480.nix +++ b/home-manager/opdavies/t480.nix @@ -8,7 +8,6 @@ features = { cli = { - bookmarkthis.enable = true; starship.enable = true; zsh.enable = true; }; diff --git a/modules/home-manager/bookmarkthis.nix b/modules/home-manager/bookmarkthis.nix deleted file mode 100644 index 286fd599..00000000 --- a/modules/home-manager/bookmarkthis.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -let - inherit (lib) mkEnableOption mkOption; - - cfg = config.features.cli.${name}; - name = "bookmarkthis"; -in -{ - options.features.cli.${name} = { - enable = mkEnableOption "Enable ${name}"; - - snippetsFile = mkOption { - default = "${config.xdg.dataHome}/snippets.txt"; - type = lib.types.str; - }; - }; - - config = lib.mkIf cfg.enable { - home = { - packages = with pkgs; [ - (pkgs.writeShellApplication { - name = "bookmarkthis"; - - text = '' - message() { - if command -v ${lib.getExe libnotify} > /dev/null; then - ${lib.getExe libnotify} "$1" "$2" - else - echo "$2" - fi - } - - main() { - bookmark="$(xclip -o)" - file="$SNIPPETS_FILE" - - if grep -q "^$bookmark$" "$file"; then - message "Oops." "Already bookmarked." >&2 - - exit 2 - fi - - echo "$bookmark" >> "$file" - - message "Bookmark added!" "$bookmark is now saved to the file." - } - - main - ''; - }) - ]; - - sessionVariables = { - SNIPPETS_FILE = cfg.snippetsFile; - }; - }; - - programs.zsh.zsh-abbr.abbreviations = lib.optionalAttrs (config.programs.zsh.enable) { - "sn" = "${config.home.sessionVariables.EDITOR} $SNIPPETS_FILE"; - }; - }; -} diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 16df9ee8..9c8c6058 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,6 +1,5 @@ { imports = [ - ./bookmarkthis.nix ./dev-commit.nix ./starship.nix ./zsh diff --git a/modules2/bookmarkthis.nix b/modules2/bookmarkthis.nix new file mode 100644 index 00000000..96c7a4eb --- /dev/null +++ b/modules2/bookmarkthis.nix @@ -0,0 +1,57 @@ +{ lib, ... }: + +{ + flake.modules.homeManager.gui = + { config, pkgs, ... }: + { + options.programs.bookmarkthis.snippetsFile = lib.mkOption { + default = "${config.xdg.dataHome}/snippets.txt"; + type = lib.types.str; + }; + + config = { + home = { + packages = [ + (pkgs.writeShellApplication { + name = "bookmarkthis"; + + text = '' + message() { + if command -v ${lib.getExe pkgs.libnotify} > /dev/null; then + ${lib.getExe pkgs.libnotify} "$1" "$2" + else + echo "$2" + fi + } + + main() { + bookmark="$(xclip -o)" + file="$SNIPPETS_FILE" + + if grep -q "^$bookmark$" "$file"; then + message "Oops." "Already bookmarked." >&2 + + exit 2 + fi + + echo "$bookmark" >> "$file" + + message "Bookmark added!" "$bookmark is now saved to the file." + } + + main + ''; + }) + ]; + + sessionVariables = { + SNIPPETS_FILE = config.programs.bookmarkthis.snippetsFile; + }; + }; + + programs.zsh.zsh-abbr.abbreviations = lib.optionalAttrs (config.programs.zsh.enable) { + "sn" = "${config.home.sessionVariables.EDITOR} $SNIPPETS_FILE"; + }; + }; + }; +}