mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-13 01:03:25 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
101 lines
2.9 KiB
Nix
101 lines
2.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.flexget;
|
|
pkg = pkgs.flexget;
|
|
ymlFile = pkgs.writeText "flexget.yml" ''
|
|
${cfg.config}
|
|
|
|
${optionalString cfg.systemScheduler "schedules: no"}
|
|
'';
|
|
configFile = "${toString cfg.homeDir}/flexget.yml";
|
|
in {
|
|
options = {
|
|
services.flexget = {
|
|
enable = mkEnableOption "Run FlexGet Daemon";
|
|
|
|
user = mkOption {
|
|
default = "deluge";
|
|
example = "some_user";
|
|
type = types.str;
|
|
description = lib.mdDoc "The user under which to run flexget.";
|
|
};
|
|
|
|
homeDir = mkOption {
|
|
default = "/var/lib/deluge";
|
|
example = "/home/flexget";
|
|
type = types.path;
|
|
description = lib.mdDoc "Where files live.";
|
|
};
|
|
|
|
interval = mkOption {
|
|
default = "10m";
|
|
example = "1h";
|
|
type = types.str;
|
|
description = lib.mdDoc "When to perform a {command}`flexget` run. See {command}`man 7 systemd.time` for the format.";
|
|
};
|
|
|
|
systemScheduler = mkOption {
|
|
default = true;
|
|
example = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc "When true, execute the runs via the flexget-runner.timer. If false, you have to specify the settings yourself in the YML file.";
|
|
};
|
|
|
|
config = mkOption {
|
|
default = "";
|
|
type = types.lines;
|
|
description = lib.mdDoc "The YAML configuration for FlexGet.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkg ];
|
|
|
|
systemd.services = {
|
|
flexget = {
|
|
description = "FlexGet Daemon";
|
|
path = [ pkg ];
|
|
serviceConfig = {
|
|
User = cfg.user;
|
|
Environment = "TZ=${config.time.timeZone}";
|
|
ExecStartPre = "${pkgs.coreutils}/bin/install -m644 ${ymlFile} ${configFile}";
|
|
ExecStart = "${pkg}/bin/flexget -c ${configFile} daemon start";
|
|
ExecStop = "${pkg}/bin/flexget -c ${configFile} daemon stop";
|
|
ExecReload = "${pkg}/bin/flexget -c ${configFile} daemon reload";
|
|
Restart = "on-failure";
|
|
PrivateTmp = true;
|
|
WorkingDirectory = toString cfg.homeDir;
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
|
|
flexget-runner = mkIf cfg.systemScheduler {
|
|
description = "FlexGet Runner";
|
|
after = [ "flexget.service" ];
|
|
wants = [ "flexget.service" ];
|
|
serviceConfig = {
|
|
User = cfg.user;
|
|
ExecStart = "${pkg}/bin/flexget -c ${configFile} execute";
|
|
PrivateTmp = true;
|
|
WorkingDirectory = toString cfg.homeDir;
|
|
};
|
|
};
|
|
};
|
|
|
|
systemd.timers.flexget-runner = mkIf cfg.systemScheduler {
|
|
description = "Run FlexGet every ${cfg.interval}";
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnBootSec = "5m";
|
|
OnUnitInactiveSec = cfg.interval;
|
|
Unit = "flexget-runner.service";
|
|
};
|
|
};
|
|
};
|
|
}
|