Commit c3eaa0e1 authored by LuckShiba's avatar LuckShiba
Browse files

nixos/dsearch: add module

parent 6e3c1bf5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@
  ./programs/direnv.nix
  ./programs/dmrconfig.nix
  ./programs/droidcam.nix
  ./programs/dsearch.nix
  ./programs/dublin-traceroute.nix
  ./programs/ecryptfs.nix
  ./programs/environment.nix
+53 −0
Original line number Diff line number Diff line
{
  config,
  lib,
  pkgs,
  ...
}:

let
  inherit (lib)
    mkEnableOption
    mkOption
    mkIf
    mkPackageOption
    types
    ;

  cfg = config.programs.dsearch;
in
{
  options.programs.dsearch = {
    enable = mkEnableOption "dsearch, a fast filesystem search service with fuzzy matching";

    package = mkPackageOption pkgs "dsearch" { };

    systemd = {
      enable = mkEnableOption "systemd user service for dsearch" // {
        default = true;
      };

      target = mkOption {
        type = types.str;
        default = "default.target";
        description = ''
          The systemd target that will automatically start the dsearch service.

          By default, dsearch starts with the user session (`default.target`).
          You can change this to `graphical-session.target` if you only want
          it to run in graphical sessions.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ cfg.package ];

    systemd.packages = [ cfg.package ];

    systemd.user.services.dsearch.wantedBy = mkIf cfg.systemd.enable [ cfg.systemd.target ];
  };

  meta.maintainers = with lib.maintainers; [ luckshiba ];
}