mirror of
https://github.com/nix-community/home-manager
synced 2024-12-21 02:23:16 +00:00
36a53d9f26
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
73 lines
2 KiB
Nix
73 lines
2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
serviceCfg = config.services.password-store-sync;
|
|
programCfg = config.programs.password-store;
|
|
|
|
in {
|
|
meta.maintainers = with maintainers; [ pacien ];
|
|
|
|
options.services.password-store-sync = {
|
|
enable = mkEnableOption (lib.mdDoc "Password store periodic sync");
|
|
|
|
frequency = mkOption {
|
|
type = types.str;
|
|
default = "*:0/5";
|
|
description = lib.mdDoc ''
|
|
How often to synchronise the password store git repository with its
|
|
default upstream.
|
|
|
|
This value is passed to the systemd timer configuration as the
|
|
`onCalendar` option.
|
|
See
|
|
{manpage}`systemd.time(7)`
|
|
for more information about the format.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf serviceCfg.enable {
|
|
assertions = [
|
|
(hm.assertions.assertPlatform "services.password-store-sync" pkgs
|
|
platforms.linux)
|
|
|
|
{
|
|
assertion = programCfg.enable;
|
|
message = "The 'services.password-store-sync' module requires"
|
|
+ " 'programs.password-store.enable = true'.";
|
|
}
|
|
];
|
|
|
|
systemd.user.services.password-store-sync = {
|
|
Unit = { Description = "Password store sync"; };
|
|
|
|
Service = {
|
|
CPUSchedulingPolicy = "idle";
|
|
IOSchedulingClass = "idle";
|
|
Environment = let
|
|
makeEnvironmentPairs =
|
|
mapAttrsToList (key: value: "${key}=${builtins.toJSON value}");
|
|
in makeEnvironmentPairs programCfg.settings;
|
|
ExecStart = toString (pkgs.writeShellScript "password-store-sync" ''
|
|
${pkgs.pass}/bin/pass git pull --rebase && \
|
|
${pkgs.pass}/bin/pass git push
|
|
'');
|
|
};
|
|
};
|
|
|
|
systemd.user.timers.password-store-sync = {
|
|
Unit = { Description = "Password store periodic sync"; };
|
|
|
|
Timer = {
|
|
Unit = "password-store-sync.service";
|
|
OnCalendar = serviceCfg.frequency;
|
|
Persistent = true;
|
|
};
|
|
|
|
Install = { WantedBy = [ "timers.target" ]; };
|
|
};
|
|
};
|
|
}
|