blob: ac4bd1549dae1ce8e4ea27ce8f2af70858042970 (
plain)
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
|
# SPDX-FileCopyrightText: V <v@unfathomable.blue>
# SPDX-License-Identifier: OSL-3.0
# TODO(V): Make the option descriptions not be terrible.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.declarative.git;
repoOpts = { name, config, ... }: {
options = {
description = mkOption {
description = "Description of the repository.";
type = types.str;
# Git defaults to "Unnamed repository; edit this file 'description' to name the repository."
# CGit defaults to "[no description]"
default = "Unnamed repository; edit this file 'description' to name the repository.";
};
config = mkOption {
description = "Git configuration for the repository.";
type = types.attrs; # TODO(V): be more precise
default = {};
};
hooks = mkOption {
description = "Git hooks for the repository.";
type = with types; attrsOf (listOf path);
default = {};
};
};
};
in {
options.declarative.git = {
repositories = mkOption {
description = "Repositories to manage declaratively.";
type = types.attrsOf (types.submodule repoOpts);
default = {};
};
hooks = mkOption {
description = "Git hooks to apply to all declarative repositories.";
type = with types; attrsOf (listOf path);
default = {};
};
};
config.systemd.tmpfiles.packages = mapAttrsToList (name: config:
pkgs.declarative-git-repository {
path = "/var/lib/git/${name}";
inherit (config) description config;
hooks = zipAttrsWith (_: concatLists) [ cfg.hooks config.hooks ];
user = "git";
group = "git";
}) cfg.repositories;
}
|