uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
16
nixos/tests/common/acme/client/default.nix
Normal file
16
nixos/tests/common/acme/client/default.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ lib, nodes, pkgs, ... }:
|
||||
let
|
||||
caCert = nodes.acme.config.test-support.acme.caCert;
|
||||
caDomain = nodes.acme.config.test-support.acme.caDomain;
|
||||
|
||||
in {
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
defaults = {
|
||||
server = "https://${caDomain}/dir";
|
||||
email = "hostmaster@example.test";
|
||||
};
|
||||
};
|
||||
|
||||
security.pki.certificateFiles = [ caCert ];
|
||||
}
|
||||
21
nixos/tests/common/acme/server/README.md
Normal file
21
nixos/tests/common/acme/server/README.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Fake Certificate Authority for ACME testing
|
||||
|
||||
This will set up a test node running [pebble](https://github.com/letsencrypt/pebble)
|
||||
to serve ACME certificate requests.
|
||||
|
||||
## "Snake oil" certs
|
||||
|
||||
The snake oil certs are hard coded into the repo for reasons explained [here](https://github.com/NixOS/nixpkgs/pull/91121#discussion_r505410235).
|
||||
The root of the issue is that Nix will hash the derivation based on the arguments
|
||||
to mkDerivation, not the output. [Minica](https://github.com/jsha/minica) will
|
||||
always generate a random certificate even if the arguments are unchanged. As a
|
||||
result, it's possible to end up in a situation where the cached and local
|
||||
generated certs mismatch and cause issues with testing.
|
||||
|
||||
To generate new certificates, run the following commands:
|
||||
|
||||
```bash
|
||||
nix-build generate-certs.nix
|
||||
cp result/* .
|
||||
rm result
|
||||
```
|
||||
19
nixos/tests/common/acme/server/acme.test.cert.pem
Normal file
19
nixos/tests/common/acme/server/acme.test.cert.pem
Normal file
|
|
@ -0,0 +1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Att+WG3gmV7RInLdFfPwbw
|
||||
bEHPCnx0uiV0nxLjd/aVT+RceVrFQVt4hR99jLoMlBitSKluZ1ljsrpIyroBhQT0
|
||||
pp/pVi6HJdijG0fsPrC325NEGAwcpotLUhczoeM/rffKJd54wLhDkfYxOyRZXivs
|
||||
-----END CERTIFICATE-----
|
||||
27
nixos/tests/common/acme/server/acme.test.key.pem
Normal file
27
nixos/tests/common/acme/server/acme.test.key.pem
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAo8XjMVUaljcaqQ5MFhfPuQgSwdyXEUbpSHz+5yPkE0h9Z4Xu
|
||||
5BJF1Oq7h5ggCtadVsIspiY6Jm6aWDOjlh4myzW5UNBNUG3OPEk50vmmHFeHpImH
|
||||
O/d8yb33QoF9VRcTZs4tuJYg7l9bSs4jNG72vYvv2YiGAcmjJcsmAZIfniCNXf/L
|
||||
jIm+Cxykn+Vo3UuzO1w5/iuofdgWO/aZxMezmXUivlL3ih4cNzCJei8WlB/lEnHr
|
||||
kcy3ogRmmynP5zcz7vmGIJX2ji6dhCa4Got5B7eZK76o2QglhQXqPatG0AOYH+Rf
|
||||
QfzKemqPG5om9MgJtwFtTOU1LoaiBw//jXKESQIDAQABAoIBADox/2FwVFo8ioS4
|
||||
R+Ex5OZjMAcjU6sX/516jTmlT05q2+UFerYgqB/YqXqtW/V9/brulN8VhmRRuRbO
|
||||
grq9TBu5o3hMDK0f18EkZB/MBnLbx594H033y6gEkPBZAyhRYtuNOEH3VwxdZhtW
|
||||
1Lu1EoiYSUqLcNMBy6+KWJ8GRaXyacMYBlj2lMHmyzkA/t1+2mwTGC3lT6zN0F5Y
|
||||
E5umXOxsn6Tb6q3KM9O5IvtmMMKpgj4HIHZLZ6j40nNgHwGRaAv4Sha/vx0DeBw3
|
||||
6VlNiTTPdShEkhESlM5/ocqTfI92VHJpM5gkqTYOWBi2aKIPfAopXoqoJdWl4pQ/
|
||||
NCFIu2ECgYEAzntNKIcQtf0ewe0/POo07SIFirvz6jVtYNMTzeQfL6CoEjYArJeu
|
||||
Vzc4wEQfA4ZFVerBb1/O6M449gI3zex1PH4AX0h8q8DSjrppK1Jt2TnpVh97k7Gg
|
||||
Tnat/M/yW3lWYkcMVJJ3AYurXLFTT1dYP0HvBwZN04yInrEcPNXKfmcCgYEAywyJ
|
||||
51d4AE94PrANathKqSI/gk8sP+L1gzylZCcUEAiGk/1r45iYB4HN2gvWbS+CvSdp
|
||||
F7ShlDWrTaNh2Bm1dgTjc4pWb4J+CPy/KN2sgLwIuM4+ZWIZmEDcio6khrM/gNqK
|
||||
aR7xUsvWsqU26O84woY/xR8IHjSNF7cFWE1H2c8CgYEAt6SSi2kVQ8dMg84uYE8t
|
||||
o3qO00U3OycpkOQqyQQLeKC62veMwfRl6swCfX4Y11mkcTXJtPTRYd2Ia8StPUkB
|
||||
PDwUuKoPt/JXUvoYb59wc7M+BIsbrdBdc2u6cw+/zfutCNuH6/AYSBeg4WAVaIuW
|
||||
wSwzG1xP+8cR+5IqOzEqWCECgYATweeVTCyQEyuHJghYMi2poXx+iIesu7/aAkex
|
||||
pB/Oo5W8xrb90XZRnK7UHbzCqRHWqAQQ23Gxgztk9ZXqui2vCzC6qGZauV7cLwPG
|
||||
zTMg36sVmHP314DYEM+k59ZYiQ6P0jQPoIQo407D2VGrfsOOIhQIcUmP7tsfyJ5L
|
||||
hlGMfwKBgGq4VNnnuX8I5kl03NpaKfG+M8jEHmVwtI9RkPTCCX9bMjeG0cDxqPTF
|
||||
TRkf3r8UWQTZ5QfAfAXYAOlZvmGhHjSembRbXMrMdi3rGsYRSrQL6n5NHnORUaMy
|
||||
FCWo4gyAnniry7tx9dVNgmHmbjEHuQnf8AC1r3dibRCjvJWUiQ8H
|
||||
-----END RSA PRIVATE KEY-----
|
||||
20
nixos/tests/common/acme/server/ca.cert.pem
Normal file
20
nixos/tests/common/acme/server/ca.cert.pem
Normal file
|
|
@ -0,0 +1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JfB0XqwCb1Vd0C3UCIS2
|
||||
NPKngRwNSzphIsbzfvxGDkdM1enuGl5CVyDhrwTMqGaJGDSOv6U5jKFxKRvigqTN
|
||||
Ls9lPmT5NXYETduWLBR3yUIdH6kZXrcozZ02B9vjOB2Cv4RMDc+9eM30CLIWpf1I
|
||||
097e7JkhzxFhfC/bMMt3P1FeQc+fwH91wdBmNi7tQw==
|
||||
-----END CERTIFICATE-----
|
||||
27
nixos/tests/common/acme/server/ca.key.pem
Normal file
27
nixos/tests/common/acme/server/ca.key.pem
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAqzU81SwyTirRmBi1PfBBHCyqbLVxwiwuhueCymxHFPNH5/gK
|
||||
1/KrD0h8oXV0JHGI6ulYfxAydU3LckUp7wI8MhuAGtWctUBXPyZ4zI784pgpFHPZ
|
||||
UPsJC8B0jPyhsEdXBo5rUPxDApWUwNDcLpSbFzClc23eWrF26v8iU0OVsNuR7XTY
|
||||
8EUF07we69yCnGPg7BA/QrxbwvaBv2YbWambsskXQpBVK67/FjVA5FkjfpTEesTM
|
||||
fL9OfNyDen9dSIV9G/rLyvfBvNQdnrMAXZM71cr/TLp2QTtCbiRvLHTOdNioVi5s
|
||||
wQtWW74FARfQbpg0aTBR+Awo+/qkNrWlnhsnOwIDAQABAoIBAA3ykVkgd5ysmlSU
|
||||
trcsCnHcJaojgff6l3PACoSpG4VWaGY6a8+54julgRm6MtMBONFCX0ZCsImj484U
|
||||
Wl0xRmwil2YYPuL5MeJgJPktMObY1IfpBCw3tz3w2M3fiuCMf0d2dMGtO1xLiUnH
|
||||
+hgFXTkfamsj6ThkOrbcQBSebeRxbKM5hqyCaQoieV+0IJnyxUVq/apib8N50VsH
|
||||
SHd4oqLUuEZgg6N70+l5DpzedJUb4nrwS/KhUHUBgnoPItYBCiGPmrwLk7fUhPs6
|
||||
kTDqJDtc/xW/JbjmzhWEpVvtumcC/OEKULss7HLdeQqwVBrRQkznb0M9AnSra3d0
|
||||
X11/Y4ECgYEA3FC8SquLPFb2lHK4+YbJ4Ac6QVWeYFEHiZ0Rj+CmONmjcAvOGLPE
|
||||
SblRLm3Nbrkxbm8FF6/AfXa/rviAKEVPs5xqGfSDw/3n1uInPcmShiBCLwM/jHH5
|
||||
NeVG+R5mTg5zyQ/pQMLWRcs+Ail+ZAnZuoGpW3Cdc8OtCUYFQ7XB6nsCgYEAxvBJ
|
||||
zFxcTtsDzWbMWXejugQiUqJcEbKWwEfkRbf3J2rAVO2+EFr7LxdRfN2VwPiTQcWc
|
||||
LnN2QN+ouOjqBMTh3qm5oQY+TLLHy86k9g1k0gXWkMRQgP2ZdfWH1HyrwjLUgLe1
|
||||
VezFN7N1azgy6xFkInAAvuA4loxElZNvkGBgekECgYA/Xw26ILvNIGqO6qzgQXAh
|
||||
+5I7JsiGheg4IjDiBMlrQtbrLMoceuD0H9UFGNplhel9DXwWgxxIOncKejpK2x0A
|
||||
2fX+/0FDh+4+9hA5ipiV8gN3iGSoHkSDxy5yC9d7jlapt+TtFt4Rd1OfxZWwatDw
|
||||
/8jaH3t6yAcmyrhK8KYVrwKBgAE5KwsBqmOlvyE9N5Z5QN189wUREIXfVkP6bTHs
|
||||
jq2EX4hmKdwJ4y+H8i1VY31bSfSGlY5HkXuWpH/2lrHO0CDBZG3UDwADvWzIaYVF
|
||||
0c/kz0v2mRQh+xaZmus4lQnNrDbaalgL666LAPbW0qFVaws3KxoBYPe0BxvwWyhF
|
||||
H3LBAoGBAKRRNsq2pWQ8Gqxc0rVoH0FlexU9U2ci3lsLmgEB0A/o/kQkSyAxaRM+
|
||||
VdKp3sWfO8o8lX5CVQslCNBSjDTNcat3Co4NEBLg6Xv1yKN/WN1GhusnchP9szsP
|
||||
oU47gC89QhUyWSd6vvr2z2NG9C3cACxe4dhDSHQcE4nHSldzCKv2
|
||||
-----END RSA PRIVATE KEY-----
|
||||
141
nixos/tests/common/acme/server/default.nix
Normal file
141
nixos/tests/common/acme/server/default.nix
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
# The certificate for the ACME service is exported as:
|
||||
#
|
||||
# config.test-support.acme.caCert
|
||||
#
|
||||
# This value can be used inside the configuration of other test nodes to inject
|
||||
# the test certificate into security.pki.certificateFiles or into package
|
||||
# overlays.
|
||||
#
|
||||
# Another value that's needed if you don't use a custom resolver (see below for
|
||||
# notes on that) is to add the acme node as a nameserver to every node
|
||||
# that needs to acquire certificates using ACME, because otherwise the API host
|
||||
# for acme.test can't be resolved.
|
||||
#
|
||||
# A configuration example of a full node setup using this would be this:
|
||||
#
|
||||
# {
|
||||
# acme = import ./common/acme/server;
|
||||
#
|
||||
# example = { nodes, ... }: {
|
||||
# networking.nameservers = [
|
||||
# nodes.acme.config.networking.primaryIPAddress
|
||||
# ];
|
||||
# security.pki.certificateFiles = [
|
||||
# nodes.acme.config.test-support.acme.caCert
|
||||
# ];
|
||||
# };
|
||||
# }
|
||||
#
|
||||
# By default, this module runs a local resolver, generated using resolver.nix
|
||||
# from the parent directory to automatically discover all zones in the network.
|
||||
#
|
||||
# If you do not want this and want to use your own resolver, you can just
|
||||
# override networking.nameservers like this:
|
||||
#
|
||||
# {
|
||||
# acme = { nodes, lib, ... }: {
|
||||
# imports = [ ./common/acme/server ];
|
||||
# networking.nameservers = lib.mkForce [
|
||||
# nodes.myresolver.config.networking.primaryIPAddress
|
||||
# ];
|
||||
# };
|
||||
#
|
||||
# myresolver = ...;
|
||||
# }
|
||||
#
|
||||
# Keep in mind, that currently only _one_ resolver is supported, if you have
|
||||
# more than one resolver in networking.nameservers only the first one will be
|
||||
# used.
|
||||
#
|
||||
# Also make sure that whenever you use a resolver from a different test node
|
||||
# that it has to be started _before_ the ACME service.
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
testCerts = import ./snakeoil-certs.nix;
|
||||
domain = testCerts.domain;
|
||||
|
||||
resolver = let
|
||||
message = "You need to define a resolver for the acme test module.";
|
||||
firstNS = lib.head config.networking.nameservers;
|
||||
in if config.networking.nameservers == [] then throw message else firstNS;
|
||||
|
||||
pebbleConf.pebble = {
|
||||
listenAddress = "0.0.0.0:443";
|
||||
managementListenAddress = "0.0.0.0:15000";
|
||||
# These certs and keys are used for the Web Front End (WFE)
|
||||
certificate = testCerts.${domain}.cert;
|
||||
privateKey = testCerts.${domain}.key;
|
||||
httpPort = 80;
|
||||
tlsPort = 443;
|
||||
ocspResponderURL = "http://${domain}:4002";
|
||||
strict = true;
|
||||
};
|
||||
|
||||
pebbleConfFile = pkgs.writeText "pebble.conf" (builtins.toJSON pebbleConf);
|
||||
|
||||
in {
|
||||
imports = [ ../../resolver.nix ];
|
||||
|
||||
options.test-support.acme = with lib; {
|
||||
caDomain = mkOption {
|
||||
type = types.str;
|
||||
readOnly = true;
|
||||
default = domain;
|
||||
description = ''
|
||||
A domain name to use with the <literal>nodes</literal> attribute to
|
||||
identify the CA server.
|
||||
'';
|
||||
};
|
||||
caCert = mkOption {
|
||||
type = types.path;
|
||||
readOnly = true;
|
||||
default = testCerts.ca.cert;
|
||||
description = ''
|
||||
A certificate file to use with the <literal>nodes</literal> attribute to
|
||||
inject the test CA certificate used in the ACME server into
|
||||
<option>security.pki.certificateFiles</option>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
test-support = {
|
||||
resolver.enable = let
|
||||
isLocalResolver = config.networking.nameservers == [ "127.0.0.1" ];
|
||||
in lib.mkOverride 900 isLocalResolver;
|
||||
};
|
||||
|
||||
# This has priority 140, because modules/testing/test-instrumentation.nix
|
||||
# already overrides this with priority 150.
|
||||
networking.nameservers = lib.mkOverride 140 [ "127.0.0.1" ];
|
||||
networking.firewall.allowedTCPPorts = [ 80 443 15000 4002 ];
|
||||
|
||||
networking.extraHosts = ''
|
||||
127.0.0.1 ${domain}
|
||||
${config.networking.primaryIPAddress} ${domain}
|
||||
'';
|
||||
|
||||
systemd.services = {
|
||||
pebble = {
|
||||
enable = true;
|
||||
description = "Pebble ACME server";
|
||||
wantedBy = [ "network.target" ];
|
||||
environment = {
|
||||
# We're not testing lego, we're just testing our configuration.
|
||||
# No need to sleep.
|
||||
PEBBLE_VA_NOSLEEP = "1";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
RuntimeDirectory = "pebble";
|
||||
WorkingDirectory = "/run/pebble";
|
||||
|
||||
# Required to bind on privileged ports.
|
||||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||
|
||||
ExecStart = "${pkgs.pebble}/bin/pebble -config ${pebbleConfFile}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
29
nixos/tests/common/acme/server/generate-certs.nix
Normal file
29
nixos/tests/common/acme/server/generate-certs.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Minica can provide a CA key and cert, plus a key
|
||||
# and cert for our fake CA server's Web Front End (WFE).
|
||||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
minica ? pkgs.minica,
|
||||
mkDerivation ? pkgs.stdenv.mkDerivation
|
||||
}:
|
||||
let
|
||||
conf = import ./snakeoil-certs.nix;
|
||||
domain = conf.domain;
|
||||
in mkDerivation {
|
||||
name = "test-certs";
|
||||
buildInputs = [ minica ];
|
||||
phases = [ "buildPhase" "installPhase" ];
|
||||
|
||||
buildPhase = ''
|
||||
minica \
|
||||
--ca-key ca.key.pem \
|
||||
--ca-cert ca.cert.pem \
|
||||
--domains ${domain}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mv ca.*.pem $out/
|
||||
mv ${domain}/key.pem $out/${domain}.key.pem
|
||||
mv ${domain}/cert.pem $out/${domain}.cert.pem
|
||||
'';
|
||||
}
|
||||
13
nixos/tests/common/acme/server/snakeoil-certs.nix
Normal file
13
nixos/tests/common/acme/server/snakeoil-certs.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
let
|
||||
domain = "acme.test";
|
||||
in {
|
||||
inherit domain;
|
||||
ca = {
|
||||
cert = ./ca.cert.pem;
|
||||
key = ./ca.key.pem;
|
||||
};
|
||||
"${domain}" = {
|
||||
cert = ./. + "/${domain}.cert.pem";
|
||||
key = ./. + "/${domain}.key.pem";
|
||||
};
|
||||
}
|
||||
68
nixos/tests/common/auto.nix
Normal file
68
nixos/tests/common/auto.nix
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
dmcfg = config.services.xserver.displayManager;
|
||||
cfg = config.test-support.displayManager.auto;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
test-support.displayManager.auto = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable the fake "auto" display manager, which
|
||||
automatically logs in the user specified in the
|
||||
<option>user</option> option. This is mostly useful for
|
||||
automated tests.
|
||||
'';
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "root";
|
||||
description = "The user account to login automatically.";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
services.xserver.displayManager = {
|
||||
lightdm.enable = true;
|
||||
autoLogin = {
|
||||
enable = true;
|
||||
user = cfg.user;
|
||||
};
|
||||
};
|
||||
|
||||
# lightdm by default doesn't allow auto login for root, which is
|
||||
# required by some nixos tests. Override it here.
|
||||
security.pam.services.lightdm-autologin.text = lib.mkForce ''
|
||||
auth requisite pam_nologin.so
|
||||
auth required pam_succeed_if.so quiet
|
||||
auth required pam_permit.so
|
||||
|
||||
account include lightdm
|
||||
|
||||
password include lightdm
|
||||
|
||||
session include lightdm
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
66
nixos/tests/common/ec2.nix
Normal file
66
nixos/tests/common/ec2.nix
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{ pkgs, makeTest }:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
{
|
||||
makeEc2Test = { name, image, userData, script, hostname ? "ec2-instance", sshPublicKey ? null, meta ? {} }:
|
||||
let
|
||||
metaData = pkgs.stdenv.mkDerivation {
|
||||
name = "metadata";
|
||||
buildCommand = ''
|
||||
mkdir -p $out/1.0/meta-data
|
||||
ln -s ${pkgs.writeText "userData" userData} $out/1.0/user-data
|
||||
echo "${hostname}" > $out/1.0/meta-data/hostname
|
||||
echo "(unknown)" > $out/1.0/meta-data/ami-manifest-path
|
||||
'' + optionalString (sshPublicKey != null) ''
|
||||
mkdir -p $out/1.0/meta-data/public-keys/0
|
||||
ln -s ${pkgs.writeText "sshPublicKey" sshPublicKey} $out/1.0/meta-data/public-keys/0/openssh-key
|
||||
'';
|
||||
};
|
||||
in makeTest {
|
||||
name = "ec2-" + name;
|
||||
nodes = {};
|
||||
testScript = ''
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
image_dir = os.path.join(
|
||||
os.environ.get("TMPDIR", tempfile.gettempdir()), "tmp", "vm-state-machine"
|
||||
)
|
||||
os.makedirs(image_dir, mode=0o700, exist_ok=True)
|
||||
disk_image = os.path.join(image_dir, "machine.qcow2")
|
||||
subprocess.check_call(
|
||||
[
|
||||
"qemu-img",
|
||||
"create",
|
||||
"-f",
|
||||
"qcow2",
|
||||
"-o",
|
||||
"backing_file=${image}",
|
||||
disk_image,
|
||||
]
|
||||
)
|
||||
subprocess.check_call(["qemu-img", "resize", disk_image, "10G"])
|
||||
|
||||
# Note: we use net=169.0.0.0/8 rather than
|
||||
# net=169.254.0.0/16 to prevent dhcpcd from getting horribly
|
||||
# confused. (It would get a DHCP lease in the 169.254.*
|
||||
# range, which it would then configure and prompty delete
|
||||
# again when it deletes link-local addresses.) Ideally we'd
|
||||
# turn off the DHCP server, but qemu does not have an option
|
||||
# to do that.
|
||||
start_command = (
|
||||
"qemu-kvm -m 1024"
|
||||
+ " -device virtio-net-pci,netdev=vlan0"
|
||||
+ " -netdev 'user,id=vlan0,net=169.0.0.0/8,guestfwd=tcp:169.254.169.254:80-cmd:${pkgs.micro-httpd}/bin/micro_httpd ${metaData}'"
|
||||
+ f" -drive file={disk_image},if=virtio,werror=report"
|
||||
+ " $QEMU_OPTS"
|
||||
)
|
||||
|
||||
machine = create_machine({"startCommand": start_command})
|
||||
'' + script;
|
||||
|
||||
inherit meta;
|
||||
};
|
||||
}
|
||||
24
nixos/tests/common/lxd/config.yaml
Normal file
24
nixos/tests/common/lxd/config.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
storage_pools:
|
||||
- name: default
|
||||
driver: dir
|
||||
config:
|
||||
source: /var/lxd-pool
|
||||
|
||||
networks:
|
||||
- name: lxdbr0
|
||||
type: bridge
|
||||
config:
|
||||
ipv4.address: auto
|
||||
ipv6.address: none
|
||||
|
||||
profiles:
|
||||
- name: default
|
||||
devices:
|
||||
eth0:
|
||||
name: eth0
|
||||
network: lxdbr0
|
||||
type: nic
|
||||
root:
|
||||
path: /
|
||||
pool: default
|
||||
type: disk
|
||||
141
nixos/tests/common/resolver.nix
Normal file
141
nixos/tests/common/resolver.nix
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
# This module automatically discovers zones in BIND and NSD NixOS
|
||||
# configurations and creates zones for all definitions of networking.extraHosts
|
||||
# (except those that point to 127.0.0.1 or ::1) within the current test network
|
||||
# and delegates these zones using a fake root zone served by a BIND recursive
|
||||
# name server.
|
||||
{ config, nodes, pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
options.test-support.resolver.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
internal = true;
|
||||
description = ''
|
||||
Whether to enable the resolver that automatically discovers zone in the
|
||||
test network.
|
||||
|
||||
This option is <literal>true</literal> by default, because the module
|
||||
defining this option needs to be explicitly imported.
|
||||
|
||||
The reason this option exists is for the
|
||||
<filename>nixos/tests/common/acme/server</filename> module, which
|
||||
needs that option to disable the resolver once the user has set its own
|
||||
resolver.
|
||||
'';
|
||||
};
|
||||
|
||||
config = lib.mkIf config.test-support.resolver.enable {
|
||||
networking.firewall.enable = false;
|
||||
services.bind.enable = true;
|
||||
services.bind.cacheNetworks = lib.mkForce [ "any" ];
|
||||
services.bind.forwarders = lib.mkForce [];
|
||||
services.bind.zones = lib.singleton {
|
||||
name = ".";
|
||||
file = let
|
||||
addDot = zone: zone + lib.optionalString (!lib.hasSuffix "." zone) ".";
|
||||
mkNsdZoneNames = zones: map addDot (lib.attrNames zones);
|
||||
mkBindZoneNames = zones: map (zone: addDot zone.name) zones;
|
||||
getZones = cfg: mkNsdZoneNames cfg.services.nsd.zones
|
||||
++ mkBindZoneNames cfg.services.bind.zones;
|
||||
|
||||
getZonesForNode = attrs: {
|
||||
ip = attrs.config.networking.primaryIPAddress;
|
||||
zones = lib.filter (zone: zone != ".") (getZones attrs.config);
|
||||
};
|
||||
|
||||
zoneInfo = lib.mapAttrsToList (lib.const getZonesForNode) nodes;
|
||||
|
||||
# A and AAAA resource records for all the definitions of
|
||||
# networking.extraHosts except those for 127.0.0.1 or ::1.
|
||||
#
|
||||
# The result is an attribute set with keys being the host name and the
|
||||
# values are either { ipv4 = ADDR; } or { ipv6 = ADDR; } where ADDR is
|
||||
# the IP address for the corresponding key.
|
||||
recordsFromExtraHosts = let
|
||||
getHostsForNode = lib.const (n: n.config.networking.extraHosts);
|
||||
allHostsList = lib.mapAttrsToList getHostsForNode nodes;
|
||||
allHosts = lib.concatStringsSep "\n" allHostsList;
|
||||
|
||||
reIp = "[a-fA-F0-9.:]+";
|
||||
reHost = "[a-zA-Z0-9.-]+";
|
||||
|
||||
matchAliases = str: let
|
||||
matched = builtins.match "[ \t]+(${reHost})(.*)" str;
|
||||
continue = lib.singleton (lib.head matched)
|
||||
++ matchAliases (lib.last matched);
|
||||
in if matched == null then [] else continue;
|
||||
|
||||
matchLine = str: let
|
||||
result = builtins.match "[ \t]*(${reIp})[ \t]+(${reHost})(.*)" str;
|
||||
in if result == null then null else {
|
||||
ipAddr = lib.head result;
|
||||
hosts = lib.singleton (lib.elemAt result 1)
|
||||
++ matchAliases (lib.last result);
|
||||
};
|
||||
|
||||
skipLine = str: let
|
||||
rest = builtins.match "[^\n]*\n(.*)" str;
|
||||
in if rest == null then "" else lib.head rest;
|
||||
|
||||
getEntries = str: acc: let
|
||||
result = matchLine str;
|
||||
next = getEntries (skipLine str);
|
||||
newEntry = acc ++ lib.singleton result;
|
||||
continue = if result == null then next acc else next newEntry;
|
||||
in if str == "" then acc else continue;
|
||||
|
||||
isIPv6 = str: builtins.match ".*:.*" str != null;
|
||||
loopbackIps = [ "127.0.0.1" "::1" ];
|
||||
filterLoopback = lib.filter (e: !lib.elem e.ipAddr loopbackIps);
|
||||
|
||||
allEntries = lib.concatMap (entry: map (host: {
|
||||
inherit host;
|
||||
${if isIPv6 entry.ipAddr then "ipv6" else "ipv4"} = entry.ipAddr;
|
||||
}) entry.hosts) (filterLoopback (getEntries (allHosts + "\n") []));
|
||||
|
||||
mkRecords = entry: let
|
||||
records = lib.optional (entry ? ipv6) "AAAA ${entry.ipv6}"
|
||||
++ lib.optional (entry ? ipv4) "A ${entry.ipv4}";
|
||||
mkRecord = typeAndData: "${entry.host}. IN ${typeAndData}";
|
||||
in lib.concatMapStringsSep "\n" mkRecord records;
|
||||
|
||||
in lib.concatMapStringsSep "\n" mkRecords allEntries;
|
||||
|
||||
# All of the zones that are subdomains of existing zones.
|
||||
# For example if there is only "example.com" the following zones would
|
||||
# be 'subZones':
|
||||
#
|
||||
# * foo.example.com.
|
||||
# * bar.example.com.
|
||||
#
|
||||
# While the following would *not* be 'subZones':
|
||||
#
|
||||
# * example.com.
|
||||
# * com.
|
||||
#
|
||||
subZones = let
|
||||
allZones = lib.concatMap (zi: zi.zones) zoneInfo;
|
||||
isSubZoneOf = z1: z2: lib.hasSuffix z2 z1 && z1 != z2;
|
||||
in lib.filter (z: lib.any (isSubZoneOf z) allZones) allZones;
|
||||
|
||||
# All the zones without 'subZones'.
|
||||
filteredZoneInfo = map (zi: zi // {
|
||||
zones = lib.filter (x: !lib.elem x subZones) zi.zones;
|
||||
}) zoneInfo;
|
||||
|
||||
in pkgs.writeText "fake-root.zone" ''
|
||||
$TTL 3600
|
||||
. IN SOA ns.fakedns. admin.fakedns. ( 1 3h 1h 1w 1d )
|
||||
ns.fakedns. IN A ${config.networking.primaryIPAddress}
|
||||
. IN NS ns.fakedns.
|
||||
${lib.concatImapStrings (num: { ip, zones }: ''
|
||||
ns${toString num}.fakedns. IN A ${ip}
|
||||
${lib.concatMapStrings (zone: ''
|
||||
${zone} IN NS ns${toString num}.fakedns.
|
||||
'') zones}
|
||||
'') (lib.filter (zi: zi.zones != []) filteredZoneInfo)}
|
||||
${recordsFromExtraHosts}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
15
nixos/tests/common/user-account.nix
Normal file
15
nixos/tests/common/user-account.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{ ... }:
|
||||
|
||||
{ users.users.alice =
|
||||
{ isNormalUser = true;
|
||||
description = "Alice Foobar";
|
||||
password = "foobar";
|
||||
uid = 1000;
|
||||
};
|
||||
|
||||
users.users.bob =
|
||||
{ isNormalUser = true;
|
||||
description = "Bob Foobar";
|
||||
password = "foobar";
|
||||
};
|
||||
}
|
||||
13
nixos/tests/common/wayland-cage.nix
Normal file
13
nixos/tests/common/wayland-cage.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [ ./user-account.nix ];
|
||||
services.cage = {
|
||||
enable = true;
|
||||
user = "alice";
|
||||
};
|
||||
|
||||
virtualisation = {
|
||||
qemu.options = [ "-vga virtio" ];
|
||||
};
|
||||
}
|
||||
27
nixos/tests/common/webroot/news-rss.xml
Normal file
27
nixos/tests/common/webroot/news-rss.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" version="2.0">
|
||||
<channel>
|
||||
<title>NixOS News</title><link>https://nixos.org</link>
|
||||
<description>News for NixOS, the purely functional Linux distribution.</description>
|
||||
<image>
|
||||
<title>NixOS</title>
|
||||
<url>https://nixos.org/logo/nixos-logo-only-hires.png</url><link>https://nixos.org/</link>
|
||||
</image>
|
||||
<item>
|
||||
<title>NixOS 18.09 released</title><link>https://nixos.org/news.html</link>
|
||||
<description>
|
||||
<a href="https://github.com/NixOS/nixos-artwork/blob/master/releases/18.09-jellyfish/jellyfish.png">
|
||||
<img class="inline" src="logo/nixos-logo-18.09-jellyfish-lores.png" alt="18.09 Jellyfish logo" with="100" height="87"/>
|
||||
</a>
|
||||
NixOS 18.09 “Jellyfish” has been released, the tenth stable release branch.
|
||||
See the <a href="/nixos/manual/release-notes.html#sec-release-18.09">release notes</a>
|
||||
for details. You can get NixOS 18.09 ISOs and VirtualBox appliances
|
||||
from the <a href="nixos/download.html">download page</a>.
|
||||
For information on how to upgrade from older release branches
|
||||
to 18.09, check out the
|
||||
<a href="/nixos/manual/index.html#sec-upgrading">manual section on upgrading</a>.
|
||||
</description>
|
||||
<pubDate>Sat Oct 06 2018 00:00:00 GMT</pubDate>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
17
nixos/tests/common/x11.nix
Normal file
17
nixos/tests/common/x11.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./auto.nix
|
||||
];
|
||||
|
||||
services.xserver.enable = true;
|
||||
|
||||
# Automatically log in.
|
||||
test-support.displayManager.auto.enable = true;
|
||||
|
||||
# Use IceWM as the window manager.
|
||||
# Don't use a desktop manager.
|
||||
services.xserver.displayManager.defaultSession = lib.mkDefault "none+icewm";
|
||||
services.xserver.windowManager.icewm.enable = true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue