1 { config, pkgs, lib, ... }:
6 cfg = config.services.oxidized;
9 options.services.oxidized = {
10 enable = mkEnableOption "the oxidized configuration backup service";
16 User under which the oxidized service runs.
24 Group under which the oxidized service runs.
30 default = "/var/lib/oxidized";
31 description = "State directory for the oxidized service.";
34 configFile = mkOption {
36 example = literalExpression ''
37 pkgs.writeText "oxidized-config.yml" '''
52 delimiter: !ruby/regexp /:/
53 file: "/var/lib/oxidized/.config/oxidized/router.db"
59 pid: "/var/lib/oxidized/.config/oxidized/pid"
62 # ... additional config
66 Path to the oxidized configuration file.
72 example = literalExpression ''
73 pkgs.writeText "oxidized-router.db" '''
74 hostname-sw1:powerconnect:username1:password2
75 hostname-sw2:procurve:username2:password2
76 # ... additional hosts
80 Path to the file/database which contains the targets for oxidized.
85 config = mkIf cfg.enable {
86 users.groups.${cfg.group} = { };
87 users.users.${cfg.user} = {
88 description = "Oxidized service user";
95 systemd.services.oxidized = {
96 wantedBy = [ "multi-user.target" ];
97 after = [ "network.target" ];
100 mkdir -p ${cfg.dataDir}/.config/oxidized
101 ln -f -s ${cfg.routerDB} ${cfg.dataDir}/.config/oxidized/router.db
102 ln -f -s ${cfg.configFile} ${cfg.dataDir}/.config/oxidized/config
106 ExecStart = "${pkgs.oxidized}/bin/oxidized";
110 NoNewPrivileges = true;
112 WorkingDirectory = cfg.dataDir;
113 KillSignal = "SIGKILL";
114 PIDFile = "${cfg.dataDir}/.config/oxidized/pid";