Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

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

+21 -5
+2 -3
nixos/modules/virtualisation/amazon-init.nix
··· 45 45 inherit script; 46 46 description = "Reconfigure the system from EC2 userdata on startup"; 47 47 48 - wantedBy = [ "sshd.service" ]; 49 - before = [ "sshd.service" ]; 50 - after = [ "network-online.target" ]; 48 + wantedBy = [ "multi-user.target" ]; 49 + after = [ "multi-user.target" ]; 51 50 requires = [ "network-online.target" ]; 52 51 53 52 restartIfChanged = false;
+19 -2
nixos/tests/ec2.nix
··· 25 25 # access. Mostly copied from 26 26 # modules/profiles/installation-device.nix. 27 27 system.extraDependencies = 28 - [ pkgs.stdenv pkgs.busybox pkgs.perlPackages.ArchiveCpio 29 - pkgs.unionfs-fuse pkgs.mkinitcpio-nfs-utils 28 + with pkgs; [ 29 + stdenv busybox perlPackages.ArchiveCpio unionfs-fuse mkinitcpio-nfs-utils 30 + 31 + # These are used in the configure-from-userdata tests for EC2. Httpd and valgrind are requested 32 + # directly by the configuration we set, and libxslt.bin is used indirectly as a build dependency 33 + # of the derivation for dbus configuration files. 34 + apacheHttpd valgrind.doc libxslt.bin 30 35 ]; 31 36 } 32 37 ]; ··· 137 142 138 143 # ### http://nixos.org/channels/nixos-unstable nixos 139 144 userData = '' 145 + { pkgs, ... }: 146 + 140 147 { 141 148 imports = [ 142 149 <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ··· 146 153 environment.etc.testFile = { 147 154 text = "whoa"; 148 155 }; 156 + 157 + services.httpd = { 158 + enable = true; 159 + adminAddr = "test@example.org"; 160 + documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html"; 161 + }; 162 + networking.firewall.allowedTCPPorts = [ 80 ]; 149 163 } 150 164 ''; 151 165 script = '' 152 166 $machine->start; 153 167 $machine->waitForFile("/etc/testFile"); 154 168 $machine->succeed("cat /etc/testFile | grep -q 'whoa'"); 169 + 170 + $machine->waitForUnit("httpd.service"); 171 + $machine->succeed("curl http://localhost | grep Valgrind"); 155 172 ''; 156 173 }; 157 174 }