mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 21:25:30 +03:00
amazon-init.service: fix starting services at startup
We now make it happen later in the boot process so that multi-user has already activated, so as to not run afoul of the logic in switch-to-configuration.pl. It's not my favorite solution, but at least it works. Also added a check to the VM test to catch the failure so we don't break in future. Fixes #23121
This commit is contained in:
parent
bccac381b2
commit
6018cf4a69
2 changed files with 21 additions and 5 deletions
|
@ -45,9 +45,8 @@ in {
|
||||||
inherit script;
|
inherit script;
|
||||||
description = "Reconfigure the system from EC2 userdata on startup";
|
description = "Reconfigure the system from EC2 userdata on startup";
|
||||||
|
|
||||||
wantedBy = [ "sshd.service" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
before = [ "sshd.service" ];
|
after = [ "multi-user.target" ];
|
||||||
after = [ "network-online.target" ];
|
|
||||||
requires = [ "network-online.target" ];
|
requires = [ "network-online.target" ];
|
||||||
|
|
||||||
restartIfChanged = false;
|
restartIfChanged = false;
|
||||||
|
|
|
@ -25,8 +25,13 @@ let
|
||||||
# access. Mostly copied from
|
# access. Mostly copied from
|
||||||
# modules/profiles/installation-device.nix.
|
# modules/profiles/installation-device.nix.
|
||||||
system.extraDependencies =
|
system.extraDependencies =
|
||||||
[ pkgs.stdenv pkgs.busybox pkgs.perlPackages.ArchiveCpio
|
with pkgs; [
|
||||||
pkgs.unionfs-fuse pkgs.mkinitcpio-nfs-utils
|
stdenv busybox perlPackages.ArchiveCpio unionfs-fuse mkinitcpio-nfs-utils
|
||||||
|
|
||||||
|
# These are used in the configure-from-userdata tests for EC2. Httpd and valgrind are requested
|
||||||
|
# directly by the configuration we set, and libxslt.bin is used indirectly as a build dependency
|
||||||
|
# of the derivation for dbus configuration files.
|
||||||
|
apacheHttpd valgrind.doc libxslt.bin
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -137,6 +142,8 @@ in {
|
||||||
|
|
||||||
# ### http://nixos.org/channels/nixos-unstable nixos
|
# ### http://nixos.org/channels/nixos-unstable nixos
|
||||||
userData = ''
|
userData = ''
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
<nixpkgs/nixos/modules/virtualisation/amazon-image.nix>
|
<nixpkgs/nixos/modules/virtualisation/amazon-image.nix>
|
||||||
|
@ -146,12 +153,22 @@ in {
|
||||||
environment.etc.testFile = {
|
environment.etc.testFile = {
|
||||||
text = "whoa";
|
text = "whoa";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.httpd = {
|
||||||
|
enable = true;
|
||||||
|
adminAddr = "test@example.org";
|
||||||
|
documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
|
||||||
|
};
|
||||||
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
script = ''
|
script = ''
|
||||||
$machine->start;
|
$machine->start;
|
||||||
$machine->waitForFile("/etc/testFile");
|
$machine->waitForFile("/etc/testFile");
|
||||||
$machine->succeed("cat /etc/testFile | grep -q 'whoa'");
|
$machine->succeed("cat /etc/testFile | grep -q 'whoa'");
|
||||||
|
|
||||||
|
$machine->waitForUnit("httpd.service");
|
||||||
|
$machine->succeed("curl http://localhost | grep Valgrind");
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue