summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorLassulus <github@lassul.us>2021-03-07 18:39:05 +0100
committerGitHub <noreply@github.com>2021-03-07 18:39:05 +0100
commitba6d848c403cc709375c4603f597d8ac44582cdd (patch)
tree925e3c1fd494c647858ccac8d6dc330b4c6a5452 /nixos
parent3e2ac5624030185b2f5f6181c7f1a084b92fac67 (diff)
parenta6766bee7bee10903232660dd9f200da9cdc1210 (diff)
Merge pull request #112332 from urbas/amazon-init-options
virtualization/amazon-init: enable option
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/amazon-init.nix41
1 files changed, 29 insertions, 12 deletions
diff --git a/nixos/modules/virtualisation/amazon-init.nix b/nixos/modules/virtualisation/amazon-init.nix
index c5470b7af09b..be83607c0af7 100644
--- a/nixos/modules/virtualisation/amazon-init.nix
+++ b/nixos/modules/virtualisation/amazon-init.nix
@@ -1,6 +1,10 @@
-{ config, pkgs, ... }:
+{ config, lib, pkgs, ... }:
+
+with lib;
let
+ cfg = config.virtualisation.amazon-init;
+
script = ''
#!${pkgs.runtimeShell} -eu
@@ -41,20 +45,33 @@ let
nixos-rebuild switch
'';
in {
- systemd.services.amazon-init = {
- inherit script;
- description = "Reconfigure the system from EC2 userdata on startup";
- wantedBy = [ "multi-user.target" ];
- after = [ "multi-user.target" ];
- requires = [ "network-online.target" ];
+ options.virtualisation.amazon-init = {
+ enable = mkOption {
+ default = true;
+ type = types.bool;
+ description = ''
+ Enable or disable the amazon-init service.
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ systemd.services.amazon-init = {
+ inherit script;
+ description = "Reconfigure the system from EC2 userdata on startup";
+
+ wantedBy = [ "multi-user.target" ];
+ after = [ "multi-user.target" ];
+ requires = [ "network-online.target" ];
- restartIfChanged = false;
- unitConfig.X-StopOnRemoval = false;
+ restartIfChanged = false;
+ unitConfig.X-StopOnRemoval = false;
- serviceConfig = {
- Type = "oneshot";
- RemainAfterExit = true;
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = true;
+ };
};
};
}