forked from mirrors/nixpkgs
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.
68 lines
1.7 KiB
Nix
68 lines
1.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) escapeShellArgs mkEnableOption mkIf mkOption types;
|
|
|
|
cfg = config.services.mimir;
|
|
|
|
settingsFormat = pkgs.formats.yaml {};
|
|
in {
|
|
options.services.mimir = {
|
|
enable = mkEnableOption "mimir";
|
|
|
|
configuration = mkOption {
|
|
type = (pkgs.formats.json {}).type;
|
|
default = {};
|
|
description = lib.mdDoc ''
|
|
Specify the configuration for Mimir in Nix.
|
|
'';
|
|
};
|
|
|
|
configFile = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = lib.mdDoc ''
|
|
Specify a configuration file that Mimir should use.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
# for mimirtool
|
|
environment.systemPackages = [ pkgs.mimir ];
|
|
|
|
assertions = [{
|
|
assertion = (
|
|
(cfg.configuration == {} -> cfg.configFile != null) &&
|
|
(cfg.configFile != null -> cfg.configuration == {})
|
|
);
|
|
message = ''
|
|
Please specify either
|
|
'services.mimir.configuration' or
|
|
'services.mimir.configFile'.
|
|
'';
|
|
}];
|
|
|
|
systemd.services.mimir = {
|
|
description = "mimir Service Daemon";
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = let
|
|
conf = if cfg.configFile == null
|
|
then settingsFormat.generate "config.yaml" cfg.configuration
|
|
else cfg.configFile;
|
|
in
|
|
{
|
|
ExecStart = "${pkgs.mimir}/bin/mimir --config.file=${conf}";
|
|
DynamicUser = true;
|
|
Restart = "always";
|
|
ProtectSystem = "full";
|
|
DevicePolicy = "closed";
|
|
NoNewPrivileges = true;
|
|
WorkingDirectory = "/var/lib/mimir";
|
|
StateDirectory = "mimir";
|
|
};
|
|
};
|
|
};
|
|
}
|