summaryrefslogtreecommitdiffstats
path: root/modules/by-name/ch/chipass/module.nix
blob: 1b34338753fc162e09ba028e5258487b9506b600 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.soispha.programs.chipass;

  iniFormat = pkgs.formats.ini {};
  settingsFile = iniFormat.generate "chipass-settings" cfg.settings;
in {
  options.soispha.programs.chipass = {
    enable = lib.mkEnableOption "chipass";

    settings = lib.mkOption {
      inherit (iniFormat) type;
      default = {};
      example = {
        Browser.Enabled = true;

        GUI = {
          AdvancedSettings = true;
          ApplicationTheme = "dark";
          CompactMode = true;
          HidePasswords = true;
        };

        SSHAgent.Enabled = true;
      };
      description = ''
        Configuration written to
        {file}`$XDG_CONFIG_HOME/keepassxc/keepassxc.ini`.

        See <https://github.com/keepassxreboot/keepassxc/blob/develop/src/core/Config.cpp>
        for the full list of options.

        ::: {.note}
        When the settings are non-empty, the configuration file will be linked
        into the Nix store and KeePassXC will report an access error for its
        configuration file. This is expected and can not be fixed in a way that
        aligns with Home Manager's principles. See [#8257](https://github.com/nix-community/home-manager/issues/8257) for more details.
        :::
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    soispha.programs.chipass.settings = lib.mkDefault {
      General = {
        BackupBeforeSave = true;
        AutoSaveAfterEveryChange = true;
        BackupFilePathPattern = "${config.home-manager.users.soispha.xdg.dataHome}/chipass/{DB_FILENAME}.old.kdbx";
        ConfigVersion = 2;
      };

      Browser = {
        Enabled = false;
        CustomProxyLocation = "";
      };

      FdoSecrets = {
        Enabled = false;
      };

      GUI = {
        ColorPasswords = false;
        CompactMode = false;
        TrayIconAppearance = "monochrome-light";
        AdvancedSettings = true;
        HidePasswords = true;
      };

      KeeShare = {
        Active = "";
        Own = "";
        QuietSuccess = true;
      };

      PasswordGenerator = {
        AdditionalChars = "";
        ExcludedChars = "";
        WordList = ":/wordlists/eff_large.wordlist";
        AdvancedMode = true;
        Braces = true;
        Dashes = true;
        EASCII = true;
        Length = 128;
        Logograms = true;
        LowerCase = true;
        Math = true;
        Numbers = true;
        Punctuation = true;
        Quotes = true;
        SpecialChars = true;
        Type = 0;
        UpperCase = true;
        WordCount = 4;
        WordSeparator = ",";
      };

      SSHAgent = {
        Enabled = false;
      };

      Security = {
        HidePasswordPreviewPanel = true;
        IconDownloadFallback = true;
        LockDatabaseIdle = false;
        LockDatabaseIdleSeconds = 960;
        PasswordEmptyPlaceholder = true;
        PasswordsHidden = true;
        PasswordsRepeatVisible = true;
      };
    };

    home-manager.users.soispha = {
      xdg.configFile."keepassxc/keepassxc.ini".source = settingsFile;
    };
  };
}