virtualization/amazon-init: enable option

This commit is contained in:
Matej Urbas 2021-02-07 21:00:00 +00:00
parent 4c9a74aa45
commit a6766bee7b

View File

@ -1,6 +1,10 @@
{ config, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.virtualisation.amazon-init;
script = '' script = ''
#!${pkgs.runtimeShell} -eu #!${pkgs.runtimeShell} -eu
@ -41,20 +45,33 @@ let
nixos-rebuild switch nixos-rebuild switch
''; '';
in { in {
systemd.services.amazon-init = {
inherit script;
description = "Reconfigure the system from EC2 userdata on startup";
wantedBy = [ "multi-user.target" ]; options.virtualisation.amazon-init = {
after = [ "multi-user.target" ]; enable = mkOption {
requires = [ "network-online.target" ]; default = true;
type = types.bool;
description = ''
Enable or disable the amazon-init service.
'';
};
};
restartIfChanged = false; config = mkIf cfg.enable {
unitConfig.X-StopOnRemoval = false; systemd.services.amazon-init = {
inherit script;
description = "Reconfigure the system from EC2 userdata on startup";
serviceConfig = { wantedBy = [ "multi-user.target" ];
Type = "oneshot"; after = [ "multi-user.target" ];
RemainAfterExit = true; requires = [ "network-online.target" ];
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
}; };
}; };
} }