diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/communication/neomutt/default.nix | 90 | ||||
| -rw-r--r-- | modules/communication/neomutt/macros.nix | 4 | ||||
| -rw-r--r-- | modules/communication/neomutt/neomutt.nix | 62 | ||||
| -rw-r--r-- | modules/default.nix | 1 | ||||
| -rw-r--r-- | modules/desktop/eww/yuck.nix | 56 | ||||
| -rw-r--r-- | modules/file-management/yazi/default.nix | 33 | ||||
| -rw-r--r-- | modules/file-management/yazi/file-chooser.sh (renamed from modules/file-management/yazi/yazi-file-chooser.sh) | 0 | ||||
| -rw-r--r-- | modules/lib/default.nix | 48 | ||||
| -rw-r--r-- | modules/lib/script.nix | 199 | ||||
| -rw-r--r-- | modules/media/screen-recording/default.nix | 74 | ||||
| -rw-r--r-- | modules/networking/usque/default.nix | 50 | ||||
| -rw-r--r-- | modules/security/gopass/default.nix | 39 | ||||
| -rw-r--r-- | modules/security/gpg/default.nix | 50 | ||||
| -rw-r--r-- | modules/system/deep-clean/default.nix | 28 | ||||
| -rw-r--r-- | modules/system/nix-update/default.nix | 58 |
15 files changed, 343 insertions, 449 deletions
diff --git a/modules/communication/neomutt/default.nix b/modules/communication/neomutt/default.nix index 8e5d51b..e8496e1 100644 --- a/modules/communication/neomutt/default.nix +++ b/modules/communication/neomutt/default.nix @@ -6,16 +6,9 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - neomuttSync = mkScriptModule { - scope = [ - "communication" - "neomutt" - ]; + neomuttSyncScript = pkgs.writeShellApplication { name = "neomutt-sync"; - path = ./neomutt-sync.sh; - description = "Neomutt-sync - Interactive mail sync with dialog progress bar"; - deps = [ + runtimeInputs = [ pkgs.bash pkgs.dialog pkgs.coreutils @@ -25,7 +18,7 @@ let config.programs.mbsync.package config.programs.notmuch.package ]; - inherit config; + text = builtins.readFile ./neomutt-sync.sh; }; in { @@ -35,7 +28,6 @@ in ./assertions.nix ./keybindings.nix ./macros.nix - ./neomutt.nix ]; options.communication.neomutt = { @@ -47,23 +39,65 @@ in default = config.programs.neomutt.package; description = "The neomutt package to use, wrapped with urlscan in PATH."; }; - } - // neomuttSync.options.communication.neomutt; + }; - config = lib.mkMerge [ - (lib.mkIf config.communication.neomutt.enable { - accounts.email.maildirBasePath = "${config.home.homeDirectory}/.local/share/mail"; - home.sessionVariables.MAILDIR = config.accounts.email.maildirBasePath; - }) - neomuttSync.config - { - assertions = [ - { - assertion = - !config.communication.neomutt.neomutt-sync.enable || config.communication.neomutt.enable; - message = "communication.neomutt.neomutt-sync is enabled but requires `communication.neomutt.enable`."; - } + config = lib.mkIf config.communication.neomutt.enable { + accounts.email.maildirBasePath = "${config.home.homeDirectory}/.local/share/mail"; + home.sessionVariables.MAILDIR = config.accounts.email.maildirBasePath; + + xdg.desktopEntries."neomutt" = { + name = "NeoMutt"; + exec = "${lib.getExe config.terminal.kitty.package} --class neomutt -e ${lib.getExe config.programs.neomutt.package}"; + icon = "${config.programs.neomutt.package}/share/neomutt/logo/neomutt.svg"; + categories = [ + "Network" + "Email" ]; - } - ]; + comment = "Terminal email client"; + terminal = false; + type = "Application"; + }; + xdg.mimeApps.defaultApplications = { + "x-scheme-handler/mailto" = "neomutt.desktop"; + }; + xdg.configFile."neomutt/mailcap".text = '' + text/html; ${lib.getExe config.web.chawan.package} -o "title='neomutt'" '%s'; nametemplate=%s.html + image/*; xdg-open '%s' & + application/pdf; xdg-open '%s'; nametemplate=%s.pdf + video/*; xdg-open '%s' & + audio/*; xdg-open '%s' & + application/*; xdg-open '%s' & + ''; + programs.neomutt = { + enable = true; + package = pkgs.symlinkJoin { + name = "neomutt-wrapped"; + paths = [ + pkgs.neomutt + neomuttSyncScript + ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/neomutt \ + --prefix PATH : ${config.home.profileDirectory}/bin:${lib.makeBinPath [ pkgs.urlscan ]} + ''; + meta.mainProgram = "neomutt"; + }; + sidebar.enable = true; + sort = "reverse-threads"; + vimKeys = false; + unmailboxes = true; + checkStatsInterval = 20; + extraConfig = '' + # Read messages in Neovim. `-` makes Neovim read the message from + # stdin and -R prevents accidental edits to message content. + set pager = "${lib.getExe config.development.nixvim.package} -R -n +'setlocal nolist | silent! 1,2g/^$/delete _ | nohlsearch | setlocal nomodified nomodifiable' -" + # Return directly to the index when Neovim exits and do not prepend + # NeoMutt’s pager status line to the message passed to Neovim. + set noprompt_after + set pager_format = "" + '' + + builtins.readFile ./.neomuttrc; + }; + }; } diff --git a/modules/communication/neomutt/macros.nix b/modules/communication/neomutt/macros.nix index e5ff437..2312b78 100644 --- a/modules/communication/neomutt/macros.nix +++ b/modules/communication/neomutt/macros.nix @@ -3,13 +3,13 @@ { config.programs.neomutt.macros = lib.mkIf config.communication.neomutt.enable [ { - # Sync the mailbox and run the external sync script + # Sync the mailbox and run the external neomutt-sync script map = [ "index" "pager" ]; key = "gs"; - action = "<enter-command>set my_wait_key=$wait_key wait_key=no<enter><sync-mailbox><shell-escape>${lib.getExe config.communication.neomutt.neomutt-sync.package}<enter><sync-mailbox><enter-command>set wait_key=$my_wait_key<enter>"; + action = "<enter-command>set my_wait_key=$wait_key wait_key=no<enter><sync-mailbox><shell-escape>neomutt-sync<enter><sync-mailbox><enter-command>set wait_key=$my_wait_key<enter>"; } { # Extract every URL from the message via urlscan into a picker menu diff --git a/modules/communication/neomutt/neomutt.nix b/modules/communication/neomutt/neomutt.nix deleted file mode 100644 index 1197e43..0000000 --- a/modules/communication/neomutt/neomutt.nix +++ /dev/null @@ -1,62 +0,0 @@ -# Terminal email client -{ - config, - lib, - pkgs, - ... -}: -{ - config = lib.mkIf config.communication.neomutt.enable { - xdg.desktopEntries."neomutt" = { - name = "NeoMutt"; - exec = "${lib.getExe config.terminal.kitty.package} --class neomutt -e ${lib.getExe config.programs.neomutt.package}"; - icon = "${config.programs.neomutt.package}/share/neomutt/logo/neomutt.svg"; - categories = [ - "Network" - "Email" - ]; - comment = "Terminal email client"; - terminal = false; - type = "Application"; - }; - xdg.mimeApps.defaultApplications = { - "x-scheme-handler/mailto" = "neomutt.desktop"; - }; - xdg.configFile."neomutt/mailcap".text = '' - text/html; ${lib.getExe config.web.chawan.package} -o "title='neomutt'" '%s'; nametemplate=%s.html - image/*; xdg-open '%s' & - application/pdf; xdg-open '%s'; nametemplate=%s.pdf - video/*; xdg-open '%s' & - audio/*; xdg-open '%s' & - application/*; xdg-open '%s' & - ''; - programs.neomutt = { - enable = true; - package = pkgs.symlinkJoin { - name = "neomutt-wrapped"; - paths = [ pkgs.neomutt ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/neomutt \ - --prefix PATH : ${config.home.profileDirectory}/bin:${lib.makeBinPath [ pkgs.urlscan ]} - ''; - meta.mainProgram = "neomutt"; - }; - sidebar.enable = true; - sort = "reverse-threads"; - vimKeys = false; - unmailboxes = true; - checkStatsInterval = 20; - extraConfig = '' - # Read messages in Neovim. `-` makes Neovim read the message from - # stdin and -R prevents accidental edits to message content. - set pager = "${lib.getExe config.development.nixvim.package} -R -n +'setlocal nolist | silent! 1,2g/^$/delete _ | nohlsearch | setlocal nomodified nomodifiable' -" - # Return directly to the index when Neovim exits and do not prepend - # NeoMutt’s pager status line to the message passed to Neovim. - set noprompt_after - set pager_format = "" - '' - + builtins.readFile ./.neomuttrc; - }; - }; -} diff --git a/modules/default.nix b/modules/default.nix index 05b1dca..a3e7307 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -8,7 +8,6 @@ ./file-management ./fonts ./gaming - ./lib ./media ./networking ./office diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix index 0efc0f1..1fde829 100644 --- a/modules/desktop/eww/yuck.nix +++ b/modules/desktop/eww/yuck.nix @@ -4,13 +4,63 @@ pkgs, ... }: -let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkPythonScript; -in { config = lib.mkIf config.desktop.enable { programs.eww.yuckConfig = let + mkPythonScript = + { + name, + path, + description ? "", + python ? pkgs.python3, + pythonPackages ? (ps: [ ]), + deps ? [ ], + gobjectIntrospection ? false, + }: + let + pythonEnv = python.withPackages pythonPackages; + pathPrefix = lib.concatStringsSep ":" ( + [ "${pythonEnv}/bin" ] ++ map (p: "${lib.getBin p}/bin") deps + ); + in + pkgs.stdenv.mkDerivation { + pname = name; + version = "0.1.0"; + src = path; + dontUnpack = true; + meta = lib.optionalAttrs (description != "") { inherit description; } // { + mainProgram = name; + }; + + nativeBuildInputs = + lib.optionals gobjectIntrospection [ + pkgs.wrapGAppsHook3 + pkgs.gobject-introspection + ] + ++ lib.optional (!gobjectIntrospection) pkgs.makeWrapper; + buildInputs = lib.optionals gobjectIntrospection [ pkgs.gtk3 ]; + + installPhase = '' + mkdir -p $out/bin + install -m755 $src $out/bin/${name} + patchShebangs $out/bin/${name} + ''; + + # wrapGAppsHook3 wraps every executable in $out/bin automatically, + # setting GI_TYPELIB_PATH etc. from buildInputs' closure. With + # gobjectIntrospection = false a plain wrapProgram only extends PATH. + preFixup = + if gobjectIntrospection then + '' + gappsWrapperArgs+=(--prefix PATH : "${pathPrefix}") + '' + else + '' + wrapProgram $out/bin/${name} --prefix PATH : "${pathPrefix}" + ''; + }; + system-stats = mkPythonScript { name = "eww-system-stats"; path = ./system-stats.py; diff --git a/modules/file-management/yazi/default.nix b/modules/file-management/yazi/default.nix index d704614..2f7c44f 100644 --- a/modules/file-management/yazi/default.nix +++ b/modules/file-management/yazi/default.nix @@ -6,22 +6,14 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - yaziFileChooser = mkScriptModule { - scope = [ - "file-management" - "yazi" - ]; + yaziFileChooserScript = pkgs.writeShellApplication { name = "yazi-file-chooser"; - path = ./yazi-file-chooser.sh; - description = "Yazi-based file chooser for XDG Desktop Portal"; - deps = [ + runtimeInputs = [ pkgs.bash config.file-management.yazi.package config.terminal.kitty.package ]; - extraLinks = [ "~/.config/xdg-desktop-portal-termfilechooser/config" ]; - inherit config; + text = builtins.readFile ./file-chooser.sh; }; in { @@ -39,8 +31,17 @@ in defaultText = lib.literalExpression "config.programs.yazi.finalPackage"; description = "The yazi package to use. Defaults to the wrapped finalPackage from programs.yazi."; }; - } - // yaziFileChooser.options.file-management.yazi; + + file-chooser = { + enable = lib.mkEnableOption "Enables the yazi-file-chooser script."; + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = yaziFileChooserScript; + description = "The yazi-file-chooser script package."; + }; + }; + }; config = lib.mkMerge [ (lib.mkIf config.file-management.yazi.enable { @@ -77,6 +78,10 @@ in TERMCMD = lib.mkIf config.terminal.kitty.enable "${lib.getExe config.terminal.kitty.package} --class file-explorer --title 'Yazi'"; }; }) - yaziFileChooser.config + (lib.mkIf config.file-management.yazi.file-chooser.enable { + home.file.".config/xdg-desktop-portal-termfilechooser/config" = { + source = lib.getExe config.file-management.yazi.file-chooser.package; + }; + }) ]; } diff --git a/modules/file-management/yazi/yazi-file-chooser.sh b/modules/file-management/yazi/file-chooser.sh index 7978222..7978222 100644 --- a/modules/file-management/yazi/yazi-file-chooser.sh +++ b/modules/file-management/yazi/file-chooser.sh diff --git a/modules/lib/default.nix b/modules/lib/default.nix deleted file mode 100644 index fd54fa2..0000000 --- a/modules/lib/default.nix +++ /dev/null @@ -1,48 +0,0 @@ -# Internal aggregation for script modules registered via mkScriptModule -{ - config, - lib, - ... -}: -{ - options.scriptPaths = lib.mkOption { - type = lib.types.listOf (lib.types.listOf lib.types.str); - default = [ ]; - internal = true; - description = "Attr paths of script modules registered via mkScriptModule."; - }; - - config = { - home.packages = lib.filter (p: p != null) ( - map (path: (lib.getAttrFromPath path config).package) config.scriptPaths - ); - - xdg.desktopEntries = lib.listToAttrs ( - map - ( - path: - let - name = lib.last path; - sc = lib.getAttrFromPath path config; - in - lib.nameValuePair name { - name = sc.desktop.displayName; - exec = "${lib.getExe config.terminal.kitty.package} --class ${name} -e ${lib.getExe sc.package}"; - icon = sc.desktop.icon; - categories = [ "Utility" ]; - terminal = false; - type = "Application"; - } - ) - ( - lib.filter ( - path: - let - sc = lib.getAttrFromPath path config; - in - sc.enable && sc.desktop.enable - ) config.scriptPaths - ) - ); - }; -} diff --git a/modules/lib/script.nix b/modules/lib/script.nix deleted file mode 100644 index 0586762..0000000 --- a/modules/lib/script.nix +++ /dev/null @@ -1,199 +0,0 @@ -# Library for creating script modules -{ - lib, - pkgs, -}: -let - shellArgs = { - zsh = name: file: "--zsh --name _${name} ${file}"; - bash = name: file: "--bash --name ${name}.bash ${file}"; - }; - - mkScript = - name: path: description: env: deps: completion: - let - descLines = lib.filter (s: s != "") (lib.splitString "\n" description); - descComment = - if descLines == [ ] then "" else lib.concatMapStringsSep "\n" (line: "# ${line}") descLines + "\n"; - envVars = lib.concatStringsSep "\n" ( - lib.mapAttrsToList (n: v: "export ${n}=${lib.escapeShellArg (toString v)}") env - ); - base = pkgs.writeShellApplication { - inherit name; - runtimeInputs = deps; - text = '' - ${descComment}${envVars} - ${builtins.readFile path} - ''; - }; - completionDrv = - pkgs.runCommand "${name}-completion" - { - nativeBuildInputs = [ pkgs.installShellFiles ]; - } - ( - "mkdir -p $out\n" - + lib.concatStringsSep "\n" ( - lib.mapAttrsToList (shell: content: '' - installShellCompletion ${shellArgs.${shell} name (pkgs.writeText "_${name}.${shell}" content)} - '') completion - ) - ); - in - if completion == { } then - base - else - pkgs.symlinkJoin { - name = name; - paths = [ - base - completionDrv - ]; - meta = base.meta or { }; - }; - - mkPythonScript = - { - name, - path, - description ? "", - python ? pkgs.python3, - pythonPackages ? (ps: [ ]), - deps ? [ ], - gobjectIntrospection ? false, - }: - let - pythonEnv = python.withPackages pythonPackages; - pathPrefix = lib.concatStringsSep ":" ( - [ "${pythonEnv}/bin" ] ++ map (p: "${lib.getBin p}/bin") deps - ); - in - pkgs.stdenv.mkDerivation { - pname = name; - version = "0.1.0"; - src = path; - dontUnpack = true; - meta = lib.optionalAttrs (description != "") { inherit description; } // { - mainProgram = name; - }; - - nativeBuildInputs = - lib.optionals gobjectIntrospection [ - pkgs.wrapGAppsHook3 - pkgs.gobject-introspection - ] - ++ lib.optional (!gobjectIntrospection) pkgs.makeWrapper; - buildInputs = lib.optionals gobjectIntrospection [ pkgs.gtk3 ]; - - installPhase = '' - mkdir -p $out/bin - install -m755 $src $out/bin/${name} - patchShebangs $out/bin/${name} - ''; - - # wrapGAppsHook3 wraps every executable in $out/bin automatically, - # setting GI_TYPELIB_PATH etc. from buildInputs' closure. With - # gobjectIntrospection = false a plain wrapProgram only extends PATH. - preFixup = - if gobjectIntrospection then - '' - gappsWrapperArgs+=(--prefix PATH : "${pathPrefix}") - '' - else - '' - wrapProgram $out/bin/${name} --prefix PATH : "${pathPrefix}" - ''; - }; - - mkScriptModule = - { - scope ? [ ], - name, - path, - env ? { }, - deps ? [ ], - desktop ? null, - extraLinks ? [ ], - config, - description ? "", - completion ? { }, - }: - let - scriptAttrs = scope ++ [ name ]; - dottedName = lib.concatStringsSep "." scriptAttrs; - c = lib.getAttrFromPath scriptAttrs config; - scriptDrv = mkScript name path description env deps completion; - in - { - options = lib.setAttrByPath scriptAttrs { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - description = "Whether to enable the ${name} script."; - }; - package = lib.mkOption { - type = lib.types.nullOr lib.types.package; - readOnly = true; - description = "The derivation for the ${name} script."; - }; - completion.enable = lib.mkOption { - type = lib.types.bool; - default = completion != { }; - description = "Whether to install completions for the ${name} script."; - }; - desktop = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - description = "Whether to create a .desktop entry for this script."; - }; - displayName = lib.mkOption { - type = lib.types.str; - default = name; - description = "Display name for the .desktop entry."; - }; - icon = lib.mkOption { - type = lib.types.str; - default = "kitty"; - description = "Icon for the .desktop entry."; - }; - }; - }; - - config = - lib.setAttrByPath scriptAttrs ( - lib.mkIf c.enable ( - { - package = scriptDrv; - } - // lib.optionalAttrs (desktop != null) { inherit desktop; } - ) - ) - // { - home.file = lib.mkIf c.enable ( - builtins.listToAttrs ( - map (linkPath: { - name = lib.removePrefix "~/" linkPath; - value = { - source = "${scriptDrv}/bin/${name}"; - }; - }) extraLinks - ) - ); - assertions = [ - { - assertion = !c.enable || !c.desktop.enable || config.terminal.kitty.enable; - message = "${dottedName}.desktop.enable requires terminal.kitty.enable because desktop entries launch scripts in kitty."; - } - { - assertion = !c.completion.enable || completion != { }; - message = "${dottedName}.completion.enable is true but no completion text was provided to mkScriptModule."; - } - ]; - scriptPaths = [ scriptAttrs ]; - }; - }; -in -{ - inherit mkPythonScript mkScript mkScriptModule; -} diff --git a/modules/media/screen-recording/default.nix b/modules/media/screen-recording/default.nix index 109ed0a..163ee3f 100644 --- a/modules/media/screen-recording/default.nix +++ b/modules/media/screen-recording/default.nix @@ -6,35 +6,63 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - script = mkScriptModule { - scope = [ "media" ]; + screenRecordingScript = pkgs.writeShellApplication { name = "screen-recording"; - path = ./screen-recording.sh; - description = "Screen recording script using wf-recorder and slurp for region selection\nRecords Wayland screen to MP4\nUsage: screen-recording.sh [-s|--select]\n -s, --select Launch slurp to select recording region"; - deps = [ + runtimeInputs = [ pkgs.bash config.media.slurp.package config.media.wf-recorder.package ]; - completion.zsh = builtins.readFile ./screen-recording.zsh; - desktop = { - enable = true; - displayName = "Screen Recording"; - icon = "obs"; - }; - inherit config; + text = builtins.readFile ./screen-recording.sh; + }; + + screenRecordingCompletion = + pkgs.runCommand "screen-recording-completion" + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } + '' + mkdir -p $out/share/zsh/site-functions + installShellCompletion zsh --name _screen-recording ${pkgs.writeText "screen-recording.zsh" (builtins.readFile ./screen-recording.zsh)} + ''; + + scriptPkg = pkgs.symlinkJoin { + name = "screen-recording"; + paths = [ + screenRecordingScript + screenRecordingCompletion + ]; + meta = screenRecordingScript.meta or { }; }; in { - options = script.options; - config = lib.mkMerge [ - script.config - { - assertions = import ./assertions.nix { inherit config lib; }; - home.file.".local/share/icons/hicolor/scalable/apps/obs.svg" = { - source = ../../../assets/icons/apps/obs.svg; - }; - } - ]; + options.media.screen-recording = { + enable = lib.mkEnableOption "Screen recording script using wf-recorder and slurp"; + + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = scriptPkg; + description = "The screen-recording script package."; + }; + }; + + config = lib.mkIf config.media.screen-recording.enable { + home.packages = [ scriptPkg ]; + + assertions = import ./assertions.nix { inherit config lib; }; + + home.file.".local/share/icons/hicolor/scalable/apps/obs.svg" = { + source = ../../../assets/icons/apps/obs.svg; + }; + + xdg.desktopEntries.screen-recording = { + name = "Screen Recording"; + exec = "${lib.getExe config.terminal.kitty.package} --class screen-recording -e ${lib.getExe scriptPkg}"; + icon = "obs"; + categories = [ "Utility" ]; + terminal = false; + type = "Application"; + }; + }; } diff --git a/modules/networking/usque/default.nix b/modules/networking/usque/default.nix index 9d04ab7..ffde47a 100644 --- a/modules/networking/usque/default.nix +++ b/modules/networking/usque/default.nix @@ -6,21 +6,32 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - usqueWarp = mkScriptModule { - scope = [ - "networking" - "usque" - ]; + usqueWarpScript = pkgs.writeShellApplication { name = "usque-warp"; - path = ./usque-warp.sh; - description = "Connect/disconnect to Cloudflare WARP via usque MASQUE tunnel"; - deps = [ + runtimeInputs = [ config.networking.usque.package pkgs.bash ]; - completion.zsh = builtins.readFile ./usque-warp.zsh; - inherit config; + text = builtins.readFile ./usque-warp.sh; + }; + + usqueWarpCompletion = + pkgs.runCommand "usque-warp-completion" + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } + '' + mkdir -p $out/share/zsh/site-functions + installShellCompletion --zsh --name _usque-warp ${pkgs.writeText "usque-warp.zsh" (builtins.readFile ./usque-warp.zsh)} + ''; + + usqueWarpScriptPkg = pkgs.symlinkJoin { + name = "usque-warp"; + paths = [ + usqueWarpScript + usqueWarpCompletion + ]; + meta = usqueWarpScript.meta or { }; }; in { @@ -31,13 +42,24 @@ in default = pkgs.usque; description = "The usque package to use."; }; - } - // usqueWarp.options.networking.usque; + + warp = { + enable = lib.mkEnableOption "Enables the usque-warp script."; + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = usqueWarpScriptPkg; + description = "The usque-warp script package."; + }; + }; + }; config = lib.mkMerge [ (lib.mkIf config.networking.usque.enable { home.packages = [ config.networking.usque.package ]; }) - usqueWarp.config + (lib.mkIf config.networking.usque.warp.enable { + home.packages = [ config.networking.usque.warp.package ]; + }) ]; } diff --git a/modules/security/gopass/default.nix b/modules/security/gopass/default.nix index 5fe5b3d..fa5e486 100644 --- a/modules/security/gopass/default.nix +++ b/modules/security/gopass/default.nix @@ -6,29 +6,21 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - gopassKeys = config.security.ssh.gopassKeys; - gopassSshLoad = mkScriptModule { - scope = [ - "security" - "gopass" - ]; + gopassSshLoadScript = pkgs.writeShellApplication { name = "gopass-ssh-load"; - path = ./gopass-ssh-load.sh; - description = "Load SSH keys from gopass password store"; - env = { - GNUPGHOME = config.home.sessionVariables.GNUPGHOME; - GOPASS_SSH_KEYS = lib.concatStringsSep " " gopassKeys; - }; - deps = with pkgs; [ + runtimeInputs = with pkgs; [ config.security.gopass.package gnupg openssh bash ]; - inherit config; + text = '' + export GNUPGHOME="${config.home.sessionVariables.GNUPGHOME}" + export GOPASS_SSH_KEYS="${lib.concatStringsSep " " gopassKeys}" + ${builtins.readFile ./gopass-ssh-load.sh} + ''; }; in { @@ -40,9 +32,16 @@ in default = config.programs.password-store.package; description = "The gopass package to use."; }; - ssh-agent.enable = lib.mkEnableOption "gopass-backed SSH keys for git"; - } - // gopassSshLoad.options.security.gopass; + ssh-agent = { + enable = lib.mkEnableOption "gopass-backed SSH keys for git"; + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = gopassSshLoadScript; + description = "The gopass-ssh-load script package."; + }; + }; + }; config = lib.mkMerge [ (lib.mkIf config.security.gopass.enable { @@ -72,6 +71,8 @@ in type = "Application"; }; }) - gopassSshLoad.config + (lib.mkIf config.security.gopass.ssh-agent.enable { + home.packages = [ config.security.gopass.ssh-agent.package ]; + }) ]; } diff --git a/modules/security/gpg/default.nix b/modules/security/gpg/default.nix index 07d9d4b..ccab0dc 100644 --- a/modules/security/gpg/default.nix +++ b/modules/security/gpg/default.nix @@ -6,24 +6,35 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - gpgBackup = mkScriptModule { - scope = [ - "security" - "gpg" - ]; + gpgBackupScript = pkgs.writeShellApplication { name = "gpg-backup"; - path = ./gpg-backup.sh; - description = "Export/import all GPG keys as a single passphrase-protected file with maximum S2K iteration count\nUsage: gpg-backup export filename.gpg | gpg-backup import filename.gpg"; - deps = [ + runtimeInputs = [ pkgs.bash pkgs.gnupg pkgs.gnutar pkgs.coreutils pkgs.findutils ]; - completion.zsh = builtins.readFile ./gpg-backup.zsh; - inherit config; + text = builtins.readFile ./gpg-backup.sh; + }; + + gpgBackupCompletion = + pkgs.runCommand "gpg-backup-completion" + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } + '' + mkdir -p $out/share/zsh/site-functions + installShellCompletion --zsh --name _gpg-backup ${pkgs.writeText "gpg-backup.zsh" (builtins.readFile ./gpg-backup.zsh)} + ''; + + gpgBackupScriptPkg = pkgs.symlinkJoin { + name = "gpg-backup"; + paths = [ + gpgBackupScript + gpgBackupCompletion + ]; + meta = gpgBackupScript.meta or { }; }; in { @@ -37,8 +48,17 @@ in defaultText = lib.literalExpression "config.programs.gpg.package"; description = "The gpg package to use."; }; - } - // gpgBackup.options.security.gpg; + + backup = { + enable = lib.mkEnableOption "Enable the gpg-backup script"; + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = gpgBackupScriptPkg; + description = "The package for the gpg-backup script"; + }; + }; + }; config = lib.mkMerge [ (lib.mkIf config.security.gpg.enable { @@ -60,6 +80,8 @@ in pinentry.package = pkgs.pinentry-rofi; }; }) - gpgBackup.config + (lib.mkIf config.security.gpg.backup.enable { + home.packages = [ config.security.gpg.backup.package ]; + }) ]; } diff --git a/modules/system/deep-clean/default.nix b/modules/system/deep-clean/default.nix index af75382..02022fe 100644 --- a/modules/system/deep-clean/default.nix +++ b/modules/system/deep-clean/default.nix @@ -6,13 +6,25 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; + deepCleanScript = pkgs.writeShellApplication { + name = "deep-clean"; + runtimeInputs = [ pkgs.bash ]; + text = builtins.readFile ./deep-clean.sh; + }; in -mkScriptModule { - scope = [ "system" ]; - name = "deep-clean"; - path = ./deep-clean.sh; - description = "Deep clean script for Nix systems\nRemoves old generations, garbage, and optimizes store\nWARNING: Do NOT run with sudo - run as normal user"; - deps = [ pkgs.bash ]; - inherit config; +{ + options.system.deep-clean = { + enable = lib.mkEnableOption "Enables the deep-clean script."; + + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = deepCleanScript; + description = "The deep-clean script package."; + }; + }; + + config = lib.mkIf config.system.deep-clean.enable { + home.packages = [ config.system.deep-clean.package ]; + }; } diff --git a/modules/system/nix-update/default.nix b/modules/system/nix-update/default.nix index 13c15f6..4d00c77 100644 --- a/modules/system/nix-update/default.nix +++ b/modules/system/nix-update/default.nix @@ -6,19 +6,49 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; + nixUpdateScript = pkgs.writeShellApplication { + name = "nix-update"; + runtimeInputs = [ + pkgs.git + pkgs.nix + config.programs.home-manager.package + pkgs.bash + ]; + text = builtins.readFile ./nix-update.sh; + }; + + nixUpdateCompletion = + pkgs.runCommand "nix-update-completion" + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } + '' + mkdir -p $out/share/zsh/site-functions + installShellCompletion --zsh --name _nix-update ${pkgs.writeText "nix-update.zsh" (builtins.readFile ./nix-update.zsh)} + ''; + + nixUpdateScriptPkg = pkgs.symlinkJoin { + name = "nix-update"; + paths = [ + nixUpdateScript + nixUpdateCompletion + ]; + meta = nixUpdateScript.meta or { }; + }; in -mkScriptModule { - scope = [ "system" ]; - name = "nix-update"; - path = ./nix-update.sh; - description = "Update NixOS and/or Home Manager flake configuration\nRuns nix flake update and rebuilds the system"; - deps = [ - pkgs.git - pkgs.nix - config.programs.home-manager.package - pkgs.bash - ]; - completion.zsh = builtins.readFile ./nix-update.zsh; - inherit config; +{ + options.system.nix-update = { + enable = lib.mkEnableOption "Update NixOS and/or Home Manager flake configuration"; + + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = nixUpdateScriptPkg; + description = "The nix-update script package."; + }; + }; + + config = lib.mkIf config.system.nix-update.enable { + home.packages = [ config.system.nix-update.package ]; + }; } |
