From f1b2dd11457bb596d7a95e235cef98faefaf3a52 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Wed, 10 Aug 2022 18:22:54 +0200 Subject: [PATCH] add misc module (with keepass currently) --- modules/default.nix | 2 ++ modules/misc.nix | 46 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 modules/misc.nix diff --git a/modules/default.nix b/modules/default.nix index c4aa0220..b96f3c34 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -6,5 +6,7 @@ ./emacs.nix ./flatpak.nix ./gaming.nix + ./misc.nix + ./nextcloud.nix ]; } diff --git a/modules/misc.nix b/modules/misc.nix new file mode 100644 index 00000000..91a5c3e3 --- /dev/null +++ b/modules/misc.nix @@ -0,0 +1,46 @@ +{ config, nixosConfig, lib, mylib, pkgs, ... }: + +with lib; +with mylib.modules; + +let + cfg = config.modules.misc; +in { + options.modules.misc = { + enable = mkEnableOpt "Misc module"; + + keepass = { + enable = mkEnableOpt "KeePassXC"; + autostart = mkBoolOpt "Autostart KeePassXC"; + }; + }; + + config = mkIf cfg.enable { + + home.packages = with pkgs; builtins.concatLists [ + (optionals cfg.keepass.enable [ keepassxc ]) + ]; + + + systemd.user.services = { + autostart-keepass = + (mkIf (cfg.keepass.enable && cfg.keepass.autostart) { + Unit = { + Type = "oneshot"; + Description = "KeePassXC password manager"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; + }; + + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; # Leads to /etc/profiles/per-user/christoph/bin + ExecStart = "${pkgs.keepassxc}/bin/keepassxc ${config.home.homeDirectory}/Documents/KeePass/passwords.kbdx"; +# ExecStop = "${pkgs.noisetorch}/bin/noisetorch -u"; + Restart = "on-failure"; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + }); + }; + }; +}