1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-07 13:53:27 +02:00
home-manager/modules/services/git-sync.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

102 lines
2.6 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.git-sync;
mkUnit = name: repo: {
Unit.Description = "Git Sync ${name}";
Install.WantedBy = [ "default.target" ];
Service = {
Environment = [
"PATH=${lib.makeBinPath (with pkgs; [ openssh git ])}"
"GIT_SYNC_DIRECTORY=${repo.path}"
"GIT_SYNC_COMMAND=${cfg.package}/bin/git-sync"
"GIT_SYNC_REPOSITORY=${repo.uri}"
"GIT_SYNC_INTERVAL=${toString repo.interval}"
];
ExecStart = "${cfg.package}/bin/git-sync-on-inotify";
Restart = "on-abort";
};
};
services = mapAttrs' (name: repo: {
name = "git-sync-${name}";
value = mkUnit name repo;
}) cfg.repositories;
repositoryType = types.submodule ({ name, ... }: {
options = {
name = mkOption {
internal = true;
default = name;
type = types.str;
description = lib.mdDoc "The name that should be given to this unit.";
};
path = mkOption {
type = types.path;
description = lib.mdDoc "The path at which to sync the repository";
};
uri = mkOption {
type = types.str;
example = "git+ssh://user@example.com:/~[user]/path/to/repo.git";
description = lib.mdDoc ''
The URI of the remote to be synchronized. This is only used in the
event that the directory does not already exist. See
<https://git-scm.com/docs/git-clone#_git_urls>
for the supported URIs.
'';
};
interval = mkOption {
type = types.int;
default = 500;
description = lib.mdDoc ''
The interval, specified in seconds, at which the synchronization will
be triggered even without filesystem changes.
'';
};
};
});
in {
meta.maintainers = [ maintainers.imalison maintainers.cab404 ];
options = {
services.git-sync = {
enable = mkEnableOption (lib.mdDoc "git-sync services");
package = mkOption {
type = types.package;
default = pkgs.git-sync;
defaultText = literalExpression "pkgs.git-sync";
description = lib.mdDoc ''
Package containing the {command}`git-sync` program.
'';
};
repositories = mkOption {
type = with types; attrsOf repositoryType;
description = lib.mdDoc ''
The repositories that should be synchronized.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.git-sync" pkgs
lib.platforms.linux)
];
systemd.user.services = services;
};
}