home-manager/modules/programs/rbw.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

119 lines
3.4 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.programs.rbw;
jsonFormat = pkgs.formats.json { };
inherit (pkgs.stdenv.hostPlatform) isDarwin;
settingsModule = with lib;
types.submodule {
freeformType = jsonFormat.type;
options = {
email = mkOption {
type = types.str;
example = "name@example.com";
description =
lib.mdDoc "The email address for your bitwarden account.";
};
base_url = mkOption {
type = with types; nullOr str;
default = null;
example = "bitwarden.example.com";
description =
lib.mdDoc "The base-url for a self-hosted bitwarden installation.";
};
identity_url = mkOption {
type = with types; nullOr str;
default = null;
example = "identity.example.com";
description =
lib.mdDoc "The identity url for your bitwarden installation.";
};
lock_timeout = mkOption {
type = types.ints.unsigned;
default = 3600;
example = 300;
description = lib.mdDoc ''
The amount of time that your login information should be cached.
'';
};
pinentry = mkOption {
type = with types; either package (enum pkgs.pinentry.flavors);
example = "gnome3";
default = "gtk2";
description = lib.mdDoc ''
Which pinentry interface to use. Beware that
`pinentry-gnome3` may not work on non-Gnome
systems. You can fix it by adding the following to your
system configuration:
```nix
services.dbus.packages = [ pkgs.gcr ];
```
For this reason, the default is `gtk2` for
now.
'';
# we want the program in the config
apply = val:
if builtins.isString val then
"${pkgs.pinentry.${val}}/bin/pinentry"
else
"${val}/${val.binaryPath or "bin/pinentry"}";
};
};
};
in {
meta.maintainers = with lib.hm.maintainers; [ ambroisie ];
options.programs.rbw = with lib; {
enable = mkEnableOption (lib.mdDoc "rbw, a CLI Bitwarden client");
package = mkOption {
type = types.package;
default = pkgs.rbw;
defaultText = literalExpression "pkgs.rbw";
description = lib.mdDoc ''
Package providing the {command}`rbw` tool and its
{command}`rbw-agent` daemon.
'';
};
settings = mkOption {
type = types.nullOr settingsModule;
default = null;
example = literalExpression ''
{
email = "name@example.com";
lock_timeout = 300;
pinentry = "gnome3";
}
'';
description = lib.mdDoc ''
rbw configuration, if not defined the configuration will not be
managed by Home Manager.
'';
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
home.packages = [ cfg.package ];
}
# Only manage configuration if not empty
(lib.mkIf (cfg.settings != null && !isDarwin) {
xdg.configFile."rbw/config.json".source =
jsonFormat.generate "rbw-config.json" cfg.settings;
})
(lib.mkIf (cfg.settings != null && isDarwin) {
home.file."Library/Application Support/rbw/config.json".source =
jsonFormat.generate "rbw-config.json" cfg.settings;
})
]);
}