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.
73 lines
2.2 KiB
Nix
73 lines
2.2 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
let
|
|
cfg = config.services.ssm-agent;
|
|
|
|
# The SSM agent doesn't pay attention to our /etc/os-release yet, and the lsb-release tool
|
|
# in nixpkgs doesn't seem to work properly on NixOS, so let's just fake the two fields SSM
|
|
# looks for. See https://github.com/aws/amazon-ssm-agent/issues/38 for upstream fix.
|
|
fake-lsb-release = pkgs.writeScriptBin "lsb_release" ''
|
|
#!${pkgs.runtimeShell}
|
|
|
|
case "$1" in
|
|
-i) echo "nixos";;
|
|
-r) echo "${config.system.nixos.version}";;
|
|
esac
|
|
'';
|
|
in {
|
|
options.services.ssm-agent = {
|
|
enable = mkEnableOption "AWS SSM agent";
|
|
|
|
package = mkOption {
|
|
type = types.path;
|
|
description = lib.mdDoc "The SSM agent package to use";
|
|
default = pkgs.ssm-agent.override { overrideEtc = false; };
|
|
defaultText = literalExpression "pkgs.ssm-agent.override { overrideEtc = false; }";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.ssm-agent = {
|
|
inherit (cfg.package.meta) description;
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ fake-lsb-release pkgs.coreutils ];
|
|
serviceConfig = {
|
|
ExecStart = "${cfg.package}/bin/amazon-ssm-agent";
|
|
KillMode = "process";
|
|
# We want this restating pretty frequently. It could be our only means
|
|
# of accessing the instance.
|
|
Restart = "always";
|
|
RestartSec = "1min";
|
|
};
|
|
};
|
|
|
|
# Add user that Session Manager needs, and give it sudo.
|
|
# This is consistent with Amazon Linux 2 images.
|
|
security.sudo.extraRules = [
|
|
{
|
|
users = [ "ssm-user" ];
|
|
commands = [
|
|
{
|
|
command = "ALL";
|
|
options = [ "NOPASSWD" ];
|
|
}
|
|
];
|
|
}
|
|
];
|
|
# On Amazon Linux 2 images, the ssm-user user is pretty much a
|
|
# normal user with its own group. We do the same.
|
|
users.groups.ssm-user = {};
|
|
users.users.ssm-user = {
|
|
isNormalUser = true;
|
|
group = "ssm-user";
|
|
};
|
|
|
|
environment.etc."amazon/ssm/seelog.xml".source = "${cfg.package}/seelog.xml.template";
|
|
|
|
environment.etc."amazon/ssm/amazon-ssm-agent.json".source = "${cfg.package}/etc/amazon/ssm/amazon-ssm-agent.json.template";
|
|
|
|
};
|
|
}
|