k 3 repo-sync: better types, add repo timer
This commit is contained in:
parent
f66d7f4d47
commit
8464ebbf69
@ -12,7 +12,34 @@ let
|
|||||||
api = {
|
api = {
|
||||||
enable = mkEnableOption "repo-sync";
|
enable = mkEnableOption "repo-sync";
|
||||||
repos = mkOption {
|
repos = mkOption {
|
||||||
type = with types;attrsOf (attrsOf (attrsOf (attrsOf str)));
|
type = types.attrsOf (types.submodule {
|
||||||
|
options = {
|
||||||
|
branches = mkOption {
|
||||||
|
type = types.attrsOf (types.submodule ({ config, ... }: {
|
||||||
|
options = {
|
||||||
|
origin = mkOption {
|
||||||
|
type = types.git-source;
|
||||||
|
};
|
||||||
|
mirror = mkOption {
|
||||||
|
type = types.git-source;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
origin.ref = mkDefault "heads/master";
|
||||||
|
mirror.ref = mkDefault "heads/${config._module.args.name}";
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
latest = mkOption {
|
||||||
|
type = types.nullOr types.git-source;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
timerConfig = mkOption {
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
default = cfg.timerConfig;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
example = literalExample ''
|
example = literalExample ''
|
||||||
# see `repo-sync --help`
|
# see `repo-sync --help`
|
||||||
# `ref` provides sane defaults and can be omitted
|
# `ref` provides sane defaults and can be omitted
|
||||||
@ -23,6 +50,7 @@ let
|
|||||||
# each attrset defines a group of repos for syncing
|
# each attrset defines a group of repos for syncing
|
||||||
|
|
||||||
{ nxpkgs = {
|
{ nxpkgs = {
|
||||||
|
branches = {
|
||||||
makefu = {
|
makefu = {
|
||||||
origin = {
|
origin = {
|
||||||
url = http://github.com/makefu/nixpkgs;
|
url = http://github.com/makefu/nixpkgs;
|
||||||
@ -41,14 +69,14 @@ let
|
|||||||
url = "git@internal:nixpkgs-mirror" ;
|
url = "git@internal:nixpkgs-mirror" ;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"@latest" = {
|
};
|
||||||
mirror = {
|
latest = {
|
||||||
url = "git@internal:nixpkgs-mirror";
|
url = "git@internal:nixpkgs-mirror";
|
||||||
ref = "heads/master";
|
ref = "heads/master";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
stockholm = {
|
stockholm = {
|
||||||
|
branches = {
|
||||||
lass = {
|
lass = {
|
||||||
origin = {
|
origin = {
|
||||||
url = http://cgit.prism.r/stockholm;
|
url = http://cgit.prism.r/stockholm;
|
||||||
@ -65,14 +93,13 @@ let
|
|||||||
url = "git@internal:stockholm-mirror" ;
|
url = "git@internal:stockholm-mirror" ;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"@latest" = {
|
};
|
||||||
mirror = {
|
latest = {
|
||||||
url = "git@internal:stockholm-mirror";
|
url = "git@internal:stockholm-mirror";
|
||||||
ref = "heads/master";
|
ref = "heads/master";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
timerConfig = mkOption {
|
timerConfig = mkOption {
|
||||||
@ -127,15 +154,16 @@ let
|
|||||||
nameValuePair "repo-sync-${name}" {
|
nameValuePair "repo-sync-${name}" {
|
||||||
description = "repo-sync timer";
|
description = "repo-sync timer";
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = repo.timerConfig;
|
||||||
timerConfig = cfg.timerConfig;
|
|
||||||
}
|
}
|
||||||
) cfg.repos;
|
) cfg.repos;
|
||||||
|
|
||||||
systemd.services = mapAttrs' (name: repo:
|
systemd.services = mapAttrs' (name: repo:
|
||||||
let
|
let
|
||||||
repo-sync-config = pkgs.writeText "repo-sync-config-${name}.json"
|
repo-sync-config = pkgs.writeJSON "repo-sync-config-${name}.json"
|
||||||
(builtins.toJSON repo);
|
(repo.branches // optionalAttrs (repo.latest != null) {
|
||||||
|
"@latest".mirror = repo.latest;
|
||||||
|
});
|
||||||
in nameValuePair "repo-sync-${name}" {
|
in nameValuePair "repo-sync-${name}" {
|
||||||
description = "repo-sync";
|
description = "repo-sync";
|
||||||
after = [ "network.target" "secret.service" ];
|
after = [ "network.target" "secret.service" ];
|
||||||
|
Loading…
Reference in New Issue
Block a user