15 json = pkgs.formats.json { };
16 cfg = config.services.renovate;
17 generateValidatedConfig =
27 value = builtins.toJSON value;
28 passAsFile = [ "value" ];
29 preferLocalBuild = true;
32 jq . "$valuePath"> $out
33 renovate-config-validator $out
36 generateConfig = if cfg.validateSettings then generateValidatedConfig else json.generate;
39 meta.maintainers = with lib.maintainers; [ marie natsukium ];
41 options.services.renovate = {
42 enable = mkEnableOption "renovate";
43 package = mkPackageOption pkgs "renovate" { };
45 type = with types; nullOr str;
46 description = "How often to run renovate. See {manpage}`systemd.time(7)` for the format.";
50 credentials = mkOption {
51 type = with types; attrsOf path;
53 Allows configuring environment variable credentials for renovate, read from files.
54 This should always be used for passing confidential data to renovate.
57 RENOVATE_TOKEN = "/etc/renovate/token";
61 runtimePackages = mkOption {
62 type = with types; listOf package;
63 description = "Packages available to renovate.";
66 validateSettings = mkOption {
69 description = "Weither to run renovate's config validator on the built configuration.";
76 endpoint = "https://git.example.com";
77 gitAuthor = "Renovate <renovate@example.com>";
80 Renovate's global configuration.
81 If you want to pass secrets to renovate, please use {option}`services.renovate.credentials` for that.
86 config = mkIf cfg.enable {
87 services.renovate.settings = {
88 cacheDir = "/var/cache/renovate";
89 baseDir = "/var/lib/renovate";
92 systemd.services.renovate = {
93 description = "Renovate dependency updater";
94 documentation = [ "https://docs.renovatebot.com/" ];
95 after = [ "network.target" ];
96 startAt = lib.optional (cfg.schedule != null) cfg.schedule;
98 config.systemd.package
100 ] ++ cfg.runtimePackages;
107 LoadCredential = lib.mapAttrsToList (name: value: "SECRET-${name}:${value}") cfg.credentials;
108 RemainAfterExit = false;
109 Restart = "on-failure";
110 CacheDirectory = "renovate";
111 StateDirectory = "renovate";
114 CapabilityBoundingSet = [ "" ];
115 DeviceAllow = [ "" ];
116 LockPersonality = true;
117 PrivateDevices = true;
121 ProtectControlGroups = true;
123 ProtectHostname = true;
124 ProtectKernelLogs = true;
125 ProtectKernelModules = true;
126 ProtectKernelTunables = true;
127 ProtectProc = "invisible";
128 RestrictAddressFamilies = [
133 RestrictNamespaces = true;
134 RestrictRealtime = true;
135 SystemCallArchitectures = "native";
140 ${lib.concatStringsSep "\n" (
141 builtins.map (name: "export ${name}=$(systemd-creds cat 'SECRET-${name}')") (
142 lib.attrNames cfg.credentials
145 exec ${lib.escapeShellArg (lib.getExe cfg.package)}
149 RENOVATE_CONFIG_FILE = generateConfig "renovate-config.json" cfg.settings;
150 HOME = "/var/lib/renovate";