From f34483be5ee2418a563545a56743b7b59c549935 Mon Sep 17 00:00:00 2001
From: Sizhe Zhao
Date: Sat, 24 May 2025 23:40:23 +0800
Subject: [PATCH] nixosTests: handleTest -> runTest, batch 1
Reference: https://github.com/NixOS/nixpkgs/issues/386873
---
nixos/tests/all-tests.nix | 1080 ++++++++---------
nixos/tests/ax25.nix | 225 ++--
nixos/tests/benchexec.nix | 118 +-
nixos/tests/bitcoind.nix | 100 +-
nixos/tests/bittorrent.nix | 336 +++--
nixos/tests/blockbook-frontend.nix | 52 +-
nixos/tests/boot-stage1.nix | 348 +++---
nixos/tests/boot-stage2.nix | 128 +-
nixos/tests/borgbackup.nix | 488 ++++----
nixos/tests/borgmatic.nix | 48 +-
nixos/tests/bpftune.nix | 38 +-
nixos/tests/breitbandmessung.nix | 70 +-
nixos/tests/brscan5.nix | 80 +-
nixos/tests/btrbk-doas.nix | 214 ++--
nixos/tests/btrbk-no-timer.nix | 66 +-
nixos/tests/btrbk-section-order.nix | 90 +-
nixos/tests/btrbk.nix | 200 ++-
nixos/tests/budgie.nix | 174 ++-
nixos/tests/buildkite-agents.nix | 50 +-
nixos/tests/c2fmzq.nix | 148 ++-
nixos/tests/cage.nix | 70 +-
nixos/tests/cagebreak.nix | 130 +-
nixos/tests/canaille.nix | 108 +-
nixos/tests/castopod.nix | 436 ++++---
nixos/tests/charliecloud.nix | 82 +-
nixos/tests/cinnamon-wayland.nix | 136 +--
nixos/tests/cinnamon.nix | 194 ++-
nixos/tests/cjdns.nix | 168 ++-
nixos/tests/clickhouse.nix | 62 +-
nixos/tests/cloudlog.nix | 38 +-
nixos/tests/cockpit.nix | 298 +++--
nixos/tests/code-server.nix | 42 +-
nixos/tests/coder.nix | 40 +-
nixos/tests/collectd.nix | 68 +-
nixos/tests/commafeed.nix | 32 +-
nixos/tests/connman.nix | 150 ++-
nixos/tests/consul-template.nix | 72 +-
nixos/tests/consul.nix | 438 ++++---
nixos/tests/containers-bridge.nix | 186 ++-
nixos/tests/containers-custom-pkgs.nix | 86 +-
nixos/tests/containers-ephemeral.nix | 90 +-
nixos/tests/containers-extra_veth.nix | 196 ++-
nixos/tests/containers-hosts.nix | 92 +-
nixos/tests/containers-imperative.nix | 386 +++---
nixos/tests/containers-ip.nix | 108 +-
nixos/tests/containers-macvlans.nix | 156 ++-
nixos/tests/containers-names.nix | 80 +-
nixos/tests/containers-nested.nix | 58 +-
.../tests/containers-physical_interfaces.nix | 248 ++--
nixos/tests/containers-portforward.nix | 108 +-
nixos/tests/containers-reloadable.nix | 100 +-
.../tests/containers-require-bind-mounts.nix | 64 +-
nixos/tests/containers-restart_networking.nix | 216 ++--
nixos/tests/containers-tmpfs.nix | 152 ++-
nixos/tests/containers-unified-hierarchy.nix | 40 +-
nixos/tests/convos.nix | 46 +-
nixos/tests/coturn.nix | 62 +-
nixos/tests/couchdb.nix | 88 +-
nixos/tests/crabfit.nix | 48 +-
nixos/tests/croc.nix | 100 +-
nixos/tests/curl-impersonate.nix | 328 +++--
nixos/tests/dae.nix | 60 +-
nixos/tests/db-rest.nix | 224 ++--
nixos/tests/dconf.nix | 78 +-
nixos/tests/ddns-updater.nix | 44 +-
nixos/tests/deconz.nix | 64 +-
nixos/tests/deepin.nix | 90 +-
nixos/tests/deluge.nix | 116 +-
nixos/tests/dependency-track.nix | 126 +-
nixos/tests/devpi-server.nix | 74 +-
nixos/tests/dex-oidc.nix | 146 ++-
nixos/tests/disable-installer-tools.nix | 58 +-
nixos/tests/discourse.nix | 400 +++---
nixos/tests/documize.nix | 114 +-
nixos/tests/doh-proxy-rust.nix | 84 +-
nixos/tests/domination.nix | 58 +-
nixos/tests/drbd-driver.nix | 40 +-
nixos/tests/drbd.nix | 152 ++-
nixos/tests/dublin-traceroute.nix | 130 +-
nixos/tests/ecryptfs.nix | 134 +-
nixos/tests/endlessh-go.nix | 118 +-
nixos/tests/endlessh.nix | 86 +-
nixos/tests/engelsystem.nix | 84 +-
nixos/tests/enlightenment.nix | 172 ++-
nixos/tests/env.nix | 88 +-
nixos/tests/envfs.nix | 74 +-
nixos/tests/ergo.nix | 40 +-
nixos/tests/ergochat.nix | 174 ++-
nixos/tests/eris-server.nix | 50 +-
nixos/tests/esphome.nix | 72 +-
nixos/tests/etebase-server.nix | 86 +-
nixos/tests/etesync-dav.nix | 48 +-
nixos/tests/fakeroute.nix | 48 +-
nixos/tests/fanout.nix | 54 +-
nixos/tests/fenics.nix | 90 +-
nixos/tests/ferm.nix | 178 ++-
nixos/tests/filesender.nix | 274 +++--
nixos/tests/firefoxpwa.nix | 64 +-
nixos/tests/firejail.nix | 164 ++-
nixos/tests/firezone/firezone.nix | 604 +++++----
nixos/tests/flaresolverr.nix | 36 +-
nixos/tests/flood.nix | 56 +-
nixos/tests/fluentd.nix | 98 +-
nixos/tests/fluidd.nix | 36 +-
nixos/tests/fontconfig-default-fonts.nix | 62 +-
nixos/tests/freeswitch.nix | 64 +-
nixos/tests/frp.nix | 158 ++-
nixos/tests/frr.nix | 204 ++--
nixos/tests/fscrypt.nix | 84 +-
nixos/tests/ft2-clone.nix | 54 +-
nixos/tests/gancio.nix | 144 ++-
nixos/tests/geth.nix | 122 +-
nixos/tests/ghostunnel.nix | 194 ++-
nixos/tests/gitdaemon.nix | 132 +-
nixos/tests/gitolite-fcgiwrap.nix | 154 ++-
nixos/tests/gitolite.nix | 242 ++--
nixos/tests/glusterfs.nix | 126 +-
nixos/tests/gnome-extensions.nix | 280 +++--
nixos/tests/gnome-flashback.nix | 104 +-
nixos/tests/gnome-xorg.nix | 194 ++-
nixos/tests/gns3-server.nix | 104 +-
nixos/tests/gnupg.nix | 206 ++--
nixos/tests/goatcounter.nix | 48 +-
nixos/tests/gobgpd.nix | 162 ++-
nixos/tests/gocd-agent.nix | 76 +-
nixos/tests/gocd-server.nix | 44 +-
nixos/tests/gollum.nix | 36 +-
nixos/tests/gonic.nix | 52 +-
nixos/tests/gopro-tool.nix | 64 +-
nixos/tests/goss.nix | 80 +-
nixos/tests/gotenberg.nix | 36 +-
nixos/tests/gotify-server.nix | 88 +-
nixos/tests/graphite.nix | 70 +-
nixos/tests/graylog.nix | 262 ++--
nixos/tests/greetd-no-shadow.nix | 90 +-
nixos/tests/grub.nix | 106 +-
nixos/tests/guacamole-server.nix | 40 +-
nixos/tests/gvisor.nix | 80 +-
nixos/tests/hardened.nix | 176 ++-
nixos/tests/haste-server.nix | 44 +-
nixos/tests/headscale.nix | 170 ++-
nixos/tests/hedgedoc.nix | 178 ++-
nixos/tests/herbstluftwm.nix | 74 +-
nixos/tests/hledger-web.nix | 100 +-
nixos/tests/hockeypuck.nix | 120 +-
nixos/tests/homebox.nix | 76 +-
nixos/tests/hound.nix | 108 +-
nixos/tests/i3wm.nix | 100 +-
nixos/tests/ifm.nix | 62 +-
nixos/tests/iftop.nix | 54 +-
nixos/tests/incron.nix | 82 +-
nixos/tests/influxdb.nix | 68 +-
nixos/tests/influxdb2.nix | 410 ++++---
nixos/tests/initrd-luks-empty-passphrase.nix | 186 ++-
nixos/tests/initrd-network.nix | 62 +-
nixos/tests/input-remapper.nix | 116 +-
nixos/tests/inspircd.nix | 166 ++-
nixos/tests/intune.nix | 118 +-
nixos/tests/invidious.nix | 258 ++--
nixos/tests/iodine.nix | 114 +-
nixos/tests/iosched.nix | 122 +-
nixos/tests/ipv6.nix | 224 ++--
nixos/tests/iscsi-multipath-root.nix | 526 ++++----
nixos/tests/iscsi-root.nix | 332 +++--
nixos/tests/isolate.nix | 68 +-
nixos/tests/isso.nix | 56 +-
nixos/tests/jackett.nix | 42 +-
nixos/tests/jellyfin.nix | 244 ++--
nixos/tests/jenkins-cli.nix | 52 +-
nixos/tests/jenkins.nix | 230 ++--
nixos/tests/jibri.nix | 130 +-
nixos/tests/jirafeau.nix | 38 +-
nixos/tests/jitsi-meet.nix | 128 +-
nixos/tests/jotta-cli.nix | 52 +-
nixos/tests/kanidm-provisioning.nix | 866 +++++++------
nixos/tests/kanidm.nix | 298 +++--
nixos/tests/karma.nix | 148 ++-
nixos/tests/kavita.nix | 78 +-
nixos/tests/kbd-setfont-decompress.nix | 38 +-
nixos/tests/kbd-update-search-paths-patch.nix | 40 +-
nixos/tests/keepalived.nix | 90 +-
nixos/tests/keepassxc.nix | 150 ++-
nixos/tests/kernel-latest-ath-user-regd.nix | 34 +-
nixos/tests/keter.nix | 76 +-
nixos/tests/komga.nix | 36 +-
nixos/tests/ksm.nix | 42 +-
nixos/tests/kthxbye.nix | 192 ++-
nixos/tests/ladybird.nix | 56 +-
nixos/tests/languagetool.nix | 46 +-
nixos/tests/lanraragi.nix | 72 +-
nixos/tests/leaps.nix | 50 +-
nixos/tests/legit.nix | 100 +-
nixos/tests/lemmy.nix | 168 ++-
nixos/tests/libinput.nix | 64 +-
nixos/tests/libresprite.nix | 60 +-
nixos/tests/libuiohook.nix | 64 +-
nixos/tests/libvirtd.nix | 140 ++-
nixos/tests/lidarr.nix | 34 +-
nixos/tests/lightdm.nix | 64 +-
nixos/tests/limesurvey.nix | 54 +-
nixos/tests/litestream.nix | 204 ++--
nixos/tests/livebook-service.nix | 86 +-
nixos/tests/lldap.nix | 48 +-
nixos/tests/localsend.nix | 38 +-
nixos/tests/locate.nix | 110 +-
nixos/tests/login.nix | 120 +-
nixos/tests/loki.nix | 112 +-
nixos/tests/luks.nix | 138 ++-
nixos/tests/lxd-image-server.nix | 164 ++-
nixos/tests/lxqt.nix | 124 +-
nixos/tests/ly.nix | 76 +-
nixos/tests/maestral.nix | 156 ++-
nixos/tests/magnetico.nix | 80 +-
nixos/tests/marytts.nix | 148 ++-
nixos/tests/mate-wayland.nix | 108 +-
nixos/tests/mate.nix | 150 ++-
nixos/tests/matrix/conduit.nix | 176 ++-
nixos/tests/matrix/dendrite.nix | 158 ++-
nixos/tests/matrix/mautrix-meta-postgres.nix | 416 ++++---
nixos/tests/matrix/mautrix-meta-sqlite.nix | 428 ++++---
nixos/tests/matrix/mjolnir.nix | 338 +++---
nixos/tests/matrix/pantalaimon.nix | 178 ++-
nixos/tests/matrix/synapse-workers.nix | 96 +-
nixos/tests/matrix/synapse.nix | 444 ++++---
nixos/tests/matter-server.nix | 80 +-
nixos/tests/mealie.nix | 76 +-
nixos/tests/mediamtx.nix | 96 +-
nixos/tests/meilisearch.nix | 118 +-
nixos/tests/merecat.nix | 60 +-
nixos/tests/metabase.nix | 42 +-
nixos/tests/mihomo.nix | 84 +-
nixos/tests/mimir.nix | 92 +-
nixos/tests/mindustry.nix | 56 +-
nixos/tests/minecraft-server.nix | 72 +-
nixos/tests/minecraft.nix | 76 +-
nixos/tests/minidlna.nix | 76 +-
nixos/tests/miniflux.nix | 230 ++--
nixos/tests/minio.nix | 202 ++-
nixos/tests/misc.nix | 286 +++--
nixos/tests/misskey.nix | 46 +-
nixos/tests/mod_perl.nix | 116 +-
nixos/tests/molly-brown.nix | 132 +-
nixos/tests/mollysocket.nix | 46 +-
nixos/tests/monado.nix | 84 +-
nixos/tests/monetdb.nix | 158 ++-
nixos/tests/moonraker.nix | 86 +-
nixos/tests/moosefs.nix | 178 ++-
nixos/tests/mopidy.nix | 28 +-
nixos/tests/morty.nix | 54 +-
nixos/tests/mtp.nix | 228 ++--
nixos/tests/multipass.nix | 68 +-
nixos/tests/munin.nix | 78 +-
nixos/tests/mutable-users.nix | 124 +-
nixos/tests/mympd.nix | 46 +-
nixos/tests/nar-serve.nix | 92 +-
nixos/tests/nats.nix | 124 +-
nixos/tests/navidrome.nix | 28 +-
nixos/tests/nbd.nix | 212 ++--
nixos/tests/ncdns.nix | 170 ++-
nixos/tests/ndppd.nix | 134 +-
nixos/tests/nebula.nix | 786 ++++++------
nixos/tests/netbird.nix | 102 +-
nixos/tests/netdata.nix | 90 +-
nixos/tests/networking-proxy.nix | 210 ++--
nixos/tests/nexus.nix | 46 +-
nixos/tests/nghttpx.nix | 110 +-
nixos/tests/nginx-njs.nix | 66 +-
nixos/tests/nimdow.nix | 62 +-
nixos/tests/nitter.nix | 60 +-
nixos/tests/nix-config.nix | 40 +-
nixos/tests/nix-serve-ssh.nix | 88 +-
nixos/tests/nixos-generate-config.nix | 100 +-
.../extra-python-packages.nix | 22 +-
nixos/tests/nixseparatedebuginfod.nix | 148 ++-
.../noto-fonts-cjk-qt-default-weight.nix | 62 +-
nixos/tests/npmrc.nix | 42 +-
nixos/tests/nscd.nix | 254 ++--
nixos/tests/nsd.nix | 222 ++--
nixos/tests/ntpd-rs.nix | 126 +-
nixos/tests/ntpd.nix | 44 +-
nixos/tests/nvmetcfg.nix | 92 +-
nixos/tests/nzbget.nix | 96 +-
nixos/tests/nzbhydra2.nix | 34 +-
nixos/tests/ocis.nix | 388 +++---
nixos/tests/octoprint.nix | 112 +-
nixos/tests/odoo.nix | 70 +-
nixos/tests/oh-my-zsh.nix | 34 +-
nixos/tests/ombi.nix | 32 +-
nixos/tests/openarena.nix | 116 +-
nixos/tests/openldap.nix | 312 +++--
nixos/tests/openresty-lua.nix | 182 ++-
nixos/tests/opensnitch.nix | 152 ++-
nixos/tests/openssh.nix | 656 +++++-----
nixos/tests/opentabletdriver.nix | 62 +-
nixos/tests/opentelemetry-collector.nix | 158 ++-
nixos/tests/openvscode-server.nix | 42 +-
nixos/tests/orangefs.nix | 154 ++-
nixos/tests/osrm-backend.nix | 114 +-
nixos/tests/outline.nix | 98 +-
nixos/tests/overlayfs.nix | 94 +-
nixos/tests/owncast.nix | 134 +-
nixos/tests/pacemaker.nix | 228 ++--
nixos/tests/packagekit.nix | 50 +-
nixos/tests/pam/pam-file-contents.nix | 40 +-
nixos/tests/pam/pam-oath-login.nix | 180 ++-
nixos/tests/pam/pam-u2f.nix | 50 +-
nixos/tests/pam/pam-ussh.nix | 150 ++-
nixos/tests/pam/zfs-key.nix | 144 ++-
nixos/tests/pantheon-wayland.nix | 174 ++-
nixos/tests/pantheon.nix | 186 ++-
nixos/tests/paperless.nix | 218 ++--
nixos/tests/pass-secret-service.nix | 130 +-
.../password-option-override-ordering.nix | 298 +++--
nixos/tests/pds.nix | 44 +-
nixos/tests/peerflix.nix | 40 +-
nixos/tests/peroxide.nix | 34 +-
nixos/tests/pgbouncer.nix | 100 +-
nixos/tests/pgmanage.nix | 80 +-
nixos/tests/phosh.nix | 150 ++-
nixos/tests/photonvision.nix | 38 +-
nixos/tests/photoprism.nix | 48 +-
nixos/tests/pict-rs.nix | 40 +-
nixos/tests/pingvin-share.nix | 42 +-
nixos/tests/plantuml-server.nix | 40 +-
nixos/tests/plasma-bigscreen.nix | 72 +-
nixos/tests/plasma5-systemd-start.nix | 80 +-
nixos/tests/plasma5.nix | 118 +-
nixos/tests/plasma6.nix | 116 +-
nixos/tests/plausible.nix | 56 +-
nixos/tests/playwright-python.nix | 112 +-
nixos/tests/please.nix | 114 +-
nixos/tests/plikd.nix | 54 +-
nixos/tests/plotinus.nix | 66 +-
nixos/tests/pocket-id.nix | 78 +-
nixos/tests/podgrab.nix | 60 +-
nixos/tests/polaris.nix | 54 +-
nixos/tests/portunus.nix | 30 +-
nixos/tests/postfixadmin.nix | 64 +-
nixos/tests/power-profiles-daemon.nix | 102 +-
nixos/tests/powerdns.nix | 114 +-
nixos/tests/pppd.nix | 132 +-
nixos/tests/private-gpt.nix | 50 +-
nixos/tests/privoxy.nix | 274 +++--
nixos/tests/proxy.nix | 162 ++-
nixos/tests/pt2-clone.nix | 62 +-
nixos/tests/public-inbox.nix | 444 ++++---
nixos/tests/pufferpanel.nix | 134 +-
nixos/tests/pykms.nix | 40 +-
nixos/tests/pyload.nix | 56 +-
nixos/tests/qownnotes.nix | 136 +--
nixos/tests/quake3.nix | 152 ++-
nixos/tests/quicktun.nix | 36 +-
nixos/tests/quickwit.nix | 180 ++-
nixos/tests/quorum.nix | 190 ++-
nixos/tests/rabbitmq.nix | 112 +-
nixos/tests/radarr.nix | 32 +-
nixos/tests/radicale.nix | 174 ++-
nixos/tests/rasdaemon.nix | 70 +-
nixos/tests/readarr.nix | 32 +-
nixos/tests/realm.nix | 68 +-
nixos/tests/redlib.nix | 50 +-
nixos/tests/renovate.nix | 118 +-
nixos/tests/restart-by-activation-script.nix | 140 ++-
nixos/tests/restic-rest-server.nix | 218 ++--
nixos/tests/restic.nix | 440 ++++---
nixos/tests/retroarch.nix | 90 +-
nixos/tests/robustirc-bridge.nix | 46 +-
nixos/tests/rosenpass.nix | 388 +++---
nixos/tests/roundcube.nix | 72 +-
nixos/tests/rspamd-trainer.nix | 314 +++--
nixos/tests/rstudio-server.nix | 76 +-
nixos/tests/rsyncd.nix | 76 +-
nixos/tests/rtorrent.nix | 52 +-
nixos/tests/rustls-libssl.nix | 168 ++-
nixos/tests/rxe.nix | 86 +-
nixos/tests/sabnzbd.nix | 52 +-
nixos/tests/samba-wsdd.nix | 78 +-
nixos/tests/sane.nix | 172 ++-
nixos/tests/sanoid.nix | 266 ++--
nixos/tests/saunafs.nix | 222 ++--
nixos/tests/sdl3.nix | 40 +-
nixos/tests/seafile.nix | 208 ++--
nixos/tests/seatd.nix | 110 +-
nixos/tests/service-runner.nix | 76 +-
nixos/tests/sfxr-qt.nix | 58 +-
nixos/tests/sgt-puzzles.nix | 64 +-
nixos/tests/shadow.nix | 316 +++--
nixos/tests/shattered-pixel-dungeon.nix | 52 +-
nixos/tests/shiori.nix | 152 ++-
nixos/tests/silverbullet.nix | 108 +-
nixos/tests/simple.nix | 36 +-
nixos/tests/sing-box.nix | 976 ++++++++-------
nixos/tests/slimserver.nix | 84 +-
nixos/tests/slurm.nix | 332 +++--
nixos/tests/smokeping.nix | 80 +-
nixos/tests/snapper.nix | 84 +-
nixos/tests/snmpd.nix | 40 +-
nixos/tests/soapui.nix | 52 +-
nixos/tests/soft-serve.nix | 194 ++-
nixos/tests/sogo.nix | 120 +-
nixos/tests/soju.nix | 56 +-
nixos/tests/solanum.nix | 174 ++-
nixos/tests/sonarr.nix | 32 +-
nixos/tests/sonic-server.nix | 42 +-
nixos/tests/spacecookie.nix | 84 +-
nixos/tests/sqlite3-to-mysql.nix | 120 +-
nixos/tests/squid.nix | 332 +++--
nixos/tests/ssh-agent-auth.nix | 114 +-
nixos/tests/ssh-audit.nix | 182 ++-
nixos/tests/stalwart-mail.nix | 214 ++--
nixos/tests/strongswan-swanctl.nix | 250 ++--
nixos/tests/sudo.nix | 312 +++--
nixos/tests/sunshine.nix | 136 +--
nixos/tests/suricata.nix | 136 +--
nixos/tests/swap-file-btrfs.nix | 82 +-
nixos/tests/swap-partition.nix | 90 +-
nixos/tests/swap-random-encryption.nix | 140 ++-
nixos/tests/sway.nix | 386 +++---
nixos/tests/swayfx.nix | 342 +++---
nixos/tests/sx.nix | 104 +-
nixos/tests/sympa.nix | 60 +-
nixos/tests/syncthing-init.nix | 54 +-
nixos/tests/syncthing-many-devices.nix | 426 ++++---
nixos/tests/syncthing-no-settings.nix | 44 +-
nixos/tests/syncthing-relay.nix | 48 +-
nixos/tests/syncthing.nix | 120 +-
nixos/tests/systemd-analyze.nix | 84 +-
nixos/tests/systemd-bpf.nix | 96 +-
nixos/tests/systemd-coredump.nix | 80 +-
nixos/tests/systemd-credentials-tpm2.nix | 114 +-
nixos/tests/systemd-cryptenroll.nix | 76 +-
nixos/tests/systemd-escaping.nix | 118 +-
nixos/tests/systemd-homed.nix | 186 ++-
nixos/tests/systemd-initrd-bridge.nix | 128 +-
nixos/tests/systemd-initrd-btrfs-raid.nix | 96 +-
nixos/tests/systemd-initrd-luks-fido2.nix | 98 +-
nixos/tests/systemd-initrd-luks-keyfile.nix | 106 +-
nixos/tests/systemd-initrd-luks-password.nix | 112 +-
nixos/tests/systemd-initrd-luks-tpm2.nix | 94 +-
nixos/tests/systemd-initrd-luks-unl0kr.nix | 182 ++-
nixos/tests/systemd-initrd-modprobe.nix | 50 +-
nixos/tests/systemd-initrd-networkd-ssh.nix | 102 +-
nixos/tests/systemd-initrd-swraid.nix | 132 +-
nixos/tests/systemd-initrd-vconsole.nix | 90 +-
nixos/tests/systemd-initrd-vlan.nix | 112 +-
nixos/tests/systemd-journal-gateway.nix | 176 ++-
nixos/tests/systemd-journal-upload.nix | 200 ++-
nixos/tests/systemd-journal.nix | 128 +-
nixos/tests/systemd-machinectl.nix | 344 +++---
nixos/tests/systemd-misc.nix | 110 +-
nixos/tests/systemd-networkd-bridge.nix | 98 +-
nixos/tests/systemd-networkd-dhcpserver.nix | 212 ++--
nixos/tests/systemd-networkd-vrf.nix | 348 +++---
nixos/tests/systemd-networkd.nix | 150 ++-
nixos/tests/systemd-no-tainted.nix | 28 +-
nixos/tests/systemd-nspawn-configfile.nix | 230 ++--
nixos/tests/systemd-nspawn.nix | 118 +-
nixos/tests/systemd-oomd.nix | 98 +-
nixos/tests/systemd-portabled.nix | 104 +-
nixos/tests/systemd-resolved.nix | 180 ++-
nixos/tests/systemd-shutdown.nix | 80 +-
nixos/tests/systemd-timesyncd-nscd-dnssec.nix | 98 +-
nixos/tests/systemd-timesyncd.nix | 122 +-
nixos/tests/systemd-user-linger.nix | 62 +-
nixos/tests/systemd-user-tmpfiles-rules.nix | 70 +-
nixos/tests/systemd-userdbd.nix | 64 +-
nixos/tests/systemd.nix | 470 ++++---
nixos/tests/tandoor-recipes-script-name.nix | 146 ++-
nixos/tests/tandoor-recipes.nix | 80 +-
nixos/tests/tang.nix | 168 ++-
nixos/tests/taskchampion-sync-server.nix | 86 +-
nixos/tests/taskserver.nix | 476 ++++----
nixos/tests/tayga.nix | 458 ++++---
nixos/tests/technitium-dns-server.nix | 50 +-
nixos/tests/teeworlds.nix | 86 +-
nixos/tests/tiddlywiki.nix | 118 +-
nixos/tests/timezone.nix | 98 +-
nixos/tests/tinydns.nix | 86 +-
nixos/tests/tinyproxy.nix | 38 +-
nixos/tests/tinywl.nix | 122 +-
nixos/tests/tmate-ssh-server.nix | 150 ++-
nixos/tests/tomcat.nix | 56 +-
nixos/tests/tor.nix | 56 +-
nixos/tests/trafficserver.nix | 338 +++---
nixos/tests/transfer-sh.nix | 42 +-
nixos/tests/trezord.nix | 50 +-
nixos/tests/trickster.nix | 82 +-
nixos/tests/tsm-client-gui.nix | 86 +-
nixos/tests/tuptime.nix | 56 +-
nixos/tests/turbovnc-headless-server.nix | 270 ++---
nixos/tests/turn-rs.nix | 104 +-
nixos/tests/txredisapi.nix | 68 +-
nixos/tests/typesense.nix | 50 +-
nixos/tests/ucarp.nix | 130 +-
nixos/tests/udisks2.nix | 122 +-
nixos/tests/ulogd/ulogd.nix | 100 +-
nixos/tests/umurmur.nix | 168 ++-
nixos/tests/unbound.nix | 738 ++++++-----
nixos/tests/uptermd.nix | 114 +-
nixos/tests/uptime-kuma.nix | 34 +-
nixos/tests/urn-timer.nix | 52 +-
nixos/tests/usbguard.nix | 112 +-
nixos/tests/user-activation-scripts.nix | 72 +-
nixos/tests/user-home-mode.nix | 72 +-
nixos/tests/ustreamer.nix | 136 +--
nixos/tests/uwsgi.nix | 152 ++-
nixos/tests/v2ray.nix | 184 ++-
nixos/tests/vault-agent.nix | 108 +-
nixos/tests/vault-dev.nix | 76 +-
nixos/tests/vault-postgresql.nix | 124 +-
nixos/tests/vault.nix | 48 +-
nixos/tests/vdirsyncer.nix | 516 ++++----
nixos/tests/vengi-tools.nix | 54 +-
nixos/tests/vikunja.nix | 136 +--
nixos/tests/vsftpd.nix | 76 +-
nixos/tests/waagent.nix | 122 +-
nixos/tests/warzone2100.nix | 52 +-
nixos/tests/wasabibackend.nix | 76 +-
nixos/tests/watchdogd.nix | 44 +-
nixos/tests/web-apps/healthchecks.nix | 72 +-
nixos/tests/web-apps/immich-public-proxy.nix | 180 ++-
nixos/tests/web-apps/immich.nix | 100 +-
nixos/tests/web-apps/netbox-upgrade.nix | 184 ++-
nixos/tests/web-apps/open-web-calendar.nix | 86 +-
nixos/tests/web-apps/peering-manager.nix | 84 +-
nixos/tests/web-apps/phylactery.nix | 40 +-
nixos/tests/web-apps/tt-rss.nix | 80 +-
nixos/tests/web-apps/weblate.nix | 176 ++-
nixos/tests/web-servers/ttyd.nix | 60 +-
nixos/tests/web-servers/unit-perl.nix | 78 +-
nixos/tests/wg-access-server.nix | 58 +-
nixos/tests/whisparr.nix | 32 +-
nixos/tests/whoogle-search.nix | 40 +-
nixos/tests/without-nix.nix | 66 +-
nixos/tests/wmderland.nix | 122 +-
nixos/tests/workout-tracker.nix | 44 +-
nixos/tests/wrappers.nix | 220 ++--
nixos/tests/xmpp/ejabberd.nix | 568 +++++----
538 files changed, 35525 insertions(+), 36600 deletions(-)
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index c01da895fbbc..2ba9260afff2 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -146,7 +146,7 @@ in
# Testing the test driver
nixos-test-driver = {
- extra-python-packages = handleTest ./nixos-test-driver/extra-python-packages.nix { };
+ extra-python-packages = runTest ./nixos-test-driver/extra-python-packages.nix;
lib-extend = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./nixos-test-driver/lib-extend.nix { };
node-name = runTest ./nixos-test-driver/node-name.nix;
busybox = runTest ./nixos-test-driver/busybox.nix;
@@ -213,7 +213,7 @@ in
atop = import ./atop.nix { inherit pkgs runTest; };
atticd = runTest ./atticd.nix;
atuin = runTest ./atuin.nix;
- ax25 = handleTest ./ax25.nix { };
+ ax25 = runTest ./ax25.nix;
audiobookshelf = runTest ./audiobookshelf.nix;
auth-mysql = runTest ./auth-mysql.nix;
authelia = runTest ./authelia.nix;
@@ -233,7 +233,7 @@ in
bcachefs = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./bcachefs.nix;
beanstalkd = runTest ./beanstalkd.nix;
bees = runTest ./bees.nix;
- benchexec = handleTest ./benchexec.nix { };
+ benchexec = runTest ./benchexec.nix;
binary-cache = runTest {
imports = [ ./binary-cache.nix ];
_module.args.compression = "zstd";
@@ -250,37 +250,37 @@ in
bird = handleTest ./bird.nix { };
birdwatcher = handleTest ./birdwatcher.nix { };
bitbox-bridge = runTest ./bitbox-bridge.nix;
- bitcoind = handleTest ./bitcoind.nix { };
- bittorrent = handleTest ./bittorrent.nix { };
- blockbook-frontend = handleTest ./blockbook-frontend.nix { };
+ bitcoind = runTest ./bitcoind.nix;
+ bittorrent = runTest ./bittorrent.nix;
+ blockbook-frontend = runTest ./blockbook-frontend.nix;
blocky = handleTest ./blocky.nix { };
boot = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./boot.nix { };
bootspec = handleTestOn [ "x86_64-linux" ] ./bootspec.nix { };
- boot-stage1 = handleTest ./boot-stage1.nix { };
- boot-stage2 = handleTest ./boot-stage2.nix { };
- borgbackup = handleTest ./borgbackup.nix { };
- borgmatic = handleTest ./borgmatic.nix { };
+ boot-stage1 = runTest ./boot-stage1.nix;
+ boot-stage2 = runTest ./boot-stage2.nix;
+ borgbackup = runTest ./borgbackup.nix;
+ borgmatic = runTest ./borgmatic.nix;
botamusique = runTest ./botamusique.nix;
bpf = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./bpf.nix { };
- bpftune = handleTest ./bpftune.nix { };
- breitbandmessung = handleTest ./breitbandmessung.nix { };
- brscan5 = handleTest ./brscan5.nix { };
- btrbk = handleTest ./btrbk.nix { };
- btrbk-doas = handleTest ./btrbk-doas.nix { };
- btrbk-no-timer = handleTest ./btrbk-no-timer.nix { };
- btrbk-section-order = handleTest ./btrbk-section-order.nix { };
- budgie = handleTest ./budgie.nix { };
+ bpftune = runTest ./bpftune.nix;
+ breitbandmessung = runTest ./breitbandmessung.nix;
+ brscan5 = runTest ./brscan5.nix;
+ btrbk = runTest ./btrbk.nix;
+ btrbk-doas = runTest ./btrbk-doas.nix;
+ btrbk-no-timer = runTest ./btrbk-no-timer.nix;
+ btrbk-section-order = runTest ./btrbk-section-order.nix;
+ budgie = runTest ./budgie.nix;
buildbot = runTest ./buildbot.nix;
- buildkite-agents = handleTest ./buildkite-agents.nix { };
- c2fmzq = handleTest ./c2fmzq.nix { };
+ buildkite-agents = runTest ./buildkite-agents.nix;
+ c2fmzq = runTest ./c2fmzq.nix;
caddy = runTest ./caddy.nix;
cadvisor = handleTestOn [ "x86_64-linux" ] ./cadvisor.nix { };
- cage = handleTest ./cage.nix { };
- cagebreak = handleTest ./cagebreak.nix { };
+ cage = runTest ./cage.nix;
+ cagebreak = runTest ./cagebreak.nix;
calibre-web = runTest ./calibre-web.nix;
calibre-server = import ./calibre-server.nix { inherit pkgs runTest; };
- canaille = handleTest ./canaille.nix { };
- castopod = handleTest ./castopod.nix { };
+ canaille = runTest ./canaille.nix;
+ castopod = runTest ./castopod.nix;
cassandra_4 = handleTest ./cassandra.nix { testPackage = pkgs.cassandra_4; };
centrifugo = runTest ./centrifugo.nix;
ceph-multi-node = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./ceph-multi-node.nix { };
@@ -296,47 +296,47 @@ in
certmgr = handleTest ./certmgr.nix { };
cfssl = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./cfssl.nix { };
cgit = runTest ./cgit.nix;
- charliecloud = handleTest ./charliecloud.nix { };
+ charliecloud = runTest ./charliecloud.nix;
chromadb = runTest ./chromadb.nix;
chromium = (handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./chromium.nix { }).stable or { };
chrony = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./chrony.nix { };
chrony-ptp = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./chrony-ptp.nix { };
- cinnamon = handleTest ./cinnamon.nix { };
- cinnamon-wayland = handleTest ./cinnamon-wayland.nix { };
- cjdns = handleTest ./cjdns.nix { };
+ cinnamon = runTest ./cinnamon.nix;
+ cinnamon-wayland = runTest ./cinnamon-wayland.nix;
+ cjdns = runTest ./cjdns.nix;
clatd = runTest ./clatd.nix;
- clickhouse = handleTest ./clickhouse.nix { };
+ clickhouse = runTest ./clickhouse.nix;
cloud-init = handleTest ./cloud-init.nix { };
cloud-init-hostname = handleTest ./cloud-init-hostname.nix { };
- cloudlog = handleTest ./cloudlog.nix { };
+ cloudlog = runTest ./cloudlog.nix;
cntr = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./cntr.nix { };
- cockpit = handleTest ./cockpit.nix { };
+ cockpit = runTest ./cockpit.nix;
cockroachdb = handleTestOn [ "x86_64-linux" ] ./cockroachdb.nix { };
- code-server = handleTest ./code-server.nix { };
- coder = handleTest ./coder.nix { };
- collectd = handleTest ./collectd.nix { };
- commafeed = handleTest ./commafeed.nix { };
- connman = handleTest ./connman.nix { };
- consul = handleTest ./consul.nix { };
- consul-template = handleTest ./consul-template.nix { };
- containers-bridge = handleTest ./containers-bridge.nix { };
- containers-custom-pkgs.nix = handleTest ./containers-custom-pkgs.nix { };
- containers-ephemeral = handleTest ./containers-ephemeral.nix { };
- containers-extra_veth = handleTest ./containers-extra_veth.nix { };
- containers-hosts = handleTest ./containers-hosts.nix { };
- containers-imperative = handleTest ./containers-imperative.nix { };
- containers-ip = handleTest ./containers-ip.nix { };
- containers-macvlans = handleTest ./containers-macvlans.nix { };
- containers-names = handleTest ./containers-names.nix { };
- containers-nested = handleTest ./containers-nested.nix { };
- containers-physical_interfaces = handleTest ./containers-physical_interfaces.nix { };
- containers-portforward = handleTest ./containers-portforward.nix { };
- containers-reloadable = handleTest ./containers-reloadable.nix { };
- containers-require-bind-mounts = handleTest ./containers-require-bind-mounts.nix { };
- containers-restart_networking = handleTest ./containers-restart_networking.nix { };
- containers-tmpfs = handleTest ./containers-tmpfs.nix { };
- containers-unified-hierarchy = handleTest ./containers-unified-hierarchy.nix { };
- convos = handleTest ./convos.nix { };
+ code-server = runTest ./code-server.nix;
+ coder = runTest ./coder.nix;
+ collectd = runTest ./collectd.nix;
+ commafeed = runTest ./commafeed.nix;
+ connman = runTest ./connman.nix;
+ consul = runTest ./consul.nix;
+ consul-template = runTest ./consul-template.nix;
+ containers-bridge = runTest ./containers-bridge.nix;
+ containers-custom-pkgs.nix = runTest ./containers-custom-pkgs.nix;
+ containers-ephemeral = runTest ./containers-ephemeral.nix;
+ containers-extra_veth = runTest ./containers-extra_veth.nix;
+ containers-hosts = runTest ./containers-hosts.nix;
+ containers-imperative = runTest ./containers-imperative.nix;
+ containers-ip = runTest ./containers-ip.nix;
+ containers-macvlans = runTest ./containers-macvlans.nix;
+ containers-names = runTest ./containers-names.nix;
+ containers-nested = runTest ./containers-nested.nix;
+ containers-physical_interfaces = runTest ./containers-physical_interfaces.nix;
+ containers-portforward = runTest ./containers-portforward.nix;
+ containers-reloadable = runTest ./containers-reloadable.nix;
+ containers-require-bind-mounts = runTest ./containers-require-bind-mounts.nix;
+ containers-restart_networking = runTest ./containers-restart_networking.nix;
+ containers-tmpfs = runTest ./containers-tmpfs.nix;
+ containers-unified-hierarchy = runTest ./containers-unified-hierarchy.nix;
+ convos = runTest ./convos.nix;
corerad = handleTest ./corerad.nix { };
cosmic = runTest {
imports = [ ./cosmic.nix ];
@@ -362,33 +362,33 @@ in
_module.args.enableAutologin = true;
_module.args.enableXWayland = false;
};
- coturn = handleTest ./coturn.nix { };
- couchdb = handleTest ./couchdb.nix { };
- crabfit = handleTest ./crabfit.nix { };
+ coturn = runTest ./coturn.nix;
+ couchdb = runTest ./couchdb.nix;
+ crabfit = runTest ./crabfit.nix;
cri-o = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./cri-o.nix { };
cryptpad = runTest ./cryptpad.nix;
cups-pdf = runTest ./cups-pdf.nix;
- curl-impersonate = handleTest ./curl-impersonate.nix { };
+ curl-impersonate = runTest ./curl-impersonate.nix;
custom-ca = handleTest ./custom-ca.nix { };
- croc = handleTest ./croc.nix { };
+ croc = runTest ./croc.nix;
cross-seed = runTest ./cross-seed.nix;
cyrus-imap = runTest ./cyrus-imap.nix;
darling-dmg = runTest ./darling-dmg.nix;
- dae = handleTest ./dae.nix { };
+ dae = runTest ./dae.nix;
davis = runTest ./davis.nix;
- db-rest = handleTest ./db-rest.nix { };
- dconf = handleTest ./dconf.nix { };
- ddns-updater = handleTest ./ddns-updater.nix { };
- deconz = handleTest ./deconz.nix { };
- deepin = handleTest ./deepin.nix { };
- deluge = handleTest ./deluge.nix { };
- dendrite = handleTest ./matrix/dendrite.nix { };
- dependency-track = handleTest ./dependency-track.nix { };
- devpi-server = handleTest ./devpi-server.nix { };
- dex-oidc = handleTest ./dex-oidc.nix { };
+ db-rest = runTest ./db-rest.nix;
+ dconf = runTest ./dconf.nix;
+ ddns-updater = runTest ./ddns-updater.nix;
+ deconz = runTest ./deconz.nix;
+ deepin = runTest ./deepin.nix;
+ deluge = runTest ./deluge.nix;
+ dendrite = runTest ./matrix/dendrite.nix;
+ dependency-track = runTest ./dependency-track.nix;
+ devpi-server = runTest ./devpi-server.nix;
+ dex-oidc = runTest ./dex-oidc.nix;
dhparams = handleTest ./dhparams.nix { };
- disable-installer-tools = handleTest ./disable-installer-tools.nix { };
- discourse = handleTest ./discourse.nix { };
+ disable-installer-tools = runTest ./disable-installer-tools.nix;
+ discourse = runTest ./discourse.nix;
dnscrypt-proxy2 = handleTestOn [ "x86_64-linux" ] ./dnscrypt-proxy2.nix { };
dnsdist = import ./dnsdist.nix { inherit pkgs runTest; };
doas = runTest ./doas.nix;
@@ -400,36 +400,36 @@ in
docker-tools-cross = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./docker-tools-cross.nix;
docker-tools-overlay = runTestOn [ "x86_64-linux" ] ./docker-tools-overlay.nix;
docling-serve = runTest ./docling-serve.nix;
- documize = handleTest ./documize.nix { };
+ documize = runTest ./documize.nix;
documentation = pkgs.callPackage ../modules/misc/documentation/test.nix { inherit nixosLib; };
- doh-proxy-rust = handleTest ./doh-proxy-rust.nix { };
+ doh-proxy-rust = runTest ./doh-proxy-rust.nix;
dokuwiki = runTest ./dokuwiki.nix;
dolibarr = runTest ./dolibarr.nix;
- domination = handleTest ./domination.nix { };
+ domination = runTest ./domination.nix;
dovecot = handleTest ./dovecot.nix { };
drawterm = discoverTests (import ./drawterm.nix);
- drbd = handleTest ./drbd.nix { };
+ drbd = runTest ./drbd.nix;
druid = handleTestOn [ "x86_64-linux" ] ./druid { };
- drbd-driver = handleTest ./drbd-driver.nix { };
- dublin-traceroute = handleTest ./dublin-traceroute.nix { };
+ drbd-driver = runTest ./drbd-driver.nix;
+ dublin-traceroute = runTest ./dublin-traceroute.nix;
earlyoom = handleTestOn [ "x86_64-linux" ] ./earlyoom.nix { };
early-mount-options = handleTest ./early-mount-options.nix { };
ec2-config = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).boot-ec2-config or { };
ec2-nixops = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).boot-ec2-nixops or { };
echoip = runTest ./echoip.nix;
- ecryptfs = handleTest ./ecryptfs.nix { };
- fscrypt = handleTest ./fscrypt.nix { };
+ ecryptfs = runTest ./ecryptfs.nix;
+ fscrypt = runTest ./fscrypt.nix;
fastnetmon-advanced = runTest ./fastnetmon-advanced.nix;
eintopf = runTest ./eintopf.nix;
- ejabberd = handleTest ./xmpp/ejabberd.nix { };
+ ejabberd = runTest ./xmpp/ejabberd.nix;
elk = handleTestOn [ "x86_64-linux" ] ./elk.nix { };
emacs-daemon = runTest ./emacs-daemon.nix;
- endlessh = handleTest ./endlessh.nix { };
- endlessh-go = handleTest ./endlessh-go.nix { };
- engelsystem = handleTest ./engelsystem.nix { };
- enlightenment = handleTest ./enlightenment.nix { };
- env = handleTest ./env.nix { };
- envfs = handleTest ./envfs.nix { };
+ endlessh = runTest ./endlessh.nix;
+ endlessh-go = runTest ./endlessh-go.nix;
+ engelsystem = runTest ./engelsystem.nix;
+ enlightenment = runTest ./enlightenment.nix;
+ env = runTest ./env.nix;
+ envfs = runTest ./envfs.nix;
envoy = runTest {
imports = [ ./envoy.nix ];
_module.args.envoyPackage = pkgs.envoy;
@@ -438,10 +438,10 @@ in
imports = [ ./envoy.nix ];
_module.args.envoyPackage = pkgs.envoy-bin;
};
- ergo = handleTest ./ergo.nix { };
- ergochat = handleTest ./ergochat.nix { };
- eris-server = handleTest ./eris-server.nix { };
- esphome = handleTest ./esphome.nix { };
+ ergo = runTest ./ergo.nix;
+ ergochat = runTest ./ergochat.nix;
+ eris-server = runTest ./eris-server.nix;
+ esphome = runTest ./esphome.nix;
etc = pkgs.callPackage ../modules/system/etc/test.nix { inherit evalMinimalConfig; };
activation = pkgs.callPackage ../modules/system/activation/test.nix { };
activation-lib = pkgs.callPackage ../modules/system/activation/lib/test.nix { };
@@ -452,20 +452,20 @@ in
activation-perlless = runTest ./activation/perlless.nix;
etcd = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./etcd/etcd.nix { };
etcd-cluster = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./etcd/etcd-cluster.nix { };
- etebase-server = handleTest ./etebase-server.nix { };
- etesync-dav = handleTest ./etesync-dav.nix { };
+ etebase-server = runTest ./etebase-server.nix;
+ etesync-dav = runTest ./etesync-dav.nix;
evcc = runTest ./evcc.nix;
fail2ban = runTest ./fail2ban.nix;
- fakeroute = handleTest ./fakeroute.nix { };
+ fakeroute = runTest ./fakeroute.nix;
fancontrol = runTest ./fancontrol.nix;
- fanout = handleTest ./fanout.nix { };
+ fanout = runTest ./fanout.nix;
fcitx5 = handleTest ./fcitx5 { };
fedimintd = runTest ./fedimintd.nix;
- fenics = handleTest ./fenics.nix { };
- ferm = handleTest ./ferm.nix { };
+ fenics = runTest ./fenics.nix;
+ ferm = runTest ./ferm.nix;
ferretdb = handleTest ./ferretdb.nix { };
fider = runTest ./fider.nix;
- filesender = handleTest ./filesender.nix { };
+ filesender = runTest ./filesender.nix;
filesystems-overlayfs = runTest ./filesystems-overlayfs.nix;
firefly-iii = runTest ./firefly-iii.nix;
firefly-iii-data-importer = runTest ./firefly-iii-data-importer.nix;
@@ -490,23 +490,23 @@ in
imports = [ ./firefox.nix ];
_module.args.firefoxPackage = pkgs.firefox-esr-128;
};
- firefoxpwa = handleTest ./firefoxpwa.nix { };
- firejail = handleTest ./firejail.nix { };
+ firefoxpwa = runTest ./firefoxpwa.nix;
+ firejail = runTest ./firejail.nix;
firewall = handleTest ./firewall.nix { nftables = false; };
firewall-nftables = handleTest ./firewall.nix { nftables = true; };
fish = runTest ./fish.nix;
- firezone = handleTest ./firezone/firezone.nix { };
+ firezone = runTest ./firezone/firezone.nix;
flannel = handleTestOn [ "x86_64-linux" ] ./flannel.nix { };
- flaresolverr = handleTest ./flaresolverr.nix { };
- flood = handleTest ./flood.nix { };
+ flaresolverr = runTest ./flaresolverr.nix;
+ flood = runTest ./flood.nix;
floorp = runTest {
imports = [ ./firefox.nix ];
_module.args.firefoxPackage = pkgs.floorp;
};
fluent-bit = runTest ./fluent-bit.nix;
- fluentd = handleTest ./fluentd.nix { };
- fluidd = handleTest ./fluidd.nix { };
- fontconfig-default-fonts = handleTest ./fontconfig-default-fonts.nix { };
+ fluentd = runTest ./fluentd.nix;
+ fluidd = runTest ./fluidd.nix;
+ fontconfig-default-fonts = runTest ./fontconfig-default-fonts.nix;
forgejo = import ./forgejo.nix {
inherit runTest;
forgejoPackage = pkgs.forgejo;
@@ -516,69 +516,69 @@ in
forgejoPackage = pkgs.forgejo-lts;
};
freenet = runTest ./freenet.nix;
- freeswitch = handleTest ./freeswitch.nix { };
+ freeswitch = runTest ./freeswitch.nix;
freetube = discoverTests (import ./freetube.nix);
freshrss = handleTest ./freshrss { };
frigate = runTest ./frigate.nix;
froide-govplan = runTest ./web-apps/froide-govplan.nix;
- frp = handleTest ./frp.nix { };
- frr = handleTest ./frr.nix { };
+ frp = runTest ./frp.nix;
+ frr = runTest ./frr.nix;
fsck = handleTest ./fsck.nix { };
fsck-systemd-stage-1 = handleTest ./fsck.nix { systemdStage1 = true; };
- ft2-clone = handleTest ./ft2-clone.nix { };
- legit = handleTest ./legit.nix { };
- mimir = handleTest ./mimir.nix { };
- gancio = handleTest ./gancio.nix { };
+ ft2-clone = runTest ./ft2-clone.nix;
+ legit = runTest ./legit.nix;
+ mimir = runTest ./mimir.nix;
+ gancio = runTest ./gancio.nix;
garage = handleTest ./garage { };
gatus = runTest ./gatus.nix;
gemstash = handleTest ./gemstash.nix { };
geoclue2 = runTest ./geoclue2.nix;
geoserver = runTest ./geoserver.nix;
gerrit = runTest ./gerrit.nix;
- geth = handleTest ./geth.nix { };
- ghostunnel = handleTest ./ghostunnel.nix { };
- gitdaemon = handleTest ./gitdaemon.nix { };
+ geth = runTest ./geth.nix;
+ ghostunnel = runTest ./ghostunnel.nix;
+ gitdaemon = runTest ./gitdaemon.nix;
gitea = handleTest ./gitea.nix { giteaPackage = pkgs.gitea; };
github-runner = runTest ./github-runner.nix;
gitlab = runTest ./gitlab.nix;
- gitolite = handleTest ./gitolite.nix { };
- gitolite-fcgiwrap = handleTest ./gitolite-fcgiwrap.nix { };
+ gitolite = runTest ./gitolite.nix;
+ gitolite-fcgiwrap = runTest ./gitolite-fcgiwrap.nix;
glance = runTest ./glance.nix;
glances = runTest ./glances.nix;
glitchtip = runTest ./glitchtip.nix;
- glusterfs = handleTest ./glusterfs.nix { };
+ glusterfs = runTest ./glusterfs.nix;
gnome = runTest ./gnome.nix;
- gnome-extensions = handleTest ./gnome-extensions.nix { };
- gnome-flashback = handleTest ./gnome-flashback.nix { };
- gnome-xorg = handleTest ./gnome-xorg.nix { };
- gns3-server = handleTest ./gns3-server.nix { };
- gnupg = handleTest ./gnupg.nix { };
- goatcounter = handleTest ./goatcounter.nix { };
+ gnome-extensions = runTest ./gnome-extensions.nix;
+ gnome-flashback = runTest ./gnome-flashback.nix;
+ gnome-xorg = runTest ./gnome-xorg.nix;
+ gns3-server = runTest ./gns3-server.nix;
+ gnupg = runTest ./gnupg.nix;
+ goatcounter = runTest ./goatcounter.nix;
go-camo = handleTest ./go-camo.nix { };
go-neb = runTest ./go-neb.nix;
- gobgpd = handleTest ./gobgpd.nix { };
- gocd-agent = handleTest ./gocd-agent.nix { };
- gocd-server = handleTest ./gocd-server.nix { };
+ gobgpd = runTest ./gobgpd.nix;
+ gocd-agent = runTest ./gocd-agent.nix;
+ gocd-server = runTest ./gocd-server.nix;
gokapi = runTest ./gokapi.nix;
- gollum = handleTest ./gollum.nix { };
- gonic = handleTest ./gonic.nix { };
+ gollum = runTest ./gollum.nix;
+ gonic = runTest ./gonic.nix;
google-oslogin = handleTest ./google-oslogin { };
- gopro-tool = handleTest ./gopro-tool.nix { };
- goss = handleTest ./goss.nix { };
- gotenberg = handleTest ./gotenberg.nix { };
- gotify-server = handleTest ./gotify-server.nix { };
+ gopro-tool = runTest ./gopro-tool.nix;
+ goss = runTest ./goss.nix;
+ gotenberg = runTest ./gotenberg.nix;
+ gotify-server = runTest ./gotify-server.nix;
gotosocial = runTest ./web-apps/gotosocial.nix;
grafana = handleTest ./grafana { };
- graphite = handleTest ./graphite.nix { };
+ graphite = runTest ./graphite.nix;
grav = runTest ./web-apps/grav.nix;
- graylog = handleTest ./graylog.nix { };
- greetd-no-shadow = handleTest ./greetd-no-shadow.nix { };
+ graylog = runTest ./graylog.nix;
+ greetd-no-shadow = runTest ./greetd-no-shadow.nix;
grocy = runTest ./grocy.nix;
grow-partition = runTest ./grow-partition.nix;
- grub = handleTest ./grub.nix { };
- guacamole-server = handleTest ./guacamole-server.nix { };
+ grub = runTest ./grub.nix;
+ guacamole-server = runTest ./guacamole-server.nix;
guix = handleTest ./guix { };
- gvisor = handleTest ./gvisor.nix { };
+ gvisor = runTest ./gvisor.nix;
h2o = import ./web-servers/h2o { inherit recurseIntoAttrs runTest; };
hadoop = import ./hadoop {
inherit handleTestOn;
@@ -592,30 +592,30 @@ in
inherit handleTestOn;
package = pkgs.hadoop2;
};
- haste-server = handleTest ./haste-server.nix { };
+ haste-server = runTest ./haste-server.nix;
haproxy = runTest ./haproxy.nix;
- hardened = handleTest ./hardened.nix { };
+ hardened = runTest ./hardened.nix;
harmonia = runTest ./harmonia.nix;
- headscale = handleTest ./headscale.nix { };
- healthchecks = handleTest ./web-apps/healthchecks.nix { };
+ headscale = runTest ./headscale.nix;
+ healthchecks = runTest ./web-apps/healthchecks.nix;
hbase2 = handleTest ./hbase.nix { package = pkgs.hbase2; };
hbase_2_5 = handleTest ./hbase.nix { package = pkgs.hbase_2_5; };
hbase_2_4 = handleTest ./hbase.nix { package = pkgs.hbase_2_4; };
hbase3 = handleTest ./hbase.nix { package = pkgs.hbase3; };
- hedgedoc = handleTest ./hedgedoc.nix { };
- herbstluftwm = handleTest ./herbstluftwm.nix { };
- homebox = handleTest ./homebox.nix { };
+ hedgedoc = runTest ./hedgedoc.nix;
+ herbstluftwm = runTest ./herbstluftwm.nix;
+ homebox = runTest ./homebox.nix;
homer = handleTest ./homer { };
homepage-dashboard = runTest ./homepage-dashboard.nix;
honk = runTest ./honk.nix;
installed-tests = pkgs.recurseIntoAttrs (handleTest ./installed-tests { });
- invidious = handleTest ./invidious.nix { };
- iosched = handleTest ./iosched.nix { };
- isolate = handleTest ./isolate.nix { };
- livebook-service = handleTest ./livebook-service.nix { };
- pyload = handleTest ./pyload.nix { };
+ invidious = runTest ./invidious.nix;
+ iosched = runTest ./iosched.nix;
+ isolate = runTest ./isolate.nix;
+ livebook-service = runTest ./livebook-service.nix;
+ pyload = runTest ./pyload.nix;
oci-containers = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./oci-containers.nix { };
- odoo = handleTest ./odoo.nix { };
+ odoo = runTest ./odoo.nix;
odoo17 = handleTest ./odoo.nix { package = pkgs.odoo17; };
odoo16 = handleTest ./odoo.nix { package = pkgs.odoo16; };
oncall = runTest ./web-apps/oncall.nix;
@@ -627,20 +627,20 @@ in
systemdStage1 = true;
};
hitch = handleTest ./hitch { };
- hledger-web = handleTest ./hledger-web.nix { };
- hockeypuck = handleTest ./hockeypuck.nix { };
+ hledger-web = runTest ./hledger-web.nix;
+ hockeypuck = runTest ./hockeypuck.nix;
home-assistant = runTest ./home-assistant.nix;
hostname = handleTest ./hostname.nix { };
- hound = handleTest ./hound.nix { };
+ hound = runTest ./hound.nix;
hub = runTest ./git/hub.nix;
hydra = runTest ./hydra;
- i3wm = handleTest ./i3wm.nix { };
+ i3wm = runTest ./i3wm.nix;
icingaweb2 = runTest ./icingaweb2.nix;
- ifm = handleTest ./ifm.nix { };
- iftop = handleTest ./iftop.nix { };
- immich = handleTest ./web-apps/immich.nix { };
- immich-public-proxy = handleTest ./web-apps/immich-public-proxy.nix { };
- incron = handleTest ./incron.nix { };
+ ifm = runTest ./ifm.nix;
+ iftop = runTest ./iftop.nix;
+ immich = runTest ./web-apps/immich.nix;
+ immich-public-proxy = runTest ./web-apps/immich-public-proxy.nix;
+ incron = runTest ./incron.nix;
incus = pkgs.recurseIntoAttrs (
handleTest ./incus {
lts = false;
@@ -648,51 +648,51 @@ in
}
);
incus-lts = pkgs.recurseIntoAttrs (handleTest ./incus { inherit system pkgs; });
- influxdb = handleTest ./influxdb.nix { };
- influxdb2 = handleTest ./influxdb2.nix { };
+ influxdb = runTest ./influxdb.nix;
+ influxdb2 = runTest ./influxdb2.nix;
+ initrd-luks-empty-passphrase = runTest ./initrd-luks-empty-passphrase.nix;
initrd-network-openvpn = handleTestOn [ "x86_64-linux" "i686-linux" ] ./initrd-network-openvpn { };
initrd-network-ssh = handleTest ./initrd-network-ssh { };
- initrd-luks-empty-passphrase = handleTest ./initrd-luks-empty-passphrase.nix { };
- initrdNetwork = handleTest ./initrd-network.nix { };
initrd-secrets = handleTest ./initrd-secrets.nix { };
initrd-secrets-changing = handleTest ./initrd-secrets-changing.nix { };
- input-remapper = handleTest ./input-remapper.nix { };
- inspircd = handleTest ./inspircd.nix { };
+ initrdNetwork = runTest ./initrd-network.nix;
+ input-remapper = runTest ./input-remapper.nix;
+ inspircd = runTest ./inspircd.nix;
installer = handleTest ./installer.nix { };
installer-systemd-stage-1 = handleTest ./installer-systemd-stage-1.nix { };
- intune = handleTest ./intune.nix { };
+ intune = runTest ./intune.nix;
invoiceplane = runTest ./invoiceplane.nix;
- iodine = handleTest ./iodine.nix { };
- ipv6 = handleTest ./ipv6.nix { };
- iscsi-multipath-root = handleTest ./iscsi-multipath-root.nix { };
- iscsi-root = handleTest ./iscsi-root.nix { };
- isso = handleTest ./isso.nix { };
- jackett = handleTest ./jackett.nix { };
- jellyfin = handleTest ./jellyfin.nix { };
- jenkins = handleTest ./jenkins.nix { };
- jenkins-cli = handleTest ./jenkins-cli.nix { };
- jibri = handleTest ./jibri.nix { };
- jirafeau = handleTest ./jirafeau.nix { };
- jitsi-meet = handleTest ./jitsi-meet.nix { };
+ iodine = runTest ./iodine.nix;
+ ipv6 = runTest ./ipv6.nix;
+ iscsi-multipath-root = runTest ./iscsi-multipath-root.nix;
+ iscsi-root = runTest ./iscsi-root.nix;
+ isso = runTest ./isso.nix;
+ jackett = runTest ./jackett.nix;
+ jellyfin = runTest ./jellyfin.nix;
+ jenkins = runTest ./jenkins.nix;
+ jenkins-cli = runTest ./jenkins-cli.nix;
+ jibri = runTest ./jibri.nix;
+ jirafeau = runTest ./jirafeau.nix;
+ jitsi-meet = runTest ./jitsi-meet.nix;
jool = import ./jool.nix { inherit pkgs runTest; };
- jotta-cli = handleTest ./jotta-cli.nix { };
+ jotta-cli = runTest ./jotta-cli.nix;
k3s = handleTest ./k3s { };
kafka = handleTest ./kafka { };
kanboard = runTest ./web-apps/kanboard.nix;
- kanidm = handleTest ./kanidm.nix { };
- kanidm-provisioning = handleTest ./kanidm-provisioning.nix { };
- karma = handleTest ./karma.nix { };
- kavita = handleTest ./kavita.nix { };
- kbd-setfont-decompress = handleTest ./kbd-setfont-decompress.nix { };
- kbd-update-search-paths-patch = handleTest ./kbd-update-search-paths-patch.nix { };
+ kanidm = runTest ./kanidm.nix;
+ kanidm-provisioning = runTest ./kanidm-provisioning.nix;
+ karma = runTest ./karma.nix;
+ kavita = runTest ./kavita.nix;
+ kbd-setfont-decompress = runTest ./kbd-setfont-decompress.nix;
+ kbd-update-search-paths-patch = runTest ./kbd-update-search-paths-patch.nix;
kea = runTest ./kea.nix;
- keepalived = handleTest ./keepalived.nix { };
- keepassxc = handleTest ./keepassxc.nix { };
+ keepalived = runTest ./keepalived.nix;
+ keepassxc = runTest ./keepassxc.nix;
kerberos = handleTest ./kerberos/default.nix { };
kernel-generic = handleTest ./kernel-generic.nix { };
- kernel-latest-ath-user-regd = handleTest ./kernel-latest-ath-user-regd.nix { };
+ kernel-latest-ath-user-regd = runTest ./kernel-latest-ath-user-regd.nix;
kernel-rust = handleTest ./kernel-rust.nix { };
- keter = handleTest ./keter.nix { };
+ keter = runTest ./keter.nix;
kexec = runTest ./kexec.nix;
keycloak = discoverTests (import ./keycloak.nix);
keyd = handleTest ./keyd.nix { };
@@ -701,52 +701,52 @@ in
kismet = runTest ./kismet.nix;
kmonad = runTest ./kmonad.nix;
knot = runTest ./knot.nix;
- komga = handleTest ./komga.nix { };
+ komga = runTest ./komga.nix;
krb5 = discoverTests (import ./krb5);
- ksm = handleTest ./ksm.nix { };
- kthxbye = handleTest ./kthxbye.nix { };
+ ksm = runTest ./ksm.nix;
+ kthxbye = runTest ./kthxbye.nix;
kubernetes = handleTestOn [ "x86_64-linux" ] ./kubernetes { };
kubo = import ./kubo { inherit recurseIntoAttrs runTest; };
- ladybird = handleTest ./ladybird.nix { };
- languagetool = handleTest ./languagetool.nix { };
- lanraragi = handleTest ./lanraragi.nix { };
+ ladybird = runTest ./ladybird.nix;
+ languagetool = runTest ./languagetool.nix;
+ lanraragi = runTest ./lanraragi.nix;
latestKernel.login = handleTest ./login.nix { latestKernel = true; };
lasuite-docs = runTest ./web-apps/lasuite-docs.nix;
lavalink = runTest ./lavalink.nix;
- leaps = handleTest ./leaps.nix { };
- lemmy = handleTest ./lemmy.nix { };
- libinput = handleTest ./libinput.nix { };
+ leaps = runTest ./leaps.nix;
+ lemmy = runTest ./lemmy.nix;
+ libinput = runTest ./libinput.nix;
librenms = runTest ./librenms.nix;
- libresprite = handleTest ./libresprite.nix { };
+ libresprite = runTest ./libresprite.nix;
libreswan = runTest ./libreswan.nix;
libreswan-nat = runTest ./libreswan-nat.nix;
librewolf = runTest {
imports = [ ./firefox.nix ];
_module.args.firefoxPackage = pkgs.librewolf;
};
- libuiohook = handleTest ./libuiohook.nix { };
- libvirtd = handleTest ./libvirtd.nix { };
- lidarr = handleTest ./lidarr.nix { };
- lightdm = handleTest ./lightdm.nix { };
+ libuiohook = runTest ./libuiohook.nix;
+ libvirtd = runTest ./libvirtd.nix;
+ lidarr = runTest ./lidarr.nix;
+ lightdm = runTest ./lightdm.nix;
lighttpd = runTest ./lighttpd.nix;
livekit = runTest ./networking/livekit.nix;
- limesurvey = handleTest ./limesurvey.nix { };
+ limesurvey = runTest ./limesurvey.nix;
limine = import ./limine { inherit runTest; };
listmonk = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./listmonk.nix { };
litellm = runTest ./litellm.nix;
- litestream = handleTest ./litestream.nix { };
+ litestream = runTest ./litestream.nix;
lk-jwt-service = runTest ./matrix/lk-jwt-service.nix;
- lldap = handleTest ./lldap.nix { };
- localsend = handleTest ./localsend.nix { };
- locate = handleTest ./locate.nix { };
- login = handleTest ./login.nix { };
+ lldap = runTest ./lldap.nix;
+ localsend = runTest ./localsend.nix;
+ locate = runTest ./locate.nix;
+ login = runTest ./login.nix;
logrotate = runTest ./logrotate.nix;
- loki = handleTest ./loki.nix { };
- luks = handleTest ./luks.nix { };
+ loki = runTest ./loki.nix;
+ luks = runTest ./luks.nix;
lvm2 = handleTest ./lvm2 { };
lxc = handleTest ./lxc { };
lxd = pkgs.recurseIntoAttrs (handleTest ./lxd { inherit handleTestOn; });
- lxd-image-server = handleTest ./lxd-image-server.nix { };
+ lxd-image-server = runTest ./lxd-image-server.nix;
#logstash = handleTest ./logstash.nix {};
lomiri = discoverTests (import ./lomiri.nix);
lomiri-calculator-app = runTest ./lomiri-calculator-app.nix;
@@ -760,60 +760,60 @@ in
lomiri-gallery-app = runTest ./lomiri-gallery-app.nix;
lomiri-system-settings = runTest ./lomiri-system-settings.nix;
lorri = handleTest ./lorri/default.nix { };
- lxqt = handleTest ./lxqt.nix { };
- ly = handleTest ./ly.nix { };
+ lxqt = runTest ./lxqt.nix;
+ ly = runTest ./ly.nix;
maddy = discoverTests (import ./maddy { inherit handleTest; });
- maestral = handleTest ./maestral.nix { };
+ maestral = runTest ./maestral.nix;
magic-wormhole-mailbox-server = runTest ./magic-wormhole-mailbox-server.nix;
- magnetico = handleTest ./magnetico.nix { };
+ magnetico = runTest ./magnetico.nix;
mailcatcher = runTest ./mailcatcher.nix;
mailhog = runTest ./mailhog.nix;
mailpit = runTest ./mailpit.nix;
mailman = runTest ./mailman.nix;
man = runTest ./man.nix;
mariadb-galera = handleTest ./mysql/mariadb-galera.nix { };
- marytts = handleTest ./marytts.nix { };
+ marytts = runTest ./marytts.nix;
mastodon = pkgs.recurseIntoAttrs (handleTest ./web-apps/mastodon { inherit handleTestOn; });
pixelfed = discoverTests (import ./web-apps/pixelfed { inherit handleTestOn; });
- mate = handleTest ./mate.nix { };
- mate-wayland = handleTest ./mate-wayland.nix { };
- matter-server = handleTest ./matter-server.nix { };
+ mate = runTest ./mate.nix;
+ mate-wayland = runTest ./mate-wayland.nix;
+ matter-server = runTest ./matter-server.nix;
matomo = runTest ./matomo.nix;
matrix-alertmanager = runTest ./matrix/matrix-alertmanager.nix;
matrix-appservice-irc = runTest ./matrix/appservice-irc.nix;
- matrix-conduit = handleTest ./matrix/conduit.nix { };
+ matrix-conduit = runTest ./matrix/conduit.nix;
matrix-continuwuity = runTest ./matrix/continuwuity.nix;
- matrix-synapse = handleTest ./matrix/synapse.nix { };
- matrix-synapse-workers = handleTest ./matrix/synapse-workers.nix { };
- mautrix-meta-postgres = handleTest ./matrix/mautrix-meta-postgres.nix { };
- mautrix-meta-sqlite = handleTest ./matrix/mautrix-meta-sqlite.nix { };
+ matrix-synapse = runTest ./matrix/synapse.nix;
+ matrix-synapse-workers = runTest ./matrix/synapse-workers.nix;
mattermost = handleTest ./mattermost { };
- mealie = handleTest ./mealie.nix { };
- mediamtx = handleTest ./mediamtx.nix { };
+ mautrix-meta-postgres = runTest ./matrix/mautrix-meta-postgres.nix;
+ mautrix-meta-sqlite = runTest ./matrix/mautrix-meta-sqlite.nix;
+ mealie = runTest ./mealie.nix;
+ mediamtx = runTest ./mediamtx.nix;
mediatomb = handleTest ./mediatomb.nix { };
mediawiki = handleTest ./mediawiki.nix { };
- meilisearch = handleTest ./meilisearch.nix { };
+ meilisearch = runTest ./meilisearch.nix;
memcached = runTest ./memcached.nix;
- merecat = handleTest ./merecat.nix { };
- metabase = handleTest ./metabase.nix { };
- mihomo = handleTest ./mihomo.nix { };
- mindustry = handleTest ./mindustry.nix { };
- minecraft = handleTest ./minecraft.nix { };
- minecraft-server = handleTest ./minecraft-server.nix { };
- minidlna = handleTest ./minidlna.nix { };
- miniflux = handleTest ./miniflux.nix { };
- minio = handleTest ./minio.nix { };
+ merecat = runTest ./merecat.nix;
+ metabase = runTest ./metabase.nix;
+ mihomo = runTest ./mihomo.nix;
+ mindustry = runTest ./mindustry.nix;
+ minecraft = runTest ./minecraft.nix;
+ minecraft-server = runTest ./minecraft-server.nix;
+ minidlna = runTest ./minidlna.nix;
+ miniflux = runTest ./miniflux.nix;
+ minio = runTest ./minio.nix;
miracle-wm = runTest ./miracle-wm.nix;
miriway = runTest ./miriway.nix;
- misc = handleTest ./misc.nix { };
- misskey = handleTest ./misskey.nix { };
- mjolnir = handleTest ./matrix/mjolnir.nix { };
+ misc = runTest ./misc.nix;
+ misskey = runTest ./misskey.nix;
+ mjolnir = runTest ./matrix/mjolnir.nix;
mobilizon = runTest ./mobilizon.nix;
- mod_perl = handleTest ./mod_perl.nix { };
- molly-brown = handleTest ./molly-brown.nix { };
- mollysocket = handleTest ./mollysocket.nix { };
- monado = handleTest ./monado.nix { };
- monetdb = handleTest ./monetdb.nix { };
+ mod_perl = runTest ./mod_perl.nix;
+ molly-brown = runTest ./molly-brown.nix;
+ mollysocket = runTest ./mollysocket.nix;
+ monado = runTest ./monado.nix;
+ monetdb = runTest ./monetdb.nix;
monica = runTest ./web-apps/monica.nix;
mongodb = runTest ./mongodb.nix;
mongodb-ce = runTest (
@@ -824,33 +824,33 @@ in
}
);
moodle = runTest ./moodle.nix;
- moonraker = handleTest ./moonraker.nix { };
- mopidy = handleTest ./mopidy.nix { };
+ moonraker = runTest ./moonraker.nix;
+ mopidy = runTest ./mopidy.nix;
morph-browser = runTest ./morph-browser.nix;
- morty = handleTest ./morty.nix { };
+ morty = runTest ./morty.nix;
mosquitto = runTest ./mosquitto.nix;
- moosefs = handleTest ./moosefs.nix { };
+ moosefs = runTest ./moosefs.nix;
movim = import ./web-apps/movim { inherit recurseIntoAttrs runTest; };
mpd = runTest ./mpd.nix;
mpv = runTest ./mpv.nix;
- mtp = handleTest ./mtp.nix { };
- multipass = handleTest ./multipass.nix { };
+ mtp = runTest ./mtp.nix;
+ multipass = runTest ./multipass.nix;
mumble = runTest ./mumble.nix;
# Fails on aarch64-linux at the PDF creation step - need to debug this on an
# aarch64 machine..
musescore = handleTestOn [ "x86_64-linux" ] ./musescore.nix { };
music-assistant = runTest ./music-assistant.nix;
- munin = handleTest ./munin.nix { };
- mutableUsers = handleTest ./mutable-users.nix { };
+ munin = runTest ./munin.nix;
+ mutableUsers = runTest ./mutable-users.nix;
mycelium = handleTest ./mycelium { };
- mympd = handleTest ./mympd.nix { };
+ mympd = runTest ./mympd.nix;
mysql = handleTest ./mysql/mysql.nix { };
mysql-autobackup = handleTest ./mysql/mysql-autobackup.nix { };
mysql-backup = handleTest ./mysql/mysql-backup.nix { };
mysql-replication = handleTest ./mysql/mysql-replication.nix { };
n8n = runTest ./n8n.nix;
nagios = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./nagios.nix { };
- nar-serve = handleTest ./nar-serve.nix { };
+ nar-serve = runTest ./nar-serve.nix;
nat.firewall = handleTest ./nat.nix { withFirewall = true; };
nat.standalone = handleTest ./nat.nix { withFirewall = false; };
nat.nftables.firewall = handleTest ./nat.nix {
@@ -861,39 +861,39 @@ in
withFirewall = false;
nftables = true;
};
- nats = handleTest ./nats.nix { };
- navidrome = handleTest ./navidrome.nix { };
- nbd = handleTest ./nbd.nix { };
- ncdns = handleTest ./ncdns.nix { };
+ nats = runTest ./nats.nix;
+ navidrome = runTest ./navidrome.nix;
+ nbd = runTest ./nbd.nix;
+ ncdns = runTest ./ncdns.nix;
ncps = runTest ./ncps.nix;
ncps-custom-cache-datapath = runTest {
imports = [ ./ncps.nix ];
defaults.services.ncps.cache.dataPath = "/path/to/ncps";
};
- ndppd = handleTest ./ndppd.nix { };
- nix-channel = pkgs.callPackage ../modules/config/nix-channel/test.nix { };
- nebula = handleTest ./nebula.nix { };
- netbird = handleTest ./netbird.nix { };
- nimdow = handleTest ./nimdow.nix { };
+ ndppd = runTest ./ndppd.nix;
+ nebula = runTest ./nebula.nix;
neo4j = handleTest ./neo4j.nix { };
- netdata = handleTest ./netdata.nix { };
+ netbird = runTest ./netbird.nix;
+ netdata = runTest ./netdata.nix;
+ nimdow = runTest ./nimdow.nix;
+ nix-channel = pkgs.callPackage ../modules/config/nix-channel/test.nix { };
networking.scripted = handleTest ./networking/networkd-and-scripted.nix { networkd = false; };
networking.networkd = handleTest ./networking/networkd-and-scripted.nix { networkd = true; };
networking.networkmanager = handleTest ./networking/networkmanager.nix { };
netbox_3_7 = handleTest ./web-apps/netbox/default.nix { netbox = pkgs.netbox_3_7; };
netbox_4_1 = handleTest ./web-apps/netbox/default.nix { netbox = pkgs.netbox_4_1; };
netbox_4_2 = handleTest ./web-apps/netbox/default.nix { netbox = pkgs.netbox_4_2; };
- netbox-upgrade = handleTest ./web-apps/netbox-upgrade.nix { };
+ netbox-upgrade = runTest ./web-apps/netbox-upgrade.nix;
# TODO: put in networking.nix after the test becomes more complete
- networkingProxy = handleTest ./networking-proxy.nix { };
+ networkingProxy = runTest ./networking-proxy.nix;
nextcloud = handleTest ./nextcloud { };
nextflow = runTestOn [ "x86_64-linux" ] ./nextflow.nix;
nextjs-ollama-llm-ui = runTest ./web-apps/nextjs-ollama-llm-ui.nix;
- nexus = handleTest ./nexus.nix { };
+ nexus = runTest ./nexus.nix;
# TODO: Test nfsv3 + Kerberos
nfs3 = handleTest ./nfs { version = 3; };
nfs4 = handleTest ./nfs { version = 4; };
- nghttpx = handleTest ./nghttpx.nix { };
+ nghttpx = runTest ./nghttpx.nix;
nginx = runTest ./nginx.nix;
nginx-auth = runTest ./nginx-auth.nix;
nginx-etag = runTest ./nginx-etag.nix;
@@ -903,7 +903,7 @@ in
nginx-mime = runTest ./nginx-mime.nix;
nginx-modsecurity = runTest ./nginx-modsecurity.nix;
nginx-moreheaders = runTest ./nginx-moreheaders.nix;
- nginx-njs = handleTest ./nginx-njs.nix { };
+ nginx-njs = runTest ./nginx-njs.nix;
nginx-proxyprotocol = runTest ./nginx-proxyprotocol/default.nix;
nginx-pubhtml = runTest ./nginx-pubhtml.nix;
nginx-redirectcode = runTest ./nginx-redirectcode.nix;
@@ -913,16 +913,16 @@ in
nginx-unix-socket = runTest ./nginx-unix-socket.nix;
nginx-variants = import ./nginx-variants.nix { inherit pkgs runTest; };
nifi = runTestOn [ "x86_64-linux" ] ./web-apps/nifi.nix;
- nitter = handleTest ./nitter.nix { };
- nix-config = handleTest ./nix-config.nix { };
+ nitter = runTest ./nitter.nix;
+ nix-config = runTest ./nix-config.nix;
nix-ld = runTest ./nix-ld.nix;
nix-misc = handleTest ./nix/misc.nix { };
nix-upgrade = handleTest ./nix/upgrade.nix { inherit (pkgs) nixVersions; };
nix-required-mounts = runTest ./nix-required-mounts;
nix-serve = runTest ./nix-serve.nix;
- nix-serve-ssh = handleTest ./nix-serve-ssh.nix { };
+ nix-serve-ssh = runTest ./nix-serve-ssh.nix;
nixops = handleTest ./nixops/default.nix { };
- nixos-generate-config = handleTest ./nixos-generate-config.nix { };
+ nixos-generate-config = runTest ./nixos-generate-config.nix;
nixos-rebuild-install-bootloader = handleTestOn [
"x86_64-linux"
] ./nixos-rebuild-install-bootloader.nix { };
@@ -946,97 +946,97 @@ in
_module.args.withNg = true;
};
nixpkgs = pkgs.callPackage ../modules/misc/nixpkgs/test.nix { inherit evalMinimalConfig; };
- nixseparatedebuginfod = handleTest ./nixseparatedebuginfod.nix { };
+ nixseparatedebuginfod = runTest ./nixseparatedebuginfod.nix;
node-red = runTest ./node-red.nix;
nomad = runTest ./nomad.nix;
non-default-filesystems = handleTest ./non-default-filesystems.nix { };
non-switchable-system = runTest ./non-switchable-system.nix;
noto-fonts = runTest ./noto-fonts.nix;
- noto-fonts-cjk-qt-default-weight = handleTest ./noto-fonts-cjk-qt-default-weight.nix { };
+ noto-fonts-cjk-qt-default-weight = runTest ./noto-fonts-cjk-qt-default-weight.nix;
novacomd = handleTestOn [ "x86_64-linux" ] ./novacomd.nix { };
- npmrc = handleTest ./npmrc.nix { };
- nscd = handleTest ./nscd.nix { };
- nsd = handleTest ./nsd.nix { };
+ npmrc = runTest ./npmrc.nix;
+ nscd = runTest ./nscd.nix;
+ nsd = runTest ./nsd.nix;
ntfy-sh = handleTest ./ntfy-sh.nix { };
ntfy-sh-migration = handleTest ./ntfy-sh-migration.nix { };
- ntpd = handleTest ./ntpd.nix { };
- ntpd-rs = handleTest ./ntpd-rs.nix { };
+ ntpd = runTest ./ntpd.nix;
+ ntpd-rs = runTest ./ntpd-rs.nix;
nvidia-container-toolkit = runTest ./nvidia-container-toolkit.nix;
- nvmetcfg = handleTest ./nvmetcfg.nix { };
- nzbget = handleTest ./nzbget.nix { };
- nzbhydra2 = handleTest ./nzbhydra2.nix { };
- ocis = handleTest ./ocis.nix { };
+ nvmetcfg = runTest ./nvmetcfg.nix;
+ nzbget = runTest ./nzbget.nix;
+ nzbhydra2 = runTest ./nzbhydra2.nix;
+ ocis = runTest ./ocis.nix;
oddjobd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./oddjobd.nix { };
obs-studio = runTest ./obs-studio.nix;
- oh-my-zsh = handleTest ./oh-my-zsh.nix { };
+ oh-my-zsh = runTest ./oh-my-zsh.nix;
olivetin = runTest ./olivetin.nix;
ollama = runTest ./ollama.nix;
ollama-cuda = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-cuda.nix;
ollama-rocm = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-rocm.nix;
- ombi = handleTest ./ombi.nix { };
- openarena = handleTest ./openarena.nix { };
+ ombi = runTest ./ombi.nix;
+ openarena = runTest ./openarena.nix;
openbao = runTest ./openbao.nix;
opencloud = runTest ./opencloud.nix;
- openldap = handleTest ./openldap.nix { };
+ openldap = runTest ./openldap.nix;
+ openresty-lua = runTest ./openresty-lua.nix;
opensearch = discoverTests (import ./opensearch.nix);
- openresty-lua = handleTest ./openresty-lua.nix { };
opensmtpd = handleTest ./opensmtpd.nix { };
opensmtpd-rspamd = handleTest ./opensmtpd-rspamd.nix { };
- opensnitch = handleTest ./opensnitch.nix { };
- openssh = handleTest ./openssh.nix { };
- octoprint = handleTest ./octoprint.nix { };
+ opensnitch = runTest ./opensnitch.nix;
+ openssh = runTest ./openssh.nix;
+ octoprint = runTest ./octoprint.nix;
openstack-image-metadata =
(handleTestOn [ "x86_64-linux" ] ./openstack-image.nix { }).metadata or { };
openstack-image-userdata =
(handleTestOn [ "x86_64-linux" ] ./openstack-image.nix { }).userdata or { };
- opentabletdriver = handleTest ./opentabletdriver.nix { };
- opentelemetry-collector = handleTest ./opentelemetry-collector.nix { };
- open-web-calendar = handleTest ./web-apps/open-web-calendar.nix { };
+ opentabletdriver = runTest ./opentabletdriver.nix;
+ opentelemetry-collector = runTest ./opentelemetry-collector.nix;
+ open-web-calendar = runTest ./web-apps/open-web-calendar.nix;
ocsinventory-agent = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./ocsinventory-agent.nix { };
orthanc = runTest ./orthanc.nix;
- owncast = handleTest ./owncast.nix { };
- outline = handleTest ./outline.nix { };
+ owncast = runTest ./owncast.nix;
+ outline = runTest ./outline.nix;
i18n = runTest ./i18n.nix;
image-contents = handleTest ./image-contents.nix { };
- openvscode-server = handleTest ./openvscode-server.nix { };
+ openvscode-server = runTest ./openvscode-server.nix;
open-webui = runTest ./open-webui.nix;
openvswitch = runTest ./openvswitch.nix;
- orangefs = handleTest ./orangefs.nix { };
+ orangefs = runTest ./orangefs.nix;
os-prober = handleTestOn [ "x86_64-linux" ] ./os-prober.nix { };
osquery = handleTestOn [ "x86_64-linux" ] ./osquery.nix { };
- osrm-backend = handleTest ./osrm-backend.nix { };
- overlayfs = handleTest ./overlayfs.nix { };
- pacemaker = handleTest ./pacemaker.nix { };
- packagekit = handleTest ./packagekit.nix { };
- pam-file-contents = handleTest ./pam/pam-file-contents.nix { };
- pam-oath-login = handleTest ./pam/pam-oath-login.nix { };
- pam-u2f = handleTest ./pam/pam-u2f.nix { };
- pam-ussh = handleTest ./pam/pam-ussh.nix { };
- pam-zfs-key = handleTest ./pam/zfs-key.nix { };
+ osrm-backend = runTest ./osrm-backend.nix;
+ overlayfs = runTest ./overlayfs.nix;
+ pacemaker = runTest ./pacemaker.nix;
+ packagekit = runTest ./packagekit.nix;
+ pam-file-contents = runTest ./pam/pam-file-contents.nix;
+ pam-oath-login = runTest ./pam/pam-oath-login.nix;
+ pam-u2f = runTest ./pam/pam-u2f.nix;
+ pam-ussh = runTest ./pam/pam-ussh.nix;
+ pam-zfs-key = runTest ./pam/zfs-key.nix;
paretosecurity = runTest ./paretosecurity.nix;
- pass-secret-service = handleTest ./pass-secret-service.nix { };
+ pass-secret-service = runTest ./pass-secret-service.nix;
patroni = handleTestOn [ "x86_64-linux" ] ./patroni.nix { };
- pantalaimon = handleTest ./matrix/pantalaimon.nix { };
- pantheon = handleTest ./pantheon.nix { };
- pantheon-wayland = handleTest ./pantheon-wayland.nix { };
- paperless = handleTest ./paperless.nix { };
+ pantalaimon = runTest ./matrix/pantalaimon.nix;
+ pantheon = runTest ./pantheon.nix;
+ pantheon-wayland = runTest ./pantheon-wayland.nix;
+ paperless = runTest ./paperless.nix;
parsedmarc = handleTest ./parsedmarc { };
- password-option-override-ordering = handleTest ./password-option-override-ordering.nix { };
+ password-option-override-ordering = runTest ./password-option-override-ordering.nix;
pdns-recursor = runTest ./pdns-recursor.nix;
- pds = handleTest ./pds.nix { };
- peerflix = handleTest ./peerflix.nix { };
- peering-manager = handleTest ./web-apps/peering-manager.nix { };
+ pds = runTest ./pds.nix;
+ peerflix = runTest ./peerflix.nix;
+ peering-manager = runTest ./web-apps/peering-manager.nix;
peertube = handleTestOn [ "x86_64-linux" ] ./web-apps/peertube.nix { };
- peroxide = handleTest ./peroxide.nix { };
+ peroxide = runTest ./peroxide.nix;
pgadmin4 = runTest ./pgadmin4.nix;
pgbackrest = import ./pgbackrest { inherit runTest; };
- pgbouncer = handleTest ./pgbouncer.nix { };
+ pgbouncer = runTest ./pgbouncer.nix;
pghero = runTest ./pghero.nix;
pgweb = runTest ./pgweb.nix;
- pgmanage = handleTest ./pgmanage.nix { };
- phosh = handleTest ./phosh.nix { };
- photonvision = handleTest ./photonvision.nix { };
- photoprism = handleTest ./photoprism.nix { };
+ pgmanage = runTest ./pgmanage.nix;
+ phosh = runTest ./phosh.nix;
+ photonvision = runTest ./photonvision.nix;
+ photoprism = runTest ./photoprism.nix;
php = import ./php/default.nix {
inherit runTest;
php = pkgs.php;
@@ -1057,43 +1057,43 @@ in
inherit runTest;
php = pkgs.php84;
};
- phylactery = handleTest ./web-apps/phylactery.nix { };
- pict-rs = handleTest ./pict-rs.nix { };
- pingvin-share = handleTest ./pingvin-share.nix { };
+ phylactery = runTest ./web-apps/phylactery.nix;
+ pict-rs = runTest ./pict-rs.nix;
+ pingvin-share = runTest ./pingvin-share.nix;
pinnwand = runTest ./pinnwand.nix;
- plantuml-server = handleTest ./plantuml-server.nix { };
- plasma-bigscreen = handleTest ./plasma-bigscreen.nix { };
- plasma5 = handleTest ./plasma5.nix { };
- plasma6 = handleTest ./plasma6.nix { };
- plasma5-systemd-start = handleTest ./plasma5-systemd-start.nix { };
- plausible = handleTest ./plausible.nix { };
- playwright-python = handleTest ./playwright-python.nix { };
- please = handleTest ./please.nix { };
+ plantuml-server = runTest ./plantuml-server.nix;
+ plasma-bigscreen = runTest ./plasma-bigscreen.nix;
+ plasma5 = runTest ./plasma5.nix;
+ plasma6 = runTest ./plasma6.nix;
+ plasma5-systemd-start = runTest ./plasma5-systemd-start.nix;
+ plausible = runTest ./plausible.nix;
+ playwright-python = runTest ./playwright-python.nix;
+ please = runTest ./please.nix;
pleroma = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./pleroma.nix { };
- plikd = handleTest ./plikd.nix { };
- plotinus = handleTest ./plotinus.nix { };
- pocket-id = handleTest ./pocket-id.nix { };
- podgrab = handleTest ./podgrab.nix { };
+ plikd = runTest ./plikd.nix;
+ plotinus = runTest ./plotinus.nix;
+ pocket-id = runTest ./pocket-id.nix;
+ podgrab = runTest ./podgrab.nix;
podman = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./podman/default.nix { };
podman-tls-ghostunnel = handleTestOn [
"aarch64-linux"
"x86_64-linux"
] ./podman/tls-ghostunnel.nix { };
- polaris = handleTest ./polaris.nix { };
+ polaris = runTest ./polaris.nix;
pomerium = handleTestOn [ "x86_64-linux" ] ./pomerium.nix { };
- portunus = handleTest ./portunus.nix { };
+ portunus = runTest ./portunus.nix;
postfix = handleTest ./postfix.nix { };
postfix-raise-smtpd-tls-security-level =
handleTest ./postfix-raise-smtpd-tls-security-level.nix
{ };
- postfixadmin = handleTest ./postfixadmin.nix { };
+ postfixadmin = runTest ./postfixadmin.nix;
postgres-websockets = runTest ./postgres-websockets.nix;
postgresql = handleTest ./postgresql { };
postgrest = runTest ./postgrest.nix;
- powerdns = handleTest ./powerdns.nix { };
+ powerdns = runTest ./powerdns.nix;
powerdns-admin = handleTest ./powerdns-admin.nix { };
- power-profiles-daemon = handleTest ./power-profiles-daemon.nix { };
- pppd = handleTest ./pppd.nix { };
+ power-profiles-daemon = runTest ./power-profiles-daemon.nix;
+ pppd = runTest ./pppd.nix;
predictable-interface-names = handleTest ./predictable-interface-names.nix { };
pretalx = runTest ./web-apps/pretalx.nix;
prefect = runTest ./prefect.nix;
@@ -1118,19 +1118,19 @@ in
_module.args.socket = false;
_module.args.listenTcp = false;
};
- private-gpt = handleTest ./private-gpt.nix { };
+ private-gpt = runTest ./private-gpt.nix;
privatebin = runTest ./privatebin.nix;
- privoxy = handleTest ./privoxy.nix { };
+ privoxy = runTest ./privoxy.nix;
prometheus = import ./prometheus { inherit runTest; };
prometheus-exporters = handleTest ./prometheus-exporters.nix { };
prosody = handleTest ./xmpp/prosody.nix { };
prosody-mysql = handleTest ./xmpp/prosody-mysql.nix { };
- proxy = handleTest ./proxy.nix { };
+ proxy = runTest ./proxy.nix;
prowlarr = runTest ./prowlarr.nix;
- pt2-clone = handleTest ./pt2-clone.nix { };
- pykms = handleTest ./pykms.nix { };
- public-inbox = handleTest ./public-inbox.nix { };
- pufferpanel = handleTest ./pufferpanel.nix { };
+ pt2-clone = runTest ./pt2-clone.nix;
+ pykms = runTest ./pykms.nix;
+ public-inbox = runTest ./public-inbox.nix;
+ pufferpanel = runTest ./pufferpanel.nix;
pulseaudio = discoverTests (import ./pulseaudio.nix);
qboot = handleTestOn [ "x86_64-linux" "i686-linux" ] ./qboot.nix { };
qemu-vm-restrictnetwork = handleTest ./qemu-vm-restrictnetwork.nix { };
@@ -1139,130 +1139,130 @@ in
qemu-vm-store = runTest ./qemu-vm-store.nix;
qgis = handleTest ./qgis.nix { package = pkgs.qgis; };
qgis-ltr = handleTest ./qgis.nix { package = pkgs.qgis-ltr; };
- qownnotes = handleTest ./qownnotes.nix { };
+ qownnotes = runTest ./qownnotes.nix;
qtile = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./qtile/default.nix;
- quake3 = handleTest ./quake3.nix { };
- quicktun = handleTest ./quicktun.nix { };
- quickwit = handleTest ./quickwit.nix { };
- quorum = handleTest ./quorum.nix { };
- rabbitmq = handleTest ./rabbitmq.nix { };
- radarr = handleTest ./radarr.nix { };
- radicale = handleTest ./radicale.nix { };
+ quake3 = runTest ./quake3.nix;
+ quicktun = runTest ./quicktun.nix;
+ quickwit = runTest ./quickwit.nix;
+ quorum = runTest ./quorum.nix;
+ rabbitmq = runTest ./rabbitmq.nix;
+ radarr = runTest ./radarr.nix;
+ radicale = runTest ./radicale.nix;
radicle = runTest ./radicle.nix;
ragnarwm = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ragnarwm.nix;
- rasdaemon = handleTest ./rasdaemon.nix { };
+ rasdaemon = runTest ./rasdaemon.nix;
rathole = runTest ./rathole.nix;
- readarr = handleTest ./readarr.nix { };
- realm = handleTest ./realm.nix { };
+ readarr = runTest ./readarr.nix;
+ realm = runTest ./realm.nix;
readeck = runTest ./readeck.nix;
rebuilderd = runTest ./rebuilderd.nix;
redis = handleTest ./redis.nix { };
- redlib = handleTest ./redlib.nix { };
+ redlib = runTest ./redlib.nix;
redmine = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./redmine.nix { };
- renovate = handleTest ./renovate.nix { };
+ renovate = runTest ./renovate.nix;
replace-dependencies = handleTest ./replace-dependencies { };
reposilite = runTest ./reposilite.nix;
- restartByActivationScript = handleTest ./restart-by-activation-script.nix { };
- restic-rest-server = handleTest ./restic-rest-server.nix { };
- restic = handleTest ./restic.nix { };
- retroarch = handleTest ./retroarch.nix { };
+ restartByActivationScript = runTest ./restart-by-activation-script.nix;
+ restic-rest-server = runTest ./restic-rest-server.nix;
+ restic = runTest ./restic.nix;
+ retroarch = runTest ./retroarch.nix;
rke2 = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./rke2 { };
rkvm = handleTest ./rkvm { };
rmfakecloud = runTest ./rmfakecloud.nix;
- robustirc-bridge = handleTest ./robustirc-bridge.nix { };
- roundcube = handleTest ./roundcube.nix { };
+ robustirc-bridge = runTest ./robustirc-bridge.nix;
+ rosenpass = runTest ./rosenpass.nix;
+ roundcube = runTest ./roundcube.nix;
routinator = handleTest ./routinator.nix { };
- rosenpass = handleTest ./rosenpass.nix { };
rshim = handleTest ./rshim.nix { };
rspamd = handleTest ./rspamd.nix { };
- rspamd-trainer = handleTest ./rspamd-trainer.nix { };
+ rspamd-trainer = runTest ./rspamd-trainer.nix;
rss-bridge = handleTest ./web-apps/rss-bridge { };
rss2email = handleTest ./rss2email.nix { };
- rstudio-server = handleTest ./rstudio-server.nix { };
- rsyncd = handleTest ./rsyncd.nix { };
+ rstudio-server = runTest ./rstudio-server.nix;
+ rsyncd = runTest ./rsyncd.nix;
rsyslogd = handleTest ./rsyslogd.nix { };
rtkit = runTest ./rtkit.nix;
- rtorrent = handleTest ./rtorrent.nix { };
+ rtorrent = runTest ./rtorrent.nix;
rush = runTest ./rush.nix;
- rustls-libssl = handleTest ./rustls-libssl.nix { };
- rxe = handleTest ./rxe.nix { };
- sabnzbd = handleTest ./sabnzbd.nix { };
+ rustls-libssl = runTest ./rustls-libssl.nix;
+ rxe = runTest ./rxe.nix;
+ sabnzbd = runTest ./sabnzbd.nix;
samba = runTest ./samba.nix;
- samba-wsdd = handleTest ./samba-wsdd.nix { };
- sane = handleTest ./sane.nix { };
- sanoid = handleTest ./sanoid.nix { };
- saunafs = handleTest ./saunafs.nix { };
+ samba-wsdd = runTest ./samba-wsdd.nix;
+ sane = runTest ./sane.nix;
+ sanoid = runTest ./sanoid.nix;
+ saunafs = runTest ./saunafs.nix;
scaphandre = handleTest ./scaphandre.nix { };
schleuder = handleTest ./schleuder.nix { };
scion-freestanding-deployment = handleTest ./scion/freestanding-deployment { };
scrutiny = runTest ./scrutiny.nix;
scx = runTest ./scx/default.nix;
sddm = handleTest ./sddm.nix { };
- sdl3 = handleTest ./sdl3.nix { };
- seafile = handleTest ./seafile.nix { };
+ sdl3 = runTest ./sdl3.nix;
+ seafile = runTest ./seafile.nix;
searx = runTest ./searx.nix;
- seatd = handleTest ./seatd.nix { };
+ seatd = runTest ./seatd.nix;
send = runTest ./send.nix;
- service-runner = handleTest ./service-runner.nix { };
+ service-runner = runTest ./service-runner.nix;
servo = runTest ./servo.nix;
shadps4 = runTest ./shadps4.nix;
sftpgo = runTest ./sftpgo.nix;
- sfxr-qt = handleTest ./sfxr-qt.nix { };
- sgt-puzzles = handleTest ./sgt-puzzles.nix { };
- shadow = handleTest ./shadow.nix { };
+ sfxr-qt = runTest ./sfxr-qt.nix;
+ sgt-puzzles = runTest ./sgt-puzzles.nix;
+ shadow = runTest ./shadow.nix;
shadowsocks = handleTest ./shadowsocks { };
- shattered-pixel-dungeon = handleTest ./shattered-pixel-dungeon.nix { };
- shiori = handleTest ./shiori.nix { };
+ shattered-pixel-dungeon = runTest ./shattered-pixel-dungeon.nix;
+ shiori = runTest ./shiori.nix;
signal-desktop = runTest ./signal-desktop.nix;
- silverbullet = handleTest ./silverbullet.nix { };
- simple = handleTest ./simple.nix { };
- sing-box = handleTest ./sing-box.nix { };
- slimserver = handleTest ./slimserver.nix { };
- slurm = handleTest ./slurm.nix { };
- snmpd = handleTest ./snmpd.nix { };
- smokeping = handleTest ./smokeping.nix { };
+ silverbullet = runTest ./silverbullet.nix;
+ simple = runTest ./simple.nix;
+ sing-box = runTest ./sing-box.nix;
+ slimserver = runTest ./slimserver.nix;
+ slurm = runTest ./slurm.nix;
+ snmpd = runTest ./snmpd.nix;
+ smokeping = runTest ./smokeping.nix;
snapcast = runTest ./snapcast.nix;
- snapper = handleTest ./snapper.nix { };
+ snapper = runTest ./snapper.nix;
snipe-it = runTest ./web-apps/snipe-it.nix;
- soapui = handleTest ./soapui.nix { };
- soft-serve = handleTest ./soft-serve.nix { };
- sogo = handleTest ./sogo.nix { };
- soju = handleTest ./soju.nix { };
- solanum = handleTest ./solanum.nix { };
- sonarr = handleTest ./sonarr.nix { };
- sonic-server = handleTest ./sonic-server.nix { };
+ soapui = runTest ./soapui.nix;
+ soft-serve = runTest ./soft-serve.nix;
+ sogo = runTest ./sogo.nix;
+ soju = runTest ./soju.nix;
+ solanum = runTest ./solanum.nix;
+ sonarr = runTest ./sonarr.nix;
+ sonic-server = runTest ./sonic-server.nix;
sourcehut = handleTest ./sourcehut { };
- spacecookie = handleTest ./spacecookie.nix { };
+ spacecookie = runTest ./spacecookie.nix;
spark = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./spark { };
spiped = runTest ./spiped.nix;
- sqlite3-to-mysql = handleTest ./sqlite3-to-mysql.nix { };
- squid = handleTest ./squid.nix { };
+ sqlite3-to-mysql = runTest ./sqlite3-to-mysql.nix;
+ squid = runTest ./squid.nix;
sslh = handleTest ./sslh.nix { };
- ssh-agent-auth = handleTest ./ssh-agent-auth.nix { };
- ssh-audit = handleTest ./ssh-audit.nix { };
+ ssh-agent-auth = runTest ./ssh-agent-auth.nix;
+ ssh-audit = runTest ./ssh-audit.nix;
sssd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd.nix { };
sssd-ldap = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd-ldap.nix { };
- stalwart-mail = handleTest ./stalwart-mail.nix { };
+ stalwart-mail = runTest ./stalwart-mail.nix;
stargazer = runTest ./web-servers/stargazer.nix;
starship = runTest ./starship.nix;
stash = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./stash.nix { };
static-web-server = runTest ./web-servers/static-web-server.nix;
step-ca = handleTestOn [ "x86_64-linux" ] ./step-ca.nix { };
stratis = handleTest ./stratis { };
- strongswan-swanctl = handleTest ./strongswan-swanctl.nix { };
+ strongswan-swanctl = runTest ./strongswan-swanctl.nix;
stub-ld = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./stub-ld.nix { };
stunnel = handleTest ./stunnel.nix { };
- sudo = handleTest ./sudo.nix { };
+ sudo = runTest ./sudo.nix;
sudo-rs = runTest ./sudo-rs.nix;
- sunshine = handleTest ./sunshine.nix { };
- suricata = handleTest ./suricata.nix { };
+ sunshine = runTest ./sunshine.nix;
+ suricata = runTest ./suricata.nix;
suwayomi-server = handleTest ./suwayomi-server.nix { };
- swap-file-btrfs = handleTest ./swap-file-btrfs.nix { };
- swap-partition = handleTest ./swap-partition.nix { };
- swap-random-encryption = handleTest ./swap-random-encryption.nix { };
+ swap-file-btrfs = runTest ./swap-file-btrfs.nix;
+ swap-partition = runTest ./swap-partition.nix;
+ swap-random-encryption = runTest ./swap-random-encryption.nix;
swapspace = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./swapspace.nix { };
- sway = handleTest ./sway.nix { };
- swayfx = handleTest ./swayfx.nix { };
+ sway = runTest ./sway.nix;
+ swayfx = runTest ./swayfx.nix;
switchTest = runTest {
imports = [ ./switch-test.nix ];
defaults.system.switch.enableNg = false;
@@ -1271,160 +1271,160 @@ in
imports = [ ./switch-test.nix ];
defaults.system.switch.enableNg = true;
};
- sx = handleTest ./sx.nix { };
- sympa = handleTest ./sympa.nix { };
- syncthing = handleTest ./syncthing.nix { };
- syncthing-no-settings = handleTest ./syncthing-no-settings.nix { };
- syncthing-init = handleTest ./syncthing-init.nix { };
- syncthing-many-devices = handleTest ./syncthing-many-devices.nix { };
+ sx = runTest ./sx.nix;
+ sympa = runTest ./sympa.nix;
+ syncthing = runTest ./syncthing.nix;
+ syncthing-no-settings = runTest ./syncthing-no-settings.nix;
+ syncthing-init = runTest ./syncthing-init.nix;
+ syncthing-many-devices = runTest ./syncthing-many-devices.nix;
syncthing-folders = runTest ./syncthing-folders.nix;
- syncthing-relay = handleTest ./syncthing-relay.nix { };
+ syncthing-relay = runTest ./syncthing-relay.nix;
sysinit-reactivation = runTest ./sysinit-reactivation.nix;
- systemd = handleTest ./systemd.nix { };
- systemd-analyze = handleTest ./systemd-analyze.nix { };
+ systemd = runTest ./systemd.nix;
+ systemd-analyze = runTest ./systemd-analyze.nix;
systemd-binfmt = handleTestOn [ "x86_64-linux" ] ./systemd-binfmt.nix { };
systemd-boot = handleTest ./systemd-boot.nix { };
- systemd-bpf = handleTest ./systemd-bpf.nix { };
+ systemd-bpf = runTest ./systemd-bpf.nix;
systemd-confinement = handleTest ./systemd-confinement { };
- systemd-coredump = handleTest ./systemd-coredump.nix { };
- systemd-cryptenroll = handleTest ./systemd-cryptenroll.nix { };
- systemd-credentials-tpm2 = handleTest ./systemd-credentials-tpm2.nix { };
- systemd-escaping = handleTest ./systemd-escaping.nix { };
- systemd-initrd-bridge = handleTest ./systemd-initrd-bridge.nix { };
- systemd-initrd-btrfs-raid = handleTest ./systemd-initrd-btrfs-raid.nix { };
- systemd-initrd-luks-fido2 = handleTest ./systemd-initrd-luks-fido2.nix { };
- systemd-initrd-luks-keyfile = handleTest ./systemd-initrd-luks-keyfile.nix { };
+ systemd-coredump = runTest ./systemd-coredump.nix;
+ systemd-cryptenroll = runTest ./systemd-cryptenroll.nix;
+ systemd-credentials-tpm2 = runTest ./systemd-credentials-tpm2.nix;
+ systemd-escaping = runTest ./systemd-escaping.nix;
+ systemd-initrd-bridge = runTest ./systemd-initrd-bridge.nix;
+ systemd-initrd-btrfs-raid = runTest ./systemd-initrd-btrfs-raid.nix;
+ systemd-initrd-luks-fido2 = runTest ./systemd-initrd-luks-fido2.nix;
+ systemd-initrd-luks-keyfile = runTest ./systemd-initrd-luks-keyfile.nix;
systemd-initrd-luks-empty-passphrase = handleTest ./initrd-luks-empty-passphrase.nix {
systemdStage1 = true;
};
- systemd-initrd-luks-password = handleTest ./systemd-initrd-luks-password.nix { };
- systemd-initrd-luks-tpm2 = handleTest ./systemd-initrd-luks-tpm2.nix { };
- systemd-initrd-luks-unl0kr = handleTest ./systemd-initrd-luks-unl0kr.nix { };
- systemd-initrd-modprobe = handleTest ./systemd-initrd-modprobe.nix { };
- systemd-initrd-shutdown = handleTest ./systemd-shutdown.nix { systemdStage1 = true; };
- systemd-initrd-simple = runTest ./systemd-initrd-simple.nix;
- systemd-initrd-swraid = handleTest ./systemd-initrd-swraid.nix { };
- systemd-initrd-vconsole = handleTest ./systemd-initrd-vconsole.nix { };
+ systemd-initrd-luks-password = runTest ./systemd-initrd-luks-password.nix;
+ systemd-initrd-luks-tpm2 = runTest ./systemd-initrd-luks-tpm2.nix;
+ systemd-initrd-luks-unl0kr = runTest ./systemd-initrd-luks-unl0kr.nix;
+ systemd-initrd-modprobe = runTest ./systemd-initrd-modprobe.nix;
systemd-initrd-networkd = handleTest ./systemd-initrd-networkd.nix { };
- systemd-initrd-networkd-ssh = handleTest ./systemd-initrd-networkd-ssh.nix { };
+ systemd-initrd-networkd-ssh = runTest ./systemd-initrd-networkd-ssh.nix;
systemd-initrd-networkd-openvpn = handleTestOn [
"x86_64-linux"
"i686-linux"
] ./initrd-network-openvpn { systemdStage1 = true; };
- systemd-initrd-vlan = handleTest ./systemd-initrd-vlan.nix { };
- systemd-journal = handleTest ./systemd-journal.nix { };
- systemd-journal-gateway = handleTest ./systemd-journal-gateway.nix { };
- systemd-journal-upload = handleTest ./systemd-journal-upload.nix { };
+ systemd-initrd-shutdown = handleTest ./systemd-shutdown.nix { systemdStage1 = true; };
+ systemd-initrd-simple = runTest ./systemd-initrd-simple.nix;
+ systemd-initrd-swraid = runTest ./systemd-initrd-swraid.nix;
+ systemd-initrd-vconsole = runTest ./systemd-initrd-vconsole.nix;
+ systemd-initrd-vlan = runTest ./systemd-initrd-vlan.nix;
+ systemd-journal = runTest ./systemd-journal.nix;
+ systemd-journal-gateway = runTest ./systemd-journal-gateway.nix;
+ systemd-journal-upload = runTest ./systemd-journal-upload.nix;
systemd-lock-handler = runTestOn [ "aarch64-linux" "x86_64-linux" ] ./systemd-lock-handler.nix;
- systemd-machinectl = handleTest ./systemd-machinectl.nix { };
- systemd-networkd = handleTest ./systemd-networkd.nix { };
- systemd-networkd-bridge = handleTest ./systemd-networkd-bridge.nix { };
- systemd-networkd-dhcpserver = handleTest ./systemd-networkd-dhcpserver.nix { };
+ systemd-machinectl = runTest ./systemd-machinectl.nix;
+ systemd-networkd = runTest ./systemd-networkd.nix;
+ systemd-networkd-bridge = runTest ./systemd-networkd-bridge.nix;
+ systemd-networkd-dhcpserver = runTest ./systemd-networkd-dhcpserver.nix;
systemd-networkd-dhcpserver-static-leases =
handleTest ./systemd-networkd-dhcpserver-static-leases.nix
{ };
systemd-networkd-ipv6-prefix-delegation =
handleTest ./systemd-networkd-ipv6-prefix-delegation.nix
{ };
- systemd-networkd-vrf = handleTest ./systemd-networkd-vrf.nix { };
- systemd-no-tainted = handleTest ./systemd-no-tainted.nix { };
- systemd-nspawn = handleTest ./systemd-nspawn.nix { };
- systemd-nspawn-configfile = handleTest ./systemd-nspawn-configfile.nix { };
- systemd-oomd = handleTest ./systemd-oomd.nix { };
- systemd-portabled = handleTest ./systemd-portabled.nix { };
+ systemd-networkd-vrf = runTest ./systemd-networkd-vrf.nix;
+ systemd-no-tainted = runTest ./systemd-no-tainted.nix;
+ systemd-nspawn = runTest ./systemd-nspawn.nix;
+ systemd-nspawn-configfile = runTest ./systemd-nspawn-configfile.nix;
+ systemd-oomd = runTest ./systemd-oomd.nix;
+ systemd-portabled = runTest ./systemd-portabled.nix;
systemd-repart = handleTest ./systemd-repart.nix { };
- systemd-resolved = handleTest ./systemd-resolved.nix { };
+ systemd-resolved = runTest ./systemd-resolved.nix;
systemd-ssh-proxy = runTest ./systemd-ssh-proxy.nix;
- systemd-shutdown = handleTest ./systemd-shutdown.nix { };
+ systemd-shutdown = runTest ./systemd-shutdown.nix;
systemd-sysupdate = runTest ./systemd-sysupdate.nix;
systemd-sysusers-mutable = runTest ./systemd-sysusers-mutable.nix;
systemd-sysusers-immutable = runTest ./systemd-sysusers-immutable.nix;
systemd-sysusers-password-option-override-ordering = runTest ./systemd-sysusers-password-option-override-ordering.nix;
- systemd-timesyncd = handleTest ./systemd-timesyncd.nix { };
- systemd-timesyncd-nscd-dnssec = handleTest ./systemd-timesyncd-nscd-dnssec.nix { };
- systemd-user-linger = handleTest ./systemd-user-linger.nix { };
- systemd-user-tmpfiles-rules = handleTest ./systemd-user-tmpfiles-rules.nix { };
- systemd-misc = handleTest ./systemd-misc.nix { };
- systemd-userdbd = handleTest ./systemd-userdbd.nix { };
- systemd-homed = handleTest ./systemd-homed.nix { };
+ systemd-timesyncd = runTest ./systemd-timesyncd.nix;
+ systemd-timesyncd-nscd-dnssec = runTest ./systemd-timesyncd-nscd-dnssec.nix;
+ systemd-user-linger = runTest ./systemd-user-linger.nix;
+ systemd-user-tmpfiles-rules = runTest ./systemd-user-tmpfiles-rules.nix;
+ systemd-misc = runTest ./systemd-misc.nix;
+ systemd-userdbd = runTest ./systemd-userdbd.nix;
+ systemd-homed = runTest ./systemd-homed.nix;
systemtap = handleTest ./systemtap.nix { };
startx = import ./startx.nix { inherit pkgs runTest; };
taler = handleTest ./taler { };
- tandoor-recipes = handleTest ./tandoor-recipes.nix { };
- tandoor-recipes-script-name = handleTest ./tandoor-recipes-script-name.nix { };
- tang = handleTest ./tang.nix { };
- taskserver = handleTest ./taskserver.nix { };
- taskchampion-sync-server = handleTest ./taskchampion-sync-server.nix { };
- tayga = handleTest ./tayga.nix { };
- technitium-dns-server = handleTest ./technitium-dns-server.nix { };
- teeworlds = handleTest ./teeworlds.nix { };
+ tandoor-recipes = runTest ./tandoor-recipes.nix;
+ tandoor-recipes-script-name = runTest ./tandoor-recipes-script-name.nix;
+ tang = runTest ./tang.nix;
+ taskserver = runTest ./taskserver.nix;
+ taskchampion-sync-server = runTest ./taskchampion-sync-server.nix;
+ tayga = runTest ./tayga.nix;
+ technitium-dns-server = runTest ./technitium-dns-server.nix;
+ teeworlds = runTest ./teeworlds.nix;
telegraf = runTest ./telegraf.nix;
teleport = handleTest ./teleport.nix { };
teleports = runTest ./teleports.nix;
thelounge = handleTest ./thelounge.nix { };
terminal-emulators = handleTest ./terminal-emulators.nix { };
thanos = handleTest ./thanos.nix { };
- tiddlywiki = handleTest ./tiddlywiki.nix { };
+ tiddlywiki = runTest ./tiddlywiki.nix;
tigervnc = handleTest ./tigervnc.nix { };
tika = runTest ./tika.nix;
- timezone = handleTest ./timezone.nix { };
+ timezone = runTest ./timezone.nix;
timidity = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./timidity { };
tinc = handleTest ./tinc { };
- tinydns = handleTest ./tinydns.nix { };
- tinyproxy = handleTest ./tinyproxy.nix { };
- tinywl = handleTest ./tinywl.nix { };
- tmate-ssh-server = handleTest ./tmate-ssh-server.nix { };
- tomcat = handleTest ./tomcat.nix { };
- tor = handleTest ./tor.nix { };
+ tinydns = runTest ./tinydns.nix;
+ tinyproxy = runTest ./tinyproxy.nix;
+ tinywl = runTest ./tinywl.nix;
+ tmate-ssh-server = runTest ./tmate-ssh-server.nix;
+ tomcat = runTest ./tomcat.nix;
+ tor = runTest ./tor.nix;
tpm-ek = handleTest ./tpm-ek { };
traefik = runTestOn [ "aarch64-linux" "x86_64-linux" ] ./traefik.nix;
- trafficserver = handleTest ./trafficserver.nix { };
- transfer-sh = handleTest ./transfer-sh.nix { };
+ trafficserver = runTest ./trafficserver.nix;
+ transfer-sh = runTest ./transfer-sh.nix;
transmission_3 = handleTest ./transmission.nix { transmission = pkgs.transmission_3; };
transmission_4 = handleTest ./transmission.nix { transmission = pkgs.transmission_4; };
# tracee requires bpf
tracee = handleTestOn [ "x86_64-linux" ] ./tracee.nix { };
- trezord = handleTest ./trezord.nix { };
- trickster = handleTest ./trickster.nix { };
+ trezord = runTest ./trezord.nix;
+ trickster = runTest ./trickster.nix;
trilium-server = handleTestOn [ "x86_64-linux" ] ./trilium-server.nix { };
- tsm-client-gui = handleTest ./tsm-client-gui.nix { };
- ttyd = handleTest ./web-servers/ttyd.nix { };
- tt-rss = handleTest ./web-apps/tt-rss.nix { };
- txredisapi = handleTest ./txredisapi.nix { };
- tuptime = handleTest ./tuptime.nix { };
- turbovnc-headless-server = handleTest ./turbovnc-headless-server.nix { };
- turn-rs = handleTest ./turn-rs.nix { };
+ tsm-client-gui = runTest ./tsm-client-gui.nix;
+ ttyd = runTest ./web-servers/ttyd.nix;
+ tt-rss = runTest ./web-apps/tt-rss.nix;
+ txredisapi = runTest ./txredisapi.nix;
+ tuptime = runTest ./tuptime.nix;
+ turbovnc-headless-server = runTest ./turbovnc-headless-server.nix;
+ turn-rs = runTest ./turn-rs.nix;
tusd = runTest ./tusd/default.nix;
tuxguitar = runTest ./tuxguitar.nix;
twingate = runTest ./twingate.nix;
- typesense = handleTest ./typesense.nix { };
+ typesense = runTest ./typesense.nix;
tzupdate = runTest ./tzupdate.nix;
- ucarp = handleTest ./ucarp.nix { };
- udisks2 = handleTest ./udisks2.nix { };
- ulogd = handleTest ./ulogd/ulogd.nix { };
- umurmur = handleTest ./umurmur.nix { };
- unbound = handleTest ./unbound.nix { };
+ ucarp = runTest ./ucarp.nix;
+ udisks2 = runTest ./udisks2.nix;
+ ulogd = runTest ./ulogd/ulogd.nix;
+ umurmur = runTest ./umurmur.nix;
+ unbound = runTest ./unbound.nix;
unifi = runTest ./unifi.nix;
unit-php = runTest ./web-servers/unit-php.nix;
- unit-perl = handleTest ./web-servers/unit-perl.nix { };
+ unit-perl = runTest ./web-servers/unit-perl.nix;
upnp.iptables = handleTest ./upnp.nix { useNftables = false; };
upnp.nftables = handleTest ./upnp.nix { useNftables = true; };
- uptermd = handleTest ./uptermd.nix { };
- uptime-kuma = handleTest ./uptime-kuma.nix { };
- urn-timer = handleTest ./urn-timer.nix { };
- usbguard = handleTest ./usbguard.nix { };
+ uptermd = runTest ./uptermd.nix;
+ uptime-kuma = runTest ./uptime-kuma.nix;
+ urn-timer = runTest ./urn-timer.nix;
+ usbguard = runTest ./usbguard.nix;
userborn = runTest ./userborn.nix;
userborn-mutable-users = runTest ./userborn-mutable-users.nix;
userborn-immutable-users = runTest ./userborn-immutable-users.nix;
userborn-mutable-etc = runTest ./userborn-mutable-etc.nix;
userborn-immutable-etc = runTest ./userborn-immutable-etc.nix;
- user-activation-scripts = handleTest ./user-activation-scripts.nix { };
+ user-activation-scripts = runTest ./user-activation-scripts.nix;
user-enable-option = runTest ./user-enable-option.nix;
user-expiry = runTest ./user-expiry.nix;
- user-home-mode = handleTest ./user-home-mode.nix { };
- ustreamer = handleTest ./ustreamer.nix { };
- uwsgi = handleTest ./uwsgi.nix { };
- v2ray = handleTest ./v2ray.nix { };
+ user-home-mode = runTest ./user-home-mode.nix;
+ ustreamer = runTest ./ustreamer.nix;
+ uwsgi = runTest ./uwsgi.nix;
+ v2ray = runTest ./v2ray.nix;
varnish60 = runTest {
imports = [ ./varnish.nix ];
_module.args.package = pkgs.varnish60;
@@ -1433,43 +1433,43 @@ in
imports = [ ./varnish.nix ];
_module.args.package = pkgs.varnish77;
};
- vault = handleTest ./vault.nix { };
- vault-agent = handleTest ./vault-agent.nix { };
- vault-dev = handleTest ./vault-dev.nix { };
- vault-postgresql = handleTest ./vault-postgresql.nix { };
+ vault = runTest ./vault.nix;
+ vault-agent = runTest ./vault-agent.nix;
+ vault-dev = runTest ./vault-dev.nix;
+ vault-postgresql = runTest ./vault-postgresql.nix;
vaultwarden = discoverTests (import ./vaultwarden.nix);
- vdirsyncer = handleTest ./vdirsyncer.nix { };
+ vdirsyncer = runTest ./vdirsyncer.nix;
vector = handleTest ./vector { };
velocity = runTest ./velocity.nix;
- vengi-tools = handleTest ./vengi-tools.nix { };
+ vengi-tools = runTest ./vengi-tools.nix;
victoriametrics = handleTest ./victoriametrics { };
- vikunja = handleTest ./vikunja.nix { };
+ vikunja = runTest ./vikunja.nix;
virtualbox = handleTestOn [ "x86_64-linux" ] ./virtualbox.nix { };
vm-variant = handleTest ./vm-variant.nix { };
vscode-remote-ssh = handleTestOn [ "x86_64-linux" ] ./vscode-remote-ssh.nix { };
vscodium = discoverTests (import ./vscodium.nix);
- vsftpd = handleTest ./vsftpd.nix { };
- waagent = handleTest ./waagent.nix { };
+ vsftpd = runTest ./vsftpd.nix;
+ waagent = runTest ./waagent.nix;
wakapi = runTest ./wakapi.nix;
- warzone2100 = handleTest ./warzone2100.nix { };
- wasabibackend = handleTest ./wasabibackend.nix { };
+ warzone2100 = runTest ./warzone2100.nix;
+ wasabibackend = runTest ./wasabibackend.nix;
wastebin = runTest ./wastebin.nix;
- watchdogd = handleTest ./watchdogd.nix { };
+ watchdogd = runTest ./watchdogd.nix;
webhook = runTest ./webhook.nix;
- weblate = handleTest ./web-apps/weblate.nix { };
- whisparr = handleTest ./whisparr.nix { };
+ weblate = runTest ./web-apps/weblate.nix;
+ whisparr = runTest ./whisparr.nix;
whoami = runTest ./whoami.nix;
- whoogle-search = handleTest ./whoogle-search.nix { };
+ whoogle-search = runTest ./whoogle-search.nix;
wiki-js = runTest ./wiki-js.nix;
wine = handleTest ./wine.nix { };
wireguard = handleTest ./wireguard { };
- wg-access-server = handleTest ./wg-access-server.nix { };
- without-nix = handleTest ./without-nix.nix { };
- wmderland = handleTest ./wmderland.nix { };
- workout-tracker = handleTest ./workout-tracker.nix { };
+ wg-access-server = runTest ./wg-access-server.nix;
+ without-nix = runTest ./without-nix.nix;
+ wmderland = runTest ./wmderland.nix;
+ workout-tracker = runTest ./workout-tracker.nix;
wpa_supplicant = import ./wpa_supplicant.nix { inherit pkgs runTest; };
wordpress = runTest ./wordpress.nix;
- wrappers = handleTest ./wrappers.nix { };
+ wrappers = runTest ./wrappers.nix;
writefreely = import ./web-apps/writefreely.nix { inherit pkgs runTest; };
wstunnel = runTest ./wstunnel.nix;
xandikos = runTest ./xandikos.nix;
diff --git a/nixos/tests/ax25.nix b/nixos/tests/ax25.nix
index f1092d5de101..df4e3de04cb1 100644
--- a/nixos/tests/ax25.nix
+++ b/nixos/tests/ax25.nix
@@ -1,131 +1,128 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
+{ pkgs, lib, ... }:
- baud = 57600;
- tty = "/dev/ttyACM0";
- port = "tnc0";
- socatPort = 1234;
+let
+ baud = 57600;
+ tty = "/dev/ttyACM0";
+ port = "tnc0";
+ socatPort = 1234;
- createAX25Node = nodeId: {
+ createAX25Node = nodeId: {
+ boot.kernelPackages = pkgs.linuxPackages_ham;
+ boot.kernelModules = [ "ax25" ];
- boot.kernelPackages = pkgs.linuxPackages_ham;
- boot.kernelModules = [ "ax25" ];
+ networking.firewall.allowedTCPPorts = [ socatPort ];
- networking.firewall.allowedTCPPorts = [ socatPort ];
+ environment.systemPackages = with pkgs; [
+ libax25
+ ax25-tools
+ ax25-apps
+ socat
+ ];
- environment.systemPackages = with pkgs; [
- libax25
- ax25-tools
- ax25-apps
- socat
+ services.ax25.axports."${port}" = {
+ inherit baud tty;
+ enable = true;
+ callsign = "NOCALL-${toString nodeId}";
+ description = "mocked tnc";
+ };
+
+ services.ax25.axlisten = {
+ enable = true;
+ };
+
+ # All mocks radios will connect back to socat-broker on node 1 in order to get
+ # all messages that are "broadcasted over the ether"
+ systemd.services.ax25-mock-hardware = {
+ description = "mock AX.25 TNC and Radio";
+ wantedBy = [ "default.target" ];
+ before = [
+ "ax25-kissattach-${port}.service"
+ "axlisten.service"
];
-
- services.ax25.axports."${port}" = {
- inherit baud tty;
- enable = true;
- callsign = "NOCALL-${toString nodeId}";
- description = "mocked tnc";
- };
-
- services.ax25.axlisten = {
- enable = true;
- };
-
- # All mocks radios will connect back to socat-broker on node 1 in order to get
- # all messages that are "broadcasted over the ether"
- systemd.services.ax25-mock-hardware = {
- description = "mock AX.25 TNC and Radio";
- wantedBy = [ "default.target" ];
- before = [
- "ax25-kissattach-${port}.service"
- "axlisten.service"
- ];
- after = [ "network.target" ];
- serviceConfig = {
- Type = "exec";
- ExecStart = "${pkgs.socat}/bin/socat -d -d tcp:192.168.1.1:${toString socatPort} pty,link=${tty},b${toString baud},raw";
- };
+ after = [ "network.target" ];
+ serviceConfig = {
+ Type = "exec";
+ ExecStart = "${pkgs.socat}/bin/socat -d -d tcp:192.168.1.1:${toString socatPort} pty,link=${tty},b${toString baud},raw";
};
};
- in
- {
- name = "ax25Simple";
- nodes = {
- node1 = lib.mkMerge [
- (createAX25Node 1)
- # mimicking radios on the same frequency
- {
- systemd.services.ax25-mock-ether = {
- description = "mock radio ether";
- wantedBy = [ "default.target" ];
- requires = [ "network.target" ];
- before = [ "ax25-mock-hardware.service" ];
- # broken needs access to "ss" or "netstat"
- path = [ pkgs.iproute2 ];
- serviceConfig = {
- Type = "exec";
- ExecStart = "${pkgs.socat}/bin/socat-broker.sh tcp4-listen:${toString socatPort}";
- };
- postStart = "${pkgs.coreutils}/bin/sleep 2";
+ };
+in
+{
+ name = "ax25Simple";
+ nodes = {
+ node1 = lib.mkMerge [
+ (createAX25Node 1)
+ # mimicking radios on the same frequency
+ {
+ systemd.services.ax25-mock-ether = {
+ description = "mock radio ether";
+ wantedBy = [ "default.target" ];
+ requires = [ "network.target" ];
+ before = [ "ax25-mock-hardware.service" ];
+ # broken needs access to "ss" or "netstat"
+ path = [ pkgs.iproute2 ];
+ serviceConfig = {
+ Type = "exec";
+ ExecStart = "${pkgs.socat}/bin/socat-broker.sh tcp4-listen:${toString socatPort}";
};
- }
- ];
- node2 = createAX25Node 2;
- node3 = createAX25Node 3;
- };
- testScript =
- { ... }:
- ''
- def wait_for_machine(m):
- m.succeed("lsmod | grep ax25")
- m.wait_for_unit("ax25-axports.target")
- m.wait_for_unit("axlisten.service")
- m.fail("journalctl -o cat -u axlisten.service | grep -i \"no AX.25 port data configured\"")
+ postStart = "${pkgs.coreutils}/bin/sleep 2";
+ };
+ }
+ ];
+ node2 = createAX25Node 2;
+ node3 = createAX25Node 3;
+ };
+ testScript =
+ { ... }:
+ ''
+ def wait_for_machine(m):
+ m.succeed("lsmod | grep ax25")
+ m.wait_for_unit("ax25-axports.target")
+ m.wait_for_unit("axlisten.service")
+ m.fail("journalctl -o cat -u axlisten.service | grep -i \"no AX.25 port data configured\"")
- # start the first node since the socat-broker needs to be running
- node1.start()
- node1.wait_for_unit("ax25-mock-ether.service")
- wait_for_machine(node1)
+ # start the first node since the socat-broker needs to be running
+ node1.start()
+ node1.wait_for_unit("ax25-mock-ether.service")
+ wait_for_machine(node1)
- node2.start()
- node3.start()
- wait_for_machine(node2)
- wait_for_machine(node3)
+ node2.start()
+ node3.start()
+ wait_for_machine(node2)
+ wait_for_machine(node3)
- # Node 1 -> Node 2
- node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-2")
- node2.sleep(1)
- node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-2 ctl I00\" | grep hello")
+ # Node 1 -> Node 2
+ node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-2")
+ node2.sleep(1)
+ node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-2 ctl I00\" | grep hello")
- # Node 1 -> Node 3
- node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-3")
- node3.sleep(1)
- node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-3 ctl I00\" | grep hello")
+ # Node 1 -> Node 3
+ node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-3")
+ node3.sleep(1)
+ node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-3 ctl I00\" | grep hello")
- # Node 2 -> Node 1
- # must sleep due to previous ax25_call lingering
- node2.sleep(5)
- node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-1")
- node1.sleep(1)
- node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-1 ctl I00\" | grep hello")
+ # Node 2 -> Node 1
+ # must sleep due to previous ax25_call lingering
+ node2.sleep(5)
+ node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-1")
+ node1.sleep(1)
+ node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-1 ctl I00\" | grep hello")
- # Node 2 -> Node 3
- node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-3")
- node3.sleep(1)
- node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-3 ctl I00\" | grep hello")
+ # Node 2 -> Node 3
+ node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-3")
+ node3.sleep(1)
+ node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-3 ctl I00\" | grep hello")
- # Node 3 -> Node 1
- # must sleep due to previous ax25_call lingering
- node3.sleep(5)
- node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-1")
- node1.sleep(1)
- node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-1 ctl I00\" | grep hello")
+ # Node 3 -> Node 1
+ # must sleep due to previous ax25_call lingering
+ node3.sleep(5)
+ node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-1")
+ node1.sleep(1)
+ node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-1 ctl I00\" | grep hello")
- # Node 3 -> Node 2
- node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-2")
- node2.sleep(1)
- node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-2 ctl I00\" | grep hello")
- '';
- }
-)
+ # Node 3 -> Node 2
+ node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-2")
+ node2.sleep(1)
+ node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-2 ctl I00\" | grep hello")
+ '';
+}
diff --git a/nixos/tests/benchexec.nix b/nixos/tests/benchexec.nix
index 218bfb5afba4..25e53179bf5a 100644
--- a/nixos/tests/benchexec.nix
+++ b/nixos/tests/benchexec.nix
@@ -1,64 +1,62 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- user = "alice";
- in
- {
- name = "benchexec";
+{ pkgs, lib, ... }:
+let
+ user = "alice";
+in
+{
+ name = "benchexec";
- nodes.benchexec = {
- imports = [ ./common/user-account.nix ];
+ nodes.benchexec = {
+ imports = [ ./common/user-account.nix ];
- programs.benchexec = {
- enable = true;
- users = [ user ];
- };
- };
-
- testScript =
- { ... }:
- let
- runexec = lib.getExe' pkgs.benchexec "runexec";
- echo = builtins.toString pkgs.benchexec;
- test = lib.getExe (
- pkgs.writeShellApplication rec {
- name = "test";
- meta.mainProgram = name;
- text = "echo '${echo}'";
- }
- );
- wd = "/tmp";
- stdout = "${wd}/runexec.out";
- stderr = "${wd}/runexec.err";
- in
- ''
- start_all()
- machine.wait_for_unit("multi-user.target")
- benchexec.succeed(''''\
- systemd-run \
- --property='StandardOutput=file:${stdout}' \
- --property='StandardError=file:${stderr}' \
- --unit=runexec --wait --user --machine='${user}@' \
- --working-directory ${wd} \
- '${runexec}' \
- --debug \
- --read-only-dir / \
- --hidden-dir /home \
- '${test}' \
- '''')
- benchexec.succeed("grep -s '${echo}' ${wd}/output.log")
- benchexec.succeed("test \"$(grep -Ec '((start|wall|cpu)time|memory)=' ${stdout})\" = 4")
- benchexec.succeed("! grep -E '(WARNING|ERROR)' ${stderr}")
- '';
-
- interactive.nodes.benchexec.services.kmscon = {
+ programs.benchexec = {
enable = true;
- fonts = [
- {
- name = "Fira Code";
- package = pkgs.fira-code;
- }
- ];
+ users = [ user ];
};
- }
-)
+ };
+
+ testScript =
+ { ... }:
+ let
+ runexec = lib.getExe' pkgs.benchexec "runexec";
+ echo = builtins.toString pkgs.benchexec;
+ test = lib.getExe (
+ pkgs.writeShellApplication rec {
+ name = "test";
+ meta.mainProgram = name;
+ text = "echo '${echo}'";
+ }
+ );
+ wd = "/tmp";
+ stdout = "${wd}/runexec.out";
+ stderr = "${wd}/runexec.err";
+ in
+ ''
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ benchexec.succeed(''''\
+ systemd-run \
+ --property='StandardOutput=file:${stdout}' \
+ --property='StandardError=file:${stderr}' \
+ --unit=runexec --wait --user --machine='${user}@' \
+ --working-directory ${wd} \
+ '${runexec}' \
+ --debug \
+ --read-only-dir / \
+ --hidden-dir /home \
+ '${test}' \
+ '''')
+ benchexec.succeed("grep -s '${echo}' ${wd}/output.log")
+ benchexec.succeed("test \"$(grep -Ec '((start|wall|cpu)time|memory)=' ${stdout})\" = 4")
+ benchexec.succeed("! grep -E '(WARNING|ERROR)' ${stderr}")
+ '';
+
+ interactive.nodes.benchexec.services.kmscon = {
+ enable = true;
+ fonts = [
+ {
+ name = "Fira Code";
+ package = pkgs.fira-code;
+ }
+ ];
+ };
+}
diff --git a/nixos/tests/bitcoind.nix b/nixos/tests/bitcoind.nix
index d588e055b14a..a4ec0beb51b5 100644
--- a/nixos/tests/bitcoind.nix
+++ b/nixos/tests/bitcoind.nix
@@ -1,57 +1,55 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "bitcoind";
- meta = with pkgs.lib; {
- maintainers = with maintainers; [ _1000101 ];
- };
+{ pkgs, ... }:
+{
+ name = "bitcoind";
+ meta = with pkgs.lib; {
+ maintainers = with maintainers; [ _1000101 ];
+ };
- nodes.machine =
- { ... }:
- {
- services.bitcoind."mainnet" = {
- enable = true;
- rpc = {
- port = 8332;
- users.rpc.passwordHMAC = "acc2374e5f9ba9e62a5204d3686616cf$53abdba5e67a9005be6a27ca03a93ce09e58854bc2b871523a0d239a72968033";
- users.rpc2.passwordHMAC = "1495e4a3ad108187576c68f7f9b5ddc5$accce0881c74aa01bb8960ff3bdbd39f607fd33178147679e055a4ac35f53225";
- };
- };
-
- environment.etc."test.blank".text = "";
- services.bitcoind."testnet" = {
- enable = true;
- configFile = "/etc/test.blank";
- testnet = true;
- rpc = {
- port = 18332;
- };
- extraCmdlineOptions = [
- "-rpcuser=rpc"
- "-rpcpassword=rpc"
- "-rpcauth=rpc2:1495e4a3ad108187576c68f7f9b5ddc5$accce0881c74aa01bb8960ff3bdbd39f607fd33178147679e055a4ac35f53225"
- ];
+ nodes.machine =
+ { ... }:
+ {
+ services.bitcoind."mainnet" = {
+ enable = true;
+ rpc = {
+ port = 8332;
+ users.rpc.passwordHMAC = "acc2374e5f9ba9e62a5204d3686616cf$53abdba5e67a9005be6a27ca03a93ce09e58854bc2b871523a0d239a72968033";
+ users.rpc2.passwordHMAC = "1495e4a3ad108187576c68f7f9b5ddc5$accce0881c74aa01bb8960ff3bdbd39f607fd33178147679e055a4ac35f53225";
};
};
- testScript = ''
- start_all()
+ environment.etc."test.blank".text = "";
+ services.bitcoind."testnet" = {
+ enable = true;
+ configFile = "/etc/test.blank";
+ testnet = true;
+ rpc = {
+ port = 18332;
+ };
+ extraCmdlineOptions = [
+ "-rpcuser=rpc"
+ "-rpcpassword=rpc"
+ "-rpcauth=rpc2:1495e4a3ad108187576c68f7f9b5ddc5$accce0881c74aa01bb8960ff3bdbd39f607fd33178147679e055a4ac35f53225"
+ ];
+ };
+ };
- machine.wait_for_unit("bitcoind-mainnet.service")
- machine.wait_for_unit("bitcoind-testnet.service")
+ testScript = ''
+ start_all()
- machine.wait_until_succeeds(
- 'curl --fail --user rpc:rpc --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:8332 | grep \'"chain":"main"\' '
- )
- machine.wait_until_succeeds(
- 'curl --fail --user rpc2:rpc2 --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:8332 | grep \'"chain":"main"\' '
- )
- machine.wait_until_succeeds(
- 'curl --fail --user rpc:rpc --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:18332 | grep \'"chain":"test"\' '
- )
- machine.wait_until_succeeds(
- 'curl --fail --user rpc2:rpc2 --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:18332 | grep \'"chain":"test"\' '
- )
- '';
- }
-)
+ machine.wait_for_unit("bitcoind-mainnet.service")
+ machine.wait_for_unit("bitcoind-testnet.service")
+
+ machine.wait_until_succeeds(
+ 'curl --fail --user rpc:rpc --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:8332 | grep \'"chain":"main"\' '
+ )
+ machine.wait_until_succeeds(
+ 'curl --fail --user rpc2:rpc2 --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:8332 | grep \'"chain":"main"\' '
+ )
+ machine.wait_until_succeeds(
+ 'curl --fail --user rpc:rpc --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:18332 | grep \'"chain":"test"\' '
+ )
+ machine.wait_until_succeeds(
+ 'curl --fail --user rpc2:rpc2 --data-binary \'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }\' -H \'content-type: text/plain;\' localhost:18332 | grep \'"chain":"test"\' '
+ )
+ '';
+}
diff --git a/nixos/tests/bittorrent.nix b/nixos/tests/bittorrent.nix
index 83d9168a6fa5..b62eddc4f663 100644
--- a/nixos/tests/bittorrent.nix
+++ b/nixos/tests/bittorrent.nix
@@ -6,199 +6,197 @@
# which only works if the first client successfully uses the UPnP-IGD
# protocol to poke a hole in the NAT.
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
+let
- # Some random file to serve.
- file = pkgs.hello.src;
+ # Some random file to serve.
+ file = pkgs.hello.src;
- internalRouterAddress = "192.168.3.1";
- internalClient1Address = "192.168.3.2";
- externalRouterAddress = "80.100.100.1";
- externalClient2Address = "80.100.100.2";
- externalTrackerAddress = "80.100.100.3";
+ internalRouterAddress = "192.168.3.1";
+ internalClient1Address = "192.168.3.2";
+ externalRouterAddress = "80.100.100.1";
+ externalClient2Address = "80.100.100.2";
+ externalTrackerAddress = "80.100.100.3";
- download-dir = "/var/lib/transmission/Downloads";
- transmissionConfig =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.transmission_3 ];
- services.transmission = {
- enable = true;
- settings = {
- dht-enabled = false;
- message-level = 2;
- inherit download-dir;
- };
+ download-dir = "/var/lib/transmission/Downloads";
+ transmissionConfig =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.transmission_3 ];
+ services.transmission = {
+ enable = true;
+ settings = {
+ dht-enabled = false;
+ message-level = 2;
+ inherit download-dir;
};
};
- in
-
- {
- name = "bittorrent";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- domenkozar
- rob
- bobvanderlinden
- ];
};
+in
- nodes = {
- tracker =
- { pkgs, ... }:
- {
- imports = [ transmissionConfig ];
+{
+ name = "bittorrent";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ domenkozar
+ rob
+ bobvanderlinden
+ ];
+ };
- virtualisation.vlans = [ 1 ];
- networking.firewall.enable = false;
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = externalTrackerAddress;
- prefixLength = 24;
- }
- ];
+ nodes = {
+ tracker =
+ { pkgs, ... }:
+ {
+ imports = [ transmissionConfig ];
- # We need Apache on the tracker to serve the torrents.
- services.httpd = {
- enable = true;
- virtualHosts = {
- "torrentserver.org" = {
- adminAddr = "foo@example.org";
- documentRoot = "/tmp";
- };
+ virtualisation.vlans = [ 1 ];
+ networking.firewall.enable = false;
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = externalTrackerAddress;
+ prefixLength = 24;
+ }
+ ];
+
+ # We need Apache on the tracker to serve the torrents.
+ services.httpd = {
+ enable = true;
+ virtualHosts = {
+ "torrentserver.org" = {
+ adminAddr = "foo@example.org";
+ documentRoot = "/tmp";
};
};
- services.opentracker.enable = true;
};
+ services.opentracker.enable = true;
+ };
- router =
- { pkgs, nodes, ... }:
- {
- virtualisation.vlans = [
- 1
- 2
- ];
- networking.nat.enable = true;
- networking.nat.internalInterfaces = [ "eth2" ];
- networking.nat.externalInterface = "eth1";
- networking.firewall.enable = true;
- networking.firewall.trustedInterfaces = [ "eth2" ];
- networking.interfaces.eth0.ipv4.addresses = [ ];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = externalRouterAddress;
- prefixLength = 24;
- }
- ];
- networking.interfaces.eth2.ipv4.addresses = [
- {
- address = internalRouterAddress;
- prefixLength = 24;
- }
- ];
- services.miniupnpd = {
- enable = true;
- externalInterface = "eth1";
- internalIPs = [ "eth2" ];
- appendConfig = ''
- ext_ip=${externalRouterAddress}
- '';
- };
+ router =
+ { pkgs, nodes, ... }:
+ {
+ virtualisation.vlans = [
+ 1
+ 2
+ ];
+ networking.nat.enable = true;
+ networking.nat.internalInterfaces = [ "eth2" ];
+ networking.nat.externalInterface = "eth1";
+ networking.firewall.enable = true;
+ networking.firewall.trustedInterfaces = [ "eth2" ];
+ networking.interfaces.eth0.ipv4.addresses = [ ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = externalRouterAddress;
+ prefixLength = 24;
+ }
+ ];
+ networking.interfaces.eth2.ipv4.addresses = [
+ {
+ address = internalRouterAddress;
+ prefixLength = 24;
+ }
+ ];
+ services.miniupnpd = {
+ enable = true;
+ externalInterface = "eth1";
+ internalIPs = [ "eth2" ];
+ appendConfig = ''
+ ext_ip=${externalRouterAddress}
+ '';
};
+ };
- client1 =
- { pkgs, nodes, ... }:
- {
- imports = [ transmissionConfig ];
- environment.systemPackages = [ pkgs.miniupnpc ];
+ client1 =
+ { pkgs, nodes, ... }:
+ {
+ imports = [ transmissionConfig ];
+ environment.systemPackages = [ pkgs.miniupnpc ];
- virtualisation.vlans = [ 2 ];
- networking.interfaces.eth0.ipv4.addresses = [ ];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = internalClient1Address;
- prefixLength = 24;
- }
- ];
- networking.defaultGateway = internalRouterAddress;
- networking.firewall.enable = false;
- };
+ virtualisation.vlans = [ 2 ];
+ networking.interfaces.eth0.ipv4.addresses = [ ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = internalClient1Address;
+ prefixLength = 24;
+ }
+ ];
+ networking.defaultGateway = internalRouterAddress;
+ networking.firewall.enable = false;
+ };
- client2 =
- { pkgs, ... }:
- {
- imports = [ transmissionConfig ];
+ client2 =
+ { pkgs, ... }:
+ {
+ imports = [ transmissionConfig ];
- virtualisation.vlans = [ 1 ];
- networking.interfaces.eth0.ipv4.addresses = [ ];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = externalClient2Address;
- prefixLength = 24;
- }
- ];
- networking.firewall.enable = false;
- };
- };
+ virtualisation.vlans = [ 1 ];
+ networking.interfaces.eth0.ipv4.addresses = [ ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = externalClient2Address;
+ prefixLength = 24;
+ }
+ ];
+ networking.firewall.enable = false;
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- start_all()
+ testScript =
+ { nodes, ... }:
+ ''
+ start_all()
- # Wait for network and miniupnpd.
- router.systemctl("start network-online.target")
- router.wait_for_unit("network-online.target")
- router.wait_for_unit("miniupnpd")
+ # Wait for network and miniupnpd.
+ router.systemctl("start network-online.target")
+ router.wait_for_unit("network-online.target")
+ router.wait_for_unit("miniupnpd")
- # Create the torrent.
- tracker.succeed("mkdir ${download-dir}/data")
- tracker.succeed(
- "cp ${file} ${download-dir}/data/test.tar.bz2"
- )
- tracker.succeed(
- "transmission-create ${download-dir}/data/test.tar.bz2 --private --tracker http://${externalTrackerAddress}:6969/announce --outfile /tmp/test.torrent"
- )
- tracker.succeed("chmod 644 /tmp/test.torrent")
+ # Create the torrent.
+ tracker.succeed("mkdir ${download-dir}/data")
+ tracker.succeed(
+ "cp ${file} ${download-dir}/data/test.tar.bz2"
+ )
+ tracker.succeed(
+ "transmission-create ${download-dir}/data/test.tar.bz2 --private --tracker http://${externalTrackerAddress}:6969/announce --outfile /tmp/test.torrent"
+ )
+ tracker.succeed("chmod 644 /tmp/test.torrent")
- # Start the tracker. !!! use a less crappy tracker
- tracker.systemctl("start network-online.target")
- tracker.wait_for_unit("network-online.target")
- tracker.wait_for_unit("opentracker.service")
- tracker.wait_for_open_port(6969)
+ # Start the tracker. !!! use a less crappy tracker
+ tracker.systemctl("start network-online.target")
+ tracker.wait_for_unit("network-online.target")
+ tracker.wait_for_unit("opentracker.service")
+ tracker.wait_for_open_port(6969)
- # Start the initial seeder.
- tracker.succeed(
- "transmission-remote --add /tmp/test.torrent --no-portmap --no-dht --download-dir ${download-dir}/data"
- )
+ # Start the initial seeder.
+ tracker.succeed(
+ "transmission-remote --add /tmp/test.torrent --no-portmap --no-dht --download-dir ${download-dir}/data"
+ )
- # Now we should be able to download from the client behind the NAT.
- tracker.wait_for_unit("httpd")
- client1.systemctl("start network-online.target")
- client1.wait_for_unit("network-online.target")
- client1.succeed("transmission-remote --add http://${externalTrackerAddress}/test.torrent >&2 &")
- client1.wait_for_file("${download-dir}/test.tar.bz2")
- client1.succeed(
- "cmp ${download-dir}/test.tar.bz2 ${file}"
- )
+ # Now we should be able to download from the client behind the NAT.
+ tracker.wait_for_unit("httpd")
+ client1.systemctl("start network-online.target")
+ client1.wait_for_unit("network-online.target")
+ client1.succeed("transmission-remote --add http://${externalTrackerAddress}/test.torrent >&2 &")
+ client1.wait_for_file("${download-dir}/test.tar.bz2")
+ client1.succeed(
+ "cmp ${download-dir}/test.tar.bz2 ${file}"
+ )
- # Bring down the initial seeder.
- tracker.stop_job("transmission")
+ # Bring down the initial seeder.
+ tracker.stop_job("transmission")
- # Now download from the second client. This can only succeed if
- # the first client created a NAT hole in the router.
- client2.systemctl("start network-online.target")
- client2.wait_for_unit("network-online.target")
- client2.succeed(
- "transmission-remote --add http://${externalTrackerAddress}/test.torrent --no-portmap --no-dht >&2 &"
- )
- client2.wait_for_file("${download-dir}/test.tar.bz2")
- client2.succeed(
- "cmp ${download-dir}/test.tar.bz2 ${file}"
- )
- '';
- }
-)
+ # Now download from the second client. This can only succeed if
+ # the first client created a NAT hole in the router.
+ client2.systemctl("start network-online.target")
+ client2.wait_for_unit("network-online.target")
+ client2.succeed(
+ "transmission-remote --add http://${externalTrackerAddress}/test.torrent --no-portmap --no-dht >&2 &"
+ )
+ client2.wait_for_file("${download-dir}/test.tar.bz2")
+ client2.succeed(
+ "cmp ${download-dir}/test.tar.bz2 ${file}"
+ )
+ '';
+}
diff --git a/nixos/tests/blockbook-frontend.nix b/nixos/tests/blockbook-frontend.nix
index 60bc59d8ec8d..bf6d6bb458c4 100644
--- a/nixos/tests/blockbook-frontend.nix
+++ b/nixos/tests/blockbook-frontend.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "blockbook-frontend";
- meta = with pkgs.lib; {
- maintainers = with maintainers; [ _1000101 ];
- };
+{ pkgs, ... }:
+{
+ name = "blockbook-frontend";
+ meta = with pkgs.lib; {
+ maintainers = with maintainers; [ _1000101 ];
+ };
- nodes.machine =
- { ... }:
- {
- services.blockbook-frontend."test" = {
- enable = true;
- };
- services.bitcoind.mainnet = {
- enable = true;
- rpc = {
- port = 8030;
- users.rpc.passwordHMAC = "acc2374e5f9ba9e62a5204d3686616cf$53abdba5e67a9005be6a27ca03a93ce09e58854bc2b871523a0d239a72968033";
- };
+ nodes.machine =
+ { ... }:
+ {
+ services.blockbook-frontend."test" = {
+ enable = true;
+ };
+ services.bitcoind.mainnet = {
+ enable = true;
+ rpc = {
+ port = 8030;
+ users.rpc.passwordHMAC = "acc2374e5f9ba9e62a5204d3686616cf$53abdba5e67a9005be6a27ca03a93ce09e58854bc2b871523a0d239a72968033";
};
};
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("blockbook-frontend-test.service")
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("blockbook-frontend-test.service")
- machine.wait_for_open_port(9030)
+ machine.wait_for_open_port(9030)
- machine.succeed("curl -sSfL http://localhost:9030 | grep 'Blockbook'")
- '';
- }
-)
+ machine.succeed("curl -sSfL http://localhost:9030 | grep 'Blockbook'")
+ '';
+}
diff --git a/nixos/tests/boot-stage1.nix b/nixos/tests/boot-stage1.nix
index c700b79b27fe..e76af3e1dc6f 100644
--- a/nixos/tests/boot-stage1.nix
+++ b/nixos/tests/boot-stage1.nix
@@ -1,193 +1,191 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "boot-stage1";
+{ pkgs, ... }:
+{
+ name = "boot-stage1";
- nodes.machine =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- boot.extraModulePackages =
- let
- compileKernelModule =
- name: source:
- pkgs.runCommandCC name
- rec {
- inherit source;
- kdev = config.boot.kernelPackages.kernel.dev;
- kver = config.boot.kernelPackages.kernel.modDirVersion;
- ksrc = "${kdev}/lib/modules/${kver}/build";
- hardeningDisable = [ "pic" ];
- nativeBuildInputs = kdev.moduleBuildDependencies;
- }
- ''
- echo "obj-m += $name.o" > Makefile
- echo "$source" > "$name.c"
- make -C "$ksrc" M=$(pwd) modules
- install -vD "$name.ko" "$out/lib/modules/$kver/$name.ko"
- '';
-
- # This spawns a kthread which just waits until it gets a signal and
- # terminates if that is the case. We want to make sure that nothing during
- # the boot process kills any kthread by accident, like what happened in
- # issue #15226.
- kcanary = compileKernelModule "kcanary" ''
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
- #include
- #endif
-
- MODULE_LICENSE("GPL");
-
- struct task_struct *canaryTask;
-
- static int kcanary(void *nothing)
- {
- allow_signal(SIGINT);
- allow_signal(SIGTERM);
- allow_signal(SIGKILL);
- while (!kthread_should_stop()) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout_interruptible(msecs_to_jiffies(100));
- if (signal_pending(current)) break;
- }
- return 0;
+ nodes.machine =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ boot.extraModulePackages =
+ let
+ compileKernelModule =
+ name: source:
+ pkgs.runCommandCC name
+ rec {
+ inherit source;
+ kdev = config.boot.kernelPackages.kernel.dev;
+ kver = config.boot.kernelPackages.kernel.modDirVersion;
+ ksrc = "${kdev}/lib/modules/${kver}/build";
+ hardeningDisable = [ "pic" ];
+ nativeBuildInputs = kdev.moduleBuildDependencies;
}
-
- static int kcanaryInit(void)
- {
- kthread_run(&kcanary, NULL, "kcanary");
- return 0;
- }
-
- static void kcanaryExit(void)
- {
- kthread_stop(canaryTask);
- }
-
- module_init(kcanaryInit);
- module_exit(kcanaryExit);
- '';
-
- in
- lib.singleton kcanary;
-
- boot.initrd.kernelModules = [ "kcanary" ];
-
- boot.initrd.extraUtilsCommands =
- let
- compile =
- name: source:
- pkgs.runCommandCC name { inherit source; } ''
- mkdir -p "$out/bin"
- echo "$source" | gcc -Wall -o "$out/bin/$name" -xc -
+ ''
+ echo "obj-m += $name.o" > Makefile
+ echo "$source" > "$name.c"
+ make -C "$ksrc" M=$(pwd) modules
+ install -vD "$name.ko" "$out/lib/modules/$kver/$name.ko"
'';
- daemonize =
- name: source:
- compile name ''
+ # This spawns a kthread which just waits until it gets a signal and
+ # terminates if that is the case. We want to make sure that nothing during
+ # the boot process kills any kthread by accident, like what happened in
+ # issue #15226.
+ kcanary = compileKernelModule "kcanary" ''
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
+ #include
+ #endif
+
+ MODULE_LICENSE("GPL");
+
+ struct task_struct *canaryTask;
+
+ static int kcanary(void *nothing)
+ {
+ allow_signal(SIGINT);
+ allow_signal(SIGTERM);
+ allow_signal(SIGKILL);
+ while (!kthread_should_stop()) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout_interruptible(msecs_to_jiffies(100));
+ if (signal_pending(current)) break;
+ }
+ return 0;
+ }
+
+ static int kcanaryInit(void)
+ {
+ kthread_run(&kcanary, NULL, "kcanary");
+ return 0;
+ }
+
+ static void kcanaryExit(void)
+ {
+ kthread_stop(canaryTask);
+ }
+
+ module_init(kcanaryInit);
+ module_exit(kcanaryExit);
+ '';
+
+ in
+ lib.singleton kcanary;
+
+ boot.initrd.kernelModules = [ "kcanary" ];
+
+ boot.initrd.extraUtilsCommands =
+ let
+ compile =
+ name: source:
+ pkgs.runCommandCC name { inherit source; } ''
+ mkdir -p "$out/bin"
+ echo "$source" | gcc -Wall -o "$out/bin/$name" -xc -
+ '';
+
+ daemonize =
+ name: source:
+ compile name ''
+ #include
+ #include
+
+ void runSource(void) {
+ ${source}
+ }
+
+ int main(void) {
+ if (fork() > 0) return 0;
+ setsid();
+ runSource();
+ return 1;
+ }
+ '';
+
+ mkCmdlineCanary =
+ {
+ name,
+ cmdline ? "",
+ source ? "",
+ }:
+ (daemonize name ''
+ char *argv[] = {"${cmdline}", NULL};
+ execvp("${name}-child", argv);
+ '')
+ // {
+ child = compile "${name}-child" ''
#include
#include
- void runSource(void) {
- ${source}
- }
-
int main(void) {
- if (fork() > 0) return 0;
- setsid();
- runSource();
+ ${source}
+ while (1) sleep(1);
return 1;
}
'';
+ };
- mkCmdlineCanary =
- {
- name,
- cmdline ? "",
- source ? "",
- }:
- (daemonize name ''
- char *argv[] = {"${cmdline}", NULL};
- execvp("${name}-child", argv);
- '')
- // {
- child = compile "${name}-child" ''
- #include
- #include
+ copyCanaries = lib.concatMapStrings (canary: ''
+ ${lib.optionalString (canary ? child) ''
+ copy_bin_and_libs "${canary.child}/bin/${canary.child.name}"
+ ''}
+ copy_bin_and_libs "${canary}/bin/${canary.name}"
+ '');
- int main(void) {
- ${source}
- while (1) sleep(1);
- return 1;
- }
- '';
- };
+ in
+ copyCanaries [
+ # Simple canary process which just sleeps forever and should be killed by
+ # stage 2.
+ (daemonize "canary1" "while (1) sleep(1);")
- copyCanaries = lib.concatMapStrings (canary: ''
- ${lib.optionalString (canary ? child) ''
- copy_bin_and_libs "${canary.child}/bin/${canary.child.name}"
- ''}
- copy_bin_and_libs "${canary}/bin/${canary.name}"
- '');
+ # We want this canary process to try mimicking a kthread using a cmdline
+ # with a zero length so we can make sure that the process is properly
+ # killed in stage 1.
+ (mkCmdlineCanary {
+ name = "canary2";
+ source = ''
+ FILE *f;
+ f = fopen("/run/canary2.pid", "w");
+ fprintf(f, "%d\n", getpid());
+ fclose(f);
+ '';
+ })
- in
- copyCanaries [
- # Simple canary process which just sleeps forever and should be killed by
- # stage 2.
- (daemonize "canary1" "while (1) sleep(1);")
+ # This canary process mimics a storage daemon, which we do NOT want to be
+ # killed before going into stage 2. For more on root storage daemons, see:
+ # https://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/
+ (mkCmdlineCanary {
+ name = "canary3";
+ cmdline = "@canary3";
+ })
+ ];
- # We want this canary process to try mimicking a kthread using a cmdline
- # with a zero length so we can make sure that the process is properly
- # killed in stage 1.
- (mkCmdlineCanary {
- name = "canary2";
- source = ''
- FILE *f;
- f = fopen("/run/canary2.pid", "w");
- fprintf(f, "%d\n", getpid());
- fclose(f);
- '';
- })
+ boot.initrd.postMountCommands = ''
+ canary1
+ canary2
+ canary3
+ # Make sure the pidfile of canary 2 is created so that we still can get
+ # its former pid after the killing spree starts next within stage 1.
+ while [ ! -s /run/canary2.pid ]; do sleep 0.1; done
+ '';
+ };
- # This canary process mimics a storage daemon, which we do NOT want to be
- # killed before going into stage 2. For more on root storage daemons, see:
- # https://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/
- (mkCmdlineCanary {
- name = "canary3";
- cmdline = "@canary3";
- })
- ];
+ testScript = ''
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("test -s /run/canary2.pid")
+ machine.fail("pgrep -a canary1")
+ machine.fail("kill -0 $(< /run/canary2.pid)")
+ machine.succeed('pgrep -a -f "^@canary3$"')
+ machine.succeed('pgrep -a -f "^\\[kcanary\\]$"')
+ '';
- boot.initrd.postMountCommands = ''
- canary1
- canary2
- canary3
- # Make sure the pidfile of canary 2 is created so that we still can get
- # its former pid after the killing spree starts next within stage 1.
- while [ ! -s /run/canary2.pid ]; do sleep 0.1; done
- '';
- };
-
- testScript = ''
- machine.wait_for_unit("multi-user.target")
- machine.succeed("test -s /run/canary2.pid")
- machine.fail("pgrep -a canary1")
- machine.fail("kill -0 $(< /run/canary2.pid)")
- machine.succeed('pgrep -a -f "^@canary3$"')
- machine.succeed('pgrep -a -f "^\\[kcanary\\]$"')
- '';
-
- meta.maintainers = with pkgs.lib.maintainers; [ aszlig ];
- }
-)
+ meta.maintainers = with pkgs.lib.maintainers; [ aszlig ];
+}
diff --git a/nixos/tests/boot-stage2.nix b/nixos/tests/boot-stage2.nix
index 90f0ac01207c..13d7b66fe67e 100644
--- a/nixos/tests/boot-stage2.nix
+++ b/nixos/tests/boot-stage2.nix
@@ -1,73 +1,71 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "boot-stage2";
+{ pkgs, ... }:
+{
+ name = "boot-stage2";
- nodes.machine =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- virtualisation = {
- emptyDiskImages = [ 256 ];
+ nodes.machine =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ virtualisation = {
+ emptyDiskImages = [ 256 ];
- # Mount an ext4 as the upper layer of the Nix store.
- fileSystems = {
- "/nix/store" = lib.mkForce {
- device = "/dev/vdb"; # the above disk image
- fsType = "ext4";
+ # Mount an ext4 as the upper layer of the Nix store.
+ fileSystems = {
+ "/nix/store" = lib.mkForce {
+ device = "/dev/vdb"; # the above disk image
+ fsType = "ext4";
- # data=journal always displays after errors=remount-ro; this is only needed because of the overlay
- # and #375257 will trigger with `errors=remount-ro` on a non-overlaid store:
- # see ordering in https://github.com/torvalds/linux/blob/v6.12/fs/ext4/super.c#L2974
- options = [
- "defaults"
- "errors=remount-ro"
- "data=journal"
- ];
- };
+ # data=journal always displays after errors=remount-ro; this is only needed because of the overlay
+ # and #375257 will trigger with `errors=remount-ro` on a non-overlaid store:
+ # see ordering in https://github.com/torvalds/linux/blob/v6.12/fs/ext4/super.c#L2974
+ options = [
+ "defaults"
+ "errors=remount-ro"
+ "data=journal"
+ ];
};
};
-
- boot = {
- initrd = {
- # Format the upper Nix store.
- postDeviceCommands = ''
- ${pkgs.e2fsprogs}/bin/mkfs.ext4 /dev/vdb
- '';
-
- # Overlay the RO store onto it.
- # Note that bug #375257 can be triggered without an overlay,
- # using the errors=remount-ro option (or similar) or with an overlay where any of the
- # paths ends in 'ro'. The offending mountpoint also has to be the last (top) one
- # if an option ending in 'ro' is the last in the list, so test both cases here.
- postMountCommands = ''
- mkdir -p /mnt-root/nix/store/ro /mnt-root/nix/store/rw /mnt-root/nix/store/work
- mount --bind /mnt-root/nix/.ro-store /mnt-root/nix/store/ro
- mount -t overlay overlay \
- -o lowerdir=/mnt-root/nix/store/ro,upperdir=/mnt-root/nix/store/rw,workdir=/mnt-root/nix/store/work \
- /mnt-root/nix/store
- '';
-
- kernelModules = [ "overlay" ];
- };
-
- postBootCommands = ''
- touch /etc/post-boot-ran
- mount
- '';
- };
};
- testScript = ''
- machine.wait_for_unit("multi-user.target")
- machine.succeed("test /etc/post-boot-ran")
- machine.fail("touch /nix/store/should-not-work");
- '';
+ boot = {
+ initrd = {
+ # Format the upper Nix store.
+ postDeviceCommands = ''
+ ${pkgs.e2fsprogs}/bin/mkfs.ext4 /dev/vdb
+ '';
- meta.maintainers = with pkgs.lib.maintainers; [ numinit ];
- }
-)
+ # Overlay the RO store onto it.
+ # Note that bug #375257 can be triggered without an overlay,
+ # using the errors=remount-ro option (or similar) or with an overlay where any of the
+ # paths ends in 'ro'. The offending mountpoint also has to be the last (top) one
+ # if an option ending in 'ro' is the last in the list, so test both cases here.
+ postMountCommands = ''
+ mkdir -p /mnt-root/nix/store/ro /mnt-root/nix/store/rw /mnt-root/nix/store/work
+ mount --bind /mnt-root/nix/.ro-store /mnt-root/nix/store/ro
+ mount -t overlay overlay \
+ -o lowerdir=/mnt-root/nix/store/ro,upperdir=/mnt-root/nix/store/rw,workdir=/mnt-root/nix/store/work \
+ /mnt-root/nix/store
+ '';
+
+ kernelModules = [ "overlay" ];
+ };
+
+ postBootCommands = ''
+ touch /etc/post-boot-ran
+ mount
+ '';
+ };
+ };
+
+ testScript = ''
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("test /etc/post-boot-ran")
+ machine.fail("touch /nix/store/should-not-work");
+ '';
+
+ meta.maintainers = with pkgs.lib.maintainers; [ numinit ];
+}
diff --git a/nixos/tests/borgbackup.nix b/nixos/tests/borgbackup.nix
index 2ee324f1de2a..88d67c09f031 100644
--- a/nixos/tests/borgbackup.nix
+++ b/nixos/tests/borgbackup.nix
@@ -1,276 +1,274 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- passphrase = "supersecret";
- dataDir = "/ran:dom/data";
- subDir = "not_anything_here";
- excludedSubDirFile = "not_this_file_either";
- excludeFile = "not_this_file";
- keepFile = "important_file";
- keepFileData = "important_data";
- localRepo = "/root/back:up";
- # a repository on a file system which is not mounted automatically
- localRepoMount = "/noAutoMount";
- archiveName = "my_archive";
- remoteRepo = "borg@server:."; # No need to specify path
- privateKey = pkgs.writeText "id_ed25519" ''
- -----BEGIN OPENSSH PRIVATE KEY-----
- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
- QyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrwAAAJB+cF5HfnBe
- RwAAAAtzc2gtZWQyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrw
- AAAEBN75NsJZSpt63faCuaD75Unko0JjlSDxMhYHAPJk2/xXHxQHThDpD9/AMWNqQer3Tg
- 9gXMb2lTZMn0pelo8xyvAAAADXJzY2h1ZXR6QGt1cnQ=
- -----END OPENSSH PRIVATE KEY-----
- '';
- publicKey = ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHHxQHThDpD9/AMWNqQer3Tg9gXMb2lTZMn0pelo8xyv root@client
- '';
- privateKeyAppendOnly = pkgs.writeText "id_ed25519" ''
- -----BEGIN OPENSSH PRIVATE KEY-----
- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
- QyNTUxOQAAACBacZuz1ELGQdhI7PF6dGFafCDlvh8pSEc4cHjkW0QjLwAAAJC9YTxxvWE8
- cQAAAAtzc2gtZWQyNTUxOQAAACBacZuz1ELGQdhI7PF6dGFafCDlvh8pSEc4cHjkW0QjLw
- AAAEAAhV7wTl5dL/lz+PF/d4PnZXuG1Id6L/mFEiGT1tZsuFpxm7PUQsZB2Ejs8Xp0YVp8
- IOW+HylIRzhweORbRCMvAAAADXJzY2h1ZXR6QGt1cnQ=
- -----END OPENSSH PRIVATE KEY-----
- '';
- publicKeyAppendOnly = ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFpxm7PUQsZB2Ejs8Xp0YVp8IOW+HylIRzhweORbRCMv root@client
- '';
+let
+ passphrase = "supersecret";
+ dataDir = "/ran:dom/data";
+ subDir = "not_anything_here";
+ excludedSubDirFile = "not_this_file_either";
+ excludeFile = "not_this_file";
+ keepFile = "important_file";
+ keepFileData = "important_data";
+ localRepo = "/root/back:up";
+ # a repository on a file system which is not mounted automatically
+ localRepoMount = "/noAutoMount";
+ archiveName = "my_archive";
+ remoteRepo = "borg@server:."; # No need to specify path
+ privateKey = pkgs.writeText "id_ed25519" ''
+ -----BEGIN OPENSSH PRIVATE KEY-----
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+ QyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrwAAAJB+cF5HfnBe
+ RwAAAAtzc2gtZWQyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrw
+ AAAEBN75NsJZSpt63faCuaD75Unko0JjlSDxMhYHAPJk2/xXHxQHThDpD9/AMWNqQer3Tg
+ 9gXMb2lTZMn0pelo8xyvAAAADXJzY2h1ZXR6QGt1cnQ=
+ -----END OPENSSH PRIVATE KEY-----
+ '';
+ publicKey = ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHHxQHThDpD9/AMWNqQer3Tg9gXMb2lTZMn0pelo8xyv root@client
+ '';
+ privateKeyAppendOnly = pkgs.writeText "id_ed25519" ''
+ -----BEGIN OPENSSH PRIVATE KEY-----
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+ QyNTUxOQAAACBacZuz1ELGQdhI7PF6dGFafCDlvh8pSEc4cHjkW0QjLwAAAJC9YTxxvWE8
+ cQAAAAtzc2gtZWQyNTUxOQAAACBacZuz1ELGQdhI7PF6dGFafCDlvh8pSEc4cHjkW0QjLw
+ AAAEAAhV7wTl5dL/lz+PF/d4PnZXuG1Id6L/mFEiGT1tZsuFpxm7PUQsZB2Ejs8Xp0YVp8
+ IOW+HylIRzhweORbRCMvAAAADXJzY2h1ZXR6QGt1cnQ=
+ -----END OPENSSH PRIVATE KEY-----
+ '';
+ publicKeyAppendOnly = ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFpxm7PUQsZB2Ejs8Xp0YVp8IOW+HylIRzhweORbRCMv root@client
+ '';
- in
- {
- name = "borgbackup";
- meta = with pkgs.lib; {
- maintainers = with maintainers; [ dotlambda ];
- };
+in
+{
+ name = "borgbackup";
+ meta = with pkgs.lib; {
+ maintainers = with maintainers; [ dotlambda ];
+ };
- nodes = {
- client =
- { ... }:
- {
- virtualisation.fileSystems.${localRepoMount} = {
- device = "tmpfs";
- fsType = "tmpfs";
- options = [ "noauto" ];
+ nodes = {
+ client =
+ { ... }:
+ {
+ virtualisation.fileSystems.${localRepoMount} = {
+ device = "tmpfs";
+ fsType = "tmpfs";
+ options = [ "noauto" ];
+ };
+
+ services.borgbackup.jobs = {
+
+ local = {
+ paths = dataDir;
+ repo = localRepo;
+ preHook = ''
+ # Don't append a timestamp
+ archiveName="${archiveName}"
+ '';
+ encryption = {
+ mode = "repokey";
+ inherit passphrase;
+ };
+ compression = "auto,zlib,9";
+ prune.keep = {
+ within = "1y";
+ yearly = 5;
+ };
+ exclude = [ "*/${excludeFile}" ];
+ extraCreateArgs = [
+ "--exclude-caches"
+ "--exclude-if-present"
+ ".dont backup"
+ ];
+ postHook = "echo post";
+ startAt = [ ]; # Do not run automatically
};
- services.borgbackup.jobs = {
+ localMount = {
+ paths = dataDir;
+ repo = localRepoMount;
+ encryption.mode = "none";
+ startAt = [ ];
+ };
- local = {
- paths = dataDir;
- repo = localRepo;
- preHook = ''
- # Don't append a timestamp
- archiveName="${archiveName}"
- '';
- encryption = {
- mode = "repokey";
- inherit passphrase;
- };
- compression = "auto,zlib,9";
- prune.keep = {
- within = "1y";
- yearly = 5;
- };
- exclude = [ "*/${excludeFile}" ];
- extraCreateArgs = [
- "--exclude-caches"
- "--exclude-if-present"
- ".dont backup"
- ];
- postHook = "echo post";
- startAt = [ ]; # Do not run automatically
- };
+ remote = {
+ paths = dataDir;
+ repo = remoteRepo;
+ encryption.mode = "none";
+ startAt = [ ];
+ environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
+ };
- localMount = {
- paths = dataDir;
- repo = localRepoMount;
- encryption.mode = "none";
- startAt = [ ];
- };
+ remoteAppendOnly = {
+ paths = dataDir;
+ repo = remoteRepo;
+ encryption.mode = "none";
+ startAt = [ ];
+ environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly";
+ };
- remote = {
- paths = dataDir;
- repo = remoteRepo;
- encryption.mode = "none";
- startAt = [ ];
- environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
- };
+ commandSuccess = {
+ dumpCommand = pkgs.writeScript "commandSuccess" ''
+ echo -n test
+ '';
+ repo = remoteRepo;
+ encryption.mode = "none";
+ startAt = [ ];
+ environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
+ };
- remoteAppendOnly = {
- paths = dataDir;
- repo = remoteRepo;
- encryption.mode = "none";
- startAt = [ ];
- environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly";
- };
+ commandFail = {
+ dumpCommand = "${pkgs.coreutils}/bin/false";
+ repo = remoteRepo;
+ encryption.mode = "none";
+ startAt = [ ];
+ environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
+ };
- commandSuccess = {
- dumpCommand = pkgs.writeScript "commandSuccess" ''
- echo -n test
- '';
- repo = remoteRepo;
- encryption.mode = "none";
- startAt = [ ];
- environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
- };
+ sleepInhibited = {
+ inhibitsSleep = true;
+ # Blocks indefinitely while "backing up" so that we can try to suspend the local system while it's hung
+ dumpCommand = pkgs.writeScript "sleepInhibited" ''
+ cat /dev/zero
+ '';
+ repo = remoteRepo;
+ encryption.mode = "none";
+ startAt = [ ];
+ environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
+ };
- commandFail = {
- dumpCommand = "${pkgs.coreutils}/bin/false";
- repo = remoteRepo;
- encryption.mode = "none";
- startAt = [ ];
- environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
- };
-
- sleepInhibited = {
- inhibitsSleep = true;
- # Blocks indefinitely while "backing up" so that we can try to suspend the local system while it's hung
- dumpCommand = pkgs.writeScript "sleepInhibited" ''
- cat /dev/zero
- '';
- repo = remoteRepo;
- encryption.mode = "none";
- startAt = [ ];
- environment.BORG_RSH = "ssh -oStrictHostKeyChecking=no -i /root/id_ed25519";
- };
+ };
+ };
+ server =
+ { ... }:
+ {
+ services.openssh = {
+ enable = true;
+ settings = {
+ PasswordAuthentication = false;
+ KbdInteractiveAuthentication = false;
};
};
- server =
- { ... }:
- {
- services.openssh = {
- enable = true;
- settings = {
- PasswordAuthentication = false;
- KbdInteractiveAuthentication = false;
- };
- };
-
- services.borgbackup.repos.repo1 = {
- authorizedKeys = [ publicKey ];
- path = "/data/borgbackup";
- };
-
- # Second repo to make sure the authorizedKeys options are merged correctly
- services.borgbackup.repos.repo2 = {
- authorizedKeysAppendOnly = [ publicKeyAppendOnly ];
- path = "/data/borgbackup";
- quota = ".5G";
- };
+ services.borgbackup.repos.repo1 = {
+ authorizedKeys = [ publicKey ];
+ path = "/data/borgbackup";
};
- };
- testScript = ''
- start_all()
+ # Second repo to make sure the authorizedKeys options are merged correctly
+ services.borgbackup.repos.repo2 = {
+ authorizedKeysAppendOnly = [ publicKeyAppendOnly ];
+ path = "/data/borgbackup";
+ quota = ".5G";
+ };
+ };
+ };
- client.fail('test -d "${remoteRepo}"')
+ testScript = ''
+ start_all()
- client.succeed(
- "cp ${privateKey} /root/id_ed25519"
- )
- client.succeed("chmod 0600 /root/id_ed25519")
- client.succeed(
- "cp ${privateKeyAppendOnly} /root/id_ed25519.appendOnly"
- )
- client.succeed("chmod 0600 /root/id_ed25519.appendOnly")
+ client.fail('test -d "${remoteRepo}"')
- client.succeed("mkdir -p ${dataDir}/${subDir}")
- client.succeed("touch ${dataDir}/${excludeFile}")
- client.succeed("touch '${dataDir}/${subDir}/.dont backup'")
- client.succeed("touch ${dataDir}/${subDir}/${excludedSubDirFile}")
- client.succeed("echo '${keepFileData}' > ${dataDir}/${keepFile}")
+ client.succeed(
+ "cp ${privateKey} /root/id_ed25519"
+ )
+ client.succeed("chmod 0600 /root/id_ed25519")
+ client.succeed(
+ "cp ${privateKeyAppendOnly} /root/id_ed25519.appendOnly"
+ )
+ client.succeed("chmod 0600 /root/id_ed25519.appendOnly")
- with subtest("local"):
- borg = "BORG_PASSPHRASE='${passphrase}' borg"
- client.systemctl("start --wait borgbackup-job-local")
- client.fail("systemctl is-failed borgbackup-job-local")
- # Make sure exactly one archive has been created
- assert int(client.succeed("{} list '${localRepo}' | wc -l".format(borg))) > 0
- # Make sure excludeFile has been excluded
- client.fail(
- "{} list '${localRepo}::${archiveName}' | grep -qF '${excludeFile}'".format(borg)
- )
- # Make sure excludedSubDirFile has been excluded
- client.fail(
- "{} list '${localRepo}::${archiveName}' | grep -qF '${subDir}/${excludedSubDirFile}".format(borg)
- )
- # Make sure keepFile has the correct content
- client.succeed("{} extract '${localRepo}::${archiveName}'".format(borg))
- assert "${keepFileData}" in client.succeed("cat ${dataDir}/${keepFile}")
- # Make sure the same is true when using `borg mount`
- client.succeed(
- "mkdir -p /mnt/borg && {} mount '${localRepo}::${archiveName}' /mnt/borg".format(
- borg
- )
- )
- assert "${keepFileData}" in client.succeed(
- "cat /mnt/borg/${dataDir}/${keepFile}"
- )
+ client.succeed("mkdir -p ${dataDir}/${subDir}")
+ client.succeed("touch ${dataDir}/${excludeFile}")
+ client.succeed("touch '${dataDir}/${subDir}/.dont backup'")
+ client.succeed("touch ${dataDir}/${subDir}/${excludedSubDirFile}")
+ client.succeed("echo '${keepFileData}' > ${dataDir}/${keepFile}")
- with subtest("localMount"):
- # the file system for the repo should not be already mounted
- client.fail("mount | grep ${localRepoMount}")
- # ensure trying to write to the mountpoint before the fs is mounted fails
- client.succeed("chattr +i ${localRepoMount}")
- borg = "borg"
- client.systemctl("start --wait borgbackup-job-localMount")
- client.fail("systemctl is-failed borgbackup-job-localMount")
- # Make sure exactly one archive has been created
- assert int(client.succeed("{} list '${localRepoMount}' | wc -l".format(borg))) > 0
+ with subtest("local"):
+ borg = "BORG_PASSPHRASE='${passphrase}' borg"
+ client.systemctl("start --wait borgbackup-job-local")
+ client.fail("systemctl is-failed borgbackup-job-local")
+ # Make sure exactly one archive has been created
+ assert int(client.succeed("{} list '${localRepo}' | wc -l".format(borg))) > 0
+ # Make sure excludeFile has been excluded
+ client.fail(
+ "{} list '${localRepo}::${archiveName}' | grep -qF '${excludeFile}'".format(borg)
+ )
+ # Make sure excludedSubDirFile has been excluded
+ client.fail(
+ "{} list '${localRepo}::${archiveName}' | grep -qF '${subDir}/${excludedSubDirFile}".format(borg)
+ )
+ # Make sure keepFile has the correct content
+ client.succeed("{} extract '${localRepo}::${archiveName}'".format(borg))
+ assert "${keepFileData}" in client.succeed("cat ${dataDir}/${keepFile}")
+ # Make sure the same is true when using `borg mount`
+ client.succeed(
+ "mkdir -p /mnt/borg && {} mount '${localRepo}::${archiveName}' /mnt/borg".format(
+ borg
+ )
+ )
+ assert "${keepFileData}" in client.succeed(
+ "cat /mnt/borg/${dataDir}/${keepFile}"
+ )
- with subtest("remote"):
- borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519' borg"
- server.wait_for_unit("sshd.service")
- client.wait_for_unit("network.target")
- client.systemctl("start --wait borgbackup-job-remote")
- client.fail("systemctl is-failed borgbackup-job-remote")
+ with subtest("localMount"):
+ # the file system for the repo should not be already mounted
+ client.fail("mount | grep ${localRepoMount}")
+ # ensure trying to write to the mountpoint before the fs is mounted fails
+ client.succeed("chattr +i ${localRepoMount}")
+ borg = "borg"
+ client.systemctl("start --wait borgbackup-job-localMount")
+ client.fail("systemctl is-failed borgbackup-job-localMount")
+ # Make sure exactly one archive has been created
+ assert int(client.succeed("{} list '${localRepoMount}' | wc -l".format(borg))) > 0
- # Make sure we can't access repos other than the specified one
- client.fail("{} list borg\@server:wrong".format(borg))
+ with subtest("remote"):
+ borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519' borg"
+ server.wait_for_unit("sshd.service")
+ client.wait_for_unit("network.target")
+ client.systemctl("start --wait borgbackup-job-remote")
+ client.fail("systemctl is-failed borgbackup-job-remote")
- # TODO: Make sure that data is actually deleted
+ # Make sure we can't access repos other than the specified one
+ client.fail("{} list borg\@server:wrong".format(borg))
- with subtest("remoteAppendOnly"):
- borg = (
- "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly' borg"
- )
- server.wait_for_unit("sshd.service")
- client.wait_for_unit("network.target")
- client.systemctl("start --wait borgbackup-job-remoteAppendOnly")
- client.fail("systemctl is-failed borgbackup-job-remoteAppendOnly")
+ # TODO: Make sure that data is actually deleted
- # Make sure we can't access repos other than the specified one
- client.fail("{} list borg\@server:wrong".format(borg))
+ with subtest("remoteAppendOnly"):
+ borg = (
+ "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly' borg"
+ )
+ server.wait_for_unit("sshd.service")
+ client.wait_for_unit("network.target")
+ client.systemctl("start --wait borgbackup-job-remoteAppendOnly")
+ client.fail("systemctl is-failed borgbackup-job-remoteAppendOnly")
- # TODO: Make sure that data is not actually deleted
+ # Make sure we can't access repos other than the specified one
+ client.fail("{} list borg\@server:wrong".format(borg))
- with subtest("commandSuccess"):
- server.wait_for_unit("sshd.service")
- client.wait_for_unit("network.target")
- client.systemctl("start --wait borgbackup-job-commandSuccess")
- client.fail("systemctl is-failed borgbackup-job-commandSuccess")
- id = client.succeed("borg-job-commandSuccess list | tail -n1 | cut -d' ' -f1").strip()
- client.succeed(f"borg-job-commandSuccess extract ::{id} stdin")
- assert "test" == client.succeed("cat stdin")
+ # TODO: Make sure that data is not actually deleted
- with subtest("commandFail"):
- server.wait_for_unit("sshd.service")
- client.wait_for_unit("network.target")
- client.systemctl("start --wait borgbackup-job-commandFail")
- client.succeed("systemctl is-failed borgbackup-job-commandFail")
+ with subtest("commandSuccess"):
+ server.wait_for_unit("sshd.service")
+ client.wait_for_unit("network.target")
+ client.systemctl("start --wait borgbackup-job-commandSuccess")
+ client.fail("systemctl is-failed borgbackup-job-commandSuccess")
+ id = client.succeed("borg-job-commandSuccess list | tail -n1 | cut -d' ' -f1").strip()
+ client.succeed(f"borg-job-commandSuccess extract ::{id} stdin")
+ assert "test" == client.succeed("cat stdin")
- with subtest("sleepInhibited"):
- server.wait_for_unit("sshd.service")
- client.wait_for_unit("network.target")
- client.fail("systemd-inhibit --list | grep -q borgbackup")
- client.systemctl("start borgbackup-job-sleepInhibited")
- client.wait_until_succeeds("systemd-inhibit --list | grep -q borgbackup")
- client.systemctl("stop borgbackup-job-sleepInhibited")
- '';
- }
-)
+ with subtest("commandFail"):
+ server.wait_for_unit("sshd.service")
+ client.wait_for_unit("network.target")
+ client.systemctl("start --wait borgbackup-job-commandFail")
+ client.succeed("systemctl is-failed borgbackup-job-commandFail")
+
+ with subtest("sleepInhibited"):
+ server.wait_for_unit("sshd.service")
+ client.wait_for_unit("network.target")
+ client.fail("systemd-inhibit --list | grep -q borgbackup")
+ client.systemctl("start borgbackup-job-sleepInhibited")
+ client.wait_until_succeeds("systemd-inhibit --list | grep -q borgbackup")
+ client.systemctl("stop borgbackup-job-sleepInhibited")
+ '';
+}
diff --git a/nixos/tests/borgmatic.nix b/nixos/tests/borgmatic.nix
index be2542ed64ca..e89e2b05e4ef 100644
--- a/nixos/tests/borgmatic.nix
+++ b/nixos/tests/borgmatic.nix
@@ -1,28 +1,26 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "borgmatic";
- nodes.machine =
- { ... }:
- {
- services.borgmatic = {
- enable = true;
- settings = {
- source_directories = [ "/home" ];
- repositories = [
- {
- label = "local";
- path = "/var/backup";
- }
- ];
- keep_daily = 7;
- };
+{ pkgs, ... }:
+{
+ name = "borgmatic";
+ nodes.machine =
+ { ... }:
+ {
+ services.borgmatic = {
+ enable = true;
+ settings = {
+ source_directories = [ "/home" ];
+ repositories = [
+ {
+ label = "local";
+ path = "/var/backup";
+ }
+ ];
+ keep_daily = 7;
};
};
+ };
- testScript = ''
- machine.succeed("borgmatic rcreate -e none")
- machine.succeed("borgmatic")
- '';
- }
-)
+ testScript = ''
+ machine.succeed("borgmatic rcreate -e none")
+ machine.succeed("borgmatic")
+ '';
+}
diff --git a/nixos/tests/bpftune.nix b/nixos/tests/bpftune.nix
index 454e27272d5b..f94e3a98e5cf 100644
--- a/nixos/tests/bpftune.nix
+++ b/nixos/tests/bpftune.nix
@@ -1,25 +1,23 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
+{ lib, pkgs, ... }:
+{
- name = "bpftune";
+ name = "bpftune";
- meta = {
- maintainers = with lib.maintainers; [ nickcao ];
- };
+ meta = {
+ maintainers = with lib.maintainers; [ nickcao ];
+ };
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.bpftune.enable = true;
- };
- };
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.bpftune.enable = true;
+ };
+ };
- testScript = ''
- machine.wait_for_unit("bpftune.service")
- machine.wait_for_console_text("bpftune works")
- '';
+ testScript = ''
+ machine.wait_for_unit("bpftune.service")
+ machine.wait_for_console_text("bpftune works")
+ '';
- }
-)
+}
diff --git a/nixos/tests/breitbandmessung.nix b/nixos/tests/breitbandmessung.nix
index 414fd09cfa54..809a995cfcc5 100644
--- a/nixos/tests/breitbandmessung.nix
+++ b/nixos/tests/breitbandmessung.nix
@@ -1,41 +1,39 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "breitbandmessung";
- meta.maintainers = with lib.maintainers; [ b4dm4n ];
+{ lib, ... }:
+{
+ name = "breitbandmessung";
+ meta.maintainers = with lib.maintainers; [ b4dm4n ];
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
- # increase screen size to make the whole program visible
- virtualisation.resolution = {
- x = 1280;
- y = 1024;
- };
-
- test-support.displayManager.auto.user = "alice";
-
- environment.systemPackages = with pkgs; [ breitbandmessung ];
- environment.variables.XAUTHORITY = "/home/alice/.Xauthority";
-
- # breitbandmessung is unfree
- nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "breitbandmessung" ];
+ # increase screen size to make the whole program visible
+ virtualisation.resolution = {
+ x = 1280;
+ y = 1024;
};
- enableOCR = true;
+ test-support.displayManager.auto.user = "alice";
- testScript = ''
- machine.wait_for_x()
- machine.execute("su - alice -c breitbandmessung >&2 &")
- machine.wait_for_window("Breitbandmessung")
- machine.wait_for_text("Breitbandmessung")
- machine.wait_for_text("Datenschutz")
- machine.screenshot("breitbandmessung")
- '';
- }
-)
+ environment.systemPackages = with pkgs; [ breitbandmessung ];
+ environment.variables.XAUTHORITY = "/home/alice/.Xauthority";
+
+ # breitbandmessung is unfree
+ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "breitbandmessung" ];
+ };
+
+ enableOCR = true;
+
+ testScript = ''
+ machine.wait_for_x()
+ machine.execute("su - alice -c breitbandmessung >&2 &")
+ machine.wait_for_window("Breitbandmessung")
+ machine.wait_for_text("Breitbandmessung")
+ machine.wait_for_text("Datenschutz")
+ machine.screenshot("breitbandmessung")
+ '';
+}
diff --git a/nixos/tests/brscan5.nix b/nixos/tests/brscan5.nix
index f61228bac41e..af70f362cb92 100644
--- a/nixos/tests/brscan5.nix
+++ b/nixos/tests/brscan5.nix
@@ -1,53 +1,51 @@
# integration tests for brscan5 sane driver
#
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "brscan5";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ mattchrist ];
- };
+{ pkgs, ... }:
+{
+ name = "brscan5";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ mattchrist ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- nixpkgs.config.allowUnfree = true;
- hardware.sane = {
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ nixpkgs.config.allowUnfree = true;
+ hardware.sane = {
+ enable = true;
+ brscan5 = {
enable = true;
- brscan5 = {
- enable = true;
- netDevices = {
- "a" = {
- model = "ADS-1200";
- nodename = "BRW0080927AFBCE";
- };
- "b" = {
- model = "ADS-1200";
- ip = "192.168.1.2";
- };
+ netDevices = {
+ "a" = {
+ model = "ADS-1200";
+ nodename = "BRW0080927AFBCE";
+ };
+ "b" = {
+ model = "ADS-1200";
+ ip = "192.168.1.2";
};
};
};
};
+ };
- testScript = ''
- import re
- # sane loads libsane-brother5.so.1 successfully, and scanimage doesn't die
- strace = machine.succeed('strace scanimage -L 2>&1').split("\n")
- regexp = 'openat\(.*libsane-brother5.so.1", O_RDONLY|O_CLOEXEC\) = \d\d*$'
- assert len([x for x in strace if re.match(regexp,x)]) > 0
+ testScript = ''
+ import re
+ # sane loads libsane-brother5.so.1 successfully, and scanimage doesn't die
+ strace = machine.succeed('strace scanimage -L 2>&1').split("\n")
+ regexp = 'openat\(.*libsane-brother5.so.1", O_RDONLY|O_CLOEXEC\) = \d\d*$'
+ assert len([x for x in strace if re.match(regexp,x)]) > 0
- # module creates a config
- cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg')
- assert 'DEVICE=a , "ADS-1200" , 0x4f9:0x459 , NODENAME=BRW0080927AFBCE' in cfg
- assert 'DEVICE=b , "ADS-1200" , 0x4f9:0x459 , IP-ADDRESS=192.168.1.2' in cfg
+ # module creates a config
+ cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg')
+ assert 'DEVICE=a , "ADS-1200" , 0x4f9:0x459 , NODENAME=BRW0080927AFBCE' in cfg
+ assert 'DEVICE=b , "ADS-1200" , 0x4f9:0x459 , IP-ADDRESS=192.168.1.2' in cfg
- # scanimage lists the two network scanners
- scanimage = machine.succeed("scanimage -L")
- print(scanimage)
- assert """device `brother5:net1;dev0' is a Brother b ADS-1200""" in scanimage
- assert """device `brother5:net1;dev1' is a Brother a ADS-1200""" in scanimage
- '';
- }
-)
+ # scanimage lists the two network scanners
+ scanimage = machine.succeed("scanimage -L")
+ print(scanimage)
+ assert """device `brother5:net1;dev0' is a Brother b ADS-1200""" in scanimage
+ assert """device `brother5:net1;dev1' is a Brother a ADS-1200""" in scanimage
+ '';
+}
diff --git a/nixos/tests/btrbk-doas.nix b/nixos/tests/btrbk-doas.nix
index aa146ff351bd..326998b16b49 100644
--- a/nixos/tests/btrbk-doas.nix
+++ b/nixos/tests/btrbk-doas.nix
@@ -1,128 +1,126 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- privateKey = ''
- -----BEGIN OPENSSH PRIVATE KEY-----
- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
- QyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrwAAAJB+cF5HfnBe
- RwAAAAtzc2gtZWQyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrw
- AAAEBN75NsJZSpt63faCuaD75Unko0JjlSDxMhYHAPJk2/xXHxQHThDpD9/AMWNqQer3Tg
- 9gXMb2lTZMn0pelo8xyvAAAADXJzY2h1ZXR6QGt1cnQ=
- -----END OPENSSH PRIVATE KEY-----
- '';
- publicKey = ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHHxQHThDpD9/AMWNqQer3Tg9gXMb2lTZMn0pelo8xyv
- '';
- in
- {
- name = "btrbk-doas";
- meta = with pkgs.lib; {
- maintainers = with maintainers; [
- symphorien
- tu-maurice
- ];
- };
+let
+ privateKey = ''
+ -----BEGIN OPENSSH PRIVATE KEY-----
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+ QyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrwAAAJB+cF5HfnBe
+ RwAAAAtzc2gtZWQyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrw
+ AAAEBN75NsJZSpt63faCuaD75Unko0JjlSDxMhYHAPJk2/xXHxQHThDpD9/AMWNqQer3Tg
+ 9gXMb2lTZMn0pelo8xyvAAAADXJzY2h1ZXR6QGt1cnQ=
+ -----END OPENSSH PRIVATE KEY-----
+ '';
+ publicKey = ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHHxQHThDpD9/AMWNqQer3Tg9gXMb2lTZMn0pelo8xyv
+ '';
+in
+{
+ name = "btrbk-doas";
+ meta = with pkgs.lib; {
+ maintainers = with maintainers; [
+ symphorien
+ tu-maurice
+ ];
+ };
- nodes = {
- archive =
- { ... }:
- {
- security.sudo.enable = false;
- security.doas.enable = true;
- environment.systemPackages = with pkgs; [ btrfs-progs ];
- # note: this makes the privateKey world readable.
- # don't do it with real ssh keys.
- environment.etc."btrbk_key".text = privateKey;
- services.btrbk = {
- extraPackages = [ pkgs.lz4 ];
- instances = {
- remote = {
- onCalendar = "minutely";
- settings = {
- ssh_identity = "/etc/btrbk_key";
- ssh_user = "btrbk";
- stream_compress = "lz4";
- volume = {
- "ssh://main/mnt" = {
- target = "/mnt";
- snapshot_dir = "btrbk/remote";
- subvolume = "to_backup";
- };
+ nodes = {
+ archive =
+ { ... }:
+ {
+ security.sudo.enable = false;
+ security.doas.enable = true;
+ environment.systemPackages = with pkgs; [ btrfs-progs ];
+ # note: this makes the privateKey world readable.
+ # don't do it with real ssh keys.
+ environment.etc."btrbk_key".text = privateKey;
+ services.btrbk = {
+ extraPackages = [ pkgs.lz4 ];
+ instances = {
+ remote = {
+ onCalendar = "minutely";
+ settings = {
+ ssh_identity = "/etc/btrbk_key";
+ ssh_user = "btrbk";
+ stream_compress = "lz4";
+ volume = {
+ "ssh://main/mnt" = {
+ target = "/mnt";
+ snapshot_dir = "btrbk/remote";
+ subvolume = "to_backup";
};
};
};
};
};
};
+ };
- main =
- { ... }:
- {
- security.sudo.enable = false;
- security.doas.enable = true;
- environment.systemPackages = with pkgs; [ btrfs-progs ];
- services.openssh = {
- enable = true;
- passwordAuthentication = false;
- kbdInteractiveAuthentication = false;
- };
- services.btrbk = {
- extraPackages = [ pkgs.lz4 ];
- sshAccess = [
- {
- key = publicKey;
- roles = [
- "source"
- "send"
- "info"
- "delete"
- ];
- }
- ];
- instances = {
- local = {
- onCalendar = "minutely";
- settings = {
- volume = {
- "/mnt" = {
- snapshot_dir = "btrbk/local";
- subvolume = "to_backup";
- };
+ main =
+ { ... }:
+ {
+ security.sudo.enable = false;
+ security.doas.enable = true;
+ environment.systemPackages = with pkgs; [ btrfs-progs ];
+ services.openssh = {
+ enable = true;
+ passwordAuthentication = false;
+ kbdInteractiveAuthentication = false;
+ };
+ services.btrbk = {
+ extraPackages = [ pkgs.lz4 ];
+ sshAccess = [
+ {
+ key = publicKey;
+ roles = [
+ "source"
+ "send"
+ "info"
+ "delete"
+ ];
+ }
+ ];
+ instances = {
+ local = {
+ onCalendar = "minutely";
+ settings = {
+ volume = {
+ "/mnt" = {
+ snapshot_dir = "btrbk/local";
+ subvolume = "to_backup";
};
};
};
};
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- # create btrfs partition at /mnt
- for machine in (archive, main):
- machine.succeed("dd if=/dev/zero of=/data_fs bs=120M count=1")
- machine.succeed("mkfs.btrfs /data_fs")
- machine.succeed("mkdir /mnt")
- machine.succeed("mount /data_fs /mnt")
+ # create btrfs partition at /mnt
+ for machine in (archive, main):
+ machine.succeed("dd if=/dev/zero of=/data_fs bs=120M count=1")
+ machine.succeed("mkfs.btrfs /data_fs")
+ machine.succeed("mkdir /mnt")
+ machine.succeed("mount /data_fs /mnt")
- # what to backup and where
- main.succeed("btrfs subvolume create /mnt/to_backup")
- main.succeed("mkdir -p /mnt/btrbk/{local,remote}")
+ # what to backup and where
+ main.succeed("btrfs subvolume create /mnt/to_backup")
+ main.succeed("mkdir -p /mnt/btrbk/{local,remote}")
- # check that local snapshots work
- with subtest("local"):
- main.succeed("echo foo > /mnt/to_backup/bar")
- main.wait_until_succeeds("cat /mnt/btrbk/local/*/bar | grep foo")
- main.succeed("echo bar > /mnt/to_backup/bar")
- main.succeed("cat /mnt/btrbk/local/*/bar | grep foo")
+ # check that local snapshots work
+ with subtest("local"):
+ main.succeed("echo foo > /mnt/to_backup/bar")
+ main.wait_until_succeeds("cat /mnt/btrbk/local/*/bar | grep foo")
+ main.succeed("echo bar > /mnt/to_backup/bar")
+ main.succeed("cat /mnt/btrbk/local/*/bar | grep foo")
- # check that btrfs send/receive works and ssh access works
- with subtest("remote"):
- archive.wait_until_succeeds("cat /mnt/*/bar | grep bar")
- main.succeed("echo baz > /mnt/to_backup/bar")
- archive.succeed("cat /mnt/*/bar | grep bar")
- '';
- }
-)
+ # check that btrfs send/receive works and ssh access works
+ with subtest("remote"):
+ archive.wait_until_succeeds("cat /mnt/*/bar | grep bar")
+ main.succeed("echo baz > /mnt/to_backup/bar")
+ archive.succeed("cat /mnt/*/bar | grep bar")
+ '';
+}
diff --git a/nixos/tests/btrbk-no-timer.nix b/nixos/tests/btrbk-no-timer.nix
index c5bcb6edab68..c73dc1907aaa 100644
--- a/nixos/tests/btrbk-no-timer.nix
+++ b/nixos/tests/btrbk-no-timer.nix
@@ -1,41 +1,39 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "btrbk-no-timer";
- meta.maintainers = with lib.maintainers; [ oxalica ];
+{ lib, pkgs, ... }:
+{
+ name = "btrbk-no-timer";
+ meta.maintainers = with lib.maintainers; [ oxalica ];
- nodes.machine =
- { ... }:
- {
- environment.systemPackages = with pkgs; [ btrfs-progs ];
- services.btrbk.instances.local = {
- onCalendar = null;
- settings.volume."/mnt" = {
- snapshot_dir = "btrbk/local";
- subvolume = "to_backup";
- };
+ nodes.machine =
+ { ... }:
+ {
+ environment.systemPackages = with pkgs; [ btrfs-progs ];
+ services.btrbk.instances.local = {
+ onCalendar = null;
+ settings.volume."/mnt" = {
+ snapshot_dir = "btrbk/local";
+ subvolume = "to_backup";
};
};
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- # Create btrfs partition at /mnt
- machine.succeed("truncate --size=128M /data_fs")
- machine.succeed("mkfs.btrfs /data_fs")
- machine.succeed("mkdir /mnt")
- machine.succeed("mount /data_fs /mnt")
- machine.succeed("btrfs subvolume create /mnt/to_backup")
- machine.succeed("mkdir -p /mnt/btrbk/local")
+ # Create btrfs partition at /mnt
+ machine.succeed("truncate --size=128M /data_fs")
+ machine.succeed("mkfs.btrfs /data_fs")
+ machine.succeed("mkdir /mnt")
+ machine.succeed("mount /data_fs /mnt")
+ machine.succeed("btrfs subvolume create /mnt/to_backup")
+ machine.succeed("mkdir -p /mnt/btrbk/local")
- # The service should not have any triggering timer.
- unit = machine.get_unit_info('btrbk-local.service')
- assert "TriggeredBy" not in unit
+ # The service should not have any triggering timer.
+ unit = machine.get_unit_info('btrbk-local.service')
+ assert "TriggeredBy" not in unit
- # Manually starting the service should still work.
- machine.succeed("echo foo > /mnt/to_backup/bar")
- machine.start_job("btrbk-local.service")
- machine.wait_until_succeeds("cat /mnt/btrbk/local/*/bar | grep foo")
- '';
- }
-)
+ # Manually starting the service should still work.
+ machine.succeed("echo foo > /mnt/to_backup/bar")
+ machine.start_job("btrbk-local.service")
+ machine.wait_until_succeeds("cat /mnt/btrbk/local/*/bar | grep foo")
+ '';
+}
diff --git a/nixos/tests/btrbk-section-order.nix b/nixos/tests/btrbk-section-order.nix
index 03762b3fee6b..226025464835 100644
--- a/nixos/tests/btrbk-section-order.nix
+++ b/nixos/tests/btrbk-section-order.nix
@@ -6,56 +6,54 @@
# order-sensitive config format.
#
# Issue: https://github.com/NixOS/nixpkgs/issues/195660
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "btrbk-section-order";
- meta.maintainers = with lib.maintainers; [ oxalica ];
+{ lib, pkgs, ... }:
+{
+ name = "btrbk-section-order";
+ meta.maintainers = with lib.maintainers; [ oxalica ];
- nodes.machine =
- { ... }:
- {
- services.btrbk.instances.local = {
- onCalendar = null;
- settings = {
- timestamp_format = "long";
- target."ssh://global-target/".ssh_user = "root";
- volume."/btrfs" = {
- snapshot_dir = "/volume-snapshots";
- target."ssh://volume-target/".ssh_user = "root";
- subvolume."@subvolume" = {
- snapshot_dir = "/subvolume-snapshots";
- target."ssh://subvolume-target/".ssh_user = "root";
- };
+ nodes.machine =
+ { ... }:
+ {
+ services.btrbk.instances.local = {
+ onCalendar = null;
+ settings = {
+ timestamp_format = "long";
+ target."ssh://global-target/".ssh_user = "root";
+ volume."/btrfs" = {
+ snapshot_dir = "/volume-snapshots";
+ target."ssh://volume-target/".ssh_user = "root";
+ subvolume."@subvolume" = {
+ snapshot_dir = "/subvolume-snapshots";
+ target."ssh://subvolume-target/".ssh_user = "root";
};
};
};
};
+ };
- testScript = ''
- import difflib
- machine.wait_for_unit("basic.target")
- got = machine.succeed("cat /etc/btrbk/local.conf").strip()
- expect = """
- backend btrfs-progs-sudo
- stream_compress no
- timestamp_format long
- target ssh://global-target/
+ testScript = ''
+ import difflib
+ machine.wait_for_unit("basic.target")
+ got = machine.succeed("cat /etc/btrbk/local.conf").strip()
+ expect = """
+ backend btrfs-progs-sudo
+ stream_compress no
+ timestamp_format long
+ target ssh://global-target/
+ ssh_user root
+ volume /btrfs
+ snapshot_dir /volume-snapshots
+ target ssh://volume-target/
+ ssh_user root
+ subvolume @subvolume
+ snapshot_dir /subvolume-snapshots
+ target ssh://subvolume-target/
ssh_user root
- volume /btrfs
- snapshot_dir /volume-snapshots
- target ssh://volume-target/
- ssh_user root
- subvolume @subvolume
- snapshot_dir /subvolume-snapshots
- target ssh://subvolume-target/
- ssh_user root
- """.strip()
- print(got)
- if got != expect:
- diff = difflib.unified_diff(expect.splitlines(keepends=True), got.splitlines(keepends=True), fromfile="expected", tofile="got")
- print("".join(diff))
- assert got == expect
- '';
- }
-)
+ """.strip()
+ print(got)
+ if got != expect:
+ diff = difflib.unified_diff(expect.splitlines(keepends=True), got.splitlines(keepends=True), fromfile="expected", tofile="got")
+ print("".join(diff))
+ assert got == expect
+ '';
+}
diff --git a/nixos/tests/btrbk.nix b/nixos/tests/btrbk.nix
index e6b3e1166ff3..10ca8c3ca95e 100644
--- a/nixos/tests/btrbk.nix
+++ b/nixos/tests/btrbk.nix
@@ -1,122 +1,120 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- privateKey = ''
- -----BEGIN OPENSSH PRIVATE KEY-----
- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
- QyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrwAAAJB+cF5HfnBe
- RwAAAAtzc2gtZWQyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrw
- AAAEBN75NsJZSpt63faCuaD75Unko0JjlSDxMhYHAPJk2/xXHxQHThDpD9/AMWNqQer3Tg
- 9gXMb2lTZMn0pelo8xyvAAAADXJzY2h1ZXR6QGt1cnQ=
- -----END OPENSSH PRIVATE KEY-----
- '';
- publicKey = ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHHxQHThDpD9/AMWNqQer3Tg9gXMb2lTZMn0pelo8xyv
- '';
- in
- {
- name = "btrbk";
- meta = with pkgs.lib; {
- maintainers = with maintainers; [ symphorien ];
- };
+let
+ privateKey = ''
+ -----BEGIN OPENSSH PRIVATE KEY-----
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+ QyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrwAAAJB+cF5HfnBe
+ RwAAAAtzc2gtZWQyNTUxOQAAACBx8UB04Q6Q/fwDFjakHq904PYFzG9pU2TJ9KXpaPMcrw
+ AAAEBN75NsJZSpt63faCuaD75Unko0JjlSDxMhYHAPJk2/xXHxQHThDpD9/AMWNqQer3Tg
+ 9gXMb2lTZMn0pelo8xyvAAAADXJzY2h1ZXR6QGt1cnQ=
+ -----END OPENSSH PRIVATE KEY-----
+ '';
+ publicKey = ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHHxQHThDpD9/AMWNqQer3Tg9gXMb2lTZMn0pelo8xyv
+ '';
+in
+{
+ name = "btrbk";
+ meta = with pkgs.lib; {
+ maintainers = with maintainers; [ symphorien ];
+ };
- nodes = {
- archive =
- { ... }:
- {
- environment.systemPackages = with pkgs; [ btrfs-progs ];
- # note: this makes the privateKey world readable.
- # don't do it with real ssh keys.
- environment.etc."btrbk_key".text = privateKey;
- services.btrbk = {
- instances = {
- remote = {
- onCalendar = "minutely";
- settings = {
- ssh_identity = "/etc/btrbk_key";
- ssh_user = "btrbk";
- stream_compress = "lz4";
- volume = {
- "ssh://main/mnt" = {
- target = "/mnt";
- snapshot_dir = "btrbk/remote";
- subvolume = "to_backup";
- };
+ nodes = {
+ archive =
+ { ... }:
+ {
+ environment.systemPackages = with pkgs; [ btrfs-progs ];
+ # note: this makes the privateKey world readable.
+ # don't do it with real ssh keys.
+ environment.etc."btrbk_key".text = privateKey;
+ services.btrbk = {
+ instances = {
+ remote = {
+ onCalendar = "minutely";
+ settings = {
+ ssh_identity = "/etc/btrbk_key";
+ ssh_user = "btrbk";
+ stream_compress = "lz4";
+ volume = {
+ "ssh://main/mnt" = {
+ target = "/mnt";
+ snapshot_dir = "btrbk/remote";
+ subvolume = "to_backup";
};
};
};
};
};
};
+ };
- main =
- { ... }:
- {
- environment.systemPackages = with pkgs; [ btrfs-progs ];
- services.openssh = {
- enable = true;
- settings = {
- KbdInteractiveAuthentication = false;
- PasswordAuthentication = false;
- };
+ main =
+ { ... }:
+ {
+ environment.systemPackages = with pkgs; [ btrfs-progs ];
+ services.openssh = {
+ enable = true;
+ settings = {
+ KbdInteractiveAuthentication = false;
+ PasswordAuthentication = false;
};
- services.btrbk = {
- extraPackages = [ pkgs.lz4 ];
- sshAccess = [
- {
- key = publicKey;
- roles = [
- "source"
- "send"
- "info"
- "delete"
- ];
- }
- ];
- instances = {
- local = {
- onCalendar = "minutely";
- settings = {
- volume = {
- "/mnt" = {
- snapshot_dir = "btrbk/local";
- subvolume = "to_backup";
- };
+ };
+ services.btrbk = {
+ extraPackages = [ pkgs.lz4 ];
+ sshAccess = [
+ {
+ key = publicKey;
+ roles = [
+ "source"
+ "send"
+ "info"
+ "delete"
+ ];
+ }
+ ];
+ instances = {
+ local = {
+ onCalendar = "minutely";
+ settings = {
+ volume = {
+ "/mnt" = {
+ snapshot_dir = "btrbk/local";
+ subvolume = "to_backup";
};
};
};
};
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- # create btrfs partition at /mnt
- for machine in (archive, main):
- machine.succeed("dd if=/dev/zero of=/data_fs bs=120M count=1")
- machine.succeed("mkfs.btrfs /data_fs")
- machine.succeed("mkdir /mnt")
- machine.succeed("mount /data_fs /mnt")
+ # create btrfs partition at /mnt
+ for machine in (archive, main):
+ machine.succeed("dd if=/dev/zero of=/data_fs bs=120M count=1")
+ machine.succeed("mkfs.btrfs /data_fs")
+ machine.succeed("mkdir /mnt")
+ machine.succeed("mount /data_fs /mnt")
- # what to backup and where
- main.succeed("btrfs subvolume create /mnt/to_backup")
- main.succeed("mkdir -p /mnt/btrbk/{local,remote}")
+ # what to backup and where
+ main.succeed("btrfs subvolume create /mnt/to_backup")
+ main.succeed("mkdir -p /mnt/btrbk/{local,remote}")
- # check that local snapshots work
- with subtest("local"):
- main.succeed("echo foo > /mnt/to_backup/bar")
- main.wait_until_succeeds("cat /mnt/btrbk/local/*/bar | grep foo")
- main.succeed("echo bar > /mnt/to_backup/bar")
- main.succeed("cat /mnt/btrbk/local/*/bar | grep foo")
+ # check that local snapshots work
+ with subtest("local"):
+ main.succeed("echo foo > /mnt/to_backup/bar")
+ main.wait_until_succeeds("cat /mnt/btrbk/local/*/bar | grep foo")
+ main.succeed("echo bar > /mnt/to_backup/bar")
+ main.succeed("cat /mnt/btrbk/local/*/bar | grep foo")
- # check that btrfs send/receive works and ssh access works
- with subtest("remote"):
- archive.wait_until_succeeds("cat /mnt/*/bar | grep bar")
- main.succeed("echo baz > /mnt/to_backup/bar")
- archive.succeed("cat /mnt/*/bar | grep bar")
- '';
- }
-)
+ # check that btrfs send/receive works and ssh access works
+ with subtest("remote"):
+ archive.wait_until_succeeds("cat /mnt/*/bar | grep bar")
+ main.succeed("echo baz > /mnt/to_backup/bar")
+ archive.succeed("cat /mnt/*/bar | grep bar")
+ '';
+}
diff --git a/nixos/tests/budgie.nix b/nixos/tests/budgie.nix
index 5389a8d9da9d..04e5300ec4fb 100644
--- a/nixos/tests/budgie.nix
+++ b/nixos/tests/budgie.nix
@@ -1,104 +1,102 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "budgie";
+{ pkgs, lib, ... }:
+{
+ name = "budgie";
- meta.maintainers = lib.teams.budgie.members;
+ meta.maintainers = lib.teams.budgie.members;
- nodes.machine =
- { ... }:
- {
- imports = [
- ./common/user-account.nix
- ];
+ nodes.machine =
+ { ... }:
+ {
+ imports = [
+ ./common/user-account.nix
+ ];
- services.xserver.enable = true;
+ services.xserver.enable = true;
- services.xserver.displayManager = {
- lightdm.enable = true;
- autoLogin = {
- enable = true;
- user = "alice";
- };
- };
-
- # We don't ship gnome-text-editor in Budgie module, we add this line mainly
- # to catch eval issues related to this option.
- environment.budgie.excludePackages = [ pkgs.gnome-text-editor ];
-
- services.xserver.desktopManager.budgie = {
+ services.xserver.displayManager = {
+ lightdm.enable = true;
+ autoLogin = {
enable = true;
- extraPlugins = [
- pkgs.budgie-analogue-clock-applet
- ];
+ user = "alice";
};
};
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0";
- su = command: "su - ${user.name} -c '${env} ${command}'";
- in
- ''
- with subtest("Wait for login"):
- # wait_for_x() checks graphical-session.target, which is expected to be
- # inactive on Budgie before Budgie manages user session with systemd.
- # https://github.com/BuddiesOfBudgie/budgie-desktop/blob/39e9f0895c978f76/src/session/budgie-desktop.in#L16
- #
- # Previously this was unconditionally touched by xsessionWrapper but was
- # changed in #233981 (we have Budgie:GNOME in XDG_CURRENT_DESKTOP).
- # machine.wait_for_x()
- machine.wait_until_succeeds('journalctl -t budgie-session-binary --grep "Entering running state"')
- machine.wait_for_file("${user.home}/.Xauthority")
- machine.succeed("xauth merge ${user.home}/.Xauthority")
+ # We don't ship gnome-text-editor in Budgie module, we add this line mainly
+ # to catch eval issues related to this option.
+ environment.budgie.excludePackages = [ pkgs.gnome-text-editor ];
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ services.xserver.desktopManager.budgie = {
+ enable = true;
+ extraPlugins = [
+ pkgs.budgie-analogue-clock-applet
+ ];
+ };
+ };
- with subtest("Check if Budgie session components actually start"):
- for i in ["budgie-daemon", "budgie-panel", "budgie-wm", "budgie-desktop-view", "gsd-media-keys"]:
- machine.wait_until_succeeds(f"pgrep -f {i}")
- # We don't check xwininfo for budgie-wm.
- # See https://github.com/NixOS/nixpkgs/pull/216737#discussion_r1155312754
- machine.wait_for_window("budgie-daemon")
- machine.wait_for_window("budgie-panel")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0";
+ su = command: "su - ${user.name} -c '${env} ${command}'";
+ in
+ ''
+ with subtest("Wait for login"):
+ # wait_for_x() checks graphical-session.target, which is expected to be
+ # inactive on Budgie before Budgie manages user session with systemd.
+ # https://github.com/BuddiesOfBudgie/budgie-desktop/blob/39e9f0895c978f76/src/session/budgie-desktop.in#L16
+ #
+ # Previously this was unconditionally touched by xsessionWrapper but was
+ # changed in #233981 (we have Budgie:GNOME in XDG_CURRENT_DESKTOP).
+ # machine.wait_for_x()
+ machine.wait_until_succeeds('journalctl -t budgie-session-binary --grep "Entering running state"')
+ machine.wait_for_file("${user.home}/.Xauthority")
+ machine.succeed("xauth merge ${user.home}/.Xauthority")
- with subtest("Check if various environment variables are set"):
- cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf /run/current-system/sw/bin/budgie-wm)/environ"
- machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Budgie:GNOME'")
- machine.succeed(f"{cmd} | grep 'BUDGIE_PLUGIN_DATADIR' | grep '${pkgs.budgie-desktop-with-plugins.pname}'")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Open run dialog"):
- machine.send_key("alt-f2")
- machine.wait_for_window("budgie-run-dialog")
- machine.sleep(2)
- machine.screenshot("run_dialog")
- machine.send_key("esc")
+ with subtest("Check if Budgie session components actually start"):
+ for i in ["budgie-daemon", "budgie-panel", "budgie-wm", "budgie-desktop-view", "gsd-media-keys"]:
+ machine.wait_until_succeeds(f"pgrep -f {i}")
+ # We don't check xwininfo for budgie-wm.
+ # See https://github.com/NixOS/nixpkgs/pull/216737#discussion_r1155312754
+ machine.wait_for_window("budgie-daemon")
+ machine.wait_for_window("budgie-panel")
- with subtest("Open Budgie Control Center"):
- machine.succeed("${su "budgie-control-center >&2 &"}")
- machine.wait_for_window("Budgie Control Center")
+ with subtest("Check if various environment variables are set"):
+ cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf /run/current-system/sw/bin/budgie-wm)/environ"
+ machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Budgie:GNOME'")
+ machine.succeed(f"{cmd} | grep 'BUDGIE_PLUGIN_DATADIR' | grep '${pkgs.budgie-desktop-with-plugins.pname}'")
- with subtest("Lock the screen"):
- machine.succeed("${su "budgie-screensaver-command -l >&2 &"}")
- machine.wait_until_succeeds("${su "budgie-screensaver-command -q"} | grep 'The screensaver is active'")
- machine.sleep(2)
- machine.send_chars("${user.password}", delay=0.5)
- machine.screenshot("budgie_screensaver")
- machine.send_chars("\n")
- machine.wait_until_succeeds("${su "budgie-screensaver-command -q"} | grep 'The screensaver is inactive'")
- machine.sleep(2)
+ with subtest("Open run dialog"):
+ machine.send_key("alt-f2")
+ machine.wait_for_window("budgie-run-dialog")
+ machine.sleep(2)
+ machine.screenshot("run_dialog")
+ machine.send_key("esc")
- with subtest("Open GNOME terminal"):
- machine.succeed("${su "gnome-terminal"}")
- machine.wait_for_window("${user.name}@machine: ~")
+ with subtest("Open Budgie Control Center"):
+ machine.succeed("${su "budgie-control-center >&2 &"}")
+ machine.wait_for_window("Budgie Control Center")
- with subtest("Check if Budgie has ever coredumped"):
- machine.fail("coredumpctl --json=short | grep budgie")
- machine.sleep(10)
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Lock the screen"):
+ machine.succeed("${su "budgie-screensaver-command -l >&2 &"}")
+ machine.wait_until_succeeds("${su "budgie-screensaver-command -q"} | grep 'The screensaver is active'")
+ machine.sleep(2)
+ machine.send_chars("${user.password}", delay=0.5)
+ machine.screenshot("budgie_screensaver")
+ machine.send_chars("\n")
+ machine.wait_until_succeeds("${su "budgie-screensaver-command -q"} | grep 'The screensaver is inactive'")
+ machine.sleep(2)
+
+ with subtest("Open GNOME terminal"):
+ machine.succeed("${su "gnome-terminal"}")
+ machine.wait_for_window("${user.name}@machine: ~")
+
+ with subtest("Check if Budgie has ever coredumped"):
+ machine.fail("coredumpctl --json=short | grep budgie")
+ machine.sleep(10)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/buildkite-agents.nix b/nixos/tests/buildkite-agents.nix
index e8934dbaaa5c..e4fe837ea8cc 100644
--- a/nixos/tests/buildkite-agents.nix
+++ b/nixos/tests/buildkite-agents.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- {
- name = "buildkite-agent";
- meta.maintainers = with lib.maintainers; [ flokli ];
+{
+ name = "buildkite-agent";
+ meta.maintainers = with lib.maintainers; [ flokli ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.buildkite-agents = {
- one = {
- privateSshKeyPath = (import ./ssh-keys.nix pkgs).snakeOilPrivateKey;
- tokenPath = (pkgs.writeText "my-token" "5678");
- };
- two = {
- tokenPath = (pkgs.writeText "my-token" "1234");
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.buildkite-agents = {
+ one = {
+ privateSshKeyPath = (import ./ssh-keys.nix pkgs).snakeOilPrivateKey;
+ tokenPath = (pkgs.writeText "my-token" "5678");
+ };
+ two = {
+ tokenPath = (pkgs.writeText "my-token" "1234");
};
};
+ };
- testScript = ''
- start_all()
- # we can't wait on the unit to start up, as we obviously can't connect to buildkite,
- # but we can look whether files are set up correctly
+ testScript = ''
+ start_all()
+ # we can't wait on the unit to start up, as we obviously can't connect to buildkite,
+ # but we can look whether files are set up correctly
- machine.wait_for_file("/var/lib/buildkite-agent-one/buildkite-agent.cfg")
- machine.wait_for_file("/var/lib/buildkite-agent-one/.ssh/id_rsa")
+ machine.wait_for_file("/var/lib/buildkite-agent-one/buildkite-agent.cfg")
+ machine.wait_for_file("/var/lib/buildkite-agent-one/.ssh/id_rsa")
- machine.wait_for_file("/var/lib/buildkite-agent-two/buildkite-agent.cfg")
- '';
- }
-)
+ machine.wait_for_file("/var/lib/buildkite-agent-two/buildkite-agent.cfg")
+ '';
+}
diff --git a/nixos/tests/c2fmzq.nix b/nixos/tests/c2fmzq.nix
index 90d816785e1e..26c2a3349ba4 100644
--- a/nixos/tests/c2fmzq.nix
+++ b/nixos/tests/c2fmzq.nix
@@ -1,87 +1,85 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "c2FmZQ";
- meta.maintainers = with lib.maintainers; [ hmenke ];
+{ pkgs, lib, ... }:
+{
+ name = "c2FmZQ";
+ meta.maintainers = with lib.maintainers; [ hmenke ];
- nodes.machine = {
- services.c2fmzq-server = {
- enable = true;
- port = 8080;
- passphraseFile = builtins.toFile "pwfile" "hunter2"; # don't do this on real deployments
- settings = {
- verbose = 3; # debug
- # make sure multiple freeform options evaluate
- allow-new-accounts = true;
- auto-approve-new-accounts = true;
- licenses = false;
- };
- };
- environment = {
- sessionVariables = {
- C2FMZQ_PASSPHRASE = "lol";
- C2FMZQ_API_SERVER = "http://localhost:8080";
- };
- systemPackages = [
- pkgs.c2fmzq
- (pkgs.writeScriptBin "c2FmZQ-client-wrapper" ''
- #!${pkgs.expect}/bin/expect -f
- spawn c2FmZQ-client {*}$argv
- expect {
- "Enter password:" { send "$env(PASSWORD)\r" }
- "Type YES to confirm:" { send "YES\r" }
- timeout { exit 1 }
- eof { exit 0 }
- }
- interact
- '')
- ];
+ nodes.machine = {
+ services.c2fmzq-server = {
+ enable = true;
+ port = 8080;
+ passphraseFile = builtins.toFile "pwfile" "hunter2"; # don't do this on real deployments
+ settings = {
+ verbose = 3; # debug
+ # make sure multiple freeform options evaluate
+ allow-new-accounts = true;
+ auto-approve-new-accounts = true;
+ licenses = false;
};
};
+ environment = {
+ sessionVariables = {
+ C2FMZQ_PASSPHRASE = "lol";
+ C2FMZQ_API_SERVER = "http://localhost:8080";
+ };
+ systemPackages = [
+ pkgs.c2fmzq
+ (pkgs.writeScriptBin "c2FmZQ-client-wrapper" ''
+ #!${pkgs.expect}/bin/expect -f
+ spawn c2FmZQ-client {*}$argv
+ expect {
+ "Enter password:" { send "$env(PASSWORD)\r" }
+ "Type YES to confirm:" { send "YES\r" }
+ timeout { exit 1 }
+ eof { exit 0 }
+ }
+ interact
+ '')
+ ];
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- machine.start()
- machine.wait_for_unit("c2fmzq-server.service")
- machine.wait_for_open_port(8080)
+ testScript =
+ { nodes, ... }:
+ ''
+ machine.start()
+ machine.wait_for_unit("c2fmzq-server.service")
+ machine.wait_for_open_port(8080)
- with subtest("Create accounts for alice and bob"):
- machine.succeed("PASSWORD=foobar c2FmZQ-client-wrapper -- -v 3 create-account alice@example.com")
- machine.succeed("PASSWORD=fizzbuzz c2FmZQ-client-wrapper -- -v 3 create-account bob@example.com")
+ with subtest("Create accounts for alice and bob"):
+ machine.succeed("PASSWORD=foobar c2FmZQ-client-wrapper -- -v 3 create-account alice@example.com")
+ machine.succeed("PASSWORD=fizzbuzz c2FmZQ-client-wrapper -- -v 3 create-account bob@example.com")
- with subtest("Log in as alice"):
- machine.succeed("PASSWORD=foobar c2FmZQ-client-wrapper -- -v 3 login alice@example.com")
- msg = machine.succeed("c2FmZQ-client -v 3 status")
- assert "Logged in as alice@example.com" in msg, f"ERROR: Not logged in as alice:\n{msg}"
+ with subtest("Log in as alice"):
+ machine.succeed("PASSWORD=foobar c2FmZQ-client-wrapper -- -v 3 login alice@example.com")
+ msg = machine.succeed("c2FmZQ-client -v 3 status")
+ assert "Logged in as alice@example.com" in msg, f"ERROR: Not logged in as alice:\n{msg}"
- with subtest("Create a new album, upload a file, and delete the uploaded file"):
- machine.succeed("c2FmZQ-client -v 3 create-album 'Rarest Memes'")
- machine.succeed("echo 'pls do not steal' > meme.txt")
- machine.succeed("c2FmZQ-client -v 3 import meme.txt 'Rarest Memes'")
- machine.succeed("c2FmZQ-client -v 3 sync")
- machine.succeed("rm meme.txt")
+ with subtest("Create a new album, upload a file, and delete the uploaded file"):
+ machine.succeed("c2FmZQ-client -v 3 create-album 'Rarest Memes'")
+ machine.succeed("echo 'pls do not steal' > meme.txt")
+ machine.succeed("c2FmZQ-client -v 3 import meme.txt 'Rarest Memes'")
+ machine.succeed("c2FmZQ-client -v 3 sync")
+ machine.succeed("rm meme.txt")
- with subtest("Share the album with bob"):
- machine.succeed("c2FmZQ-client-wrapper -- -v 3 share 'Rarest Memes' bob@example.com")
+ with subtest("Share the album with bob"):
+ machine.succeed("c2FmZQ-client-wrapper -- -v 3 share 'Rarest Memes' bob@example.com")
- with subtest("Log in as bob"):
- machine.succeed("PASSWORD=fizzbuzz c2FmZQ-client-wrapper -- -v 3 login bob@example.com")
- msg = machine.succeed("c2FmZQ-client -v 3 status")
- assert "Logged in as bob@example.com" in msg, f"ERROR: Not logged in as bob:\n{msg}"
+ with subtest("Log in as bob"):
+ machine.succeed("PASSWORD=fizzbuzz c2FmZQ-client-wrapper -- -v 3 login bob@example.com")
+ msg = machine.succeed("c2FmZQ-client -v 3 status")
+ assert "Logged in as bob@example.com" in msg, f"ERROR: Not logged in as bob:\n{msg}"
- with subtest("Download the shared file"):
- machine.succeed("c2FmZQ-client -v 3 download 'shared/Rarest Memes/meme.txt'")
- machine.succeed("c2FmZQ-client -v 3 export 'shared/Rarest Memes/meme.txt' .")
- msg = machine.succeed("cat meme.txt")
- assert "pls do not steal\n" == msg, f"File content is not the same:\n{msg}"
+ with subtest("Download the shared file"):
+ machine.succeed("c2FmZQ-client -v 3 download 'shared/Rarest Memes/meme.txt'")
+ machine.succeed("c2FmZQ-client -v 3 export 'shared/Rarest Memes/meme.txt' .")
+ msg = machine.succeed("cat meme.txt")
+ assert "pls do not steal\n" == msg, f"File content is not the same:\n{msg}"
- with subtest("Test that PWA is served"):
- msg = machine.succeed("curl -sSfL http://localhost:8080")
- assert "c2FmZQ" in msg, f"Could not find 'c2FmZQ' in the output:\n{msg}"
+ with subtest("Test that PWA is served"):
+ msg = machine.succeed("curl -sSfL http://localhost:8080")
+ assert "c2FmZQ" in msg, f"Could not find 'c2FmZQ' in the output:\n{msg}"
- with subtest("A setting with false value is properly passed"):
- machine.succeed("systemctl show -p ExecStart --value c2fmzq-server.service | grep -F -- '--licenses=false'");
- '';
- }
-)
+ with subtest("A setting with false value is properly passed"):
+ machine.succeed("systemctl show -p ExecStart --value c2fmzq-server.service | grep -F -- '--licenses=false'");
+ '';
+}
diff --git a/nixos/tests/cage.nix b/nixos/tests/cage.nix
index e9c025e51021..585968b5e0e4 100644
--- a/nixos/tests/cage.nix
+++ b/nixos/tests/cage.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "cage";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ matthewbauer ];
- };
+{
+ name = "cage";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ matthewbauer ];
+ };
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [ ./common/user-account.nix ];
+ {
+ imports = [ ./common/user-account.nix ];
- fonts.packages = with pkgs; [ dejavu_fonts ];
+ fonts.packages = with pkgs; [ dejavu_fonts ];
- services.cage = {
- enable = true;
- user = "alice";
- program = "${pkgs.xterm}/bin/xterm";
- };
-
- # Need to switch to a different GPU driver than the default one (-vga std) so that Cage can launch:
- virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
+ services.cage = {
+ enable = true;
+ user = "alice";
+ program = "${pkgs.xterm}/bin/xterm";
};
- enableOCR = true;
+ # Need to switch to a different GPU driver than the default one (-vga std) so that Cage can launch:
+ virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
+ };
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.config.users.users.alice;
- in
- ''
- with subtest("Wait for cage to boot up"):
- start_all()
- machine.wait_for_file("/run/user/${toString user.uid}/wayland-0.lock")
- machine.wait_until_succeeds("pgrep xterm")
- machine.wait_for_text("alice@machine")
- machine.screenshot("screen")
- '';
- }
-)
+ enableOCR = true;
+
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.config.users.users.alice;
+ in
+ ''
+ with subtest("Wait for cage to boot up"):
+ start_all()
+ machine.wait_for_file("/run/user/${toString user.uid}/wayland-0.lock")
+ machine.wait_until_succeeds("pgrep xterm")
+ machine.wait_for_text("alice@machine")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/cagebreak.nix b/nixos/tests/cagebreak.nix
index 2c07833b142f..13012281a151 100644
--- a/nixos/tests/cagebreak.nix
+++ b/nixos/tests/cagebreak.nix
@@ -1,72 +1,70 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- cagebreakConfigfile = pkgs.writeText "config" ''
- workspaces 1
- escape C-t
- bind t exec env DISPLAY=:0 ${pkgs.xterm}/bin/xterm -cm -pc
- '';
- in
- {
- name = "cagebreak";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ berbiche ];
+let
+ cagebreakConfigfile = pkgs.writeText "config" ''
+ workspaces 1
+ escape C-t
+ bind t exec env DISPLAY=:0 ${pkgs.xterm}/bin/xterm -cm -pc
+ '';
+in
+{
+ name = "cagebreak";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ berbiche ];
+ };
+
+ nodes.machine =
+ { config, ... }:
+ {
+ # Automatically login on tty1 as a normal user:
+ imports = [ ./common/user-account.nix ];
+ services.getty.autologinUser = "alice";
+ programs.bash.loginShellInit = ''
+ if [ "$(tty)" = "/dev/tty1" ]; then
+ set -e
+
+ mkdir -p ~/.config/cagebreak
+ cp -f ${cagebreakConfigfile} ~/.config/cagebreak/config
+
+ cagebreak
+ fi
+ '';
+
+ hardware.graphics.enable = true;
+ programs.xwayland.enable = true;
+ security.polkit.enable = true;
+ environment.systemPackages = [
+ pkgs.cagebreak
+ pkgs.wayland-utils
+ ];
+
+ # Need to switch to a different GPU driver than the default one (-vga std) so that Cagebreak can launch:
+ virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
};
- nodes.machine =
- { config, ... }:
- {
- # Automatically login on tty1 as a normal user:
- imports = [ ./common/user-account.nix ];
- services.getty.autologinUser = "alice";
- programs.bash.loginShellInit = ''
- if [ "$(tty)" = "/dev/tty1" ]; then
- set -e
+ enableOCR = true;
- mkdir -p ~/.config/cagebreak
- cp -f ${cagebreakConfigfile} ~/.config/cagebreak/config
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.config.users.users.alice;
+ XDG_RUNTIME_DIR = "/run/user/${toString user.uid}";
+ in
+ ''
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_for_file("${XDG_RUNTIME_DIR}/wayland-0")
- cagebreak
- fi
- '';
+ with subtest("ensure wayland works with wayinfo from wallutils"):
+ print(machine.succeed("env XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} wayland-info"))
- hardware.graphics.enable = true;
- programs.xwayland.enable = true;
- security.polkit.enable = true;
- environment.systemPackages = [
- pkgs.cagebreak
- pkgs.wayland-utils
- ];
-
- # Need to switch to a different GPU driver than the default one (-vga std) so that Cagebreak can launch:
- virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
- };
-
- enableOCR = true;
-
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.config.users.users.alice;
- XDG_RUNTIME_DIR = "/run/user/${toString user.uid}";
- in
- ''
- start_all()
- machine.wait_for_unit("multi-user.target")
- machine.wait_for_file("${XDG_RUNTIME_DIR}/wayland-0")
-
- with subtest("ensure wayland works with wayinfo from wallutils"):
- print(machine.succeed("env XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} wayland-info"))
-
- # TODO: Fix the XWayland test (log the cagebreak output to debug):
- # with subtest("ensure xwayland works with xterm"):
- # machine.send_key("ctrl-t")
- # machine.send_key("t")
- # machine.wait_until_succeeds("pgrep xterm")
- # machine.wait_for_text("${user.name}@machine")
- # machine.screenshot("screen")
- # machine.send_key("ctrl-d")
- '';
- }
-)
+ # TODO: Fix the XWayland test (log the cagebreak output to debug):
+ # with subtest("ensure xwayland works with xterm"):
+ # machine.send_key("ctrl-t")
+ # machine.send_key("t")
+ # machine.wait_until_succeeds("pgrep xterm")
+ # machine.wait_for_text("${user.name}@machine")
+ # machine.screenshot("screen")
+ # machine.send_key("ctrl-d")
+ '';
+}
diff --git a/nixos/tests/canaille.nix b/nixos/tests/canaille.nix
index 58e81e058de0..fa0d33b0f2e2 100644
--- a/nixos/tests/canaille.nix
+++ b/nixos/tests/canaille.nix
@@ -1,62 +1,60 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- certs = import ./common/acme/server/snakeoil-certs.nix;
- inherit (certs) domain;
- in
- {
- name = "canaille";
- meta.maintainers = with pkgs.lib.maintainers; [ erictapen ];
+{ pkgs, ... }:
+let
+ certs = import ./common/acme/server/snakeoil-certs.nix;
+ inherit (certs) domain;
+in
+{
+ name = "canaille";
+ meta.maintainers = with pkgs.lib.maintainers; [ erictapen ];
- nodes.server =
- { pkgs, lib, ... }:
- {
- services.canaille = {
- enable = true;
- secretKeyFile = pkgs.writeText "canaille-secret-key" ''
- this is not a secret key
- '';
- settings = {
- SERVER_NAME = domain;
- };
+ nodes.server =
+ { pkgs, lib, ... }:
+ {
+ services.canaille = {
+ enable = true;
+ secretKeyFile = pkgs.writeText "canaille-secret-key" ''
+ this is not a secret key
+ '';
+ settings = {
+ SERVER_NAME = domain;
};
-
- services.nginx.virtualHosts."${domain}" = {
- enableACME = lib.mkForce false;
- sslCertificate = certs."${domain}".cert;
- sslCertificateKey = certs."${domain}".key;
- };
-
- networking.hosts."::1" = [ "${domain}" ];
- networking.firewall.allowedTCPPorts = [
- 80
- 443
- ];
-
- users.users.canaille.shell = pkgs.bashInteractive;
-
- security.pki.certificateFiles = [ certs.ca.cert ];
};
- nodes.client =
- { nodes, ... }:
- {
- networking.hosts."${nodes.server.networking.primaryIPAddress}" = [ "${domain}" ];
- security.pki.certificateFiles = [ certs.ca.cert ];
+ services.nginx.virtualHosts."${domain}" = {
+ enableACME = lib.mkForce false;
+ sslCertificate = certs."${domain}".cert;
+ sslCertificateKey = certs."${domain}".key;
};
- testScript =
- { ... }:
- ''
- import json
+ networking.hosts."::1" = [ "${domain}" ];
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
+ ];
- start_all()
- server.wait_for_unit("canaille.socket")
- server.wait_until_succeeds("curl -f https://${domain}")
- server.succeed("sudo -iu canaille -- canaille create user --user-name admin --password adminpass --emails admin@${domain}")
- json_str = server.succeed("sudo -iu canaille -- canaille get user")
- assert json.loads(json_str)[0]["user_name"] == "admin"
- server.succeed("sudo -iu canaille -- canaille config check")
- '';
- }
-)
+ users.users.canaille.shell = pkgs.bashInteractive;
+
+ security.pki.certificateFiles = [ certs.ca.cert ];
+ };
+
+ nodes.client =
+ { nodes, ... }:
+ {
+ networking.hosts."${nodes.server.networking.primaryIPAddress}" = [ "${domain}" ];
+ security.pki.certificateFiles = [ certs.ca.cert ];
+ };
+
+ testScript =
+ { ... }:
+ ''
+ import json
+
+ start_all()
+ server.wait_for_unit("canaille.socket")
+ server.wait_until_succeeds("curl -f https://${domain}")
+ server.succeed("sudo -iu canaille -- canaille create user --user-name admin --password adminpass --emails admin@${domain}")
+ json_str = server.succeed("sudo -iu canaille -- canaille get user")
+ assert json.loads(json_str)[0]["user_name"] == "admin"
+ server.succeed("sudo -iu canaille -- canaille config check")
+ '';
+}
diff --git a/nixos/tests/castopod.nix b/nixos/tests/castopod.nix
index 3d62cc0711fe..608526c728c6 100644
--- a/nixos/tests/castopod.nix
+++ b/nixos/tests/castopod.nix
@@ -1,250 +1,248 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "castopod";
- meta = with lib.maintainers; {
- maintainers = [ alexoundos ];
+{ pkgs, lib, ... }:
+{
+ name = "castopod";
+ meta = with lib.maintainers; {
+ maintainers = [ alexoundos ];
+ };
+
+ nodes.castopod =
+ { nodes, ... }:
+ {
+ # otherwise 500 MiB file upload fails!
+ virtualisation.diskSize = 512 + 3 * 512;
+
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ networking.extraHosts = lib.strings.concatStringsSep "\n" (
+ lib.attrsets.mapAttrsToList (
+ name: _: "127.0.0.1 ${name}"
+ ) nodes.castopod.services.nginx.virtualHosts
+ );
+
+ services.castopod = {
+ enable = true;
+ database.createLocally = true;
+ localDomain = "castopod.example.com";
+ maxUploadSize = "512M";
+ };
};
- nodes.castopod =
- { nodes, ... }:
- {
- # otherwise 500 MiB file upload fails!
- virtualisation.diskSize = 512 + 3 * 512;
+ nodes.client =
+ {
+ nodes,
+ pkgs,
+ lib,
+ ...
+ }:
+ let
+ domain = nodes.castopod.services.castopod.localDomain;
- networking.firewall.allowedTCPPorts = [ 80 ];
- networking.extraHosts = lib.strings.concatStringsSep "\n" (
- lib.attrsets.mapAttrsToList (
- name: _: "127.0.0.1 ${name}"
- ) nodes.castopod.services.nginx.virtualHosts
- );
+ getIP = node: (builtins.head node.networking.interfaces.eth1.ipv4.addresses).address;
- services.castopod = {
- enable = true;
- database.createLocally = true;
- localDomain = "castopod.example.com";
- maxUploadSize = "512M";
- };
- };
+ targetPodcastSize = 500 * 1024 * 1024;
+ lameMp3Bitrate = 348300;
+ lameMp3FileAdjust = -800;
+ targetPodcastDuration = toString ((targetPodcastSize + lameMp3FileAdjust) / (lameMp3Bitrate / 8));
+ bannerWidth = 3000;
+ banner = pkgs.runCommand "gen-castopod-cover.jpg" { } ''
+ ${pkgs.imagemagick}/bin/magick `
+ `-background green -bordercolor white -gravity northwest xc:black `
+ `-duplicate 99 `
+ `-seed 1 -resize "%[fx:rand()*72+24]" `
+ `-seed 0 -rotate "%[fx:rand()*360]" -border 6x6 -splice 16x36 `
+ `-seed 0 -rotate "%[fx:floor(rand()*4)*90]" -resize "150x50!" `
+ `+append -crop 10x1@ +repage -roll "+%[fx:(t%2)*72]+0" -append `
+ `-resize ${toString bannerWidth} -quality 1 $out
+ '';
- nodes.client =
- {
- nodes,
- pkgs,
- lib,
- ...
- }:
- let
- domain = nodes.castopod.services.castopod.localDomain;
+ coverWidth = toString 3000;
+ cover = pkgs.runCommand "gen-castopod-banner.jpg" { } ''
+ ${pkgs.imagemagick}/bin/magick `
+ `-background white -bordercolor white -gravity northwest xc:black `
+ `-duplicate 99 `
+ `-seed 1 -resize "%[fx:rand()*72+24]" `
+ `-seed 0 -rotate "%[fx:rand()*360]" -border 6x6 -splice 36x36 `
+ `-seed 0 -rotate "%[fx:floor(rand()*4)*90]" -resize "144x144!" `
+ `+append -crop 10x1@ +repage -roll "+%[fx:(t%2)*72]+0" -append `
+ `-resize ${coverWidth} -quality 1 $out
+ '';
+ in
+ {
+ networking.extraHosts = lib.strings.concatStringsSep "\n" (
+ lib.attrsets.mapAttrsToList (
+ name: _: "${getIP nodes.castopod} ${name}"
+ ) nodes.castopod.services.nginx.virtualHosts
+ );
- getIP = node: (builtins.head node.networking.interfaces.eth1.ipv4.addresses).address;
+ environment.systemPackages =
+ let
+ username = "admin";
+ email = "admin@${domain}";
+ password = "Abcd1234";
+ podcastTitle = "Some Title";
+ episodeTitle = "Episode Title";
+ browser-test =
+ pkgs.writers.writePython3Bin "browser-test"
+ {
+ libraries = [ pkgs.python3Packages.selenium ];
+ flakeIgnore = [
+ "E124"
+ "E501"
+ ];
+ }
+ ''
+ from selenium.webdriver.common.by import By
+ from selenium.webdriver import Firefox
+ from selenium.webdriver.firefox.options import Options
+ from selenium.webdriver.firefox.service import Service
+ from selenium.webdriver.support.ui import WebDriverWait
+ from selenium.webdriver.support import expected_conditions as EC
+ from subprocess import STDOUT
+ import logging
- targetPodcastSize = 500 * 1024 * 1024;
- lameMp3Bitrate = 348300;
- lameMp3FileAdjust = -800;
- targetPodcastDuration = toString ((targetPodcastSize + lameMp3FileAdjust) / (lameMp3Bitrate / 8));
- bannerWidth = 3000;
- banner = pkgs.runCommand "gen-castopod-cover.jpg" { } ''
- ${pkgs.imagemagick}/bin/magick `
- `-background green -bordercolor white -gravity northwest xc:black `
- `-duplicate 99 `
- `-seed 1 -resize "%[fx:rand()*72+24]" `
- `-seed 0 -rotate "%[fx:rand()*360]" -border 6x6 -splice 16x36 `
- `-seed 0 -rotate "%[fx:floor(rand()*4)*90]" -resize "150x50!" `
- `+append -crop 10x1@ +repage -roll "+%[fx:(t%2)*72]+0" -append `
- `-resize ${toString bannerWidth} -quality 1 $out
- '';
+ selenium_logger = logging.getLogger("selenium")
+ selenium_logger.setLevel(logging.DEBUG)
+ selenium_logger.addHandler(logging.StreamHandler())
- coverWidth = toString 3000;
- cover = pkgs.runCommand "gen-castopod-banner.jpg" { } ''
- ${pkgs.imagemagick}/bin/magick `
- `-background white -bordercolor white -gravity northwest xc:black `
- `-duplicate 99 `
- `-seed 1 -resize "%[fx:rand()*72+24]" `
- `-seed 0 -rotate "%[fx:rand()*360]" -border 6x6 -splice 36x36 `
- `-seed 0 -rotate "%[fx:floor(rand()*4)*90]" -resize "144x144!" `
- `+append -crop 10x1@ +repage -roll "+%[fx:(t%2)*72]+0" -append `
- `-resize ${coverWidth} -quality 1 $out
- '';
- in
- {
- networking.extraHosts = lib.strings.concatStringsSep "\n" (
- lib.attrsets.mapAttrsToList (
- name: _: "${getIP nodes.castopod} ${name}"
- ) nodes.castopod.services.nginx.virtualHosts
- );
+ options = Options()
+ options.add_argument('--headless')
+ service = Service(log_output=STDOUT)
+ driver = Firefox(options=options, service=service)
+ driver = Firefox(options=options)
+ driver.implicitly_wait(30)
+ driver.set_page_load_timeout(60)
- environment.systemPackages =
- let
- username = "admin";
- email = "admin@${domain}";
- password = "Abcd1234";
- podcastTitle = "Some Title";
- episodeTitle = "Episode Title";
- browser-test =
- pkgs.writers.writePython3Bin "browser-test"
- {
- libraries = [ pkgs.python3Packages.selenium ];
- flakeIgnore = [
- "E124"
- "E501"
- ];
- }
- ''
- from selenium.webdriver.common.by import By
- from selenium.webdriver import Firefox
- from selenium.webdriver.firefox.options import Options
- from selenium.webdriver.firefox.service import Service
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from subprocess import STDOUT
- import logging
+ # install ##########################################################
- selenium_logger = logging.getLogger("selenium")
- selenium_logger.setLevel(logging.DEBUG)
- selenium_logger.addHandler(logging.StreamHandler())
+ driver.get('http://${domain}/cp-install')
- options = Options()
- options.add_argument('--headless')
- service = Service(log_output=STDOUT)
- driver = Firefox(options=options, service=service)
- driver = Firefox(options=options)
- driver.implicitly_wait(30)
- driver.set_page_load_timeout(60)
+ wait = WebDriverWait(driver, 20)
- # install ##########################################################
+ wait.until(EC.title_contains("installer"))
- driver.get('http://${domain}/cp-install')
+ driver.find_element(By.CSS_SELECTOR, '#username').send_keys(
+ '${username}'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#email').send_keys(
+ '${email}'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#password').send_keys(
+ '${password}'
+ )
+ driver.find_element(By.XPATH,
+ "//button[contains(., 'Finish install')]"
+ ).click()
- wait = WebDriverWait(driver, 20)
+ wait.until(EC.title_contains("Auth"))
- wait.until(EC.title_contains("installer"))
+ driver.find_element(By.CSS_SELECTOR, '#email').send_keys(
+ '${email}'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#password').send_keys(
+ '${password}'
+ )
+ driver.find_element(By.XPATH,
+ "//button[contains(., 'Login')]"
+ ).click()
- driver.find_element(By.CSS_SELECTOR, '#username').send_keys(
- '${username}'
- )
- driver.find_element(By.CSS_SELECTOR, '#email').send_keys(
- '${email}'
- )
- driver.find_element(By.CSS_SELECTOR, '#password').send_keys(
- '${password}'
- )
- driver.find_element(By.XPATH,
- "//button[contains(., 'Finish install')]"
- ).click()
+ wait.until(EC.title_contains("Admin dashboard"))
- wait.until(EC.title_contains("Auth"))
+ # create podcast ###################################################
- driver.find_element(By.CSS_SELECTOR, '#email').send_keys(
- '${email}'
- )
- driver.find_element(By.CSS_SELECTOR, '#password').send_keys(
- '${password}'
- )
- driver.find_element(By.XPATH,
- "//button[contains(., 'Login')]"
- ).click()
+ driver.get('http://${domain}/admin/podcasts/new')
- wait.until(EC.title_contains("Admin dashboard"))
+ wait.until(EC.title_contains("Create podcast"))
- # create podcast ###################################################
+ driver.find_element(By.CSS_SELECTOR, '#cover').send_keys(
+ '${cover}'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#banner').send_keys(
+ '${banner}'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#title').send_keys(
+ '${podcastTitle}'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#handle').send_keys(
+ 'some_handle'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#description').send_keys(
+ 'Some description'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#owner_name').send_keys(
+ 'Owner Name'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#owner_email').send_keys(
+ 'owner@email.xyz'
+ )
+ driver.find_element(By.XPATH,
+ "//button[contains(., 'Create podcast')]"
+ ).click()
- driver.get('http://${domain}/admin/podcasts/new')
+ wait.until(EC.title_contains("${podcastTitle}"))
- wait.until(EC.title_contains("Create podcast"))
+ driver.find_element(By.XPATH,
+ "//span[contains(., 'Add an episode')]"
+ ).click()
- driver.find_element(By.CSS_SELECTOR, '#cover').send_keys(
- '${cover}'
- )
- driver.find_element(By.CSS_SELECTOR, '#banner').send_keys(
- '${banner}'
- )
- driver.find_element(By.CSS_SELECTOR, '#title').send_keys(
- '${podcastTitle}'
- )
- driver.find_element(By.CSS_SELECTOR, '#handle').send_keys(
- 'some_handle'
- )
- driver.find_element(By.CSS_SELECTOR, '#description').send_keys(
- 'Some description'
- )
- driver.find_element(By.CSS_SELECTOR, '#owner_name').send_keys(
- 'Owner Name'
- )
- driver.find_element(By.CSS_SELECTOR, '#owner_email').send_keys(
- 'owner@email.xyz'
- )
- driver.find_element(By.XPATH,
- "//button[contains(., 'Create podcast')]"
- ).click()
+ wait.until(EC.title_contains("Add an episode"))
- wait.until(EC.title_contains("${podcastTitle}"))
+ # upload podcast ###################################################
- driver.find_element(By.XPATH,
- "//span[contains(., 'Add an episode')]"
- ).click()
+ driver.find_element(By.CSS_SELECTOR, '#audio_file').send_keys(
+ '/tmp/podcast.mp3'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#cover').send_keys(
+ '${cover}'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#description').send_keys(
+ 'Episode description'
+ )
+ driver.find_element(By.CSS_SELECTOR, '#title').send_keys(
+ '${episodeTitle}'
+ )
+ driver.find_element(By.XPATH,
+ "//button[contains(., 'Create episode')]"
+ ).click()
- wait.until(EC.title_contains("Add an episode"))
+ wait.until(EC.title_contains("${episodeTitle}"))
- # upload podcast ###################################################
-
- driver.find_element(By.CSS_SELECTOR, '#audio_file').send_keys(
- '/tmp/podcast.mp3'
- )
- driver.find_element(By.CSS_SELECTOR, '#cover').send_keys(
- '${cover}'
- )
- driver.find_element(By.CSS_SELECTOR, '#description').send_keys(
- 'Episode description'
- )
- driver.find_element(By.CSS_SELECTOR, '#title').send_keys(
- '${episodeTitle}'
- )
- driver.find_element(By.XPATH,
- "//button[contains(., 'Create episode')]"
- ).click()
-
- wait.until(EC.title_contains("${episodeTitle}"))
-
- driver.close()
- driver.quit()
- '';
- in
- [
- pkgs.firefox-unwrapped
- pkgs.geckodriver
- browser-test
- (pkgs.writeShellApplication {
- name = "build-mp3";
- runtimeInputs = with pkgs; [
- sox
- lame
- ];
- text = ''
- out=/tmp/podcast.mp3
- sox -n -r 48000 -t wav - synth ${targetPodcastDuration} sine 440 `
- `| lame --noreplaygain --cbr -q 9 -b 320 - $out
- FILESIZE="$(stat -c%s $out)"
- [ "$FILESIZE" -gt 0 ]
- [ "$FILESIZE" -le "${toString targetPodcastSize}" ]
+ driver.close()
+ driver.quit()
'';
- })
- ];
- };
+ in
+ [
+ pkgs.firefox-unwrapped
+ pkgs.geckodriver
+ browser-test
+ (pkgs.writeShellApplication {
+ name = "build-mp3";
+ runtimeInputs = with pkgs; [
+ sox
+ lame
+ ];
+ text = ''
+ out=/tmp/podcast.mp3
+ sox -n -r 48000 -t wav - synth ${targetPodcastDuration} sine 440 `
+ `| lame --noreplaygain --cbr -q 9 -b 320 - $out
+ FILESIZE="$(stat -c%s $out)"
+ [ "$FILESIZE" -gt 0 ]
+ [ "$FILESIZE" -le "${toString targetPodcastSize}" ]
+ '';
+ })
+ ];
+ };
- testScript = ''
- start_all()
- castopod.wait_for_unit("castopod-setup.service")
- castopod.wait_for_file("/run/phpfpm/castopod.sock")
- castopod.wait_for_unit("nginx.service")
- castopod.wait_for_open_port(80)
- castopod.wait_until_succeeds("curl -sS -f http://castopod.example.com")
+ testScript = ''
+ start_all()
+ castopod.wait_for_unit("castopod-setup.service")
+ castopod.wait_for_file("/run/phpfpm/castopod.sock")
+ castopod.wait_for_unit("nginx.service")
+ castopod.wait_for_open_port(80)
+ castopod.wait_until_succeeds("curl -sS -f http://castopod.example.com")
- client.succeed("build-mp3")
+ client.succeed("build-mp3")
- with subtest("Create superadmin, log in, create and upload a podcast"):
- client.succeed(\
- "PYTHONUNBUFFERED=1 systemd-cat -t browser-test browser-test")
- '';
- }
-)
+ with subtest("Create superadmin, log in, create and upload a podcast"):
+ client.succeed(\
+ "PYTHONUNBUFFERED=1 systemd-cat -t browser-test browser-test")
+ '';
+}
diff --git a/nixos/tests/charliecloud.nix b/nixos/tests/charliecloud.nix
index 957ec6ea4374..abdb2d877c19 100644
--- a/nixos/tests/charliecloud.nix
+++ b/nixos/tests/charliecloud.nix
@@ -1,49 +1,47 @@
# This test checks charliecloud image construction and run
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
+{ pkgs, ... }:
+let
- dockerfile = pkgs.writeText "Dockerfile" ''
- FROM nix
- RUN mkdir /home /tmp
- RUN touch /etc/passwd /etc/group
- CMD ["true"]
- '';
+ dockerfile = pkgs.writeText "Dockerfile" ''
+ FROM nix
+ RUN mkdir /home /tmp
+ RUN touch /etc/passwd /etc/group
+ CMD ["true"]
+ '';
- in
- {
- name = "charliecloud";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ bzizou ];
- };
+in
+{
+ name = "charliecloud";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ bzizou ];
+ };
- nodes = {
- host =
- { ... }:
- {
- environment.systemPackages = [ pkgs.charliecloud ];
- virtualisation.docker.enable = true;
- users.users.alice = {
- isNormalUser = true;
- extraGroups = [ "docker" ];
- };
+ nodes = {
+ host =
+ { ... }:
+ {
+ environment.systemPackages = [ pkgs.charliecloud ];
+ virtualisation.docker.enable = true;
+ users.users.alice = {
+ isNormalUser = true;
+ extraGroups = [ "docker" ];
};
- };
+ };
+ };
- testScript = ''
- host.start()
- host.wait_for_unit("docker.service")
- host.succeed(
- 'su - alice -c "docker load --input=${pkgs.dockerTools.examples.nix}"'
- )
- host.succeed(
- "cp ${dockerfile} /home/alice/Dockerfile"
- )
- host.succeed('su - alice -c "ch-build -t hello ."')
- host.succeed('su - alice -c "ch-builder2tar hello /var/tmp"')
- host.succeed('su - alice -c "ch-tar2dir /var/tmp/hello.tar.gz /var/tmp"')
- host.succeed('su - alice -c "ch-run /var/tmp/hello -- echo Running_From_Container_OK"')
- '';
- }
-)
+ testScript = ''
+ host.start()
+ host.wait_for_unit("docker.service")
+ host.succeed(
+ 'su - alice -c "docker load --input=${pkgs.dockerTools.examples.nix}"'
+ )
+ host.succeed(
+ "cp ${dockerfile} /home/alice/Dockerfile"
+ )
+ host.succeed('su - alice -c "ch-build -t hello ."')
+ host.succeed('su - alice -c "ch-builder2tar hello /var/tmp"')
+ host.succeed('su - alice -c "ch-tar2dir /var/tmp/hello.tar.gz /var/tmp"')
+ host.succeed('su - alice -c "ch-run /var/tmp/hello -- echo Running_From_Container_OK"')
+ '';
+}
diff --git a/nixos/tests/cinnamon-wayland.nix b/nixos/tests/cinnamon-wayland.nix
index 1b472f863099..a80199956cc2 100644
--- a/nixos/tests/cinnamon-wayland.nix
+++ b/nixos/tests/cinnamon-wayland.nix
@@ -1,84 +1,82 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "cinnamon-wayland";
+{ pkgs, lib, ... }:
+{
+ name = "cinnamon-wayland";
- meta.maintainers = lib.teams.cinnamon.members;
+ meta.maintainers = lib.teams.cinnamon.members;
- nodes.machine =
- { nodes, ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.xserver.desktopManager.cinnamon.enable = true;
- services.displayManager = {
- autoLogin.enable = true;
- autoLogin.user = nodes.machine.users.users.alice.name;
- defaultSession = "cinnamon-wayland";
- };
-
- # For the sessionPath subtest.
- services.xserver.desktopManager.cinnamon.sessionPath = [ pkgs.gpaste ];
+ nodes.machine =
+ { nodes, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.xserver.desktopManager.cinnamon.enable = true;
+ services.displayManager = {
+ autoLogin.enable = true;
+ autoLogin.user = nodes.machine.users.users.alice.name;
+ defaultSession = "cinnamon-wayland";
};
- enableOCR = true;
+ # For the sessionPath subtest.
+ services.xserver.desktopManager.cinnamon.sessionPath = [ pkgs.gpaste ];
+ };
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus";
- su = command: "su - ${user.name} -c '${env} ${command}'";
+ enableOCR = true;
- # Call javascript in cinnamon (the shell), returns a tuple (success, output),
- # where `success` is true if the dbus call was successful and `output` is what
- # the javascript evaluates to.
- eval =
- name: su "gdbus call --session -d org.Cinnamon -o /org/Cinnamon -m org.Cinnamon.Eval ${name}";
- in
- ''
- machine.wait_for_unit("display-manager.service")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus";
+ su = command: "su - ${user.name} -c '${env} ${command}'";
- with subtest("Wait for wayland server"):
- machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
+ # Call javascript in cinnamon (the shell), returns a tuple (success, output),
+ # where `success` is true if the dbus call was successful and `output` is what
+ # the javascript evaluates to.
+ eval =
+ name: su "gdbus call --session -d org.Cinnamon -o /org/Cinnamon -m org.Cinnamon.Eval ${name}";
+ in
+ ''
+ machine.wait_for_unit("display-manager.service")
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ with subtest("Wait for wayland server"):
+ machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
- with subtest("Wait for the Cinnamon shell"):
- # Correct output should be (true, '2')
- # https://github.com/linuxmint/cinnamon/blob/5.4.0/js/ui/main.js#L183-L187
- machine.wait_until_succeeds("${eval "Main.runState"} | grep -q 'true,..2'")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Check if Cinnamon components actually start"):
- for i in ["csd-media-keys", "xapp-sn-watcher", "nemo-desktop"]:
- machine.wait_until_succeeds(f"pgrep -f {i}")
- machine.wait_until_succeeds("journalctl -b --grep 'Loaded applet menu@cinnamon.org'")
- machine.wait_until_succeeds("journalctl -b --grep 'calendar@cinnamon.org: Calendar events supported'")
+ with subtest("Wait for the Cinnamon shell"):
+ # Correct output should be (true, '2')
+ # https://github.com/linuxmint/cinnamon/blob/5.4.0/js/ui/main.js#L183-L187
+ machine.wait_until_succeeds("${eval "Main.runState"} | grep -q 'true,..2'")
- with subtest("Check if sessionPath option actually works"):
- machine.succeed("${eval "imports.gi.GIRepository.Repository.get_search_path\\(\\)"} | grep gpaste")
+ with subtest("Check if Cinnamon components actually start"):
+ for i in ["csd-media-keys", "xapp-sn-watcher", "nemo-desktop"]:
+ machine.wait_until_succeeds(f"pgrep -f {i}")
+ machine.wait_until_succeeds("journalctl -b --grep 'Loaded applet menu@cinnamon.org'")
+ machine.wait_until_succeeds("journalctl -b --grep 'calendar@cinnamon.org: Calendar events supported'")
- with subtest("Open Cinnamon Settings"):
- machine.succeed("${su "cinnamon-settings themes >&2 &"}")
- machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'cinnamon-settings'")
- machine.wait_for_text('(Style|Appearance|Color)')
- machine.sleep(2)
- machine.screenshot("cinnamon_settings")
+ with subtest("Check if sessionPath option actually works"):
+ machine.succeed("${eval "imports.gi.GIRepository.Repository.get_search_path\\(\\)"} | grep gpaste")
- with subtest("Check if screensaver works"):
- # This is not supported at the moment.
- # https://trello.com/b/HHs01Pab/cinnamon-wayland
- machine.execute("${su "cinnamon-screensaver-command -l >&2 &"}")
- machine.wait_until_succeeds("journalctl -b --grep 'cinnamon-screensaver is disabled in wayland sessions'")
+ with subtest("Open Cinnamon Settings"):
+ machine.succeed("${su "cinnamon-settings themes >&2 &"}")
+ machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'cinnamon-settings'")
+ machine.wait_for_text('(Style|Appearance|Color)')
+ machine.sleep(2)
+ machine.screenshot("cinnamon_settings")
- with subtest("Open GNOME Terminal"):
- machine.succeed("${su "dbus-launch gnome-terminal"}")
- machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'gnome-terminal'")
- machine.sleep(2)
+ with subtest("Check if screensaver works"):
+ # This is not supported at the moment.
+ # https://trello.com/b/HHs01Pab/cinnamon-wayland
+ machine.execute("${su "cinnamon-screensaver-command -l >&2 &"}")
+ machine.wait_until_succeeds("journalctl -b --grep 'cinnamon-screensaver is disabled in wayland sessions'")
- with subtest("Check if Cinnamon has ever coredumped"):
- machine.fail("coredumpctl --json=short | grep -E 'cinnamon|nemo'")
- '';
- }
-)
+ with subtest("Open GNOME Terminal"):
+ machine.succeed("${su "dbus-launch gnome-terminal"}")
+ machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'gnome-terminal'")
+ machine.sleep(2)
+
+ with subtest("Check if Cinnamon has ever coredumped"):
+ machine.fail("coredumpctl --json=short | grep -E 'cinnamon|nemo'")
+ '';
+}
diff --git a/nixos/tests/cinnamon.nix b/nixos/tests/cinnamon.nix
index 34777f8ee7b2..3230d7b07358 100644
--- a/nixos/tests/cinnamon.nix
+++ b/nixos/tests/cinnamon.nix
@@ -1,104 +1,102 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "cinnamon";
+{ pkgs, lib, ... }:
+{
+ name = "cinnamon";
- meta.maintainers = lib.teams.cinnamon.members;
+ meta.maintainers = lib.teams.cinnamon.members;
- nodes.machine =
- { ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.xserver.desktopManager.cinnamon.enable = true;
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.xserver.desktopManager.cinnamon.enable = true;
- # We don't ship gnome-text-editor in Cinnamon module, we add this line mainly
- # to catch eval issues related to this option.
- environment.cinnamon.excludePackages = [ pkgs.gnome-text-editor ];
+ # We don't ship gnome-text-editor in Cinnamon module, we add this line mainly
+ # to catch eval issues related to this option.
+ environment.cinnamon.excludePackages = [ pkgs.gnome-text-editor ];
- # For the sessionPath subtest.
- services.xserver.desktopManager.cinnamon.sessionPath = [ pkgs.gpaste ];
+ # For the sessionPath subtest.
+ services.xserver.desktopManager.cinnamon.sessionPath = [ pkgs.gpaste ];
- # For OCR test.
- services.xserver.displayManager.lightdm.greeters.slick.extraConfig = ''
- enable-hidpi = on
- '';
- };
-
- enableOCR = true;
-
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0";
- su = command: "su - ${user.name} -c '${env} ${command}'";
-
- # Call javascript in cinnamon (the shell), returns a tuple (success, output),
- # where `success` is true if the dbus call was successful and `output` is what
- # the javascript evaluates to.
- eval =
- name: su "gdbus call --session -d org.Cinnamon -o /org/Cinnamon -m org.Cinnamon.Eval ${name}";
- in
- ''
- machine.wait_for_unit("display-manager.service")
-
- with subtest("Test if we can see username in slick-greeter"):
- machine.wait_for_text("${user.description}")
- machine.screenshot("slick_greeter_lightdm")
-
- with subtest("Login with slick-greeter"):
- machine.send_chars("${user.password}\n")
- machine.wait_for_x()
- machine.wait_for_file("${user.home}/.Xauthority")
- machine.succeed("xauth merge ${user.home}/.Xauthority")
-
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
-
- with subtest("Wait for the Cinnamon shell"):
- # Correct output should be (true, '2')
- # https://github.com/linuxmint/cinnamon/blob/5.4.0/js/ui/main.js#L183-L187
- machine.wait_until_succeeds("${eval "Main.runState"} | grep -q 'true,..2'")
-
- with subtest("Check if Cinnamon components actually start"):
- for i in ["csd-media-keys", "cinnamon-killer-daemon", "xapp-sn-watcher", "nemo-desktop"]:
- machine.wait_until_succeeds(f"pgrep -f {i}")
- machine.wait_until_succeeds("journalctl -b --grep 'Loaded applet menu@cinnamon.org'")
- machine.wait_until_succeeds("journalctl -b --grep 'calendar@cinnamon.org: Calendar events supported'")
-
- with subtest("Check if sessionPath option actually works"):
- machine.succeed("${eval "imports.gi.GIRepository.Repository.get_search_path\\(\\)"} | grep gpaste")
-
- with subtest("Open Cinnamon Settings"):
- machine.succeed("${su "cinnamon-settings themes >&2 &"}")
- machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'cinnamon-settings'")
- machine.wait_for_text('(Style|Appearance|Color)')
- machine.sleep(2)
- machine.screenshot("cinnamon_settings")
-
- with subtest("Lock the screen"):
- machine.succeed("${su "cinnamon-screensaver-command -l >&2 &"}")
- machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is active'")
- machine.sleep(2)
- machine.screenshot("cinnamon_screensaver")
- machine.send_chars("${user.password}\n", delay=0.2)
- machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is inactive'")
- machine.sleep(2)
-
- with subtest("Open GNOME Terminal"):
- machine.succeed("${su "gnome-terminal"}")
- machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'gnome-terminal'")
- machine.sleep(2)
-
- with subtest("Open virtual keyboard"):
- machine.succeed("${su "dbus-send --print-reply --dest=org.Cinnamon /org/Cinnamon org.Cinnamon.ToggleKeyboard"}")
- machine.wait_for_text('(Ctrl|Alt)')
- machine.sleep(2)
- machine.screenshot("cinnamon_virtual_keyboard")
-
- with subtest("Check if Cinnamon has ever coredumped"):
- machine.fail("coredumpctl --json=short | grep -E 'cinnamon|nemo'")
+ # For OCR test.
+ services.xserver.displayManager.lightdm.greeters.slick.extraConfig = ''
+ enable-hidpi = on
'';
- }
-)
+ };
+
+ enableOCR = true;
+
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0";
+ su = command: "su - ${user.name} -c '${env} ${command}'";
+
+ # Call javascript in cinnamon (the shell), returns a tuple (success, output),
+ # where `success` is true if the dbus call was successful and `output` is what
+ # the javascript evaluates to.
+ eval =
+ name: su "gdbus call --session -d org.Cinnamon -o /org/Cinnamon -m org.Cinnamon.Eval ${name}";
+ in
+ ''
+ machine.wait_for_unit("display-manager.service")
+
+ with subtest("Test if we can see username in slick-greeter"):
+ machine.wait_for_text("${user.description}")
+ machine.screenshot("slick_greeter_lightdm")
+
+ with subtest("Login with slick-greeter"):
+ machine.send_chars("${user.password}\n")
+ machine.wait_for_x()
+ machine.wait_for_file("${user.home}/.Xauthority")
+ machine.succeed("xauth merge ${user.home}/.Xauthority")
+
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+
+ with subtest("Wait for the Cinnamon shell"):
+ # Correct output should be (true, '2')
+ # https://github.com/linuxmint/cinnamon/blob/5.4.0/js/ui/main.js#L183-L187
+ machine.wait_until_succeeds("${eval "Main.runState"} | grep -q 'true,..2'")
+
+ with subtest("Check if Cinnamon components actually start"):
+ for i in ["csd-media-keys", "cinnamon-killer-daemon", "xapp-sn-watcher", "nemo-desktop"]:
+ machine.wait_until_succeeds(f"pgrep -f {i}")
+ machine.wait_until_succeeds("journalctl -b --grep 'Loaded applet menu@cinnamon.org'")
+ machine.wait_until_succeeds("journalctl -b --grep 'calendar@cinnamon.org: Calendar events supported'")
+
+ with subtest("Check if sessionPath option actually works"):
+ machine.succeed("${eval "imports.gi.GIRepository.Repository.get_search_path\\(\\)"} | grep gpaste")
+
+ with subtest("Open Cinnamon Settings"):
+ machine.succeed("${su "cinnamon-settings themes >&2 &"}")
+ machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'cinnamon-settings'")
+ machine.wait_for_text('(Style|Appearance|Color)')
+ machine.sleep(2)
+ machine.screenshot("cinnamon_settings")
+
+ with subtest("Lock the screen"):
+ machine.succeed("${su "cinnamon-screensaver-command -l >&2 &"}")
+ machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is active'")
+ machine.sleep(2)
+ machine.screenshot("cinnamon_screensaver")
+ machine.send_chars("${user.password}\n", delay=0.2)
+ machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is inactive'")
+ machine.sleep(2)
+
+ with subtest("Open GNOME Terminal"):
+ machine.succeed("${su "gnome-terminal"}")
+ machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'gnome-terminal'")
+ machine.sleep(2)
+
+ with subtest("Open virtual keyboard"):
+ machine.succeed("${su "dbus-send --print-reply --dest=org.Cinnamon /org/Cinnamon org.Cinnamon.ToggleKeyboard"}")
+ machine.wait_for_text('(Ctrl|Alt)')
+ machine.sleep(2)
+ machine.screenshot("cinnamon_virtual_keyboard")
+
+ with subtest("Check if Cinnamon has ever coredumped"):
+ machine.fail("coredumpctl --json=short | grep -E 'cinnamon|nemo'")
+ '';
+}
diff --git a/nixos/tests/cjdns.nix b/nixos/tests/cjdns.nix
index 7fdb30a0abe6..52762f853e20 100644
--- a/nixos/tests/cjdns.nix
+++ b/nixos/tests/cjdns.nix
@@ -18,117 +18,115 @@ let
in
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "cjdns";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ehmry ];
- };
+{ pkgs, ... }:
+{
+ name = "cjdns";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ehmry ];
+ };
- nodes = {
- # Alice finds peers over over ETHInterface.
- alice =
- { ... }:
- {
- imports = [ basicConfig ];
+ nodes = {
+ # Alice finds peers over over ETHInterface.
+ alice =
+ { ... }:
+ {
+ imports = [ basicConfig ];
- services.cjdns.ETHInterface.bind = "eth1";
+ services.cjdns.ETHInterface.bind = "eth1";
- services.httpd.enable = true;
- services.httpd.adminAddr = "foo@example.org";
- networking.firewall.allowedTCPPorts = [ 80 ];
- };
+ services.httpd.enable = true;
+ services.httpd.adminAddr = "foo@example.org";
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ };
- # Bob explicitly connects to Carol over UDPInterface.
- bob =
- { ... }:
+ # Bob explicitly connects to Carol over UDPInterface.
+ bob =
+ { ... }:
- {
- imports = [ basicConfig ];
+ {
+ imports = [ basicConfig ];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "192.168.0.2";
- prefixLength = 24;
- }
- ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "192.168.0.2";
+ prefixLength = 24;
+ }
+ ];
- services.cjdns = {
- UDPInterface = {
- bind = "0.0.0.0:1024";
- connectTo."192.168.0.1:1024" = {
- password = carolPassword;
- publicKey = carolPubKey;
- };
+ services.cjdns = {
+ UDPInterface = {
+ bind = "0.0.0.0:1024";
+ connectTo."192.168.0.1:1024" = {
+ password = carolPassword;
+ publicKey = carolPubKey;
};
};
};
+ };
- # Carol listens on ETHInterface and UDPInterface,
- # but knows neither Alice or Bob.
- carol =
- { ... }:
- {
- imports = [ basicConfig ];
+ # Carol listens on ETHInterface and UDPInterface,
+ # but knows neither Alice or Bob.
+ carol =
+ { ... }:
+ {
+ imports = [ basicConfig ];
- environment.etc."cjdns.keys".text = ''
- CJDNS_PRIVATE_KEY=${carolKey}
- CJDNS_ADMIN_PASSWORD=FOOBAR
- '';
+ environment.etc."cjdns.keys".text = ''
+ CJDNS_PRIVATE_KEY=${carolKey}
+ CJDNS_ADMIN_PASSWORD=FOOBAR
+ '';
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "192.168.0.1";
- prefixLength = 24;
- }
- ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "192.168.0.1";
+ prefixLength = 24;
+ }
+ ];
- services.cjdns = {
- authorizedPasswords = [ carolPassword ];
- ETHInterface.bind = "eth1";
- UDPInterface.bind = "192.168.0.1:1024";
- };
- networking.firewall.allowedUDPPorts = [ 1024 ];
+ services.cjdns = {
+ authorizedPasswords = [ carolPassword ];
+ ETHInterface.bind = "eth1";
+ UDPInterface.bind = "192.168.0.1:1024";
};
+ networking.firewall.allowedUDPPorts = [ 1024 ];
+ };
- };
+ };
- testScript = ''
- import re
+ testScript = ''
+ import re
- start_all()
+ start_all()
- alice.wait_for_unit("cjdns.service")
- bob.wait_for_unit("cjdns.service")
- carol.wait_for_unit("cjdns.service")
+ alice.wait_for_unit("cjdns.service")
+ bob.wait_for_unit("cjdns.service")
+ carol.wait_for_unit("cjdns.service")
- def cjdns_ip(machine):
- res = machine.succeed("ip -o -6 addr show dev tun0")
- ip = re.split("\s+|/", res)[3]
- machine.log("has ip {}".format(ip))
- return ip
+ def cjdns_ip(machine):
+ res = machine.succeed("ip -o -6 addr show dev tun0")
+ ip = re.split("\s+|/", res)[3]
+ machine.log("has ip {}".format(ip))
+ return ip
- alice_ip6 = cjdns_ip(alice)
- bob_ip6 = cjdns_ip(bob)
- carol_ip6 = cjdns_ip(carol)
+ alice_ip6 = cjdns_ip(alice)
+ bob_ip6 = cjdns_ip(bob)
+ carol_ip6 = cjdns_ip(carol)
- # ping a few times each to let the routing table establish itself
+ # ping a few times each to let the routing table establish itself
- alice.succeed("ping -c 4 {}".format(carol_ip6))
- bob.succeed("ping -c 4 {}".format(carol_ip6))
+ alice.succeed("ping -c 4 {}".format(carol_ip6))
+ bob.succeed("ping -c 4 {}".format(carol_ip6))
- carol.succeed("ping -c 4 {}".format(alice_ip6))
- carol.succeed("ping -c 4 {}".format(bob_ip6))
+ carol.succeed("ping -c 4 {}".format(alice_ip6))
+ carol.succeed("ping -c 4 {}".format(bob_ip6))
- alice.succeed("ping -c 4 {}".format(bob_ip6))
- bob.succeed("ping -c 4 {}".format(alice_ip6))
+ alice.succeed("ping -c 4 {}".format(bob_ip6))
+ bob.succeed("ping -c 4 {}".format(alice_ip6))
- alice.wait_for_unit("httpd.service")
+ alice.wait_for_unit("httpd.service")
- bob.succeed("curl --fail -g http://[{}]".format(alice_ip6))
- '';
- }
-)
+ bob.succeed("curl --fail -g http://[{}]".format(alice_ip6))
+ '';
+}
diff --git a/nixos/tests/clickhouse.nix b/nixos/tests/clickhouse.nix
index 80868c04e9e4..165f00a1ec4e 100644
--- a/nixos/tests/clickhouse.nix
+++ b/nixos/tests/clickhouse.nix
@@ -1,35 +1,33 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "clickhouse";
- meta.maintainers = with pkgs.lib.maintainers; [ ];
+{ pkgs, ... }:
+{
+ name = "clickhouse";
+ meta.maintainers = with pkgs.lib.maintainers; [ ];
- nodes.machine = {
- services.clickhouse.enable = true;
- virtualisation.memorySize = 4096;
- };
+ nodes.machine = {
+ services.clickhouse.enable = true;
+ virtualisation.memorySize = 4096;
+ };
- testScript =
- let
- # work around quote/substitution complexity by Nix, Perl, bash and SQL.
- tableDDL = pkgs.writeText "ddl.sql" "CREATE TABLE `demo` (`value` FixedString(10)) engine = MergeTree PARTITION BY value ORDER BY tuple();";
- insertQuery = pkgs.writeText "insert.sql" "INSERT INTO `demo` (`value`) VALUES ('foo');";
- selectQuery = pkgs.writeText "select.sql" "SELECT * from `demo`";
- in
- ''
- machine.start()
- machine.wait_for_unit("clickhouse.service")
- machine.wait_for_open_port(9000)
+ testScript =
+ let
+ # work around quote/substitution complexity by Nix, Perl, bash and SQL.
+ tableDDL = pkgs.writeText "ddl.sql" "CREATE TABLE `demo` (`value` FixedString(10)) engine = MergeTree PARTITION BY value ORDER BY tuple();";
+ insertQuery = pkgs.writeText "insert.sql" "INSERT INTO `demo` (`value`) VALUES ('foo');";
+ selectQuery = pkgs.writeText "select.sql" "SELECT * from `demo`";
+ in
+ ''
+ machine.start()
+ machine.wait_for_unit("clickhouse.service")
+ machine.wait_for_open_port(9000)
- machine.succeed(
- "cat ${tableDDL} | clickhouse-client"
- )
- machine.succeed(
- "cat ${insertQuery} | clickhouse-client"
- )
- machine.succeed(
- "cat ${selectQuery} | clickhouse-client | grep foo"
- )
- '';
- }
-)
+ machine.succeed(
+ "cat ${tableDDL} | clickhouse-client"
+ )
+ machine.succeed(
+ "cat ${insertQuery} | clickhouse-client"
+ )
+ machine.succeed(
+ "cat ${selectQuery} | clickhouse-client | grep foo"
+ )
+ '';
+}
diff --git a/nixos/tests/cloudlog.nix b/nixos/tests/cloudlog.nix
index b49d1929f80c..94be4d241f1b 100644
--- a/nixos/tests/cloudlog.nix
+++ b/nixos/tests/cloudlog.nix
@@ -1,21 +1,19 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "cloudlog";
- meta = {
- maintainers = with pkgs.lib.maintainers; [ melling ];
+{ pkgs, ... }:
+{
+ name = "cloudlog";
+ meta = {
+ maintainers = with pkgs.lib.maintainers; [ melling ];
+ };
+ nodes = {
+ machine = {
+ services.mysql.package = pkgs.mariadb;
+ services.cloudlog.enable = true;
};
- nodes = {
- machine = {
- services.mysql.package = pkgs.mariadb;
- services.cloudlog.enable = true;
- };
- };
- testScript = ''
- start_all()
- machine.wait_for_unit("phpfpm-cloudlog")
- machine.wait_for_open_port(80);
- machine.wait_until_succeeds("curl -s -L --fail http://localhost | grep 'Login - Cloudlog'")
- '';
- }
-)
+ };
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("phpfpm-cloudlog")
+ machine.wait_for_open_port(80);
+ machine.wait_until_succeeds("curl -s -L --fail http://localhost | grep 'Login - Cloudlog'")
+ '';
+}
diff --git a/nixos/tests/cockpit.nix b/nixos/tests/cockpit.nix
index 29692f10aad2..b05c4b4dc93d 100644
--- a/nixos/tests/cockpit.nix
+++ b/nixos/tests/cockpit.nix
@@ -1,156 +1,154 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- user = "alice"; # from ./common/user-account.nix
- password = "foobar"; # from ./common/user-account.nix
- in
- {
- name = "cockpit";
- meta = {
- maintainers = with lib.maintainers; [ lucasew ];
- };
- nodes = {
- server =
- { config, ... }:
- {
- imports = [ ./common/user-account.nix ];
- security.polkit.enable = true;
- users.users.${user} = {
- extraGroups = [ "wheel" ];
- };
- services.cockpit = {
- enable = true;
- port = 7890;
- openFirewall = true;
- allowed-origins = [
- "https://server:${toString config.services.cockpit.port}"
- ];
- };
+let
+ user = "alice"; # from ./common/user-account.nix
+ password = "foobar"; # from ./common/user-account.nix
+in
+{
+ name = "cockpit";
+ meta = {
+ maintainers = with lib.maintainers; [ lucasew ];
+ };
+ nodes = {
+ server =
+ { config, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ security.polkit.enable = true;
+ users.users.${user} = {
+ extraGroups = [ "wheel" ];
};
- client =
- { config, ... }:
- {
- imports = [ ./common/user-account.nix ];
- environment.systemPackages =
- let
- seleniumScript =
- pkgs.writers.writePython3Bin "selenium-script"
- {
- libraries = with pkgs.python3Packages; [ selenium ];
- }
- ''
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.firefox.options import Options
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from time import sleep
-
-
- def log(msg):
- from sys import stderr
- print(f"[*] {msg}", file=stderr)
-
-
- log("Initializing")
-
- options = Options()
- options.add_argument("--headless")
-
- service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
- driver = webdriver.Firefox(options=options, service=service)
-
- driver.implicitly_wait(10)
-
- log("Opening homepage")
- driver.get("https://server:7890")
-
-
- def wait_elem(by, query, timeout=10):
- wait = WebDriverWait(driver, timeout)
- wait.until(EC.presence_of_element_located((by, query)))
-
-
- def wait_title_contains(title, timeout=10):
- wait = WebDriverWait(driver, timeout)
- wait.until(EC.title_contains(title))
-
-
- def find_element(by, query):
- return driver.find_element(by, query)
-
-
- def set_value(elem, value):
- script = 'arguments[0].value = arguments[1]'
- return driver.execute_script(script, elem, value)
-
-
- log("Waiting for the homepage to load")
-
- # cockpit sets initial title as hostname
- wait_title_contains("server")
- wait_elem(By.CSS_SELECTOR, 'input#login-user-input')
-
- log("Homepage loaded!")
-
- log("Filling out username")
- login_input = find_element(By.CSS_SELECTOR, 'input#login-user-input')
- set_value(login_input, "${user}")
-
- log("Filling out password")
- password_input = find_element(By.CSS_SELECTOR, 'input#login-password-input')
- set_value(password_input, "${password}")
-
- log("Submitting credentials for login")
- driver.find_element(By.CSS_SELECTOR, 'button#login-button').click()
-
- # driver.implicitly_wait(1)
- # driver.get("https://server:7890/system")
-
- log("Waiting dashboard to load")
- wait_title_contains("${user}@server")
-
- log("Waiting for the frontend to initialize")
- sleep(1)
-
- log("Looking for that banner that tells about limited access")
- container_iframe = find_element(By.CSS_SELECTOR, 'iframe.container-frame')
- driver.switch_to.frame(container_iframe)
-
- assert "Web console is running in limited access mode" in driver.page_source
-
- log("Clicking the sudo button")
- for button in driver.find_elements(By.TAG_NAME, "button"):
- if 'admin' in button.text:
- button.click()
- driver.switch_to.default_content()
-
- log("Checking that /nonexistent is not a thing")
- assert '/nonexistent' not in driver.page_source
- assert len(driver.find_elements(By.CSS_SELECTOR, '#machine-reconnect')) == 0
-
- driver.close()
- '';
- in
- with pkgs;
- [
- firefox-unwrapped
- geckodriver
- seleniumScript
- ];
+ services.cockpit = {
+ enable = true;
+ port = 7890;
+ openFirewall = true;
+ allowed-origins = [
+ "https://server:${toString config.services.cockpit.port}"
+ ];
};
- };
+ };
+ client =
+ { config, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ environment.systemPackages =
+ let
+ seleniumScript =
+ pkgs.writers.writePython3Bin "selenium-script"
+ {
+ libraries = with pkgs.python3Packages; [ selenium ];
+ }
+ ''
+ from selenium import webdriver
+ from selenium.webdriver.common.by import By
+ from selenium.webdriver.firefox.options import Options
+ from selenium.webdriver.support.ui import WebDriverWait
+ from selenium.webdriver.support import expected_conditions as EC
+ from time import sleep
- testScript = ''
- start_all()
- server.wait_for_unit("sockets.target")
- server.wait_for_open_port(7890)
+ def log(msg):
+ from sys import stderr
+ print(f"[*] {msg}", file=stderr)
- client.succeed("curl -k https://server:7890 -o /dev/stderr")
- print(client.succeed("whoami"))
- client.succeed('PYTHONUNBUFFERED=1 selenium-script')
- '';
- }
-)
+
+ log("Initializing")
+
+ options = Options()
+ options.add_argument("--headless")
+
+ service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
+ driver = webdriver.Firefox(options=options, service=service)
+
+ driver.implicitly_wait(10)
+
+ log("Opening homepage")
+ driver.get("https://server:7890")
+
+
+ def wait_elem(by, query, timeout=10):
+ wait = WebDriverWait(driver, timeout)
+ wait.until(EC.presence_of_element_located((by, query)))
+
+
+ def wait_title_contains(title, timeout=10):
+ wait = WebDriverWait(driver, timeout)
+ wait.until(EC.title_contains(title))
+
+
+ def find_element(by, query):
+ return driver.find_element(by, query)
+
+
+ def set_value(elem, value):
+ script = 'arguments[0].value = arguments[1]'
+ return driver.execute_script(script, elem, value)
+
+
+ log("Waiting for the homepage to load")
+
+ # cockpit sets initial title as hostname
+ wait_title_contains("server")
+ wait_elem(By.CSS_SELECTOR, 'input#login-user-input')
+
+ log("Homepage loaded!")
+
+ log("Filling out username")
+ login_input = find_element(By.CSS_SELECTOR, 'input#login-user-input')
+ set_value(login_input, "${user}")
+
+ log("Filling out password")
+ password_input = find_element(By.CSS_SELECTOR, 'input#login-password-input')
+ set_value(password_input, "${password}")
+
+ log("Submitting credentials for login")
+ driver.find_element(By.CSS_SELECTOR, 'button#login-button').click()
+
+ # driver.implicitly_wait(1)
+ # driver.get("https://server:7890/system")
+
+ log("Waiting dashboard to load")
+ wait_title_contains("${user}@server")
+
+ log("Waiting for the frontend to initialize")
+ sleep(1)
+
+ log("Looking for that banner that tells about limited access")
+ container_iframe = find_element(By.CSS_SELECTOR, 'iframe.container-frame')
+ driver.switch_to.frame(container_iframe)
+
+ assert "Web console is running in limited access mode" in driver.page_source
+
+ log("Clicking the sudo button")
+ for button in driver.find_elements(By.TAG_NAME, "button"):
+ if 'admin' in button.text:
+ button.click()
+ driver.switch_to.default_content()
+
+ log("Checking that /nonexistent is not a thing")
+ assert '/nonexistent' not in driver.page_source
+ assert len(driver.find_elements(By.CSS_SELECTOR, '#machine-reconnect')) == 0
+
+ driver.close()
+ '';
+ in
+ with pkgs;
+ [
+ firefox-unwrapped
+ geckodriver
+ seleniumScript
+ ];
+ };
+ };
+
+ testScript = ''
+ start_all()
+
+ server.wait_for_unit("sockets.target")
+ server.wait_for_open_port(7890)
+
+ client.succeed("curl -k https://server:7890 -o /dev/stderr")
+ print(client.succeed("whoami"))
+ client.succeed('PYTHONUNBUFFERED=1 selenium-script')
+ '';
+}
diff --git a/nixos/tests/code-server.nix b/nixos/tests/code-server.nix
index d58a0faee104..e4c9c8397740 100644
--- a/nixos/tests/code-server.nix
+++ b/nixos/tests/code-server.nix
@@ -1,26 +1,24 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "code-server";
+{ pkgs, lib, ... }:
+{
+ name = "code-server";
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.code-server = {
- enable = true;
- auth = "none";
- };
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.code-server = {
+ enable = true;
+ auth = "none";
};
- };
+ };
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("code-server.service")
- machine.wait_for_open_port(4444)
- machine.succeed("curl -k --fail http://localhost:4444", timeout=10)
- '';
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("code-server.service")
+ machine.wait_for_open_port(4444)
+ machine.succeed("curl -k --fail http://localhost:4444", timeout=10)
+ '';
- meta.maintainers = [ lib.maintainers.drupol ];
- }
-)
+ meta.maintainers = [ lib.maintainers.drupol ];
+}
diff --git a/nixos/tests/coder.nix b/nixos/tests/coder.nix
index 8bbba5d900c0..9b0b2c334a0b 100644
--- a/nixos/tests/coder.nix
+++ b/nixos/tests/coder.nix
@@ -1,25 +1,23 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "coder";
- meta.maintainers = pkgs.coder.meta.maintainers;
+{ pkgs, ... }:
+{
+ name = "coder";
+ meta.maintainers = pkgs.coder.meta.maintainers;
- nodes.machine =
- { pkgs, ... }:
- {
- services.coder = {
- enable = true;
- accessUrl = "http://localhost:3000";
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.coder = {
+ enable = true;
+ accessUrl = "http://localhost:3000";
};
+ };
- testScript = ''
- machine.start()
- machine.wait_for_unit("postgresql.service")
- machine.wait_for_unit("coder.service")
- machine.wait_for_open_port(3000)
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("postgresql.service")
+ machine.wait_for_unit("coder.service")
+ machine.wait_for_open_port(3000)
- machine.succeed("curl --fail http://localhost:3000")
- '';
- }
-)
+ machine.succeed("curl --fail http://localhost:3000")
+ '';
+}
diff --git a/nixos/tests/collectd.nix b/nixos/tests/collectd.nix
index 31d4689f1efe..7f99bff111e5 100644
--- a/nixos/tests/collectd.nix
+++ b/nixos/tests/collectd.nix
@@ -1,41 +1,39 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "collectd";
- meta = { };
+{ pkgs, ... }:
+{
+ name = "collectd";
+ meta = { };
- nodes.machine =
- { pkgs, lib, ... }:
+ nodes.machine =
+ { pkgs, lib, ... }:
- {
- services.collectd = {
- enable = true;
- extraConfig = lib.mkBefore ''
- Interval 30
+ {
+ services.collectd = {
+ enable = true;
+ extraConfig = lib.mkBefore ''
+ Interval 30
+ '';
+ plugins = {
+ rrdtool = ''
+ DataDir "/var/lib/collectd/rrd"
'';
- plugins = {
- rrdtool = ''
- DataDir "/var/lib/collectd/rrd"
- '';
- load = "";
- };
+ load = "";
};
- environment.systemPackages = [ pkgs.rrdtool ];
};
+ environment.systemPackages = [ pkgs.rrdtool ];
+ };
- testScript = ''
- machine.wait_for_unit("collectd.service")
- hostname = machine.succeed("hostname").strip()
- file = f"/var/lib/collectd/rrd/{hostname}/load/load.rrd"
- machine.wait_for_file(file);
- machine.succeed(f"rrdinfo {file} | logger")
- # check that this file contains a shortterm metric
- machine.succeed(f"rrdinfo {file} | grep -F 'ds[shortterm].min = '")
- # check that interval was set before the plugins
- machine.succeed(f"rrdinfo {file} | grep -F 'step = 30'")
- # check that there are frequent updates
- machine.succeed(f"cp {file} before")
- machine.wait_until_fails(f"cmp before {file}")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("collectd.service")
+ hostname = machine.succeed("hostname").strip()
+ file = f"/var/lib/collectd/rrd/{hostname}/load/load.rrd"
+ machine.wait_for_file(file);
+ machine.succeed(f"rrdinfo {file} | logger")
+ # check that this file contains a shortterm metric
+ machine.succeed(f"rrdinfo {file} | grep -F 'ds[shortterm].min = '")
+ # check that interval was set before the plugins
+ machine.succeed(f"rrdinfo {file} | grep -F 'step = 30'")
+ # check that there are frequent updates
+ machine.succeed(f"cp {file} before")
+ machine.wait_until_fails(f"cmp before {file}")
+ '';
+}
diff --git a/nixos/tests/commafeed.nix b/nixos/tests/commafeed.nix
index 7b65720818a9..c93619e46635 100644
--- a/nixos/tests/commafeed.nix
+++ b/nixos/tests/commafeed.nix
@@ -1,21 +1,19 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "commafeed";
+{ lib, ... }:
+{
+ name = "commafeed";
- nodes.server = {
- services.commafeed = {
- enable = true;
- };
+ nodes.server = {
+ services.commafeed = {
+ enable = true;
};
+ };
- testScript = ''
- server.start()
- server.wait_for_unit("commafeed.service")
- server.wait_for_open_port(8082)
- server.succeed("curl --fail --silent http://localhost:8082")
- '';
+ testScript = ''
+ server.start()
+ server.wait_for_unit("commafeed.service")
+ server.wait_for_open_port(8082)
+ server.succeed("curl --fail --silent http://localhost:8082")
+ '';
- meta.maintainers = [ lib.maintainers.raroh73 ];
- }
-)
+ meta.maintainers = [ lib.maintainers.raroh73 ];
+}
diff --git a/nixos/tests/connman.nix b/nixos/tests/connman.nix
index 8ab00de10601..1902e0638b96 100644
--- a/nixos/tests/connman.nix
+++ b/nixos/tests/connman.nix
@@ -1,85 +1,83 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "connman";
- meta = with lib.maintainers; {
- maintainers = [ rnhmjoj ];
+{ pkgs, lib, ... }:
+{
+ name = "connman";
+ meta = with lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
+
+ # Router running radvd on VLAN 1
+ nodes.router =
+ { ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+
+ virtualisation.vlans = [ 1 ];
+
+ boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = true;
+
+ networking = {
+ useDHCP = false;
+ interfaces.eth1.ipv6.addresses = [
+ {
+ address = "fd12::1";
+ prefixLength = 64;
+ }
+ ];
+ };
+
+ services.radvd = {
+ enable = true;
+ config = ''
+ interface eth1 {
+ AdvSendAdvert on;
+ AdvManagedFlag on;
+ AdvOtherConfigFlag on;
+ prefix fd12::/64 {
+ AdvAutonomous off;
+ };
+ };
+ '';
+ };
};
- # Router running radvd on VLAN 1
- nodes.router =
- { ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
+ # Client running connman, connected to VLAN 1
+ nodes.client =
+ { ... }:
+ {
+ virtualisation.vlans = [ 1 ];
- virtualisation.vlans = [ 1 ];
+ # add a virtual wlan interface
+ boot.kernelModules = [ "mac80211_hwsim" ];
+ boot.extraModprobeConfig = ''
+ options mac80211_hwsim radios=1
+ '';
- boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = true;
+ # Note: the overrides are needed because the wifi is
+ # disabled with mkVMOverride in qemu-vm.nix.
+ services.connman.enable = lib.mkOverride 0 true;
+ services.connman.networkInterfaceBlacklist = [ "eth0" ];
+ networking.wireless.enable = lib.mkOverride 0 true;
+ networking.wireless.interfaces = [ "wlan0" ];
+ };
- networking = {
- useDHCP = false;
- interfaces.eth1.ipv6.addresses = [
- {
- address = "fd12::1";
- prefixLength = 64;
- }
- ];
- };
+ testScript = ''
+ start_all()
- services.radvd = {
- enable = true;
- config = ''
- interface eth1 {
- AdvSendAdvert on;
- AdvManagedFlag on;
- AdvOtherConfigFlag on;
- prefix fd12::/64 {
- AdvAutonomous off;
- };
- };
- '';
- };
- };
+ with subtest("Router is ready"):
+ router.wait_for_unit("radvd.service")
- # Client running connman, connected to VLAN 1
- nodes.client =
- { ... }:
- {
- virtualisation.vlans = [ 1 ];
+ with subtest("Daemons are running"):
+ client.wait_for_unit("wpa_supplicant-wlan0.service")
+ client.wait_for_unit("connman.service")
+ client.wait_until_succeeds("connmanctl state | grep -q ready")
- # add a virtual wlan interface
- boot.kernelModules = [ "mac80211_hwsim" ];
- boot.extraModprobeConfig = ''
- options mac80211_hwsim radios=1
- '';
+ with subtest("Wired interface is configured"):
+ client.wait_until_succeeds("ip -6 route | grep -q fd12::/64")
+ client.wait_until_succeeds("ping -c 1 fd12::1")
- # Note: the overrides are needed because the wifi is
- # disabled with mkVMOverride in qemu-vm.nix.
- services.connman.enable = lib.mkOverride 0 true;
- services.connman.networkInterfaceBlacklist = [ "eth0" ];
- networking.wireless.enable = lib.mkOverride 0 true;
- networking.wireless.interfaces = [ "wlan0" ];
- };
-
- testScript = ''
- start_all()
-
- with subtest("Router is ready"):
- router.wait_for_unit("radvd.service")
-
- with subtest("Daemons are running"):
- client.wait_for_unit("wpa_supplicant-wlan0.service")
- client.wait_for_unit("connman.service")
- client.wait_until_succeeds("connmanctl state | grep -q ready")
-
- with subtest("Wired interface is configured"):
- client.wait_until_succeeds("ip -6 route | grep -q fd12::/64")
- client.wait_until_succeeds("ping -c 1 fd12::1")
-
- with subtest("Can set up a wireless access point"):
- client.succeed("connmanctl enable wifi")
- client.wait_until_succeeds("connmanctl tether wifi on nixos-test reproducibility | grep -q 'Enabled'")
- client.wait_until_succeeds("iw wlan0 info | grep -q nixos-test")
- '';
- }
-)
+ with subtest("Can set up a wireless access point"):
+ client.succeed("connmanctl enable wifi")
+ client.wait_until_succeeds("connmanctl tether wifi on nixos-test reproducibility | grep -q 'Enabled'")
+ client.wait_until_succeeds("iw wlan0 info | grep -q nixos-test")
+ '';
+}
diff --git a/nixos/tests/consul-template.nix b/nixos/tests/consul-template.nix
index 015e09111b3d..6720cd44e629 100644
--- a/nixos/tests/consul-template.nix
+++ b/nixos/tests/consul-template.nix
@@ -1,43 +1,41 @@
-import ./make-test-python.nix (
- { ... }:
- {
- name = "consul-template";
+{ ... }:
+{
+ name = "consul-template";
- nodes.machine =
- { ... }:
- {
- services.consul-template.instances.example.settings = {
- template = [
- {
- contents = ''
- {{ key "example" }}
- '';
- perms = "0600";
- destination = "/example";
- }
- ];
- };
-
- services.consul = {
- enable = true;
- extraConfig = {
- server = true;
- bootstrap_expect = 1;
- bind_addr = "127.0.0.1";
- };
- };
+ nodes.machine =
+ { ... }:
+ {
+ services.consul-template.instances.example.settings = {
+ template = [
+ {
+ contents = ''
+ {{ key "example" }}
+ '';
+ perms = "0600";
+ destination = "/example";
+ }
+ ];
};
- testScript = ''
- machine.wait_for_unit("consul.service")
- machine.wait_for_open_port(8500)
+ services.consul = {
+ enable = true;
+ extraConfig = {
+ server = true;
+ bootstrap_expect = 1;
+ bind_addr = "127.0.0.1";
+ };
+ };
+ };
- machine.wait_for_unit("consul-template-example.service")
+ testScript = ''
+ machine.wait_for_unit("consul.service")
+ machine.wait_for_open_port(8500)
- machine.wait_until_succeeds('consul kv put example example')
+ machine.wait_for_unit("consul-template-example.service")
- machine.wait_for_file("/example")
- machine.succeed('grep "example" /example')
- '';
- }
-)
+ machine.wait_until_succeeds('consul kv put example example')
+
+ machine.wait_for_file("/example")
+ machine.succeed('grep "example" /example')
+ '';
+}
diff --git a/nixos/tests/consul.nix b/nixos/tests/consul.nix
index 253d70f13b59..8dc141b674f7 100644
--- a/nixos/tests/consul.nix
+++ b/nixos/tests/consul.nix
@@ -1,267 +1,265 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- # Settings for both servers and agents
- webUi = true;
- retry_interval = "1s";
- raft_multiplier = 1;
+let
+ # Settings for both servers and agents
+ webUi = true;
+ retry_interval = "1s";
+ raft_multiplier = 1;
- defaultExtraConfig = {
- inherit retry_interval;
- performance = {
- inherit raft_multiplier;
+ defaultExtraConfig = {
+ inherit retry_interval;
+ performance = {
+ inherit raft_multiplier;
+ };
+ };
+
+ allConsensusServerHosts = [
+ "192.168.1.1"
+ "192.168.1.2"
+ "192.168.1.3"
+ ];
+
+ allConsensusClientHosts = [
+ "192.168.2.1"
+ "192.168.2.2"
+ ];
+
+ firewallSettings = {
+ # See https://www.consul.io/docs/install/ports.html
+ allowedTCPPorts = [
+ 8301
+ 8302
+ 8600
+ 8500
+ 8300
+ ];
+ allowedUDPPorts = [
+ 8301
+ 8302
+ 8600
+ ];
+ };
+
+ client =
+ index:
+ { pkgs, ... }:
+ let
+ ip = builtins.elemAt allConsensusClientHosts index;
+ in
+ {
+ environment.systemPackages = [ pkgs.consul ];
+
+ networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
+ {
+ address = ip;
+ prefixLength = 16;
+ }
+ ];
+ networking.firewall = firewallSettings;
+
+ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "consul" ];
+
+ services.consul = {
+ enable = true;
+ inherit webUi;
+ extraConfig = defaultExtraConfig // {
+ server = false;
+ retry_join = allConsensusServerHosts;
+ bind_addr = ip;
+ };
};
};
- allConsensusServerHosts = [
- "192.168.1.1"
- "192.168.1.2"
- "192.168.1.3"
- ];
-
- allConsensusClientHosts = [
- "192.168.2.1"
- "192.168.2.2"
- ];
-
- firewallSettings = {
- # See https://www.consul.io/docs/install/ports.html
- allowedTCPPorts = [
- 8301
- 8302
- 8600
- 8500
- 8300
+ server =
+ index:
+ { pkgs, ... }:
+ let
+ numConsensusServers = builtins.length allConsensusServerHosts;
+ thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
+ ip = thisConsensusServerHost; # since we already use IPs to identify servers
+ in
+ {
+ networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
+ {
+ address = ip;
+ prefixLength = 16;
+ }
];
- allowedUDPPorts = [
- 8301
- 8302
- 8600
- ];
- };
+ networking.firewall = firewallSettings;
- client =
- index:
- { pkgs, ... }:
- let
- ip = builtins.elemAt allConsensusClientHosts index;
- in
- {
- environment.systemPackages = [ pkgs.consul ];
+ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "consul" ];
- networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
- {
- address = ip;
- prefixLength = 16;
- }
- ];
- networking.firewall = firewallSettings;
-
- nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "consul" ];
-
- services.consul = {
+ services.consul =
+ assert builtins.elem thisConsensusServerHost allConsensusServerHosts;
+ {
enable = true;
inherit webUi;
extraConfig = defaultExtraConfig // {
- server = false;
- retry_join = allConsensusServerHosts;
+ server = true;
+ bootstrap_expect = numConsensusServers;
+ # Tell Consul that we never intend to drop below this many servers.
+ # Ensures to not permanently lose consensus after temporary loss.
+ # See https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040
+ autopilot.min_quorum = numConsensusServers;
+ retry_join =
+ # If there's only 1 node in the network, we allow self-join;
+ # otherwise, the node must not try to join itself, and join only the other servers.
+ # See https://github.com/hashicorp/consul/issues/2868
+ if numConsensusServers == 1 then
+ allConsensusServerHosts
+ else
+ builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
bind_addr = ip;
};
};
- };
-
- server =
- index:
- { pkgs, ... }:
- let
- numConsensusServers = builtins.length allConsensusServerHosts;
- thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
- ip = thisConsensusServerHost; # since we already use IPs to identify servers
- in
- {
- networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
- {
- address = ip;
- prefixLength = 16;
- }
- ];
- networking.firewall = firewallSettings;
-
- nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "consul" ];
-
- services.consul =
- assert builtins.elem thisConsensusServerHost allConsensusServerHosts;
- {
- enable = true;
- inherit webUi;
- extraConfig = defaultExtraConfig // {
- server = true;
- bootstrap_expect = numConsensusServers;
- # Tell Consul that we never intend to drop below this many servers.
- # Ensures to not permanently lose consensus after temporary loss.
- # See https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040
- autopilot.min_quorum = numConsensusServers;
- retry_join =
- # If there's only 1 node in the network, we allow self-join;
- # otherwise, the node must not try to join itself, and join only the other servers.
- # See https://github.com/hashicorp/consul/issues/2868
- if numConsensusServers == 1 then
- allConsensusServerHosts
- else
- builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
- bind_addr = ip;
- };
- };
- };
- in
- {
- name = "consul";
-
- nodes = {
- server1 = server 0;
- server2 = server 1;
- server3 = server 2;
-
- client1 = client 0;
- client2 = client 1;
};
+in
+{
+ name = "consul";
- testScript = ''
- servers = [server1, server2, server3]
- machines = [server1, server2, server3, client1, client2]
+ nodes = {
+ server1 = server 0;
+ server2 = server 1;
+ server3 = server 2;
- for m in machines:
- m.wait_for_unit("consul.service")
+ client1 = client 0;
+ client2 = client 1;
+ };
+
+ testScript = ''
+ servers = [server1, server2, server3]
+ machines = [server1, server2, server3, client1, client2]
+
+ for m in machines:
+ m.wait_for_unit("consul.service")
- def wait_for_healthy_servers():
- # See https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040
- # for why the `Voter` column of `list-peers` has that info.
- # TODO: The `grep true` relies on the fact that currently in
- # the output like
- # # consul operator raft list-peers
- # Node ID Address State Voter RaftProtocol
- # server3 ... 192.168.1.3:8300 leader true 3
- # server2 ... 192.168.1.2:8300 follower true 3
- # server1 ... 192.168.1.1:8300 follower false 3
- # `Voter`is the only boolean column.
- # Change this to the more reliable way to be defined by
- # https://github.com/hashicorp/consul/issues/8118
- # once that ticket is closed.
- for m in machines:
- m.wait_until_succeeds(
- "[ $(consul operator raft list-peers | grep true | wc -l) == 3 ]"
- )
+ def wait_for_healthy_servers():
+ # See https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040
+ # for why the `Voter` column of `list-peers` has that info.
+ # TODO: The `grep true` relies on the fact that currently in
+ # the output like
+ # # consul operator raft list-peers
+ # Node ID Address State Voter RaftProtocol
+ # server3 ... 192.168.1.3:8300 leader true 3
+ # server2 ... 192.168.1.2:8300 follower true 3
+ # server1 ... 192.168.1.1:8300 follower false 3
+ # `Voter`is the only boolean column.
+ # Change this to the more reliable way to be defined by
+ # https://github.com/hashicorp/consul/issues/8118
+ # once that ticket is closed.
+ for m in machines:
+ m.wait_until_succeeds(
+ "[ $(consul operator raft list-peers | grep true | wc -l) == 3 ]"
+ )
- def wait_for_all_machines_alive():
- """
- Note that Serf-"alive" does not mean "Raft"-healthy;
- see `wait_for_healthy_servers()` for that instead.
- """
- for m in machines:
- m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
+ def wait_for_all_machines_alive():
+ """
+ Note that Serf-"alive" does not mean "Raft"-healthy;
+ see `wait_for_healthy_servers()` for that instead.
+ """
+ for m in machines:
+ m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
- wait_for_healthy_servers()
- # Also wait for clients to be alive.
- wait_for_all_machines_alive()
+ wait_for_healthy_servers()
+ # Also wait for clients to be alive.
+ wait_for_all_machines_alive()
- client1.succeed("consul kv put testkey 42")
- client2.succeed("[ $(consul kv get testkey) == 42 ]")
+ client1.succeed("consul kv put testkey 42")
+ client2.succeed("[ $(consul kv get testkey) == 42 ]")
- def rolling_restart_test(proper_rolling_procedure=True):
- """
- Tests that the cluster can tolearate failures of any single server,
- following the recommended rolling upgrade procedure from
- https://www.consul.io/docs/upgrading#standard-upgrades.
+ def rolling_restart_test(proper_rolling_procedure=True):
+ """
+ Tests that the cluster can tolearate failures of any single server,
+ following the recommended rolling upgrade procedure from
+ https://www.consul.io/docs/upgrading#standard-upgrades.
- Optionally, `proper_rolling_procedure=False` can be given
- to wait only for each server to be back `Healthy`, not `Stable`
- in the Raft consensus, see Consul setting `ServerStabilizationTime` and
- https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040.
- """
+ Optionally, `proper_rolling_procedure=False` can be given
+ to wait only for each server to be back `Healthy`, not `Stable`
+ in the Raft consensus, see Consul setting `ServerStabilizationTime` and
+ https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040.
+ """
- for server in servers:
- server.block()
- server.systemctl("stop consul")
+ for server in servers:
+ server.block()
+ server.systemctl("stop consul")
- # Make sure the stopped peer is recognized as being down
- client1.wait_until_succeeds(
- f"[ $(consul members | grep {server.name} | grep -o -E 'failed|left' | wc -l) == 1 ]"
- )
+ # Make sure the stopped peer is recognized as being down
+ client1.wait_until_succeeds(
+ f"[ $(consul members | grep {server.name} | grep -o -E 'failed|left' | wc -l) == 1 ]"
+ )
- # For each client, wait until they have connection again
- # using `kv get -recurse` before issuing commands.
- client1.wait_until_succeeds("consul kv get -recurse")
- client2.wait_until_succeeds("consul kv get -recurse")
+ # For each client, wait until they have connection again
+ # using `kv get -recurse` before issuing commands.
+ client1.wait_until_succeeds("consul kv get -recurse")
+ client2.wait_until_succeeds("consul kv get -recurse")
- # Do some consul actions while one server is down.
- client1.succeed("consul kv put testkey 43")
- client2.succeed("[ $(consul kv get testkey) == 43 ]")
- client2.succeed("consul kv delete testkey")
+ # Do some consul actions while one server is down.
+ client1.succeed("consul kv put testkey 43")
+ client2.succeed("[ $(consul kv get testkey) == 43 ]")
+ client2.succeed("consul kv delete testkey")
- server.unblock()
- server.systemctl("start consul")
+ server.unblock()
+ server.systemctl("start consul")
- if proper_rolling_procedure:
- # Wait for recovery.
- wait_for_healthy_servers()
- else:
- # NOT proper rolling upgrade procedure, see above.
- wait_for_all_machines_alive()
+ if proper_rolling_procedure:
+ # Wait for recovery.
+ wait_for_healthy_servers()
+ else:
+ # NOT proper rolling upgrade procedure, see above.
+ wait_for_all_machines_alive()
- # Wait for client connections.
- client1.wait_until_succeeds("consul kv get -recurse")
- client2.wait_until_succeeds("consul kv get -recurse")
+ # Wait for client connections.
+ client1.wait_until_succeeds("consul kv get -recurse")
+ client2.wait_until_succeeds("consul kv get -recurse")
- # Do some consul actions with server back up.
- client1.succeed("consul kv put testkey 44")
- client2.succeed("[ $(consul kv get testkey) == 44 ]")
- client2.succeed("consul kv delete testkey")
+ # Do some consul actions with server back up.
+ client1.succeed("consul kv put testkey 44")
+ client2.succeed("[ $(consul kv get testkey) == 44 ]")
+ client2.succeed("consul kv delete testkey")
- def all_servers_crash_simultaneously_test():
- """
- Tests that the cluster will eventually come back after all
- servers crash simultaneously.
- """
+ def all_servers_crash_simultaneously_test():
+ """
+ Tests that the cluster will eventually come back after all
+ servers crash simultaneously.
+ """
- for server in servers:
- server.block()
- server.systemctl("stop --no-block consul")
+ for server in servers:
+ server.block()
+ server.systemctl("stop --no-block consul")
- for server in servers:
- # --no-block is async, so ensure it has been stopped by now
- server.wait_until_fails("systemctl is-active --quiet consul")
- server.unblock()
- server.systemctl("start consul")
+ for server in servers:
+ # --no-block is async, so ensure it has been stopped by now
+ server.wait_until_fails("systemctl is-active --quiet consul")
+ server.unblock()
+ server.systemctl("start consul")
- # Wait for recovery.
- wait_for_healthy_servers()
+ # Wait for recovery.
+ wait_for_healthy_servers()
- # Wait for client connections.
- client1.wait_until_succeeds("consul kv get -recurse")
- client2.wait_until_succeeds("consul kv get -recurse")
+ # Wait for client connections.
+ client1.wait_until_succeeds("consul kv get -recurse")
+ client2.wait_until_succeeds("consul kv get -recurse")
- # Do some consul actions with servers back up.
- client1.succeed("consul kv put testkey 44")
- client2.succeed("[ $(consul kv get testkey) == 44 ]")
- client2.succeed("consul kv delete testkey")
+ # Do some consul actions with servers back up.
+ client1.succeed("consul kv put testkey 44")
+ client2.succeed("[ $(consul kv get testkey) == 44 ]")
+ client2.succeed("consul kv delete testkey")
- # Run the tests.
+ # Run the tests.
- print("rolling_restart_test()")
- rolling_restart_test()
+ print("rolling_restart_test()")
+ rolling_restart_test()
- print("all_servers_crash_simultaneously_test()")
- all_servers_crash_simultaneously_test()
+ print("all_servers_crash_simultaneously_test()")
+ all_servers_crash_simultaneously_test()
- print("rolling_restart_test(proper_rolling_procedure=False)")
- rolling_restart_test(proper_rolling_procedure=False)
- '';
- }
-)
+ print("rolling_restart_test(proper_rolling_procedure=False)")
+ rolling_restart_test(proper_rolling_procedure=False)
+ '';
+}
diff --git a/nixos/tests/containers-bridge.nix b/nixos/tests/containers-bridge.nix
index a8e9f574924f..1f38b1b48e11 100644
--- a/nixos/tests/containers-bridge.nix
+++ b/nixos/tests/containers-bridge.nix
@@ -5,110 +5,108 @@ let
containerIp6 = "fc00::2/7";
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-bridge";
- meta = {
- maintainers = with lib.maintainers; [
- aristid
- aszlig
- kampfschlaefer
- ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-bridge";
+ meta = {
+ maintainers = with lib.maintainers; [
+ aristid
+ aszlig
+ kampfschlaefer
+ ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ../modules/installer/cd-dvd/channel.nix ];
- virtualisation.writableStore = true;
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ../modules/installer/cd-dvd/channel.nix ];
+ virtualisation.writableStore = true;
- networking.bridges = {
- br0 = {
- interfaces = [ ];
- };
+ networking.bridges = {
+ br0 = {
+ interfaces = [ ];
};
- networking.interfaces = {
- br0 = {
- ipv4.addresses = [
- {
- address = hostIp;
- prefixLength = 24;
- }
- ];
- ipv6.addresses = [
- {
- address = hostIp6;
- prefixLength = 7;
- }
- ];
- };
+ };
+ networking.interfaces = {
+ br0 = {
+ ipv4.addresses = [
+ {
+ address = hostIp;
+ prefixLength = 24;
+ }
+ ];
+ ipv6.addresses = [
+ {
+ address = hostIp6;
+ prefixLength = 7;
+ }
+ ];
};
-
- containers.webserver = {
- autoStart = true;
- privateNetwork = true;
- hostBridge = "br0";
- localAddress = containerIp;
- localAddress6 = containerIp6;
- config = {
- services.httpd.enable = true;
- services.httpd.adminAddr = "foo@example.org";
- networking.firewall.allowedTCPPorts = [ 80 ];
- };
- };
-
- containers.web-noip = {
- autoStart = true;
- privateNetwork = true;
- hostBridge = "br0";
- config = {
- services.httpd.enable = true;
- services.httpd.adminAddr = "foo@example.org";
- networking.firewall.allowedTCPPorts = [ 80 ];
- };
- };
-
- virtualisation.additionalPaths = [ pkgs.stdenv ];
};
- testScript = ''
- machine.wait_for_unit("default.target")
- assert "webserver" in machine.succeed("nixos-container list")
+ containers.webserver = {
+ autoStart = true;
+ privateNetwork = true;
+ hostBridge = "br0";
+ localAddress = containerIp;
+ localAddress6 = containerIp6;
+ config = {
+ services.httpd.enable = true;
+ services.httpd.adminAddr = "foo@example.org";
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ };
+ };
- with subtest("Start the webserver container"):
- assert "up" in machine.succeed("nixos-container status webserver")
+ containers.web-noip = {
+ autoStart = true;
+ privateNetwork = true;
+ hostBridge = "br0";
+ config = {
+ services.httpd.enable = true;
+ services.httpd.adminAddr = "foo@example.org";
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ };
+ };
- with subtest("Bridges exist inside containers"):
- machine.succeed(
- "nixos-container run webserver -- ip link show eth0",
- "nixos-container run web-noip -- ip link show eth0",
- )
+ virtualisation.additionalPaths = [ pkgs.stdenv ];
+ };
- ip = "${containerIp}".split("/")[0]
- machine.succeed(f"ping -n -c 1 {ip}")
- machine.succeed(f"curl --fail http://{ip}/ > /dev/null")
+ testScript = ''
+ machine.wait_for_unit("default.target")
+ assert "webserver" in machine.succeed("nixos-container list")
- ip6 = "${containerIp6}".split("/")[0]
- machine.succeed(f"ping -n -c 1 {ip6}")
- machine.succeed(f"curl --fail http://[{ip6}]/ > /dev/null")
+ with subtest("Start the webserver container"):
+ assert "up" in machine.succeed("nixos-container status webserver")
- with subtest(
- "nixos-container show-ip works in case of an ipv4 address "
- + "with subnetmask in CIDR notation."
- ):
- result = machine.succeed("nixos-container show-ip webserver").rstrip()
- assert result == ip
+ with subtest("Bridges exist inside containers"):
+ machine.succeed(
+ "nixos-container run webserver -- ip link show eth0",
+ "nixos-container run web-noip -- ip link show eth0",
+ )
- with subtest("Stop the container"):
- machine.succeed("nixos-container stop webserver")
- machine.fail(
- f"curl --fail --connect-timeout 2 http://{ip}/ > /dev/null",
- f"curl --fail --connect-timeout 2 http://[{ip6}]/ > /dev/null",
- )
+ ip = "${containerIp}".split("/")[0]
+ machine.succeed(f"ping -n -c 1 {ip}")
+ machine.succeed(f"curl --fail http://{ip}/ > /dev/null")
- # Destroying a declarative container should fail.
- machine.fail("nixos-container destroy webserver")
- '';
- }
-)
+ ip6 = "${containerIp6}".split("/")[0]
+ machine.succeed(f"ping -n -c 1 {ip6}")
+ machine.succeed(f"curl --fail http://[{ip6}]/ > /dev/null")
+
+ with subtest(
+ "nixos-container show-ip works in case of an ipv4 address "
+ + "with subnetmask in CIDR notation."
+ ):
+ result = machine.succeed("nixos-container show-ip webserver").rstrip()
+ assert result == ip
+
+ with subtest("Stop the container"):
+ machine.succeed("nixos-container stop webserver")
+ machine.fail(
+ f"curl --fail --connect-timeout 2 http://{ip}/ > /dev/null",
+ f"curl --fail --connect-timeout 2 http://[{ip6}]/ > /dev/null",
+ )
+
+ # Destroying a declarative container should fail.
+ machine.fail("nixos-container destroy webserver")
+ '';
+}
diff --git a/nixos/tests/containers-custom-pkgs.nix b/nixos/tests/containers-custom-pkgs.nix
index 74b1ea207b68..b341232fd8cd 100644
--- a/nixos/tests/containers-custom-pkgs.nix
+++ b/nixos/tests/containers-custom-pkgs.nix
@@ -1,48 +1,46 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
+{ pkgs, lib, ... }:
+let
- customPkgs = pkgs.appendOverlays [
- (self: super: {
- hello = super.hello.overrideAttrs (old: {
- name = "custom-hello";
- });
- })
- ];
+ customPkgs = pkgs.appendOverlays [
+ (self: super: {
+ hello = super.hello.overrideAttrs (old: {
+ name = "custom-hello";
+ });
+ })
+ ];
- in
- {
- name = "containers-custom-pkgs";
- meta = {
- maintainers = with lib.maintainers; [ erikarvstedt ];
+in
+{
+ name = "containers-custom-pkgs";
+ meta = {
+ maintainers = with lib.maintainers; [ erikarvstedt ];
+ };
+
+ nodes.machine =
+ { config, ... }:
+ {
+ assertions =
+ let
+ helloName = (builtins.head config.containers.test.config.system.extraDependencies).name;
+ in
+ [
+ {
+ assertion = helloName == "custom-hello";
+ message = "Unexpected value: ${helloName}";
+ }
+ ];
+
+ containers.test = {
+ autoStart = true;
+ config =
+ { pkgs, config, ... }:
+ {
+ nixpkgs.pkgs = customPkgs;
+ system.extraDependencies = [ pkgs.hello ];
+ };
+ };
};
- nodes.machine =
- { config, ... }:
- {
- assertions =
- let
- helloName = (builtins.head config.containers.test.config.system.extraDependencies).name;
- in
- [
- {
- assertion = helloName == "custom-hello";
- message = "Unexpected value: ${helloName}";
- }
- ];
-
- containers.test = {
- autoStart = true;
- config =
- { pkgs, config, ... }:
- {
- nixpkgs.pkgs = customPkgs;
- system.extraDependencies = [ pkgs.hello ];
- };
- };
- };
-
- # This test only consists of evaluating the test machine
- testScript = "pass";
- }
-)
+ # This test only consists of evaluating the test machine
+ testScript = "pass";
+}
diff --git a/nixos/tests/containers-ephemeral.nix b/nixos/tests/containers-ephemeral.nix
index 5204ba67e26b..798962967704 100644
--- a/nixos/tests/containers-ephemeral.nix
+++ b/nixos/tests/containers-ephemeral.nix
@@ -1,59 +1,57 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-ephemeral";
- meta = {
- maintainers = with lib.maintainers; [ patryk27 ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-ephemeral";
+ meta = {
+ maintainers = with lib.maintainers; [ patryk27 ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- virtualisation.writableStore = true;
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ virtualisation.writableStore = true;
- containers.webserver = {
- ephemeral = true;
- privateNetwork = true;
- hostAddress = "10.231.136.1";
- localAddress = "10.231.136.2";
- config = {
- services.nginx = {
- enable = true;
- virtualHosts.localhost = {
- root = pkgs.runCommand "localhost" { } ''
- mkdir "$out"
- echo hello world > "$out/index.html"
- '';
- };
+ containers.webserver = {
+ ephemeral = true;
+ privateNetwork = true;
+ hostAddress = "10.231.136.1";
+ localAddress = "10.231.136.2";
+ config = {
+ services.nginx = {
+ enable = true;
+ virtualHosts.localhost = {
+ root = pkgs.runCommand "localhost" { } ''
+ mkdir "$out"
+ echo hello world > "$out/index.html"
+ '';
};
- networking.firewall.allowedTCPPorts = [ 80 ];
};
+ networking.firewall.allowedTCPPorts = [ 80 ];
};
};
+ };
- testScript = ''
- assert "webserver" in machine.succeed("nixos-container list")
+ testScript = ''
+ assert "webserver" in machine.succeed("nixos-container list")
- machine.succeed("nixos-container start webserver")
+ machine.succeed("nixos-container start webserver")
- with subtest("Container got its own root folder"):
- machine.succeed("ls /run/nixos-containers/webserver")
+ with subtest("Container got its own root folder"):
+ machine.succeed("ls /run/nixos-containers/webserver")
- with subtest("Container persistent directory is not created"):
- machine.fail("ls /var/lib/nixos-containers/webserver")
+ with subtest("Container persistent directory is not created"):
+ machine.fail("ls /var/lib/nixos-containers/webserver")
- # Since "start" returns after the container has reached
- # multi-user.target, we should now be able to access it.
- ip = machine.succeed("nixos-container show-ip webserver").rstrip()
- machine.succeed(f"ping -n -c1 {ip}")
- machine.succeed(f"curl --fail http://{ip}/ > /dev/null")
+ # Since "start" returns after the container has reached
+ # multi-user.target, we should now be able to access it.
+ ip = machine.succeed("nixos-container show-ip webserver").rstrip()
+ machine.succeed(f"ping -n -c1 {ip}")
+ machine.succeed(f"curl --fail http://{ip}/ > /dev/null")
- with subtest("Stop the container"):
- machine.succeed("nixos-container stop webserver")
- machine.fail(f"curl --fail --connect-timeout 2 http://{ip}/ > /dev/null")
+ with subtest("Stop the container"):
+ machine.succeed("nixos-container stop webserver")
+ machine.fail(f"curl --fail --connect-timeout 2 http://{ip}/ > /dev/null")
- with subtest("Container's root folder was removed"):
- machine.fail("ls /run/nixos-containers/webserver")
- '';
- }
-)
+ with subtest("Container's root folder was removed"):
+ machine.fail("ls /run/nixos-containers/webserver")
+ '';
+}
diff --git a/nixos/tests/containers-extra_veth.nix b/nixos/tests/containers-extra_veth.nix
index ed3b8099036b..3a50fa824986 100644
--- a/nixos/tests/containers-extra_veth.nix
+++ b/nixos/tests/containers-extra_veth.nix
@@ -1,115 +1,113 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-extra_veth";
- meta = {
- maintainers = with lib.maintainers; [ kampfschlaefer ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-extra_veth";
+ meta = {
+ maintainers = with lib.maintainers; [ kampfschlaefer ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ../modules/installer/cd-dvd/channel.nix ];
- virtualisation.writableStore = true;
- virtualisation.vlans = [ ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ../modules/installer/cd-dvd/channel.nix ];
+ virtualisation.writableStore = true;
+ virtualisation.vlans = [ ];
- networking.useDHCP = false;
- networking.bridges = {
- br0 = {
- interfaces = [ ];
- };
- br1 = {
- interfaces = [ ];
- };
+ networking.useDHCP = false;
+ networking.bridges = {
+ br0 = {
+ interfaces = [ ];
};
- networking.interfaces = {
- br0 = {
- ipv4.addresses = [
- {
- address = "192.168.0.1";
- prefixLength = 24;
- }
- ];
- ipv6.addresses = [
- {
- address = "fc00::1";
- prefixLength = 7;
- }
- ];
- };
- br1 = {
- ipv4.addresses = [
- {
- address = "192.168.1.1";
- prefixLength = 24;
- }
- ];
- };
+ br1 = {
+ interfaces = [ ];
};
-
- containers.webserver = {
- autoStart = true;
- privateNetwork = true;
- hostBridge = "br0";
- localAddress = "192.168.0.100/24";
- localAddress6 = "fc00::2/7";
- extraVeths = {
- veth1 = {
- hostBridge = "br1";
- localAddress = "192.168.1.100/24";
- };
- veth2 = {
- hostAddress = "192.168.2.1";
- localAddress = "192.168.2.100";
- };
- };
- config = {
- networking.firewall.allowedTCPPorts = [ 80 ];
- };
+ };
+ networking.interfaces = {
+ br0 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.0.1";
+ prefixLength = 24;
+ }
+ ];
+ ipv6.addresses = [
+ {
+ address = "fc00::1";
+ prefixLength = 7;
+ }
+ ];
+ };
+ br1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.1.1";
+ prefixLength = 24;
+ }
+ ];
};
-
- virtualisation.additionalPaths = [ pkgs.stdenv ];
};
- testScript = ''
- machine.wait_for_unit("default.target")
- assert "webserver" in machine.succeed("nixos-container list")
+ containers.webserver = {
+ autoStart = true;
+ privateNetwork = true;
+ hostBridge = "br0";
+ localAddress = "192.168.0.100/24";
+ localAddress6 = "fc00::2/7";
+ extraVeths = {
+ veth1 = {
+ hostBridge = "br1";
+ localAddress = "192.168.1.100/24";
+ };
+ veth2 = {
+ hostAddress = "192.168.2.1";
+ localAddress = "192.168.2.100";
+ };
+ };
+ config = {
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ };
+ };
- with subtest("Status of the webserver container is up"):
- assert "up" in machine.succeed("nixos-container status webserver")
+ virtualisation.additionalPaths = [ pkgs.stdenv ];
+ };
- with subtest("Ensure that the veths are inside the container"):
- assert "state UP" in machine.succeed(
- "nixos-container run webserver -- ip link show veth1"
- )
- assert "state UP" in machine.succeed(
- "nixos-container run webserver -- ip link show veth2"
- )
+ testScript = ''
+ machine.wait_for_unit("default.target")
+ assert "webserver" in machine.succeed("nixos-container list")
- with subtest("Ensure the presence of the extra veths"):
- assert "state UP" in machine.succeed("ip link show veth1")
- assert "state UP" in machine.succeed("ip link show veth2")
+ with subtest("Status of the webserver container is up"):
+ assert "up" in machine.succeed("nixos-container status webserver")
- with subtest("Ensure the veth1 is part of br1 on the host"):
- assert "master br1" in machine.succeed("ip link show veth1")
+ with subtest("Ensure that the veths are inside the container"):
+ assert "state UP" in machine.succeed(
+ "nixos-container run webserver -- ip link show veth1"
+ )
+ assert "state UP" in machine.succeed(
+ "nixos-container run webserver -- ip link show veth2"
+ )
- with subtest("Ping on main veth"):
- machine.succeed("ping -n -c 1 192.168.0.100")
- machine.succeed("ping -n -c 1 fc00::2")
+ with subtest("Ensure the presence of the extra veths"):
+ assert "state UP" in machine.succeed("ip link show veth1")
+ assert "state UP" in machine.succeed("ip link show veth2")
- with subtest("Ping on the first extra veth"):
- machine.succeed("ping -n -c 1 192.168.1.100 >&2")
+ with subtest("Ensure the veth1 is part of br1 on the host"):
+ assert "master br1" in machine.succeed("ip link show veth1")
- with subtest("Ping on the second extra veth"):
- machine.succeed("ping -n -c 1 192.168.2.100 >&2")
+ with subtest("Ping on main veth"):
+ machine.succeed("ping -n -c 1 192.168.0.100")
+ machine.succeed("ping -n -c 1 fc00::2")
- with subtest("Container can be stopped"):
- machine.succeed("nixos-container stop webserver")
- machine.fail("ping -n -c 1 192.168.1.100 >&2")
- machine.fail("ping -n -c 1 192.168.2.100 >&2")
+ with subtest("Ping on the first extra veth"):
+ machine.succeed("ping -n -c 1 192.168.1.100 >&2")
- with subtest("Destroying a declarative container should fail"):
- machine.fail("nixos-container destroy webserver")
- '';
- }
-)
+ with subtest("Ping on the second extra veth"):
+ machine.succeed("ping -n -c 1 192.168.2.100 >&2")
+
+ with subtest("Container can be stopped"):
+ machine.succeed("nixos-container stop webserver")
+ machine.fail("ping -n -c 1 192.168.1.100 >&2")
+ machine.fail("ping -n -c 1 192.168.2.100 >&2")
+
+ with subtest("Destroying a declarative container should fail"):
+ machine.fail("nixos-container destroy webserver")
+ '';
+}
diff --git a/nixos/tests/containers-hosts.nix b/nixos/tests/containers-hosts.nix
index 0e5f50f5292c..4e827e7c3983 100644
--- a/nixos/tests/containers-hosts.nix
+++ b/nixos/tests/containers-hosts.nix
@@ -1,55 +1,53 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-hosts";
- meta = {
- maintainers = with lib.maintainers; [ montag451 ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-hosts";
+ meta = {
+ maintainers = with lib.maintainers; [ montag451 ];
+ };
- nodes.machine =
- { lib, ... }:
- {
- virtualisation.vlans = [ ];
+ nodes.machine =
+ { lib, ... }:
+ {
+ virtualisation.vlans = [ ];
- networking.bridges.br0.interfaces = [ ];
- networking.interfaces.br0.ipv4.addresses = [
- {
- address = "10.11.0.254";
- prefixLength = 24;
- }
- ];
+ networking.bridges.br0.interfaces = [ ];
+ networking.interfaces.br0.ipv4.addresses = [
+ {
+ address = "10.11.0.254";
+ prefixLength = 24;
+ }
+ ];
- # Force /etc/hosts to be the only source for host name resolution
- environment.etc."nsswitch.conf".text = lib.mkForce ''
- hosts: files
- '';
+ # Force /etc/hosts to be the only source for host name resolution
+ environment.etc."nsswitch.conf".text = lib.mkForce ''
+ hosts: files
+ '';
- containers.simple = {
- autoStart = true;
- privateNetwork = true;
- localAddress = "10.10.0.1";
- hostAddress = "10.10.0.254";
+ containers.simple = {
+ autoStart = true;
+ privateNetwork = true;
+ localAddress = "10.10.0.1";
+ hostAddress = "10.10.0.254";
- config = { };
- };
-
- containers.netmask = {
- autoStart = true;
- privateNetwork = true;
- hostBridge = "br0";
- localAddress = "10.11.0.1/24";
-
- config = { };
- };
+ config = { };
};
- testScript = ''
- start_all()
- machine.wait_for_unit("default.target")
+ containers.netmask = {
+ autoStart = true;
+ privateNetwork = true;
+ hostBridge = "br0";
+ localAddress = "10.11.0.1/24";
- with subtest("Ping the containers using the entries added in /etc/hosts"):
- for host in "simple.containers", "netmask.containers":
- machine.succeed(f"ping -n -c 1 {host}")
- '';
- }
-)
+ config = { };
+ };
+ };
+
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("default.target")
+
+ with subtest("Ping the containers using the entries added in /etc/hosts"):
+ for host in "simple.containers", "netmask.containers":
+ machine.succeed(f"ping -n -c 1 {host}")
+ '';
+}
diff --git a/nixos/tests/containers-imperative.nix b/nixos/tests/containers-imperative.nix
index f1bd56519c6d..746e72f54a32 100644
--- a/nixos/tests/containers-imperative.nix
+++ b/nixos/tests/containers-imperative.nix
@@ -1,197 +1,195 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-imperative";
- meta = {
- maintainers = with lib.maintainers; [
- aristid
- aszlig
- kampfschlaefer
- ];
+{ pkgs, lib, ... }:
+{
+ name = "containers-imperative";
+ meta = {
+ maintainers = with lib.maintainers; [
+ aristid
+ aszlig
+ kampfschlaefer
+ ];
+ };
+
+ nodes.machine =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ imports = [ ../modules/installer/cd-dvd/channel.nix ];
+
+ # XXX: Sandbox setup fails while trying to hardlink files from the host's
+ # store file system into the prepared chroot directory.
+ nix.settings.sandbox = false;
+ nix.settings.substituters = [ ]; # don't try to access cache.nixos.org
+
+ virtualisation.memorySize = 2048;
+ virtualisation.writableStore = true;
+ # Make sure we always have all the required dependencies for creating a
+ # container available within the VM, because we don't have network access.
+ virtualisation.additionalPaths =
+ let
+ emptyContainer = import ../lib/eval-config.nix {
+ modules = lib.singleton {
+ nixpkgs = { inherit (config.nixpkgs) localSystem; };
+
+ containers.foo.config = { };
+ };
+
+ # The system is inherited from the host above.
+ # Set it to null, to remove the "legacy" entrypoint's non-hermetic default.
+ system = null;
+ };
+ in
+ with pkgs;
+ [
+ stdenv
+ stdenvNoCC
+ emptyContainer.config.containers.foo.path
+ libxslt
+ desktop-file-utils
+ texinfo
+ docbook5
+ libxml2
+ docbook_xsl_ns
+ xorg.lndir
+ documentation-highlighter
+ perlPackages.ConfigIniFiles
+ ];
};
- nodes.machine =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- imports = [ ../modules/installer/cd-dvd/channel.nix ];
-
- # XXX: Sandbox setup fails while trying to hardlink files from the host's
- # store file system into the prepared chroot directory.
- nix.settings.sandbox = false;
- nix.settings.substituters = [ ]; # don't try to access cache.nixos.org
-
- virtualisation.memorySize = 2048;
- virtualisation.writableStore = true;
- # Make sure we always have all the required dependencies for creating a
- # container available within the VM, because we don't have network access.
- virtualisation.additionalPaths =
- let
- emptyContainer = import ../lib/eval-config.nix {
- modules = lib.singleton {
- nixpkgs = { inherit (config.nixpkgs) localSystem; };
-
- containers.foo.config = { };
- };
-
- # The system is inherited from the host above.
- # Set it to null, to remove the "legacy" entrypoint's non-hermetic default.
- system = null;
- };
- in
- with pkgs;
- [
- stdenv
- stdenvNoCC
- emptyContainer.config.containers.foo.path
- libxslt
- desktop-file-utils
- texinfo
- docbook5
- libxml2
- docbook_xsl_ns
- xorg.lndir
- documentation-highlighter
- perlPackages.ConfigIniFiles
- ];
- };
-
- testScript =
- let
- tmpfilesContainerConfig = pkgs.writeText "container-config-tmpfiles" ''
- {
- systemd.tmpfiles.rules = [ "d /foo - - - - -" ];
- systemd.services.foo = {
- serviceConfig.Type = "oneshot";
- script = "ls -al /foo";
- wantedBy = [ "multi-user.target" ];
- };
- }
- '';
- brokenCfg = pkgs.writeText "broken.nix" ''
- {
- assertions = [
- { assertion = false;
- message = "I never evaluate";
- }
- ];
- }
- '';
- in
- ''
- with subtest("Make sure we have a NixOS tree (required by ‘nixos-container create’)"):
- machine.succeed("PAGER=cat nix-env -qa -A nixos.hello >&2")
-
- id1, id2 = None, None
-
- with subtest("Create some containers imperatively"):
- id1 = machine.succeed("nixos-container create foo --ensure-unique-name").rstrip()
- machine.log(f"created container {id1}")
-
- id2 = machine.succeed("nixos-container create foo --ensure-unique-name").rstrip()
- machine.log(f"created container {id2}")
-
- assert id1 != id2
-
- with subtest(f"Put the root of {id2} into a bind mount"):
- machine.succeed(
- f"mv /var/lib/nixos-containers/{id2} /id2-bindmount",
- f"mount --bind /id2-bindmount /var/lib/nixos-containers/{id1}",
- )
-
- ip1 = machine.succeed(f"nixos-container show-ip {id1}").rstrip()
- ip2 = machine.succeed(f"nixos-container show-ip {id2}").rstrip()
- assert ip1 != ip2
-
- with subtest(
- "Create a directory and a file we can later check if it still exists "
- + "after destruction of the container"
- ):
- machine.succeed("mkdir /nested-bindmount")
- machine.succeed("echo important data > /nested-bindmount/dummy")
-
- with subtest(
- "Create a directory with a dummy file and bind-mount it into both containers."
- ):
- for id in id1, id2:
- important_path = f"/var/lib/nixos-containers/{id}/very/important/data"
- machine.succeed(
- f"mkdir -p {important_path}",
- f"mount --bind /nested-bindmount {important_path}",
- )
-
- with subtest("Start one of them"):
- machine.succeed(f"nixos-container start {id1}")
-
- with subtest("Execute commands via the root shell"):
- assert "Linux" in machine.succeed(f"nixos-container run {id1} -- uname")
-
- with subtest("Execute a nix command via the root shell. (regression test for #40355)"):
- machine.succeed(
- f"nixos-container run {id1} -- nix-instantiate -E "
- + '\'derivation { name = "empty"; builder = "false"; system = "false"; }\' '
- )
-
- with subtest("Stop and start (regression test for #4989)"):
- machine.succeed(f"nixos-container stop {id1}")
- machine.succeed(f"nixos-container start {id1}")
-
- # clear serial backlog for next tests
- machine.succeed("logger eat console backlog 3ea46eb2-7f82-4f70-b810-3f00e3dd4c4d")
- machine.wait_for_console_text(
- "eat console backlog 3ea46eb2-7f82-4f70-b810-3f00e3dd4c4d"
- )
-
- with subtest("Stop a container early"):
- machine.succeed(f"nixos-container stop {id1}")
- machine.succeed(f"nixos-container start {id1} >&2 &")
- machine.wait_for_console_text("Stage 2")
- machine.succeed(f"nixos-container stop {id1}")
- machine.wait_for_console_text(f"Container {id1} exited successfully")
- machine.succeed(f"nixos-container start {id1}")
-
- with subtest("Stop a container without machined (regression test for #109695)"):
- machine.systemctl("stop systemd-machined")
- machine.succeed(f"nixos-container stop {id1}")
- machine.wait_for_console_text(f"Container {id1} has been shut down")
- machine.succeed(f"nixos-container start {id1}")
-
- with subtest("tmpfiles are present"):
- machine.log("creating container tmpfiles")
- machine.succeed(
- "nixos-container create tmpfiles --config-file ${tmpfilesContainerConfig}"
- )
- machine.log("created, starting…")
- machine.succeed("nixos-container start tmpfiles")
- machine.log("done starting, investigating…")
- machine.succeed(
- "echo $(nixos-container run tmpfiles -- systemctl is-active foo.service) | grep -q active;"
- )
- machine.succeed("nixos-container destroy tmpfiles")
-
- with subtest("Execute commands via the root shell"):
- assert "Linux" in machine.succeed(f"nixos-container run {id1} -- uname")
-
- with subtest("Destroy the containers"):
- for id in id1, id2:
- machine.succeed(f"nixos-container destroy {id}")
-
- with subtest("Check whether destruction of any container has killed important data"):
- machine.succeed("grep -qF 'important data' /nested-bindmount/dummy")
-
- with subtest("Ensure that the container path is gone"):
- print(machine.succeed("ls -lsa /var/lib/nixos-containers"))
- machine.succeed(f"test ! -e /var/lib/nixos-containers/{id1}")
-
- with subtest("Ensure that a failed container creation doesn'leave any state"):
- machine.fail(
- "nixos-container create b0rk --config-file ${brokenCfg}"
- )
- machine.succeed("test ! -e /var/lib/nixos-containers/b0rk")
+ testScript =
+ let
+ tmpfilesContainerConfig = pkgs.writeText "container-config-tmpfiles" ''
+ {
+ systemd.tmpfiles.rules = [ "d /foo - - - - -" ];
+ systemd.services.foo = {
+ serviceConfig.Type = "oneshot";
+ script = "ls -al /foo";
+ wantedBy = [ "multi-user.target" ];
+ };
+ }
'';
- }
-)
+ brokenCfg = pkgs.writeText "broken.nix" ''
+ {
+ assertions = [
+ { assertion = false;
+ message = "I never evaluate";
+ }
+ ];
+ }
+ '';
+ in
+ ''
+ with subtest("Make sure we have a NixOS tree (required by ‘nixos-container create’)"):
+ machine.succeed("PAGER=cat nix-env -qa -A nixos.hello >&2")
+
+ id1, id2 = None, None
+
+ with subtest("Create some containers imperatively"):
+ id1 = machine.succeed("nixos-container create foo --ensure-unique-name").rstrip()
+ machine.log(f"created container {id1}")
+
+ id2 = machine.succeed("nixos-container create foo --ensure-unique-name").rstrip()
+ machine.log(f"created container {id2}")
+
+ assert id1 != id2
+
+ with subtest(f"Put the root of {id2} into a bind mount"):
+ machine.succeed(
+ f"mv /var/lib/nixos-containers/{id2} /id2-bindmount",
+ f"mount --bind /id2-bindmount /var/lib/nixos-containers/{id1}",
+ )
+
+ ip1 = machine.succeed(f"nixos-container show-ip {id1}").rstrip()
+ ip2 = machine.succeed(f"nixos-container show-ip {id2}").rstrip()
+ assert ip1 != ip2
+
+ with subtest(
+ "Create a directory and a file we can later check if it still exists "
+ + "after destruction of the container"
+ ):
+ machine.succeed("mkdir /nested-bindmount")
+ machine.succeed("echo important data > /nested-bindmount/dummy")
+
+ with subtest(
+ "Create a directory with a dummy file and bind-mount it into both containers."
+ ):
+ for id in id1, id2:
+ important_path = f"/var/lib/nixos-containers/{id}/very/important/data"
+ machine.succeed(
+ f"mkdir -p {important_path}",
+ f"mount --bind /nested-bindmount {important_path}",
+ )
+
+ with subtest("Start one of them"):
+ machine.succeed(f"nixos-container start {id1}")
+
+ with subtest("Execute commands via the root shell"):
+ assert "Linux" in machine.succeed(f"nixos-container run {id1} -- uname")
+
+ with subtest("Execute a nix command via the root shell. (regression test for #40355)"):
+ machine.succeed(
+ f"nixos-container run {id1} -- nix-instantiate -E "
+ + '\'derivation { name = "empty"; builder = "false"; system = "false"; }\' '
+ )
+
+ with subtest("Stop and start (regression test for #4989)"):
+ machine.succeed(f"nixos-container stop {id1}")
+ machine.succeed(f"nixos-container start {id1}")
+
+ # clear serial backlog for next tests
+ machine.succeed("logger eat console backlog 3ea46eb2-7f82-4f70-b810-3f00e3dd4c4d")
+ machine.wait_for_console_text(
+ "eat console backlog 3ea46eb2-7f82-4f70-b810-3f00e3dd4c4d"
+ )
+
+ with subtest("Stop a container early"):
+ machine.succeed(f"nixos-container stop {id1}")
+ machine.succeed(f"nixos-container start {id1} >&2 &")
+ machine.wait_for_console_text("Stage 2")
+ machine.succeed(f"nixos-container stop {id1}")
+ machine.wait_for_console_text(f"Container {id1} exited successfully")
+ machine.succeed(f"nixos-container start {id1}")
+
+ with subtest("Stop a container without machined (regression test for #109695)"):
+ machine.systemctl("stop systemd-machined")
+ machine.succeed(f"nixos-container stop {id1}")
+ machine.wait_for_console_text(f"Container {id1} has been shut down")
+ machine.succeed(f"nixos-container start {id1}")
+
+ with subtest("tmpfiles are present"):
+ machine.log("creating container tmpfiles")
+ machine.succeed(
+ "nixos-container create tmpfiles --config-file ${tmpfilesContainerConfig}"
+ )
+ machine.log("created, starting…")
+ machine.succeed("nixos-container start tmpfiles")
+ machine.log("done starting, investigating…")
+ machine.succeed(
+ "echo $(nixos-container run tmpfiles -- systemctl is-active foo.service) | grep -q active;"
+ )
+ machine.succeed("nixos-container destroy tmpfiles")
+
+ with subtest("Execute commands via the root shell"):
+ assert "Linux" in machine.succeed(f"nixos-container run {id1} -- uname")
+
+ with subtest("Destroy the containers"):
+ for id in id1, id2:
+ machine.succeed(f"nixos-container destroy {id}")
+
+ with subtest("Check whether destruction of any container has killed important data"):
+ machine.succeed("grep -qF 'important data' /nested-bindmount/dummy")
+
+ with subtest("Ensure that the container path is gone"):
+ print(machine.succeed("ls -lsa /var/lib/nixos-containers"))
+ machine.succeed(f"test ! -e /var/lib/nixos-containers/{id1}")
+
+ with subtest("Ensure that a failed container creation doesn'leave any state"):
+ machine.fail(
+ "nixos-container create b0rk --config-file ${brokenCfg}"
+ )
+ machine.succeed("test ! -e /var/lib/nixos-containers/b0rk")
+ '';
+}
diff --git a/nixos/tests/containers-ip.nix b/nixos/tests/containers-ip.nix
index 979fb365126d..44217970d24e 100644
--- a/nixos/tests/containers-ip.nix
+++ b/nixos/tests/containers-ip.nix
@@ -12,71 +12,69 @@ let
};
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-ipv4-ipv6";
- meta = {
- maintainers = with lib.maintainers; [
- aristid
- aszlig
- kampfschlaefer
- ];
+{ pkgs, lib, ... }:
+{
+ name = "containers-ipv4-ipv6";
+ meta = {
+ maintainers = with lib.maintainers; [
+ aristid
+ aszlig
+ kampfschlaefer
+ ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ virtualisation.writableStore = true;
+
+ containers.webserver4 = webserverFor "10.231.136.1" "10.231.136.2";
+ containers.webserver6 = webserverFor "fc00::2" "fc00::1";
+ virtualisation.additionalPaths = [ pkgs.stdenv ];
};
- nodes.machine =
- { pkgs, ... }:
- {
- virtualisation.writableStore = true;
-
- containers.webserver4 = webserverFor "10.231.136.1" "10.231.136.2";
- containers.webserver6 = webserverFor "fc00::2" "fc00::1";
- virtualisation.additionalPaths = [ pkgs.stdenv ];
- };
-
- testScript =
- { nodes, ... }:
- ''
- import time
+ testScript =
+ { nodes, ... }:
+ ''
+ import time
- def curl_host(ip):
- # put [] around ipv6 addresses for curl
- host = ip if ":" not in ip else f"[{ip}]"
- return f"curl --fail --connect-timeout 2 http://{host}/ > /dev/null"
+ def curl_host(ip):
+ # put [] around ipv6 addresses for curl
+ host = ip if ":" not in ip else f"[{ip}]"
+ return f"curl --fail --connect-timeout 2 http://{host}/ > /dev/null"
- def get_ip(container):
- # need to distinguish because show-ip won't work for ipv6
- if container == "webserver4":
- ip = machine.succeed(f"nixos-container show-ip {container}").rstrip()
- assert ip == "${nodes.machine.config.containers.webserver4.localAddress}"
- return ip
- return "${nodes.machine.config.containers.webserver6.localAddress}"
+ def get_ip(container):
+ # need to distinguish because show-ip won't work for ipv6
+ if container == "webserver4":
+ ip = machine.succeed(f"nixos-container show-ip {container}").rstrip()
+ assert ip == "${nodes.machine.config.containers.webserver4.localAddress}"
+ return ip
+ return "${nodes.machine.config.containers.webserver6.localAddress}"
- for container in "webserver4", "webserver6":
- assert container in machine.succeed("nixos-container list")
+ for container in "webserver4", "webserver6":
+ assert container in machine.succeed("nixos-container list")
- with subtest(f"Start container {container}"):
- machine.succeed(f"nixos-container start {container}")
- # wait 2s for container to start and network to be up
- time.sleep(2)
+ with subtest(f"Start container {container}"):
+ machine.succeed(f"nixos-container start {container}")
+ # wait 2s for container to start and network to be up
+ time.sleep(2)
- # Since "start" returns after the container has reached
- # multi-user.target, we should now be able to access it.
+ # Since "start" returns after the container has reached
+ # multi-user.target, we should now be able to access it.
- ip = get_ip(container)
- with subtest(f"{container} reacts to pings and HTTP requests"):
- machine.succeed(f"ping -n -c1 {ip}")
- machine.succeed(curl_host(ip))
+ ip = get_ip(container)
+ with subtest(f"{container} reacts to pings and HTTP requests"):
+ machine.succeed(f"ping -n -c1 {ip}")
+ machine.succeed(curl_host(ip))
- with subtest(f"Stop container {container}"):
- machine.succeed(f"nixos-container stop {container}")
- machine.fail(curl_host(ip))
+ with subtest(f"Stop container {container}"):
+ machine.succeed(f"nixos-container stop {container}")
+ machine.fail(curl_host(ip))
- # Destroying a declarative container should fail.
- machine.fail(f"nixos-container destroy {container}")
- '';
- }
-)
+ # Destroying a declarative container should fail.
+ machine.fail(f"nixos-container destroy {container}")
+ '';
+}
diff --git a/nixos/tests/containers-macvlans.nix b/nixos/tests/containers-macvlans.nix
index 3ebfef9d0bc8..7b9644d0542f 100644
--- a/nixos/tests/containers-macvlans.nix
+++ b/nixos/tests/containers-macvlans.nix
@@ -4,97 +4,95 @@ let
containerIp2 = "192.168.1.254";
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-macvlans";
- meta = {
- maintainers = with lib.maintainers; [ montag451 ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-macvlans";
+ meta = {
+ maintainers = with lib.maintainers; [ montag451 ];
+ };
- nodes = {
+ nodes = {
- machine1 =
- { lib, ... }:
- {
- virtualisation.vlans = [ 1 ];
+ machine1 =
+ { lib, ... }:
+ {
+ virtualisation.vlans = [ 1 ];
- # To be able to ping containers from the host, it is necessary
- # to create a macvlan on the host on the VLAN 1 network.
- networking.macvlans.mv-eth1-host = {
- interface = "eth1";
- mode = "bridge";
- };
- networking.interfaces.eth1.ipv4.addresses = lib.mkForce [ ];
- networking.interfaces.mv-eth1-host = {
- ipv4.addresses = [
- {
- address = "192.168.1.1";
- prefixLength = 24;
- }
- ];
- };
+ # To be able to ping containers from the host, it is necessary
+ # to create a macvlan on the host on the VLAN 1 network.
+ networking.macvlans.mv-eth1-host = {
+ interface = "eth1";
+ mode = "bridge";
+ };
+ networking.interfaces.eth1.ipv4.addresses = lib.mkForce [ ];
+ networking.interfaces.mv-eth1-host = {
+ ipv4.addresses = [
+ {
+ address = "192.168.1.1";
+ prefixLength = 24;
+ }
+ ];
+ };
- containers.test1 = {
- autoStart = true;
- macvlans = [ "eth1" ];
+ containers.test1 = {
+ autoStart = true;
+ macvlans = [ "eth1" ];
- config = {
- networking.interfaces.mv-eth1 = {
- ipv4.addresses = [
- {
- address = containerIp1;
- prefixLength = 24;
- }
- ];
- };
- };
- };
-
- containers.test2 = {
- autoStart = true;
- macvlans = [ "eth1" ];
-
- config = {
- networking.interfaces.mv-eth1 = {
- ipv4.addresses = [
- {
- address = containerIp2;
- prefixLength = 24;
- }
- ];
- };
+ config = {
+ networking.interfaces.mv-eth1 = {
+ ipv4.addresses = [
+ {
+ address = containerIp1;
+ prefixLength = 24;
+ }
+ ];
};
};
};
- machine2 =
- { ... }:
- {
- virtualisation.vlans = [ 1 ];
+ containers.test2 = {
+ autoStart = true;
+ macvlans = [ "eth1" ];
+
+ config = {
+ networking.interfaces.mv-eth1 = {
+ ipv4.addresses = [
+ {
+ address = containerIp2;
+ prefixLength = 24;
+ }
+ ];
+ };
+ };
};
+ };
- };
+ machine2 =
+ { ... }:
+ {
+ virtualisation.vlans = [ 1 ];
+ };
- testScript = ''
- start_all()
- machine1.wait_for_unit("default.target")
- machine2.wait_for_unit("default.target")
+ };
- with subtest(
- "Ping between containers to check that macvlans are created in bridge mode"
- ):
- machine1.succeed("nixos-container run test1 -- ping -n -c 1 ${containerIp2}")
+ testScript = ''
+ start_all()
+ machine1.wait_for_unit("default.target")
+ machine2.wait_for_unit("default.target")
- with subtest("Ping containers from the host (machine1)"):
- machine1.succeed("ping -n -c 1 ${containerIp1}")
- machine1.succeed("ping -n -c 1 ${containerIp2}")
+ with subtest(
+ "Ping between containers to check that macvlans are created in bridge mode"
+ ):
+ machine1.succeed("nixos-container run test1 -- ping -n -c 1 ${containerIp2}")
- with subtest(
- "Ping containers from the second machine to check that containers are reachable from the outside"
- ):
- machine2.succeed("ping -n -c 1 ${containerIp1}")
- machine2.succeed("ping -n -c 1 ${containerIp2}")
- '';
- }
-)
+ with subtest("Ping containers from the host (machine1)"):
+ machine1.succeed("ping -n -c 1 ${containerIp1}")
+ machine1.succeed("ping -n -c 1 ${containerIp2}")
+
+ with subtest(
+ "Ping containers from the second machine to check that containers are reachable from the outside"
+ ):
+ machine2.succeed("ping -n -c 1 ${containerIp1}")
+ machine2.succeed("ping -n -c 1 ${containerIp2}")
+ '';
+}
diff --git a/nixos/tests/containers-names.nix b/nixos/tests/containers-names.nix
index 2ed047b62fe2..65f2763c50b3 100644
--- a/nixos/tests/containers-names.nix
+++ b/nixos/tests/containers-names.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-names";
- meta = {
- maintainers = with lib.maintainers; [ patryk27 ];
+{ pkgs, lib, ... }:
+{
+ name = "containers-names";
+ meta = {
+ maintainers = with lib.maintainers; [ patryk27 ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ # We're using the newest kernel, so that we can test containers with long names.
+ # Please see https://github.com/NixOS/nixpkgs/issues/38509 for details.
+ boot.kernelPackages = pkgs.linuxPackages_latest;
+
+ containers =
+ let
+ container = subnet: {
+ autoStart = true;
+ privateNetwork = true;
+ hostAddress = "192.168.${subnet}.1";
+ localAddress = "192.168.${subnet}.2";
+ config = { };
+ };
+
+ in
+ {
+ first = container "1";
+ second = container "2";
+ really-long-name = container "3";
+ really-long-long-name-2 = container "4";
+ };
};
- nodes.machine =
- { ... }:
- {
- # We're using the newest kernel, so that we can test containers with long names.
- # Please see https://github.com/NixOS/nixpkgs/issues/38509 for details.
- boot.kernelPackages = pkgs.linuxPackages_latest;
+ testScript = ''
+ machine.wait_for_unit("default.target")
- containers =
- let
- container = subnet: {
- autoStart = true;
- privateNetwork = true;
- hostAddress = "192.168.${subnet}.1";
- localAddress = "192.168.${subnet}.2";
- config = { };
- };
-
- in
- {
- first = container "1";
- second = container "2";
- really-long-name = container "3";
- really-long-long-name-2 = container "4";
- };
- };
-
- testScript = ''
- machine.wait_for_unit("default.target")
-
- machine.succeed("ip link show | grep ve-first")
- machine.succeed("ip link show | grep ve-second")
- machine.succeed("ip link show | grep ve-really-lFYWO")
- machine.succeed("ip link show | grep ve-really-l3QgY")
- '';
- }
-)
+ machine.succeed("ip link show | grep ve-first")
+ machine.succeed("ip link show | grep ve-second")
+ machine.succeed("ip link show | grep ve-really-lFYWO")
+ machine.succeed("ip link show | grep ve-really-l3QgY")
+ '';
+}
diff --git a/nixos/tests/containers-nested.nix b/nixos/tests/containers-nested.nix
index a274b64c443e..363332dc5853 100644
--- a/nixos/tests/containers-nested.nix
+++ b/nixos/tests/containers-nested.nix
@@ -1,36 +1,34 @@
# Test for NixOS' container nesting.
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "nested";
+{ pkgs, ... }:
+{
+ name = "nested";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ sorki ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ sorki ];
+ };
- nodes.machine =
- { lib, ... }:
- let
- makeNested = subConf: {
- containers.nested = {
- autoStart = true;
- privateNetwork = true;
- config = subConf;
- };
+ nodes.machine =
+ { lib, ... }:
+ let
+ makeNested = subConf: {
+ containers.nested = {
+ autoStart = true;
+ privateNetwork = true;
+ config = subConf;
};
- in
- makeNested (makeNested { });
+ };
+ in
+ makeNested (makeNested { });
- testScript = ''
- machine.start()
- machine.wait_for_unit("container@nested.service")
- machine.succeed("systemd-run --pty --machine=nested -- machinectl list | grep nested")
- print(
- machine.succeed(
- "systemd-run --pty --machine=nested -- systemd-run --pty --machine=nested -- systemctl status"
- )
- )
- '';
- }
-)
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("container@nested.service")
+ machine.succeed("systemd-run --pty --machine=nested -- machinectl list | grep nested")
+ print(
+ machine.succeed(
+ "systemd-run --pty --machine=nested -- systemd-run --pty --machine=nested -- systemctl status"
+ )
+ )
+ '';
+}
diff --git a/nixos/tests/containers-physical_interfaces.nix b/nixos/tests/containers-physical_interfaces.nix
index efe7982c6762..aa96727985c5 100644
--- a/nixos/tests/containers-physical_interfaces.nix
+++ b/nixos/tests/containers-physical_interfaces.nix
@@ -1,153 +1,151 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-physical_interfaces";
- meta = {
- maintainers = with lib.maintainers; [ kampfschlaefer ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-physical_interfaces";
+ meta = {
+ maintainers = with lib.maintainers; [ kampfschlaefer ];
+ };
- nodes = {
- server =
- { ... }:
- {
- virtualisation.vlans = [ 1 ];
+ nodes = {
+ server =
+ { ... }:
+ {
+ virtualisation.vlans = [ 1 ];
- containers.server = {
- privateNetwork = true;
- interfaces = [ "eth1" ];
+ containers.server = {
+ privateNetwork = true;
+ interfaces = [ "eth1" ];
- config = {
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "10.10.0.1";
- prefixLength = 24;
- }
- ];
- networking.firewall.enable = false;
- };
+ config = {
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "10.10.0.1";
+ prefixLength = 24;
+ }
+ ];
+ networking.firewall.enable = false;
};
};
- bridged =
- { ... }:
- {
- virtualisation.vlans = [ 1 ];
+ };
+ bridged =
+ { ... }:
+ {
+ virtualisation.vlans = [ 1 ];
- containers.bridged = {
- privateNetwork = true;
- interfaces = [ "eth1" ];
+ containers.bridged = {
+ privateNetwork = true;
+ interfaces = [ "eth1" ];
- config = {
- networking.bridges.br0.interfaces = [ "eth1" ];
- networking.interfaces.br0.ipv4.addresses = [
- {
- address = "10.10.0.2";
- prefixLength = 24;
- }
- ];
- networking.firewall.enable = false;
- };
+ config = {
+ networking.bridges.br0.interfaces = [ "eth1" ];
+ networking.interfaces.br0.ipv4.addresses = [
+ {
+ address = "10.10.0.2";
+ prefixLength = 24;
+ }
+ ];
+ networking.firewall.enable = false;
};
};
+ };
- bonded =
- { ... }:
- {
- virtualisation.vlans = [ 1 ];
+ bonded =
+ { ... }:
+ {
+ virtualisation.vlans = [ 1 ];
- containers.bonded = {
- privateNetwork = true;
- interfaces = [ "eth1" ];
+ containers.bonded = {
+ privateNetwork = true;
+ interfaces = [ "eth1" ];
- config = {
- networking.bonds.bond0 = {
- interfaces = [ "eth1" ];
- driverOptions.mode = "active-backup";
- };
- networking.interfaces.bond0.ipv4.addresses = [
- {
- address = "10.10.0.3";
- prefixLength = 24;
- }
- ];
- networking.firewall.enable = false;
+ config = {
+ networking.bonds.bond0 = {
+ interfaces = [ "eth1" ];
+ driverOptions.mode = "active-backup";
};
+ networking.interfaces.bond0.ipv4.addresses = [
+ {
+ address = "10.10.0.3";
+ prefixLength = 24;
+ }
+ ];
+ networking.firewall.enable = false;
};
};
+ };
- bridgedbond =
- { ... }:
- {
- virtualisation.vlans = [ 1 ];
+ bridgedbond =
+ { ... }:
+ {
+ virtualisation.vlans = [ 1 ];
- containers.bridgedbond = {
- privateNetwork = true;
- interfaces = [ "eth1" ];
+ containers.bridgedbond = {
+ privateNetwork = true;
+ interfaces = [ "eth1" ];
- config = {
- networking.bonds.bond0 = {
- interfaces = [ "eth1" ];
- driverOptions.mode = "active-backup";
- };
- networking.bridges.br0.interfaces = [ "bond0" ];
- networking.interfaces.br0.ipv4.addresses = [
- {
- address = "10.10.0.4";
- prefixLength = 24;
- }
- ];
- networking.firewall.enable = false;
+ config = {
+ networking.bonds.bond0 = {
+ interfaces = [ "eth1" ];
+ driverOptions.mode = "active-backup";
};
+ networking.bridges.br0.interfaces = [ "bond0" ];
+ networking.interfaces.br0.ipv4.addresses = [
+ {
+ address = "10.10.0.4";
+ prefixLength = 24;
+ }
+ ];
+ networking.firewall.enable = false;
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- with subtest("Prepare server"):
- server.wait_for_unit("default.target")
- server.succeed("ip link show dev eth1 >&2")
+ with subtest("Prepare server"):
+ server.wait_for_unit("default.target")
+ server.succeed("ip link show dev eth1 >&2")
- with subtest("Simple physical interface is up"):
- server.succeed("nixos-container start server")
- server.wait_for_unit("container@server")
- server.succeed(
- "systemctl -M server list-dependencies network-addresses-eth1.service >&2"
- )
+ with subtest("Simple physical interface is up"):
+ server.succeed("nixos-container start server")
+ server.wait_for_unit("container@server")
+ server.succeed(
+ "systemctl -M server list-dependencies network-addresses-eth1.service >&2"
+ )
- # The other tests will ping this container on its ip. Here we just check
- # that the device is present in the container.
- server.succeed("nixos-container run server -- ip a show dev eth1 >&2")
+ # The other tests will ping this container on its ip. Here we just check
+ # that the device is present in the container.
+ server.succeed("nixos-container run server -- ip a show dev eth1 >&2")
- with subtest("Physical device in bridge in container can ping server"):
- bridged.wait_for_unit("default.target")
- bridged.succeed("nixos-container start bridged")
- bridged.wait_for_unit("container@bridged")
- bridged.succeed(
- "systemctl -M bridged list-dependencies network-addresses-br0.service >&2",
- "systemctl -M bridged status -n 30 -l network-addresses-br0.service",
- "nixos-container run bridged -- ping -w 10 -c 1 -n 10.10.0.1",
- )
+ with subtest("Physical device in bridge in container can ping server"):
+ bridged.wait_for_unit("default.target")
+ bridged.succeed("nixos-container start bridged")
+ bridged.wait_for_unit("container@bridged")
+ bridged.succeed(
+ "systemctl -M bridged list-dependencies network-addresses-br0.service >&2",
+ "systemctl -M bridged status -n 30 -l network-addresses-br0.service",
+ "nixos-container run bridged -- ping -w 10 -c 1 -n 10.10.0.1",
+ )
- with subtest("Physical device in bond in container can ping server"):
- bonded.wait_for_unit("default.target")
- bonded.succeed("nixos-container start bonded")
- bonded.wait_for_unit("container@bonded")
- bonded.succeed(
- "systemctl -M bonded list-dependencies network-addresses-bond0 >&2",
- "systemctl -M bonded status -n 30 -l network-addresses-bond0 >&2",
- "nixos-container run bonded -- ping -w 10 -c 1 -n 10.10.0.1",
- )
+ with subtest("Physical device in bond in container can ping server"):
+ bonded.wait_for_unit("default.target")
+ bonded.succeed("nixos-container start bonded")
+ bonded.wait_for_unit("container@bonded")
+ bonded.succeed(
+ "systemctl -M bonded list-dependencies network-addresses-bond0 >&2",
+ "systemctl -M bonded status -n 30 -l network-addresses-bond0 >&2",
+ "nixos-container run bonded -- ping -w 10 -c 1 -n 10.10.0.1",
+ )
- with subtest("Physical device in bond in bridge in container can ping server"):
- bridgedbond.wait_for_unit("default.target")
- bridgedbond.succeed("nixos-container start bridgedbond")
- bridgedbond.wait_for_unit("container@bridgedbond")
- bridgedbond.succeed(
- "systemctl -M bridgedbond list-dependencies network-addresses-br0.service >&2",
- "systemctl -M bridgedbond status -n 30 -l network-addresses-br0.service",
- "nixos-container run bridgedbond -- ping -w 10 -c 1 -n 10.10.0.1",
- )
- '';
- }
-)
+ with subtest("Physical device in bond in bridge in container can ping server"):
+ bridgedbond.wait_for_unit("default.target")
+ bridgedbond.succeed("nixos-container start bridgedbond")
+ bridgedbond.wait_for_unit("container@bridgedbond")
+ bridgedbond.succeed(
+ "systemctl -M bridgedbond list-dependencies network-addresses-br0.service >&2",
+ "systemctl -M bridgedbond status -n 30 -l network-addresses-br0.service",
+ "nixos-container run bridgedbond -- ping -w 10 -c 1 -n 10.10.0.1",
+ )
+ '';
+}
diff --git a/nixos/tests/containers-portforward.nix b/nixos/tests/containers-portforward.nix
index be087dba48f0..21b618b4abd5 100644
--- a/nixos/tests/containers-portforward.nix
+++ b/nixos/tests/containers-portforward.nix
@@ -5,69 +5,67 @@ let
containerPort = 80;
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-portforward";
- meta = {
- maintainers = with lib.maintainers; [
- aristid
- aszlig
- kampfschlaefer
- ianwookim
- ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-portforward";
+ meta = {
+ maintainers = with lib.maintainers; [
+ aristid
+ aszlig
+ kampfschlaefer
+ ianwookim
+ ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ../modules/installer/cd-dvd/channel.nix ];
- virtualisation.writableStore = true;
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ../modules/installer/cd-dvd/channel.nix ];
+ virtualisation.writableStore = true;
- containers.webserver = {
- privateNetwork = true;
- hostAddress = hostIp;
- localAddress = containerIp;
- forwardPorts = [
- {
- protocol = "tcp";
- hostPort = hostPort;
- containerPort = containerPort;
- }
- ];
- config = {
- services.httpd.enable = true;
- services.httpd.adminAddr = "foo@example.org";
- networking.firewall.allowedTCPPorts = [ 80 ];
- };
+ containers.webserver = {
+ privateNetwork = true;
+ hostAddress = hostIp;
+ localAddress = containerIp;
+ forwardPorts = [
+ {
+ protocol = "tcp";
+ hostPort = hostPort;
+ containerPort = containerPort;
+ }
+ ];
+ config = {
+ services.httpd.enable = true;
+ services.httpd.adminAddr = "foo@example.org";
+ networking.firewall.allowedTCPPorts = [ 80 ];
};
-
- virtualisation.additionalPaths = [ pkgs.stdenv ];
};
- testScript = ''
- container_list = machine.succeed("nixos-container list")
- assert "webserver" in container_list
+ virtualisation.additionalPaths = [ pkgs.stdenv ];
+ };
- # Start the webserver container.
- machine.succeed("nixos-container start webserver")
+ testScript = ''
+ container_list = machine.succeed("nixos-container list")
+ assert "webserver" in container_list
- # wait two seconds for the container to start and the network to be up
- machine.sleep(2)
+ # Start the webserver container.
+ machine.succeed("nixos-container start webserver")
- # Since "start" returns after the container has reached
- # multi-user.target, we should now be able to access it.
- # ip = machine.succeed("nixos-container show-ip webserver").strip()
- machine.succeed("ping -n -c1 ${hostIp}")
- machine.succeed("curl --fail http://${hostIp}:${toString hostPort}/ > /dev/null")
+ # wait two seconds for the container to start and the network to be up
+ machine.sleep(2)
- # Stop the container.
- machine.succeed("nixos-container stop webserver")
- machine.fail("curl --fail --connect-timeout 2 http://${hostIp}:${toString hostPort}/ > /dev/null")
+ # Since "start" returns after the container has reached
+ # multi-user.target, we should now be able to access it.
+ # ip = machine.succeed("nixos-container show-ip webserver").strip()
+ machine.succeed("ping -n -c1 ${hostIp}")
+ machine.succeed("curl --fail http://${hostIp}:${toString hostPort}/ > /dev/null")
- # Destroying a declarative container should fail.
- machine.fail("nixos-container destroy webserver")
- '';
+ # Stop the container.
+ machine.succeed("nixos-container stop webserver")
+ machine.fail("curl --fail --connect-timeout 2 http://${hostIp}:${toString hostPort}/ > /dev/null")
- }
-)
+ # Destroying a declarative container should fail.
+ machine.fail("nixos-container destroy webserver")
+ '';
+
+}
diff --git a/nixos/tests/containers-reloadable.nix b/nixos/tests/containers-reloadable.nix
index 74c6003da659..9854db830550 100644
--- a/nixos/tests/containers-reloadable.nix
+++ b/nixos/tests/containers-reloadable.nix
@@ -1,61 +1,59 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-reloadable";
- meta = {
- maintainers = with lib.maintainers; [ danbst ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-reloadable";
+ meta = {
+ maintainers = with lib.maintainers; [ danbst ];
+ };
- nodes = {
- machine =
- { lib, ... }:
- {
- containers.test1 = {
- autoStart = true;
- config.environment.etc.check.text = "client_base";
- };
+ nodes = {
+ machine =
+ { lib, ... }:
+ {
+ containers.test1 = {
+ autoStart = true;
+ config.environment.etc.check.text = "client_base";
+ };
- # prevent make-test-python.nix to change IP
- networking.interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [ ];
+ # prevent make-test-python.nix to change IP
+ networking.interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [ ];
- specialisation.c1.configuration = {
- containers.test1.config = {
- environment.etc.check.text = lib.mkForce "client_c1";
- services.httpd.enable = true;
- services.httpd.adminAddr = "nixos@example.com";
- };
- };
-
- specialisation.c2.configuration = {
- containers.test1.config = {
- environment.etc.check.text = lib.mkForce "client_c2";
- services.nginx.enable = true;
- };
+ specialisation.c1.configuration = {
+ containers.test1.config = {
+ environment.etc.check.text = lib.mkForce "client_c1";
+ services.httpd.enable = true;
+ services.httpd.adminAddr = "nixos@example.com";
};
};
- };
- testScript = ''
- machine.start()
- machine.wait_for_unit("default.target")
+ specialisation.c2.configuration = {
+ containers.test1.config = {
+ environment.etc.check.text = lib.mkForce "client_c2";
+ services.nginx.enable = true;
+ };
+ };
+ };
+ };
- assert "client_base" in machine.succeed("nixos-container run test1 cat /etc/check")
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("default.target")
- with subtest("httpd is available after activating config1"):
- machine.succeed(
- "/run/booted-system/specialisation/c1/bin/switch-to-configuration test >&2",
- "[[ $(nixos-container run test1 cat /etc/check) == client_c1 ]] >&2",
- "systemctl status httpd -M test1 >&2",
- )
+ assert "client_base" in machine.succeed("nixos-container run test1 cat /etc/check")
- with subtest("httpd is not available any longer after switching to config2"):
- machine.succeed(
- "/run/booted-system/specialisation/c2/bin/switch-to-configuration test >&2",
- "[[ $(nixos-container run test1 cat /etc/check) == client_c2 ]] >&2",
- "systemctl status nginx -M test1 >&2",
- )
- machine.fail("systemctl status httpd -M test1 >&2")
- '';
+ with subtest("httpd is available after activating config1"):
+ machine.succeed(
+ "/run/booted-system/specialisation/c1/bin/switch-to-configuration test >&2",
+ "[[ $(nixos-container run test1 cat /etc/check) == client_c1 ]] >&2",
+ "systemctl status httpd -M test1 >&2",
+ )
- }
-)
+ with subtest("httpd is not available any longer after switching to config2"):
+ machine.succeed(
+ "/run/booted-system/specialisation/c2/bin/switch-to-configuration test >&2",
+ "[[ $(nixos-container run test1 cat /etc/check) == client_c2 ]] >&2",
+ "systemctl status nginx -M test1 >&2",
+ )
+ machine.fail("systemctl status httpd -M test1 >&2")
+ '';
+
+}
diff --git a/nixos/tests/containers-require-bind-mounts.nix b/nixos/tests/containers-require-bind-mounts.nix
index b5a861beacc9..eb65a619c7e9 100644
--- a/nixos/tests/containers-require-bind-mounts.nix
+++ b/nixos/tests/containers-require-bind-mounts.nix
@@ -1,40 +1,38 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "containers-require-bind-mounts";
- meta.maintainers = with lib.maintainers; [ kira-bruneau ];
+{ lib, ... }:
+{
+ name = "containers-require-bind-mounts";
+ meta.maintainers = with lib.maintainers; [ kira-bruneau ];
- nodes.machine = {
- containers.require-bind-mounts = {
- bindMounts = {
- "/srv/data" = { };
- };
- config = { };
- };
-
- virtualisation.fileSystems = {
- "/srv/data" = {
- fsType = "tmpfs";
- options = [ "noauto" ];
- };
+ nodes.machine = {
+ containers.require-bind-mounts = {
+ bindMounts = {
+ "/srv/data" = { };
};
+ config = { };
};
- testScript = ''
- machine.wait_for_unit("default.target")
+ virtualisation.fileSystems = {
+ "/srv/data" = {
+ fsType = "tmpfs";
+ options = [ "noauto" ];
+ };
+ };
+ };
- assert "require-bind-mounts" in machine.succeed("nixos-container list")
+ testScript = ''
+ machine.wait_for_unit("default.target")
+
+ assert "require-bind-mounts" in machine.succeed("nixos-container list")
+ assert "down" in machine.succeed("nixos-container status require-bind-mounts")
+ assert "inactive" in machine.fail("systemctl is-active srv-data.mount")
+
+ with subtest("bind mount host paths must be mounted to run container"):
+ machine.succeed("nixos-container start require-bind-mounts")
+ assert "up" in machine.succeed("nixos-container status require-bind-mounts")
+ assert "active" in machine.succeed("systemctl status srv-data.mount")
+
+ machine.succeed("systemctl stop srv-data.mount")
assert "down" in machine.succeed("nixos-container status require-bind-mounts")
assert "inactive" in machine.fail("systemctl is-active srv-data.mount")
-
- with subtest("bind mount host paths must be mounted to run container"):
- machine.succeed("nixos-container start require-bind-mounts")
- assert "up" in machine.succeed("nixos-container status require-bind-mounts")
- assert "active" in machine.succeed("systemctl status srv-data.mount")
-
- machine.succeed("systemctl stop srv-data.mount")
- assert "down" in machine.succeed("nixos-container status require-bind-mounts")
- assert "inactive" in machine.fail("systemctl is-active srv-data.mount")
- '';
- }
-)
+ '';
+}
diff --git a/nixos/tests/containers-restart_networking.nix b/nixos/tests/containers-restart_networking.nix
index d0d77031ea4b..8ce524a3e91c 100644
--- a/nixos/tests/containers-restart_networking.nix
+++ b/nixos/tests/containers-restart_networking.nix
@@ -1,131 +1,129 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-restart_networking";
- meta = {
- maintainers = with lib.maintainers; [ kampfschlaefer ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-restart_networking";
+ meta = {
+ maintainers = with lib.maintainers; [ kampfschlaefer ];
+ };
- nodes = {
- client = {
- virtualisation.vlans = [ 1 ];
+ nodes = {
+ client = {
+ virtualisation.vlans = [ 1 ];
- networking.firewall.enable = false;
+ networking.firewall.enable = false;
- containers.webserver = {
- autoStart = true;
- privateNetwork = true;
- hostBridge = "br0";
- config = {
- networking.firewall.enable = false;
- networking.interfaces.eth0.ipv4.addresses = [
- {
- address = "192.168.1.122";
- prefixLength = 24;
- }
- ];
- };
+ containers.webserver = {
+ autoStart = true;
+ privateNetwork = true;
+ hostBridge = "br0";
+ config = {
+ networking.firewall.enable = false;
+ networking.interfaces.eth0.ipv4.addresses = [
+ {
+ address = "192.168.1.122";
+ prefixLength = 24;
+ }
+ ];
};
+ };
+ networking.bridges.br0 = {
+ interfaces = [ ];
+ rstp = false;
+ };
+
+ networking.interfaces.br0.ipv4.addresses = [
+ {
+ address = "192.168.1.1";
+ prefixLength = 24;
+ }
+ ];
+
+ networking.interfaces.eth1 = {
+ ipv4.addresses = lib.mkForce [ ];
+ ipv6.addresses = lib.mkForce [ ];
+ };
+
+ specialisation.eth1.configuration = {
+ networking.bridges.br0.interfaces = [ "eth1" ];
+ networking.interfaces = {
+ eth1.ipv4.addresses = lib.mkForce [ ];
+ eth1.ipv6.addresses = lib.mkForce [ ];
+ br0.ipv4.addresses = [
+ {
+ address = "192.168.1.2";
+ prefixLength = 24;
+ }
+ ];
+ };
+ };
+
+ specialisation.eth1-rstp.configuration = {
networking.bridges.br0 = {
- interfaces = [ ];
- rstp = false;
+ interfaces = [ "eth1" ];
+ rstp = lib.mkForce true;
};
- networking.interfaces.br0.ipv4.addresses = [
- {
- address = "192.168.1.1";
- prefixLength = 24;
- }
- ];
-
- networking.interfaces.eth1 = {
- ipv4.addresses = lib.mkForce [ ];
- ipv6.addresses = lib.mkForce [ ];
- };
-
- specialisation.eth1.configuration = {
- networking.bridges.br0.interfaces = [ "eth1" ];
- networking.interfaces = {
- eth1.ipv4.addresses = lib.mkForce [ ];
- eth1.ipv6.addresses = lib.mkForce [ ];
- br0.ipv4.addresses = [
- {
- address = "192.168.1.2";
- prefixLength = 24;
- }
- ];
- };
- };
-
- specialisation.eth1-rstp.configuration = {
- networking.bridges.br0 = {
- interfaces = [ "eth1" ];
- rstp = lib.mkForce true;
- };
-
- networking.interfaces = {
- eth1.ipv4.addresses = lib.mkForce [ ];
- eth1.ipv6.addresses = lib.mkForce [ ];
- br0.ipv4.addresses = [
- {
- address = "192.168.1.2";
- prefixLength = 24;
- }
- ];
- };
+ networking.interfaces = {
+ eth1.ipv4.addresses = lib.mkForce [ ];
+ eth1.ipv6.addresses = lib.mkForce [ ];
+ br0.ipv4.addresses = [
+ {
+ address = "192.168.1.2";
+ prefixLength = 24;
+ }
+ ];
};
};
};
+ };
- testScript = ''
- client.start()
+ testScript = ''
+ client.start()
- client.wait_for_unit("default.target")
+ client.wait_for_unit("default.target")
- with subtest("Initial configuration connectivity check"):
- client.succeed("ping 192.168.1.122 -c 1 -n >&2")
- client.succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2")
+ with subtest("Initial configuration connectivity check"):
+ client.succeed("ping 192.168.1.122 -c 1 -n >&2")
+ client.succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2")
- client.fail("ip l show eth1 |grep 'master br0' >&2")
- client.fail("grep eth1 /run/br0.interfaces >&2")
+ client.fail("ip l show eth1 |grep 'master br0' >&2")
+ client.fail("grep eth1 /run/br0.interfaces >&2")
- with subtest("Bridged configuration without STP preserves connectivity"):
- client.succeed(
- "/run/booted-system/specialisation/eth1/bin/switch-to-configuration test >&2"
- )
+ with subtest("Bridged configuration without STP preserves connectivity"):
+ client.succeed(
+ "/run/booted-system/specialisation/eth1/bin/switch-to-configuration test >&2"
+ )
- client.succeed(
- "ping 192.168.1.122 -c 1 -n >&2",
- "nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2",
- "ip l show eth1 |grep 'master br0' >&2",
- "grep eth1 /run/br0.interfaces >&2",
- )
+ client.succeed(
+ "ping 192.168.1.122 -c 1 -n >&2",
+ "nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2",
+ "ip l show eth1 |grep 'master br0' >&2",
+ "grep eth1 /run/br0.interfaces >&2",
+ )
- # activating rstp needs another service, therefore the bridge will restart and the container will lose its connectivity
- # with subtest("Bridged configuration with STP"):
- # client.succeed("/run/booted-system/specialisation/eth1-rstp/bin/switch-to-configuration test >&2")
- # client.execute("ip -4 a >&2")
- # client.execute("ip l >&2")
- #
- # client.succeed(
- # "ping 192.168.1.122 -c 1 -n >&2",
- # "nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2",
- # "ip l show eth1 |grep 'master br0' >&2",
- # "grep eth1 /run/br0.interfaces >&2",
- # )
+ # activating rstp needs another service, therefore the bridge will restart and the container will lose its connectivity
+ # with subtest("Bridged configuration with STP"):
+ # client.succeed("/run/booted-system/specialisation/eth1-rstp/bin/switch-to-configuration test >&2")
+ # client.execute("ip -4 a >&2")
+ # client.execute("ip l >&2")
+ #
+ # client.succeed(
+ # "ping 192.168.1.122 -c 1 -n >&2",
+ # "nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2",
+ # "ip l show eth1 |grep 'master br0' >&2",
+ # "grep eth1 /run/br0.interfaces >&2",
+ # )
- with subtest("Reverting to initial configuration preserves connectivity"):
- client.succeed(
- "/run/booted-system/bin/switch-to-configuration test >&2"
- )
+ with subtest("Reverting to initial configuration preserves connectivity"):
+ client.succeed(
+ "/run/booted-system/bin/switch-to-configuration test >&2"
+ )
- client.succeed("ping 192.168.1.122 -c 1 -n >&2")
- client.succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2")
+ client.succeed("ping 192.168.1.122 -c 1 -n >&2")
+ client.succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2")
- client.fail("ip l show eth1 |grep 'master br0' >&2")
- client.fail("grep eth1 /run/br0.interfaces >&2")
- '';
+ client.fail("ip l show eth1 |grep 'master br0' >&2")
+ client.fail("grep eth1 /run/br0.interfaces >&2")
+ '';
- }
-)
+}
diff --git a/nixos/tests/containers-tmpfs.nix b/nixos/tests/containers-tmpfs.nix
index 668417df271e..2ac1795cca06 100644
--- a/nixos/tests/containers-tmpfs.nix
+++ b/nixos/tests/containers-tmpfs.nix
@@ -1,93 +1,91 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-tmpfs";
- meta = {
- maintainers = with lib.maintainers; [ patryk27 ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-tmpfs";
+ meta = {
+ maintainers = with lib.maintainers; [ patryk27 ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ../modules/installer/cd-dvd/channel.nix ];
- virtualisation.writableStore = true;
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ../modules/installer/cd-dvd/channel.nix ];
+ virtualisation.writableStore = true;
- containers.tmpfs = {
- autoStart = true;
- tmpfs = [
- # Mount var as a tmpfs
- "/var"
+ containers.tmpfs = {
+ autoStart = true;
+ tmpfs = [
+ # Mount var as a tmpfs
+ "/var"
- # Add a nested mount inside a tmpfs
- "/var/log"
+ # Add a nested mount inside a tmpfs
+ "/var/log"
- # Add a tmpfs on a path that does not exist
- "/some/random/path"
- ];
- config = { };
- };
-
- virtualisation.additionalPaths = [ pkgs.stdenv ];
+ # Add a tmpfs on a path that does not exist
+ "/some/random/path"
+ ];
+ config = { };
};
- testScript = ''
- machine.wait_for_unit("default.target")
- assert "tmpfs" in machine.succeed("nixos-container list")
+ virtualisation.additionalPaths = [ pkgs.stdenv ];
+ };
- with subtest("tmpfs container is up"):
- assert "up" in machine.succeed("nixos-container status tmpfs")
+ testScript = ''
+ machine.wait_for_unit("default.target")
+ assert "tmpfs" in machine.succeed("nixos-container list")
+
+ with subtest("tmpfs container is up"):
+ assert "up" in machine.succeed("nixos-container status tmpfs")
- def tmpfs_cmd(command):
- return f"nixos-container run tmpfs -- {command} 2>/dev/null"
+ def tmpfs_cmd(command):
+ return f"nixos-container run tmpfs -- {command} 2>/dev/null"
- with subtest("/var is mounted as a tmpfs"):
- machine.succeed(tmpfs_cmd("mountpoint -q /var"))
+ with subtest("/var is mounted as a tmpfs"):
+ machine.succeed(tmpfs_cmd("mountpoint -q /var"))
- with subtest("/var/log is mounted as a tmpfs"):
- assert "What: tmpfs" in machine.succeed(
- tmpfs_cmd("systemctl status var-log.mount --no-pager")
- )
- machine.succeed(tmpfs_cmd("mountpoint -q /var/log"))
+ with subtest("/var/log is mounted as a tmpfs"):
+ assert "What: tmpfs" in machine.succeed(
+ tmpfs_cmd("systemctl status var-log.mount --no-pager")
+ )
+ machine.succeed(tmpfs_cmd("mountpoint -q /var/log"))
- with subtest("/some/random/path is mounted as a tmpfs"):
- assert "What: tmpfs" in machine.succeed(
- tmpfs_cmd("systemctl status some-random-path.mount --no-pager")
- )
- machine.succeed(tmpfs_cmd("mountpoint -q /some/random/path"))
+ with subtest("/some/random/path is mounted as a tmpfs"):
+ assert "What: tmpfs" in machine.succeed(
+ tmpfs_cmd("systemctl status some-random-path.mount --no-pager")
+ )
+ machine.succeed(tmpfs_cmd("mountpoint -q /some/random/path"))
- with subtest(
- "files created in the container in a non-tmpfs directory are visible on the host."
- ):
- # This establishes legitimacy for the following tests
- machine.succeed(
- tmpfs_cmd("touch /root/test.file"),
- tmpfs_cmd("ls -l /root | grep -q test.file"),
- "test -e /var/lib/nixos-containers/tmpfs/root/test.file",
- )
+ with subtest(
+ "files created in the container in a non-tmpfs directory are visible on the host."
+ ):
+ # This establishes legitimacy for the following tests
+ machine.succeed(
+ tmpfs_cmd("touch /root/test.file"),
+ tmpfs_cmd("ls -l /root | grep -q test.file"),
+ "test -e /var/lib/nixos-containers/tmpfs/root/test.file",
+ )
- with subtest(
- "/some/random/path is writable and that files created there are not "
- + "in the hosts container dir but in the tmpfs"
- ):
- machine.succeed(
- tmpfs_cmd("touch /some/random/path/test.file"),
- tmpfs_cmd("test -e /some/random/path/test.file"),
- )
- machine.fail("test -e /var/lib/nixos-containers/tmpfs/some/random/path/test.file")
+ with subtest(
+ "/some/random/path is writable and that files created there are not "
+ + "in the hosts container dir but in the tmpfs"
+ ):
+ machine.succeed(
+ tmpfs_cmd("touch /some/random/path/test.file"),
+ tmpfs_cmd("test -e /some/random/path/test.file"),
+ )
+ machine.fail("test -e /var/lib/nixos-containers/tmpfs/some/random/path/test.file")
- with subtest(
- "files created in the hosts container dir in a path where a tmpfs "
- + "file system has been mounted are not visible to the container as "
- + "the do not exist in the tmpfs"
- ):
- machine.succeed(
- "touch /var/lib/nixos-containers/tmpfs/var/test.file",
- "test -e /var/lib/nixos-containers/tmpfs/var/test.file",
- "ls -l /var/lib/nixos-containers/tmpfs/var/ | grep -q test.file 2>/dev/null",
- )
- machine.fail(tmpfs_cmd("ls -l /var | grep -q test.file"))
- '';
- }
-)
+ with subtest(
+ "files created in the hosts container dir in a path where a tmpfs "
+ + "file system has been mounted are not visible to the container as "
+ + "the do not exist in the tmpfs"
+ ):
+ machine.succeed(
+ "touch /var/lib/nixos-containers/tmpfs/var/test.file",
+ "test -e /var/lib/nixos-containers/tmpfs/var/test.file",
+ "ls -l /var/lib/nixos-containers/tmpfs/var/ | grep -q test.file 2>/dev/null",
+ )
+ machine.fail(tmpfs_cmd("ls -l /var | grep -q test.file"))
+ '';
+}
diff --git a/nixos/tests/containers-unified-hierarchy.nix b/nixos/tests/containers-unified-hierarchy.nix
index 5ea89d96dcfe..417f68d0d31d 100644
--- a/nixos/tests/containers-unified-hierarchy.nix
+++ b/nixos/tests/containers-unified-hierarchy.nix
@@ -1,26 +1,24 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "containers-unified-hierarchy";
- meta = {
- maintainers = with lib.maintainers; [ farnoy ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "containers-unified-hierarchy";
+ meta = {
+ maintainers = with lib.maintainers; [ farnoy ];
+ };
- nodes.machine =
- { ... }:
- {
- containers = {
- test-container = {
- autoStart = true;
- config = { };
- };
+ nodes.machine =
+ { ... }:
+ {
+ containers = {
+ test-container = {
+ autoStart = true;
+ config = { };
};
};
+ };
- testScript = ''
- machine.wait_for_unit("default.target")
+ testScript = ''
+ machine.wait_for_unit("default.target")
- machine.succeed("echo 'stat -fc %T /sys/fs/cgroup/ | grep cgroup2fs' | nixos-container root-login test-container")
- '';
- }
-)
+ machine.succeed("echo 'stat -fc %T /sys/fs/cgroup/ | grep cgroup2fs' | nixos-container root-login test-container")
+ '';
+}
diff --git a/nixos/tests/convos.nix b/nixos/tests/convos.nix
index f92ab49a2988..fd0588290950 100644
--- a/nixos/tests/convos.nix
+++ b/nixos/tests/convos.nix
@@ -1,28 +1,26 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- let
- port = 3333;
- in
- {
- name = "convos";
- meta.maintainers = with lib.maintainers; [ sgo ];
+let
+ port = 3333;
+in
+{
+ name = "convos";
+ meta.maintainers = with lib.maintainers; [ sgo ];
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.convos = {
- enable = true;
- listenPort = port;
- };
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.convos = {
+ enable = true;
+ listenPort = port;
};
- };
+ };
+ };
- testScript = ''
- machine.wait_for_unit("convos")
- machine.wait_for_open_port(${toString port})
- machine.succeed("curl -f http://localhost:${toString port}/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("convos")
+ machine.wait_for_open_port(${toString port})
+ machine.succeed("curl -f http://localhost:${toString port}/")
+ '';
+}
diff --git a/nixos/tests/coturn.nix b/nixos/tests/coturn.nix
index e090b45d4af6..8366ceb0045e 100644
--- a/nixos/tests/coturn.nix
+++ b/nixos/tests/coturn.nix
@@ -1,38 +1,36 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "coturn";
- nodes = {
- default = {
- services.coturn.enable = true;
- };
- secretsfile = {
- boot.postBootCommands = ''
- echo "some-very-secret-string" > /run/coturn-secret
- '';
- services.coturn = {
- enable = true;
- static-auth-secret-file = "/run/coturn-secret";
- };
+{ pkgs, ... }:
+{
+ name = "coturn";
+ nodes = {
+ default = {
+ services.coturn.enable = true;
+ };
+ secretsfile = {
+ boot.postBootCommands = ''
+ echo "some-very-secret-string" > /run/coturn-secret
+ '';
+ services.coturn = {
+ enable = true;
+ static-auth-secret-file = "/run/coturn-secret";
};
};
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- with subtest("by default works without configuration"):
- default.wait_for_unit("coturn.service")
+ with subtest("by default works without configuration"):
+ default.wait_for_unit("coturn.service")
- with subtest("works with static-auth-secret-file"):
- secretsfile.wait_for_unit("coturn.service")
- secretsfile.wait_for_open_port(3478)
- secretsfile.succeed("grep 'some-very-secret-string' /run/coturn/turnserver.cfg")
- # Forbidden IP, fails:
- secretsfile.fail("${pkgs.coturn}/bin/turnutils_uclient -W some-very-secret-string 127.0.0.1 -DgX -e 127.0.0.1 -n 1 -c -y")
- # allowed-peer-ip, should succeed:
- secretsfile.succeed("${pkgs.coturn}/bin/turnutils_uclient -W some-very-secret-string 192.168.1.2 -DgX -e 192.168.1.2 -n 1 -c -y")
+ with subtest("works with static-auth-secret-file"):
+ secretsfile.wait_for_unit("coturn.service")
+ secretsfile.wait_for_open_port(3478)
+ secretsfile.succeed("grep 'some-very-secret-string' /run/coturn/turnserver.cfg")
+ # Forbidden IP, fails:
+ secretsfile.fail("${pkgs.coturn}/bin/turnutils_uclient -W some-very-secret-string 127.0.0.1 -DgX -e 127.0.0.1 -n 1 -c -y")
+ # allowed-peer-ip, should succeed:
+ secretsfile.succeed("${pkgs.coturn}/bin/turnutils_uclient -W some-very-secret-string 192.168.1.2 -DgX -e 192.168.1.2 -n 1 -c -y")
- default.log(default.execute("systemd-analyze security coturn.service | grep -v '✓'")[1])
- '';
- }
-)
+ default.log(default.execute("systemd-analyze security coturn.service | grep -v '✓'")[1])
+ '';
+}
diff --git a/nixos/tests/couchdb.nix b/nixos/tests/couchdb.nix
index a3945915f98b..d11176bdd311 100644
--- a/nixos/tests/couchdb.nix
+++ b/nixos/tests/couchdb.nix
@@ -14,51 +14,49 @@ let
testpass = "cowabunga";
testlogin = "${testuser}:${testpass}@";
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "couchdb";
- meta.maintainers = [ ];
+{ pkgs, lib, ... }:
+{
+ name = "couchdb";
+ meta.maintainers = [ ];
- nodes = {
- couchdb3 = makeNode pkgs.couchdb3 testuser testpass;
- };
+ nodes = {
+ couchdb3 = makeNode pkgs.couchdb3 testuser testpass;
+ };
- testScript =
- let
- curlJqCheck =
- login: action: path: jqexpr: result:
- pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
- RESULT=$(curl -X ${action} http://${login}127.0.0.1:5984/${path} | jq -r '${jqexpr}')
- echo $RESULT >&2
- if [ "$RESULT" != "${result}" ]; then
- exit 1
- fi
- '';
- in
- ''
- start_all()
+ testScript =
+ let
+ curlJqCheck =
+ login: action: path: jqexpr: result:
+ pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
+ RESULT=$(curl -X ${action} http://${login}127.0.0.1:5984/${path} | jq -r '${jqexpr}')
+ echo $RESULT >&2
+ if [ "$RESULT" != "${result}" ]; then
+ exit 1
+ fi
+ '';
+ in
+ ''
+ start_all()
- couchdb3.wait_for_unit("couchdb.service")
- couchdb3.wait_until_succeeds(
- "${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}"
- )
- couchdb3.wait_until_succeeds(
- "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
- )
- couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
- couchdb3.succeed(
- "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}"
- )
- couchdb3.succeed(
- "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
- )
- couchdb3.succeed(
- "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
- )
- couchdb3.succeed(
- "${curlJqCheck testlogin "GET" "_node/couchdb@127.0.0.1" ".couchdb" "Welcome"}"
- )
- '';
- }
-)
+ couchdb3.wait_for_unit("couchdb.service")
+ couchdb3.wait_until_succeeds(
+ "${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}"
+ )
+ couchdb3.wait_until_succeeds(
+ "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
+ )
+ couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
+ couchdb3.succeed(
+ "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}"
+ )
+ couchdb3.succeed(
+ "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
+ )
+ couchdb3.succeed(
+ "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
+ )
+ couchdb3.succeed(
+ "${curlJqCheck testlogin "GET" "_node/couchdb@127.0.0.1" ".couchdb" "Welcome"}"
+ )
+ '';
+}
diff --git a/nixos/tests/crabfit.nix b/nixos/tests/crabfit.nix
index eb38a0ae0cfc..e22615c5a049 100644
--- a/nixos/tests/crabfit.nix
+++ b/nixos/tests/crabfit.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- {
- name = "crabfit";
+{
+ name = "crabfit";
- meta.maintainers = [ ];
+ meta.maintainers = [ ];
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.crabfit = {
- enable = true;
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.crabfit = {
+ enable = true;
- frontend.host = "http://127.0.0.1:3001";
- api.host = "127.0.0.1:3000";
- };
+ frontend.host = "http://127.0.0.1:3001";
+ api.host = "127.0.0.1:3000";
};
- };
+ };
+ };
- # TODO: Add a reverse proxy and a dns entry for testing
- testScript = ''
- machine.wait_for_unit("crabfit-api")
- machine.wait_for_unit("crabfit-frontend")
+ # TODO: Add a reverse proxy and a dns entry for testing
+ testScript = ''
+ machine.wait_for_unit("crabfit-api")
+ machine.wait_for_unit("crabfit-frontend")
- machine.wait_for_open_port(3000)
- machine.wait_for_open_port(3001)
+ machine.wait_for_open_port(3000)
+ machine.wait_for_open_port(3001)
- machine.succeed("curl -f http://localhost:3001/")
- '';
- }
-)
+ machine.succeed("curl -f http://localhost:3001/")
+ '';
+}
diff --git a/nixos/tests/croc.nix b/nixos/tests/croc.nix
index 4b6d3f4d85a7..296d12c4ebe6 100644
--- a/nixos/tests/croc.nix
+++ b/nixos/tests/croc.nix
@@ -1,59 +1,57 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.croc ];
- };
- pass = "PassRelay";
- in
- {
- name = "croc";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- equirosa
- SuperSandro2000
- ];
+{ pkgs, ... }:
+let
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.croc ];
};
+ pass = "PassRelay";
+in
+{
+ name = "croc";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ equirosa
+ SuperSandro2000
+ ];
+ };
- nodes = {
- relay = {
- services.croc = {
- enable = true;
- pass = pass;
- openFirewall = true;
- };
+ nodes = {
+ relay = {
+ services.croc = {
+ enable = true;
+ pass = pass;
+ openFirewall = true;
};
- sender = client;
- receiver = client;
};
+ sender = client;
+ receiver = client;
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- # wait until relay is up
- relay.wait_for_unit("croc")
- relay.wait_for_open_port(9009)
- relay.wait_for_open_port(9010)
- relay.wait_for_open_port(9011)
- relay.wait_for_open_port(9012)
- relay.wait_for_open_port(9013)
+ # wait until relay is up
+ relay.wait_for_unit("croc")
+ relay.wait_for_open_port(9009)
+ relay.wait_for_open_port(9010)
+ relay.wait_for_open_port(9011)
+ relay.wait_for_open_port(9012)
+ relay.wait_for_open_port(9013)
- # generate testfiles and send them
- sender.wait_for_unit("multi-user.target")
- sender.execute("echo Hello World > testfile01.txt")
- sender.execute("echo Hello Earth > testfile02.txt")
- sender.execute(
- "env CROC_SECRET=topSecret croc --pass ${pass} --relay relay send testfile01.txt testfile02.txt >&2 &"
- )
+ # generate testfiles and send them
+ sender.wait_for_unit("multi-user.target")
+ sender.execute("echo Hello World > testfile01.txt")
+ sender.execute("echo Hello Earth > testfile02.txt")
+ sender.execute(
+ "env CROC_SECRET=topSecret croc --pass ${pass} --relay relay send testfile01.txt testfile02.txt >&2 &"
+ )
- # receive the testfiles and check them
- receiver.succeed(
- "env CROC_SECRET=topSecret croc --pass ${pass} --yes --relay relay"
- )
- assert "Hello World" in receiver.succeed("cat testfile01.txt")
- assert "Hello Earth" in receiver.succeed("cat testfile02.txt")
- '';
- }
-)
+ # receive the testfiles and check them
+ receiver.succeed(
+ "env CROC_SECRET=topSecret croc --pass ${pass} --yes --relay relay"
+ )
+ assert "Hello World" in receiver.succeed("cat testfile01.txt")
+ assert "Hello Earth" in receiver.succeed("cat testfile02.txt")
+ '';
+}
diff --git a/nixos/tests/curl-impersonate.nix b/nixos/tests/curl-impersonate.nix
index 28e741a2e19f..866bd78ce163 100644
--- a/nixos/tests/curl-impersonate.nix
+++ b/nixos/tests/curl-impersonate.nix
@@ -24,182 +24,180 @@
uses upstream for its tests.
*/
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- # Update with domains in TestImpersonate.TEST_URLS if needed from:
- # https://github.com/lwthiker/curl-impersonate/blob/main/tests/test_impersonate.py
- domains = [
- "www.wikimedia.org"
- "www.wikipedia.org"
- "www.mozilla.org"
- "www.apache.org"
- "www.kernel.org"
- "git-scm.com"
- ];
+{ pkgs, lib, ... }:
+let
+ # Update with domains in TestImpersonate.TEST_URLS if needed from:
+ # https://github.com/lwthiker/curl-impersonate/blob/main/tests/test_impersonate.py
+ domains = [
+ "www.wikimedia.org"
+ "www.wikipedia.org"
+ "www.mozilla.org"
+ "www.apache.org"
+ "www.kernel.org"
+ "git-scm.com"
+ ];
- tls-certs =
- let
- # Configure CA with X.509 v3 extensions that would be trusted by curl
- ca-cert-conf = pkgs.writeText "curl-impersonate-ca.cnf" ''
- basicConstraints = critical, CA:TRUE
- subjectKeyIdentifier = hash
- authorityKeyIdentifier = keyid:always, issuer:always
- keyUsage = critical, cRLSign, digitalSignature, keyCertSign
- '';
-
- # Configure leaf certificate with X.509 v3 extensions that would be trusted
- # by curl and set subject-alternative names for test domains
- tls-cert-conf = pkgs.writeText "curl-impersonate-tls.cnf" ''
- basicConstraints = critical, CA:FALSE
- subjectKeyIdentifier = hash
- authorityKeyIdentifier = keyid:always, issuer:always
- keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
- extendedKeyUsage = critical, serverAuth
- subjectAltName = @alt_names
-
- [alt_names]
- ${lib.concatStringsSep "\n" (lib.imap0 (idx: domain: "DNS.${toString idx} = ${domain}") domains)}
- '';
- in
- pkgs.runCommand "curl-impersonate-test-certs"
- {
- nativeBuildInputs = [ pkgs.openssl ];
- }
- ''
- # create CA certificate and key
- openssl req -newkey rsa:4096 -keyout ca-key.pem -out ca-csr.pem -nodes -subj '/CN=curl-impersonate-ca.nixos.test'
- openssl x509 -req -sha512 -in ca-csr.pem -key ca-key.pem -out ca.pem -extfile ${ca-cert-conf} -days 36500
- openssl x509 -in ca.pem -text
-
- # create server certificate and key
- openssl req -newkey rsa:4096 -keyout key.pem -out csr.pem -nodes -subj '/CN=curl-impersonate.nixos.test'
- openssl x509 -req -sha512 -in csr.pem -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile ${tls-cert-conf} -days 36500
- openssl x509 -in cert.pem -text
-
- # output CA cert and server cert and key
- mkdir -p $out
- cp key.pem cert.pem ca.pem $out
- '';
-
- # Test script
- curl-impersonate-test =
- let
- # Build miniature libcurl client used by test driver
- minicurl =
- pkgs.runCommandCC "minicurl"
- {
- buildInputs = [ pkgs.curl ];
- }
- ''
- mkdir -p $out/bin
- $CC -Wall -Werror -o $out/bin/minicurl ${pkgs.curl-impersonate.src}/tests/minicurl.c `curl-config --libs`
- '';
- in
- pkgs.writeShellScript "curl-impersonate-test" ''
- set -euxo pipefail
-
- # Test driver requirements
- export PATH="${
- with pkgs;
- lib.makeBinPath [
- bash
- coreutils
- python3Packages.pytest
- nghttp2
- tcpdump
- ]
- }"
- export PYTHONPATH="${
- with pkgs.python3Packages;
- makePythonPath [
- pyyaml
- pytest-asyncio
- dpkt
- ts1-signatures
- ]
- }"
-
- # Prepare test root prefix
- mkdir -p usr/{bin,lib}
- cp -rs ${pkgs.curl-impersonate}/* ${minicurl}/* usr/
-
- cp -r ${pkgs.curl-impersonate.src}/tests ./
-
- # Run tests
- cd tests
- pytest . --install-dir ../usr --capture-interface eth1 --exitfirst -k 'not test_http2_headers'
+ tls-certs =
+ let
+ # Configure CA with X.509 v3 extensions that would be trusted by curl
+ ca-cert-conf = pkgs.writeText "curl-impersonate-ca.cnf" ''
+ basicConstraints = critical, CA:TRUE
+ subjectKeyIdentifier = hash
+ authorityKeyIdentifier = keyid:always, issuer:always
+ keyUsage = critical, cRLSign, digitalSignature, keyCertSign
'';
- in
- {
- name = "curl-impersonate";
- meta = with lib.maintainers; {
- maintainers = [ ];
- };
+ # Configure leaf certificate with X.509 v3 extensions that would be trusted
+ # by curl and set subject-alternative names for test domains
+ tls-cert-conf = pkgs.writeText "curl-impersonate-tls.cnf" ''
+ basicConstraints = critical, CA:FALSE
+ subjectKeyIdentifier = hash
+ authorityKeyIdentifier = keyid:always, issuer:always
+ keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
+ extendedKeyUsage = critical, serverAuth
+ subjectAltName = @alt_names
- nodes = {
- web =
- {
- nodes,
- pkgs,
- lib,
- config,
- ...
- }:
- {
- networking.firewall.allowedTCPPorts = [
- 80
- 443
- ];
+ [alt_names]
+ ${lib.concatStringsSep "\n" (lib.imap0 (idx: domain: "DNS.${toString idx} = ${domain}") domains)}
+ '';
+ in
+ pkgs.runCommand "curl-impersonate-test-certs"
+ {
+ nativeBuildInputs = [ pkgs.openssl ];
+ }
+ ''
+ # create CA certificate and key
+ openssl req -newkey rsa:4096 -keyout ca-key.pem -out ca-csr.pem -nodes -subj '/CN=curl-impersonate-ca.nixos.test'
+ openssl x509 -req -sha512 -in ca-csr.pem -key ca-key.pem -out ca.pem -extfile ${ca-cert-conf} -days 36500
+ openssl x509 -in ca.pem -text
- services = {
- nginx = {
- enable = true;
- virtualHosts."curl-impersonate.nixos.test" = {
- default = true;
- addSSL = true;
- sslCertificate = "${tls-certs}/cert.pem";
- sslCertificateKey = "${tls-certs}/key.pem";
- };
+ # create server certificate and key
+ openssl req -newkey rsa:4096 -keyout key.pem -out csr.pem -nodes -subj '/CN=curl-impersonate.nixos.test'
+ openssl x509 -req -sha512 -in csr.pem -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile ${tls-cert-conf} -days 36500
+ openssl x509 -in cert.pem -text
+
+ # output CA cert and server cert and key
+ mkdir -p $out
+ cp key.pem cert.pem ca.pem $out
+ '';
+
+ # Test script
+ curl-impersonate-test =
+ let
+ # Build miniature libcurl client used by test driver
+ minicurl =
+ pkgs.runCommandCC "minicurl"
+ {
+ buildInputs = [ pkgs.curl ];
+ }
+ ''
+ mkdir -p $out/bin
+ $CC -Wall -Werror -o $out/bin/minicurl ${pkgs.curl-impersonate.src}/tests/minicurl.c `curl-config --libs`
+ '';
+ in
+ pkgs.writeShellScript "curl-impersonate-test" ''
+ set -euxo pipefail
+
+ # Test driver requirements
+ export PATH="${
+ with pkgs;
+ lib.makeBinPath [
+ bash
+ coreutils
+ python3Packages.pytest
+ nghttp2
+ tcpdump
+ ]
+ }"
+ export PYTHONPATH="${
+ with pkgs.python3Packages;
+ makePythonPath [
+ pyyaml
+ pytest-asyncio
+ dpkt
+ ts1-signatures
+ ]
+ }"
+
+ # Prepare test root prefix
+ mkdir -p usr/{bin,lib}
+ cp -rs ${pkgs.curl-impersonate}/* ${minicurl}/* usr/
+
+ cp -r ${pkgs.curl-impersonate.src}/tests ./
+
+ # Run tests
+ cd tests
+ pytest . --install-dir ../usr --capture-interface eth1 --exitfirst -k 'not test_http2_headers'
+ '';
+in
+{
+ name = "curl-impersonate";
+
+ meta = with lib.maintainers; {
+ maintainers = [ ];
+ };
+
+ nodes = {
+ web =
+ {
+ nodes,
+ pkgs,
+ lib,
+ config,
+ ...
+ }:
+ {
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
+ ];
+
+ services = {
+ nginx = {
+ enable = true;
+ virtualHosts."curl-impersonate.nixos.test" = {
+ default = true;
+ addSSL = true;
+ sslCertificate = "${tls-certs}/cert.pem";
+ sslCertificateKey = "${tls-certs}/key.pem";
};
};
};
+ };
- curl =
- {
- nodes,
- pkgs,
- lib,
- config,
- ...
- }:
- {
- networking.extraHosts = lib.concatStringsSep "\n" (
- map (domain: "${nodes.web.networking.primaryIPAddress} ${domain}") domains
- );
+ curl =
+ {
+ nodes,
+ pkgs,
+ lib,
+ config,
+ ...
+ }:
+ {
+ networking.extraHosts = lib.concatStringsSep "\n" (
+ map (domain: "${nodes.web.networking.primaryIPAddress} ${domain}") domains
+ );
- security.pki.certificateFiles = [ "${tls-certs}/ca.pem" ];
- };
- };
+ security.pki.certificateFiles = [ "${tls-certs}/ca.pem" ];
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- start_all()
+ testScript =
+ { nodes, ... }:
+ ''
+ start_all()
- with subtest("Wait for network"):
- web.systemctl("start network-online.target")
- curl.systemctl("start network-online.target")
- web.wait_for_unit("network-online.target")
- curl.wait_for_unit("network-online.target")
+ with subtest("Wait for network"):
+ web.systemctl("start network-online.target")
+ curl.systemctl("start network-online.target")
+ web.wait_for_unit("network-online.target")
+ curl.wait_for_unit("network-online.target")
- with subtest("Wait for web server"):
- web.wait_for_unit("nginx.service")
- web.wait_for_open_port(443)
+ with subtest("Wait for web server"):
+ web.wait_for_unit("nginx.service")
+ web.wait_for_open_port(443)
- with subtest("Run curl-impersonate tests"):
- curl.succeed("${curl-impersonate-test}")
- '';
- }
-)
+ with subtest("Run curl-impersonate tests"):
+ curl.succeed("${curl-impersonate-test}")
+ '';
+}
diff --git a/nixos/tests/dae.nix b/nixos/tests/dae.nix
index 127bbcb78813..f3e4edaf8f94 100644
--- a/nixos/tests/dae.nix
+++ b/nixos/tests/dae.nix
@@ -1,38 +1,36 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
+{ lib, pkgs, ... }:
+{
- name = "dae";
+ name = "dae";
- meta = {
- maintainers = with lib.maintainers; [ oluceps ];
+ meta = {
+ maintainers = with lib.maintainers; [ oluceps ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.curl ];
+ services.nginx = {
+ enable = true;
+ statusPage = true;
+ };
+ services.dae = {
+ enable = true;
+ config = ''
+ global { disable_waiting_network: true }
+ routing{}
+ '';
+ };
};
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.curl ];
- services.nginx = {
- enable = true;
- statusPage = true;
- };
- services.dae = {
- enable = true;
- config = ''
- global { disable_waiting_network: true }
- routing{}
- '';
- };
- };
+ testScript = ''
+ machine.wait_for_unit("nginx.service")
+ machine.wait_for_unit("dae.service")
- testScript = ''
- machine.wait_for_unit("nginx.service")
- machine.wait_for_unit("dae.service")
+ machine.wait_for_open_port(80)
- machine.wait_for_open_port(80)
+ machine.succeed("curl --fail --max-time 10 http://localhost")
+ '';
- machine.succeed("curl --fail --max-time 10 http://localhost")
- '';
-
- }
-)
+}
diff --git a/nixos/tests/db-rest.nix b/nixos/tests/db-rest.nix
index 18843f330837..9d6cb251a45b 100644
--- a/nixos/tests/db-rest.nix
+++ b/nixos/tests/db-rest.nix
@@ -1,125 +1,123 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "db-rest";
- meta.maintainers = with pkgs.lib.maintainers; [ marie ];
+{ pkgs, ... }:
+{
+ name = "db-rest";
+ meta.maintainers = with pkgs.lib.maintainers; [ marie ];
- nodes = {
- database = {
- networking = {
- interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.2.10";
- prefixLength = 24;
- }
- ];
- };
- firewall.allowedTCPPorts = [ 31638 ];
- };
-
- services.redis.servers.db-rest = {
- enable = true;
- bind = "0.0.0.0";
- requirePass = "choochoo";
- port = 31638;
+ nodes = {
+ database = {
+ networking = {
+ interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.2.10";
+ prefixLength = 24;
+ }
+ ];
};
+ firewall.allowedTCPPorts = [ 31638 ];
};
- serverWithTcp =
- { pkgs, ... }:
- {
- environment = {
- etc = {
- "db-rest/password-redis-db".text = ''
- choochoo
- '';
- };
- };
-
- networking = {
- interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.2.11";
- prefixLength = 24;
- }
- ];
- };
- firewall.allowedTCPPorts = [ 3000 ];
- };
-
- services.db-rest = {
- enable = true;
- host = "0.0.0.0";
- redis = {
- enable = true;
- createLocally = false;
- host = "192.168.2.10";
- port = 31638;
- passwordFile = "/etc/db-rest/password-redis-db";
- useSSL = false;
- };
- };
- };
-
- serverWithUnixSocket =
- { pkgs, ... }:
- {
- networking = {
- interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.2.12";
- prefixLength = 24;
- }
- ];
- };
- firewall.allowedTCPPorts = [ 3000 ];
- };
-
- services.db-rest = {
- enable = true;
- host = "0.0.0.0";
- redis = {
- enable = true;
- createLocally = true;
- };
- };
- };
-
- client = {
- environment.systemPackages = [ pkgs.jq ];
- networking = {
- interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.2.13";
- prefixLength = 24;
- }
- ];
- };
- };
+ services.redis.servers.db-rest = {
+ enable = true;
+ bind = "0.0.0.0";
+ requirePass = "choochoo";
+ port = 31638;
};
};
- testScript = ''
- start_all()
+ serverWithTcp =
+ { pkgs, ... }:
+ {
+ environment = {
+ etc = {
+ "db-rest/password-redis-db".text = ''
+ choochoo
+ '';
+ };
+ };
- with subtest("db-rest redis with TCP socket"):
- database.wait_for_unit("redis-db-rest.service")
- database.wait_for_open_port(31638)
+ networking = {
+ interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.2.11";
+ prefixLength = 24;
+ }
+ ];
+ };
+ firewall.allowedTCPPorts = [ 3000 ];
+ };
- serverWithTcp.wait_for_unit("db-rest.service")
- serverWithTcp.wait_for_open_port(3000)
+ services.db-rest = {
+ enable = true;
+ host = "0.0.0.0";
+ redis = {
+ enable = true;
+ createLocally = false;
+ host = "192.168.2.10";
+ port = 31638;
+ passwordFile = "/etc/db-rest/password-redis-db";
+ useSSL = false;
+ };
+ };
+ };
- client.succeed("curl --fail --get http://192.168.2.11:3000/stations --data-urlencode 'query=Köln Hbf' | jq -r '.\"8000207\".name' | grep 'Köln Hbf'")
+ serverWithUnixSocket =
+ { pkgs, ... }:
+ {
+ networking = {
+ interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.2.12";
+ prefixLength = 24;
+ }
+ ];
+ };
+ firewall.allowedTCPPorts = [ 3000 ];
+ };
- with subtest("db-rest redis with Unix socket"):
- serverWithUnixSocket.wait_for_unit("db-rest.service")
- serverWithUnixSocket.wait_for_open_port(3000)
+ services.db-rest = {
+ enable = true;
+ host = "0.0.0.0";
+ redis = {
+ enable = true;
+ createLocally = true;
+ };
+ };
+ };
- client.succeed("curl --fail --get http://192.168.2.12:3000/stations --data-urlencode 'query=Köln Hbf' | jq -r '.\"8000207\".name' | grep 'Köln Hbf'")
- '';
- }
-)
+ client = {
+ environment.systemPackages = [ pkgs.jq ];
+ networking = {
+ interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.2.13";
+ prefixLength = 24;
+ }
+ ];
+ };
+ };
+ };
+ };
+
+ testScript = ''
+ start_all()
+
+ with subtest("db-rest redis with TCP socket"):
+ database.wait_for_unit("redis-db-rest.service")
+ database.wait_for_open_port(31638)
+
+ serverWithTcp.wait_for_unit("db-rest.service")
+ serverWithTcp.wait_for_open_port(3000)
+
+ client.succeed("curl --fail --get http://192.168.2.11:3000/stations --data-urlencode 'query=Köln Hbf' | jq -r '.\"8000207\".name' | grep 'Köln Hbf'")
+
+ with subtest("db-rest redis with Unix socket"):
+ serverWithUnixSocket.wait_for_unit("db-rest.service")
+ serverWithUnixSocket.wait_for_open_port(3000)
+
+ client.succeed("curl --fail --get http://192.168.2.12:3000/stations --data-urlencode 'query=Köln Hbf' | jq -r '.\"8000207\".name' | grep 'Köln Hbf'")
+ '';
+}
diff --git a/nixos/tests/dconf.nix b/nixos/tests/dconf.nix
index 933817917104..195c56702e2b 100644
--- a/nixos/tests/dconf.nix
+++ b/nixos/tests/dconf.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "dconf";
+{ lib, ... }:
+{
+ name = "dconf";
- meta.maintainers = with lib.maintainers; [
- linsui
- ];
+ meta.maintainers = with lib.maintainers; [
+ linsui
+ ];
- nodes.machine =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- users.extraUsers.alice = {
- isNormalUser = true;
- };
- programs.dconf = with lib.gvariant; {
- enable = true;
- profiles.user.databases = [
- {
- settings = {
- "test/not".locked = mkInt32 1;
- "test/is".locked = "locked";
- };
- locks = [
- "/test/is/locked"
- ];
- }
- ];
- };
+ nodes.machine =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ users.extraUsers.alice = {
+ isNormalUser = true;
};
+ programs.dconf = with lib.gvariant; {
+ enable = true;
+ profiles.user.databases = [
+ {
+ settings = {
+ "test/not".locked = mkInt32 1;
+ "test/is".locked = "locked";
+ };
+ locks = [
+ "/test/is/locked"
+ ];
+ }
+ ];
+ };
+ };
- testScript = ''
- machine.succeed("test $(dconf read -d /test/not/locked) == 1")
- machine.succeed("test $(dconf read -d /test/is/locked) == \"'locked'\"")
- machine.fail("sudo -u alice dbus-run-session -- dconf write /test/is/locked \"@s 'unlocked'\"")
- machine.succeed("sudo -u alice dbus-run-session -- dconf write /test/not/locked \"@i 2\"")
- '';
- }
-)
+ testScript = ''
+ machine.succeed("test $(dconf read -d /test/not/locked) == 1")
+ machine.succeed("test $(dconf read -d /test/is/locked) == \"'locked'\"")
+ machine.fail("sudo -u alice dbus-run-session -- dconf write /test/is/locked \"@s 'unlocked'\"")
+ machine.succeed("sudo -u alice dbus-run-session -- dconf write /test/not/locked \"@i 2\"")
+ '';
+}
diff --git a/nixos/tests/ddns-updater.nix b/nixos/tests/ddns-updater.nix
index caa763e09bba..95e5953e6a11 100644
--- a/nixos/tests/ddns-updater.nix
+++ b/nixos/tests/ddns-updater.nix
@@ -1,28 +1,26 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- port = 6000;
- in
- {
- name = "ddns-updater";
+{ pkgs, lib, ... }:
+let
+ port = 6000;
+in
+{
+ name = "ddns-updater";
- meta.maintainers = with lib.maintainers; [ delliott ];
+ meta.maintainers = with lib.maintainers; [ delliott ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.ddns-updater = {
- enable = true;
- environment = {
- LISTENING_ADDRESS = ":" + (toString port);
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.ddns-updater = {
+ enable = true;
+ environment = {
+ LISTENING_ADDRESS = ":" + (toString port);
};
};
+ };
- testScript = ''
- machine.wait_for_unit("ddns-updater.service")
- machine.wait_for_open_port(${toString port})
- machine.succeed("curl --fail http://localhost:${toString port}/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("ddns-updater.service")
+ machine.wait_for_open_port(${toString port})
+ machine.succeed("curl --fail http://localhost:${toString port}/")
+ '';
+}
diff --git a/nixos/tests/deconz.nix b/nixos/tests/deconz.nix
index ceeabb6c261a..ea0e19a74683 100644
--- a/nixos/tests/deconz.nix
+++ b/nixos/tests/deconz.nix
@@ -1,37 +1,35 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- httpPort = 800;
- in
- {
- name = "deconz";
+{ pkgs, lib, ... }:
+let
+ httpPort = 800;
+in
+{
+ name = "deconz";
- meta.maintainers = with lib.maintainers; [
- bjornfor
- ];
+ meta.maintainers = with lib.maintainers; [
+ bjornfor
+ ];
- nodes.machine =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- nixpkgs.config.allowUnfree = true;
- services.deconz = {
- enable = true;
- inherit httpPort;
- extraArgs = [
- "--dbg-err=2"
- "--dbg-info=2"
- ];
- };
+ nodes.machine =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ nixpkgs.config.allowUnfree = true;
+ services.deconz = {
+ enable = true;
+ inherit httpPort;
+ extraArgs = [
+ "--dbg-err=2"
+ "--dbg-info=2"
+ ];
};
+ };
- testScript = ''
- machine.wait_for_unit("deconz.service")
- machine.succeed("curl -sfL http://localhost:${toString httpPort}")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("deconz.service")
+ machine.succeed("curl -sfL http://localhost:${toString httpPort}")
+ '';
+}
diff --git a/nixos/tests/deepin.nix b/nixos/tests/deepin.nix
index bf545c08f886..677e58942079 100644
--- a/nixos/tests/deepin.nix
+++ b/nixos/tests/deepin.nix
@@ -1,57 +1,55 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "deepin";
+{ pkgs, lib, ... }:
+{
+ name = "deepin";
- meta.maintainers = lib.teams.deepin.members;
+ meta.maintainers = lib.teams.deepin.members;
- nodes.machine =
- { ... }:
- {
- imports = [
- ./common/user-account.nix
- ];
+ nodes.machine =
+ { ... }:
+ {
+ imports = [
+ ./common/user-account.nix
+ ];
- virtualisation.memorySize = 2048;
+ virtualisation.memorySize = 2048;
- services.xserver.enable = true;
+ services.xserver.enable = true;
- services.xserver.displayManager = {
- lightdm.enable = true;
- autoLogin = {
- enable = true;
- user = "alice";
- };
+ services.xserver.displayManager = {
+ lightdm.enable = true;
+ autoLogin = {
+ enable = true;
+ user = "alice";
};
-
- services.xserver.desktopManager.deepin.enable = true;
};
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
- ''
- with subtest("Wait for login"):
- machine.wait_for_x()
- machine.wait_for_file("${user.home}/.Xauthority")
- machine.succeed("xauth merge ${user.home}/.Xauthority")
+ services.xserver.desktopManager.deepin.enable = true;
+ };
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
+ ''
+ with subtest("Wait for login"):
+ machine.wait_for_x()
+ machine.wait_for_file("${user.home}/.Xauthority")
+ machine.succeed("xauth merge ${user.home}/.Xauthority")
- with subtest("Check if Deepin session components actually start"):
- machine.wait_until_succeeds("pgrep -f dde-session-daemon")
- machine.wait_for_window("dde-session-daemon")
- machine.wait_until_succeeds("pgrep -f dde-desktop")
- machine.wait_for_window("dde-desktop")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Open deepin-terminal"):
- machine.succeed("su - ${user.name} -c 'DISPLAY=:0 deepin-terminal >&2 &'")
- machine.wait_for_window("deepin-terminal")
- machine.sleep(20)
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Check if Deepin session components actually start"):
+ machine.wait_until_succeeds("pgrep -f dde-session-daemon")
+ machine.wait_for_window("dde-session-daemon")
+ machine.wait_until_succeeds("pgrep -f dde-desktop")
+ machine.wait_for_window("dde-desktop")
+
+ with subtest("Open deepin-terminal"):
+ machine.succeed("su - ${user.name} -c 'DISPLAY=:0 deepin-terminal >&2 &'")
+ machine.wait_for_window("deepin-terminal")
+ machine.sleep(20)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/deluge.nix b/nixos/tests/deluge.nix
index 58763bab5345..b7385608a86c 100644
--- a/nixos/tests/deluge.nix
+++ b/nixos/tests/deluge.nix
@@ -1,69 +1,67 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "deluge";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ flokli ];
- };
+{ pkgs, ... }:
+{
+ name = "deluge";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ flokli ];
+ };
- nodes = {
- simple = {
- services.deluge = {
+ nodes = {
+ simple = {
+ services.deluge = {
+ enable = true;
+ package = pkgs.deluge-2_x;
+ web = {
enable = true;
- package = pkgs.deluge-2_x;
- web = {
- enable = true;
- openFirewall = true;
- };
- };
- };
-
- declarative = {
- services.deluge = {
- enable = true;
- package = pkgs.deluge-2_x;
openFirewall = true;
- declarative = true;
- config = {
- allow_remote = true;
- download_location = "/var/lib/deluge/my-download";
- daemon_port = 58846;
- listen_ports = [
- 6881
- 6889
- ];
- };
- web = {
- enable = true;
- port = 3142;
- };
- authFile = pkgs.writeText "deluge-auth" ''
- localclient:a7bef72a890:10
- andrew:password:10
- user3:anotherpass:5
- '';
};
};
-
};
- testScript = ''
- start_all()
+ declarative = {
+ services.deluge = {
+ enable = true;
+ package = pkgs.deluge-2_x;
+ openFirewall = true;
+ declarative = true;
+ config = {
+ allow_remote = true;
+ download_location = "/var/lib/deluge/my-download";
+ daemon_port = 58846;
+ listen_ports = [
+ 6881
+ 6889
+ ];
+ };
+ web = {
+ enable = true;
+ port = 3142;
+ };
+ authFile = pkgs.writeText "deluge-auth" ''
+ localclient:a7bef72a890:10
+ andrew:password:10
+ user3:anotherpass:5
+ '';
+ };
+ };
- simple.wait_for_unit("deluged")
- simple.wait_for_unit("delugeweb")
- simple.wait_for_open_port(8112)
- declarative.wait_for_unit("network.target")
- declarative.wait_until_succeeds("curl --fail http://simple:8112")
+ };
- declarative.wait_for_unit("deluged")
- declarative.wait_for_unit("delugeweb")
- declarative.wait_until_succeeds("curl --fail http://declarative:3142")
+ testScript = ''
+ start_all()
- # deluge-console always exits with 1. https://dev.deluge-torrent.org/ticket/3291
- declarative.succeed(
- "(deluge-console 'connect 127.0.0.1:58846 andrew password; help' || true) | grep -q 'rm.*Remove a torrent'"
- )
- '';
- }
-)
+ simple.wait_for_unit("deluged")
+ simple.wait_for_unit("delugeweb")
+ simple.wait_for_open_port(8112)
+ declarative.wait_for_unit("network.target")
+ declarative.wait_until_succeeds("curl --fail http://simple:8112")
+
+ declarative.wait_for_unit("deluged")
+ declarative.wait_for_unit("delugeweb")
+ declarative.wait_until_succeeds("curl --fail http://declarative:3142")
+
+ # deluge-console always exits with 1. https://dev.deluge-torrent.org/ticket/3291
+ declarative.succeed(
+ "(deluge-console 'connect 127.0.0.1:58846 andrew password; help' || true) | grep -q 'rm.*Remove a torrent'"
+ )
+ '';
+}
diff --git a/nixos/tests/dependency-track.nix b/nixos/tests/dependency-track.nix
index baa55e779058..4039339ff8cd 100644
--- a/nixos/tests/dependency-track.nix
+++ b/nixos/tests/dependency-track.nix
@@ -1,71 +1,69 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- dependencyTrackPort = 8081;
- in
- {
- name = "dependency-track";
- meta = {
- maintainers = pkgs.lib.teams.cyberus.members;
- };
+{ pkgs, ... }:
+let
+ dependencyTrackPort = 8081;
+in
+{
+ name = "dependency-track";
+ meta = {
+ maintainers = pkgs.lib.teams.cyberus.members;
+ };
- nodes = {
- server =
- { pkgs, ... }:
- {
- virtualisation = {
- cores = 2;
- diskSize = 4096;
- memorySize = 1024 * 2;
- };
-
- environment.systemPackages = with pkgs; [ curl ];
- systemd.services.dependency-track = {
- # source: https://github.com/DependencyTrack/dependency-track/blob/37e0ba59e8057c18a87a7a76e247a8f75677a56c/dev/scripts/data-nist-generate-dummy.sh
- preStart = ''
- set -euo pipefail
-
- NIST_DIR="$HOME/.dependency-track/nist"
-
- rm -rf "$NIST_DIR"
- mkdir -p "$NIST_DIR"
-
- for feed in $(seq "2024" "2002"); do
- touch "$NIST_DIR/nvdcve-1.1-$feed.json.gz"
- echo "9999999999999" > "$NIST_DIR/nvdcve-1.1-$feed.json.gz.ts"
- done
- '';
- };
- services.dependency-track = {
- enable = true;
- port = dependencyTrackPort;
- nginx.domain = "localhost";
- database.passwordFile = "${pkgs.writeText "dbPassword" ''hunter2'THE'''H''''E''}";
- };
+ nodes = {
+ server =
+ { pkgs, ... }:
+ {
+ virtualisation = {
+ cores = 2;
+ diskSize = 4096;
+ memorySize = 1024 * 2;
};
- };
- testScript =
- # python
- ''
- import json
+ environment.systemPackages = with pkgs; [ curl ];
+ systemd.services.dependency-track = {
+ # source: https://github.com/DependencyTrack/dependency-track/blob/37e0ba59e8057c18a87a7a76e247a8f75677a56c/dev/scripts/data-nist-generate-dummy.sh
+ preStart = ''
+ set -euo pipefail
- start_all()
+ NIST_DIR="$HOME/.dependency-track/nist"
- server.wait_for_unit("dependency-track.service")
- server.wait_until_succeeds(
- "journalctl -o cat -u dependency-track.service | grep 'Dependency-Track is ready'"
+ rm -rf "$NIST_DIR"
+ mkdir -p "$NIST_DIR"
+
+ for feed in $(seq "2024" "2002"); do
+ touch "$NIST_DIR/nvdcve-1.1-$feed.json.gz"
+ echo "9999999999999" > "$NIST_DIR/nvdcve-1.1-$feed.json.gz.ts"
+ done
+ '';
+ };
+ services.dependency-track = {
+ enable = true;
+ port = dependencyTrackPort;
+ nginx.domain = "localhost";
+ database.passwordFile = "${pkgs.writeText "dbPassword" ''hunter2'THE'''H''''E''}";
+ };
+ };
+ };
+
+ testScript =
+ # python
+ ''
+ import json
+
+ start_all()
+
+ server.wait_for_unit("dependency-track.service")
+ server.wait_until_succeeds(
+ "journalctl -o cat -u dependency-track.service | grep 'Dependency-Track is ready'"
+ )
+ server.wait_for_open_port(${toString dependencyTrackPort})
+
+ with subtest("version api returns correct version"):
+ version = json.loads(
+ server.succeed("curl http://localhost/api/version")
)
- server.wait_for_open_port(${toString dependencyTrackPort})
+ assert version["version"] == "${pkgs.dependency-track.version}"
- with subtest("version api returns correct version"):
- version = json.loads(
- server.succeed("curl http://localhost/api/version")
- )
- assert version["version"] == "${pkgs.dependency-track.version}"
-
- with subtest("nginx serves frontend"):
- server.succeed("curl http://localhost/ | grep \"Dependency-Track\"")
- '';
- }
-)
+ with subtest("nginx serves frontend"):
+ server.succeed("curl http://localhost/ | grep \"Dependency-Track\"")
+ '';
+}
diff --git a/nixos/tests/devpi-server.nix b/nixos/tests/devpi-server.nix
index cec019e9d1c4..723499941654 100644
--- a/nixos/tests/devpi-server.nix
+++ b/nixos/tests/devpi-server.nix
@@ -1,43 +1,41 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- server-port = 3141;
- in
- {
- name = "devpi-server";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ cafkafk ];
- };
+{ pkgs, ... }:
+let
+ server-port = 3141;
+in
+{
+ name = "devpi-server";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ cafkafk ];
+ };
- nodes = {
- devpi =
- { ... }:
- {
- services.devpi-server = {
- enable = true;
- host = "0.0.0.0";
- port = server-port;
- openFirewall = true;
- secretFile = pkgs.writeText "devpi-secret" "v263P+V3YGDYUyfYL/RBURw+tCPMDw94R/iCuBNJrDhaYrZYjpA6XPFVDDH8ViN20j77y2PHoMM/U0opNkVQ2g==";
- };
+ nodes = {
+ devpi =
+ { ... }:
+ {
+ services.devpi-server = {
+ enable = true;
+ host = "0.0.0.0";
+ port = server-port;
+ openFirewall = true;
+ secretFile = pkgs.writeText "devpi-secret" "v263P+V3YGDYUyfYL/RBURw+tCPMDw94R/iCuBNJrDhaYrZYjpA6XPFVDDH8ViN20j77y2PHoMM/U0opNkVQ2g==";
};
+ };
- client1 =
- { ... }:
- {
- environment.systemPackages = with pkgs; [
- devpi-client
- jq
- ];
- };
- };
+ client1 =
+ { ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ devpi-client
+ jq
+ ];
+ };
+ };
- testScript = ''
- start_all()
- devpi.wait_for_unit("devpi-server.service")
- devpi.wait_for_open_port(${builtins.toString server-port})
+ testScript = ''
+ start_all()
+ devpi.wait_for_unit("devpi-server.service")
+ devpi.wait_for_open_port(${builtins.toString server-port})
- client1.succeed("devpi getjson http://devpi:${builtins.toString server-port}")
- '';
- }
-)
+ client1.succeed("devpi getjson http://devpi:${builtins.toString server-port}")
+ '';
+}
diff --git a/nixos/tests/dex-oidc.nix b/nixos/tests/dex-oidc.nix
index 37718fdcdbde..bc764cc1c471 100644
--- a/nixos/tests/dex-oidc.nix
+++ b/nixos/tests/dex-oidc.nix
@@ -1,84 +1,82 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "dex-oidc";
- meta.maintainers = with lib.maintainers; [ Flakebi ];
+{ lib, ... }:
+{
+ name = "dex-oidc";
+ meta.maintainers = with lib.maintainers; [ Flakebi ];
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [ jq ];
- services.dex = {
- enable = true;
- settings = {
- issuer = "http://127.0.0.1:8080/dex";
- storage = {
- type = "postgres";
- config.host = "/var/run/postgresql";
- };
- web.http = "127.0.0.1:8080";
- oauth2.skipApprovalScreen = true;
- staticClients = [
- {
- id = "oidcclient";
- name = "Client";
- redirectURIs = [ "https://example.com/callback" ];
- secretFile = "/etc/dex/oidcclient";
- }
- ];
- connectors = [
- {
- type = "mockPassword";
- id = "mock";
- name = "Example";
- config = {
- username = "admin";
- password = "password";
- };
- }
- ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [ jq ];
+ services.dex = {
+ enable = true;
+ settings = {
+ issuer = "http://127.0.0.1:8080/dex";
+ storage = {
+ type = "postgres";
+ config.host = "/var/run/postgresql";
};
- };
-
- # This should not be set from nix but through other means to not leak the secret.
- environment.etc."dex/oidcclient" = {
- mode = "0400";
- user = "dex";
- text = "oidcclientsecret";
- };
-
- services.postgresql = {
- enable = true;
- ensureDatabases = [ "dex" ];
- ensureUsers = [
+ web.http = "127.0.0.1:8080";
+ oauth2.skipApprovalScreen = true;
+ staticClients = [
{
- name = "dex";
- ensureDBOwnership = true;
+ id = "oidcclient";
+ name = "Client";
+ redirectURIs = [ "https://example.com/callback" ];
+ secretFile = "/etc/dex/oidcclient";
+ }
+ ];
+ connectors = [
+ {
+ type = "mockPassword";
+ id = "mock";
+ name = "Example";
+ config = {
+ username = "admin";
+ password = "password";
+ };
}
];
};
};
- testScript = ''
- with subtest("Web server gets ready"):
- machine.wait_for_unit("dex.service", timeout=120)
- # Wait until server accepts connections
- machine.wait_until_succeeds("curl -fs 'localhost:8080/dex/auth/mock?client_id=oidcclient&response_type=code&redirect_uri=https://example.com/callback&scope=openid'", timeout=120)
+ # This should not be set from nix but through other means to not leak the secret.
+ environment.etc."dex/oidcclient" = {
+ mode = "0400";
+ user = "dex";
+ text = "oidcclientsecret";
+ };
- with subtest("Login"):
- state = machine.succeed("curl -fs 'localhost:8080/dex/auth/mock?client_id=oidcclient&response_type=code&redirect_uri=https://example.com/callback&scope=openid' | sed -n 's/.*state=\\(.*\\)\">.*/\\1/p'").strip()
- print(f"Got state {state}")
- # Login request returns 303 with redirect_url that has code as query parameter:
- # https://example.com/callback?code=kibsamwdupuy2iwqnlbqei3u6&state=
- code = machine.succeed(f"curl -fs 'localhost:8080/dex/auth/mock/login?back=&state={state}' -d 'login=admin&password=password' -w '%{{redirect_url}}' | sed -n 's/.*code=\\(.*\\)&.*/\\1/p'")
- print(f"Got approval code {code}")
- bearer = machine.succeed(f"curl -fs localhost:8080/dex/token -u oidcclient:oidcclientsecret -d 'grant_type=authorization_code&redirect_uri=https://example.com/callback&code={code}' | jq .access_token -r").strip()
- print(f"Got access token {bearer}")
+ services.postgresql = {
+ enable = true;
+ ensureDatabases = [ "dex" ];
+ ensureUsers = [
+ {
+ name = "dex";
+ ensureDBOwnership = true;
+ }
+ ];
+ };
+ };
- with subtest("Get userinfo"):
- assert '"sub"' in machine.succeed(
- f"curl -fs localhost:8080/dex/userinfo --oauth2-bearer {bearer}"
- )
- '';
- }
-)
+ testScript = ''
+ with subtest("Web server gets ready"):
+ machine.wait_for_unit("dex.service", timeout=120)
+ # Wait until server accepts connections
+ machine.wait_until_succeeds("curl -fs 'localhost:8080/dex/auth/mock?client_id=oidcclient&response_type=code&redirect_uri=https://example.com/callback&scope=openid'", timeout=120)
+
+ with subtest("Login"):
+ state = machine.succeed("curl -fs 'localhost:8080/dex/auth/mock?client_id=oidcclient&response_type=code&redirect_uri=https://example.com/callback&scope=openid' | sed -n 's/.*state=\\(.*\\)\">.*/\\1/p'").strip()
+ print(f"Got state {state}")
+ # Login request returns 303 with redirect_url that has code as query parameter:
+ # https://example.com/callback?code=kibsamwdupuy2iwqnlbqei3u6&state=
+ code = machine.succeed(f"curl -fs 'localhost:8080/dex/auth/mock/login?back=&state={state}' -d 'login=admin&password=password' -w '%{{redirect_url}}' | sed -n 's/.*code=\\(.*\\)&.*/\\1/p'")
+ print(f"Got approval code {code}")
+ bearer = machine.succeed(f"curl -fs localhost:8080/dex/token -u oidcclient:oidcclientsecret -d 'grant_type=authorization_code&redirect_uri=https://example.com/callback&code={code}' | jq .access_token -r").strip()
+ print(f"Got access token {bearer}")
+
+ with subtest("Get userinfo"):
+ assert '"sub"' in machine.succeed(
+ f"curl -fs localhost:8080/dex/userinfo --oauth2-bearer {bearer}"
+ )
+ '';
+}
diff --git a/nixos/tests/disable-installer-tools.nix b/nixos/tests/disable-installer-tools.nix
index d794f7d3f86d..ac8fa4cbf46a 100644
--- a/nixos/tests/disable-installer-tools.nix
+++ b/nixos/tests/disable-installer-tools.nix
@@ -1,35 +1,33 @@
-import ./make-test-python.nix (
- {
- pkgs,
- latestKernel ? false,
- ...
- }:
+{
+ pkgs,
+ latestKernel ? false,
+ ...
+}:
- {
- name = "disable-installer-tools";
+{
+ name = "disable-installer-tools";
- nodes.machine =
- { pkgs, lib, ... }:
- {
- system.disableInstallerTools = true;
- boot.enableContainers = false;
- environment.defaultPackages = [ ];
- };
+ nodes.machine =
+ { pkgs, lib, ... }:
+ {
+ system.disableInstallerTools = true;
+ boot.enableContainers = false;
+ environment.defaultPackages = [ ];
+ };
- testScript = ''
- machine.wait_for_unit("multi-user.target")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+ testScript = ''
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
- with subtest("nixos installer tools should not be included"):
- machine.fail("which nixos-rebuild")
- machine.fail("which nixos-install")
- machine.fail("which nixos-generate-config")
- machine.fail("which nixos-enter")
- machine.fail("which nixos-version")
- machine.fail("which nixos-build-vms")
+ with subtest("nixos installer tools should not be included"):
+ machine.fail("which nixos-rebuild")
+ machine.fail("which nixos-install")
+ machine.fail("which nixos-generate-config")
+ machine.fail("which nixos-enter")
+ machine.fail("which nixos-version")
+ machine.fail("which nixos-build-vms")
- with subtest("perl should not be included"):
- machine.fail("which perl")
- '';
- }
-)
+ with subtest("perl should not be included"):
+ machine.fail("which perl")
+ '';
+}
diff --git a/nixos/tests/discourse.nix b/nixos/tests/discourse.nix
index 1f8d1b7bdf4c..8db47f2b1ad1 100644
--- a/nixos/tests/discourse.nix
+++ b/nixos/tests/discourse.nix
@@ -3,209 +3,207 @@
# 2. sending a private message to the admin user through the API
# 3. replying to that message via email.
-import ./make-test-python.nix (
- {
- pkgs,
- lib,
- package ? pkgs.discourse,
- ...
- }:
- let
- certs = import ./common/acme/server/snakeoil-certs.nix;
- clientDomain = "client.fake.domain";
- discourseDomain = certs.domain;
- adminPassword = "eYAX85qmMJ5GZIHLaXGDAoszD7HSZp5d";
- secretKeyBase = "381f4ac6d8f5e49d804dae72aa9c046431d2f34c656a705c41cd52fed9b4f6f76f51549f0b55db3b8b0dded7a00d6a381ebe9a4367d2d44f5e743af6628b4d42";
- admin = {
- email = "alice@${clientDomain}";
- username = "alice";
- fullName = "Alice Admin";
- passwordFile = "${pkgs.writeText "admin-pass" adminPassword}";
- };
- in
- {
- name = "discourse";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ talyz ];
- };
+{
+ pkgs,
+ lib,
+ package ? pkgs.discourse,
+ ...
+}:
+let
+ certs = import ./common/acme/server/snakeoil-certs.nix;
+ clientDomain = "client.fake.domain";
+ discourseDomain = certs.domain;
+ adminPassword = "eYAX85qmMJ5GZIHLaXGDAoszD7HSZp5d";
+ secretKeyBase = "381f4ac6d8f5e49d804dae72aa9c046431d2f34c656a705c41cd52fed9b4f6f76f51549f0b55db3b8b0dded7a00d6a381ebe9a4367d2d44f5e743af6628b4d42";
+ admin = {
+ email = "alice@${clientDomain}";
+ username = "alice";
+ fullName = "Alice Admin";
+ passwordFile = "${pkgs.writeText "admin-pass" adminPassword}";
+ };
+in
+{
+ name = "discourse";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ talyz ];
+ };
- nodes.discourse =
- { nodes, ... }:
- {
- virtualisation.memorySize = 2048;
- virtualisation.cores = 4;
- virtualisation.useNixStoreImage = true;
- virtualisation.writableStore = false;
+ nodes.discourse =
+ { nodes, ... }:
+ {
+ virtualisation.memorySize = 2048;
+ virtualisation.cores = 4;
+ virtualisation.useNixStoreImage = true;
+ virtualisation.writableStore = false;
- imports = [ common/user-account.nix ];
+ imports = [ common/user-account.nix ];
- security.pki.certificateFiles = [
- certs.ca.cert
- ];
+ security.pki.certificateFiles = [
+ certs.ca.cert
+ ];
- networking.extraHosts = ''
- 127.0.0.1 ${discourseDomain}
- ${nodes.client.networking.primaryIPAddress} ${clientDomain}
- '';
-
- services.postfix = {
- enableSubmission = true;
- enableSubmissions = true;
- submissionsOptions = {
- smtpd_sasl_auth_enable = "yes";
- smtpd_client_restrictions = "permit";
- };
- };
-
- environment.systemPackages = [ pkgs.jq ];
-
- services.postgresql.package = pkgs.postgresql_15;
-
- services.discourse = {
- enable = true;
- inherit admin package;
- hostname = discourseDomain;
- sslCertificate = "${certs.${discourseDomain}.cert}";
- sslCertificateKey = "${certs.${discourseDomain}.key}";
- secretKeyBaseFile = "${pkgs.writeText "secret-key-base" secretKeyBase}";
- enableACME = false;
- mail.outgoing.serverAddress = clientDomain;
- mail.incoming.enable = true;
- siteSettings = {
- posting = {
- min_post_length = 5;
- min_first_post_length = 5;
- min_personal_message_post_length = 5;
- };
- };
- unicornTimeout = 900;
- };
-
- networking.firewall.allowedTCPPorts = [
- 25
- 465
- ];
- };
-
- nodes.client =
- { nodes, ... }:
- {
- imports = [ common/user-account.nix ];
-
- security.pki.certificateFiles = [
- certs.ca.cert
- ];
-
- networking.extraHosts = ''
- 127.0.0.1 ${clientDomain}
- ${nodes.discourse.networking.primaryIPAddress} ${discourseDomain}
- '';
-
- services.dovecot2 = {
- enable = true;
- protocols = [ "imap" ];
- };
-
- services.postfix = {
- enable = true;
- origin = clientDomain;
- relayDomains = [ clientDomain ];
- config = {
- compatibility_level = "2";
- smtpd_banner = "ESMTP server";
- myhostname = clientDomain;
- mydestination = clientDomain;
- };
- };
-
- environment.systemPackages =
- let
- replyToEmail = pkgs.writeScriptBin "reply-to-email" ''
- #!${pkgs.python3.interpreter}
- import imaplib
- import smtplib
- import ssl
- import email.header
- from email import message_from_bytes
- from email.message import EmailMessage
-
- with imaplib.IMAP4('localhost') as imap:
- imap.login('alice', 'foobar')
- imap.select()
- status, data = imap.search(None, 'ALL')
- assert status == 'OK'
-
- nums = data[0].split()
- assert len(nums) == 1
-
- status, msg_data = imap.fetch(nums[0], '(RFC822)')
- assert status == 'OK'
-
- msg = email.message_from_bytes(msg_data[0][1])
- subject = str(email.header.make_header(email.header.decode_header(msg['Subject'])))
- reply_to = email.header.decode_header(msg['Reply-To'])[0][0]
- message_id = email.header.decode_header(msg['Message-ID'])[0][0]
- date = email.header.decode_header(msg['Date'])[0][0]
-
- ctx = ssl.create_default_context()
- with smtplib.SMTP_SSL(host='${discourseDomain}', context=ctx) as smtp:
- reply = EmailMessage()
- reply['Subject'] = 'Re: ' + subject
- reply['To'] = reply_to
- reply['From'] = 'alice@${clientDomain}'
- reply['In-Reply-To'] = message_id
- reply['References'] = message_id
- reply['Date'] = date
- reply.set_content("Test reply.")
-
- smtp.send_message(reply)
- smtp.quit()
- '';
- in
- [ replyToEmail ];
-
- networking.firewall.allowedTCPPorts = [ 25 ];
- };
-
- testScript =
- { nodes }:
- let
- request = builtins.toJSON {
- title = "Private message";
- raw = "This is a test message.";
- target_recipients = admin.username;
- archetype = "private_message";
- };
- in
- ''
- discourse.start()
- client.start()
-
- discourse.wait_for_unit("discourse.service")
- discourse.wait_for_file("/run/discourse/sockets/unicorn.sock")
- discourse.wait_until_succeeds("curl -sS -f https://${discourseDomain}")
- discourse.succeed(
- "curl -sS -f https://${discourseDomain}/session/csrf -c cookie -b cookie -H 'Accept: application/json' | jq -r '\"X-CSRF-Token: \" + .csrf' > csrf_token",
- "curl -sS -f https://${discourseDomain}/session -c cookie -b cookie -H @csrf_token -H 'Accept: application/json' -d 'login=${nodes.discourse.services.discourse.admin.username}' -d \"password=${adminPassword}\" | jq -e '.user.username == \"${nodes.discourse.services.discourse.admin.username}\"'",
- "curl -sS -f https://${discourseDomain}/login -v -H 'Accept: application/json' -c cookie -b cookie 2>&1 | grep ${nodes.discourse.services.discourse.admin.username}",
- )
-
- client.wait_for_unit("postfix.service")
- client.wait_for_unit("dovecot2.service")
-
- discourse.succeed(
- "sudo -u discourse discourse-rake api_key:create_master[master] >api_key",
- 'curl -sS -f https://${discourseDomain}/posts -X POST -H "Content-Type: application/json" -H "Api-Key: $(topic_id'
- )
- discourse.succeed(
- 'curl -sS -f https://${discourseDomain}/t/$(Test reply.
" then true else null end\' '
- )
+ networking.extraHosts = ''
+ 127.0.0.1 ${discourseDomain}
+ ${nodes.client.networking.primaryIPAddress} ${clientDomain}
'';
- }
-)
+
+ services.postfix = {
+ enableSubmission = true;
+ enableSubmissions = true;
+ submissionsOptions = {
+ smtpd_sasl_auth_enable = "yes";
+ smtpd_client_restrictions = "permit";
+ };
+ };
+
+ environment.systemPackages = [ pkgs.jq ];
+
+ services.postgresql.package = pkgs.postgresql_15;
+
+ services.discourse = {
+ enable = true;
+ inherit admin package;
+ hostname = discourseDomain;
+ sslCertificate = "${certs.${discourseDomain}.cert}";
+ sslCertificateKey = "${certs.${discourseDomain}.key}";
+ secretKeyBaseFile = "${pkgs.writeText "secret-key-base" secretKeyBase}";
+ enableACME = false;
+ mail.outgoing.serverAddress = clientDomain;
+ mail.incoming.enable = true;
+ siteSettings = {
+ posting = {
+ min_post_length = 5;
+ min_first_post_length = 5;
+ min_personal_message_post_length = 5;
+ };
+ };
+ unicornTimeout = 900;
+ };
+
+ networking.firewall.allowedTCPPorts = [
+ 25
+ 465
+ ];
+ };
+
+ nodes.client =
+ { nodes, ... }:
+ {
+ imports = [ common/user-account.nix ];
+
+ security.pki.certificateFiles = [
+ certs.ca.cert
+ ];
+
+ networking.extraHosts = ''
+ 127.0.0.1 ${clientDomain}
+ ${nodes.discourse.networking.primaryIPAddress} ${discourseDomain}
+ '';
+
+ services.dovecot2 = {
+ enable = true;
+ protocols = [ "imap" ];
+ };
+
+ services.postfix = {
+ enable = true;
+ origin = clientDomain;
+ relayDomains = [ clientDomain ];
+ config = {
+ compatibility_level = "2";
+ smtpd_banner = "ESMTP server";
+ myhostname = clientDomain;
+ mydestination = clientDomain;
+ };
+ };
+
+ environment.systemPackages =
+ let
+ replyToEmail = pkgs.writeScriptBin "reply-to-email" ''
+ #!${pkgs.python3.interpreter}
+ import imaplib
+ import smtplib
+ import ssl
+ import email.header
+ from email import message_from_bytes
+ from email.message import EmailMessage
+
+ with imaplib.IMAP4('localhost') as imap:
+ imap.login('alice', 'foobar')
+ imap.select()
+ status, data = imap.search(None, 'ALL')
+ assert status == 'OK'
+
+ nums = data[0].split()
+ assert len(nums) == 1
+
+ status, msg_data = imap.fetch(nums[0], '(RFC822)')
+ assert status == 'OK'
+
+ msg = email.message_from_bytes(msg_data[0][1])
+ subject = str(email.header.make_header(email.header.decode_header(msg['Subject'])))
+ reply_to = email.header.decode_header(msg['Reply-To'])[0][0]
+ message_id = email.header.decode_header(msg['Message-ID'])[0][0]
+ date = email.header.decode_header(msg['Date'])[0][0]
+
+ ctx = ssl.create_default_context()
+ with smtplib.SMTP_SSL(host='${discourseDomain}', context=ctx) as smtp:
+ reply = EmailMessage()
+ reply['Subject'] = 'Re: ' + subject
+ reply['To'] = reply_to
+ reply['From'] = 'alice@${clientDomain}'
+ reply['In-Reply-To'] = message_id
+ reply['References'] = message_id
+ reply['Date'] = date
+ reply.set_content("Test reply.")
+
+ smtp.send_message(reply)
+ smtp.quit()
+ '';
+ in
+ [ replyToEmail ];
+
+ networking.firewall.allowedTCPPorts = [ 25 ];
+ };
+
+ testScript =
+ { nodes }:
+ let
+ request = builtins.toJSON {
+ title = "Private message";
+ raw = "This is a test message.";
+ target_recipients = admin.username;
+ archetype = "private_message";
+ };
+ in
+ ''
+ discourse.start()
+ client.start()
+
+ discourse.wait_for_unit("discourse.service")
+ discourse.wait_for_file("/run/discourse/sockets/unicorn.sock")
+ discourse.wait_until_succeeds("curl -sS -f https://${discourseDomain}")
+ discourse.succeed(
+ "curl -sS -f https://${discourseDomain}/session/csrf -c cookie -b cookie -H 'Accept: application/json' | jq -r '\"X-CSRF-Token: \" + .csrf' > csrf_token",
+ "curl -sS -f https://${discourseDomain}/session -c cookie -b cookie -H @csrf_token -H 'Accept: application/json' -d 'login=${nodes.discourse.services.discourse.admin.username}' -d \"password=${adminPassword}\" | jq -e '.user.username == \"${nodes.discourse.services.discourse.admin.username}\"'",
+ "curl -sS -f https://${discourseDomain}/login -v -H 'Accept: application/json' -c cookie -b cookie 2>&1 | grep ${nodes.discourse.services.discourse.admin.username}",
+ )
+
+ client.wait_for_unit("postfix.service")
+ client.wait_for_unit("dovecot2.service")
+
+ discourse.succeed(
+ "sudo -u discourse discourse-rake api_key:create_master[master] >api_key",
+ 'curl -sS -f https://${discourseDomain}/posts -X POST -H "Content-Type: application/json" -H "Api-Key: $(topic_id'
+ )
+ discourse.succeed(
+ 'curl -sS -f https://${discourseDomain}/t/$(Test reply." then true else null end\' '
+ )
+ '';
+}
diff --git a/nixos/tests/documize.nix b/nixos/tests/documize.nix
index 1537047ad679..4565033a9349 100644
--- a/nixos/tests/documize.nix
+++ b/nixos/tests/documize.nix
@@ -1,67 +1,65 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "documize";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "documize";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.jq ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.jq ];
- services.documize = {
- enable = true;
- port = 3000;
- dbtype = "postgresql";
- db = "host=localhost port=5432 sslmode=disable user=documize password=documize dbname=documize";
- };
-
- systemd.services.documize-server = {
- after = [ "postgresql.service" ];
- requires = [ "postgresql.service" ];
- };
-
- services.postgresql = {
- enable = true;
- initialScript = pkgs.writeText "psql-init" ''
- CREATE ROLE documize WITH LOGIN PASSWORD 'documize';
- CREATE DATABASE documize WITH OWNER documize;
- '';
- };
+ services.documize = {
+ enable = true;
+ port = 3000;
+ dbtype = "postgresql";
+ db = "host=localhost port=5432 sslmode=disable user=documize password=documize dbname=documize";
};
- testScript = ''
- start_all()
+ systemd.services.documize-server = {
+ after = [ "postgresql.service" ];
+ requires = [ "postgresql.service" ];
+ };
- machine.wait_for_unit("documize-server.service")
- machine.wait_for_open_port(3000)
+ services.postgresql = {
+ enable = true;
+ initialScript = pkgs.writeText "psql-init" ''
+ CREATE ROLE documize WITH LOGIN PASSWORD 'documize';
+ CREATE DATABASE documize WITH OWNER documize;
+ '';
+ };
+ };
- dbhash = machine.succeed(
- "curl -f localhost:3000 | grep 'property=\"dbhash' | grep -Po 'content=\"\\K[^\"]*'"
- )
+ testScript = ''
+ start_all()
- dbhash = dbhash.strip()
+ machine.wait_for_unit("documize-server.service")
+ machine.wait_for_open_port(3000)
- machine.succeed(
- (
- "curl -X POST"
- " --data 'dbname=documize'"
- " --data 'dbhash={}'"
- " --data 'title=NixOS'"
- " --data 'message=Docs'"
- " --data 'firstname=Bob'"
- " --data 'lastname=Foobar'"
- " --data 'email=bob.foobar@nixos.org'"
- " --data 'password=verysafe'"
- " -f localhost:3000/api/setup"
- ).format(dbhash)
- )
+ dbhash = machine.succeed(
+ "curl -f localhost:3000 | grep 'property=\"dbhash' | grep -Po 'content=\"\\K[^\"]*'"
+ )
- machine.succeed(
- 'test "$(curl -f localhost:3000/api/public/meta | jq ".title" | xargs echo)" = "NixOS"'
- )
- '';
- }
-)
+ dbhash = dbhash.strip()
+
+ machine.succeed(
+ (
+ "curl -X POST"
+ " --data 'dbname=documize'"
+ " --data 'dbhash={}'"
+ " --data 'title=NixOS'"
+ " --data 'message=Docs'"
+ " --data 'firstname=Bob'"
+ " --data 'lastname=Foobar'"
+ " --data 'email=bob.foobar@nixos.org'"
+ " --data 'password=verysafe'"
+ " -f localhost:3000/api/setup"
+ ).format(dbhash)
+ )
+
+ machine.succeed(
+ 'test "$(curl -f localhost:3000/api/public/meta | jq ".title" | xargs echo)" = "NixOS"'
+ )
+ '';
+}
diff --git a/nixos/tests/doh-proxy-rust.nix b/nixos/tests/doh-proxy-rust.nix
index f9c73edcb778..26e6ea2c3885 100644
--- a/nixos/tests/doh-proxy-rust.nix
+++ b/nixos/tests/doh-proxy-rust.nix
@@ -1,48 +1,46 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "doh-proxy-rust";
- meta.maintainers = with lib.maintainers; [ stephank ];
+{ lib, pkgs, ... }:
+{
+ name = "doh-proxy-rust";
+ meta.maintainers = with lib.maintainers; [ stephank ];
- nodes = {
- machine =
- { pkgs, lib, ... }:
- {
- services.bind = {
- enable = true;
- extraOptions = "empty-zones-enable no;";
- zones = lib.singleton {
- name = ".";
- master = true;
- file = pkgs.writeText "root.zone" ''
- $TTL 3600
- . IN SOA ns.example.org. admin.example.org. ( 1 3h 1h 1w 1d )
- . IN NS ns.example.org.
- ns.example.org. IN A 192.168.0.1
- '';
- };
- };
- services.doh-proxy-rust = {
- enable = true;
- flags = [
- "--server-address=127.0.0.1:53"
- ];
+ nodes = {
+ machine =
+ { pkgs, lib, ... }:
+ {
+ services.bind = {
+ enable = true;
+ extraOptions = "empty-zones-enable no;";
+ zones = lib.singleton {
+ name = ".";
+ master = true;
+ file = pkgs.writeText "root.zone" ''
+ $TTL 3600
+ . IN SOA ns.example.org. admin.example.org. ( 1 3h 1h 1w 1d )
+ . IN NS ns.example.org.
+ ns.example.org. IN A 192.168.0.1
+ '';
};
};
- };
+ services.doh-proxy-rust = {
+ enable = true;
+ flags = [
+ "--server-address=127.0.0.1:53"
+ ];
+ };
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- url = "http://localhost:3000/dns-query"
- query = "AAABAAABAAAAAAAAAm5zB2V4YW1wbGUDb3JnAAABAAE=" # IN A ns.example.org.
- bin_ip = r"$'\xC0\xA8\x00\x01'" # 192.168.0.1, as shell binary string
+ testScript =
+ { nodes, ... }:
+ ''
+ url = "http://localhost:3000/dns-query"
+ query = "AAABAAABAAAAAAAAAm5zB2V4YW1wbGUDb3JnAAABAAE=" # IN A ns.example.org.
+ bin_ip = r"$'\xC0\xA8\x00\x01'" # 192.168.0.1, as shell binary string
- machine.wait_for_unit("bind.service")
- machine.wait_for_unit("doh-proxy-rust.service")
- machine.wait_for_open_port(53)
- machine.wait_for_open_port(3000)
- machine.succeed(f"curl --fail -H 'Accept: application/dns-message' '{url}?dns={query}' | grep -F {bin_ip}")
- '';
- }
-)
+ machine.wait_for_unit("bind.service")
+ machine.wait_for_unit("doh-proxy-rust.service")
+ machine.wait_for_open_port(53)
+ machine.wait_for_open_port(3000)
+ machine.succeed(f"curl --fail -H 'Accept: application/dns-message' '{url}?dns={query}' | grep -F {bin_ip}")
+ '';
+}
diff --git a/nixos/tests/domination.nix b/nixos/tests/domination.nix
index d37a7ba98be9..48f5825afc97 100644
--- a/nixos/tests/domination.nix
+++ b/nixos/tests/domination.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "domination";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fgaz ];
+{ pkgs, ... }:
+{
+ name = "domination";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fgaz ];
+ };
+
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ];
+
+ services.xserver.enable = true;
+ environment.systemPackages = [ pkgs.domination ];
};
- nodes.machine =
- { config, pkgs, ... }:
- {
- imports = [
- ./common/x11.nix
- ];
+ enableOCR = true;
- services.xserver.enable = true;
- environment.systemPackages = [ pkgs.domination ];
- };
-
- enableOCR = true;
-
- testScript = ''
- machine.wait_for_x()
- # Add a dummy sound card, or an error reporting popup will appear,
- # covering the main window and preventing OCR
- machine.execute("modprobe snd-dummy")
- machine.execute("domination >&2 &")
- machine.wait_for_window("Menu")
- machine.wait_for_text(r"(New Game|Start Server|Load Game|Help Manual|Join Game|About|Play Online)")
- machine.screenshot("screen")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_x()
+ # Add a dummy sound card, or an error reporting popup will appear,
+ # covering the main window and preventing OCR
+ machine.execute("modprobe snd-dummy")
+ machine.execute("domination >&2 &")
+ machine.wait_for_window("Menu")
+ machine.wait_for_text(r"(New Game|Start Server|Load Game|Help Manual|Join Game|About|Play Online)")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/drbd-driver.nix b/nixos/tests/drbd-driver.nix
index 9ba7c438eabc..9df032bd797c 100644
--- a/nixos/tests/drbd-driver.nix
+++ b/nixos/tests/drbd-driver.nix
@@ -1,24 +1,22 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "drbd-driver";
- meta.maintainers = with pkgs.lib.maintainers; [ birkb ];
+{ lib, pkgs, ... }:
+{
+ name = "drbd-driver";
+ meta.maintainers = with pkgs.lib.maintainers; [ birkb ];
- nodes = {
- machine =
- { config, pkgs, ... }:
- {
- boot = {
- kernelModules = [ "drbd" ];
- extraModulePackages = with config.boot.kernelPackages; [ drbd ];
- kernelPackages = pkgs.linuxPackages;
- };
+ nodes = {
+ machine =
+ { config, pkgs, ... }:
+ {
+ boot = {
+ kernelModules = [ "drbd" ];
+ extraModulePackages = with config.boot.kernelPackages; [ drbd ];
+ kernelPackages = pkgs.linuxPackages;
};
- };
+ };
+ };
- testScript = ''
- machine.start();
- machine.succeed("modinfo drbd | grep --extended-regexp '^version:\s+${pkgs.linuxPackages.drbd.version}$'")
- '';
- }
-)
+ testScript = ''
+ machine.start();
+ machine.succeed("modinfo drbd | grep --extended-regexp '^version:\s+${pkgs.linuxPackages.drbd.version}$'")
+ '';
+}
diff --git a/nixos/tests/drbd.nix b/nixos/tests/drbd.nix
index 9d0a26a3252f..fb88362b10a2 100644
--- a/nixos/tests/drbd.nix
+++ b/nixos/tests/drbd.nix
@@ -1,93 +1,91 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- drbdPort = 7789;
+{ pkgs, lib, ... }:
+let
+ drbdPort = 7789;
- drbdConfig =
- { nodes, ... }:
- {
- virtualisation.emptyDiskImages = [ 1 ];
- networking.firewall.allowedTCPPorts = [ drbdPort ];
+ drbdConfig =
+ { nodes, ... }:
+ {
+ virtualisation.emptyDiskImages = [ 1 ];
+ networking.firewall.allowedTCPPorts = [ drbdPort ];
- services.drbd = {
- enable = true;
- config = ''
- global {
- usage-count yes;
+ services.drbd = {
+ enable = true;
+ config = ''
+ global {
+ usage-count yes;
+ }
+
+ common {
+ net {
+ protocol C;
+ ping-int 1;
+ }
+ }
+
+ resource r0 {
+ volume 0 {
+ device /dev/drbd0;
+ disk /dev/vdb;
+ meta-disk internal;
}
- common {
- net {
- protocol C;
- ping-int 1;
- }
+ on drbd1 {
+ address ${nodes.drbd1.networking.primaryIPAddress}:${toString drbdPort};
}
- resource r0 {
- volume 0 {
- device /dev/drbd0;
- disk /dev/vdb;
- meta-disk internal;
- }
-
- on drbd1 {
- address ${nodes.drbd1.networking.primaryIPAddress}:${toString drbdPort};
- }
-
- on drbd2 {
- address ${nodes.drbd2.networking.primaryIPAddress}:${toString drbdPort};
- }
+ on drbd2 {
+ address ${nodes.drbd2.networking.primaryIPAddress}:${toString drbdPort};
}
- '';
- };
+ }
+ '';
};
- in
- {
- name = "drbd";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- ryantm
- astro
- birkb
- ];
};
+in
+{
+ name = "drbd";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ ryantm
+ astro
+ birkb
+ ];
+ };
- nodes.drbd1 = drbdConfig;
- nodes.drbd2 = drbdConfig;
+ nodes.drbd1 = drbdConfig;
+ nodes.drbd2 = drbdConfig;
- testScript =
- { nodes }:
- ''
- drbd1.start()
- drbd2.start()
+ testScript =
+ { nodes }:
+ ''
+ drbd1.start()
+ drbd2.start()
- drbd1.wait_for_unit("network.target")
- drbd2.wait_for_unit("network.target")
+ drbd1.wait_for_unit("network.target")
+ drbd2.wait_for_unit("network.target")
- drbd1.succeed(
- "drbdadm create-md r0",
- "drbdadm up r0",
- "drbdadm primary r0 --force",
- )
+ drbd1.succeed(
+ "drbdadm create-md r0",
+ "drbdadm up r0",
+ "drbdadm primary r0 --force",
+ )
- drbd2.succeed("drbdadm create-md r0", "drbdadm up r0")
+ drbd2.succeed("drbdadm create-md r0", "drbdadm up r0")
- drbd1.succeed(
- "mkfs.ext4 /dev/drbd0",
- "mkdir -p /mnt/drbd",
- "mount /dev/drbd0 /mnt/drbd",
- "touch /mnt/drbd/hello",
- "umount /mnt/drbd",
- "drbdadm secondary r0",
- )
- drbd1.sleep(1)
+ drbd1.succeed(
+ "mkfs.ext4 /dev/drbd0",
+ "mkdir -p /mnt/drbd",
+ "mount /dev/drbd0 /mnt/drbd",
+ "touch /mnt/drbd/hello",
+ "umount /mnt/drbd",
+ "drbdadm secondary r0",
+ )
+ drbd1.sleep(1)
- drbd2.succeed(
- "drbdadm primary r0",
- "mkdir -p /mnt/drbd",
- "mount /dev/drbd0 /mnt/drbd",
- "ls /mnt/drbd/hello",
- )
- '';
- }
-)
+ drbd2.succeed(
+ "drbdadm primary r0",
+ "mkdir -p /mnt/drbd",
+ "mount /dev/drbd0 /mnt/drbd",
+ "ls /mnt/drbd/hello",
+ )
+ '';
+}
diff --git a/nixos/tests/dublin-traceroute.nix b/nixos/tests/dublin-traceroute.nix
index cae8e4f894f3..51532ede15eb 100644
--- a/nixos/tests/dublin-traceroute.nix
+++ b/nixos/tests/dublin-traceroute.nix
@@ -3,75 +3,73 @@
# client on the inside network, a server on the outside network, and a
# router connected to both that performs Network Address Translation
# for the client.
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- routerBase = lib.mkMerge [
- {
- virtualisation.vlans = [
- 2
- 1
- ];
- networking.nftables.enable = true;
- networking.nat.internalIPs = [ "192.168.1.0/24" ];
- networking.nat.externalInterface = "eth1";
- }
- ];
- in
- {
- name = "dublin-traceroute";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ baloo ];
+{ pkgs, lib, ... }:
+let
+ routerBase = lib.mkMerge [
+ {
+ virtualisation.vlans = [
+ 2
+ 1
+ ];
+ networking.nftables.enable = true;
+ networking.nat.internalIPs = [ "192.168.1.0/24" ];
+ networking.nat.externalInterface = "eth1";
+ }
+ ];
+in
+{
+ name = "dublin-traceroute";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ baloo ];
+ };
+
+ nodes.client =
+ { nodes, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ virtualisation.vlans = [ 1 ];
+
+ networking.defaultGateway =
+ (builtins.head nodes.router.networking.interfaces.eth2.ipv4.addresses).address;
+ networking.nftables.enable = true;
+
+ programs.dublin-traceroute.enable = true;
};
- nodes.client =
- { nodes, ... }:
- {
- imports = [ ./common/user-account.nix ];
- virtualisation.vlans = [ 1 ];
+ nodes.router =
+ { ... }:
+ {
+ virtualisation.vlans = [
+ 2
+ 1
+ ];
+ networking.nftables.enable = true;
+ networking.nat.internalIPs = [ "192.168.1.0/24" ];
+ networking.nat.externalInterface = "eth1";
+ networking.nat.enable = true;
+ };
- networking.defaultGateway =
- (builtins.head nodes.router.networking.interfaces.eth2.ipv4.addresses).address;
- networking.nftables.enable = true;
+ nodes.server =
+ { ... }:
+ {
+ virtualisation.vlans = [ 2 ];
+ networking.firewall.enable = false;
+ services.httpd.enable = true;
+ services.httpd.adminAddr = "foo@example.org";
+ services.vsftpd.enable = true;
+ services.vsftpd.anonymousUser = true;
+ };
- programs.dublin-traceroute.enable = true;
- };
+ testScript = ''
+ client.start()
+ router.start()
+ server.start()
- nodes.router =
- { ... }:
- {
- virtualisation.vlans = [
- 2
- 1
- ];
- networking.nftables.enable = true;
- networking.nat.internalIPs = [ "192.168.1.0/24" ];
- networking.nat.externalInterface = "eth1";
- networking.nat.enable = true;
- };
+ server.wait_for_unit("network.target")
+ router.wait_for_unit("network.target")
+ client.wait_for_unit("network.target")
- nodes.server =
- { ... }:
- {
- virtualisation.vlans = [ 2 ];
- networking.firewall.enable = false;
- services.httpd.enable = true;
- services.httpd.adminAddr = "foo@example.org";
- services.vsftpd.enable = true;
- services.vsftpd.anonymousUser = true;
- };
-
- testScript = ''
- client.start()
- router.start()
- server.start()
-
- server.wait_for_unit("network.target")
- router.wait_for_unit("network.target")
- client.wait_for_unit("network.target")
-
- # Make sure we can trace from an unprivileged user
- client.succeed("sudo -u alice dublin-traceroute server")
- '';
- }
-)
+ # Make sure we can trace from an unprivileged user
+ client.succeed("sudo -u alice dublin-traceroute server")
+ '';
+}
diff --git a/nixos/tests/ecryptfs.nix b/nixos/tests/ecryptfs.nix
index ceeeb1b15da2..e0deaa7e5013 100644
--- a/nixos/tests/ecryptfs.nix
+++ b/nixos/tests/ecryptfs.nix
@@ -1,89 +1,87 @@
-import ./make-test-python.nix (
- { ... }:
- {
- name = "ecryptfs";
+{ ... }:
+{
+ name = "ecryptfs";
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ./common/user-account.nix ];
- boot.kernelModules = [ "ecryptfs" ];
- security.pam.enableEcryptfs = true;
- environment.systemPackages = with pkgs; [ keyutils ];
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ boot.kernelModules = [ "ecryptfs" ];
+ security.pam.enableEcryptfs = true;
+ environment.systemPackages = with pkgs; [ keyutils ];
+ };
- testScript = ''
- def login_as_alice():
- machine.wait_until_tty_matches("1", "login: ")
- machine.send_chars("alice\n")
- machine.wait_until_tty_matches("1", "Password: ")
- machine.send_chars("foobar\n")
- machine.wait_until_tty_matches("1", "alice\@machine")
+ testScript = ''
+ def login_as_alice():
+ machine.wait_until_tty_matches("1", "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches("1", "Password: ")
+ machine.send_chars("foobar\n")
+ machine.wait_until_tty_matches("1", "alice\@machine")
- def logout():
- machine.send_chars("logout\n")
- machine.wait_until_tty_matches("1", "login: ")
+ def logout():
+ machine.send_chars("logout\n")
+ machine.wait_until_tty_matches("1", "login: ")
- machine.wait_for_unit("default.target")
+ machine.wait_for_unit("default.target")
- with subtest("Set alice up with a password and a home"):
- machine.succeed("(echo foobar; echo foobar) | passwd alice")
- machine.succeed("chown -R alice.users ~alice")
+ with subtest("Set alice up with a password and a home"):
+ machine.succeed("(echo foobar; echo foobar) | passwd alice")
+ machine.succeed("chown -R alice.users ~alice")
- with subtest("Migrate alice's home"):
- out = machine.succeed("echo foobar | ecryptfs-migrate-home -u alice")
- machine.log(f"ecryptfs-migrate-home said: {out}")
+ with subtest("Migrate alice's home"):
+ out = machine.succeed("echo foobar | ecryptfs-migrate-home -u alice")
+ machine.log(f"ecryptfs-migrate-home said: {out}")
- with subtest("Log alice in (ecryptfs passwhrase is wrapped during first login)"):
- login_as_alice()
- machine.send_chars("logout\n")
- machine.wait_until_tty_matches("1", "login: ")
+ with subtest("Log alice in (ecryptfs passwhrase is wrapped during first login)"):
+ login_as_alice()
+ machine.send_chars("logout\n")
+ machine.wait_until_tty_matches("1", "login: ")
- # Why do I need to do this??
- machine.succeed("su alice -c ecryptfs-umount-private || true")
- machine.sleep(1)
+ # Why do I need to do this??
+ machine.succeed("su alice -c ecryptfs-umount-private || true")
+ machine.sleep(1)
- with subtest("check that encrypted home is not mounted"):
- machine.fail("mount | grep ecryptfs")
+ with subtest("check that encrypted home is not mounted"):
+ machine.fail("mount | grep ecryptfs")
- with subtest("Show contents of the user keyring"):
- out = machine.succeed("su - alice -c 'keyctl list \@u'")
- machine.log(f"keyctl unlink said: {out}")
+ with subtest("Show contents of the user keyring"):
+ out = machine.succeed("su - alice -c 'keyctl list \@u'")
+ machine.log(f"keyctl unlink said: {out}")
- with subtest("Log alice again"):
- login_as_alice()
+ with subtest("Log alice again"):
+ login_as_alice()
- with subtest("Create some files in encrypted home"):
- machine.succeed("su alice -c 'touch ~alice/a'")
- machine.succeed("su alice -c 'echo c > ~alice/b'")
+ with subtest("Create some files in encrypted home"):
+ machine.succeed("su alice -c 'touch ~alice/a'")
+ machine.succeed("su alice -c 'echo c > ~alice/b'")
- with subtest("Logout"):
- logout()
+ with subtest("Logout"):
+ logout()
- # Why do I need to do this??
- machine.succeed("su alice -c ecryptfs-umount-private || true")
- machine.sleep(1)
+ # Why do I need to do this??
+ machine.succeed("su alice -c ecryptfs-umount-private || true")
+ machine.sleep(1)
- with subtest("Check that the filesystem is not accessible"):
- machine.fail("mount | grep ecryptfs")
- machine.succeed("su alice -c 'test \! -f ~alice/a'")
- machine.succeed("su alice -c 'test \! -f ~alice/b'")
+ with subtest("Check that the filesystem is not accessible"):
+ machine.fail("mount | grep ecryptfs")
+ machine.succeed("su alice -c 'test \! -f ~alice/a'")
+ machine.succeed("su alice -c 'test \! -f ~alice/b'")
- with subtest("Log alice once more"):
- login_as_alice()
+ with subtest("Log alice once more"):
+ login_as_alice()
- with subtest("Check that the files are there"):
- machine.sleep(1)
- machine.succeed("su alice -c 'test -f ~alice/a'")
- machine.succeed("su alice -c 'test -f ~alice/b'")
- machine.succeed('test "$(cat ~alice/b)" = "c"')
+ with subtest("Check that the files are there"):
+ machine.sleep(1)
+ machine.succeed("su alice -c 'test -f ~alice/a'")
+ machine.succeed("su alice -c 'test -f ~alice/b'")
+ machine.succeed('test "$(cat ~alice/b)" = "c"')
- with subtest("Catch https://github.com/NixOS/nixpkgs/issues/16766"):
- machine.succeed("su alice -c 'ls -lh ~alice/'")
+ with subtest("Catch https://github.com/NixOS/nixpkgs/issues/16766"):
+ machine.succeed("su alice -c 'ls -lh ~alice/'")
- logout()
- '';
- }
-)
+ logout()
+ '';
+}
diff --git a/nixos/tests/endlessh-go.nix b/nixos/tests/endlessh-go.nix
index 0c2402af2568..892d54af6101 100644
--- a/nixos/tests/endlessh-go.nix
+++ b/nixos/tests/endlessh-go.nix
@@ -1,71 +1,69 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "endlessh-go";
- meta.maintainers = with lib.maintainers; [ azahi ];
+{ lib, pkgs, ... }:
+{
+ name = "endlessh-go";
+ meta.maintainers = with lib.maintainers; [ azahi ];
- nodes = {
- server =
- { ... }:
- {
- services.endlessh-go = {
- enable = true;
- prometheus.enable = true;
- openFirewall = true;
+ nodes = {
+ server =
+ { ... }:
+ {
+ services.endlessh-go = {
+ enable = true;
+ prometheus.enable = true;
+ openFirewall = true;
+ };
+
+ specialisation = {
+ unprivileged.configuration = {
+ services.endlessh-go = {
+ port = 2222;
+ prometheus.port = 9229;
+ };
};
- specialisation = {
- unprivileged.configuration = {
- services.endlessh-go = {
- port = 2222;
- prometheus.port = 9229;
- };
- };
-
- privileged.configuration = {
- services.endlessh-go = {
- port = 22;
- prometheus.port = 92;
- };
+ privileged.configuration = {
+ services.endlessh-go = {
+ port = 22;
+ prometheus.port = 92;
};
};
};
+ };
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [
- curl
- netcat
- ];
- };
- };
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ curl
+ netcat
+ ];
+ };
+ };
- testScript = ''
- def activate_specialisation(name: str):
- server.succeed(f"/run/booted-system/specialisation/{name}/bin/switch-to-configuration test >&2")
+ testScript = ''
+ def activate_specialisation(name: str):
+ server.succeed(f"/run/booted-system/specialisation/{name}/bin/switch-to-configuration test >&2")
- start_all()
+ start_all()
- with subtest("Unprivileged"):
- activate_specialisation("unprivileged")
- server.wait_for_unit("endlessh-go.service")
- server.wait_for_open_port(2222)
- server.wait_for_open_port(9229)
- server.fail("curl -sSf server:9229/metrics | grep -q endlessh_client_closed_count_total")
- client.succeed("nc -dvW5 server 2222")
- server.succeed("curl -sSf server:9229/metrics | grep -q endlessh_client_closed_count_total")
- client.fail("curl -sSfm 5 server:9229/metrics")
+ with subtest("Unprivileged"):
+ activate_specialisation("unprivileged")
+ server.wait_for_unit("endlessh-go.service")
+ server.wait_for_open_port(2222)
+ server.wait_for_open_port(9229)
+ server.fail("curl -sSf server:9229/metrics | grep -q endlessh_client_closed_count_total")
+ client.succeed("nc -dvW5 server 2222")
+ server.succeed("curl -sSf server:9229/metrics | grep -q endlessh_client_closed_count_total")
+ client.fail("curl -sSfm 5 server:9229/metrics")
- with subtest("Privileged"):
- activate_specialisation("privileged")
- server.wait_for_unit("endlessh-go.service")
- server.wait_for_open_port(22)
- server.wait_for_open_port(92)
- server.fail("curl -sSf server:92/metrics | grep -q endlessh_client_closed_count_total")
- client.succeed("nc -dvW5 server 22")
- server.succeed("curl -sSf server:92/metrics | grep -q endlessh_client_closed_count_total")
- client.fail("curl -sSfm 5 server:92/metrics")
- '';
- }
-)
+ with subtest("Privileged"):
+ activate_specialisation("privileged")
+ server.wait_for_unit("endlessh-go.service")
+ server.wait_for_open_port(22)
+ server.wait_for_open_port(92)
+ server.fail("curl -sSf server:92/metrics | grep -q endlessh_client_closed_count_total")
+ client.succeed("nc -dvW5 server 22")
+ server.succeed("curl -sSf server:92/metrics | grep -q endlessh_client_closed_count_total")
+ client.fail("curl -sSfm 5 server:92/metrics")
+ '';
+}
diff --git a/nixos/tests/endlessh.nix b/nixos/tests/endlessh.nix
index 696ef1b6013f..95cdbf8586c2 100644
--- a/nixos/tests/endlessh.nix
+++ b/nixos/tests/endlessh.nix
@@ -1,52 +1,50 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "endlessh";
- meta.maintainers = with lib.maintainers; [ azahi ];
+{ lib, pkgs, ... }:
+{
+ name = "endlessh";
+ meta.maintainers = with lib.maintainers; [ azahi ];
- nodes = {
- server =
- { ... }:
- {
- services.endlessh = {
- enable = true;
- openFirewall = true;
- };
-
- specialisation = {
- unprivileged.configuration.services.endlessh.port = 2222;
-
- privileged.configuration.services.endlessh.port = 22;
- };
+ nodes = {
+ server =
+ { ... }:
+ {
+ services.endlessh = {
+ enable = true;
+ openFirewall = true;
};
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [
- curl
- netcat
- ];
+ specialisation = {
+ unprivileged.configuration.services.endlessh.port = 2222;
+
+ privileged.configuration.services.endlessh.port = 22;
};
- };
+ };
- testScript = ''
- def activate_specialisation(name: str):
- server.succeed(f"/run/booted-system/specialisation/{name}/bin/switch-to-configuration test >&2")
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ curl
+ netcat
+ ];
+ };
+ };
- start_all()
+ testScript = ''
+ def activate_specialisation(name: str):
+ server.succeed(f"/run/booted-system/specialisation/{name}/bin/switch-to-configuration test >&2")
- with subtest("Unprivileged"):
- activate_specialisation("unprivileged")
- server.wait_for_unit("endlessh.service")
- server.wait_for_open_port(2222)
- client.succeed("nc -dvW5 server 2222")
+ start_all()
- with subtest("Privileged"):
- activate_specialisation("privileged")
- server.wait_for_unit("endlessh.service")
- server.wait_for_open_port(22)
- client.succeed("nc -dvW5 server 22")
- '';
- }
-)
+ with subtest("Unprivileged"):
+ activate_specialisation("unprivileged")
+ server.wait_for_unit("endlessh.service")
+ server.wait_for_open_port(2222)
+ client.succeed("nc -dvW5 server 2222")
+
+ with subtest("Privileged"):
+ activate_specialisation("privileged")
+ server.wait_for_unit("endlessh.service")
+ server.wait_for_open_port(22)
+ client.succeed("nc -dvW5 server 22")
+ '';
+}
diff --git a/nixos/tests/engelsystem.nix b/nixos/tests/engelsystem.nix
index 69187973ada9..a0eaff6bb1fe 100644
--- a/nixos/tests/engelsystem.nix
+++ b/nixos/tests/engelsystem.nix
@@ -1,45 +1,43 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "engelsystem";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ talyz ];
+{ pkgs, lib, ... }:
+{
+ name = "engelsystem";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ talyz ];
+ };
+
+ nodes.engelsystem =
+ { ... }:
+ {
+ services.engelsystem = {
+ enable = true;
+ domain = "engelsystem";
+ createDatabase = true;
+ };
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
+ ];
+ environment.systemPackages = with pkgs; [
+ xmlstarlet
+ libxml2
+ ];
};
- nodes.engelsystem =
- { ... }:
- {
- services.engelsystem = {
- enable = true;
- domain = "engelsystem";
- createDatabase = true;
- };
- networking.firewall.allowedTCPPorts = [
- 80
- 443
- ];
- environment.systemPackages = with pkgs; [
- xmlstarlet
- libxml2
- ];
- };
-
- testScript = ''
- engelsystem.start()
- engelsystem.wait_for_unit("phpfpm-engelsystem.service")
- engelsystem.wait_until_succeeds("curl engelsystem/login -sS -f")
- engelsystem.succeed(
- "curl engelsystem/login -sS -f -c cookie | xmllint -html -xmlout - >login"
- )
- engelsystem.succeed(
- "xml sel -T -t -m \"html/head/meta[@name='csrf-token']\" -v @content login >token"
- )
- engelsystem.succeed(
- "curl engelsystem/login -sS -f -b cookie -F 'login=admin' -F 'password=asdfasdf' -F '_token=news"
- )
- engelsystem.succeed(
- "test 'News - Engelsystem' = \"$(xml sel -T -t -c html/head/title news)\""
- )
- '';
- }
-)
+ testScript = ''
+ engelsystem.start()
+ engelsystem.wait_for_unit("phpfpm-engelsystem.service")
+ engelsystem.wait_until_succeeds("curl engelsystem/login -sS -f")
+ engelsystem.succeed(
+ "curl engelsystem/login -sS -f -c cookie | xmllint -html -xmlout - >login"
+ )
+ engelsystem.succeed(
+ "xml sel -T -t -m \"html/head/meta[@name='csrf-token']\" -v @content login >token"
+ )
+ engelsystem.succeed(
+ "curl engelsystem/login -sS -f -b cookie -F 'login=admin' -F 'password=asdfasdf' -F '_token=news"
+ )
+ engelsystem.succeed(
+ "test 'News - Engelsystem' = \"$(xml sel -T -t -c html/head/title news)\""
+ )
+ '';
+}
diff --git a/nixos/tests/enlightenment.nix b/nixos/tests/enlightenment.nix
index f2fc23685dd6..77e731feddbf 100644
--- a/nixos/tests/enlightenment.nix
+++ b/nixos/tests/enlightenment.nix
@@ -1,104 +1,102 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "enlightenment";
+{ pkgs, ... }:
+{
+ name = "enlightenment";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ romildo ];
- timeout = 600;
- # OCR tests are flaky
- broken = true;
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ romildo ];
+ timeout = 600;
+ # OCR tests are flaky
+ broken = true;
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.xserver.desktopManager.enlightenment.enable = true;
+ services.xserver.displayManager = {
+ lightdm.enable = true;
+ autoLogin = {
+ enable = true;
+ user = "alice";
+ };
+ };
+ environment.systemPackages = [ pkgs.xdotool ];
+ services.acpid.enable = true;
+ services.connman.enable = true;
+ services.connman.package = pkgs.connmanMinimal;
};
- nodes.machine =
- { ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.xserver.desktopManager.enlightenment.enable = true;
- services.xserver.displayManager = {
- lightdm.enable = true;
- autoLogin = {
- enable = true;
- user = "alice";
- };
- };
- environment.systemPackages = [ pkgs.xdotool ];
- services.acpid.enable = true;
- services.connman.enable = true;
- services.connman.package = pkgs.connmanMinimal;
- };
+ enableOCR = true;
- enableOCR = true;
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.config.users.users.alice;
+ in
+ ''
+ with subtest("Ensure x starts"):
+ machine.wait_for_x()
+ machine.wait_for_file("${user.home}/.Xauthority")
+ machine.succeed("xauth merge ${user.home}/.Xauthority")
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.config.users.users.alice;
- in
- ''
- with subtest("Ensure x starts"):
- machine.wait_for_x()
- machine.wait_for_file("${user.home}/.Xauthority")
- machine.succeed("xauth merge ${user.home}/.Xauthority")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ with subtest("First time wizard"):
+ machine.wait_for_text("Default") # Language
+ machine.screenshot("wizard1")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.screenshot("wizard2")
- with subtest("First time wizard"):
- machine.wait_for_text("Default") # Language
- machine.screenshot("wizard1")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.screenshot("wizard2")
+ machine.wait_for_text("English") # Keyboard (default)
+ machine.screenshot("wizard3")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("English") # Keyboard (default)
- machine.screenshot("wizard3")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("Standard") # Profile (default)
+ machine.screenshot("wizard4")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("Standard") # Profile (default)
- machine.screenshot("wizard4")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("Title") # Sizing (default)
+ machine.screenshot("wizard5")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("Title") # Sizing (default)
- machine.screenshot("wizard5")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("clicked") # Windows Focus
+ machine.succeed("xdotool mousemove 512 370 click 1") # Click
+ machine.screenshot("wizard6")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("clicked") # Windows Focus
- machine.succeed("xdotool mousemove 512 370 click 1") # Click
- machine.screenshot("wizard6")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("Connman") # Network Management (default)
+ machine.screenshot("wizard7")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("Connman") # Network Management (default)
- machine.screenshot("wizard7")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("BlusZ") # Bluetooth Management (default)
+ machine.screenshot("wizard8")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("BlusZ") # Bluetooth Management (default)
- machine.screenshot("wizard8")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("OpenGL") # Compositing (default)
+ machine.screenshot("wizard9")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("OpenGL") # Compositing (default)
- machine.screenshot("wizard9")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("update") # Updates
+ machine.succeed("xdotool mousemove 512 495 click 1") # Disable
+ machine.screenshot("wizard10")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("update") # Updates
- machine.succeed("xdotool mousemove 512 495 click 1") # Disable
- machine.screenshot("wizard10")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("taskbar") # Taskbar
+ machine.succeed("xdotool mousemove 480 410 click 1") # Enable
+ machine.screenshot("wizard11")
+ machine.succeed("xdotool mousemove 512 740 click 1") # Next
- machine.wait_for_text("taskbar") # Taskbar
- machine.succeed("xdotool mousemove 480 410 click 1") # Enable
- machine.screenshot("wizard11")
- machine.succeed("xdotool mousemove 512 740 click 1") # Next
+ machine.wait_for_text("Home") # The desktop
+ machine.screenshot("wizard12")
- machine.wait_for_text("Home") # The desktop
- machine.screenshot("wizard12")
-
- with subtest("Run Terminology"):
- machine.succeed("terminology >&2 &")
- machine.sleep(5)
- machine.send_chars("ls --color -alF\n")
- machine.sleep(2)
- machine.screenshot("terminology")
- '';
- }
-)
+ with subtest("Run Terminology"):
+ machine.succeed("terminology >&2 &")
+ machine.sleep(5)
+ machine.send_chars("ls --color -alF\n")
+ machine.sleep(2)
+ machine.screenshot("terminology")
+ '';
+}
diff --git a/nixos/tests/env.nix b/nixos/tests/env.nix
index 5636a423469a..6e94771b1ff1 100644
--- a/nixos/tests/env.nix
+++ b/nixos/tests/env.nix
@@ -1,49 +1,47 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "environment";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ nequissimus ];
- };
+{ pkgs, ... }:
+{
+ name = "environment";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ nequissimus ];
+ };
- nodes.machine =
- { pkgs, lib, ... }:
- lib.mkMerge [
- {
- boot.kernelPackages = pkgs.linuxPackages;
- environment.etc.plainFile.text = ''
- Hello World
- '';
- environment.etc."folder/with/file".text = ''
- Foo Bar!
- '';
+ nodes.machine =
+ { pkgs, lib, ... }:
+ lib.mkMerge [
+ {
+ boot.kernelPackages = pkgs.linuxPackages;
+ environment.etc.plainFile.text = ''
+ Hello World
+ '';
+ environment.etc."folder/with/file".text = ''
+ Foo Bar!
+ '';
- environment.sessionVariables = {
- TERMINFO_DIRS = "/run/current-system/sw/share/terminfo";
- NIXCON = "awesome";
- SHOULD_NOT_BE_SET = "oops";
- };
- }
- {
- environment.sessionVariables = {
- SHOULD_NOT_BE_SET = lib.mkForce null;
- };
- }
- ];
+ environment.sessionVariables = {
+ TERMINFO_DIRS = "/run/current-system/sw/share/terminfo";
+ NIXCON = "awesome";
+ SHOULD_NOT_BE_SET = "oops";
+ };
+ }
+ {
+ environment.sessionVariables = {
+ SHOULD_NOT_BE_SET = lib.mkForce null;
+ };
+ }
+ ];
- testScript = ''
- machine.succeed('[ -L "/etc/plainFile" ]')
- assert "Hello World" in machine.succeed('cat "/etc/plainFile"')
- machine.succeed('[ -d "/etc/folder" ]')
- machine.succeed('[ -d "/etc/folder/with" ]')
- machine.succeed('[ -L "/etc/folder/with/file" ]')
- assert "Hello World" in machine.succeed('cat "/etc/plainFile"')
+ testScript = ''
+ machine.succeed('[ -L "/etc/plainFile" ]')
+ assert "Hello World" in machine.succeed('cat "/etc/plainFile"')
+ machine.succeed('[ -d "/etc/folder" ]')
+ machine.succeed('[ -d "/etc/folder/with" ]')
+ machine.succeed('[ -L "/etc/folder/with/file" ]')
+ assert "Hello World" in machine.succeed('cat "/etc/plainFile"')
- assert "/run/current-system/sw/share/terminfo" in machine.succeed(
- "echo ''${TERMINFO_DIRS}"
- )
- assert "awesome" in machine.succeed("echo ''${NIXCON}")
- machine.fail("printenv SHOULD_NOT_BE_SET")
- '';
- }
-)
+ assert "/run/current-system/sw/share/terminfo" in machine.succeed(
+ "echo ''${TERMINFO_DIRS}"
+ )
+ assert "awesome" in machine.succeed("echo ''${NIXCON}")
+ machine.fail("printenv SHOULD_NOT_BE_SET")
+ '';
+}
diff --git a/nixos/tests/envfs.nix b/nixos/tests/envfs.nix
index b9067467eb2b..6e8ee7e55aea 100644
--- a/nixos/tests/envfs.nix
+++ b/nixos/tests/envfs.nix
@@ -1,42 +1,40 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- let
- pythonShebang = pkgs.writeScript "python-shebang" ''
- #!/usr/bin/python
- print("OK")
- '';
+{ lib, pkgs, ... }:
+let
+ pythonShebang = pkgs.writeScript "python-shebang" ''
+ #!/usr/bin/python
+ print("OK")
+ '';
- bashShebang = pkgs.writeScript "bash-shebang" ''
- #!/usr/bin/bash
- echo "OK"
- '';
- in
- {
- name = "envfs";
- nodes.machine.services.envfs.enable = true;
+ bashShebang = pkgs.writeScript "bash-shebang" ''
+ #!/usr/bin/bash
+ echo "OK"
+ '';
+in
+{
+ name = "envfs";
+ nodes.machine.services.envfs.enable = true;
- testScript = ''
- start_all()
- machine.wait_until_succeeds("mountpoint -q /usr/bin/")
- machine.succeed(
- "PATH=${pkgs.coreutils}/bin /usr/bin/cp --version",
- # check fallback paths
- "PATH= /usr/bin/sh --version",
- "PATH= /usr/bin/env --version",
- "PATH= test -e /usr/bin/sh",
- "PATH= test -e /usr/bin/env",
- # also picks up PATH that was set after execve
- "! /usr/bin/hello",
- "PATH=${pkgs.hello}/bin /usr/bin/hello",
- )
+ testScript = ''
+ start_all()
+ machine.wait_until_succeeds("mountpoint -q /usr/bin/")
+ machine.succeed(
+ "PATH=${pkgs.coreutils}/bin /usr/bin/cp --version",
+ # check fallback paths
+ "PATH= /usr/bin/sh --version",
+ "PATH= /usr/bin/env --version",
+ "PATH= test -e /usr/bin/sh",
+ "PATH= test -e /usr/bin/env",
+ # also picks up PATH that was set after execve
+ "! /usr/bin/hello",
+ "PATH=${pkgs.hello}/bin /usr/bin/hello",
+ )
- out = machine.succeed("PATH=${pkgs.python3}/bin ${pythonShebang}")
- print(out)
- assert out == "OK\n"
+ out = machine.succeed("PATH=${pkgs.python3}/bin ${pythonShebang}")
+ print(out)
+ assert out == "OK\n"
- out = machine.succeed("PATH=${pkgs.bash}/bin ${bashShebang}")
- print(out)
- assert out == "OK\n"
- '';
- }
-)
+ out = machine.succeed("PATH=${pkgs.bash}/bin ${bashShebang}")
+ print(out)
+ assert out == "OK\n"
+ '';
+}
diff --git a/nixos/tests/ergo.nix b/nixos/tests/ergo.nix
index fadf44589906..816bec0d3ac4 100644
--- a/nixos/tests/ergo.nix
+++ b/nixos/tests/ergo.nix
@@ -1,23 +1,21 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "ergo";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ mmahut ];
- };
+{ pkgs, ... }:
+{
+ name = "ergo";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ mmahut ];
+ };
- nodes = {
- machine =
- { ... }:
- {
- services.ergo.enable = true;
- services.ergo.api.keyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf";
- };
- };
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.ergo.enable = true;
+ services.ergo.api.keyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf";
+ };
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("ergo.service")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("ergo.service")
+ '';
+}
diff --git a/nixos/tests/ergochat.nix b/nixos/tests/ergochat.nix
index 6dd9efbb2ccf..30f262bf5569 100644
--- a/nixos/tests/ergochat.nix
+++ b/nixos/tests/ergochat.nix
@@ -9,100 +9,98 @@ let
iiDir = "/tmp/irc";
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "ergochat";
- nodes =
- {
- "${server}" = {
- networking.firewall.allowedTCPPorts = [ ircPort ];
- services.ergochat = {
- enable = true;
- settings.server.motd = pkgs.writeText "ergo.motd" ''
- The default MOTD doesn't contain the word "nixos" in it.
- This one does.
- '';
- };
+{ pkgs, lib, ... }:
+{
+ name = "ergochat";
+ nodes =
+ {
+ "${server}" = {
+ networking.firewall.allowedTCPPorts = [ ircPort ];
+ services.ergochat = {
+ enable = true;
+ settings.server.motd = pkgs.writeText "ergo.motd" ''
+ The default MOTD doesn't contain the word "nixos" in it.
+ This one does.
+ '';
};
- }
- // lib.listToAttrs (
- builtins.map (
- client:
- lib.nameValuePair client {
- imports = [
- ./common/user-account.nix
- ];
+ };
+ }
+ // lib.listToAttrs (
+ builtins.map (
+ client:
+ lib.nameValuePair client {
+ imports = [
+ ./common/user-account.nix
+ ];
- systemd.services.ii = {
- requires = [ "network.target" ];
- wantedBy = [ "default.target" ];
+ systemd.services.ii = {
+ requires = [ "network.target" ];
+ wantedBy = [ "default.target" ];
- serviceConfig = {
- Type = "simple";
- ExecPreStartPre = "mkdir -p ${iiDir}";
- ExecStart = ''
- ${lib.getBin pkgs.ii}/bin/ii -n ${client} -s ${server} -i ${iiDir}
- '';
- User = "alice";
- };
+ serviceConfig = {
+ Type = "simple";
+ ExecPreStartPre = "mkdir -p ${iiDir}";
+ ExecStart = ''
+ ${lib.getBin pkgs.ii}/bin/ii -n ${client} -s ${server} -i ${iiDir}
+ '';
+ User = "alice";
};
- }
- ) clients
- );
+ };
+ }
+ ) clients
+ );
- testScript =
- let
- msg = client: "Hello, my name is ${client}";
- clientScript =
- client:
- [
- ''
- ${client}.wait_for_unit("network.target")
- ${client}.systemctl("start ii")
- ${client}.wait_for_unit("ii")
- ${client}.wait_for_file("${iiDir}/${server}/out")
- ''
- # look for the custom text in the MOTD.
- ''
- ${client}.wait_until_succeeds("grep 'nixos' ${iiDir}/${server}/out")
- ''
- # wait until first PING from server arrives before joining,
- # so we don't try it too early
- ''
- ${client}.wait_until_succeeds("grep 'PING' ${iiDir}/${server}/out")
- ''
- # join ${channel}
- ''
- ${client}.succeed("echo '/j #${channel}' > ${iiDir}/${server}/in")
- ${client}.wait_for_file("${iiDir}/${server}/#${channel}/in")
- ''
- # send a greeting
- ''
- ${client}.succeed(
- "echo '${msg client}' > ${iiDir}/${server}/#${channel}/in"
- )
- ''
- # check that all greetings arrived on all clients
- ]
- ++ builtins.map (other: ''
+ testScript =
+ let
+ msg = client: "Hello, my name is ${client}";
+ clientScript =
+ client:
+ [
+ ''
+ ${client}.wait_for_unit("network.target")
+ ${client}.systemctl("start ii")
+ ${client}.wait_for_unit("ii")
+ ${client}.wait_for_file("${iiDir}/${server}/out")
+ ''
+ # look for the custom text in the MOTD.
+ ''
+ ${client}.wait_until_succeeds("grep 'nixos' ${iiDir}/${server}/out")
+ ''
+ # wait until first PING from server arrives before joining,
+ # so we don't try it too early
+ ''
+ ${client}.wait_until_succeeds("grep 'PING' ${iiDir}/${server}/out")
+ ''
+ # join ${channel}
+ ''
+ ${client}.succeed("echo '/j #${channel}' > ${iiDir}/${server}/in")
+ ${client}.wait_for_file("${iiDir}/${server}/#${channel}/in")
+ ''
+ # send a greeting
+ ''
${client}.succeed(
- "grep '${msg other}$' ${iiDir}/${server}/#${channel}/out"
+ "echo '${msg client}' > ${iiDir}/${server}/#${channel}/in"
)
- '') clients;
+ ''
+ # check that all greetings arrived on all clients
+ ]
+ ++ builtins.map (other: ''
+ ${client}.succeed(
+ "grep '${msg other}$' ${iiDir}/${server}/#${channel}/out"
+ )
+ '') clients;
- # foldl', but requires a non-empty list instead of a start value
- reduce = f: list: builtins.foldl' f (builtins.head list) (builtins.tail list);
- in
- ''
- start_all()
- ${server}.systemctl("status ergochat")
- ${server}.wait_for_open_port(${toString ircPort})
+ # foldl', but requires a non-empty list instead of a start value
+ reduce = f: list: builtins.foldl' f (builtins.head list) (builtins.tail list);
+ in
+ ''
+ start_all()
+ ${server}.systemctl("status ergochat")
+ ${server}.wait_for_open_port(${toString ircPort})
- # run clientScript for all clients so that every list
- # entry is executed by every client before advancing
- # to the next one.
- ''
- + lib.concatStrings (reduce (lib.zipListsWith (cs: c: cs + c)) (builtins.map clientScript clients));
- }
-)
+ # run clientScript for all clients so that every list
+ # entry is executed by every client before advancing
+ # to the next one.
+ ''
+ + lib.concatStrings (reduce (lib.zipListsWith (cs: c: cs + c)) (builtins.map clientScript clients));
+}
diff --git a/nixos/tests/eris-server.nix b/nixos/tests/eris-server.nix
index 795be7f5086c..55d02c1a9803 100644
--- a/nixos/tests/eris-server.nix
+++ b/nixos/tests/eris-server.nix
@@ -1,29 +1,27 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "eris-server";
- meta.maintainers = with lib.maintainers; [ ehmry ];
+{ pkgs, lib, ... }:
+{
+ name = "eris-server";
+ meta.maintainers = with lib.maintainers; [ ehmry ];
- nodes.server = {
- environment.systemPackages = [
- pkgs.eris-go
- pkgs.eriscmd
- ];
- services.eris-server = {
- enable = true;
- decode = true;
- listenHttp = "[::1]:80";
- backends = [ "badger+file:///var/cache/eris.badger?get&put" ];
- mountpoint = "/eris";
- };
+ nodes.server = {
+ environment.systemPackages = [
+ pkgs.eris-go
+ pkgs.eriscmd
+ ];
+ services.eris-server = {
+ enable = true;
+ decode = true;
+ listenHttp = "[::1]:80";
+ backends = [ "badger+file:///var/cache/eris.badger?get&put" ];
+ mountpoint = "/eris";
};
+ };
- testScript = ''
- start_all()
- server.wait_for_unit("eris-server.service")
- server.wait_for_open_port(5683)
- server.wait_for_open_port(80)
- server.succeed("eriscmd get http://[::1] $(echo 'Hail ERIS!' | eriscmd put coap+tcp://[::1]:5683)")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ server.wait_for_unit("eris-server.service")
+ server.wait_for_open_port(5683)
+ server.wait_for_open_port(80)
+ server.succeed("eriscmd get http://[::1] $(echo 'Hail ERIS!' | eriscmd put coap+tcp://[::1]:5683)")
+ '';
+}
diff --git a/nixos/tests/esphome.nix b/nixos/tests/esphome.nix
index 4fe0a9303ce8..8a84213f971d 100644
--- a/nixos/tests/esphome.nix
+++ b/nixos/tests/esphome.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- testPort = 6052;
- unixSocket = "/run/esphome/esphome.sock";
- in
- {
- name = "esphome";
- meta.maintainers = with lib.maintainers; [ oddlama ];
+let
+ testPort = 6052;
+ unixSocket = "/run/esphome/esphome.sock";
+in
+{
+ name = "esphome";
+ meta.maintainers = with lib.maintainers; [ oddlama ];
- nodes = {
- esphomeTcp =
- { ... }:
- {
- services.esphome = {
- enable = true;
- port = testPort;
- address = "0.0.0.0";
- openFirewall = true;
- };
+ nodes = {
+ esphomeTcp =
+ { ... }:
+ {
+ services.esphome = {
+ enable = true;
+ port = testPort;
+ address = "0.0.0.0";
+ openFirewall = true;
};
+ };
- esphomeUnix =
- { ... }:
- {
- services.esphome = {
- enable = true;
- enableUnixSocket = true;
- };
+ esphomeUnix =
+ { ... }:
+ {
+ services.esphome = {
+ enable = true;
+ enableUnixSocket = true;
};
- };
+ };
+ };
- testScript = ''
- esphomeTcp.wait_for_unit("esphome.service")
- esphomeTcp.wait_for_open_port(${toString testPort})
- esphomeTcp.succeed("curl --fail http://localhost:${toString testPort}/")
+ testScript = ''
+ esphomeTcp.wait_for_unit("esphome.service")
+ esphomeTcp.wait_for_open_port(${toString testPort})
+ esphomeTcp.succeed("curl --fail http://localhost:${toString testPort}/")
- esphomeUnix.wait_for_unit("esphome.service")
- esphomeUnix.wait_for_file("${unixSocket}")
- esphomeUnix.succeed("curl --fail --unix-socket ${unixSocket} http://localhost/")
- '';
- }
-)
+ esphomeUnix.wait_for_unit("esphome.service")
+ esphomeUnix.wait_for_file("${unixSocket}")
+ esphomeUnix.succeed("curl --fail --unix-socket ${unixSocket} http://localhost/")
+ '';
+}
diff --git a/nixos/tests/etebase-server.nix b/nixos/tests/etebase-server.nix
index 110338ef8915..4d848b8b0a06 100644
--- a/nixos/tests/etebase-server.nix
+++ b/nixos/tests/etebase-server.nix
@@ -1,52 +1,50 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- dataDir = "/var/lib/foobar";
+let
+ dataDir = "/var/lib/foobar";
- in
- {
- name = "etebase-server";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ felschr ];
+in
+{
+ name = "etebase-server";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ felschr ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.etebase-server = {
+ inherit dataDir;
+ enable = true;
+ settings.global.secret_file = toString (pkgs.writeText "secret" "123456");
+ };
};
- nodes.machine =
- { pkgs, ... }:
- {
- services.etebase-server = {
- inherit dataDir;
- enable = true;
- settings.global.secret_file = toString (pkgs.writeText "secret" "123456");
- };
- };
+ testScript = ''
+ machine.wait_for_unit("etebase-server.service")
+ machine.wait_for_open_port(8001)
- testScript = ''
- machine.wait_for_unit("etebase-server.service")
- machine.wait_for_open_port(8001)
+ with subtest("Database & src-version were created"):
+ machine.wait_for_file("${dataDir}/src-version")
+ assert (
+ "${pkgs.etebase-server}"
+ in machine.succeed("cat ${dataDir}/src-version")
+ )
+ machine.wait_for_file("${dataDir}/db.sqlite3")
+ machine.wait_for_file("${dataDir}/static")
- with subtest("Database & src-version were created"):
- machine.wait_for_file("${dataDir}/src-version")
- assert (
- "${pkgs.etebase-server}"
- in machine.succeed("cat ${dataDir}/src-version")
- )
- machine.wait_for_file("${dataDir}/db.sqlite3")
- machine.wait_for_file("${dataDir}/static")
+ with subtest("Only allow access from allowed_hosts"):
+ machine.succeed("curl -sSfL http://0.0.0.0:8001/")
+ machine.fail("curl -sSfL http://127.0.0.1:8001/")
+ machine.fail("curl -sSfL http://localhost:8001/")
- with subtest("Only allow access from allowed_hosts"):
- machine.succeed("curl -sSfL http://0.0.0.0:8001/")
- machine.fail("curl -sSfL http://127.0.0.1:8001/")
- machine.fail("curl -sSfL http://localhost:8001/")
+ with subtest("Run tests"):
+ machine.succeed("etebase-server check")
+ machine.succeed("etebase-server test")
- with subtest("Run tests"):
- machine.succeed("etebase-server check")
- machine.succeed("etebase-server test")
-
- with subtest("Create superuser"):
- machine.succeed(
- "etebase-server createsuperuser --no-input --username admin --email root@localhost"
- )
- '';
- }
-)
+ with subtest("Create superuser"):
+ machine.succeed(
+ "etebase-server createsuperuser --no-input --username admin --email root@localhost"
+ )
+ '';
+}
diff --git a/nixos/tests/etesync-dav.nix b/nixos/tests/etesync-dav.nix
index c8f86a84e371..feff9030f2a9 100644
--- a/nixos/tests/etesync-dav.nix
+++ b/nixos/tests/etesync-dav.nix
@@ -1,28 +1,26 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
+{ pkgs, ... }:
+{
- name = "etesync-dav";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ _3699n ];
+ name = "etesync-dav";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ _3699n ];
+ };
+
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ environment.systemPackages = [
+ pkgs.curl
+ pkgs.etesync-dav
+ ];
};
- nodes.machine =
- { config, pkgs, ... }:
- {
- environment.systemPackages = [
- pkgs.curl
- pkgs.etesync-dav
- ];
- };
-
- testScript = ''
- machine.wait_for_unit("multi-user.target")
- machine.succeed("etesync-dav --version")
- machine.execute("etesync-dav >&2 &")
- machine.wait_for_open_port(37358)
- with subtest("Check that the web interface is accessible"):
- assert "Add User" in machine.succeed("curl -s http://localhost:37358/.web/add/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("etesync-dav --version")
+ machine.execute("etesync-dav >&2 &")
+ machine.wait_for_open_port(37358)
+ with subtest("Check that the web interface is accessible"):
+ assert "Add User" in machine.succeed("curl -s http://localhost:37358/.web/add/")
+ '';
+}
diff --git a/nixos/tests/fakeroute.nix b/nixos/tests/fakeroute.nix
index 24919d6b242c..3886b976f1c7 100644
--- a/nixos/tests/fakeroute.nix
+++ b/nixos/tests/fakeroute.nix
@@ -1,27 +1,25 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "fakeroute";
- meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+{ lib, pkgs, ... }:
+{
+ name = "fakeroute";
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
- nodes.machine =
- { ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
- services.fakeroute.enable = true;
- services.fakeroute.route = [
- "216.102.187.130"
- "4.0.1.122"
- "198.116.142.34"
- "63.199.8.242"
- ];
- environment.systemPackages = [ pkgs.traceroute ];
- };
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+ services.fakeroute.enable = true;
+ services.fakeroute.route = [
+ "216.102.187.130"
+ "4.0.1.122"
+ "198.116.142.34"
+ "63.199.8.242"
+ ];
+ environment.systemPackages = [ pkgs.traceroute ];
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("fakeroute.service")
- machine.succeed("traceroute 127.0.0.1 | grep -q 216.102.187.130")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("fakeroute.service")
+ machine.succeed("traceroute 127.0.0.1 | grep -q 216.102.187.130")
+ '';
+}
diff --git a/nixos/tests/fanout.nix b/nixos/tests/fanout.nix
index a6ee1b8120b6..8a75d51e07a6 100644
--- a/nixos/tests/fanout.nix
+++ b/nixos/tests/fanout.nix
@@ -3,36 +3,34 @@
config ? { },
pkgs ? import ../.. { inherit system config; },
}:
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "fanout";
- meta.maintainers = [ lib.maintainers.therishidesai ];
+{ lib, pkgs, ... }:
+{
+ name = "fanout";
+ meta.maintainers = [ lib.maintainers.therishidesai ];
- nodes =
- let
- cfg =
- { ... }:
- {
- services.fanout = {
- enable = true;
- fanoutDevices = 2;
- bufferSize = 8192;
- };
+ nodes =
+ let
+ cfg =
+ { ... }:
+ {
+ services.fanout = {
+ enable = true;
+ fanoutDevices = 2;
+ bufferSize = 8192;
};
- in
- {
- machine = cfg;
- };
+ };
+ in
+ {
+ machine = cfg;
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- # mDNS.
- machine.wait_for_unit("multi-user.target")
+ # mDNS.
+ machine.wait_for_unit("multi-user.target")
- machine.succeed("test -c /dev/fanout0")
- machine.succeed("test -c /dev/fanout1")
- '';
- }
-)
+ machine.succeed("test -c /dev/fanout0")
+ machine.succeed("test -c /dev/fanout1")
+ '';
+}
diff --git a/nixos/tests/fenics.nix b/nixos/tests/fenics.nix
index bf991fed9b0c..ebfff402627f 100644
--- a/nixos/tests/fenics.nix
+++ b/nixos/tests/fenics.nix
@@ -1,53 +1,51 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- fenicsScript = pkgs.writeScript "poisson.py" ''
- #!/usr/bin/env python
- from dolfin import *
+let
+ fenicsScript = pkgs.writeScript "poisson.py" ''
+ #!/usr/bin/env python
+ from dolfin import *
- mesh = UnitSquareMesh(4, 4)
- V = FunctionSpace(mesh, "Lagrange", 1)
+ mesh = UnitSquareMesh(4, 4)
+ V = FunctionSpace(mesh, "Lagrange", 1)
- def boundary(x):
- return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS
+ def boundary(x):
+ return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS
- u0 = Constant(0.0)
- bc = DirichletBC(V, u0, boundary)
+ u0 = Constant(0.0)
+ bc = DirichletBC(V, u0, boundary)
- u = TrialFunction(V)
- v = TestFunction(V)
- f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
- g = Expression("sin(5*x[0])", degree=2)
- a = inner(grad(u), grad(v))*dx
- L = f*v*dx + g*v*ds
+ u = TrialFunction(V)
+ v = TestFunction(V)
+ f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
+ g = Expression("sin(5*x[0])", degree=2)
+ a = inner(grad(u), grad(v))*dx
+ L = f*v*dx + g*v*ds
- u = Function(V)
- solve(a == L, u, bc)
- print(u)
+ u = Function(V)
+ solve(a == L, u, bc)
+ print(u)
+ '';
+in
+{
+ name = "fenics";
+ meta = {
+ maintainers = with pkgs.lib.maintainers; [ ];
+ };
+
+ nodes = {
+ fenicsnode =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ gcc
+ (python3.withPackages (ps: with ps; [ fenics ]))
+ ];
+ };
+ };
+ testScript =
+ { nodes, ... }:
+ ''
+ start_all()
+ fenicsnode.succeed("${fenicsScript}")
'';
- in
- {
- name = "fenics";
- meta = {
- maintainers = with pkgs.lib.maintainers; [ ];
- };
-
- nodes = {
- fenicsnode =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [
- gcc
- (python3.withPackages (ps: with ps; [ fenics ]))
- ];
- };
- };
- testScript =
- { nodes, ... }:
- ''
- start_all()
- fenicsnode.succeed("${fenicsScript}")
- '';
- }
-)
+}
diff --git a/nixos/tests/ferm.nix b/nixos/tests/ferm.nix
index b0a3a828384b..55781a3b5c05 100644
--- a/nixos/tests/ferm.nix
+++ b/nixos/tests/ferm.nix
@@ -1,98 +1,96 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "ferm";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ mic92 ];
- };
+{ pkgs, ... }:
+{
+ name = "ferm";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ mic92 ];
+ };
- nodes = {
- client =
- { pkgs, ... }:
- with pkgs.lib;
- {
- networking = {
- dhcpcd.enable = false;
- interfaces.eth1.ipv6.addresses = mkOverride 0 [
- {
- address = "fd00::2";
- prefixLength = 64;
- }
- ];
- interfaces.eth1.ipv4.addresses = mkOverride 0 [
- {
- address = "192.168.1.2";
- prefixLength = 24;
- }
- ];
- };
+ nodes = {
+ client =
+ { pkgs, ... }:
+ with pkgs.lib;
+ {
+ networking = {
+ dhcpcd.enable = false;
+ interfaces.eth1.ipv6.addresses = mkOverride 0 [
+ {
+ address = "fd00::2";
+ prefixLength = 64;
+ }
+ ];
+ interfaces.eth1.ipv4.addresses = mkOverride 0 [
+ {
+ address = "192.168.1.2";
+ prefixLength = 24;
+ }
+ ];
};
- server =
- { pkgs, ... }:
- with pkgs.lib;
- {
- networking = {
- dhcpcd.enable = false;
- useNetworkd = true;
- useDHCP = false;
- interfaces.eth1.ipv6.addresses = mkOverride 0 [
- {
- address = "fd00::1";
- prefixLength = 64;
- }
- ];
- interfaces.eth1.ipv4.addresses = mkOverride 0 [
- {
- address = "192.168.1.1";
- prefixLength = 24;
- }
- ];
- };
-
- services = {
- ferm.enable = true;
- ferm.config = ''
- domain (ip ip6) table filter chain INPUT {
- interface lo ACCEPT;
- proto tcp dport 8080 REJECT reject-with tcp-reset;
- }
- '';
- nginx.enable = true;
- nginx.httpConfig = ''
- server {
- listen 80;
- listen [::]:80;
- listen 8080;
- listen [::]:8080;
-
- location /status { stub_status on; }
- }
- '';
- };
+ };
+ server =
+ { pkgs, ... }:
+ with pkgs.lib;
+ {
+ networking = {
+ dhcpcd.enable = false;
+ useNetworkd = true;
+ useDHCP = false;
+ interfaces.eth1.ipv6.addresses = mkOverride 0 [
+ {
+ address = "fd00::1";
+ prefixLength = 64;
+ }
+ ];
+ interfaces.eth1.ipv4.addresses = mkOverride 0 [
+ {
+ address = "192.168.1.1";
+ prefixLength = 24;
+ }
+ ];
};
- };
- testScript = ''
- start_all()
+ services = {
+ ferm.enable = true;
+ ferm.config = ''
+ domain (ip ip6) table filter chain INPUT {
+ interface lo ACCEPT;
+ proto tcp dport 8080 REJECT reject-with tcp-reset;
+ }
+ '';
+ nginx.enable = true;
+ nginx.httpConfig = ''
+ server {
+ listen 80;
+ listen [::]:80;
+ listen 8080;
+ listen [::]:8080;
- client.systemctl("start network-online.target")
- server.systemctl("start network-online.target")
- client.wait_for_unit("network-online.target")
- server.wait_for_unit("network-online.target")
- server.wait_for_unit("ferm.service")
- server.wait_for_unit("nginx.service")
- server.wait_until_succeeds("ss -ntl | grep -q 80")
+ location /status { stub_status on; }
+ }
+ '';
+ };
+ };
+ };
- with subtest("port 80 is allowed"):
- client.succeed("curl --fail -g http://192.168.1.1:80/status")
- client.succeed("curl --fail -g http://[fd00::1]:80/status")
+ testScript = ''
+ start_all()
- with subtest("port 8080 is not allowed"):
- server.succeed("curl --fail -g http://192.168.1.1:8080/status")
- server.succeed("curl --fail -g http://[fd00::1]:8080/status")
+ client.systemctl("start network-online.target")
+ server.systemctl("start network-online.target")
+ client.wait_for_unit("network-online.target")
+ server.wait_for_unit("network-online.target")
+ server.wait_for_unit("ferm.service")
+ server.wait_for_unit("nginx.service")
+ server.wait_until_succeeds("ss -ntl | grep -q 80")
- client.fail("curl --fail -g http://192.168.1.1:8080/status")
- client.fail("curl --fail -g http://[fd00::1]:8080/status")
- '';
- }
-)
+ with subtest("port 80 is allowed"):
+ client.succeed("curl --fail -g http://192.168.1.1:80/status")
+ client.succeed("curl --fail -g http://[fd00::1]:80/status")
+
+ with subtest("port 8080 is not allowed"):
+ server.succeed("curl --fail -g http://192.168.1.1:8080/status")
+ server.succeed("curl --fail -g http://[fd00::1]:8080/status")
+
+ client.fail("curl --fail -g http://192.168.1.1:8080/status")
+ client.fail("curl --fail -g http://[fd00::1]:8080/status")
+ '';
+}
diff --git a/nixos/tests/filesender.nix b/nixos/tests/filesender.nix
index 5c4c1a738243..b81b2ab04af3 100644
--- a/nixos/tests/filesender.nix
+++ b/nixos/tests/filesender.nix
@@ -1,148 +1,146 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "filesender";
- meta = {
- maintainers = with lib.maintainers; [ nhnn ];
- broken = pkgs.stdenv.hostPlatform.isAarch64; # selenium.common.exceptions.WebDriverException: Message: Unsupported platform/architecture combination: linux/aarch64
- };
+{ pkgs, lib, ... }:
+{
+ name = "filesender";
+ meta = {
+ maintainers = with lib.maintainers; [ nhnn ];
+ broken = pkgs.stdenv.hostPlatform.isAarch64; # selenium.common.exceptions.WebDriverException: Message: Unsupported platform/architecture combination: linux/aarch64
+ };
- nodes.filesender =
- { ... }:
- let
- format = pkgs.formats.php { };
- in
- {
- networking.firewall.allowedTCPPorts = [ 80 ];
+ nodes.filesender =
+ { ... }:
+ let
+ format = pkgs.formats.php { };
+ in
+ {
+ networking.firewall.allowedTCPPorts = [ 80 ];
- services.filesender.enable = true;
- services.filesender.localDomain = "filesender";
- services.filesender.settings = {
- auth_sp_saml_authentication_source = "default";
- auth_sp_saml_uid_attribute = "uid";
- storage_filesystem_path = "/tmp";
- site_url = "http://filesender";
- force_ssl = false;
- admin = "";
- admin_email = "admin@localhost";
- email_reply_to = "noreply@localhost";
+ services.filesender.enable = true;
+ services.filesender.localDomain = "filesender";
+ services.filesender.settings = {
+ auth_sp_saml_authentication_source = "default";
+ auth_sp_saml_uid_attribute = "uid";
+ storage_filesystem_path = "/tmp";
+ site_url = "http://filesender";
+ force_ssl = false;
+ admin = "";
+ admin_email = "admin@localhost";
+ email_reply_to = "noreply@localhost";
+ };
+ services.simplesamlphp.filesender = {
+ settings = {
+ baseurlpath = "http://filesender/saml";
+ "module.enable".exampleauth = true;
};
- services.simplesamlphp.filesender = {
- settings = {
- baseurlpath = "http://filesender/saml";
- "module.enable".exampleauth = true;
- };
- authSources = {
- admin = [ "core:AdminPassword" ];
- default = format.lib.mkMixedArray [ "exampleauth:UserPass" ] {
- "user:password" = {
- uid = [ "user" ];
- cn = [ "user" ];
- mail = [ "user@nixos.org" ];
- };
+ authSources = {
+ admin = [ "core:AdminPassword" ];
+ default = format.lib.mkMixedArray [ "exampleauth:UserPass" ] {
+ "user:password" = {
+ uid = [ "user" ];
+ cn = [ "user" ];
+ mail = [ "user@nixos.org" ];
};
};
};
};
+ };
- nodes.client =
- {
- pkgs,
- nodes,
- ...
- }:
- let
- filesenderIP = (builtins.head (nodes.filesender.networking.interfaces.eth1.ipv4.addresses)).address;
- in
- {
- networking.hosts.${filesenderIP} = [ "filesender" ];
+ nodes.client =
+ {
+ pkgs,
+ nodes,
+ ...
+ }:
+ let
+ filesenderIP = (builtins.head (nodes.filesender.networking.interfaces.eth1.ipv4.addresses)).address;
+ in
+ {
+ networking.hosts.${filesenderIP} = [ "filesender" ];
- environment.systemPackages =
- let
- username = "user";
- password = "password";
- browser-test =
- pkgs.writers.writePython3Bin "browser-test"
- {
- libraries = [ pkgs.python3Packages.selenium ];
- flakeIgnore = [
- "E124"
- "E501"
- ];
- }
- ''
- from selenium.webdriver.common.by import By
- from selenium.webdriver import Firefox
- from selenium.webdriver.firefox.options import Options
- from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
- from selenium.webdriver.firefox.service import Service
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from subprocess import STDOUT
- import string
- import random
- import logging
- import time
- selenium_logger = logging.getLogger("selenium")
- selenium_logger.setLevel(logging.DEBUG)
- selenium_logger.addHandler(logging.StreamHandler())
- profile = FirefoxProfile()
- profile.set_preference("browser.download.folderList", 2)
- profile.set_preference("browser.download.manager.showWhenStarting", False)
- profile.set_preference("browser.download.dir", "/tmp/firefox")
- profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain;text/txt")
- options = Options()
- options.profile = profile
- options.add_argument('--headless')
- service = Service(log_output=STDOUT)
- driver = Firefox(options=options)
- driver.set_window_size(1024, 768)
- driver.implicitly_wait(30)
- driver.get('http://filesender/')
- wait = WebDriverWait(driver, 20)
- wait.until(EC.title_contains("FileSender"))
- driver.find_element(By.ID, "btn_logon").click()
- wait.until(EC.title_contains("Enter your username and password"))
- driver.find_element(By.ID, 'username').send_keys(
- '${username}'
- )
- driver.find_element(By.ID, 'password').send_keys(
- '${password}'
- )
- driver.find_element(By.ID, "submit_button").click()
- wait.until(EC.title_contains("FileSender"))
- wait.until(EC.presence_of_element_located((By.ID, "topmenu_logoff")))
- test_string = "".join(random.choices(string.ascii_uppercase + string.digits, k=20))
- with open("/tmp/test_file.txt", "w") as file:
- file.write(test_string)
- driver.find_element(By.ID, "files").send_keys("/tmp/test_file.txt")
- time.sleep(2)
- driver.find_element(By.CSS_SELECTOR, '.start').click()
- wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".download_link")))
- download_link = driver.find_element(By.CSS_SELECTOR, '.download_link > textarea').get_attribute('value').strip()
- driver.get(download_link)
- wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".download")))
- driver.find_element(By.CSS_SELECTOR, '.download').click()
- wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".ui-dialog-buttonset > button:nth-child(2)")))
- driver.find_element(By.CSS_SELECTOR, ".ui-dialog-buttonset > button:nth-child(2)").click()
- driver.close()
- driver.quit()
- '';
- in
- [
- pkgs.firefox-unwrapped
- pkgs.geckodriver
- browser-test
- ];
- };
+ environment.systemPackages =
+ let
+ username = "user";
+ password = "password";
+ browser-test =
+ pkgs.writers.writePython3Bin "browser-test"
+ {
+ libraries = [ pkgs.python3Packages.selenium ];
+ flakeIgnore = [
+ "E124"
+ "E501"
+ ];
+ }
+ ''
+ from selenium.webdriver.common.by import By
+ from selenium.webdriver import Firefox
+ from selenium.webdriver.firefox.options import Options
+ from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
+ from selenium.webdriver.firefox.service import Service
+ from selenium.webdriver.support.ui import WebDriverWait
+ from selenium.webdriver.support import expected_conditions as EC
+ from subprocess import STDOUT
+ import string
+ import random
+ import logging
+ import time
+ selenium_logger = logging.getLogger("selenium")
+ selenium_logger.setLevel(logging.DEBUG)
+ selenium_logger.addHandler(logging.StreamHandler())
+ profile = FirefoxProfile()
+ profile.set_preference("browser.download.folderList", 2)
+ profile.set_preference("browser.download.manager.showWhenStarting", False)
+ profile.set_preference("browser.download.dir", "/tmp/firefox")
+ profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain;text/txt")
+ options = Options()
+ options.profile = profile
+ options.add_argument('--headless')
+ service = Service(log_output=STDOUT)
+ driver = Firefox(options=options)
+ driver.set_window_size(1024, 768)
+ driver.implicitly_wait(30)
+ driver.get('http://filesender/')
+ wait = WebDriverWait(driver, 20)
+ wait.until(EC.title_contains("FileSender"))
+ driver.find_element(By.ID, "btn_logon").click()
+ wait.until(EC.title_contains("Enter your username and password"))
+ driver.find_element(By.ID, 'username').send_keys(
+ '${username}'
+ )
+ driver.find_element(By.ID, 'password').send_keys(
+ '${password}'
+ )
+ driver.find_element(By.ID, "submit_button").click()
+ wait.until(EC.title_contains("FileSender"))
+ wait.until(EC.presence_of_element_located((By.ID, "topmenu_logoff")))
+ test_string = "".join(random.choices(string.ascii_uppercase + string.digits, k=20))
+ with open("/tmp/test_file.txt", "w") as file:
+ file.write(test_string)
+ driver.find_element(By.ID, "files").send_keys("/tmp/test_file.txt")
+ time.sleep(2)
+ driver.find_element(By.CSS_SELECTOR, '.start').click()
+ wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".download_link")))
+ download_link = driver.find_element(By.CSS_SELECTOR, '.download_link > textarea').get_attribute('value').strip()
+ driver.get(download_link)
+ wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".download")))
+ driver.find_element(By.CSS_SELECTOR, '.download').click()
+ wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".ui-dialog-buttonset > button:nth-child(2)")))
+ driver.find_element(By.CSS_SELECTOR, ".ui-dialog-buttonset > button:nth-child(2)").click()
+ driver.close()
+ driver.quit()
+ '';
+ in
+ [
+ pkgs.firefox-unwrapped
+ pkgs.geckodriver
+ browser-test
+ ];
+ };
- testScript = ''
- start_all()
- filesender.wait_for_file("/run/phpfpm/filesender.sock")
- filesender.wait_for_open_port(80)
- if "If you have received an invitation to access this site as a guest" not in client.wait_until_succeeds("curl -sS -f http://filesender"):
- raise Exception("filesender returned invalid html")
- client.succeed("browser-test")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ filesender.wait_for_file("/run/phpfpm/filesender.sock")
+ filesender.wait_for_open_port(80)
+ if "If you have received an invitation to access this site as a guest" not in client.wait_until_succeeds("curl -sS -f http://filesender"):
+ raise Exception("filesender returned invalid html")
+ client.succeed("browser-test")
+ '';
+}
diff --git a/nixos/tests/firefoxpwa.nix b/nixos/tests/firefoxpwa.nix
index 546534d1f05e..0e664dfc6e49 100644
--- a/nixos/tests/firefoxpwa.nix
+++ b/nixos/tests/firefoxpwa.nix
@@ -1,41 +1,39 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "firefoxpwa";
- meta.maintainers = with lib.maintainers; [ camillemndn ];
+{
+ name = "firefoxpwa";
+ meta.maintainers = with lib.maintainers; [ camillemndn ];
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ./common/x11.nix ];
- environment.systemPackages = with pkgs; [
- firefoxpwa
- jq
- ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ./common/x11.nix ];
+ environment.systemPackages = with pkgs; [
+ firefoxpwa
+ jq
+ ];
- programs.firefox = {
- enable = true;
- nativeMessagingHosts.packages = [ pkgs.firefoxpwa ];
- };
-
- services.jellyfin.enable = true;
+ programs.firefox = {
+ enable = true;
+ nativeMessagingHosts.packages = [ pkgs.firefoxpwa ];
};
- enableOCR = true;
+ services.jellyfin.enable = true;
+ };
- testScript = ''
- machine.start()
+ enableOCR = true;
- with subtest("Install a progressive web app"):
- machine.wait_for_unit("jellyfin.service")
- machine.wait_for_open_port(8096)
- machine.succeed("firefoxpwa site install http://localhost:8096/web/manifest.json >&2")
+ testScript = ''
+ machine.start()
- with subtest("Launch the progressive web app"):
- machine.succeed("firefoxpwa site launch $(jq -r < ~/.local/share/firefoxpwa/config.json '.sites | keys[0]') >&2")
- machine.wait_for_window("Jellyfin")
- machine.wait_for_text("Jellyfin")
- '';
- }
-)
+ with subtest("Install a progressive web app"):
+ machine.wait_for_unit("jellyfin.service")
+ machine.wait_for_open_port(8096)
+ machine.succeed("firefoxpwa site install http://localhost:8096/web/manifest.json >&2")
+
+ with subtest("Launch the progressive web app"):
+ machine.succeed("firefoxpwa site launch $(jq -r < ~/.local/share/firefoxpwa/config.json '.sites | keys[0]') >&2")
+ machine.wait_for_window("Jellyfin")
+ machine.wait_for_text("Jellyfin")
+ '';
+}
diff --git a/nixos/tests/firejail.nix b/nixos/tests/firejail.nix
index 24ec4dbe2a7e..6ac163ba0678 100644
--- a/nixos/tests/firejail.nix
+++ b/nixos/tests/firejail.nix
@@ -1,95 +1,93 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "firejail";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ sgo ];
- };
+{ pkgs, ... }:
+{
+ name = "firejail";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ sgo ];
+ };
- nodes.machine =
- { ... }:
- {
- imports = [ ./common/user-account.nix ];
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ./common/user-account.nix ];
- programs.firejail = {
- enable = true;
- wrappedBinaries = {
- bash-jailed = "${pkgs.bash}/bin/bash";
- bash-jailed2 = {
- executable = "${pkgs.bash}/bin/bash";
- extraArgs = [ "--private=~/firejail-home" ];
- };
+ programs.firejail = {
+ enable = true;
+ wrappedBinaries = {
+ bash-jailed = "${pkgs.bash}/bin/bash";
+ bash-jailed2 = {
+ executable = "${pkgs.bash}/bin/bash";
+ extraArgs = [ "--private=~/firejail-home" ];
};
};
-
- systemd.services.setupFirejailTest = {
- wantedBy = [ "multi-user.target" ];
- before = [ "multi-user.target" ];
-
- environment = {
- HOME = "/home/alice";
- };
-
- unitConfig = {
- type = "oneshot";
- RemainAfterExit = true;
- user = "alice";
- };
-
- script = ''
- cd $HOME
-
- mkdir .password-store && echo s3cret > .password-store/secret
- mkdir my-secrets && echo s3cret > my-secrets/secret
-
- echo publ1c > public
-
- mkdir -p .config/firejail
- echo 'blacklist ''${HOME}/my-secrets' > .config/firejail/globals.local
- '';
- };
};
- testScript = ''
- start_all()
- machine.wait_for_unit("multi-user.target")
+ systemd.services.setupFirejailTest = {
+ wantedBy = [ "multi-user.target" ];
+ before = [ "multi-user.target" ];
- # Test path acl with wrapper
- machine.succeed("sudo -u alice bash-jailed -c 'cat ~/public' | grep -q publ1c")
- machine.fail(
- "sudo -u alice bash-jailed -c 'cat ~/.password-store/secret' | grep -q s3cret"
- )
- machine.fail("sudo -u alice bash-jailed -c 'cat ~/my-secrets/secret' | grep -q s3cret")
+ environment = {
+ HOME = "/home/alice";
+ };
- # Test extraArgs
- machine.succeed("sudo -u alice mkdir /home/alice/firejail-home")
- machine.succeed("sudo -u alice bash-jailed2 -c 'echo test > /home/alice/foo'")
- machine.fail("sudo -u alice cat /home/alice/foo")
- machine.succeed("sudo -u alice cat /home/alice/firejail-home/foo | grep test")
+ unitConfig = {
+ type = "oneshot";
+ RemainAfterExit = true;
+ user = "alice";
+ };
- # Test path acl with firejail executable
- machine.succeed("sudo -u alice firejail -- bash -c 'cat ~/public' | grep -q publ1c")
- machine.fail(
- "sudo -u alice firejail -- bash -c 'cat ~/.password-store/secret' | grep -q s3cret"
- )
- machine.fail(
- "sudo -u alice firejail -- bash -c 'cat ~/my-secrets/secret' | grep -q s3cret"
- )
+ script = ''
+ cd $HOME
- # Disabling profiles
- machine.succeed(
- "sudo -u alice bash -c 'firejail --noprofile -- cat ~/.password-store/secret' | grep -q s3cret"
- )
+ mkdir .password-store && echo s3cret > .password-store/secret
+ mkdir my-secrets && echo s3cret > my-secrets/secret
- # CVE-2020-17367
- machine.fail(
- "sudo -u alice firejail --private-tmp id --output=/tmp/vuln1 && cat /tmp/vuln1"
- )
+ echo publ1c > public
- # CVE-2020-17368
- machine.fail(
- "sudo -u alice firejail --private-tmp --output=/tmp/foo 'bash -c $(id>/tmp/vuln2;echo id)' && cat /tmp/vuln2"
- )
- '';
- }
-)
+ mkdir -p .config/firejail
+ echo 'blacklist ''${HOME}/my-secrets' > .config/firejail/globals.local
+ '';
+ };
+ };
+
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+
+ # Test path acl with wrapper
+ machine.succeed("sudo -u alice bash-jailed -c 'cat ~/public' | grep -q publ1c")
+ machine.fail(
+ "sudo -u alice bash-jailed -c 'cat ~/.password-store/secret' | grep -q s3cret"
+ )
+ machine.fail("sudo -u alice bash-jailed -c 'cat ~/my-secrets/secret' | grep -q s3cret")
+
+ # Test extraArgs
+ machine.succeed("sudo -u alice mkdir /home/alice/firejail-home")
+ machine.succeed("sudo -u alice bash-jailed2 -c 'echo test > /home/alice/foo'")
+ machine.fail("sudo -u alice cat /home/alice/foo")
+ machine.succeed("sudo -u alice cat /home/alice/firejail-home/foo | grep test")
+
+ # Test path acl with firejail executable
+ machine.succeed("sudo -u alice firejail -- bash -c 'cat ~/public' | grep -q publ1c")
+ machine.fail(
+ "sudo -u alice firejail -- bash -c 'cat ~/.password-store/secret' | grep -q s3cret"
+ )
+ machine.fail(
+ "sudo -u alice firejail -- bash -c 'cat ~/my-secrets/secret' | grep -q s3cret"
+ )
+
+ # Disabling profiles
+ machine.succeed(
+ "sudo -u alice bash -c 'firejail --noprofile -- cat ~/.password-store/secret' | grep -q s3cret"
+ )
+
+ # CVE-2020-17367
+ machine.fail(
+ "sudo -u alice firejail --private-tmp id --output=/tmp/vuln1 && cat /tmp/vuln1"
+ )
+
+ # CVE-2020-17368
+ machine.fail(
+ "sudo -u alice firejail --private-tmp --output=/tmp/foo 'bash -c $(id>/tmp/vuln2;echo id)' && cat /tmp/vuln2"
+ )
+ '';
+}
diff --git a/nixos/tests/firezone/firezone.nix b/nixos/tests/firezone/firezone.nix
index 10d89778a4c6..82b05b47086c 100644
--- a/nixos/tests/firezone/firezone.nix
+++ b/nixos/tests/firezone/firezone.nix
@@ -1,349 +1,347 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
- certs = import ../common/acme/server/snakeoil-certs.nix;
- domain = certs.domain;
- in
- {
- name = "firezone";
- meta.maintainers = with pkgs.lib.maintainers; [ oddlama ];
+{ pkgs, ... }:
+let
+ certs = import ../common/acme/server/snakeoil-certs.nix;
+ domain = certs.domain;
+in
+{
+ name = "firezone";
+ meta.maintainers = with pkgs.lib.maintainers; [ oddlama ];
- nodes = {
- server =
- {
- config,
- lib,
- pkgs,
- ...
- }:
- {
- security.pki.certificateFiles = [ certs.ca.cert ];
+ nodes = {
+ server =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ security.pki.certificateFiles = [ certs.ca.cert ];
- networking.extraHosts = ''
- ${config.networking.primaryIPAddress} ${domain}
- ${config.networking.primaryIPv6Address} ${domain}
- '';
+ networking.extraHosts = ''
+ ${config.networking.primaryIPAddress} ${domain}
+ ${config.networking.primaryIPv6Address} ${domain}
+ '';
- networking.firewall.allowedTCPPorts = [
- 80
- 443
- ];
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
+ ];
- services.nginx = {
- enable = true;
- virtualHosts.${domain} = {
- sslCertificate = certs.${domain}.cert;
- sslCertificateKey = certs.${domain}.key;
- };
+ services.nginx = {
+ enable = true;
+ virtualHosts.${domain} = {
+ sslCertificate = certs.${domain}.cert;
+ sslCertificateKey = certs.${domain}.key;
+ };
+ };
+
+ services.firezone.server = {
+ enable = true;
+ enableLocalDB = true;
+ nginx.enable = true;
+
+ # Doesn't need to work for this test, but needs to be configured
+ # otherwise the server will not start.
+ smtp = {
+ from = "firezone@example.com";
+ host = "mail.localhost";
+ port = 465;
+ implicitTls = true;
+ username = "firezone@example.com";
+ passwordFile = pkgs.writeText "tmpmailpasswd" "supermailpassword";
};
- services.firezone.server = {
+ provision = {
enable = true;
- enableLocalDB = true;
- nginx.enable = true;
-
- # Doesn't need to work for this test, but needs to be configured
- # otherwise the server will not start.
- smtp = {
- from = "firezone@example.com";
- host = "mail.localhost";
- port = 465;
- implicitTls = true;
- username = "firezone@example.com";
- passwordFile = pkgs.writeText "tmpmailpasswd" "supermailpassword";
- };
-
- provision = {
- enable = true;
- accounts.main = {
- name = "My Account";
- relayGroups.my-relays.name = "Relays";
- gatewayGroups.site.name = "Site";
- actors = {
- admin = {
- type = "account_admin_user";
- name = "Admin";
- email = "admin@example.com";
- };
- client = {
- type = "service_account";
- name = "A client";
- email = "client@example.com";
- };
+ accounts.main = {
+ name = "My Account";
+ relayGroups.my-relays.name = "Relays";
+ gatewayGroups.site.name = "Site";
+ actors = {
+ admin = {
+ type = "account_admin_user";
+ name = "Admin";
+ email = "admin@example.com";
};
- resources.res1 = {
- type = "dns";
- name = "Dns Resource";
- address = "resource.example.com";
- gatewayGroups = [ "site" ];
- filters = [
- { protocol = "icmp"; }
- {
- protocol = "tcp";
- ports = [ 80 ];
- }
- ];
- };
- resources.res2 = {
- type = "ip";
- name = "Ip Resource";
- address = "172.20.2.1";
- gatewayGroups = [ "site" ];
- };
- resources.res3 = {
- type = "cidr";
- name = "Cidr Resource";
- address = "172.20.1.0/24";
- gatewayGroups = [ "site" ];
- };
- policies.pol1 = {
- description = "Allow anyone res1 access";
- group = "everyone";
- resource = "res1";
- };
- policies.pol2 = {
- description = "Allow anyone res2 access";
- group = "everyone";
- resource = "res2";
- };
- policies.pol3 = {
- description = "Allow anyone res3 access";
- group = "everyone";
- resource = "res3";
+ client = {
+ type = "service_account";
+ name = "A client";
+ email = "client@example.com";
};
};
+ resources.res1 = {
+ type = "dns";
+ name = "Dns Resource";
+ address = "resource.example.com";
+ gatewayGroups = [ "site" ];
+ filters = [
+ { protocol = "icmp"; }
+ {
+ protocol = "tcp";
+ ports = [ 80 ];
+ }
+ ];
+ };
+ resources.res2 = {
+ type = "ip";
+ name = "Ip Resource";
+ address = "172.20.2.1";
+ gatewayGroups = [ "site" ];
+ };
+ resources.res3 = {
+ type = "cidr";
+ name = "Cidr Resource";
+ address = "172.20.1.0/24";
+ gatewayGroups = [ "site" ];
+ };
+ policies.pol1 = {
+ description = "Allow anyone res1 access";
+ group = "everyone";
+ resource = "res1";
+ };
+ policies.pol2 = {
+ description = "Allow anyone res2 access";
+ group = "everyone";
+ resource = "res2";
+ };
+ policies.pol3 = {
+ description = "Allow anyone res3 access";
+ group = "everyone";
+ resource = "res3";
+ };
};
-
- api.externalUrl = "https://${domain}/api/";
- web.externalUrl = "https://${domain}/";
};
- systemd.services.firezone-server-domain.postStart = lib.mkAfter ''
- ${lib.getExe config.services.firezone.server.domain.package} rpc 'Code.eval_file("${./create-tokens.exs}")'
- '';
+ api.externalUrl = "https://${domain}/api/";
+ web.externalUrl = "https://${domain}/";
};
- relay =
- {
- nodes,
- config,
- lib,
- ...
- }:
- {
- security.pki.certificateFiles = [ certs.ca.cert ];
- networking.extraHosts = ''
- ${nodes.server.networking.primaryIPAddress} ${domain}
- ${nodes.server.networking.primaryIPv6Address} ${domain}
- '';
+ systemd.services.firezone-server-domain.postStart = lib.mkAfter ''
+ ${lib.getExe config.services.firezone.server.domain.package} rpc 'Code.eval_file("${./create-tokens.exs}")'
+ '';
+ };
- services.firezone.relay = {
- enable = true;
- logLevel = "debug";
- name = "test-relay";
- apiUrl = "wss://${domain}/api/";
- tokenFile = "/tmp/shared/relay_token.txt";
- publicIpv4 = config.networking.primaryIPAddress;
- publicIpv6 = config.networking.primaryIPv6Address;
- openFirewall = true;
+ relay =
+ {
+ nodes,
+ config,
+ lib,
+ ...
+ }:
+ {
+ security.pki.certificateFiles = [ certs.ca.cert ];
+ networking.extraHosts = ''
+ ${nodes.server.networking.primaryIPAddress} ${domain}
+ ${nodes.server.networking.primaryIPv6Address} ${domain}
+ '';
+
+ services.firezone.relay = {
+ enable = true;
+ logLevel = "debug";
+ name = "test-relay";
+ apiUrl = "wss://${domain}/api/";
+ tokenFile = "/tmp/shared/relay_token.txt";
+ publicIpv4 = config.networking.primaryIPAddress;
+ publicIpv6 = config.networking.primaryIPv6Address;
+ openFirewall = true;
+ };
+
+ # Don't auto-start so we can wait until the token was provisioned
+ systemd.services.firezone-relay.wantedBy = lib.mkForce [ ];
+ };
+
+ # A resource that is only connected to the gateway,
+ # allowing us to confirm the VPN works
+ resource = {
+ virtualisation.vlans = [
+ 1
+ 2
+ ];
+
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "172.20.1.1";
+ prefixLength = 24;
+ }
+ ];
+
+ networking.interfaces.eth2.ipv4.addresses = [
+ {
+ address = "172.20.2.1";
+ prefixLength = 24;
+ }
+ ];
+
+ networking.firewall.allowedTCPPorts = [
+ 80
+ ];
+
+ services.nginx = {
+ enable = true;
+ virtualHosts = {
+ "localhost" = {
+ default = true;
+ locations."/".extraConfig = ''
+ return 200 'greetings from the resource';
+ add_header Content-Type text/plain;
+ '';
};
-
- # Don't auto-start so we can wait until the token was provisioned
- systemd.services.firezone-relay.wantedBy = lib.mkForce [ ];
};
+ };
+ };
- # A resource that is only connected to the gateway,
- # allowing us to confirm the VPN works
- resource = {
+ gateway =
+ {
+ nodes,
+ lib,
+ ...
+ }:
+ {
virtualisation.vlans = [
1
2
];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "172.20.1.1";
- prefixLength = 24;
- }
- ];
-
- networking.interfaces.eth2.ipv4.addresses = [
- {
- address = "172.20.2.1";
- prefixLength = 24;
- }
- ];
-
- networking.firewall.allowedTCPPorts = [
- 80
- ];
-
- services.nginx = {
- enable = true;
- virtualHosts = {
- "localhost" = {
- default = true;
- locations."/".extraConfig = ''
- return 200 'greetings from the resource';
- add_header Content-Type text/plain;
- '';
- };
- };
- };
- };
-
- gateway =
- {
- nodes,
- lib,
- ...
- }:
- {
- virtualisation.vlans = [
- 1
- 2
+ networking = {
+ interfaces.eth1.ipv4.addresses = [
+ {
+ address = "172.20.1.2";
+ prefixLength = 24;
+ }
];
- networking = {
- interfaces.eth1.ipv4.addresses = [
- {
- address = "172.20.1.2";
- prefixLength = 24;
- }
- ];
+ interfaces.eth2.ipv4.addresses = [
+ {
+ address = "172.20.2.2";
+ prefixLength = 24;
+ }
+ ];
- interfaces.eth2.ipv4.addresses = [
- {
- address = "172.20.2.2";
- prefixLength = 24;
- }
- ];
+ firewall.enable = false;
+ nftables.enable = true;
+ nftables.tables."filter".family = "inet";
+ nftables.tables."filter".content = ''
+ chain incoming {
+ type filter hook input priority 0; policy accept;
+ }
- firewall.enable = false;
- nftables.enable = true;
- nftables.tables."filter".family = "inet";
- nftables.tables."filter".content = ''
- chain incoming {
- type filter hook input priority 0; policy accept;
- }
+ chain postrouting {
+ type nat hook postrouting priority srcnat; policy accept;
+ meta protocol ip iifname "tun-firezone" oifname { "eth1", "eth2" } masquerade random
+ }
- chain postrouting {
- type nat hook postrouting priority srcnat; policy accept;
- meta protocol ip iifname "tun-firezone" oifname { "eth1", "eth2" } masquerade random
- }
+ chain forward {
+ type filter hook forward priority 0; policy drop;
+ iifname "tun-firezone" accept
+ oifname "tun-firezone" accept
+ }
- chain forward {
- type filter hook forward priority 0; policy drop;
- iifname "tun-firezone" accept
- oifname "tun-firezone" accept
- }
-
- chain output {
- type filter hook output priority 0; policy accept;
- }
- '';
- };
-
- boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
- # boot.kernel.sysctl."net.ipv4.conf.all.src_valid_mark" = "1";
- boot.kernel.sysctl."net.ipv6.conf.default.forwarding" = "1";
- boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = "1";
-
- security.pki.certificateFiles = [ certs.ca.cert ];
- networking.extraHosts = ''
- ${nodes.server.networking.primaryIPAddress} ${domain}
- ${nodes.server.networking.primaryIPv6Address} ${domain}
- 172.20.1.1 resource.example.com
+ chain output {
+ type filter hook output priority 0; policy accept;
+ }
'';
-
- services.firezone.gateway = {
- enable = true;
- logLevel = "debug";
- name = "test-gateway";
- apiUrl = "wss://${domain}/api/";
- tokenFile = "/tmp/shared/gateway_token.txt";
- };
-
- # Don't auto-start so we can wait until the token was provisioned
- systemd.services.firezone-gateway.wantedBy = lib.mkForce [ ];
};
- client =
- {
- nodes,
- lib,
- ...
- }:
- {
- security.pki.certificateFiles = [ certs.ca.cert ];
- networking.useNetworkd = true;
- networking.extraHosts = ''
- ${nodes.server.networking.primaryIPAddress} ${domain}
- ${nodes.server.networking.primaryIPv6Address} ${domain}
- '';
+ boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
+ # boot.kernel.sysctl."net.ipv4.conf.all.src_valid_mark" = "1";
+ boot.kernel.sysctl."net.ipv6.conf.default.forwarding" = "1";
+ boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = "1";
- services.firezone.headless-client = {
- enable = true;
- logLevel = "debug";
- name = "test-client-somebody";
- apiUrl = "wss://${domain}/api/";
- tokenFile = "/tmp/shared/client_token.txt";
- };
+ security.pki.certificateFiles = [ certs.ca.cert ];
+ networking.extraHosts = ''
+ ${nodes.server.networking.primaryIPAddress} ${domain}
+ ${nodes.server.networking.primaryIPv6Address} ${domain}
+ 172.20.1.1 resource.example.com
+ '';
- # Don't auto-start so we can wait until the token was provisioned
- systemd.services.firezone-headless-client.wantedBy = lib.mkForce [ ];
+ services.firezone.gateway = {
+ enable = true;
+ logLevel = "debug";
+ name = "test-gateway";
+ apiUrl = "wss://${domain}/api/";
+ tokenFile = "/tmp/shared/gateway_token.txt";
};
- };
- testScript =
- { ... }:
- ''
- start_all()
+ # Don't auto-start so we can wait until the token was provisioned
+ systemd.services.firezone-gateway.wantedBy = lib.mkForce [ ];
+ };
- with subtest("Start server"):
- server.wait_for_unit("firezone.target")
- server.wait_until_succeeds("curl -Lsf https://${domain} | grep 'Welcome to Firezone'")
- server.wait_until_succeeds("curl -Ls https://${domain}/api | grep 'Not Found'")
+ client =
+ {
+ nodes,
+ lib,
+ ...
+ }:
+ {
+ security.pki.certificateFiles = [ certs.ca.cert ];
+ networking.useNetworkd = true;
+ networking.extraHosts = ''
+ ${nodes.server.networking.primaryIPAddress} ${domain}
+ ${nodes.server.networking.primaryIPv6Address} ${domain}
+ '';
- # Wait for tokens and copy them to shared folder
- server.wait_for_file("/var/lib/private/firezone/relay_token.txt")
- server.wait_for_file("/var/lib/private/firezone/gateway_token.txt")
- server.wait_for_file("/var/lib/private/firezone/client_token.txt")
- server.succeed("cp /var/lib/private/firezone/*_token.txt /tmp/shared")
+ services.firezone.headless-client = {
+ enable = true;
+ logLevel = "debug";
+ name = "test-client-somebody";
+ apiUrl = "wss://${domain}/api/";
+ tokenFile = "/tmp/shared/client_token.txt";
+ };
- with subtest("Connect relay"):
- relay.succeed("systemctl start firezone-relay")
- relay.wait_for_unit("firezone-relay.service")
- relay.wait_until_succeeds("journalctl --since -2m --unit firezone-relay.service --grep 'Connected to portal.*${domain}'", timeout=30)
+ # Don't auto-start so we can wait until the token was provisioned
+ systemd.services.firezone-headless-client.wantedBy = lib.mkForce [ ];
+ };
+ };
- with subtest("Connect gateway"):
- gateway.succeed("systemctl start firezone-gateway")
- gateway.wait_for_unit("firezone-gateway.service")
- gateway.wait_until_succeeds("journalctl --since -2m --unit firezone-gateway.service --grep 'Connected to portal.*${domain}'", timeout=30)
- relay.wait_until_succeeds("journalctl --since -2m --unit firezone-relay.service --grep 'Created allocation.*IPv4'", timeout=30)
- relay.wait_until_succeeds("journalctl --since -2m --unit firezone-relay.service --grep 'Created allocation.*IPv6'", timeout=30)
+ testScript =
+ { ... }:
+ ''
+ start_all()
- # Assert both relay ips are known
- gateway.wait_until_succeeds("journalctl --since -2m --unit firezone-gateway.service --grep 'Updated allocation.*relay_ip4.*Some.*relay_ip6.*Some'", timeout=30)
+ with subtest("Start server"):
+ server.wait_for_unit("firezone.target")
+ server.wait_until_succeeds("curl -Lsf https://${domain} | grep 'Welcome to Firezone'")
+ server.wait_until_succeeds("curl -Ls https://${domain}/api | grep 'Not Found'")
- with subtest("Connect headless-client"):
- client.succeed("systemctl start firezone-headless-client")
- client.wait_for_unit("firezone-headless-client.service")
- client.wait_until_succeeds("journalctl --since -2m --unit firezone-headless-client.service --grep 'Connected to portal.*${domain}'", timeout=30)
- client.wait_until_succeeds("journalctl --since -2m --unit firezone-headless-client.service --grep 'Tunnel ready'", timeout=30)
+ # Wait for tokens and copy them to shared folder
+ server.wait_for_file("/var/lib/private/firezone/relay_token.txt")
+ server.wait_for_file("/var/lib/private/firezone/gateway_token.txt")
+ server.wait_for_file("/var/lib/private/firezone/client_token.txt")
+ server.succeed("cp /var/lib/private/firezone/*_token.txt /tmp/shared")
- with subtest("Check DNS based access"):
- # Check that we can access the resource through the VPN via DNS
- client.wait_until_succeeds("curl -4 -Lsf http://resource.example.com | grep 'greetings from the resource'")
- client.wait_until_succeeds("curl -6 -Lsf http://resource.example.com | grep 'greetings from the resource'")
+ with subtest("Connect relay"):
+ relay.succeed("systemctl start firezone-relay")
+ relay.wait_for_unit("firezone-relay.service")
+ relay.wait_until_succeeds("journalctl --since -2m --unit firezone-relay.service --grep 'Connected to portal.*${domain}'", timeout=30)
- with subtest("Check CIDR based access"):
- # Check that we can access the resource through the VPN via CIDR
- client.wait_until_succeeds("ping -c1 -W1 172.20.1.1")
+ with subtest("Connect gateway"):
+ gateway.succeed("systemctl start firezone-gateway")
+ gateway.wait_for_unit("firezone-gateway.service")
+ gateway.wait_until_succeeds("journalctl --since -2m --unit firezone-gateway.service --grep 'Connected to portal.*${domain}'", timeout=30)
+ relay.wait_until_succeeds("journalctl --since -2m --unit firezone-relay.service --grep 'Created allocation.*IPv4'", timeout=30)
+ relay.wait_until_succeeds("journalctl --since -2m --unit firezone-relay.service --grep 'Created allocation.*IPv6'", timeout=30)
- with subtest("Check IP based access"):
- # Check that we can access the resource through the VPN via IP
- client.wait_until_succeeds("ping -c1 -W1 172.20.2.1")
- '';
- }
-)
+ # Assert both relay ips are known
+ gateway.wait_until_succeeds("journalctl --since -2m --unit firezone-gateway.service --grep 'Updated allocation.*relay_ip4.*Some.*relay_ip6.*Some'", timeout=30)
+
+ with subtest("Connect headless-client"):
+ client.succeed("systemctl start firezone-headless-client")
+ client.wait_for_unit("firezone-headless-client.service")
+ client.wait_until_succeeds("journalctl --since -2m --unit firezone-headless-client.service --grep 'Connected to portal.*${domain}'", timeout=30)
+ client.wait_until_succeeds("journalctl --since -2m --unit firezone-headless-client.service --grep 'Tunnel ready'", timeout=30)
+
+ with subtest("Check DNS based access"):
+ # Check that we can access the resource through the VPN via DNS
+ client.wait_until_succeeds("curl -4 -Lsf http://resource.example.com | grep 'greetings from the resource'")
+ client.wait_until_succeeds("curl -6 -Lsf http://resource.example.com | grep 'greetings from the resource'")
+
+ with subtest("Check CIDR based access"):
+ # Check that we can access the resource through the VPN via CIDR
+ client.wait_until_succeeds("ping -c1 -W1 172.20.1.1")
+
+ with subtest("Check IP based access"):
+ # Check that we can access the resource through the VPN via IP
+ client.wait_until_succeeds("ping -c1 -W1 172.20.2.1")
+ '';
+}
diff --git a/nixos/tests/flaresolverr.nix b/nixos/tests/flaresolverr.nix
index 0cec7adf6d6b..dc92e03a0a60 100644
--- a/nixos/tests/flaresolverr.nix
+++ b/nixos/tests/flaresolverr.nix
@@ -1,22 +1,20 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "flaresolverr";
- meta.maintainers = with lib.maintainers; [ paveloom ];
+{ lib, ... }:
+{
+ name = "flaresolverr";
+ meta.maintainers = with lib.maintainers; [ paveloom ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.flaresolverr = {
- enable = true;
- port = 8888;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.flaresolverr = {
+ enable = true;
+ port = 8888;
};
+ };
- testScript = ''
- machine.wait_for_unit("flaresolverr.service")
- machine.wait_for_open_port(8888)
- machine.succeed("curl --fail http://localhost:8888/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("flaresolverr.service")
+ machine.wait_for_open_port(8888)
+ machine.succeed("curl --fail http://localhost:8888/")
+ '';
+}
diff --git a/nixos/tests/flood.nix b/nixos/tests/flood.nix
index ca3ef1d919a5..c474f5efeefb 100644
--- a/nixos/tests/flood.nix
+++ b/nixos/tests/flood.nix
@@ -1,32 +1,30 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- port = 3001;
- in
- {
- name = "flood";
- meta = {
- maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
+{ pkgs, ... }:
+let
+ port = 3001;
+in
+{
+ name = "flood";
+ meta = {
+ maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.flood = {
+ inherit port;
+ enable = true;
+ openFirewall = true;
+ extraArgs = [ "--baseuri=/" ];
+ };
};
- nodes.machine =
- { pkgs, ... }:
- {
- services.flood = {
- inherit port;
- enable = true;
- openFirewall = true;
- extraArgs = [ "--baseuri=/" ];
- };
- };
+ testScript = # python
+ ''
+ machine.start()
+ machine.wait_for_unit("flood.service")
+ machine.wait_for_open_port(${toString port})
- testScript = # python
- ''
- machine.start()
- machine.wait_for_unit("flood.service")
- machine.wait_for_open_port(${toString port})
-
- machine.succeed("curl --fail http://localhost:${toString port}")
- '';
- }
-)
+ machine.succeed("curl --fail http://localhost:${toString port}")
+ '';
+}
diff --git a/nixos/tests/fluentd.nix b/nixos/tests/fluentd.nix
index aa56db49dc53..8f4fb6e37f0e 100644
--- a/nixos/tests/fluentd.nix
+++ b/nixos/tests/fluentd.nix
@@ -1,58 +1,56 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "fluentd";
+{ pkgs, lib, ... }:
+{
+ name = "fluentd";
- nodes.machine =
- { pkgs, ... }:
- {
- services.fluentd = {
- enable = true;
- config = ''
-
- @type http
- port 9880
-
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.fluentd = {
+ enable = true;
+ config = ''
+
+ @type http
+ port 9880
+
-
- type copy
-
- @type file
- format json
- path /tmp/fluentd
- symlink_path /tmp/current-log
-
-
- @type stdout
-
-
- '';
- };
+
+ type copy
+
+ @type file
+ format json
+ path /tmp/fluentd
+ symlink_path /tmp/current-log
+
+
+ @type stdout
+
+
+ '';
};
+ };
- testScript =
- let
- testMessage = "an example log message";
+ testScript =
+ let
+ testMessage = "an example log message";
- payload = pkgs.writeText "test-message.json" (
- builtins.toJSON {
- inherit testMessage;
- }
- );
- in
- ''
- machine.start()
- machine.wait_for_unit("fluentd.service")
- machine.wait_for_open_port(9880)
+ payload = pkgs.writeText "test-message.json" (
+ builtins.toJSON {
+ inherit testMessage;
+ }
+ );
+ in
+ ''
+ machine.start()
+ machine.wait_for_unit("fluentd.service")
+ machine.wait_for_open_port(9880)
- machine.succeed(
- "curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag"
- )
+ machine.succeed(
+ "curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag"
+ )
- # blocking flush
- machine.succeed("systemctl stop fluentd")
+ # blocking flush
+ machine.succeed("systemctl stop fluentd")
- machine.succeed("grep '${testMessage}' /tmp/current-log")
- '';
- }
-)
+ machine.succeed("grep '${testMessage}' /tmp/current-log")
+ '';
+}
diff --git a/nixos/tests/fluidd.nix b/nixos/tests/fluidd.nix
index 94463fc74e49..edfc1e8d9a49 100644
--- a/nixos/tests/fluidd.nix
+++ b/nixos/tests/fluidd.nix
@@ -1,23 +1,21 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "fluidd";
- meta.maintainers = with lib.maintainers; [ vtuan10 ];
+{
+ name = "fluidd";
+ meta.maintainers = with lib.maintainers; [ vtuan10 ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.fluidd = {
- enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.fluidd = {
+ enable = true;
};
+ };
- testScript = ''
- machine.start()
- machine.wait_for_unit("nginx.service")
- machine.wait_for_open_port(80)
- machine.succeed("curl -sSfL http://localhost/ | grep 'fluidd'")
- '';
- }
-)
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("nginx.service")
+ machine.wait_for_open_port(80)
+ machine.succeed("curl -sSfL http://localhost/ | grep 'fluidd'")
+ '';
+}
diff --git a/nixos/tests/fontconfig-default-fonts.nix b/nixos/tests/fontconfig-default-fonts.nix
index ce7f33201638..674192e7bba2 100644
--- a/nixos/tests/fontconfig-default-fonts.nix
+++ b/nixos/tests/fontconfig-default-fonts.nix
@@ -1,36 +1,34 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "fontconfig-default-fonts";
+{ lib, ... }:
+{
+ name = "fontconfig-default-fonts";
- meta.maintainers = with lib.maintainers; [
- jtojnar
- ];
+ meta.maintainers = with lib.maintainers; [
+ jtojnar
+ ];
- nodes.machine =
- { config, pkgs, ... }:
- {
- fonts.enableDefaultPackages = true; # Background fonts
- fonts.packages = with pkgs; [
- noto-fonts-color-emoji
- cantarell-fonts
- twitter-color-emoji
- source-code-pro
- gentium
- ];
- fonts.fontconfig.defaultFonts = {
- serif = [ "Gentium Plus" ];
- sansSerif = [ "Cantarell" ];
- monospace = [ "Source Code Pro" ];
- emoji = [ "Twitter Color Emoji" ];
- };
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ fonts.enableDefaultPackages = true; # Background fonts
+ fonts.packages = with pkgs; [
+ noto-fonts-color-emoji
+ cantarell-fonts
+ twitter-color-emoji
+ source-code-pro
+ gentium
+ ];
+ fonts.fontconfig.defaultFonts = {
+ serif = [ "Gentium Plus" ];
+ sansSerif = [ "Cantarell" ];
+ monospace = [ "Source Code Pro" ];
+ emoji = [ "Twitter Color Emoji" ];
};
+ };
- testScript = ''
- machine.succeed("fc-match serif | grep '\"Gentium Plus\"'")
- machine.succeed("fc-match sans-serif | grep '\"Cantarell\"'")
- machine.succeed("fc-match monospace | grep '\"Source Code Pro\"'")
- machine.succeed("fc-match emoji | grep '\"Twitter Color Emoji\"'")
- '';
- }
-)
+ testScript = ''
+ machine.succeed("fc-match serif | grep '\"Gentium Plus\"'")
+ machine.succeed("fc-match sans-serif | grep '\"Cantarell\"'")
+ machine.succeed("fc-match monospace | grep '\"Source Code Pro\"'")
+ machine.succeed("fc-match emoji | grep '\"Twitter Color Emoji\"'")
+ '';
+}
diff --git a/nixos/tests/freeswitch.nix b/nixos/tests/freeswitch.nix
index 91f25244c9a4..8dbb28efe90d 100644
--- a/nixos/tests/freeswitch.nix
+++ b/nixos/tests/freeswitch.nix
@@ -1,34 +1,32 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "freeswitch";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ misuzu ];
- };
- nodes = {
- node0 =
- { config, lib, ... }:
- {
- networking.useDHCP = false;
- networking.interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.0.1";
- prefixLength = 24;
- }
- ];
- };
- services.freeswitch = {
- enable = true;
- enableReload = true;
- configTemplate = "${config.services.freeswitch.package}/share/freeswitch/conf/minimal";
- };
+{ pkgs, ... }:
+{
+ name = "freeswitch";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ misuzu ];
+ };
+ nodes = {
+ node0 =
+ { config, lib, ... }:
+ {
+ networking.useDHCP = false;
+ networking.interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.0.1";
+ prefixLength = 24;
+ }
+ ];
};
- };
- testScript = ''
- node0.wait_for_unit("freeswitch.service")
- # Wait for SIP port to be open
- node0.wait_for_open_port(5060)
- '';
- }
-)
+ services.freeswitch = {
+ enable = true;
+ enableReload = true;
+ configTemplate = "${config.services.freeswitch.package}/share/freeswitch/conf/minimal";
+ };
+ };
+ };
+ testScript = ''
+ node0.wait_for_unit("freeswitch.service")
+ # Wait for SIP port to be open
+ node0.wait_for_open_port(5060)
+ '';
+}
diff --git a/nixos/tests/frp.nix b/nixos/tests/frp.nix
index 8771ab8ad224..14db56308edc 100644
--- a/nixos/tests/frp.nix
+++ b/nixos/tests/frp.nix
@@ -1,87 +1,85 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "frp";
- meta.maintainers = with lib.maintainers; [ zaldnoay ];
- nodes = {
- frps = {
- networking = {
- useNetworkd = true;
- useDHCP = false;
- firewall.enable = false;
- };
-
- systemd.network.networks."01-eth1" = {
- name = "eth1";
- networkConfig.Address = "10.0.0.1/24";
- };
-
- services.frp = {
- enable = true;
- role = "server";
- settings = {
- bindPort = 7000;
- vhostHTTPPort = 80;
- };
- };
+{ pkgs, lib, ... }:
+{
+ name = "frp";
+ meta.maintainers = with lib.maintainers; [ zaldnoay ];
+ nodes = {
+ frps = {
+ networking = {
+ useNetworkd = true;
+ useDHCP = false;
+ firewall.enable = false;
};
- frpc = {
- networking = {
- useNetworkd = true;
- useDHCP = false;
- };
+ systemd.network.networks."01-eth1" = {
+ name = "eth1";
+ networkConfig.Address = "10.0.0.1/24";
+ };
- systemd.network.networks."01-eth1" = {
- name = "eth1";
- networkConfig.Address = "10.0.0.2/24";
- };
-
- services.httpd = {
- enable = true;
- adminAddr = "admin@example.com";
- virtualHosts."test-appication" =
- let
- testdir = pkgs.writeTextDir "web/index.php" "&2")
+ router2 =
+ { ... }:
+ {
+ virtualisation.vlans = [
+ 3
+ 2
+ ];
+ boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
+ networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
+ services.frr = {
+ ospfd.enable = true;
+ config = ospfConf2;
+ };
+ };
- with subtest("Wait for OSPF to form adjacencies"):
- for gw in router1, router2:
- gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
- gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
+ server =
+ { nodes, ... }:
+ {
+ virtualisation.vlans = [ 3 ];
+ services.frr = {
+ config = ''
+ ip route 192.168.0.0/16 ${ifAddr nodes.router2 "eth1"}
+ '';
+ };
+ };
+ };
- with subtest("Test ICMP"):
- client.wait_until_succeeds("ping -4 -c 3 server >&2")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ ''
+ start_all()
+
+ # Wait for the networking to start on all machines
+ for machine in client, router1, router2, server:
+ machine.wait_for_unit("network.target")
+
+ with subtest("Wait for FRR"):
+ for gw in client, router1, router2, server:
+ gw.wait_for_unit("frr")
+
+ router1.succeed("${nodes.router1.system.build.toplevel}/specialisation/ospf/bin/switch-to-configuration test >&2")
+
+ with subtest("Wait for OSPF to form adjacencies"):
+ for gw in router1, router2:
+ gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
+ gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
+
+ with subtest("Test ICMP"):
+ client.wait_until_succeeds("ping -4 -c 3 server >&2")
+ '';
+}
diff --git a/nixos/tests/fscrypt.nix b/nixos/tests/fscrypt.nix
index 5bc611f123c4..4dc839dac447 100644
--- a/nixos/tests/fscrypt.nix
+++ b/nixos/tests/fscrypt.nix
@@ -1,54 +1,52 @@
-import ./make-test-python.nix (
- { ... }:
- {
- name = "fscrypt";
+{ ... }:
+{
+ name = "fscrypt";
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ./common/user-account.nix ];
- security.pam.enableFscrypt = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ security.pam.enableFscrypt = true;
+ };
- testScript = ''
- def login_as_alice():
- machine.wait_until_tty_matches("1", "login: ")
- machine.send_chars("alice\n")
- machine.wait_until_tty_matches("1", "Password: ")
- machine.send_chars("foobar\n")
- machine.wait_until_tty_matches("1", "alice\@machine")
+ testScript = ''
+ def login_as_alice():
+ machine.wait_until_tty_matches("1", "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches("1", "Password: ")
+ machine.send_chars("foobar\n")
+ machine.wait_until_tty_matches("1", "alice\@machine")
- def logout():
- machine.send_chars("logout\n")
- machine.wait_until_tty_matches("1", "login: ")
+ def logout():
+ machine.send_chars("logout\n")
+ machine.wait_until_tty_matches("1", "login: ")
- machine.wait_for_unit("default.target")
+ machine.wait_for_unit("default.target")
- with subtest("Enable fscrypt on filesystem"):
- machine.succeed("tune2fs -O encrypt /dev/vda")
- machine.succeed("fscrypt setup --quiet --force --time=1ms")
+ with subtest("Enable fscrypt on filesystem"):
+ machine.succeed("tune2fs -O encrypt /dev/vda")
+ machine.succeed("fscrypt setup --quiet --force --time=1ms")
- with subtest("Set up alice with an fscrypt-enabled home directory"):
- machine.succeed("(echo foobar; echo foobar) | passwd alice")
- machine.succeed("chown -R alice.users ~alice")
- machine.succeed("echo foobar | fscrypt encrypt --skip-unlock --source=pam_passphrase --user=alice /home/alice")
+ with subtest("Set up alice with an fscrypt-enabled home directory"):
+ machine.succeed("(echo foobar; echo foobar) | passwd alice")
+ machine.succeed("chown -R alice.users ~alice")
+ machine.succeed("echo foobar | fscrypt encrypt --skip-unlock --source=pam_passphrase --user=alice /home/alice")
- with subtest("Create file as alice"):
- login_as_alice()
- machine.succeed("echo hello > /home/alice/world")
- logout()
- # Wait for logout to be processed
- machine.sleep(1)
+ with subtest("Create file as alice"):
+ login_as_alice()
+ machine.succeed("echo hello > /home/alice/world")
+ logout()
+ # Wait for logout to be processed
+ machine.sleep(1)
- with subtest("File should not be readable without being logged in as alice"):
- machine.fail("cat /home/alice/world")
+ with subtest("File should not be readable without being logged in as alice"):
+ machine.fail("cat /home/alice/world")
- with subtest("File should be readable again as alice"):
- login_as_alice()
- machine.succeed("cat /home/alice/world")
- logout()
- '';
- }
-)
+ with subtest("File should be readable again as alice"):
+ login_as_alice()
+ machine.succeed("cat /home/alice/world")
+ logout()
+ '';
+}
diff --git a/nixos/tests/ft2-clone.nix b/nixos/tests/ft2-clone.nix
index 012432bb3f84..c4f1475ad710 100644
--- a/nixos/tests/ft2-clone.nix
+++ b/nixos/tests/ft2-clone.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "ft2-clone";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fgaz ];
+{ pkgs, ... }:
+{
+ name = "ft2-clone";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fgaz ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ];
+ environment.systemPackages = [ pkgs.ft2-clone ];
};
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [
- ./common/x11.nix
- ];
- environment.systemPackages = [ pkgs.ft2-clone ];
- };
+ enableOCR = true;
- enableOCR = true;
+ testScript = ''
+ machine.wait_for_x()
+ # Add a dummy sound card, or the program won't start
+ machine.execute("modprobe snd-dummy")
- testScript = ''
- machine.wait_for_x()
- # Add a dummy sound card, or the program won't start
- machine.execute("modprobe snd-dummy")
+ machine.execute("ft2-clone >&2 &")
- machine.execute("ft2-clone >&2 &")
-
- machine.wait_for_window(r"Fasttracker")
- machine.sleep(5)
- machine.wait_for_text(r"(Songlen|Repstart|Time|About|Nibbles|Help)")
- machine.screenshot("screen")
- '';
- }
-)
+ machine.wait_for_window(r"Fasttracker")
+ machine.sleep(5)
+ machine.wait_for_text(r"(Songlen|Repstart|Time|About|Nibbles|Help)")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/gancio.nix b/nixos/tests/gancio.nix
index 8f4696d6f6cc..6cd487008670 100644
--- a/nixos/tests/gancio.nix
+++ b/nixos/tests/gancio.nix
@@ -1,87 +1,85 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- extraHosts = ''
- 192.168.13.12 agenda.example.com
- '';
- in
- {
- name = "gancio";
- meta.maintainers = with pkgs.lib.maintainers; [ jbgi ];
+{ pkgs, ... }:
+let
+ extraHosts = ''
+ 192.168.13.12 agenda.example.com
+ '';
+in
+{
+ name = "gancio";
+ meta.maintainers = with pkgs.lib.maintainers; [ jbgi ];
- nodes = {
- server =
- { pkgs, ... }:
- {
- networking = {
- interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.13.12";
- prefixLength = 24;
- }
- ];
- };
- inherit extraHosts;
- firewall.allowedTCPPorts = [ 80 ];
+ nodes = {
+ server =
+ { pkgs, ... }:
+ {
+ networking = {
+ interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.13.12";
+ prefixLength = 24;
+ }
+ ];
};
- environment.systemPackages = [ pkgs.gancio ];
- services.gancio = {
- enable = true;
- settings = {
- hostname = "agenda.example.com";
- db.dialect = "postgres";
- };
- plugins = [ pkgs.gancioPlugins.telegram-bridge ];
- userLocale = {
- en = {
- register = {
- description = "My new registration page description";
- };
+ inherit extraHosts;
+ firewall.allowedTCPPorts = [ 80 ];
+ };
+ environment.systemPackages = [ pkgs.gancio ];
+ services.gancio = {
+ enable = true;
+ settings = {
+ hostname = "agenda.example.com";
+ db.dialect = "postgres";
+ };
+ plugins = [ pkgs.gancioPlugins.telegram-bridge ];
+ userLocale = {
+ en = {
+ register = {
+ description = "My new registration page description";
};
};
- nginx = {
- enableACME = false;
- forceSSL = false;
- };
+ };
+ nginx = {
+ enableACME = false;
+ forceSSL = false;
};
};
+ };
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.jq ];
- networking = {
- interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.13.1";
- prefixLength = 24;
- }
- ];
- };
- inherit extraHosts;
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.jq ];
+ networking = {
+ interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.13.1";
+ prefixLength = 24;
+ }
+ ];
};
+ inherit extraHosts;
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- server.wait_for_unit("postgresql")
- server.wait_for_unit("gancio")
- server.wait_for_unit("nginx")
- server.wait_for_file("/run/gancio/socket")
- server.wait_for_open_port(80)
+ server.wait_for_unit("postgresql")
+ server.wait_for_unit("gancio")
+ server.wait_for_unit("nginx")
+ server.wait_for_file("/run/gancio/socket")
+ server.wait_for_open_port(80)
- # Check can create user via cli
- server.succeed("cd /var/lib/gancio && sudo -u gancio gancio users create admin dummy admin")
+ # Check can create user via cli
+ server.succeed("cd /var/lib/gancio && sudo -u gancio gancio users create admin dummy admin")
- # Check event list is returned
- client.wait_until_succeeds("curl --verbose --fail-with-body http://agenda.example.com/api/events", timeout=30)
+ # Check event list is returned
+ client.wait_until_succeeds("curl --verbose --fail-with-body http://agenda.example.com/api/events", timeout=30)
- server.shutdown()
- client.shutdown()
- '';
- }
-)
+ server.shutdown()
+ client.shutdown()
+ '';
+}
diff --git a/nixos/tests/geth.nix b/nixos/tests/geth.nix
index 7fa7b97ed3bb..49a2c4f11701 100644
--- a/nixos/tests/geth.nix
+++ b/nixos/tests/geth.nix
@@ -1,71 +1,69 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "geth";
- meta = with pkgs.lib; {
- maintainers = with maintainers; [ bachp ];
- };
+{ pkgs, ... }:
+{
+ name = "geth";
+ meta = with pkgs.lib; {
+ maintainers = with maintainers; [ bachp ];
+ };
- nodes.machine =
- { ... }:
- {
- services.geth."mainnet" = {
+ nodes.machine =
+ { ... }:
+ {
+ services.geth."mainnet" = {
+ enable = true;
+ http = {
enable = true;
- http = {
- enable = true;
- };
- };
-
- services.geth."holesky" = {
- enable = true;
- port = 30304;
- network = "holesky";
- http = {
- enable = true;
- port = 18545;
- };
- authrpc = {
- enable = true;
- port = 18551;
- };
- };
-
- services.geth."sepolia" = {
- enable = true;
- port = 30305;
- network = "sepolia";
- http = {
- enable = true;
- port = 28545;
- };
- authrpc = {
- enable = true;
- port = 28551;
- };
};
};
- testScript = ''
- start_all()
+ services.geth."holesky" = {
+ enable = true;
+ port = 30304;
+ network = "holesky";
+ http = {
+ enable = true;
+ port = 18545;
+ };
+ authrpc = {
+ enable = true;
+ port = 18551;
+ };
+ };
- machine.wait_for_unit("geth-mainnet.service")
- machine.wait_for_unit("geth-holesky.service")
- machine.wait_for_unit("geth-sepolia.service")
- machine.wait_for_open_port(8545)
- machine.wait_for_open_port(18545)
- machine.wait_for_open_port(28545)
+ services.geth."sepolia" = {
+ enable = true;
+ port = 30305;
+ network = "sepolia";
+ http = {
+ enable = true;
+ port = 28545;
+ };
+ authrpc = {
+ enable = true;
+ port = 28551;
+ };
+ };
+ };
- machine.succeed(
- 'geth attach --exec "eth.blockNumber" http://localhost:8545 | grep \'^0$\' '
- )
+ testScript = ''
+ start_all()
- machine.succeed(
- 'geth attach --exec "eth.blockNumber" http://localhost:18545 | grep \'^0$\' '
- )
+ machine.wait_for_unit("geth-mainnet.service")
+ machine.wait_for_unit("geth-holesky.service")
+ machine.wait_for_unit("geth-sepolia.service")
+ machine.wait_for_open_port(8545)
+ machine.wait_for_open_port(18545)
+ machine.wait_for_open_port(28545)
- machine.succeed(
- 'geth attach --exec "eth.blockNumber" http://localhost:28545 | grep \'^0$\' '
- )
- '';
- }
-)
+ machine.succeed(
+ 'geth attach --exec "eth.blockNumber" http://localhost:8545 | grep \'^0$\' '
+ )
+
+ machine.succeed(
+ 'geth attach --exec "eth.blockNumber" http://localhost:18545 | grep \'^0$\' '
+ )
+
+ machine.succeed(
+ 'geth attach --exec "eth.blockNumber" http://localhost:28545 | grep \'^0$\' '
+ )
+ '';
+}
diff --git a/nixos/tests/ghostunnel.nix b/nixos/tests/ghostunnel.nix
index bd16a802e60d..417f1a64765b 100644
--- a/nixos/tests/ghostunnel.nix
+++ b/nixos/tests/ghostunnel.nix
@@ -1,116 +1,114 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "ghostunnel";
- nodes = {
- backend =
- { pkgs, ... }:
- {
- services.nginx.enable = true;
- services.nginx.virtualHosts."backend".root = pkgs.runCommand "webroot" { } ''
- mkdir $out
- echo hi >$out/hi.txt
- '';
- networking.firewall.allowedTCPPorts = [ 80 ];
+{ pkgs, ... }:
+{
+ name = "ghostunnel";
+ nodes = {
+ backend =
+ { pkgs, ... }:
+ {
+ services.nginx.enable = true;
+ services.nginx.virtualHosts."backend".root = pkgs.runCommand "webroot" { } ''
+ mkdir $out
+ echo hi >$out/hi.txt
+ '';
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ };
+ service =
+ { ... }:
+ {
+ services.ghostunnel.enable = true;
+ services.ghostunnel.servers."plain-old" = {
+ listen = "0.0.0.0:443";
+ cert = "/root/service-cert.pem";
+ key = "/root/service-key.pem";
+ disableAuthentication = true;
+ target = "backend:80";
+ unsafeTarget = true;
};
- service =
- { ... }:
- {
- services.ghostunnel.enable = true;
- services.ghostunnel.servers."plain-old" = {
- listen = "0.0.0.0:443";
- cert = "/root/service-cert.pem";
- key = "/root/service-key.pem";
- disableAuthentication = true;
- target = "backend:80";
- unsafeTarget = true;
- };
- services.ghostunnel.servers."client-cert" = {
- listen = "0.0.0.0:1443";
- cert = "/root/service-cert.pem";
- key = "/root/service-key.pem";
- cacert = "/root/ca.pem";
- target = "backend:80";
- allowCN = [ "client" ];
- unsafeTarget = true;
- };
- networking.firewall.allowedTCPPorts = [
- 443
- 1443
- ];
+ services.ghostunnel.servers."client-cert" = {
+ listen = "0.0.0.0:1443";
+ cert = "/root/service-cert.pem";
+ key = "/root/service-key.pem";
+ cacert = "/root/ca.pem";
+ target = "backend:80";
+ allowCN = [ "client" ];
+ unsafeTarget = true;
};
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [
- pkgs.curl
- ];
- };
- };
+ networking.firewall.allowedTCPPorts = [
+ 443
+ 1443
+ ];
+ };
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [
+ pkgs.curl
+ ];
+ };
+ };
- testScript = ''
+ testScript = ''
- # prepare certificates
+ # prepare certificates
- def cmd(command):
- print(f"+{command}")
- r = os.system(command)
- if r != 0:
- raise Exception(f"Command {command} failed with exit code {r}")
+ def cmd(command):
+ print(f"+{command}")
+ r = os.system(command)
+ if r != 0:
+ raise Exception(f"Command {command} failed with exit code {r}")
- # Create CA
- cmd("${pkgs.openssl}/bin/openssl genrsa -out ca-key.pem 4096")
- cmd("${pkgs.openssl}/bin/openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -subj '/C=NL/ST=Zuid-Holland/L=The Hague/O=Stevige Balken en Planken B.V./OU=OpSec/CN=Certificate Authority' -out ca.pem")
+ # Create CA
+ cmd("${pkgs.openssl}/bin/openssl genrsa -out ca-key.pem 4096")
+ cmd("${pkgs.openssl}/bin/openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -subj '/C=NL/ST=Zuid-Holland/L=The Hague/O=Stevige Balken en Planken B.V./OU=OpSec/CN=Certificate Authority' -out ca.pem")
- # Create service
- cmd("${pkgs.openssl}/bin/openssl genrsa -out service-key.pem 4096")
- cmd("${pkgs.openssl}/bin/openssl req -subj '/CN=service' -sha256 -new -key service-key.pem -out service.csr")
- cmd("echo subjectAltName = DNS:service,IP:127.0.0.1 >> extfile.cnf")
- cmd("echo extendedKeyUsage = serverAuth >> extfile.cnf")
- cmd("${pkgs.openssl}/bin/openssl x509 -req -days 365 -sha256 -in service.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out service-cert.pem -extfile extfile.cnf")
+ # Create service
+ cmd("${pkgs.openssl}/bin/openssl genrsa -out service-key.pem 4096")
+ cmd("${pkgs.openssl}/bin/openssl req -subj '/CN=service' -sha256 -new -key service-key.pem -out service.csr")
+ cmd("echo subjectAltName = DNS:service,IP:127.0.0.1 >> extfile.cnf")
+ cmd("echo extendedKeyUsage = serverAuth >> extfile.cnf")
+ cmd("${pkgs.openssl}/bin/openssl x509 -req -days 365 -sha256 -in service.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out service-cert.pem -extfile extfile.cnf")
- # Create client
- cmd("${pkgs.openssl}/bin/openssl genrsa -out client-key.pem 4096")
- cmd("${pkgs.openssl}/bin/openssl req -subj '/CN=client' -new -key client-key.pem -out client.csr")
- cmd("echo extendedKeyUsage = clientAuth > extfile-client.cnf")
- cmd("${pkgs.openssl}/bin/openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out client-cert.pem -extfile extfile-client.cnf")
+ # Create client
+ cmd("${pkgs.openssl}/bin/openssl genrsa -out client-key.pem 4096")
+ cmd("${pkgs.openssl}/bin/openssl req -subj '/CN=client' -new -key client-key.pem -out client.csr")
+ cmd("echo extendedKeyUsage = clientAuth > extfile-client.cnf")
+ cmd("${pkgs.openssl}/bin/openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out client-cert.pem -extfile extfile-client.cnf")
- cmd("ls -al")
+ cmd("ls -al")
- start_all()
+ start_all()
- # Configuration
- service.copy_from_host("ca.pem", "/root/ca.pem")
- service.copy_from_host("service-cert.pem", "/root/service-cert.pem")
- service.copy_from_host("service-key.pem", "/root/service-key.pem")
- client.copy_from_host("ca.pem", "/root/ca.pem")
- client.copy_from_host("service-cert.pem", "/root/service-cert.pem")
- client.copy_from_host("client-cert.pem", "/root/client-cert.pem")
- client.copy_from_host("client-key.pem", "/root/client-key.pem")
+ # Configuration
+ service.copy_from_host("ca.pem", "/root/ca.pem")
+ service.copy_from_host("service-cert.pem", "/root/service-cert.pem")
+ service.copy_from_host("service-key.pem", "/root/service-key.pem")
+ client.copy_from_host("ca.pem", "/root/ca.pem")
+ client.copy_from_host("service-cert.pem", "/root/service-cert.pem")
+ client.copy_from_host("client-cert.pem", "/root/client-cert.pem")
+ client.copy_from_host("client-key.pem", "/root/client-key.pem")
- backend.wait_for_unit("nginx.service")
- service.wait_for_unit("multi-user.target")
- service.wait_for_unit("multi-user.target")
- client.wait_for_unit("multi-user.target")
+ backend.wait_for_unit("nginx.service")
+ service.wait_for_unit("multi-user.target")
+ service.wait_for_unit("multi-user.target")
+ client.wait_for_unit("multi-user.target")
- # Check assumptions before the real test
- client.succeed("bash -c 'diff <(curl -v --no-progress-meter http://backend/hi.txt) <(echo hi)'")
+ # Check assumptions before the real test
+ client.succeed("bash -c 'diff <(curl -v --no-progress-meter http://backend/hi.txt) <(echo hi)'")
- # Plain old simple TLS can connect, ignoring cert
- client.succeed("bash -c 'diff <(curl -v --no-progress-meter --insecure https://service/hi.txt) <(echo hi)'")
+ # Plain old simple TLS can connect, ignoring cert
+ client.succeed("bash -c 'diff <(curl -v --no-progress-meter --insecure https://service/hi.txt) <(echo hi)'")
- # Plain old simple TLS provides correct signature with its cert
- client.succeed("bash -c 'diff <(curl -v --no-progress-meter --cacert /root/ca.pem https://service/hi.txt) <(echo hi)'")
+ # Plain old simple TLS provides correct signature with its cert
+ client.succeed("bash -c 'diff <(curl -v --no-progress-meter --cacert /root/ca.pem https://service/hi.txt) <(echo hi)'")
- # Client can authenticate with certificate
- client.succeed("bash -c 'diff <(curl -v --no-progress-meter --cert /root/client-cert.pem --key /root/client-key.pem --cacert /root/ca.pem https://service:1443/hi.txt) <(echo hi)'")
+ # Client can authenticate with certificate
+ client.succeed("bash -c 'diff <(curl -v --no-progress-meter --cert /root/client-cert.pem --key /root/client-key.pem --cacert /root/ca.pem https://service:1443/hi.txt) <(echo hi)'")
- # Client must authenticate with certificate
- client.fail("bash -c 'diff <(curl -v --no-progress-meter --cacert /root/ca.pem https://service:1443/hi.txt) <(echo hi)'")
- '';
+ # Client must authenticate with certificate
+ client.fail("bash -c 'diff <(curl -v --no-progress-meter --cacert /root/ca.pem https://service:1443/hi.txt) <(echo hi)'")
+ '';
- meta.maintainers = with pkgs.lib.maintainers; [
- roberth
- ];
- }
-)
+ meta.maintainers = with pkgs.lib.maintainers; [
+ roberth
+ ];
+}
diff --git a/nixos/tests/gitdaemon.nix b/nixos/tests/gitdaemon.nix
index 41a29168bda4..35278a319827 100644
--- a/nixos/tests/gitdaemon.nix
+++ b/nixos/tests/gitdaemon.nix
@@ -1,83 +1,81 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- hashes = pkgs.writeText "hashes" ''
- b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /project/bar
- '';
- in
- {
- name = "gitdaemon";
+let
+ hashes = pkgs.writeText "hashes" ''
+ b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /project/bar
+ '';
+in
+{
+ name = "gitdaemon";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ tilpner ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ tilpner ];
+ };
- nodes = {
- server =
- { config, ... }:
- {
- networking.firewall.allowedTCPPorts = [ config.services.gitDaemon.port ];
+ nodes = {
+ server =
+ { config, ... }:
+ {
+ networking.firewall.allowedTCPPorts = [ config.services.gitDaemon.port ];
- environment.systemPackages = [ pkgs.git ];
+ environment.systemPackages = [ pkgs.git ];
- systemd.tmpfiles.rules = [
- # type path mode user group age arg
- " d /git 0755 git git - -"
- ];
+ systemd.tmpfiles.rules = [
+ # type path mode user group age arg
+ " d /git 0755 git git - -"
+ ];
- services.gitDaemon = {
- enable = true;
- basePath = "/git";
- };
+ services.gitDaemon = {
+ enable = true;
+ basePath = "/git";
};
+ };
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.git ];
- };
- };
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.git ];
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- with subtest("create project.git"):
- server.succeed(
- "git init --bare /git/project.git",
- "touch /git/project.git/git-daemon-export-ok",
- )
+ with subtest("create project.git"):
+ server.succeed(
+ "git init --bare /git/project.git",
+ "touch /git/project.git/git-daemon-export-ok",
+ )
- with subtest("add file to project.git"):
- server.succeed(
- "git clone /git/project.git /project",
- "echo foo > /project/bar",
- "git config --global user.email 'you@example.com'",
- "git config --global user.name 'Your Name'",
- "git -C /project add bar",
- "git -C /project commit -m 'quux'",
- "git -C /project push",
- "rm -r /project",
- )
+ with subtest("add file to project.git"):
+ server.succeed(
+ "git clone /git/project.git /project",
+ "echo foo > /project/bar",
+ "git config --global user.email 'you@example.com'",
+ "git config --global user.name 'Your Name'",
+ "git -C /project add bar",
+ "git -C /project commit -m 'quux'",
+ "git -C /project push",
+ "rm -r /project",
+ )
- # Change user/group to default daemon user/group from module
- # to avoid "fatal: detected dubious ownership in repository at '/git/project.git'"
- server.succeed("chown git:git -R /git/project.git")
+ # Change user/group to default daemon user/group from module
+ # to avoid "fatal: detected dubious ownership in repository at '/git/project.git'"
+ server.succeed("chown git:git -R /git/project.git")
- with subtest("git daemon starts"):
- server.wait_for_unit("git-daemon.service")
+ with subtest("git daemon starts"):
+ server.wait_for_unit("git-daemon.service")
- server.systemctl("start network-online.target")
- client.systemctl("start network-online.target")
- server.wait_for_unit("network-online.target")
- client.wait_for_unit("network-online.target")
+ server.systemctl("start network-online.target")
+ client.systemctl("start network-online.target")
+ server.wait_for_unit("network-online.target")
+ client.wait_for_unit("network-online.target")
- with subtest("client can clone project.git"):
- client.succeed(
- "git clone git://server/project.git /project",
- "sha256sum -c ${hashes}",
- )
- '';
- }
-)
+ with subtest("client can clone project.git"):
+ client.succeed(
+ "git clone git://server/project.git /project",
+ "sha256sum -c ${hashes}",
+ )
+ '';
+}
diff --git a/nixos/tests/gitolite-fcgiwrap.nix b/nixos/tests/gitolite-fcgiwrap.nix
index 9560c5c34913..fff676ee1f59 100644
--- a/nixos/tests/gitolite-fcgiwrap.nix
+++ b/nixos/tests/gitolite-fcgiwrap.nix
@@ -1,98 +1,96 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- user = "gitolite-admin";
- password = "some_password";
+let
+ user = "gitolite-admin";
+ password = "some_password";
- # not used but needed to setup gitolite
- adminPublicKey = ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7urFhAA90BTpGuEHeWWTY3W/g9PBxXNxfWhfbrm4Le root@client
- '';
- in
- {
- name = "gitolite-fcgiwrap";
+ # not used but needed to setup gitolite
+ adminPublicKey = ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7urFhAA90BTpGuEHeWWTY3W/g9PBxXNxfWhfbrm4Le root@client
+ '';
+in
+{
+ name = "gitolite-fcgiwrap";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ bbigras ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ bbigras ];
+ };
- nodes = {
+ nodes = {
- server =
- { config, ... }:
- {
- networking.firewall.allowedTCPPorts = [ 80 ];
+ server =
+ { config, ... }:
+ {
+ networking.firewall.allowedTCPPorts = [ 80 ];
- services.fcgiwrap.instances.gitolite = {
- process.user = "gitolite";
- process.group = "gitolite";
- socket = { inherit (config.services.nginx) user group; };
- };
+ services.fcgiwrap.instances.gitolite = {
+ process.user = "gitolite";
+ process.group = "gitolite";
+ socket = { inherit (config.services.nginx) user group; };
+ };
- services.gitolite = {
- enable = true;
- adminPubkey = adminPublicKey;
- };
+ services.gitolite = {
+ enable = true;
+ adminPubkey = adminPublicKey;
+ };
- services.nginx = {
- enable = true;
- recommendedProxySettings = true;
- virtualHosts."server".locations."/git".extraConfig = ''
- # turn off gzip as git objects are already well compressed
- gzip off;
+ services.nginx = {
+ enable = true;
+ recommendedProxySettings = true;
+ virtualHosts."server".locations."/git".extraConfig = ''
+ # turn off gzip as git objects are already well compressed
+ gzip off;
- # use file based basic authentication
- auth_basic "Git Repository Authentication";
- auth_basic_user_file /etc/gitolite/htpasswd;
+ # use file based basic authentication
+ auth_basic "Git Repository Authentication";
+ auth_basic_user_file /etc/gitolite/htpasswd;
- # common FastCGI parameters are required
- include ${config.services.nginx.package}/conf/fastcgi_params;
+ # common FastCGI parameters are required
+ include ${config.services.nginx.package}/conf/fastcgi_params;
- # strip the CGI program prefix
- fastcgi_split_path_info ^(/git)(.*)$;
- fastcgi_param PATH_INFO $fastcgi_path_info;
+ # strip the CGI program prefix
+ fastcgi_split_path_info ^(/git)(.*)$;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
- # pass authenticated user login(mandatory) to Gitolite
- fastcgi_param REMOTE_USER $remote_user;
+ # pass authenticated user login(mandatory) to Gitolite
+ fastcgi_param REMOTE_USER $remote_user;
- # pass git repository root directory and hosting user directory
- # these env variables can be set in a wrapper script
- fastcgi_param GIT_HTTP_EXPORT_ALL "";
- fastcgi_param GIT_PROJECT_ROOT /var/lib/gitolite/repositories;
- fastcgi_param GITOLITE_HTTP_HOME /var/lib/gitolite;
- fastcgi_param SCRIPT_FILENAME ${pkgs.gitolite}/bin/gitolite-shell;
+ # pass git repository root directory and hosting user directory
+ # these env variables can be set in a wrapper script
+ fastcgi_param GIT_HTTP_EXPORT_ALL "";
+ fastcgi_param GIT_PROJECT_ROOT /var/lib/gitolite/repositories;
+ fastcgi_param GITOLITE_HTTP_HOME /var/lib/gitolite;
+ fastcgi_param SCRIPT_FILENAME ${pkgs.gitolite}/bin/gitolite-shell;
- # use Unix domain socket or inet socket
- fastcgi_pass unix:${config.services.fcgiwrap.instances.gitolite.socket.address};
- '';
- };
-
- # WARNING: DON'T DO THIS IN PRODUCTION!
- # This puts unhashed secrets directly into the Nix store for ease of testing.
- environment.etc."gitolite/htpasswd".source = pkgs.runCommand "htpasswd" { } ''
- ${pkgs.apacheHttpd}/bin/htpasswd -bc "$out" ${user} ${password}
+ # use Unix domain socket or inet socket
+ fastcgi_pass unix:${config.services.fcgiwrap.instances.gitolite.socket.address};
'';
};
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.git ];
- };
- };
+ # WARNING: DON'T DO THIS IN PRODUCTION!
+ # This puts unhashed secrets directly into the Nix store for ease of testing.
+ environment.etc."gitolite/htpasswd".source = pkgs.runCommand "htpasswd" { } ''
+ ${pkgs.apacheHttpd}/bin/htpasswd -bc "$out" ${user} ${password}
+ '';
+ };
- testScript = ''
- start_all()
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.git ];
+ };
+ };
- server.wait_for_unit("gitolite-init.service")
- server.wait_for_unit("nginx.service")
- server.wait_for_file("/run/fcgiwrap-gitolite.sock")
+ testScript = ''
+ start_all()
- client.wait_for_unit("multi-user.target")
- client.succeed(
- "git clone http://${user}:${password}@server/git/gitolite-admin.git"
- )
- '';
- }
-)
+ server.wait_for_unit("gitolite-init.service")
+ server.wait_for_unit("nginx.service")
+ server.wait_for_file("/run/fcgiwrap-gitolite.sock")
+
+ client.wait_for_unit("multi-user.target")
+ client.succeed(
+ "git clone http://${user}:${password}@server/git/gitolite-admin.git"
+ )
+ '';
+}
diff --git a/nixos/tests/gitolite.nix b/nixos/tests/gitolite.nix
index af2aa327c016..3b4c4634e270 100644
--- a/nixos/tests/gitolite.nix
+++ b/nixos/tests/gitolite.nix
@@ -1,144 +1,142 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- adminPrivateKey = pkgs.writeText "id_ed25519" ''
- -----BEGIN OPENSSH PRIVATE KEY-----
- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
- QyNTUxOQAAACDu7qxYQAPdAU6RrhB3llk2N1v4PTwcVzcX1oX265uC3gAAAJBJiYxDSYmM
- QwAAAAtzc2gtZWQyNTUxOQAAACDu7qxYQAPdAU6RrhB3llk2N1v4PTwcVzcX1oX265uC3g
- AAAEDE1W6vMwSEUcF1r7Hyypm/+sCOoDmKZgPxi3WOa1mD2u7urFhAA90BTpGuEHeWWTY3
- W/g9PBxXNxfWhfbrm4LeAAAACGJmb0BtaW5pAQIDBAU=
- -----END OPENSSH PRIVATE KEY-----
- '';
+let
+ adminPrivateKey = pkgs.writeText "id_ed25519" ''
+ -----BEGIN OPENSSH PRIVATE KEY-----
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+ QyNTUxOQAAACDu7qxYQAPdAU6RrhB3llk2N1v4PTwcVzcX1oX265uC3gAAAJBJiYxDSYmM
+ QwAAAAtzc2gtZWQyNTUxOQAAACDu7qxYQAPdAU6RrhB3llk2N1v4PTwcVzcX1oX265uC3g
+ AAAEDE1W6vMwSEUcF1r7Hyypm/+sCOoDmKZgPxi3WOa1mD2u7urFhAA90BTpGuEHeWWTY3
+ W/g9PBxXNxfWhfbrm4LeAAAACGJmb0BtaW5pAQIDBAU=
+ -----END OPENSSH PRIVATE KEY-----
+ '';
- adminPublicKey = ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7urFhAA90BTpGuEHeWWTY3W/g9PBxXNxfWhfbrm4Le root@client
- '';
+ adminPublicKey = ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7urFhAA90BTpGuEHeWWTY3W/g9PBxXNxfWhfbrm4Le root@client
+ '';
- alicePrivateKey = pkgs.writeText "id_ed25519" ''
- -----BEGIN OPENSSH PRIVATE KEY-----
- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
- QyNTUxOQAAACBbeWvHh/AWGWI6EIc1xlSihyXtacNQ9KeztlW/VUy8wQAAAJAwVQ5VMFUO
- VQAAAAtzc2gtZWQyNTUxOQAAACBbeWvHh/AWGWI6EIc1xlSihyXtacNQ9KeztlW/VUy8wQ
- AAAEB7lbfkkdkJoE+4TKHPdPQWBKLSx+J54Eg8DaTr+3KoSlt5a8eH8BYZYjoQhzXGVKKH
- Je1pw1D0p7O2Vb9VTLzBAAAACGJmb0BtaW5pAQIDBAU=
- -----END OPENSSH PRIVATE KEY-----
- '';
+ alicePrivateKey = pkgs.writeText "id_ed25519" ''
+ -----BEGIN OPENSSH PRIVATE KEY-----
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+ QyNTUxOQAAACBbeWvHh/AWGWI6EIc1xlSihyXtacNQ9KeztlW/VUy8wQAAAJAwVQ5VMFUO
+ VQAAAAtzc2gtZWQyNTUxOQAAACBbeWvHh/AWGWI6EIc1xlSihyXtacNQ9KeztlW/VUy8wQ
+ AAAEB7lbfkkdkJoE+4TKHPdPQWBKLSx+J54Eg8DaTr+3KoSlt5a8eH8BYZYjoQhzXGVKKH
+ Je1pw1D0p7O2Vb9VTLzBAAAACGJmb0BtaW5pAQIDBAU=
+ -----END OPENSSH PRIVATE KEY-----
+ '';
- alicePublicKey = pkgs.writeText "id_ed25519.pub" ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFt5a8eH8BYZYjoQhzXGVKKHJe1pw1D0p7O2Vb9VTLzB alice@client
- '';
+ alicePublicKey = pkgs.writeText "id_ed25519.pub" ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFt5a8eH8BYZYjoQhzXGVKKHJe1pw1D0p7O2Vb9VTLzB alice@client
+ '';
- bobPrivateKey = pkgs.writeText "id_ed25519" ''
- -----BEGIN OPENSSH PRIVATE KEY-----
- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
- QyNTUxOQAAACCWTaJ1D9Xjxy6759FvQ9oXTes1lmWBciXPkEeqTikBMAAAAJDQBmNV0AZj
- VQAAAAtzc2gtZWQyNTUxOQAAACCWTaJ1D9Xjxy6759FvQ9oXTes1lmWBciXPkEeqTikBMA
- AAAEDM1IYYFUwk/IVxauha9kuR6bbRtT3gZ6ZA0GLb9txb/pZNonUP1ePHLrvn0W9D2hdN
- 6zWWZYFyJc+QR6pOKQEwAAAACGJmb0BtaW5pAQIDBAU=
- -----END OPENSSH PRIVATE KEY-----
- '';
+ bobPrivateKey = pkgs.writeText "id_ed25519" ''
+ -----BEGIN OPENSSH PRIVATE KEY-----
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
+ QyNTUxOQAAACCWTaJ1D9Xjxy6759FvQ9oXTes1lmWBciXPkEeqTikBMAAAAJDQBmNV0AZj
+ VQAAAAtzc2gtZWQyNTUxOQAAACCWTaJ1D9Xjxy6759FvQ9oXTes1lmWBciXPkEeqTikBMA
+ AAAEDM1IYYFUwk/IVxauha9kuR6bbRtT3gZ6ZA0GLb9txb/pZNonUP1ePHLrvn0W9D2hdN
+ 6zWWZYFyJc+QR6pOKQEwAAAACGJmb0BtaW5pAQIDBAU=
+ -----END OPENSSH PRIVATE KEY-----
+ '';
- bobPublicKey = pkgs.writeText "id_ed25519.pub" ''
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJZNonUP1ePHLrvn0W9D2hdN6zWWZYFyJc+QR6pOKQEw bob@client
- '';
+ bobPublicKey = pkgs.writeText "id_ed25519.pub" ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJZNonUP1ePHLrvn0W9D2hdN6zWWZYFyJc+QR6pOKQEw bob@client
+ '';
- gitoliteAdminConfSnippet = pkgs.writeText "gitolite-admin-conf-snippet" ''
- repo alice-project
- RW+ = alice
- '';
- in
- {
- name = "gitolite";
+ gitoliteAdminConfSnippet = pkgs.writeText "gitolite-admin-conf-snippet" ''
+ repo alice-project
+ RW+ = alice
+ '';
+in
+{
+ name = "gitolite";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ bjornfor ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ bjornfor ];
+ };
- nodes = {
+ nodes = {
- server =
- { ... }:
- {
- services.gitolite = {
- enable = true;
- adminPubkey = adminPublicKey;
- };
- services.openssh.enable = true;
+ server =
+ { ... }:
+ {
+ services.gitolite = {
+ enable = true;
+ adminPubkey = adminPublicKey;
};
+ services.openssh.enable = true;
+ };
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.git ];
- programs.ssh.extraConfig = ''
- Host *
- UserKnownHostsFile /dev/null
- StrictHostKeyChecking no
- # there's nobody around that can input password
- PreferredAuthentications publickey
- '';
- users.users.alice = {
- isNormalUser = true;
- };
- users.users.bob = {
- isNormalUser = true;
- };
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.git ];
+ programs.ssh.extraConfig = ''
+ Host *
+ UserKnownHostsFile /dev/null
+ StrictHostKeyChecking no
+ # there's nobody around that can input password
+ PreferredAuthentications publickey
+ '';
+ users.users.alice = {
+ isNormalUser = true;
};
+ users.users.bob = {
+ isNormalUser = true;
+ };
+ };
- };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- with subtest("can setup ssh keys on system"):
- client.succeed(
- "mkdir -p ~root/.ssh",
- "cp ${adminPrivateKey} ~root/.ssh/id_ed25519",
- "chmod 600 ~root/.ssh/id_ed25519",
- )
- client.succeed(
- "sudo -u alice mkdir -p ~alice/.ssh",
- "sudo -u alice cp ${alicePrivateKey} ~alice/.ssh/id_ed25519",
- "sudo -u alice chmod 600 ~alice/.ssh/id_ed25519",
- )
- client.succeed(
- "sudo -u bob mkdir -p ~bob/.ssh",
- "sudo -u bob cp ${bobPrivateKey} ~bob/.ssh/id_ed25519",
- "sudo -u bob chmod 600 ~bob/.ssh/id_ed25519",
- )
+ with subtest("can setup ssh keys on system"):
+ client.succeed(
+ "mkdir -p ~root/.ssh",
+ "cp ${adminPrivateKey} ~root/.ssh/id_ed25519",
+ "chmod 600 ~root/.ssh/id_ed25519",
+ )
+ client.succeed(
+ "sudo -u alice mkdir -p ~alice/.ssh",
+ "sudo -u alice cp ${alicePrivateKey} ~alice/.ssh/id_ed25519",
+ "sudo -u alice chmod 600 ~alice/.ssh/id_ed25519",
+ )
+ client.succeed(
+ "sudo -u bob mkdir -p ~bob/.ssh",
+ "sudo -u bob cp ${bobPrivateKey} ~bob/.ssh/id_ed25519",
+ "sudo -u bob chmod 600 ~bob/.ssh/id_ed25519",
+ )
- with subtest("gitolite server starts"):
- server.wait_for_unit("gitolite-init.service")
- server.wait_for_unit("sshd.service")
- client.succeed("ssh -n gitolite@server info")
+ with subtest("gitolite server starts"):
+ server.wait_for_unit("gitolite-init.service")
+ server.wait_for_unit("sshd.service")
+ client.succeed("ssh -n gitolite@server info")
- with subtest("admin can clone and configure gitolite-admin.git"):
- client.succeed(
- "git clone gitolite@server:gitolite-admin.git",
- "git config --global user.name 'System Administrator'",
- "git config --global user.email root\@domain.example",
- "cp ${alicePublicKey} gitolite-admin/keydir/alice.pub",
- "cp ${bobPublicKey} gitolite-admin/keydir/bob.pub",
- "(cd gitolite-admin && git add . && git commit -m 'Add keys for alice, bob' && git push)",
- "cat ${gitoliteAdminConfSnippet} >> gitolite-admin/conf/gitolite.conf",
- "(cd gitolite-admin && git add . && git commit -m 'Add repo for alice' && git push)",
- )
+ with subtest("admin can clone and configure gitolite-admin.git"):
+ client.succeed(
+ "git clone gitolite@server:gitolite-admin.git",
+ "git config --global user.name 'System Administrator'",
+ "git config --global user.email root\@domain.example",
+ "cp ${alicePublicKey} gitolite-admin/keydir/alice.pub",
+ "cp ${bobPublicKey} gitolite-admin/keydir/bob.pub",
+ "(cd gitolite-admin && git add . && git commit -m 'Add keys for alice, bob' && git push)",
+ "cat ${gitoliteAdminConfSnippet} >> gitolite-admin/conf/gitolite.conf",
+ "(cd gitolite-admin && git add . && git commit -m 'Add repo for alice' && git push)",
+ )
- with subtest("non-admins cannot clone gitolite-admin.git"):
- client.fail("sudo -i -u alice git clone gitolite@server:gitolite-admin.git")
- client.fail("sudo -i -u bob git clone gitolite@server:gitolite-admin.git")
+ with subtest("non-admins cannot clone gitolite-admin.git"):
+ client.fail("sudo -i -u alice git clone gitolite@server:gitolite-admin.git")
+ client.fail("sudo -i -u bob git clone gitolite@server:gitolite-admin.git")
- with subtest("non-admins can clone testing.git"):
- client.succeed("sudo -i -u alice git clone gitolite@server:testing.git")
- client.succeed("sudo -i -u bob git clone gitolite@server:testing.git")
+ with subtest("non-admins can clone testing.git"):
+ client.succeed("sudo -i -u alice git clone gitolite@server:testing.git")
+ client.succeed("sudo -i -u bob git clone gitolite@server:testing.git")
- with subtest("alice can clone alice-project.git"):
- client.succeed("sudo -i -u alice git clone gitolite@server:alice-project.git")
+ with subtest("alice can clone alice-project.git"):
+ client.succeed("sudo -i -u alice git clone gitolite@server:alice-project.git")
- with subtest("bob cannot clone alice-project.git"):
- client.fail("sudo -i -u bob git clone gitolite@server:alice-project.git")
- '';
- }
-)
+ with subtest("bob cannot clone alice-project.git"):
+ client.fail("sudo -i -u bob git clone gitolite@server:alice-project.git")
+ '';
+}
diff --git a/nixos/tests/glusterfs.nix b/nixos/tests/glusterfs.nix
index 8beed8e4a91f..e8b0a442aedc 100644
--- a/nixos/tests/glusterfs.nix
+++ b/nixos/tests/glusterfs.nix
@@ -1,75 +1,73 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.glusterfs ];
- virtualisation.fileSystems = {
- "/gluster" = {
- device = "server1:/gv0";
- fsType = "glusterfs";
- };
+let
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.glusterfs ];
+ virtualisation.fileSystems = {
+ "/gluster" = {
+ device = "server1:/gv0";
+ fsType = "glusterfs";
};
};
-
- server =
- { pkgs, ... }:
- {
- networking.firewall.enable = false;
- services.glusterfs.enable = true;
-
- # create a mount point for the volume
- boot.initrd.postDeviceCommands = ''
- ${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
- '';
-
- virtualisation.emptyDiskImages = [ 1024 ];
-
- virtualisation.fileSystems = {
- "/data" = {
- device = "/dev/disk/by-label/data";
- fsType = "ext4";
- };
- };
- };
- in
- {
- name = "glusterfs";
-
- nodes = {
- server1 = server;
- server2 = server;
- client1 = client;
- client2 = client;
};
- testScript = ''
- server1.wait_for_unit("glusterd.service")
- server2.wait_for_unit("glusterd.service")
+ server =
+ { pkgs, ... }:
+ {
+ networking.firewall.enable = false;
+ services.glusterfs.enable = true;
- server1.wait_until_succeeds("gluster peer status")
- server2.wait_until_succeeds("gluster peer status")
+ # create a mount point for the volume
+ boot.initrd.postDeviceCommands = ''
+ ${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
+ '';
- # establish initial contact
- server1.succeed("gluster peer probe server2")
- server1.succeed("gluster peer probe server1")
+ virtualisation.emptyDiskImages = [ 1024 ];
- server1.succeed("gluster peer status | grep Connected")
+ virtualisation.fileSystems = {
+ "/data" = {
+ device = "/dev/disk/by-label/data";
+ fsType = "ext4";
+ };
+ };
+ };
+in
+{
+ name = "glusterfs";
- # create volumes
- server1.succeed("mkdir -p /data/vg0")
- server2.succeed("mkdir -p /data/vg0")
- server1.succeed("gluster volume create gv0 server1:/data/vg0 server2:/data/vg0")
- server1.succeed("gluster volume start gv0")
+ nodes = {
+ server1 = server;
+ server2 = server;
+ client1 = client;
+ client2 = client;
+ };
- # test clients
- client1.wait_for_unit("gluster.mount")
- client2.wait_for_unit("gluster.mount")
+ testScript = ''
+ server1.wait_for_unit("glusterd.service")
+ server2.wait_for_unit("glusterd.service")
- client1.succeed("echo test > /gluster/file1")
- client2.succeed("grep test /gluster/file1")
- '';
- }
-)
+ server1.wait_until_succeeds("gluster peer status")
+ server2.wait_until_succeeds("gluster peer status")
+
+ # establish initial contact
+ server1.succeed("gluster peer probe server2")
+ server1.succeed("gluster peer probe server1")
+
+ server1.succeed("gluster peer status | grep Connected")
+
+ # create volumes
+ server1.succeed("mkdir -p /data/vg0")
+ server2.succeed("mkdir -p /data/vg0")
+ server1.succeed("gluster volume create gv0 server1:/data/vg0 server2:/data/vg0")
+ server1.succeed("gluster volume start gv0")
+
+ # test clients
+ client1.wait_for_unit("gluster.mount")
+ client2.wait_for_unit("gluster.mount")
+
+ client1.succeed("echo test > /gluster/file1")
+ client2.succeed("grep test /gluster/file1")
+ '';
+}
diff --git a/nixos/tests/gnome-extensions.nix b/nixos/tests/gnome-extensions.nix
index d6381a899f3b..fa20d5e7e840 100644
--- a/nixos/tests/gnome-extensions.nix
+++ b/nixos/tests/gnome-extensions.nix
@@ -1,162 +1,160 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "gnome-extensions";
- meta.maintainers = [ ];
+{ pkgs, lib, ... }:
+{
+ name = "gnome-extensions";
+ meta.maintainers = [ ];
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ./common/user-account.nix ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
- # Install all extensions
- environment.systemPackages = lib.filter (e: e ? extensionUuid) (
- lib.attrValues pkgs.gnomeExtensions
- );
+ # Install all extensions
+ environment.systemPackages = lib.filter (e: e ? extensionUuid) (
+ lib.attrValues pkgs.gnomeExtensions
+ );
- # Some extensions are broken, but that's kind of the point of a testing VM
- nixpkgs.config.allowBroken = true;
- # There are some aliases which throw exceptions; ignore them.
- # Also prevent duplicate extensions under different names.
- nixpkgs.config.allowAliases = false;
+ # Some extensions are broken, but that's kind of the point of a testing VM
+ nixpkgs.config.allowBroken = true;
+ # There are some aliases which throw exceptions; ignore them.
+ # Also prevent duplicate extensions under different names.
+ nixpkgs.config.allowAliases = false;
- # Configure GDM
- services.xserver.enable = true;
- services.xserver.displayManager = {
- gdm = {
- enable = true;
- debug = true;
- wayland = true;
- };
- autoLogin = {
- enable = true;
- user = "alice";
- };
+ # Configure GDM
+ services.xserver.enable = true;
+ services.xserver.displayManager = {
+ gdm = {
+ enable = true;
+ debug = true;
+ wayland = true;
};
-
- # Configure Gnome
- services.xserver.desktopManager.gnome.enable = true;
- services.xserver.desktopManager.gnome.debug = true;
-
- systemd.user.services = {
- "org.gnome.Shell@wayland" = {
- serviceConfig = {
- ExecStart = [
- # Clear the list before overriding it.
- ""
- # Eval API is now internal so Shell needs to run in unsafe mode.
- # TODO: improve test driver so that it supports openqa-like manipulation
- # that would allow us to drop this mess.
- "${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
- ];
- };
- };
+ autoLogin = {
+ enable = true;
+ user = "alice";
};
-
};
- testScript =
- { nodes, ... }:
- let
- # Keep line widths somewhat manageable
- user = nodes.machine.users.users.alice;
- uid = toString user.uid;
- bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
- # Run a command in the appropriate user environment
- run = command: "su - ${user.name} -c '${bus} ${command}'";
+ # Configure Gnome
+ services.xserver.desktopManager.gnome.enable = true;
+ services.xserver.desktopManager.gnome.debug = true;
- # Call javascript in gnome shell, returns a tuple (success, output), where
- # `success` is true if the dbus call was successful and output is what the
- # javascript evaluates to.
- eval =
- command:
- run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
+ systemd.user.services = {
+ "org.gnome.Shell@wayland" = {
+ serviceConfig = {
+ ExecStart = [
+ # Clear the list before overriding it.
+ ""
+ # Eval API is now internal so Shell needs to run in unsafe mode.
+ # TODO: improve test driver so that it supports openqa-like manipulation
+ # that would allow us to drop this mess.
+ "${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
+ ];
+ };
+ };
+ };
- # False when startup is done
- startingUp = eval "Main.layoutManager._startingUp";
+ };
- # Extensions to keep always enabled together
- # Those are extensions that are usually always on for many users, and that we expect to work
- # well together with most others without conflicts
- alwaysOnExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
- "applications-menu"
- "user-themes"
- ];
+ testScript =
+ { nodes, ... }:
+ let
+ # Keep line widths somewhat manageable
+ user = nodes.machine.users.users.alice;
+ uid = toString user.uid;
+ bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
+ # Run a command in the appropriate user environment
+ run = command: "su - ${user.name} -c '${bus} ${command}'";
- # Extensions to enable and disable individually
- # Extensions like dash-to-dock and dash-to-panel cannot be enabled at the same time.
- testExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
- "appindicator"
- "dash-to-dock"
- "dash-to-panel"
- "ddterm"
- "gsconnect"
- "system-monitor-next"
- "desktop-icons-ng-ding"
- "workspace-indicator"
- "vitals"
- ];
- in
- ''
- with subtest("Login to GNOME with GDM"):
- # wait for gdm to start
- machine.wait_for_unit("display-manager.service")
- # wait for the wayland server
- machine.wait_for_file("/run/user/${uid}/wayland-0")
- # wait for alice to be logged in
- machine.wait_for_unit("default.target", "${user.name}")
- # check that logging in has given the user ownership of devices
- assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
+ # Call javascript in gnome shell, returns a tuple (success, output), where
+ # `success` is true if the dbus call was successful and output is what the
+ # javascript evaluates to.
+ eval =
+ command:
+ run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
- with subtest("Wait for GNOME Shell"):
- # correct output should be (true, 'false')
- machine.wait_until_succeeds(
- "${startingUp} | grep -q 'true,..false'"
- )
+ # False when startup is done
+ startingUp = eval "Main.layoutManager._startingUp";
- # Close the Activities view so that Shell can correctly track the focused window.
- machine.send_key("esc")
- # # Disable extension version validation (only use for manual testing)
- # machine.succeed(
- # "${run "gsettings set org.gnome.shell disable-extension-version-validation true"}"
- # )
+ # Extensions to keep always enabled together
+ # Those are extensions that are usually always on for many users, and that we expect to work
+ # well together with most others without conflicts
+ alwaysOnExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
+ "applications-menu"
+ "user-themes"
+ ];
- def getState(extension):
- return machine.succeed(
- f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
- )
+ # Extensions to enable and disable individually
+ # Extensions like dash-to-dock and dash-to-panel cannot be enabled at the same time.
+ testExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
+ "appindicator"
+ "dash-to-dock"
+ "dash-to-panel"
+ "ddterm"
+ "gsconnect"
+ "system-monitor-next"
+ "desktop-icons-ng-ding"
+ "workspace-indicator"
+ "vitals"
+ ];
+ in
+ ''
+ with subtest("Login to GNOME with GDM"):
+ # wait for gdm to start
+ machine.wait_for_unit("display-manager.service")
+ # wait for the wayland server
+ machine.wait_for_file("/run/user/${uid}/wayland-0")
+ # wait for alice to be logged in
+ machine.wait_for_unit("default.target", "${user.name}")
+ # check that logging in has given the user ownership of devices
+ assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
- # Assert that some extension is in a specific state
- def checkState(target, extension):
- state = getState(extension)
- assert target in state, f"{state} instead of {target}"
+ with subtest("Wait for GNOME Shell"):
+ # correct output should be (true, 'false')
+ machine.wait_until_succeeds(
+ "${startingUp} | grep -q 'true,..false'"
+ )
- def checkExtension(extension, disable):
- with subtest(f"Enable extension '{extension}'"):
- # Check that the extension is properly initialized; skip out of date ones
- state = machine.succeed(
- f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
- )
- if "OUT OF DATE" in state:
- machine.log(f"Extension {extension} will be skipped because out of date")
- return
+ # Close the Activities view so that Shell can correctly track the focused window.
+ machine.send_key("esc")
+ # # Disable extension version validation (only use for manual testing)
+ # machine.succeed(
+ # "${run "gsettings set org.gnome.shell disable-extension-version-validation true"}"
+ # )
- assert "INITIALIZED" in state, f"{state} instead of INITIALIZED"
+ def getState(extension):
+ return machine.succeed(
+ f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
+ )
- # Enable and optionally disable
+ # Assert that some extension is in a specific state
+ def checkState(target, extension):
+ state = getState(extension)
+ assert target in state, f"{state} instead of {target}"
- machine.succeed(f"${run "gnome-extensions enable {extension}"}")
- wait_time = 5
- while getState(extension) == "ACTIVATING" and (wait_time := wait_time - 1) > 0:
- machine.log(f"Extension {extension} is still activating, waiting {wait_time} more seconds")
- machine.sleep(1)
- checkState("ACTIVE", extension)
+ def checkExtension(extension, disable):
+ with subtest(f"Enable extension '{extension}'"):
+ # Check that the extension is properly initialized; skip out of date ones
+ state = machine.succeed(
+ f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
+ )
+ if "OUT OF DATE" in state:
+ machine.log(f"Extension {extension} will be skipped because out of date")
+ return
- if disable:
- machine.succeed(f"${run "gnome-extensions disable {extension}"}")
- checkState("INACTIVE", extension)
- ''
- + lib.concatLines (map (e: ''checkExtension("${e}", False)'') alwaysOnExtensions)
- + lib.concatLines (map (e: ''checkExtension("${e}", True)'') testExtensions);
- }
-)
+ assert "INITIALIZED" in state, f"{state} instead of INITIALIZED"
+
+ # Enable and optionally disable
+
+ machine.succeed(f"${run "gnome-extensions enable {extension}"}")
+ wait_time = 5
+ while getState(extension) == "ACTIVATING" and (wait_time := wait_time - 1) > 0:
+ machine.log(f"Extension {extension} is still activating, waiting {wait_time} more seconds")
+ machine.sleep(1)
+ checkState("ACTIVE", extension)
+
+ if disable:
+ machine.succeed(f"${run "gnome-extensions disable {extension}"}")
+ checkState("INACTIVE", extension)
+ ''
+ + lib.concatLines (map (e: ''checkExtension("${e}", False)'') alwaysOnExtensions)
+ + lib.concatLines (map (e: ''checkExtension("${e}", True)'') testExtensions);
+}
diff --git a/nixos/tests/gnome-flashback.nix b/nixos/tests/gnome-flashback.nix
index b96245b4461e..ceb420adaa54 100644
--- a/nixos/tests/gnome-flashback.nix
+++ b/nixos/tests/gnome-flashback.nix
@@ -1,61 +1,59 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "gnome-flashback";
- meta.maintainers = lib.teams.gnome.members ++ [ lib.maintainers.chpatrick ];
+{ pkgs, lib, ... }:
+{
+ name = "gnome-flashback";
+ meta.maintainers = lib.teams.gnome.members ++ [ lib.maintainers.chpatrick ];
- nodes.machine =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
+ nodes.machine =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
- {
- imports = [ ./common/user-account.nix ];
+ {
+ imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
+ services.xserver.enable = true;
- services.xserver.displayManager = {
- gdm.enable = true;
- gdm.debug = true;
- };
-
- services.displayManager.autoLogin = {
- enable = true;
- user = user.name;
- };
-
- services.xserver.desktopManager.gnome.enable = true;
- services.xserver.desktopManager.gnome.debug = true;
- services.xserver.desktopManager.gnome.flashback.enableMetacity = true;
- services.displayManager.defaultSession = "gnome-flashback-metacity";
+ services.xserver.displayManager = {
+ gdm.enable = true;
+ gdm.debug = true;
};
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- uid = toString user.uid;
- xauthority = "/run/user/${uid}/gdm/Xauthority";
- in
- ''
- with subtest("Login to GNOME Flashback with GDM"):
- machine.wait_for_x()
- machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"')
- # Wait for alice to be logged in"
- machine.wait_for_unit("default.target", "${user.name}")
- machine.wait_for_file("${xauthority}")
- machine.succeed("xauth merge ${xauthority}")
- # Check that logging in has given the user ownership of devices
- assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
+ services.displayManager.autoLogin = {
+ enable = true;
+ user = user.name;
+ };
- with subtest("Wait for Metacity"):
- machine.wait_until_succeeds("pgrep metacity")
+ services.xserver.desktopManager.gnome.enable = true;
+ services.xserver.desktopManager.gnome.debug = true;
+ services.xserver.desktopManager.gnome.flashback.enableMetacity = true;
+ services.displayManager.defaultSession = "gnome-flashback-metacity";
+ };
- with subtest("Regression test for #233920"):
- machine.wait_until_succeeds("pgrep -fa gnome-flashback-media-keys")
- machine.sleep(20)
- machine.screenshot("screen")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ uid = toString user.uid;
+ xauthority = "/run/user/${uid}/gdm/Xauthority";
+ in
+ ''
+ with subtest("Login to GNOME Flashback with GDM"):
+ machine.wait_for_x()
+ machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"')
+ # Wait for alice to be logged in"
+ machine.wait_for_unit("default.target", "${user.name}")
+ machine.wait_for_file("${xauthority}")
+ machine.succeed("xauth merge ${xauthority}")
+ # Check that logging in has given the user ownership of devices
+ assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
+
+ with subtest("Wait for Metacity"):
+ machine.wait_until_succeeds("pgrep metacity")
+
+ with subtest("Regression test for #233920"):
+ machine.wait_until_succeeds("pgrep -fa gnome-flashback-media-keys")
+ machine.sleep(20)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/gnome-xorg.nix b/nixos/tests/gnome-xorg.nix
index b605781ce40f..318d206d07ac 100644
--- a/nixos/tests/gnome-xorg.nix
+++ b/nixos/tests/gnome-xorg.nix
@@ -1,111 +1,109 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "gnome-xorg";
- meta = {
- maintainers = lib.teams.gnome.members;
- };
+{ pkgs, lib, ... }:
+{
+ name = "gnome-xorg";
+ meta = {
+ maintainers = lib.teams.gnome.members;
+ };
- nodes.machine =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
+ nodes.machine =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
- {
- imports = [ ./common/user-account.nix ];
+ {
+ imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
-
- services.xserver.displayManager = {
- gdm.enable = true;
- gdm.debug = true;
- };
-
- services.displayManager.autoLogin = {
- enable = true;
- user = user.name;
- };
-
- services.xserver.desktopManager.gnome.enable = true;
- services.xserver.desktopManager.gnome.debug = true;
- services.displayManager.defaultSession = "gnome-xorg";
-
- systemd.user.services = {
- "org.gnome.Shell@x11" = {
- serviceConfig = {
- ExecStart = [
- # Clear the list before overriding it.
- ""
- # Eval API is now internal so Shell needs to run in unsafe mode.
- # TODO: improve test driver so that it supports openqa-like manipulation
- # that would allow us to drop this mess.
- "${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
- ];
- };
- };
- };
+ services.xserver.enable = true;
+ services.xserver.displayManager = {
+ gdm.enable = true;
+ gdm.debug = true;
};
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- uid = toString user.uid;
- bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
- xauthority = "/run/user/${uid}/gdm/Xauthority";
- display = "DISPLAY=:0.0";
- env = "${bus} XAUTHORITY=${xauthority} ${display}";
- # Run a command in the appropriate user environment
- run = command: "su - ${user.name} -c '${bus} ${command}'";
+ services.displayManager.autoLogin = {
+ enable = true;
+ user = user.name;
+ };
- # Call javascript in gnome shell, returns a tuple (success, output), where
- # `success` is true if the dbus call was successful and output is what the
- # javascript evaluates to.
- eval =
- command:
- run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
+ services.xserver.desktopManager.gnome.enable = true;
+ services.xserver.desktopManager.gnome.debug = true;
+ services.displayManager.defaultSession = "gnome-xorg";
- # False when startup is done
- startingUp = eval "Main.layoutManager._startingUp";
+ systemd.user.services = {
+ "org.gnome.Shell@x11" = {
+ serviceConfig = {
+ ExecStart = [
+ # Clear the list before overriding it.
+ ""
+ # Eval API is now internal so Shell needs to run in unsafe mode.
+ # TODO: improve test driver so that it supports openqa-like manipulation
+ # that would allow us to drop this mess.
+ "${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
+ ];
+ };
+ };
+ };
- # Start Console
- launchConsole = run "gapplication launch org.gnome.Console";
+ };
- # Hopefully Console's wm class
- wmClass = eval "global.display.focus_window.wm_class";
- in
- ''
- with subtest("Login to GNOME Xorg with GDM"):
- machine.wait_for_x()
- # Wait for alice to be logged in"
- machine.wait_for_unit("default.target", "${user.name}")
- machine.wait_for_file("${xauthority}")
- machine.succeed("xauth merge ${xauthority}")
- # Check that logging in has given the user ownership of devices
- assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ uid = toString user.uid;
+ bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
+ xauthority = "/run/user/${uid}/gdm/Xauthority";
+ display = "DISPLAY=:0.0";
+ env = "${bus} XAUTHORITY=${xauthority} ${display}";
+ # Run a command in the appropriate user environment
+ run = command: "su - ${user.name} -c '${bus} ${command}'";
- with subtest("Wait for GNOME Shell"):
- # correct output should be (true, 'false')
- machine.wait_until_succeeds(
- "${startingUp} | grep -q 'true,..false'"
- )
+ # Call javascript in gnome shell, returns a tuple (success, output), where
+ # `success` is true if the dbus call was successful and output is what the
+ # javascript evaluates to.
+ eval =
+ command:
+ run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
- with subtest("Open Console"):
- # Close the Activities view so that Shell can correctly track the focused window.
- machine.send_key("esc")
+ # False when startup is done
+ startingUp = eval "Main.layoutManager._startingUp";
- machine.succeed(
- "${launchConsole}"
- )
- # correct output should be (true, '"kgx"')
- # For some reason, this deviates from Wayland.
- machine.wait_until_succeeds(
- "${wmClass} | grep -q 'true,...kgx'"
- )
- machine.sleep(20)
- machine.screenshot("screen")
- '';
- }
-)
+ # Start Console
+ launchConsole = run "gapplication launch org.gnome.Console";
+
+ # Hopefully Console's wm class
+ wmClass = eval "global.display.focus_window.wm_class";
+ in
+ ''
+ with subtest("Login to GNOME Xorg with GDM"):
+ machine.wait_for_x()
+ # Wait for alice to be logged in"
+ machine.wait_for_unit("default.target", "${user.name}")
+ machine.wait_for_file("${xauthority}")
+ machine.succeed("xauth merge ${xauthority}")
+ # Check that logging in has given the user ownership of devices
+ assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
+
+ with subtest("Wait for GNOME Shell"):
+ # correct output should be (true, 'false')
+ machine.wait_until_succeeds(
+ "${startingUp} | grep -q 'true,..false'"
+ )
+
+ with subtest("Open Console"):
+ # Close the Activities view so that Shell can correctly track the focused window.
+ machine.send_key("esc")
+
+ machine.succeed(
+ "${launchConsole}"
+ )
+ # correct output should be (true, '"kgx"')
+ # For some reason, this deviates from Wayland.
+ machine.wait_until_succeeds(
+ "${wmClass} | grep -q 'true,...kgx'"
+ )
+ machine.sleep(20)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/gns3-server.nix b/nixos/tests/gns3-server.nix
index 309b83053b8d..19aa1e984ed7 100644
--- a/nixos/tests/gns3-server.nix
+++ b/nixos/tests/gns3-server.nix
@@ -1,62 +1,60 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "gns3-server";
- meta.maintainers = [ lib.maintainers.anthonyroussel ];
+{ pkgs, lib, ... }:
+{
+ name = "gns3-server";
+ meta.maintainers = [ lib.maintainers.anthonyroussel ];
- nodes.machine =
- { ... }:
- let
- tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
- openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 365 \
- -subj '/CN=localhost'
- install -D -t $out key.pem cert.pem
- '';
- in
- {
- services.gns3-server = {
+ nodes.machine =
+ { ... }:
+ let
+ tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
+ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 365 \
+ -subj '/CN=localhost'
+ install -D -t $out key.pem cert.pem
+ '';
+ in
+ {
+ services.gns3-server = {
+ enable = true;
+ auth = {
enable = true;
- auth = {
- enable = true;
- user = "user";
- passwordFile = pkgs.writeText "gns3-auth-password-file" "password";
- };
- ssl = {
- enable = true;
- certFile = "${tls-cert}/cert.pem";
- keyFile = "${tls-cert}/key.pem";
- };
- dynamips.enable = true;
- ubridge.enable = true;
- vpcs.enable = true;
+ user = "user";
+ passwordFile = pkgs.writeText "gns3-auth-password-file" "password";
};
-
- security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
+ ssl = {
+ enable = true;
+ certFile = "${tls-cert}/cert.pem";
+ keyFile = "${tls-cert}/key.pem";
+ };
+ dynamips.enable = true;
+ ubridge.enable = true;
+ vpcs.enable = true;
};
- testScript =
- let
- createProject = pkgs.writeText "createProject.json" (
- builtins.toJSON {
- name = "test_project";
- }
- );
- in
- ''
- start_all()
+ security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
+ };
- machine.wait_for_unit("gns3-server.service")
- machine.wait_for_open_port(3080)
+ testScript =
+ let
+ createProject = pkgs.writeText "createProject.json" (
+ builtins.toJSON {
+ name = "test_project";
+ }
+ );
+ in
+ ''
+ start_all()
- with subtest("server is listening"):
- machine.succeed("curl -sSfL -u user:password https://localhost:3080/v2/version")
+ machine.wait_for_unit("gns3-server.service")
+ machine.wait_for_open_port(3080)
- with subtest("create dummy project"):
- machine.succeed("curl -sSfL -u user:password https://localhost:3080/v2/projects -d @${createProject}")
+ with subtest("server is listening"):
+ machine.succeed("curl -sSfL -u user:password https://localhost:3080/v2/version")
- with subtest("logging works"):
- log_path = "/var/log/gns3/server.log"
- machine.wait_for_file(log_path)
- '';
- }
-)
+ with subtest("create dummy project"):
+ machine.succeed("curl -sSfL -u user:password https://localhost:3080/v2/projects -d @${createProject}")
+
+ with subtest("logging works"):
+ log_path = "/var/log/gns3/server.log"
+ machine.wait_for_file(log_path)
+ '';
+}
diff --git a/nixos/tests/gnupg.nix b/nixos/tests/gnupg.nix
index 897c94aba507..1c720b2d6b84 100644
--- a/nixos/tests/gnupg.nix
+++ b/nixos/tests/gnupg.nix
@@ -1,127 +1,125 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- {
- name = "gnupg";
- meta = with lib.maintainers; {
- maintainers = [ rnhmjoj ];
+{
+ name = "gnupg";
+ meta = with lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
+
+ # server for testing SSH
+ nodes.server =
+ { ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+
+ users.users.alice.isNormalUser = true;
+ services.openssh.enable = true;
};
- # server for testing SSH
- nodes.server =
- { ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
+ # machine for testing GnuPG
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
- users.users.alice.isNormalUser = true;
- services.openssh.enable = true;
- };
+ users.users.alice.isNormalUser = true;
+ services.getty.autologinUser = "alice";
- # machine for testing GnuPG
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
+ environment.shellInit = ''
+ # preset a key passphrase in gpg-agent
+ preset_key() {
+ # find all keys
+ case "$1" in
+ ssh) grips=$(awk '/^[0-9A-F]/{print $1}' "''${GNUPGHOME:-$HOME/.gnupg}/sshcontrol") ;;
+ pgp) grips=$(gpg --with-keygrip --list-secret-keys | awk '/Keygrip/{print $3}') ;;
+ esac
- users.users.alice.isNormalUser = true;
- services.getty.autologinUser = "alice";
+ # try to preset the passphrase for each key found
+ for grip in $grips; do
+ "$(gpgconf --list-dirs libexecdir)/gpg-preset-passphrase" -c -P "$2" "$grip"
+ done
+ }
+ '';
- environment.shellInit = ''
- # preset a key passphrase in gpg-agent
- preset_key() {
- # find all keys
- case "$1" in
- ssh) grips=$(awk '/^[0-9A-F]/{print $1}' "''${GNUPGHOME:-$HOME/.gnupg}/sshcontrol") ;;
- pgp) grips=$(gpg --with-keygrip --list-secret-keys | awk '/Keygrip/{print $3}') ;;
- esac
+ programs.gnupg.agent.enable = true;
+ programs.gnupg.agent.enableSSHSupport = true;
+ };
- # try to preset the passphrase for each key found
- for grip in $grips; do
- "$(gpgconf --list-dirs libexecdir)/gpg-preset-passphrase" -c -P "$2" "$grip"
- done
- }
- '';
-
- programs.gnupg.agent.enable = true;
- programs.gnupg.agent.enableSSHSupport = true;
- };
-
- testScript = ''
- import shlex
+ testScript = ''
+ import shlex
- def as_alice(command: str) -> str:
- """
- Wraps a command to run it as Alice in a login shell
- """
- quoted = shlex.quote(command)
- return "su --login alice --command " + quoted
+ def as_alice(command: str) -> str:
+ """
+ Wraps a command to run it as Alice in a login shell
+ """
+ quoted = shlex.quote(command)
+ return "su --login alice --command " + quoted
- start_all()
+ start_all()
- with subtest("Wait for the autologin"):
- machine.wait_until_tty_matches("1", "alice@machine")
+ with subtest("Wait for the autologin"):
+ machine.wait_until_tty_matches("1", "alice@machine")
- with subtest("Can generate a PGP key"):
- # Note: this needs a tty because of pinentry
- machine.send_chars("gpg --gen-key\n")
- machine.wait_until_tty_matches("1", "Real name:")
- machine.send_chars("Alice\n")
- machine.wait_until_tty_matches("1", "Email address:")
- machine.send_chars("alice@machine\n")
- machine.wait_until_tty_matches("1", "Change")
- machine.send_chars("O\n")
- machine.wait_until_tty_matches("1", "Please enter")
- machine.send_chars("pgp_p4ssphrase")
- machine.send_key("tab")
- machine.send_chars("pgp_p4ssphrase")
- machine.wait_until_tty_matches("1", "Passphrases match")
- machine.send_chars("\n")
- machine.wait_until_tty_matches("1", "public and secret key created")
+ with subtest("Can generate a PGP key"):
+ # Note: this needs a tty because of pinentry
+ machine.send_chars("gpg --gen-key\n")
+ machine.wait_until_tty_matches("1", "Real name:")
+ machine.send_chars("Alice\n")
+ machine.wait_until_tty_matches("1", "Email address:")
+ machine.send_chars("alice@machine\n")
+ machine.wait_until_tty_matches("1", "Change")
+ machine.send_chars("O\n")
+ machine.wait_until_tty_matches("1", "Please enter")
+ machine.send_chars("pgp_p4ssphrase")
+ machine.send_key("tab")
+ machine.send_chars("pgp_p4ssphrase")
+ machine.wait_until_tty_matches("1", "Passphrases match")
+ machine.send_chars("\n")
+ machine.wait_until_tty_matches("1", "public and secret key created")
- with subtest("Confirm the key is in the keyring"):
- machine.wait_until_succeeds(as_alice("gpg --list-secret-keys | grep -q alice@machine"))
+ with subtest("Confirm the key is in the keyring"):
+ machine.wait_until_succeeds(as_alice("gpg --list-secret-keys | grep -q alice@machine"))
- with subtest("Can generate and add an SSH key"):
- machine.succeed(as_alice("ssh-keygen -t ed25519 -f alice -N ssh_p4ssphrase"))
+ with subtest("Can generate and add an SSH key"):
+ machine.succeed(as_alice("ssh-keygen -t ed25519 -f alice -N ssh_p4ssphrase"))
- # Note: apparently this must be run before using the OpenSSH agent
- # socket for the first time in a tty. It's not needed for `ssh`
- # because there's a hook that calls it automatically (only in NixOS).
- machine.send_chars("gpg-connect-agent updatestartuptty /bye\n")
+ # Note: apparently this must be run before using the OpenSSH agent
+ # socket for the first time in a tty. It's not needed for `ssh`
+ # because there's a hook that calls it automatically (only in NixOS).
+ machine.send_chars("gpg-connect-agent updatestartuptty /bye\n")
- # Note: again, this needs a tty because of pinentry
- machine.send_chars("ssh-add alice\n")
- machine.wait_until_tty_matches("1", "Enter passphrase")
- machine.send_chars("ssh_p4ssphrase\n")
- machine.wait_until_tty_matches("1", "Please enter")
- machine.send_chars("ssh_agent_p4ssphrase")
- machine.send_key("tab")
- machine.send_chars("ssh_agent_p4ssphrase")
- machine.wait_until_tty_matches("1", "Passphrases match")
- machine.send_chars("\n")
+ # Note: again, this needs a tty because of pinentry
+ machine.send_chars("ssh-add alice\n")
+ machine.wait_until_tty_matches("1", "Enter passphrase")
+ machine.send_chars("ssh_p4ssphrase\n")
+ machine.wait_until_tty_matches("1", "Please enter")
+ machine.send_chars("ssh_agent_p4ssphrase")
+ machine.send_key("tab")
+ machine.send_chars("ssh_agent_p4ssphrase")
+ machine.wait_until_tty_matches("1", "Passphrases match")
+ machine.send_chars("\n")
- with subtest("Confirm the SSH key has been registered"):
- machine.wait_until_succeeds(as_alice("ssh-add -l | grep -q alice@machine"))
+ with subtest("Confirm the SSH key has been registered"):
+ machine.wait_until_succeeds(as_alice("ssh-add -l | grep -q alice@machine"))
- with subtest("Can preset the key passphrases in the agent"):
- machine.succeed(as_alice("echo allow-preset-passphrase > .gnupg/gpg-agent.conf"))
- machine.succeed(as_alice("pkill gpg-agent"))
- machine.succeed(as_alice("preset_key pgp pgp_p4ssphrase"))
- machine.succeed(as_alice("preset_key ssh ssh_agent_p4ssphrase"))
+ with subtest("Can preset the key passphrases in the agent"):
+ machine.succeed(as_alice("echo allow-preset-passphrase > .gnupg/gpg-agent.conf"))
+ machine.succeed(as_alice("pkill gpg-agent"))
+ machine.succeed(as_alice("preset_key pgp pgp_p4ssphrase"))
+ machine.succeed(as_alice("preset_key ssh ssh_agent_p4ssphrase"))
- with subtest("Can encrypt and decrypt a message"):
- machine.succeed(as_alice("echo Hello | gpg -e -r alice | gpg -d | grep -q Hello"))
+ with subtest("Can encrypt and decrypt a message"):
+ machine.succeed(as_alice("echo Hello | gpg -e -r alice | gpg -d | grep -q Hello"))
- with subtest("Can log into the server"):
- # Install Alice's public key
- public_key = machine.succeed(as_alice("cat alice.pub"))
- server.succeed("mkdir /etc/ssh/authorized_keys.d")
- server.succeed(f"printf '{public_key}' > /etc/ssh/authorized_keys.d/alice")
+ with subtest("Can log into the server"):
+ # Install Alice's public key
+ public_key = machine.succeed(as_alice("cat alice.pub"))
+ server.succeed("mkdir /etc/ssh/authorized_keys.d")
+ server.succeed(f"printf '{public_key}' > /etc/ssh/authorized_keys.d/alice")
- server.wait_for_open_port(22)
- machine.succeed(as_alice("ssh -i alice -o StrictHostKeyChecking=no server exit"))
- '';
- }
-)
+ server.wait_for_open_port(22)
+ machine.succeed(as_alice("ssh -i alice -o StrictHostKeyChecking=no server exit"))
+ '';
+}
diff --git a/nixos/tests/goatcounter.nix b/nixos/tests/goatcounter.nix
index ee3b373383e2..b3dfe6f267f7 100644
--- a/nixos/tests/goatcounter.nix
+++ b/nixos/tests/goatcounter.nix
@@ -1,32 +1,30 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- {
- name = "goatcounter";
+{
+ name = "goatcounter";
- meta.maintainers = with lib.maintainers; [ bhankas ];
+ meta.maintainers = with lib.maintainers; [ bhankas ];
- nodes.machine =
- { config, ... }:
- {
- virtualisation.memorySize = 2048;
+ nodes.machine =
+ { config, ... }:
+ {
+ virtualisation.memorySize = 2048;
- services.goatcounter = {
- enable = true;
- proxy = true;
- };
+ services.goatcounter = {
+ enable = true;
+ proxy = true;
};
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("goatcounter.service")
- # wait for goatcounter to fully come up
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("goatcounter.service")
+ # wait for goatcounter to fully come up
- with subtest("goatcounter service starts"):
- machine.wait_until_succeeds(
- "curl -sSfL http://localhost:8081/ > /dev/null",
- timeout=30
- )
- '';
- }
-)
+ with subtest("goatcounter service starts"):
+ machine.wait_until_succeeds(
+ "curl -sSfL http://localhost:8081/ > /dev/null",
+ timeout=30
+ )
+ '';
+}
diff --git a/nixos/tests/gobgpd.nix b/nixos/tests/gobgpd.nix
index 029b486b7cc6..8491e1893403 100644
--- a/nixos/tests/gobgpd.nix
+++ b/nixos/tests/gobgpd.nix
@@ -1,87 +1,85 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- ifAddr =
- node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
- in
- {
- name = "gobgpd";
+{ pkgs, ... }:
+let
+ ifAddr =
+ node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
+in
+{
+ name = "gobgpd";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ higebu ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ higebu ];
+ };
- nodes = {
- node1 =
- { nodes, ... }:
- {
- environment.systemPackages = [ pkgs.gobgp ];
- networking.firewall.allowedTCPPorts = [ 179 ];
- services.gobgpd = {
- enable = true;
- settings = {
- global = {
- config = {
- as = 64512;
- router-id = "192.168.255.1";
- };
- };
- neighbors = [
- {
- config = {
- neighbor-address = ifAddr nodes.node2 "eth1";
- peer-as = 64513;
- };
- }
- ];
- };
- };
- };
- node2 =
- { nodes, ... }:
- {
- environment.systemPackages = [ pkgs.gobgp ];
- networking.firewall.allowedTCPPorts = [ 179 ];
- services.gobgpd = {
- enable = true;
- settings = {
- global = {
- config = {
- as = 64513;
- router-id = "192.168.255.2";
- };
- };
- neighbors = [
- {
- config = {
- neighbor-address = ifAddr nodes.node1 "eth1";
- peer-as = 64512;
- };
- }
- ];
- };
- };
- };
- };
-
- testScript =
+ nodes = {
+ node1 =
{ nodes, ... }:
- let
- addr1 = ifAddr nodes.node1 "eth1";
- addr2 = ifAddr nodes.node2 "eth1";
- in
- ''
- start_all()
+ {
+ environment.systemPackages = [ pkgs.gobgp ];
+ networking.firewall.allowedTCPPorts = [ 179 ];
+ services.gobgpd = {
+ enable = true;
+ settings = {
+ global = {
+ config = {
+ as = 64512;
+ router-id = "192.168.255.1";
+ };
+ };
+ neighbors = [
+ {
+ config = {
+ neighbor-address = ifAddr nodes.node2 "eth1";
+ peer-as = 64513;
+ };
+ }
+ ];
+ };
+ };
+ };
+ node2 =
+ { nodes, ... }:
+ {
+ environment.systemPackages = [ pkgs.gobgp ];
+ networking.firewall.allowedTCPPorts = [ 179 ];
+ services.gobgpd = {
+ enable = true;
+ settings = {
+ global = {
+ config = {
+ as = 64513;
+ router-id = "192.168.255.2";
+ };
+ };
+ neighbors = [
+ {
+ config = {
+ neighbor-address = ifAddr nodes.node1 "eth1";
+ peer-as = 64512;
+ };
+ }
+ ];
+ };
+ };
+ };
+ };
- for node in node1, node2:
- with subtest("should start gobgpd node"):
- node.wait_for_unit("gobgpd.service")
- with subtest("should open port 179"):
- node.wait_for_open_port(179)
+ testScript =
+ { nodes, ... }:
+ let
+ addr1 = ifAddr nodes.node1 "eth1";
+ addr2 = ifAddr nodes.node2 "eth1";
+ in
+ ''
+ start_all()
- with subtest("should show neighbors by gobgp cli and BGP state should be ESTABLISHED"):
- node1.wait_until_succeeds("gobgp neighbor ${addr2} | grep -q ESTABLISHED")
- node2.wait_until_succeeds("gobgp neighbor ${addr1} | grep -q ESTABLISHED")
- '';
- }
-)
+ for node in node1, node2:
+ with subtest("should start gobgpd node"):
+ node.wait_for_unit("gobgpd.service")
+ with subtest("should open port 179"):
+ node.wait_for_open_port(179)
+
+ with subtest("should show neighbors by gobgp cli and BGP state should be ESTABLISHED"):
+ node1.wait_until_succeeds("gobgp neighbor ${addr2} | grep -q ESTABLISHED")
+ node2.wait_until_succeeds("gobgp neighbor ${addr1} | grep -q ESTABLISHED")
+ '';
+}
diff --git a/nixos/tests/gocd-agent.nix b/nixos/tests/gocd-agent.nix
index d717299d55c7..674bc2374fd1 100644
--- a/nixos/tests/gocd-agent.nix
+++ b/nixos/tests/gocd-agent.nix
@@ -9,46 +9,44 @@ let
header = "Accept: application/vnd.go.cd.v2+json";
in
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "gocd-agent";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- grahamc
- swarren83
- ];
+{ pkgs, ... }:
+{
+ name = "gocd-agent";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ grahamc
+ swarren83
+ ];
- # gocd agent needs to register with the autoregister key created on first server startup,
- # but NixOS module doesn't seem to allow to pass during runtime currently
- broken = true;
- };
+ # gocd agent needs to register with the autoregister key created on first server startup,
+ # but NixOS module doesn't seem to allow to pass during runtime currently
+ broken = true;
+ };
- nodes = {
- agent =
- { ... }:
- {
- virtualisation.memorySize = 2046;
- services.gocd-agent = {
- enable = true;
- };
- services.gocd-server = {
- enable = true;
- };
+ nodes = {
+ agent =
+ { ... }:
+ {
+ virtualisation.memorySize = 2046;
+ services.gocd-agent = {
+ enable = true;
};
- };
+ services.gocd-server = {
+ enable = true;
+ };
+ };
+ };
- testScript = ''
- start_all()
- agent.wait_for_unit("gocd-server")
- agent.wait_for_open_port(8153)
- agent.wait_for_unit("gocd-agent")
- agent.wait_until_succeeds(
- "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].uuid"
- )
- agent.succeed(
- "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].agent_state | grep Idle"
- )
- '';
- }
-)
+ testScript = ''
+ start_all()
+ agent.wait_for_unit("gocd-server")
+ agent.wait_for_open_port(8153)
+ agent.wait_for_unit("gocd-agent")
+ agent.wait_until_succeeds(
+ "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].uuid"
+ )
+ agent.succeed(
+ "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].agent_state | grep Idle"
+ )
+ '';
+}
diff --git a/nixos/tests/gocd-server.nix b/nixos/tests/gocd-server.nix
index 95b126c55a52..cffd9f50aedd 100644
--- a/nixos/tests/gocd-server.nix
+++ b/nixos/tests/gocd-server.nix
@@ -2,29 +2,27 @@
# 1. GoCD server starts
# 2. GoCD server responds
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "gocd-server";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ swarren83 ];
- };
+{
+ name = "gocd-server";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ swarren83 ];
+ };
- nodes = {
- server =
- { ... }:
- {
- virtualisation.memorySize = 2046;
- services.gocd-server.enable = true;
- };
- };
+ nodes = {
+ server =
+ { ... }:
+ {
+ virtualisation.memorySize = 2046;
+ services.gocd-server.enable = true;
+ };
+ };
- testScript = ''
- server.start()
- server.wait_for_unit("gocd-server")
- server.wait_for_open_port(8153)
- server.wait_until_succeeds("curl -s -f localhost:8153/go")
- '';
- }
-)
+ testScript = ''
+ server.start()
+ server.wait_for_unit("gocd-server")
+ server.wait_for_open_port(8153)
+ server.wait_until_succeeds("curl -s -f localhost:8153/go")
+ '';
+}
diff --git a/nixos/tests/gollum.nix b/nixos/tests/gollum.nix
index ab937bc990bb..bf42ccc35e30 100644
--- a/nixos/tests/gollum.nix
+++ b/nixos/tests/gollum.nix
@@ -1,21 +1,19 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "gollum";
+{ pkgs, ... }:
+{
+ name = "gollum";
- nodes = {
- webserver =
- { pkgs, lib, ... }:
- {
- services.gollum.enable = true;
- };
- };
+ nodes = {
+ webserver =
+ { pkgs, lib, ... }:
+ {
+ services.gollum.enable = true;
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- webserver.wait_for_unit("gollum")
- webserver.wait_for_open_port(${toString nodes.webserver.services.gollum.port})
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ ''
+ webserver.wait_for_unit("gollum")
+ webserver.wait_for_open_port(${toString nodes.webserver.services.gollum.port})
+ '';
+}
diff --git a/nixos/tests/gonic.nix b/nixos/tests/gonic.nix
index 47d432d6354a..836e7167035f 100644
--- a/nixos/tests/gonic.nix
+++ b/nixos/tests/gonic.nix
@@ -1,31 +1,29 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "gonic";
+{ pkgs, ... }:
+{
+ name = "gonic";
- nodes.machine =
- { ... }:
- {
- systemd.tmpfiles.settings = {
- "10-gonic" = {
- "/tmp/music"."d" = { };
- "/tmp/podcast"."d" = { };
- "/tmp/playlists"."d" = { };
- };
- };
- services.gonic = {
- enable = true;
- settings = {
- music-path = [ "/tmp/music" ];
- podcast-path = "/tmp/podcast";
- playlists-path = "/tmp/playlists";
- };
+ nodes.machine =
+ { ... }:
+ {
+ systemd.tmpfiles.settings = {
+ "10-gonic" = {
+ "/tmp/music"."d" = { };
+ "/tmp/podcast"."d" = { };
+ "/tmp/playlists"."d" = { };
};
};
+ services.gonic = {
+ enable = true;
+ settings = {
+ music-path = [ "/tmp/music" ];
+ podcast-path = "/tmp/podcast";
+ playlists-path = "/tmp/playlists";
+ };
+ };
+ };
- testScript = ''
- machine.wait_for_unit("gonic")
- machine.wait_for_open_port(4747)
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("gonic")
+ machine.wait_for_open_port(4747)
+ '';
+}
diff --git a/nixos/tests/gopro-tool.nix b/nixos/tests/gopro-tool.nix
index 1f183e4c30d5..e52a6106ee41 100644
--- a/nixos/tests/gopro-tool.nix
+++ b/nixos/tests/gopro-tool.nix
@@ -1,41 +1,39 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- let
- testScript = ''
- start_all()
+let
+ testScript = ''
+ start_all()
- machine.wait_for_unit("multi-user.target")
+ machine.wait_for_unit("multi-user.target")
- # Check that gopro-tool is installed
- machine.succeed("which gopro-tool")
+ # Check that gopro-tool is installed
+ machine.succeed("which gopro-tool")
- # Check that the v4l2loopback module is available
- machine.succeed("lsmod | grep v4l2loopback || echo 'Module not found'")
+ # Check that the v4l2loopback module is available
+ machine.succeed("lsmod | grep v4l2loopback || echo 'Module not found'")
- # Check that VLC is installed
- machine.succeed("which vlc")
- '';
- in
- {
- name = "gopro-tool";
- meta.maintainers = with lib.maintainers; [ ZMon3y ];
- nodes.machine =
- { config, pkgs, ... }:
- {
- # Ensure dependencies are installed
- environment.systemPackages = with pkgs; [
- gopro-tool
- vlc
- ];
+ # Check that VLC is installed
+ machine.succeed("which vlc")
+ '';
+in
+{
+ name = "gopro-tool";
+ meta.maintainers = with lib.maintainers; [ ZMon3y ];
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ # Ensure dependencies are installed
+ environment.systemPackages = with pkgs; [
+ gopro-tool
+ vlc
+ ];
- # Load kernel module for testing
- boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
+ # Load kernel module for testing
+ boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
- # Enable module loading
- boot.kernelModules = [ "v4l2loopback" ];
- };
+ # Enable module loading
+ boot.kernelModules = [ "v4l2loopback" ];
+ };
- testScript = testScript;
- }
-)
+ testScript = testScript;
+}
diff --git a/nixos/tests/goss.nix b/nixos/tests/goss.nix
index 1bf9feda8ba3..a9d49b4ff53c 100644
--- a/nixos/tests/goss.nix
+++ b/nixos/tests/goss.nix
@@ -1,52 +1,50 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "goss";
- meta.maintainers = [ lib.maintainers.anthonyroussel ];
+{ pkgs, lib, ... }:
+{
+ name = "goss";
+ meta.maintainers = [ lib.maintainers.anthonyroussel ];
- nodes.machine = {
- environment.systemPackages = [ pkgs.jq ];
+ nodes.machine = {
+ environment.systemPackages = [ pkgs.jq ];
- services.goss = {
- enable = true;
+ services.goss = {
+ enable = true;
- environment = {
- GOSS_FMT = "json";
+ environment = {
+ GOSS_FMT = "json";
+ };
+
+ settings = {
+ addr."tcp://localhost:8080" = {
+ reachable = true;
+ local-address = "127.0.0.1";
};
-
- settings = {
- addr."tcp://localhost:8080" = {
- reachable = true;
- local-address = "127.0.0.1";
- };
- command."check-goss-version" = {
- exec = "${lib.getExe pkgs.goss} --version";
- exit-status = 0;
- };
- dns.localhost.resolvable = true;
- file."/nix" = {
- filetype = "directory";
- exists = true;
- };
- group.root.exists = true;
- kernel-param."kernel.ostype".value = "Linux";
- user.root.exists = true;
+ command."check-goss-version" = {
+ exec = "${lib.getExe pkgs.goss} --version";
+ exit-status = 0;
};
+ dns.localhost.resolvable = true;
+ file."/nix" = {
+ filetype = "directory";
+ exists = true;
+ };
+ group.root.exists = true;
+ kernel-param."kernel.ostype".value = "Linux";
+ user.root.exists = true;
};
};
+ };
- testScript = ''
- import json
+ testScript = ''
+ import json
- machine.wait_for_unit("goss.service")
- machine.wait_for_open_port(8080)
+ machine.wait_for_unit("goss.service")
+ machine.wait_for_open_port(8080)
- with subtest("returns health status"):
- result = json.loads(machine.succeed("curl -sS http://localhost:8080/healthz"))
+ with subtest("returns health status"):
+ result = json.loads(machine.succeed("curl -sS http://localhost:8080/healthz"))
- assert len(result["results"]) == 8, f".results should be an array of 10 items, was {result['results']!r}"
- assert result["summary"]["failed-count"] == 0, f".summary.failed-count should be zero, was {result['summary']['failed-count']}"
- assert result["summary"]["test-count"] == 8, f".summary.test-count should be 10, was {result['summary']['test-count']}"
- '';
- }
-)
+ assert len(result["results"]) == 8, f".results should be an array of 10 items, was {result['results']!r}"
+ assert result["summary"]["failed-count"] == 0, f".summary.failed-count should be zero, was {result['summary']['failed-count']}"
+ assert result["summary"]["test-count"] == 8, f".summary.test-count should be 10, was {result['summary']['test-count']}"
+ '';
+}
diff --git a/nixos/tests/gotenberg.nix b/nixos/tests/gotenberg.nix
index aa39b2d349d7..c640657ea872 100644
--- a/nixos/tests/gotenberg.nix
+++ b/nixos/tests/gotenberg.nix
@@ -1,26 +1,24 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "gotenberg";
- meta.maintainers = with lib.maintainers; [ pyrox0 ];
+{
+ name = "gotenberg";
+ meta.maintainers = with lib.maintainers; [ pyrox0 ];
- nodes.machine = {
- services.gotenberg = {
- enable = true;
- };
+ nodes.machine = {
+ services.gotenberg = {
+ enable = true;
};
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine.wait_for_unit("gotenberg.service")
+ machine.wait_for_unit("gotenberg.service")
- # Gotenberg startup
- machine.wait_for_open_port(3000)
+ # Gotenberg startup
+ machine.wait_for_open_port(3000)
- # Ensure healthcheck endpoint succeeds
- machine.succeed("curl http://localhost:3000/health")
- '';
- }
-)
+ # Ensure healthcheck endpoint succeeds
+ machine.succeed("curl http://localhost:3000/health")
+ '';
+}
diff --git a/nixos/tests/gotify-server.nix b/nixos/tests/gotify-server.nix
index 55f5fe6468f5..560022be89e8 100644
--- a/nixos/tests/gotify-server.nix
+++ b/nixos/tests/gotify-server.nix
@@ -1,57 +1,55 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "gotify-server";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "gotify-server";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.jq ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.jq ];
- services.gotify = {
- enable = true;
- environment = {
- GOTIFY_SERVER_PORT = 3000;
- };
+ services.gotify = {
+ enable = true;
+ environment = {
+ GOTIFY_SERVER_PORT = 3000;
};
};
+ };
- testScript = ''
- machine.start()
+ testScript = ''
+ machine.start()
- machine.wait_for_unit("gotify-server.service")
- machine.wait_for_open_port(3000)
+ machine.wait_for_unit("gotify-server.service")
+ machine.wait_for_open_port(3000)
- token = machine.succeed(
- "curl --fail -sS -X POST localhost:3000/application -F name=nixos "
- + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
- + "| jq .token | xargs echo -n"
- )
+ token = machine.succeed(
+ "curl --fail -sS -X POST localhost:3000/application -F name=nixos "
+ + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
+ + "| jq .token | xargs echo -n"
+ )
- usertoken = machine.succeed(
- "curl --fail -sS -X POST localhost:3000/client -F name=nixos "
- + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
- + "| jq .token | xargs echo -n"
- )
+ usertoken = machine.succeed(
+ "curl --fail -sS -X POST localhost:3000/client -F name=nixos "
+ + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
+ + "| jq .token | xargs echo -n"
+ )
- machine.succeed(
- f"curl --fail -sS -X POST 'localhost:3000/message?token={token}' -H 'Accept: application/json' "
- + "-F title=Gotify -F message=Works"
- )
+ machine.succeed(
+ f"curl --fail -sS -X POST 'localhost:3000/message?token={token}' -H 'Accept: application/json' "
+ + "-F title=Gotify -F message=Works"
+ )
- title = machine.succeed(
- f"curl --fail -sS 'localhost:3000/message?since=0&token={usertoken}' | jq '.messages|.[0]|.title' | xargs echo -n"
- )
+ title = machine.succeed(
+ f"curl --fail -sS 'localhost:3000/message?since=0&token={usertoken}' | jq '.messages|.[0]|.title' | xargs echo -n"
+ )
- assert title == "Gotify"
+ assert title == "Gotify"
- # Ensure that the UI responds with a successful code and that the
- # response is not empty
- result = machine.succeed("curl -fsS localhost:3000")
- assert result, "HTTP response from localhost:3000 must not be empty!"
- '';
- }
-)
+ # Ensure that the UI responds with a successful code and that the
+ # response is not empty
+ result = machine.succeed("curl -fsS localhost:3000")
+ assert result, "HTTP response from localhost:3000 must not be empty!"
+ '';
+}
diff --git a/nixos/tests/graphite.nix b/nixos/tests/graphite.nix
index 1791cb38fc62..fd5888f0c973 100644
--- a/nixos/tests/graphite.nix
+++ b/nixos/tests/graphite.nix
@@ -1,39 +1,37 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "graphite";
- nodes = {
- one =
- { ... }:
- {
- time.timeZone = "UTC";
- services.graphite = {
- web = {
- enable = true;
- extraConfig = ''
- SECRET_KEY = "abcd";
- '';
- };
- carbon.enableCache = true;
- seyren.enable = false; # Implicitly requires openssl-1.0.2u which is marked insecure
+{ pkgs, ... }:
+{
+ name = "graphite";
+ nodes = {
+ one =
+ { ... }:
+ {
+ time.timeZone = "UTC";
+ services.graphite = {
+ web = {
+ enable = true;
+ extraConfig = ''
+ SECRET_KEY = "abcd";
+ '';
};
+ carbon.enableCache = true;
+ seyren.enable = false; # Implicitly requires openssl-1.0.2u which is marked insecure
};
- };
+ };
+ };
- testScript = ''
- start_all()
- one.wait_for_unit("default.target")
- one.wait_for_unit("graphiteWeb.service")
- one.wait_for_unit("carbonCache.service")
- # The services above are of type "simple". systemd considers them active immediately
- # even if they're still in preStart (which takes quite long for graphiteWeb).
- # Wait for ports to open so we're sure the services are up and listening.
- one.wait_for_open_port(8080)
- one.wait_for_open_port(2003)
- one.succeed('echo "foo 1 `date +%s`" | nc -N localhost 2003')
- one.wait_until_succeeds(
- "curl 'http://localhost:8080/metrics/find/?query=foo&format=treejson' --silent | grep foo >&2"
- )
- '';
- }
-)
+ testScript = ''
+ start_all()
+ one.wait_for_unit("default.target")
+ one.wait_for_unit("graphiteWeb.service")
+ one.wait_for_unit("carbonCache.service")
+ # The services above are of type "simple". systemd considers them active immediately
+ # even if they're still in preStart (which takes quite long for graphiteWeb).
+ # Wait for ports to open so we're sure the services are up and listening.
+ one.wait_for_open_port(8080)
+ one.wait_for_open_port(2003)
+ one.succeed('echo "foo 1 `date +%s`" | nc -N localhost 2003')
+ one.wait_until_succeeds(
+ "curl 'http://localhost:8080/metrics/find/?query=foo&format=treejson' --silent | grep foo >&2"
+ )
+ '';
+}
diff --git a/nixos/tests/graylog.nix b/nixos/tests/graylog.nix
index 7766ad9a6a05..32c419378713 100644
--- a/nixos/tests/graylog.nix
+++ b/nixos/tests/graylog.nix
@@ -1,140 +1,138 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "graylog";
- meta.maintainers = [ ];
+{ pkgs, lib, ... }:
+{
+ name = "graylog";
+ meta.maintainers = [ ];
- nodes.machine =
- { pkgs, ... }:
- {
- virtualisation.memorySize = 4096;
- virtualisation.diskSize = 1024 * 6;
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ virtualisation.memorySize = 4096;
+ virtualisation.diskSize = 1024 * 6;
- services.mongodb.enable = true;
- services.elasticsearch.enable = true;
- services.elasticsearch.extraConf = ''
- network.publish_host: 127.0.0.1
- network.bind_host: 127.0.0.1
- '';
+ services.mongodb.enable = true;
+ services.elasticsearch.enable = true;
+ services.elasticsearch.extraConf = ''
+ network.publish_host: 127.0.0.1
+ network.bind_host: 127.0.0.1
+ '';
- services.graylog = {
- enable = true;
- passwordSecret = "YGhZ59wXMrYOojx5xdgEpBpDw2N6FbhM4lTtaJ1KPxxmKrUvSlDbtWArwAWMQ5LKx1ojHEVrQrBMVRdXbRyZLqffoUzHfssc";
- elasticsearchHosts = [ "http://localhost:9200" ];
+ services.graylog = {
+ enable = true;
+ passwordSecret = "YGhZ59wXMrYOojx5xdgEpBpDw2N6FbhM4lTtaJ1KPxxmKrUvSlDbtWArwAWMQ5LKx1ojHEVrQrBMVRdXbRyZLqffoUzHfssc";
+ elasticsearchHosts = [ "http://localhost:9200" ];
- # `echo -n "nixos" | shasum -a 256`
- rootPasswordSha2 = "6ed332bcfa615381511d4d5ba44a293bb476f368f7e9e304f0dff50230d1a85b";
- };
-
- environment.systemPackages = [ pkgs.jq ];
-
- systemd.services.graylog.path = [ pkgs.netcat ];
- systemd.services.graylog.preStart = ''
- until nc -z localhost 9200; do
- sleep 2
- done
- '';
+ # `echo -n "nixos" | shasum -a 256`
+ rootPasswordSha2 = "6ed332bcfa615381511d4d5ba44a293bb476f368f7e9e304f0dff50230d1a85b";
};
- testScript =
- let
- payloads.login = pkgs.writeText "login.json" (
- builtins.toJSON {
- host = "127.0.0.1:9000";
- username = "admin";
- password = "nixos";
- }
- );
+ environment.systemPackages = [ pkgs.jq ];
- payloads.input = pkgs.writeText "input.json" (
- builtins.toJSON {
- title = "Demo";
- global = false;
- type = "org.graylog2.inputs.gelf.udp.GELFUDPInput";
- node = "@node@";
- configuration = {
- bind_address = "0.0.0.0";
- decompress_size_limit = 8388608;
- number_worker_threads = 1;
- override_source = null;
- port = 12201;
- recv_buffer_size = 262144;
- };
- }
- );
-
- payloads.gelf_message = pkgs.writeText "gelf.json" (
- builtins.toJSON {
- host = "example.org";
- short_message = "A short message";
- full_message = "A long message";
- version = "1.1";
- level = 5;
- facility = "Test";
- }
- );
- in
- ''
- machine.start()
- machine.wait_for_unit("graylog.service")
-
- machine.wait_until_succeeds(
- "journalctl -o cat -u graylog.service | grep 'Started REST API at <127.0.0.1:9000>'"
- )
-
- machine.wait_for_open_port(9000)
- machine.succeed("curl -sSfL http://127.0.0.1:9000/")
-
- machine.wait_until_succeeds(
- "journalctl -o cat -u graylog.service | grep 'Graylog server up and running'"
- )
-
- session = machine.succeed(
- "curl -X POST "
- + "-sSfL http://127.0.0.1:9000/api/system/sessions "
- + "-d $(cat ${payloads.login}) "
- + "-H 'Content-Type: application/json' "
- + "-H 'Accept: application/json' "
- + "-H 'x-requested-by: cli' "
- + "| jq .session_id | xargs echo"
- ).rstrip()
-
- machine.succeed(
- "curl -X POST "
- + f"-sSfL http://127.0.0.1:9000/api/system/inputs -u {session}:session "
- + '-d $(cat ${payloads.input} | sed -e "s,@node@,$(cat /var/lib/graylog/server/node-id),") '
- + "-H 'Accept: application/json' "
- + "-H 'Content-Type: application/json' "
- + "-H 'x-requested-by: cli' "
- )
-
- machine.wait_until_succeeds(
- "journalctl -o cat -u graylog.service | grep -E 'Input \[GELF UDP/Demo/[[:alnum:]]{24}\] is now RUNNING'"
- )
-
- machine.wait_until_succeeds(
- "test \"$(curl -sSfL 'http://127.0.0.1:9000/api/cluster/inputstates' "
- + f"-u {session}:session "
- + "-H 'Accept: application/json' "
- + "-H 'Content-Type: application/json' "
- + "-H 'x-requested-by: cli'"
- + "| jq 'to_entries[]|.value|.[0]|.state' | xargs echo"
- + ')" = "RUNNING"'
- )
-
- machine.succeed(
- "echo -n $(cat ${payloads.gelf_message}) | nc -w10 -u 127.0.0.1 12201"
- )
-
- machine.succeed(
- 'test "$(curl -X GET '
- + "-sSfL 'http://127.0.0.1:9000/api/search/universal/relative?query=*' "
- + f"-u {session}:session "
- + "-H 'Accept: application/json' "
- + "-H 'Content-Type: application/json' "
- + "-H 'x-requested-by: cli'"
- + ' | jq \'.total_results\' | xargs echo)" = "1"'
- )
+ systemd.services.graylog.path = [ pkgs.netcat ];
+ systemd.services.graylog.preStart = ''
+ until nc -z localhost 9200; do
+ sleep 2
+ done
'';
- }
-)
+ };
+
+ testScript =
+ let
+ payloads.login = pkgs.writeText "login.json" (
+ builtins.toJSON {
+ host = "127.0.0.1:9000";
+ username = "admin";
+ password = "nixos";
+ }
+ );
+
+ payloads.input = pkgs.writeText "input.json" (
+ builtins.toJSON {
+ title = "Demo";
+ global = false;
+ type = "org.graylog2.inputs.gelf.udp.GELFUDPInput";
+ node = "@node@";
+ configuration = {
+ bind_address = "0.0.0.0";
+ decompress_size_limit = 8388608;
+ number_worker_threads = 1;
+ override_source = null;
+ port = 12201;
+ recv_buffer_size = 262144;
+ };
+ }
+ );
+
+ payloads.gelf_message = pkgs.writeText "gelf.json" (
+ builtins.toJSON {
+ host = "example.org";
+ short_message = "A short message";
+ full_message = "A long message";
+ version = "1.1";
+ level = 5;
+ facility = "Test";
+ }
+ );
+ in
+ ''
+ machine.start()
+ machine.wait_for_unit("graylog.service")
+
+ machine.wait_until_succeeds(
+ "journalctl -o cat -u graylog.service | grep 'Started REST API at <127.0.0.1:9000>'"
+ )
+
+ machine.wait_for_open_port(9000)
+ machine.succeed("curl -sSfL http://127.0.0.1:9000/")
+
+ machine.wait_until_succeeds(
+ "journalctl -o cat -u graylog.service | grep 'Graylog server up and running'"
+ )
+
+ session = machine.succeed(
+ "curl -X POST "
+ + "-sSfL http://127.0.0.1:9000/api/system/sessions "
+ + "-d $(cat ${payloads.login}) "
+ + "-H 'Content-Type: application/json' "
+ + "-H 'Accept: application/json' "
+ + "-H 'x-requested-by: cli' "
+ + "| jq .session_id | xargs echo"
+ ).rstrip()
+
+ machine.succeed(
+ "curl -X POST "
+ + f"-sSfL http://127.0.0.1:9000/api/system/inputs -u {session}:session "
+ + '-d $(cat ${payloads.input} | sed -e "s,@node@,$(cat /var/lib/graylog/server/node-id),") '
+ + "-H 'Accept: application/json' "
+ + "-H 'Content-Type: application/json' "
+ + "-H 'x-requested-by: cli' "
+ )
+
+ machine.wait_until_succeeds(
+ "journalctl -o cat -u graylog.service | grep -E 'Input \[GELF UDP/Demo/[[:alnum:]]{24}\] is now RUNNING'"
+ )
+
+ machine.wait_until_succeeds(
+ "test \"$(curl -sSfL 'http://127.0.0.1:9000/api/cluster/inputstates' "
+ + f"-u {session}:session "
+ + "-H 'Accept: application/json' "
+ + "-H 'Content-Type: application/json' "
+ + "-H 'x-requested-by: cli'"
+ + "| jq 'to_entries[]|.value|.[0]|.state' | xargs echo"
+ + ')" = "RUNNING"'
+ )
+
+ machine.succeed(
+ "echo -n $(cat ${payloads.gelf_message}) | nc -w10 -u 127.0.0.1 12201"
+ )
+
+ machine.succeed(
+ 'test "$(curl -X GET '
+ + "-sSfL 'http://127.0.0.1:9000/api/search/universal/relative?query=*' "
+ + f"-u {session}:session "
+ + "-H 'Accept: application/json' "
+ + "-H 'Content-Type: application/json' "
+ + "-H 'x-requested-by: cli'"
+ + ' | jq \'.total_results\' | xargs echo)" = "1"'
+ )
+ '';
+}
diff --git a/nixos/tests/greetd-no-shadow.nix b/nixos/tests/greetd-no-shadow.nix
index 0bbf4faa3d9c..c4cb028ff6eb 100644
--- a/nixos/tests/greetd-no-shadow.nix
+++ b/nixos/tests/greetd-no-shadow.nix
@@ -1,56 +1,54 @@
-import ./make-test-python.nix (
- {
- pkgs,
- latestKernel ? false,
- ...
- }:
- {
- name = "greetd-no-shadow";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
- };
+{
+ pkgs,
+ latestKernel ? false,
+ ...
+}:
+{
+ name = "greetd-no-shadow";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
- nodes.machine =
- { pkgs, lib, ... }:
- {
+ nodes.machine =
+ { pkgs, lib, ... }:
+ {
- users.users.alice = {
- isNormalUser = true;
- group = "alice";
- password = "foobar";
- };
- users.groups.alice = { };
+ users.users.alice = {
+ isNormalUser = true;
+ group = "alice";
+ password = "foobar";
+ };
+ users.groups.alice = { };
- # This means login(1) breaks, so we must use greetd/agreety instead.
- security.shadow.enable = false;
+ # This means login(1) breaks, so we must use greetd/agreety instead.
+ security.shadow.enable = false;
- services.greetd = {
- enable = true;
- settings = {
- default_session = {
- command = "${pkgs.greetd.greetd}/bin/agreety --cmd bash";
- };
+ services.greetd = {
+ enable = true;
+ settings = {
+ default_session = {
+ command = "${pkgs.greetd.greetd}/bin/agreety --cmd bash";
};
};
};
+ };
- testScript = ''
- machine.start()
+ testScript = ''
+ machine.start()
- machine.wait_for_unit("multi-user.target")
- machine.wait_until_succeeds("pgrep -f 'agretty.*tty1'")
- machine.screenshot("postboot")
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_until_succeeds("pgrep -f 'agretty.*tty1'")
+ machine.screenshot("postboot")
- with subtest("Log in as alice on a virtual console"):
- machine.wait_until_tty_matches("1", "login: ")
- machine.send_chars("alice\n")
- machine.wait_until_tty_matches("1", "login: alice")
- machine.wait_until_succeeds("pgrep login")
- machine.wait_until_tty_matches("1", "Password: ")
- machine.send_chars("foobar\n")
- machine.wait_until_succeeds("pgrep -u alice bash")
- machine.send_chars("touch done\n")
- machine.wait_for_file("/home/alice/done")
- '';
- }
-)
+ with subtest("Log in as alice on a virtual console"):
+ machine.wait_until_tty_matches("1", "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches("1", "login: alice")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches("1", "Password: ")
+ machine.send_chars("foobar\n")
+ machine.wait_until_succeeds("pgrep -u alice bash")
+ machine.send_chars("touch done\n")
+ machine.wait_for_file("/home/alice/done")
+ '';
+}
diff --git a/nixos/tests/grub.nix b/nixos/tests/grub.nix
index c7232a9e6940..4221eec73049 100644
--- a/nixos/tests/grub.nix
+++ b/nixos/tests/grub.nix
@@ -1,65 +1,63 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "grub";
+{ lib, ... }:
+{
+ name = "grub";
- meta = with lib.maintainers; {
- maintainers = [ rnhmjoj ];
+ meta = with lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ virtualisation.useBootLoader = true;
+
+ boot.loader.timeout = null;
+ boot.loader.grub = {
+ enable = true;
+ users.alice.password = "supersecret";
+
+ # OCR is not accurate enough
+ extraConfig = "serial; terminal_output serial";
+ };
};
- nodes.machine =
- { ... }:
- {
- virtualisation.useBootLoader = true;
-
- boot.loader.timeout = null;
- boot.loader.grub = {
- enable = true;
- users.alice.password = "supersecret";
-
- # OCR is not accurate enough
- extraConfig = "serial; terminal_output serial";
- };
- };
-
- testScript = ''
- def grub_login_as(user, password):
- """
- Enters user and password to log into GRUB
- """
- machine.wait_for_console_text("Enter username:")
- machine.send_chars(user + "\n")
- machine.wait_for_console_text("Enter password:")
- machine.send_chars(password + "\n")
+ testScript = ''
+ def grub_login_as(user, password):
+ """
+ Enters user and password to log into GRUB
+ """
+ machine.wait_for_console_text("Enter username:")
+ machine.send_chars(user + "\n")
+ machine.wait_for_console_text("Enter password:")
+ machine.send_chars(password + "\n")
- def grub_select_all_configurations():
- """
- Selects "All configurations" from the GRUB menu
- to trigger a login request.
- """
- machine.send_monitor_command("sendkey down")
- machine.send_monitor_command("sendkey ret")
+ def grub_select_all_configurations():
+ """
+ Selects "All configurations" from the GRUB menu
+ to trigger a login request.
+ """
+ machine.send_monitor_command("sendkey down")
+ machine.send_monitor_command("sendkey ret")
- machine.start()
+ machine.start()
- # wait for grub screen
- machine.wait_for_console_text("GNU GRUB")
+ # wait for grub screen
+ machine.wait_for_console_text("GNU GRUB")
- grub_select_all_configurations()
- with subtest("Invalid credentials are rejected"):
- grub_login_as("wronguser", "wrongsecret")
- machine.wait_for_console_text("error: access denied.")
+ grub_select_all_configurations()
+ with subtest("Invalid credentials are rejected"):
+ grub_login_as("wronguser", "wrongsecret")
+ machine.wait_for_console_text("error: access denied.")
- grub_select_all_configurations()
- with subtest("Valid credentials are accepted"):
- grub_login_as("alice", "supersecret")
- machine.send_chars("\n") # press enter to boot
- machine.wait_for_console_text("Linux version")
+ grub_select_all_configurations()
+ with subtest("Valid credentials are accepted"):
+ grub_login_as("alice", "supersecret")
+ machine.send_chars("\n") # press enter to boot
+ machine.wait_for_console_text("Linux version")
- with subtest("Machine boots correctly"):
- machine.wait_for_unit("multi-user.target")
- '';
- }
-)
+ with subtest("Machine boots correctly"):
+ machine.wait_for_unit("multi-user.target")
+ '';
+}
diff --git a/nixos/tests/guacamole-server.nix b/nixos/tests/guacamole-server.nix
index 41830778d836..280742f5ad0b 100644
--- a/nixos/tests/guacamole-server.nix
+++ b/nixos/tests/guacamole-server.nix
@@ -1,25 +1,23 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "guacamole-server";
+{ pkgs, lib, ... }:
+{
+ name = "guacamole-server";
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.guacamole-server = {
- enable = true;
- host = "0.0.0.0";
- };
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.guacamole-server = {
+ enable = true;
+ host = "0.0.0.0";
};
- };
+ };
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("guacamole-server.service")
- machine.wait_for_open_port(4822)
- '';
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("guacamole-server.service")
+ machine.wait_for_open_port(4822)
+ '';
- meta.maintainers = [ lib.maintainers.drupol ];
- }
-)
+ meta.maintainers = [ lib.maintainers.drupol ];
+}
diff --git a/nixos/tests/gvisor.nix b/nixos/tests/gvisor.nix
index 905abaeedc62..73b013754e81 100644
--- a/nixos/tests/gvisor.nix
+++ b/nixos/tests/gvisor.nix
@@ -1,48 +1,46 @@
# This test runs a container through gvisor and checks if simple container starts
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "gvisor";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
- };
+{ pkgs, ... }:
+{
+ name = "gvisor";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
- nodes = {
- gvisor =
- { pkgs, ... }:
- {
- virtualisation.docker = {
- enable = true;
- extraOptions = "--add-runtime runsc=${pkgs.gvisor}/bin/runsc";
- };
-
- networking = {
- dhcpcd.enable = false;
- defaultGateway = "192.168.1.1";
- interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
- {
- address = "192.168.1.2";
- prefixLength = 24;
- }
- ];
- };
+ nodes = {
+ gvisor =
+ { pkgs, ... }:
+ {
+ virtualisation.docker = {
+ enable = true;
+ extraOptions = "--add-runtime runsc=${pkgs.gvisor}/bin/runsc";
};
- };
- testScript = ''
- start_all()
+ networking = {
+ dhcpcd.enable = false;
+ defaultGateway = "192.168.1.1";
+ interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
+ {
+ address = "192.168.1.2";
+ prefixLength = 24;
+ }
+ ];
+ };
+ };
+ };
- gvisor.wait_for_unit("network.target")
- gvisor.wait_for_unit("sockets.target")
+ testScript = ''
+ start_all()
- # Test the Docker runtime
- gvisor.succeed("tar cv --files-from /dev/null | docker import - scratchimg")
- gvisor.succeed(
- "docker run -d --name=sleeping --runtime=runsc -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
- )
- gvisor.succeed("docker ps | grep sleeping")
- gvisor.succeed("docker stop sleeping")
- '';
- }
-)
+ gvisor.wait_for_unit("network.target")
+ gvisor.wait_for_unit("sockets.target")
+
+ # Test the Docker runtime
+ gvisor.succeed("tar cv --files-from /dev/null | docker import - scratchimg")
+ gvisor.succeed(
+ "docker run -d --name=sleeping --runtime=runsc -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
+ )
+ gvisor.succeed("docker ps | grep sleeping")
+ gvisor.succeed("docker stop sleeping")
+ '';
+}
diff --git a/nixos/tests/hardened.nix b/nixos/tests/hardened.nix
index 7e1301b8099a..5a11b0a90567 100644
--- a/nixos/tests/hardened.nix
+++ b/nixos/tests/hardened.nix
@@ -1,113 +1,111 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "hardened";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ joachifm ];
+{ pkgs, ... }:
+{
+ name = "hardened";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ joachifm ];
+ };
+
+ nodes.machine =
+ {
+ lib,
+ pkgs,
+ config,
+ ...
+ }:
+ {
+ users.users.alice = {
+ isNormalUser = true;
+ extraGroups = [ "proc" ];
+ };
+ users.users.sybil = {
+ isNormalUser = true;
+ group = "wheel";
+ };
+ imports = [ ../modules/profiles/hardened.nix ];
+ environment.memoryAllocator.provider = "graphene-hardened";
+ nix.settings.sandbox = false;
+ virtualisation.emptyDiskImages = [ 4096 ];
+ boot.initrd.postDeviceCommands = ''
+ ${pkgs.dosfstools}/bin/mkfs.vfat -n EFISYS /dev/vdb
+ '';
+ virtualisation.fileSystems = {
+ "/efi" = {
+ device = "/dev/disk/by-label/EFISYS";
+ fsType = "vfat";
+ options = [ "noauto" ];
+ };
+ };
+ boot.extraModulePackages = pkgs.lib.optional (pkgs.lib.versionOlder config.boot.kernelPackages.kernel.version "5.6") config.boot.kernelPackages.wireguard;
+ boot.kernelModules = [ "wireguard" ];
};
- nodes.machine =
- {
- lib,
- pkgs,
- config,
- ...
- }:
- {
- users.users.alice = {
- isNormalUser = true;
- extraGroups = [ "proc" ];
- };
- users.users.sybil = {
- isNormalUser = true;
- group = "wheel";
- };
- imports = [ ../modules/profiles/hardened.nix ];
- environment.memoryAllocator.provider = "graphene-hardened";
- nix.settings.sandbox = false;
- virtualisation.emptyDiskImages = [ 4096 ];
- boot.initrd.postDeviceCommands = ''
- ${pkgs.dosfstools}/bin/mkfs.vfat -n EFISYS /dev/vdb
- '';
- virtualisation.fileSystems = {
- "/efi" = {
- device = "/dev/disk/by-label/EFISYS";
- fsType = "vfat";
- options = [ "noauto" ];
- };
- };
- boot.extraModulePackages = pkgs.lib.optional (pkgs.lib.versionOlder config.boot.kernelPackages.kernel.version "5.6") config.boot.kernelPackages.wireguard;
- boot.kernelModules = [ "wireguard" ];
- };
-
- testScript =
- let
- hardened-malloc-tests = pkgs.graphene-hardened-malloc.ld-preload-tests;
- in
- ''
- machine.wait_for_unit("multi-user.target")
+ testScript =
+ let
+ hardened-malloc-tests = pkgs.graphene-hardened-malloc.ld-preload-tests;
+ in
+ ''
+ machine.wait_for_unit("multi-user.target")
- with subtest("AppArmor profiles are loaded"):
- machine.succeed("systemctl status apparmor.service")
+ with subtest("AppArmor profiles are loaded"):
+ machine.succeed("systemctl status apparmor.service")
- # AppArmor securityfs
- with subtest("AppArmor securityfs is mounted"):
- machine.succeed("mountpoint -q /sys/kernel/security")
- machine.succeed("cat /sys/kernel/security/apparmor/profiles")
+ # AppArmor securityfs
+ with subtest("AppArmor securityfs is mounted"):
+ machine.succeed("mountpoint -q /sys/kernel/security")
+ machine.succeed("cat /sys/kernel/security/apparmor/profiles")
- # Test loading out-of-tree modules
- with subtest("Out-of-tree modules can be loaded"):
- machine.succeed("grep -Fq wireguard /proc/modules")
+ # Test loading out-of-tree modules
+ with subtest("Out-of-tree modules can be loaded"):
+ machine.succeed("grep -Fq wireguard /proc/modules")
- # Test kernel module hardening
- with subtest("No more kernel modules can be loaded"):
- # note: this better a be module we normally wouldn't load ...
- machine.wait_for_unit("disable-kernel-module-loading.service")
- machine.fail("modprobe dccp")
+ # Test kernel module hardening
+ with subtest("No more kernel modules can be loaded"):
+ # note: this better a be module we normally wouldn't load ...
+ machine.wait_for_unit("disable-kernel-module-loading.service")
+ machine.fail("modprobe dccp")
- # Test userns
- with subtest("User namespaces are restricted"):
- machine.succeed("unshare --user true")
- machine.fail("su -l alice -c 'unshare --user true'")
+ # Test userns
+ with subtest("User namespaces are restricted"):
+ machine.succeed("unshare --user true")
+ machine.fail("su -l alice -c 'unshare --user true'")
- # Test dmesg restriction
- with subtest("Regular users cannot access dmesg"):
- machine.fail("su -l alice -c dmesg")
+ # Test dmesg restriction
+ with subtest("Regular users cannot access dmesg"):
+ machine.fail("su -l alice -c dmesg")
- # Test access to kcore
- with subtest("Kcore is inaccessible as root"):
- machine.fail("cat /proc/kcore")
+ # Test access to kcore
+ with subtest("Kcore is inaccessible as root"):
+ machine.fail("cat /proc/kcore")
- # Test deferred mount
- with subtest("Deferred mounts work"):
- machine.fail("mountpoint -q /efi") # was deferred
- machine.execute("mkdir -p /efi")
- machine.succeed("mount /dev/disk/by-label/EFISYS /efi")
- machine.succeed("mountpoint -q /efi") # now mounted
+ # Test deferred mount
+ with subtest("Deferred mounts work"):
+ machine.fail("mountpoint -q /efi") # was deferred
+ machine.execute("mkdir -p /efi")
+ machine.succeed("mount /dev/disk/by-label/EFISYS /efi")
+ machine.succeed("mountpoint -q /efi") # now mounted
- # Test Nix dæmon usage
- with subtest("nix-daemon cannot be used by all users"):
- machine.fail("su -l nobody -s /bin/sh -c 'nix --extra-experimental-features nix-command ping-store'")
- machine.succeed("su -l alice -c 'nix --extra-experimental-features nix-command ping-store'")
+ # Test Nix dæmon usage
+ with subtest("nix-daemon cannot be used by all users"):
+ machine.fail("su -l nobody -s /bin/sh -c 'nix --extra-experimental-features nix-command ping-store'")
+ machine.succeed("su -l alice -c 'nix --extra-experimental-features nix-command ping-store'")
- # Test kernel image protection
- with subtest("The kernel image is protected"):
- machine.fail("systemctl hibernate")
- machine.fail("systemctl kexec")
+ # Test kernel image protection
+ with subtest("The kernel image is protected"):
+ machine.fail("systemctl hibernate")
+ machine.fail("systemctl kexec")
- with subtest("The hardened memory allocator works"):
- machine.succeed("${hardened-malloc-tests}/bin/run-tests")
- '';
- }
-)
+ with subtest("The hardened memory allocator works"):
+ machine.succeed("${hardened-malloc-tests}/bin/run-tests")
+ '';
+}
diff --git a/nixos/tests/haste-server.nix b/nixos/tests/haste-server.nix
index 9c076155f2fc..758e5f9dcae8 100644
--- a/nixos/tests/haste-server.nix
+++ b/nixos/tests/haste-server.nix
@@ -1,27 +1,25 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "haste-server";
- meta.maintainers = with lib.maintainers; [ mkg20001 ];
+{ pkgs, lib, ... }:
+{
+ name = "haste-server";
+ meta.maintainers = with lib.maintainers; [ mkg20001 ];
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [
- curl
- jq
- ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ curl
+ jq
+ ];
- services.haste-server = {
- enable = true;
- };
+ services.haste-server = {
+ enable = true;
};
+ };
- testScript = ''
- machine.wait_for_unit("haste-server")
- machine.wait_until_succeeds("curl -s localhost:7777")
- machine.succeed('curl -s -X POST http://localhost:7777/documents -d "Hello World!" > bla')
- machine.succeed('curl http://localhost:7777/raw/$(cat bla | jq -r .key) | grep "Hello World"')
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("haste-server")
+ machine.wait_until_succeeds("curl -s localhost:7777")
+ machine.succeed('curl -s -X POST http://localhost:7777/documents -d "Hello World!" > bla')
+ machine.succeed('curl http://localhost:7777/raw/$(cat bla | jq -r .key) | grep "Hello World"')
+ '';
+}
diff --git a/nixos/tests/headscale.nix b/nixos/tests/headscale.nix
index 3ba331b7c3d4..c4e69cd1ffd5 100644
--- a/nixos/tests/headscale.nix
+++ b/nixos/tests/headscale.nix
@@ -1,93 +1,91 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
- openssl req \
- -x509 -newkey rsa:4096 -sha256 -days 365 \
- -nodes -out cert.pem -keyout key.pem \
- -subj '/CN=headscale' -addext "subjectAltName=DNS:headscale"
+{ pkgs, lib, ... }:
+let
+ tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
+ openssl req \
+ -x509 -newkey rsa:4096 -sha256 -days 365 \
+ -nodes -out cert.pem -keyout key.pem \
+ -subj '/CN=headscale' -addext "subjectAltName=DNS:headscale"
- mkdir -p $out
- cp key.pem cert.pem $out
- '';
- in
- {
- name = "headscale";
- meta.maintainers = with lib.maintainers; [
- kradalby
- misterio77
- ];
+ mkdir -p $out
+ cp key.pem cert.pem $out
+ '';
+in
+{
+ name = "headscale";
+ meta.maintainers = with lib.maintainers; [
+ kradalby
+ misterio77
+ ];
- nodes =
- let
- headscalePort = 8080;
- stunPort = 3478;
- peer = {
- services.tailscale.enable = true;
- security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
- };
- in
- {
- peer1 = peer;
- peer2 = peer;
-
- headscale = {
- services = {
- headscale = {
- enable = true;
- port = headscalePort;
- settings = {
- server_url = "https://headscale";
- ip_prefixes = [ "100.64.0.0/10" ];
- derp.server = {
- enabled = true;
- region_id = 999;
- stun_listen_addr = "0.0.0.0:${toString stunPort}";
- };
- dns.base_domain = "tailnet";
- };
- };
- nginx = {
- enable = true;
- virtualHosts.headscale = {
- addSSL = true;
- sslCertificate = "${tls-cert}/cert.pem";
- sslCertificateKey = "${tls-cert}/key.pem";
- locations."/" = {
- proxyPass = "http://127.0.0.1:${toString headscalePort}";
- proxyWebsockets = true;
- };
- };
- };
- };
- networking.firewall = {
- allowedTCPPorts = [
- 80
- 443
- ];
- allowedUDPPorts = [ stunPort ];
- };
- environment.systemPackages = [ pkgs.headscale ];
- };
+ nodes =
+ let
+ headscalePort = 8080;
+ stunPort = 3478;
+ peer = {
+ services.tailscale.enable = true;
+ security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
};
+ in
+ {
+ peer1 = peer;
+ peer2 = peer;
- testScript = ''
- start_all()
- headscale.wait_for_unit("headscale")
- headscale.wait_for_open_port(443)
+ headscale = {
+ services = {
+ headscale = {
+ enable = true;
+ port = headscalePort;
+ settings = {
+ server_url = "https://headscale";
+ ip_prefixes = [ "100.64.0.0/10" ];
+ derp.server = {
+ enabled = true;
+ region_id = 999;
+ stun_listen_addr = "0.0.0.0:${toString stunPort}";
+ };
+ dns.base_domain = "tailnet";
+ };
+ };
+ nginx = {
+ enable = true;
+ virtualHosts.headscale = {
+ addSSL = true;
+ sslCertificate = "${tls-cert}/cert.pem";
+ sslCertificateKey = "${tls-cert}/key.pem";
+ locations."/" = {
+ proxyPass = "http://127.0.0.1:${toString headscalePort}";
+ proxyWebsockets = true;
+ };
+ };
+ };
+ };
+ networking.firewall = {
+ allowedTCPPorts = [
+ 80
+ 443
+ ];
+ allowedUDPPorts = [ stunPort ];
+ };
+ environment.systemPackages = [ pkgs.headscale ];
+ };
+ };
- # Create headscale user and preauth-key
- headscale.succeed("headscale users create test")
- authkey = headscale.succeed("headscale preauthkeys -u test create --reusable")
+ testScript = ''
+ start_all()
+ headscale.wait_for_unit("headscale")
+ headscale.wait_for_open_port(443)
- # Connect peers
- up_cmd = f"tailscale up --login-server 'https://headscale' --auth-key {authkey}"
- peer1.execute(up_cmd)
- peer2.execute(up_cmd)
+ # Create headscale user and preauth-key
+ headscale.succeed("headscale users create test")
+ authkey = headscale.succeed("headscale preauthkeys -u test create --reusable")
- # Check that they are reachable from the tailnet
- peer1.wait_until_succeeds("tailscale ping peer2")
- peer2.wait_until_succeeds("tailscale ping peer1.tailnet")
- '';
- }
-)
+ # Connect peers
+ up_cmd = f"tailscale up --login-server 'https://headscale' --auth-key {authkey}"
+ peer1.execute(up_cmd)
+ peer2.execute(up_cmd)
+
+ # Check that they are reachable from the tailnet
+ peer1.wait_until_succeeds("tailscale ping peer2")
+ peer2.wait_until_succeeds("tailscale ping peer1.tailnet")
+ '';
+}
diff --git a/nixos/tests/hedgedoc.nix b/nixos/tests/hedgedoc.nix
index aa1be7421d5e..aaf83a30bfc5 100644
--- a/nixos/tests/hedgedoc.nix
+++ b/nixos/tests/hedgedoc.nix
@@ -1,104 +1,102 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "hedgedoc";
+{ pkgs, lib, ... }:
+{
+ name = "hedgedoc";
- meta = with lib.maintainers; {
- maintainers = [ willibutz ];
- };
+ meta = with lib.maintainers; {
+ maintainers = [ willibutz ];
+ };
- nodes = {
- hedgedocSqlite =
- { ... }:
- {
- services.hedgedoc.enable = true;
- };
+ nodes = {
+ hedgedocSqlite =
+ { ... }:
+ {
+ services.hedgedoc.enable = true;
+ };
- hedgedocPostgresWithTCPSocket =
- { ... }:
- {
- systemd.services.hedgedoc.after = [ "postgresql.service" ];
- services = {
- hedgedoc = {
- enable = true;
- settings.db = {
- dialect = "postgres";
- user = "hedgedoc";
- password = "$DB_PASSWORD";
- host = "localhost";
- port = 5432;
- database = "hedgedocdb";
- };
-
- /*
- Do not use pkgs.writeText for secrets as
- they will end up in the world-readable Nix store.
- */
- environmentFile = pkgs.writeText "hedgedoc-env" ''
- DB_PASSWORD=snakeoilpassword
- '';
- };
- postgresql = {
- enable = true;
- initialScript = pkgs.writeText "pg-init-script.sql" ''
- CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword';
- CREATE DATABASE hedgedocdb OWNER hedgedoc;
- '';
+ hedgedocPostgresWithTCPSocket =
+ { ... }:
+ {
+ systemd.services.hedgedoc.after = [ "postgresql.service" ];
+ services = {
+ hedgedoc = {
+ enable = true;
+ settings.db = {
+ dialect = "postgres";
+ user = "hedgedoc";
+ password = "$DB_PASSWORD";
+ host = "localhost";
+ port = 5432;
+ database = "hedgedocdb";
};
+
+ /*
+ Do not use pkgs.writeText for secrets as
+ they will end up in the world-readable Nix store.
+ */
+ environmentFile = pkgs.writeText "hedgedoc-env" ''
+ DB_PASSWORD=snakeoilpassword
+ '';
+ };
+ postgresql = {
+ enable = true;
+ initialScript = pkgs.writeText "pg-init-script.sql" ''
+ CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword';
+ CREATE DATABASE hedgedocdb OWNER hedgedoc;
+ '';
};
};
+ };
- hedgedocPostgresWithUNIXSocket =
- { ... }:
- {
- systemd.services.hedgedoc.after = [ "postgresql.service" ];
- services = {
- hedgedoc = {
- enable = true;
- settings.db = {
- dialect = "postgres";
- user = "hedgedoc";
- password = "$DB_PASSWORD";
- host = "/run/postgresql";
- database = "hedgedocdb";
- };
+ hedgedocPostgresWithUNIXSocket =
+ { ... }:
+ {
+ systemd.services.hedgedoc.after = [ "postgresql.service" ];
+ services = {
+ hedgedoc = {
+ enable = true;
+ settings.db = {
+ dialect = "postgres";
+ user = "hedgedoc";
+ password = "$DB_PASSWORD";
+ host = "/run/postgresql";
+ database = "hedgedocdb";
+ };
- environmentFile = pkgs.writeText "hedgedoc-env" ''
- DB_PASSWORD=snakeoilpassword
- '';
- };
- postgresql = {
- enable = true;
- initialScript = pkgs.writeText "pg-init-script.sql" ''
- CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword';
- CREATE DATABASE hedgedocdb OWNER hedgedoc;
- '';
- };
+ environmentFile = pkgs.writeText "hedgedoc-env" ''
+ DB_PASSWORD=snakeoilpassword
+ '';
+ };
+ postgresql = {
+ enable = true;
+ initialScript = pkgs.writeText "pg-init-script.sql" ''
+ CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword';
+ CREATE DATABASE hedgedocdb OWNER hedgedoc;
+ '';
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- with subtest("HedgeDoc sqlite"):
- hedgedocSqlite.wait_for_unit("hedgedoc.service")
- hedgedocSqlite.wait_for_open_port(3000)
- hedgedocSqlite.wait_until_succeeds("curl -sSf http://localhost:3000/new")
+ with subtest("HedgeDoc sqlite"):
+ hedgedocSqlite.wait_for_unit("hedgedoc.service")
+ hedgedocSqlite.wait_for_open_port(3000)
+ hedgedocSqlite.wait_until_succeeds("curl -sSf http://localhost:3000/new")
- with subtest("HedgeDoc postgres with TCP socket"):
- hedgedocPostgresWithTCPSocket.wait_for_unit("postgresql.service")
- hedgedocPostgresWithTCPSocket.wait_for_unit("hedgedoc.service")
- hedgedocPostgresWithTCPSocket.wait_for_open_port(5432)
- hedgedocPostgresWithTCPSocket.wait_for_open_port(3000)
- hedgedocPostgresWithTCPSocket.wait_until_succeeds("curl -sSf http://localhost:3000/new")
+ with subtest("HedgeDoc postgres with TCP socket"):
+ hedgedocPostgresWithTCPSocket.wait_for_unit("postgresql.service")
+ hedgedocPostgresWithTCPSocket.wait_for_unit("hedgedoc.service")
+ hedgedocPostgresWithTCPSocket.wait_for_open_port(5432)
+ hedgedocPostgresWithTCPSocket.wait_for_open_port(3000)
+ hedgedocPostgresWithTCPSocket.wait_until_succeeds("curl -sSf http://localhost:3000/new")
- with subtest("HedgeDoc postgres with UNIX socket"):
- hedgedocPostgresWithUNIXSocket.wait_for_unit("postgresql.service")
- hedgedocPostgresWithUNIXSocket.wait_for_unit("hedgedoc.service")
- hedgedocPostgresWithUNIXSocket.wait_for_open_port(5432)
- hedgedocPostgresWithUNIXSocket.wait_for_open_port(3000)
- hedgedocPostgresWithUNIXSocket.wait_until_succeeds("curl -sSf http://localhost:3000/new")
- '';
- }
-)
+ with subtest("HedgeDoc postgres with UNIX socket"):
+ hedgedocPostgresWithUNIXSocket.wait_for_unit("postgresql.service")
+ hedgedocPostgresWithUNIXSocket.wait_for_unit("hedgedoc.service")
+ hedgedocPostgresWithUNIXSocket.wait_for_open_port(5432)
+ hedgedocPostgresWithUNIXSocket.wait_for_open_port(3000)
+ hedgedocPostgresWithUNIXSocket.wait_until_succeeds("curl -sSf http://localhost:3000/new")
+ '';
+}
diff --git a/nixos/tests/herbstluftwm.nix b/nixos/tests/herbstluftwm.nix
index 84e6985803c3..5f6678e41fff 100644
--- a/nixos/tests/herbstluftwm.nix
+++ b/nixos/tests/herbstluftwm.nix
@@ -1,45 +1,43 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "herbstluftwm";
+{ lib, ... }:
+{
+ name = "herbstluftwm";
- meta = {
- maintainers = with lib.maintainers; [ thibautmarty ];
+ meta = {
+ maintainers = with lib.maintainers; [ thibautmarty ];
+ };
+
+ nodes.machine =
+ { pkgs, lib, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ./common/user-account.nix
+ ];
+ test-support.displayManager.auto.user = "alice";
+ services.displayManager.defaultSession = lib.mkForce "none+herbstluftwm";
+ services.xserver.windowManager.herbstluftwm.enable = true;
+ environment.systemPackages = [ pkgs.dzen2 ]; # needed for upstream provided panel
};
- nodes.machine =
- { pkgs, lib, ... }:
- {
- imports = [
- ./common/x11.nix
- ./common/user-account.nix
- ];
- test-support.displayManager.auto.user = "alice";
- services.displayManager.defaultSession = lib.mkForce "none+herbstluftwm";
- services.xserver.windowManager.herbstluftwm.enable = true;
- environment.systemPackages = [ pkgs.dzen2 ]; # needed for upstream provided panel
- };
+ testScript = ''
+ with subtest("ensure x starts"):
+ machine.wait_for_x()
+ machine.wait_for_file("/home/alice/.Xauthority")
+ machine.succeed("xauth merge ~alice/.Xauthority")
- testScript = ''
- with subtest("ensure x starts"):
- machine.wait_for_x()
- machine.wait_for_file("/home/alice/.Xauthority")
- machine.succeed("xauth merge ~alice/.Xauthority")
+ with subtest("ensure client is available"):
+ machine.succeed("herbstclient --version")
- with subtest("ensure client is available"):
- machine.succeed("herbstclient --version")
+ with subtest("ensure keybindings are set"):
+ machine.wait_until_succeeds("herbstclient list_keybinds | grep xterm")
- with subtest("ensure keybindings are set"):
- machine.wait_until_succeeds("herbstclient list_keybinds | grep xterm")
+ with subtest("ensure panel starts"):
+ machine.wait_for_window("dzen title")
- with subtest("ensure panel starts"):
- machine.wait_for_window("dzen title")
-
- with subtest("ensure we can open a new terminal"):
- machine.send_key("alt-ret")
- machine.wait_for_window(r"alice.*?machine")
- machine.sleep(2)
- machine.screenshot("terminal")
- '';
- }
-)
+ with subtest("ensure we can open a new terminal"):
+ machine.send_key("alt-ret")
+ machine.wait_for_window(r"alice.*?machine")
+ machine.sleep(2)
+ machine.screenshot("terminal")
+ '';
+}
diff --git a/nixos/tests/hledger-web.nix b/nixos/tests/hledger-web.nix
index fcb3c7f656aa..705288dc4e71 100644
--- a/nixos/tests/hledger-web.nix
+++ b/nixos/tests/hledger-web.nix
@@ -1,56 +1,54 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- journal = pkgs.writeText "test.journal" ''
- 2010/01/10 Loan
- assets:cash 500$
- income:loan -500$
- 2010/01/10 NixOS Foundation donation
- expenses:donation 250$
- assets:cash -250$
- '';
- in
- rec {
- name = "hledger-web";
- meta.maintainers = with lib.maintainers; [ marijanp ];
+{ pkgs, lib, ... }:
+let
+ journal = pkgs.writeText "test.journal" ''
+ 2010/01/10 Loan
+ assets:cash 500$
+ income:loan -500$
+ 2010/01/10 NixOS Foundation donation
+ expenses:donation 250$
+ assets:cash -250$
+ '';
+in
+rec {
+ name = "hledger-web";
+ meta.maintainers = with lib.maintainers; [ marijanp ];
- nodes = rec {
- server =
- { config, pkgs, ... }:
- {
- services.hledger-web = {
- host = "127.0.0.1";
- port = 5000;
- enable = true;
- allow = "edit";
- };
- networking.firewall.allowedTCPPorts = [ config.services.hledger-web.port ];
- systemd.services.hledger-web.preStart = ''
- ln -s ${journal} /var/lib/hledger-web/.hledger.journal
- '';
+ nodes = rec {
+ server =
+ { config, pkgs, ... }:
+ {
+ services.hledger-web = {
+ host = "127.0.0.1";
+ port = 5000;
+ enable = true;
+ allow = "edit";
};
- apiserver =
- { ... }:
- {
- imports = [ server ];
- services.hledger-web.serveApi = true;
- };
- };
+ networking.firewall.allowedTCPPorts = [ config.services.hledger-web.port ];
+ systemd.services.hledger-web.preStart = ''
+ ln -s ${journal} /var/lib/hledger-web/.hledger.journal
+ '';
+ };
+ apiserver =
+ { ... }:
+ {
+ imports = [ server ];
+ services.hledger-web.serveApi = true;
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- server.wait_for_unit("hledger-web.service")
- server.wait_for_open_port(5000)
- with subtest("Check if web UI is accessible"):
- page = server.succeed("curl -L http://127.0.0.1:5000")
- assert ".hledger.journal" in page
+ server.wait_for_unit("hledger-web.service")
+ server.wait_for_open_port(5000)
+ with subtest("Check if web UI is accessible"):
+ page = server.succeed("curl -L http://127.0.0.1:5000")
+ assert ".hledger.journal" in page
- apiserver.wait_for_unit("hledger-web.service")
- apiserver.wait_for_open_port(5000)
- with subtest("Check if the JSON API is served"):
- transactions = apiserver.succeed("curl -L http://127.0.0.1:5000/transactions")
- assert "NixOS Foundation donation" in transactions
- '';
- }
-)
+ apiserver.wait_for_unit("hledger-web.service")
+ apiserver.wait_for_open_port(5000)
+ with subtest("Check if the JSON API is served"):
+ transactions = apiserver.succeed("curl -L http://127.0.0.1:5000/transactions")
+ assert "NixOS Foundation donation" in transactions
+ '';
+}
diff --git a/nixos/tests/hockeypuck.nix b/nixos/tests/hockeypuck.nix
index bc24ceb4b70f..d1b5037fbe26 100644
--- a/nixos/tests/hockeypuck.nix
+++ b/nixos/tests/hockeypuck.nix
@@ -1,72 +1,70 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- let
- gpgKeyring = (
- pkgs.runCommand "gpg-keyring" { buildInputs = [ pkgs.gnupg ]; } ''
- mkdir -p $out
- export GNUPGHOME=$out
- cat > foo < foo <OpenPGP Keyserver" in response, "HTML title not found"
+ assert "OpenPGP Keyserver" in response, "HTML title not found"
- # Copy the keyring
- machine.succeed("cp -R ${gpgKeyring} /tmp/GNUPGHOME")
+ # Copy the keyring
+ machine.succeed("cp -R ${gpgKeyring} /tmp/GNUPGHOME")
- # Extract our GPG key id
- keyId = machine.succeed("GNUPGHOME=/tmp/GNUPGHOME gpg --list-keys | grep dsa1024 --after-context=1 | grep -v dsa1024").strip()
+ # Extract our GPG key id
+ keyId = machine.succeed("GNUPGHOME=/tmp/GNUPGHOME gpg --list-keys | grep dsa1024 --after-context=1 | grep -v dsa1024").strip()
- # Send the key to our local keyserver
- machine.succeed("GNUPGHOME=/tmp/GNUPGHOME gpg --keyserver hkp://127.0.0.1:11371 --send-keys " + keyId)
+ # Send the key to our local keyserver
+ machine.succeed("GNUPGHOME=/tmp/GNUPGHOME gpg --keyserver hkp://127.0.0.1:11371 --send-keys " + keyId)
- # Receive the key from our local keyserver to a separate directory
- machine.succeed("GNUPGHOME=$(mktemp -d) gpg --keyserver hkp://127.0.0.1:11371 --recv-keys " + keyId)
- '';
- }
-)
+ # Receive the key from our local keyserver to a separate directory
+ machine.succeed("GNUPGHOME=$(mktemp -d) gpg --keyserver hkp://127.0.0.1:11371 --recv-keys " + keyId)
+ '';
+}
diff --git a/nixos/tests/homebox.nix b/nixos/tests/homebox.nix
index aadcd4269774..160d09f116bb 100644
--- a/nixos/tests/homebox.nix
+++ b/nixos/tests/homebox.nix
@@ -1,43 +1,41 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- port = "7745";
- in
- {
- name = "homebox";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ patrickdag ];
- };
- nodes =
- let
- self = {
- simple = {
- services.homebox = {
- enable = true;
- settings.HBOX_WEB_PORT = port;
- };
- };
-
- postgres = {
- imports = [ self.simple ];
- services.homebox.database.createLocally = true;
+{ pkgs, ... }:
+let
+ port = "7745";
+in
+{
+ name = "homebox";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ patrickdag ];
+ };
+ nodes =
+ let
+ self = {
+ simple = {
+ services.homebox = {
+ enable = true;
+ settings.HBOX_WEB_PORT = port;
};
};
- in
- self;
- testScript = ''
- def test_homebox(node):
- node.wait_for_unit("homebox.service")
- node.wait_for_open_port(${port})
- node.succeed("curl --fail -X GET 'http://localhost:${port}/'")
- out = node.succeed("curl --fail 'http://localhost:${port}/api/v1/status'")
- assert '"health":true' in out
+ postgres = {
+ imports = [ self.simple ];
+ services.homebox.database.createLocally = true;
+ };
+ };
+ in
+ self;
+ testScript = ''
+ def test_homebox(node):
+ node.wait_for_unit("homebox.service")
+ node.wait_for_open_port(${port})
- test_homebox(simple)
- simple.send_monitor_command("quit")
- simple.wait_for_shutdown()
- test_homebox(postgres)
- '';
- }
-)
+ node.succeed("curl --fail -X GET 'http://localhost:${port}/'")
+ out = node.succeed("curl --fail 'http://localhost:${port}/api/v1/status'")
+ assert '"health":true' in out
+
+ test_homebox(simple)
+ simple.send_monitor_command("quit")
+ simple.wait_for_shutdown()
+ test_homebox(postgres)
+ '';
+}
diff --git a/nixos/tests/hound.nix b/nixos/tests/hound.nix
index b73ba27bed29..59574b6ce937 100644
--- a/nixos/tests/hound.nix
+++ b/nixos/tests/hound.nix
@@ -1,62 +1,60 @@
# Test whether `houndd` indexes nixpkgs
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "hound";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ grahamc ];
- };
- nodes.machine =
- { pkgs, ... }:
- {
- services.hound = {
- enable = true;
- settings = {
- "max-concurrent-indexers" = 1;
- "dbpath" = "/var/lib/hound/data";
- "repos" = {
- "nix" = {
- "url" = "file:///var/lib/hound/my-git";
- };
+{ pkgs, ... }:
+{
+ name = "hound";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ grahamc ];
+ };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.hound = {
+ enable = true;
+ settings = {
+ "max-concurrent-indexers" = 1;
+ "dbpath" = "/var/lib/hound/data";
+ "repos" = {
+ "nix" = {
+ "url" = "file:///var/lib/hound/my-git";
};
};
};
-
- systemd.services.houndseed = {
- description = "seed hound with a git repo";
- requiredBy = [ "hound.service" ];
- before = [ "hound.service" ];
-
- serviceConfig = {
- User = "hound";
- Group = "hound";
- WorkingDirectory = "/var/lib/hound";
- };
- path = [ pkgs.git ];
- script = ''
- git config --global user.email "you@example.com"
- git config --global user.name "Your Name"
- git init my-git --bare
- git init my-git-clone
- cd my-git-clone
- echo 'hi nix!' > hello
- git add hello
- git commit -m "hello there :)"
- git remote add origin /var/lib/hound/my-git
- git push origin master
- '';
- };
};
- testScript = ''
- start_all()
+ systemd.services.houndseed = {
+ description = "seed hound with a git repo";
+ requiredBy = [ "hound.service" ];
+ before = [ "hound.service" ];
- machine.wait_for_unit("network.target")
- machine.wait_for_unit("hound.service")
- machine.wait_for_open_port(6080)
- machine.wait_until_succeeds(
- "curl -f http://127.0.0.1:6080/api/v1/search\?stats\=fosho\&repos\=\*\&rng=%3A20\&q\=hi\&files\=\&i=nope | grep 'Filename' | grep 'hello'"
- )
- '';
- }
-)
+ serviceConfig = {
+ User = "hound";
+ Group = "hound";
+ WorkingDirectory = "/var/lib/hound";
+ };
+ path = [ pkgs.git ];
+ script = ''
+ git config --global user.email "you@example.com"
+ git config --global user.name "Your Name"
+ git init my-git --bare
+ git init my-git-clone
+ cd my-git-clone
+ echo 'hi nix!' > hello
+ git add hello
+ git commit -m "hello there :)"
+ git remote add origin /var/lib/hound/my-git
+ git push origin master
+ '';
+ };
+ };
+
+ testScript = ''
+ start_all()
+
+ machine.wait_for_unit("network.target")
+ machine.wait_for_unit("hound.service")
+ machine.wait_for_open_port(6080)
+ machine.wait_until_succeeds(
+ "curl -f http://127.0.0.1:6080/api/v1/search\?stats\=fosho\&repos\=\*\&rng=%3A20\&q\=hi\&files\=\&i=nope | grep 'Filename' | grep 'hello'"
+ )
+ '';
+}
diff --git a/nixos/tests/i3wm.nix b/nixos/tests/i3wm.nix
index 9dfde33aff8a..eb897573deb5 100644
--- a/nixos/tests/i3wm.nix
+++ b/nixos/tests/i3wm.nix
@@ -1,56 +1,54 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "i3wm";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ aszlig ];
+{ pkgs, ... }:
+{
+ name = "i3wm";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ aszlig ];
+ };
+
+ nodes.machine =
+ { lib, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ./common/user-account.nix
+ ];
+ test-support.displayManager.auto.user = "alice";
+ services.displayManager.defaultSession = lib.mkForce "none+i3";
+ services.xserver.windowManager.i3.enable = true;
};
- nodes.machine =
- { lib, ... }:
- {
- imports = [
- ./common/x11.nix
- ./common/user-account.nix
- ];
- test-support.displayManager.auto.user = "alice";
- services.displayManager.defaultSession = lib.mkForce "none+i3";
- services.xserver.windowManager.i3.enable = true;
- };
+ testScript =
+ { ... }:
+ ''
+ with subtest("ensure x starts"):
+ machine.wait_for_x()
+ machine.wait_for_file("/home/alice/.Xauthority")
+ machine.succeed("xauth merge ~alice/.Xauthority")
- testScript =
- { ... }:
- ''
- with subtest("ensure x starts"):
- machine.wait_for_x()
- machine.wait_for_file("/home/alice/.Xauthority")
- machine.succeed("xauth merge ~alice/.Xauthority")
+ with subtest("ensure we get first configuration window"):
+ machine.wait_for_window(r".*?first configuration.*?")
+ machine.sleep(2)
+ machine.screenshot("started")
- with subtest("ensure we get first configuration window"):
- machine.wait_for_window(r".*?first configuration.*?")
- machine.sleep(2)
- machine.screenshot("started")
+ with subtest("ensure we generate and save a config"):
+ # press return to indicate we want to gen a new config
+ machine.send_key("\n")
+ machine.sleep(2)
+ machine.screenshot("preconfig")
+ # press alt then return to indicate we want to use alt as our Mod key
+ machine.send_key("alt")
+ machine.send_key("\n")
+ machine.sleep(2)
+ # make sure the config file is created before we continue
+ machine.wait_for_file("/home/alice/.config/i3/config")
+ machine.screenshot("postconfig")
+ machine.sleep(2)
- with subtest("ensure we generate and save a config"):
- # press return to indicate we want to gen a new config
- machine.send_key("\n")
- machine.sleep(2)
- machine.screenshot("preconfig")
- # press alt then return to indicate we want to use alt as our Mod key
- machine.send_key("alt")
- machine.send_key("\n")
- machine.sleep(2)
- # make sure the config file is created before we continue
- machine.wait_for_file("/home/alice/.config/i3/config")
- machine.screenshot("postconfig")
- machine.sleep(2)
-
- with subtest("ensure we can open a new terminal"):
- machine.send_key("alt-ret")
- machine.sleep(2)
- machine.wait_for_window(r"alice.*?machine")
- machine.sleep(2)
- machine.screenshot("terminal")
- '';
- }
-)
+ with subtest("ensure we can open a new terminal"):
+ machine.send_key("alt-ret")
+ machine.sleep(2)
+ machine.wait_for_window(r"alice.*?machine")
+ machine.sleep(2)
+ machine.screenshot("terminal")
+ '';
+}
diff --git a/nixos/tests/ifm.nix b/nixos/tests/ifm.nix
index a1bc8e23a897..228f0a06c121 100644
--- a/nixos/tests/ifm.nix
+++ b/nixos/tests/ifm.nix
@@ -1,38 +1,36 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "ifm";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ litchipi ];
- };
+{
+ name = "ifm";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ litchipi ];
+ };
- nodes = {
- server = rec {
- services.ifm = {
- enable = true;
- port = 9001;
- dataDir = "/data";
- };
-
- system.activationScripts.ifm-setup-dir = ''
- mkdir -p ${services.ifm.dataDir}
- chmod u+w,g+w,o+w ${services.ifm.dataDir}
- '';
+ nodes = {
+ server = rec {
+ services.ifm = {
+ enable = true;
+ port = 9001;
+ dataDir = "/data";
};
+
+ system.activationScripts.ifm-setup-dir = ''
+ mkdir -p ${services.ifm.dataDir}
+ chmod u+w,g+w,o+w ${services.ifm.dataDir}
+ '';
};
+ };
- testScript = ''
- start_all()
- server.wait_for_unit("ifm.service")
- server.wait_for_open_port(9001)
- server.succeed("curl --fail http://localhost:9001")
+ testScript = ''
+ start_all()
+ server.wait_for_unit("ifm.service")
+ server.wait_for_open_port(9001)
+ server.succeed("curl --fail http://localhost:9001")
- server.succeed("echo \"testfile\" > testfile && shasum testfile >> checksums")
- server.succeed("curl --fail http://localhost:9001 -X POST -F \"api=upload\" -F \"dir=\" -F \"file=@testfile\" | grep \"OK\"");
- server.succeed("rm testfile")
- server.succeed("curl --fail http://localhost:9001 -X POST -F \"api=download\" -F \"filename=testfile\" -F \"dir=\" --output testfile");
- server.succeed("shasum testfile >> checksums && shasum --check checksums")
- '';
- }
-)
+ server.succeed("echo \"testfile\" > testfile && shasum testfile >> checksums")
+ server.succeed("curl --fail http://localhost:9001 -X POST -F \"api=upload\" -F \"dir=\" -F \"file=@testfile\" | grep \"OK\"");
+ server.succeed("rm testfile")
+ server.succeed("curl --fail http://localhost:9001 -X POST -F \"api=download\" -F \"filename=testfile\" -F \"dir=\" --output testfile");
+ server.succeed("shasum testfile >> checksums && shasum --check checksums")
+ '';
+}
diff --git a/nixos/tests/iftop.nix b/nixos/tests/iftop.nix
index 3b4fedbbb940..8afa314293ac 100644
--- a/nixos/tests/iftop.nix
+++ b/nixos/tests/iftop.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- {
- name = "iftop";
- meta.maintainers = with lib.maintainers; [ ma27 ];
+{
+ name = "iftop";
+ meta.maintainers = with lib.maintainers; [ ma27 ];
- nodes = {
- withIftop = {
- imports = [ ./common/user-account.nix ];
- programs.iftop.enable = true;
- };
- withoutIftop = {
- imports = [ ./common/user-account.nix ];
- environment.systemPackages = [ pkgs.iftop ];
- };
+ nodes = {
+ withIftop = {
+ imports = [ ./common/user-account.nix ];
+ programs.iftop.enable = true;
};
+ withoutIftop = {
+ imports = [ ./common/user-account.nix ];
+ environment.systemPackages = [ pkgs.iftop ];
+ };
+ };
- testScript = ''
- with subtest("machine with iftop enabled"):
- withIftop.wait_for_unit("default.target")
- # limit to eth1 (eth0 is the test driver's control interface)
- # and don't try name lookups
- withIftop.succeed("su -l alice -c 'iftop -t -s 1 -n -i eth1'")
+ testScript = ''
+ with subtest("machine with iftop enabled"):
+ withIftop.wait_for_unit("default.target")
+ # limit to eth1 (eth0 is the test driver's control interface)
+ # and don't try name lookups
+ withIftop.succeed("su -l alice -c 'iftop -t -s 1 -n -i eth1'")
- with subtest("machine without iftop"):
- withoutIftop.wait_for_unit("default.target")
- # check that iftop is there but user alice lacks capabilitie
- withoutIftop.succeed("iftop -t -s 1 -n -i eth1")
- withoutIftop.fail("su -l alice -c 'iftop -t -s 1 -n -i eth1'")
- '';
- }
-)
+ with subtest("machine without iftop"):
+ withoutIftop.wait_for_unit("default.target")
+ # check that iftop is there but user alice lacks capabilitie
+ withoutIftop.succeed("iftop -t -s 1 -n -i eth1")
+ withoutIftop.fail("su -l alice -c 'iftop -t -s 1 -n -i eth1'")
+ '';
+}
diff --git a/nixos/tests/incron.nix b/nixos/tests/incron.nix
index adbea25b9bde..dc368eb768af 100644
--- a/nixos/tests/incron.nix
+++ b/nixos/tests/incron.nix
@@ -1,55 +1,53 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- {
- name = "incron";
- meta.maintainers = [ lib.maintainers.aanderse ];
+{
+ name = "incron";
+ meta.maintainers = [ lib.maintainers.aanderse ];
- nodes.machine =
- { ... }:
- {
- services.incron.enable = true;
- services.incron.extraPackages = [ pkgs.coreutils ];
- services.incron.systab = ''
- /test IN_CREATE,IN_MODIFY,IN_CLOSE_WRITE,IN_MOVED_FROM,IN_MOVED_TO echo "$@/$# $%" >> /root/incron.log
- '';
+ nodes.machine =
+ { ... }:
+ {
+ services.incron.enable = true;
+ services.incron.extraPackages = [ pkgs.coreutils ];
+ services.incron.systab = ''
+ /test IN_CREATE,IN_MODIFY,IN_CLOSE_WRITE,IN_MOVED_FROM,IN_MOVED_TO echo "$@/$# $%" >> /root/incron.log
+ '';
- # ensure the directory to be monitored exists before incron is started
- systemd.tmpfiles.settings.incron-test = {
- "/test".d = { };
- };
+ # ensure the directory to be monitored exists before incron is started
+ systemd.tmpfiles.settings.incron-test = {
+ "/test".d = { };
};
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine.wait_for_unit("multi-user.target")
- machine.wait_for_unit("incron.service")
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_for_unit("incron.service")
- machine.succeed("test -d /test")
- # create some activity for incron to monitor
- machine.succeed("touch /test/file")
- machine.succeed("echo foo >> /test/file")
- machine.succeed("mv /test/file /root")
- machine.succeed("mv /root/file /test")
+ machine.succeed("test -d /test")
+ # create some activity for incron to monitor
+ machine.succeed("touch /test/file")
+ machine.succeed("echo foo >> /test/file")
+ machine.succeed("mv /test/file /root")
+ machine.succeed("mv /root/file /test")
- machine.sleep(1)
+ machine.sleep(1)
- # touch /test/file
- machine.succeed("grep '/test/file IN_CREATE' /root/incron.log")
+ # touch /test/file
+ machine.succeed("grep '/test/file IN_CREATE' /root/incron.log")
- # echo foo >> /test/file
- machine.succeed("grep '/test/file IN_MODIFY' /root/incron.log")
- machine.succeed("grep '/test/file IN_CLOSE_WRITE' /root/incron.log")
+ # echo foo >> /test/file
+ machine.succeed("grep '/test/file IN_MODIFY' /root/incron.log")
+ machine.succeed("grep '/test/file IN_CLOSE_WRITE' /root/incron.log")
- # mv /test/file /root
- machine.succeed("grep '/test/file IN_MOVED_FROM' /root/incron.log")
+ # mv /test/file /root
+ machine.succeed("grep '/test/file IN_MOVED_FROM' /root/incron.log")
- # mv /root/file /test
- machine.succeed("grep '/test/file IN_MOVED_TO' /root/incron.log")
+ # mv /root/file /test
+ machine.succeed("grep '/test/file IN_MOVED_TO' /root/incron.log")
- # ensure something unexpected is not present
- machine.fail("grep 'IN_OPEN' /root/incron.log")
- '';
- }
-)
+ # ensure something unexpected is not present
+ machine.fail("grep 'IN_OPEN' /root/incron.log")
+ '';
+}
diff --git a/nixos/tests/influxdb.nix b/nixos/tests/influxdb.nix
index 87b1192c3062..f8ec355469f7 100644
--- a/nixos/tests/influxdb.nix
+++ b/nixos/tests/influxdb.nix
@@ -1,45 +1,43 @@
# This test runs influxdb and checks if influxdb is up and running
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "influxdb";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ offline ];
- };
+{ pkgs, ... }:
+{
+ name = "influxdb";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ offline ];
+ };
- nodes = {
- one =
- { ... }:
- {
- services.influxdb.enable = true;
- environment.systemPackages = [ pkgs.httpie ];
- };
- };
+ nodes = {
+ one =
+ { ... }:
+ {
+ services.influxdb.enable = true;
+ environment.systemPackages = [ pkgs.httpie ];
+ };
+ };
- testScript = ''
- import shlex
+ testScript = ''
+ import shlex
- start_all()
+ start_all()
- one.wait_for_unit("influxdb.service")
+ one.wait_for_unit("influxdb.service")
- # create database
- one.succeed(
- "curl -XPOST http://localhost:8086/query --data-urlencode 'q=CREATE DATABASE test'"
- )
+ # create database
+ one.succeed(
+ "curl -XPOST http://localhost:8086/query --data-urlencode 'q=CREATE DATABASE test'"
+ )
- # write some points and run simple query
- out = one.succeed(
- "curl -XPOST 'http://localhost:8086/write?db=test' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'"
- )
+ # write some points and run simple query
+ out = one.succeed(
+ "curl -XPOST 'http://localhost:8086/write?db=test' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'"
+ )
- qv = "SELECT value FROM cpu_load_short WHERE region='us-west'"
- cmd = f'curl -GET "http://localhost:8086/query?db=test" --data-urlencode {shlex.quote("q="+ qv)}'
- out = one.succeed(cmd)
+ qv = "SELECT value FROM cpu_load_short WHERE region='us-west'"
+ cmd = f'curl -GET "http://localhost:8086/query?db=test" --data-urlencode {shlex.quote("q="+ qv)}'
+ out = one.succeed(cmd)
- assert "2015-06-11T20:46:02Z" in out
- assert "0.64" in out
- '';
- }
-)
+ assert "2015-06-11T20:46:02Z" in out
+ assert "0.64" in out
+ '';
+}
diff --git a/nixos/tests/influxdb2.nix b/nixos/tests/influxdb2.nix
index 3646960c1569..f054039fa9a3 100644
--- a/nixos/tests/influxdb2.nix
+++ b/nixos/tests/influxdb2.nix
@@ -1,241 +1,239 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "influxdb2";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ offline ];
- };
+{ pkgs, ... }:
+{
+ name = "influxdb2";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ offline ];
+ };
- nodes.machine =
- { lib, ... }:
- {
- environment.systemPackages = [ pkgs.influxdb2-cli ];
- # Make sure that the service is restarted immediately if tokens need to be rewritten
- # without relying on any Restart=on-failure behavior
- systemd.services.influxdb2.serviceConfig.RestartSec = 6000;
- services.influxdb2.enable = true;
- services.influxdb2.provision = {
- enable = true;
- initialSetup = {
- organization = "default";
- bucket = "default";
- passwordFile = pkgs.writeText "admin-pw" "ExAmPl3PA55W0rD";
- tokenFile = pkgs.writeText "admin-token" "verysecureadmintoken";
- };
- organizations.someorg = {
- buckets.somebucket = { };
- auths.sometoken = {
- description = "some auth token";
- readBuckets = [ "somebucket" ];
- writeBuckets = [ "somebucket" ];
- };
- };
- users.someuser.passwordFile = pkgs.writeText "tmp-pw" "abcgoiuhaoga";
+ nodes.machine =
+ { lib, ... }:
+ {
+ environment.systemPackages = [ pkgs.influxdb2-cli ];
+ # Make sure that the service is restarted immediately if tokens need to be rewritten
+ # without relying on any Restart=on-failure behavior
+ systemd.services.influxdb2.serviceConfig.RestartSec = 6000;
+ services.influxdb2.enable = true;
+ services.influxdb2.provision = {
+ enable = true;
+ initialSetup = {
+ organization = "default";
+ bucket = "default";
+ passwordFile = pkgs.writeText "admin-pw" "ExAmPl3PA55W0rD";
+ tokenFile = pkgs.writeText "admin-token" "verysecureadmintoken";
};
-
- specialisation.withModifications.configuration =
- { ... }:
- {
- services.influxdb2.provision = {
- organizations.someorg.buckets.somebucket.present = false;
- organizations.someorg.auths.sometoken.present = false;
- users.someuser.present = false;
-
- organizations.myorg = {
- description = "Myorg description";
- buckets.mybucket = {
- description = "Mybucket description";
- };
- auths.mytoken = {
- operator = true;
- description = "operator token";
- tokenFile = pkgs.writeText "tmp-tok" "someusertoken";
- };
- };
- users.myuser.passwordFile = pkgs.writeText "tmp-pw" "abcgoiuhaoga";
- };
- };
-
- specialisation.withParentDelete.configuration =
- { ... }:
- {
- services.influxdb2.provision = {
- organizations.someorg.present = false;
- # Deleting the parent implies:
- #organizations.someorg.buckets.somebucket.present = false;
- #organizations.someorg.auths.sometoken.present = false;
- };
- };
-
- specialisation.withNewTokens.configuration =
- { ... }:
- {
- services.influxdb2.provision = {
- organizations.default = {
- auths.operator = {
- operator = true;
- description = "new optoken";
- tokenFile = pkgs.writeText "tmp-tok" "newoptoken";
- };
- auths.allaccess = {
- operator = true;
- description = "new allaccess";
- tokenFile = pkgs.writeText "tmp-tok" "newallaccess";
- };
- auths.specifics = {
- description = "new specifics";
- readPermissions = [
- "users"
- "tasks"
- ];
- writePermissions = [ "tasks" ];
- tokenFile = pkgs.writeText "tmp-tok" "newspecificstoken";
- };
- };
- };
+ organizations.someorg = {
+ buckets.somebucket = { };
+ auths.sometoken = {
+ description = "some auth token";
+ readBuckets = [ "somebucket" ];
+ writeBuckets = [ "somebucket" ];
};
+ };
+ users.someuser.passwordFile = pkgs.writeText "tmp-pw" "abcgoiuhaoga";
};
- testScript =
- { nodes, ... }:
- let
- specialisations = "${nodes.machine.system.build.toplevel}/specialisation";
- tokenArg = "--token verysecureadmintoken";
- in
- ''
- def assert_contains(haystack, needle):
- if needle not in haystack:
- print("The haystack that will cause the following exception is:")
- print("---")
- print(haystack)
- print("---")
- raise Exception(f"Expected string '{needle}' was not found")
+ specialisation.withModifications.configuration =
+ { ... }:
+ {
+ services.influxdb2.provision = {
+ organizations.someorg.buckets.somebucket.present = false;
+ organizations.someorg.auths.sometoken.present = false;
+ users.someuser.present = false;
- def assert_lacks(haystack, needle):
- if needle in haystack:
- print("The haystack that will cause the following exception is:")
- print("---")
- print(haystack, end="")
- print("---")
- raise Exception(f"Unexpected string '{needle}' was found")
+ organizations.myorg = {
+ description = "Myorg description";
+ buckets.mybucket = {
+ description = "Mybucket description";
+ };
+ auths.mytoken = {
+ operator = true;
+ description = "operator token";
+ tokenFile = pkgs.writeText "tmp-tok" "someusertoken";
+ };
+ };
+ users.myuser.passwordFile = pkgs.writeText "tmp-pw" "abcgoiuhaoga";
+ };
+ };
+ specialisation.withParentDelete.configuration =
+ { ... }:
+ {
+ services.influxdb2.provision = {
+ organizations.someorg.present = false;
+ # Deleting the parent implies:
+ #organizations.someorg.buckets.somebucket.present = false;
+ #organizations.someorg.auths.sometoken.present = false;
+ };
+ };
+
+ specialisation.withNewTokens.configuration =
+ { ... }:
+ {
+ services.influxdb2.provision = {
+ organizations.default = {
+ auths.operator = {
+ operator = true;
+ description = "new optoken";
+ tokenFile = pkgs.writeText "tmp-tok" "newoptoken";
+ };
+ auths.allaccess = {
+ operator = true;
+ description = "new allaccess";
+ tokenFile = pkgs.writeText "tmp-tok" "newallaccess";
+ };
+ auths.specifics = {
+ description = "new specifics";
+ readPermissions = [
+ "users"
+ "tasks"
+ ];
+ writePermissions = [ "tasks" ];
+ tokenFile = pkgs.writeText "tmp-tok" "newspecificstoken";
+ };
+ };
+ };
+ };
+ };
+
+ testScript =
+ { nodes, ... }:
+ let
+ specialisations = "${nodes.machine.system.build.toplevel}/specialisation";
+ tokenArg = "--token verysecureadmintoken";
+ in
+ ''
+ def assert_contains(haystack, needle):
+ if needle not in haystack:
+ print("The haystack that will cause the following exception is:")
+ print("---")
+ print(haystack)
+ print("---")
+ raise Exception(f"Expected string '{needle}' was not found")
+
+ def assert_lacks(haystack, needle):
+ if needle in haystack:
+ print("The haystack that will cause the following exception is:")
+ print("---")
+ print(haystack, end="")
+ print("---")
+ raise Exception(f"Unexpected string '{needle}' was found")
+
+ machine.wait_for_unit("influxdb2.service")
+
+ machine.fail("curl --fail -X POST 'http://localhost:8086/api/v2/signin' -u admin:wrongpassword")
+ machine.succeed("curl --fail -X POST 'http://localhost:8086/api/v2/signin' -u admin:ExAmPl3PA55W0rD")
+
+ out = machine.succeed("influx org list ${tokenArg}")
+ assert_contains(out, "default")
+ assert_lacks(out, "myorg")
+ assert_contains(out, "someorg")
+
+ out = machine.succeed("influx bucket list ${tokenArg} --org default")
+ assert_contains(out, "default")
+
+ machine.fail("influx bucket list ${tokenArg} --org myorg")
+
+ out = machine.succeed("influx bucket list ${tokenArg} --org someorg")
+ assert_contains(out, "somebucket")
+
+ out = machine.succeed("influx user list ${tokenArg}")
+ assert_contains(out, "admin")
+ assert_lacks(out, "myuser")
+ assert_contains(out, "someuser")
+
+ out = machine.succeed("influx auth list ${tokenArg}")
+ assert_lacks(out, "operator token")
+ assert_contains(out, "some auth token")
+
+ with subtest("withModifications"):
+ machine.succeed('${specialisations}/withModifications/bin/switch-to-configuration test')
machine.wait_for_unit("influxdb2.service")
- machine.fail("curl --fail -X POST 'http://localhost:8086/api/v2/signin' -u admin:wrongpassword")
- machine.succeed("curl --fail -X POST 'http://localhost:8086/api/v2/signin' -u admin:ExAmPl3PA55W0rD")
-
out = machine.succeed("influx org list ${tokenArg}")
assert_contains(out, "default")
- assert_lacks(out, "myorg")
+ assert_contains(out, "myorg")
+ assert_contains(out, "someorg")
+
+ out = machine.succeed("influx bucket list ${tokenArg} --org myorg")
+ assert_contains(out, "mybucket")
+
+ out = machine.succeed("influx bucket list ${tokenArg} --org someorg")
+ assert_lacks(out, "somebucket")
+
+ out = machine.succeed("influx user list ${tokenArg}")
+ assert_contains(out, "admin")
+ assert_contains(out, "myuser")
+ assert_lacks(out, "someuser")
+
+ out = machine.succeed("influx auth list ${tokenArg}")
+ assert_contains(out, "operator token")
+ assert_lacks(out, "some auth token")
+
+ # Make sure the user token is also usable
+ machine.succeed("influx auth list --token someusertoken")
+
+ with subtest("keepsUnrelated"):
+ machine.succeed('${nodes.machine.system.build.toplevel}/bin/switch-to-configuration test')
+ machine.wait_for_unit("influxdb2.service")
+
+ out = machine.succeed("influx org list ${tokenArg}")
+ assert_contains(out, "default")
+ assert_contains(out, "myorg")
assert_contains(out, "someorg")
out = machine.succeed("influx bucket list ${tokenArg} --org default")
assert_contains(out, "default")
- machine.fail("influx bucket list ${tokenArg} --org myorg")
+ out = machine.succeed("influx bucket list ${tokenArg} --org myorg")
+ assert_contains(out, "mybucket")
out = machine.succeed("influx bucket list ${tokenArg} --org someorg")
assert_contains(out, "somebucket")
out = machine.succeed("influx user list ${tokenArg}")
assert_contains(out, "admin")
- assert_lacks(out, "myuser")
+ assert_contains(out, "myuser")
assert_contains(out, "someuser")
out = machine.succeed("influx auth list ${tokenArg}")
- assert_lacks(out, "operator token")
+ assert_contains(out, "operator token")
assert_contains(out, "some auth token")
- with subtest("withModifications"):
- machine.succeed('${specialisations}/withModifications/bin/switch-to-configuration test')
- machine.wait_for_unit("influxdb2.service")
+ with subtest("withParentDelete"):
+ machine.succeed('${specialisations}/withParentDelete/bin/switch-to-configuration test')
+ machine.wait_for_unit("influxdb2.service")
- out = machine.succeed("influx org list ${tokenArg}")
- assert_contains(out, "default")
- assert_contains(out, "myorg")
- assert_contains(out, "someorg")
+ out = machine.succeed("influx org list ${tokenArg}")
+ assert_contains(out, "default")
+ assert_contains(out, "myorg")
+ assert_lacks(out, "someorg")
- out = machine.succeed("influx bucket list ${tokenArg} --org myorg")
- assert_contains(out, "mybucket")
+ out = machine.succeed("influx bucket list ${tokenArg} --org default")
+ assert_contains(out, "default")
- out = machine.succeed("influx bucket list ${tokenArg} --org someorg")
- assert_lacks(out, "somebucket")
+ out = machine.succeed("influx bucket list ${tokenArg} --org myorg")
+ assert_contains(out, "mybucket")
- out = machine.succeed("influx user list ${tokenArg}")
- assert_contains(out, "admin")
- assert_contains(out, "myuser")
- assert_lacks(out, "someuser")
+ machine.fail("influx bucket list ${tokenArg} --org someorg")
- out = machine.succeed("influx auth list ${tokenArg}")
- assert_contains(out, "operator token")
- assert_lacks(out, "some auth token")
+ out = machine.succeed("influx user list ${tokenArg}")
+ assert_contains(out, "admin")
+ assert_contains(out, "myuser")
+ assert_contains(out, "someuser")
- # Make sure the user token is also usable
- machine.succeed("influx auth list --token someusertoken")
+ out = machine.succeed("influx auth list ${tokenArg}")
+ assert_contains(out, "operator token")
+ assert_lacks(out, "some auth token")
- with subtest("keepsUnrelated"):
- machine.succeed('${nodes.machine.system.build.toplevel}/bin/switch-to-configuration test')
- machine.wait_for_unit("influxdb2.service")
+ with subtest("withNewTokens"):
+ machine.succeed('${specialisations}/withNewTokens/bin/switch-to-configuration test')
+ machine.wait_for_unit("influxdb2.service")
- out = machine.succeed("influx org list ${tokenArg}")
- assert_contains(out, "default")
- assert_contains(out, "myorg")
- assert_contains(out, "someorg")
-
- out = machine.succeed("influx bucket list ${tokenArg} --org default")
- assert_contains(out, "default")
-
- out = machine.succeed("influx bucket list ${tokenArg} --org myorg")
- assert_contains(out, "mybucket")
-
- out = machine.succeed("influx bucket list ${tokenArg} --org someorg")
- assert_contains(out, "somebucket")
-
- out = machine.succeed("influx user list ${tokenArg}")
- assert_contains(out, "admin")
- assert_contains(out, "myuser")
- assert_contains(out, "someuser")
-
- out = machine.succeed("influx auth list ${tokenArg}")
- assert_contains(out, "operator token")
- assert_contains(out, "some auth token")
-
- with subtest("withParentDelete"):
- machine.succeed('${specialisations}/withParentDelete/bin/switch-to-configuration test')
- machine.wait_for_unit("influxdb2.service")
-
- out = machine.succeed("influx org list ${tokenArg}")
- assert_contains(out, "default")
- assert_contains(out, "myorg")
- assert_lacks(out, "someorg")
-
- out = machine.succeed("influx bucket list ${tokenArg} --org default")
- assert_contains(out, "default")
-
- out = machine.succeed("influx bucket list ${tokenArg} --org myorg")
- assert_contains(out, "mybucket")
-
- machine.fail("influx bucket list ${tokenArg} --org someorg")
-
- out = machine.succeed("influx user list ${tokenArg}")
- assert_contains(out, "admin")
- assert_contains(out, "myuser")
- assert_contains(out, "someuser")
-
- out = machine.succeed("influx auth list ${tokenArg}")
- assert_contains(out, "operator token")
- assert_lacks(out, "some auth token")
-
- with subtest("withNewTokens"):
- machine.succeed('${specialisations}/withNewTokens/bin/switch-to-configuration test')
- machine.wait_for_unit("influxdb2.service")
-
- out = machine.succeed("influx auth list ${tokenArg}")
- assert_contains(out, "operator token")
- assert_contains(out, "some auth token")
- assert_contains(out, "new optoken")
- assert_contains(out, "new allaccess")
- assert_contains(out, "new specifics")
- '';
- }
-)
+ out = machine.succeed("influx auth list ${tokenArg}")
+ assert_contains(out, "operator token")
+ assert_contains(out, "some auth token")
+ assert_contains(out, "new optoken")
+ assert_contains(out, "new allaccess")
+ assert_contains(out, "new specifics")
+ '';
+}
diff --git a/nixos/tests/initrd-luks-empty-passphrase.nix b/nixos/tests/initrd-luks-empty-passphrase.nix
index 2b981e009f79..e9f4a1776d52 100644
--- a/nixos/tests/initrd-luks-empty-passphrase.nix
+++ b/nixos/tests/initrd-luks-empty-passphrase.nix
@@ -4,110 +4,108 @@
pkgs ? import ../.. { inherit system config; },
systemdStage1 ? false,
}:
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- let
+{ lib, pkgs, ... }:
+let
- keyfile = pkgs.writeText "luks-keyfile" ''
- MIGHAoGBAJ4rGTSo/ldyjQypd0kuS7k2OSsmQYzMH6TNj3nQ/vIUjDn7fqa3slt2
- gV6EK3TmTbGc4tzC1v4SWx2m+2Bjdtn4Fs4wiBwn1lbRdC6i5ZYCqasTWIntWn+6
- FllUkMD5oqjOR/YcboxG8Z3B5sJuvTP9llsF+gnuveWih9dpbBr7AgEC
- '';
+ keyfile = pkgs.writeText "luks-keyfile" ''
+ MIGHAoGBAJ4rGTSo/ldyjQypd0kuS7k2OSsmQYzMH6TNj3nQ/vIUjDn7fqa3slt2
+ gV6EK3TmTbGc4tzC1v4SWx2m+2Bjdtn4Fs4wiBwn1lbRdC6i5ZYCqasTWIntWn+6
+ FllUkMD5oqjOR/YcboxG8Z3B5sJuvTP9llsF+gnuveWih9dpbBr7AgEC
+ '';
- in
- {
- name = "initrd-luks-empty-passphrase";
+in
+{
+ name = "initrd-luks-empty-passphrase";
- nodes.machine =
- { pkgs, ... }:
- {
- imports = lib.optionals (!systemdStage1) [ ./common/auto-format-root-device.nix ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = lib.optionals (!systemdStage1) [ ./common/auto-format-root-device.nix ];
- virtualisation = {
- emptyDiskImages = [ 512 ];
- useBootLoader = true;
- useEFIBoot = true;
- # This requires to have access
- # to a host Nix store as
- # the new root device is /dev/vdb
- # an empty 512MiB drive, containing no Nix store.
- mountHostNixStore = true;
- fileSystems."/".autoFormat = lib.mkIf systemdStage1 true;
- };
-
- boot.loader.systemd-boot.enable = true;
- boot.initrd.systemd = lib.mkIf systemdStage1 {
- enable = true;
- emergencyAccess = true;
- };
- environment.systemPackages = with pkgs; [ cryptsetup ];
-
- specialisation.boot-luks-wrong-keyfile.configuration = {
- boot.initrd.luks.devices = lib.mkVMOverride {
- cryptroot = {
- device = "/dev/vdb";
- keyFile = "/etc/cryptroot.key";
- tryEmptyPassphrase = true;
- fallbackToPassword = !systemdStage1;
- };
- };
- virtualisation.rootDevice = "/dev/mapper/cryptroot";
- boot.initrd.secrets."/etc/cryptroot.key" = keyfile;
- };
-
- specialisation.boot-luks-missing-keyfile.configuration = {
- boot.initrd.luks.devices = lib.mkVMOverride {
- cryptroot = {
- device = "/dev/vdb";
- keyFile = "/etc/cryptroot.key";
- tryEmptyPassphrase = true;
- fallbackToPassword = !systemdStage1;
- };
- };
- virtualisation.rootDevice = "/dev/mapper/cryptroot";
- };
+ virtualisation = {
+ emptyDiskImages = [ 512 ];
+ useBootLoader = true;
+ useEFIBoot = true;
+ # This requires to have access
+ # to a host Nix store as
+ # the new root device is /dev/vdb
+ # an empty 512MiB drive, containing no Nix store.
+ mountHostNixStore = true;
+ fileSystems."/".autoFormat = lib.mkIf systemdStage1 true;
};
- testScript = ''
- # Encrypt key with empty key so boot should try keyfile and then fallback to empty passphrase
+ boot.loader.systemd-boot.enable = true;
+ boot.initrd.systemd = lib.mkIf systemdStage1 {
+ enable = true;
+ emergencyAccess = true;
+ };
+ environment.systemPackages = with pkgs; [ cryptsetup ];
+
+ specialisation.boot-luks-wrong-keyfile.configuration = {
+ boot.initrd.luks.devices = lib.mkVMOverride {
+ cryptroot = {
+ device = "/dev/vdb";
+ keyFile = "/etc/cryptroot.key";
+ tryEmptyPassphrase = true;
+ fallbackToPassword = !systemdStage1;
+ };
+ };
+ virtualisation.rootDevice = "/dev/mapper/cryptroot";
+ boot.initrd.secrets."/etc/cryptroot.key" = keyfile;
+ };
+
+ specialisation.boot-luks-missing-keyfile.configuration = {
+ boot.initrd.luks.devices = lib.mkVMOverride {
+ cryptroot = {
+ device = "/dev/vdb";
+ keyFile = "/etc/cryptroot.key";
+ tryEmptyPassphrase = true;
+ fallbackToPassword = !systemdStage1;
+ };
+ };
+ virtualisation.rootDevice = "/dev/mapper/cryptroot";
+ };
+ };
+
+ testScript = ''
+ # Encrypt key with empty key so boot should try keyfile and then fallback to empty passphrase
- def grub_select_boot_luks_wrong_key_file():
- """
- Selects "boot-luks" from the GRUB menu
- to trigger a login request.
- """
- machine.send_monitor_command("sendkey down")
- machine.send_monitor_command("sendkey down")
- machine.send_monitor_command("sendkey ret")
+ def grub_select_boot_luks_wrong_key_file():
+ """
+ Selects "boot-luks" from the GRUB menu
+ to trigger a login request.
+ """
+ machine.send_monitor_command("sendkey down")
+ machine.send_monitor_command("sendkey down")
+ machine.send_monitor_command("sendkey ret")
- def grub_select_boot_luks_missing_key_file():
- """
- Selects "boot-luks" from the GRUB menu
- to trigger a login request.
- """
- machine.send_monitor_command("sendkey down")
- machine.send_monitor_command("sendkey ret")
+ def grub_select_boot_luks_missing_key_file():
+ """
+ Selects "boot-luks" from the GRUB menu
+ to trigger a login request.
+ """
+ machine.send_monitor_command("sendkey down")
+ machine.send_monitor_command("sendkey ret")
- # Create encrypted volume
- machine.wait_for_unit("multi-user.target")
- machine.succeed("echo "" | cryptsetup luksFormat /dev/vdb --batch-mode")
- machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks-wrong-keyfile.conf")
- machine.succeed("sync")
- machine.crash()
+ # Create encrypted volume
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("echo "" | cryptsetup luksFormat /dev/vdb --batch-mode")
+ machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks-wrong-keyfile.conf")
+ machine.succeed("sync")
+ machine.crash()
- # Check if rootfs is on /dev/mapper/cryptroot
- machine.wait_for_unit("multi-user.target")
- assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
+ # Check if rootfs is on /dev/mapper/cryptroot
+ machine.wait_for_unit("multi-user.target")
+ assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
- # Choose boot-luks-missing-keyfile specialisation
- machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks-missing-keyfile.conf")
- machine.succeed("sync")
- machine.crash()
+ # Choose boot-luks-missing-keyfile specialisation
+ machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks-missing-keyfile.conf")
+ machine.succeed("sync")
+ machine.crash()
- # Check if rootfs is on /dev/mapper/cryptroot
- machine.wait_for_unit("multi-user.target")
- assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
- '';
- }
-)
+ # Check if rootfs is on /dev/mapper/cryptroot
+ machine.wait_for_unit("multi-user.target")
+ assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
+ '';
+}
diff --git a/nixos/tests/initrd-network.nix b/nixos/tests/initrd-network.nix
index 7e86f7f87075..b84588f1d250 100644
--- a/nixos/tests/initrd-network.nix
+++ b/nixos/tests/initrd-network.nix
@@ -1,35 +1,33 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "initrd-network";
+{ pkgs, lib, ... }:
+{
+ name = "initrd-network";
- meta.maintainers = [ ];
+ meta.maintainers = [ ];
- nodes.machine =
- { ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
- boot.initrd.network.enable = true;
- boot.initrd.network.postCommands = ''
- ip addr show
- ip route show
- ip addr | grep 10.0.2.15 || exit 1
- ping -c1 10.0.2.2 || exit 1
- '';
- # Check if cleanup was done correctly
- boot.initrd.postMountCommands = lib.mkAfter ''
- ip addr show
- ip route show
- ip addr | grep 10.0.2.15 && exit 1
- ping -c1 10.0.2.2 && exit 1
- '';
- };
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+ boot.initrd.network.enable = true;
+ boot.initrd.network.postCommands = ''
+ ip addr show
+ ip route show
+ ip addr | grep 10.0.2.15 || exit 1
+ ping -c1 10.0.2.2 || exit 1
+ '';
+ # Check if cleanup was done correctly
+ boot.initrd.postMountCommands = lib.mkAfter ''
+ ip addr show
+ ip route show
+ ip addr | grep 10.0.2.15 && exit 1
+ ping -c1 10.0.2.2 && exit 1
+ '';
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("multi-user.target")
- machine.succeed("ip addr show >&2")
- machine.succeed("ip route show >&2")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("ip addr show >&2")
+ machine.succeed("ip route show >&2")
+ '';
+}
diff --git a/nixos/tests/input-remapper.nix b/nixos/tests/input-remapper.nix
index 4937274aa692..eb444d8683a6 100644
--- a/nixos/tests/input-remapper.nix
+++ b/nixos/tests/input-remapper.nix
@@ -1,65 +1,63 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "input-remapper";
- meta = {
- maintainers = with pkgs.lib.maintainers; [ LunNova ];
+{
+ name = "input-remapper";
+ meta = {
+ maintainers = with pkgs.lib.maintainers; [ LunNova ];
+ };
+
+ nodes.machine =
+ { config, ... }:
+ let
+ user = config.users.users.sybil;
+ in
+ {
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
+
+ services.xserver.enable = true;
+ services.input-remapper.enable = true;
+ users.users.sybil = {
+ isNormalUser = true;
+ group = "wheel";
+ };
+ test-support.displayManager.auto.user = user.name;
+ # workaround for pkexec not working in the test environment
+ # Error creating textual authentication agent:
+ # Error opening current controlling terminal for the process (`/dev/tty'):
+ # No such device or address
+ # passwordless pkexec with polkit module also doesn't work
+ # to allow the program to run, we replace pkexec with sudo
+ # and turn on passwordless sudo
+ # this is not correct in general but good enough for this test
+ security.sudo = {
+ enable = true;
+ wheelNeedsPassword = false;
+ };
+ security.wrappers.pkexec = pkgs.lib.mkForce {
+ setuid = true;
+ owner = "root";
+ group = "root";
+ source = "${pkgs.sudo}/bin/sudo";
+ };
};
- nodes.machine =
- { config, ... }:
- let
- user = config.users.users.sybil;
- in
- {
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
+ enableOCR = true;
- services.xserver.enable = true;
- services.input-remapper.enable = true;
- users.users.sybil = {
- isNormalUser = true;
- group = "wheel";
- };
- test-support.displayManager.auto.user = user.name;
- # workaround for pkexec not working in the test environment
- # Error creating textual authentication agent:
- # Error opening current controlling terminal for the process (`/dev/tty'):
- # No such device or address
- # passwordless pkexec with polkit module also doesn't work
- # to allow the program to run, we replace pkexec with sudo
- # and turn on passwordless sudo
- # this is not correct in general but good enough for this test
- security.sudo = {
- enable = true;
- wheelNeedsPassword = false;
- };
- security.wrappers.pkexec = pkgs.lib.mkForce {
- setuid = true;
- owner = "root";
- group = "root";
- source = "${pkgs.sudo}/bin/sudo";
- };
- };
+ testScript =
+ { nodes, ... }:
+ ''
+ start_all()
+ machine.wait_for_x()
- enableOCR = true;
+ machine.succeed("systemctl status input-remapper.service")
+ machine.execute("su - sybil -c input-remapper-gtk >&2 &")
- testScript =
- { nodes, ... }:
- ''
- start_all()
- machine.wait_for_x()
-
- machine.succeed("systemctl status input-remapper.service")
- machine.execute("su - sybil -c input-remapper-gtk >&2 &")
-
- machine.wait_for_text("Input Remapper")
- machine.wait_for_text("Device")
- machine.wait_for_text("Presets")
- machine.wait_for_text("Editor")
- '';
- }
-)
+ machine.wait_for_text("Input Remapper")
+ machine.wait_for_text("Device")
+ machine.wait_for_text("Presets")
+ machine.wait_for_text("Editor")
+ '';
+}
diff --git a/nixos/tests/inspircd.nix b/nixos/tests/inspircd.nix
index b3dc09dd7521..b163622dd5b5 100644
--- a/nixos/tests/inspircd.nix
+++ b/nixos/tests/inspircd.nix
@@ -9,96 +9,94 @@ let
iiDir = "/tmp/irc";
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "inspircd";
- nodes =
- {
- "${server}" = {
- networking.firewall.allowedTCPPorts = [ ircPort ];
- services.inspircd = {
- enable = true;
- package = pkgs.inspircdMinimal;
- config = ''
-
-
- '';
- };
+{ pkgs, lib, ... }:
+{
+ name = "inspircd";
+ nodes =
+ {
+ "${server}" = {
+ networking.firewall.allowedTCPPorts = [ ircPort ];
+ services.inspircd = {
+ enable = true;
+ package = pkgs.inspircdMinimal;
+ config = ''
+
+
+ '';
};
- }
- // lib.listToAttrs (
- builtins.map (
- client:
- lib.nameValuePair client {
- imports = [
- ./common/user-account.nix
- ];
+ };
+ }
+ // lib.listToAttrs (
+ builtins.map (
+ client:
+ lib.nameValuePair client {
+ imports = [
+ ./common/user-account.nix
+ ];
- systemd.services.ii = {
- requires = [ "network.target" ];
- wantedBy = [ "default.target" ];
+ systemd.services.ii = {
+ requires = [ "network.target" ];
+ wantedBy = [ "default.target" ];
- serviceConfig = {
- Type = "simple";
- ExecPreStartPre = "mkdir -p ${iiDir}";
- ExecStart = ''
- ${lib.getBin pkgs.ii}/bin/ii -n ${client} -s ${server} -i ${iiDir}
- '';
- User = "alice";
- };
+ serviceConfig = {
+ Type = "simple";
+ ExecPreStartPre = "mkdir -p ${iiDir}";
+ ExecStart = ''
+ ${lib.getBin pkgs.ii}/bin/ii -n ${client} -s ${server} -i ${iiDir}
+ '';
+ User = "alice";
};
- }
- ) clients
- );
+ };
+ }
+ ) clients
+ );
- testScript =
- let
- msg = client: "Hello, my name is ${client}";
- clientScript =
- client:
- [
- ''
- ${client}.wait_for_unit("network.target")
- ${client}.systemctl("start ii")
- ${client}.wait_for_unit("ii")
- ${client}.wait_for_file("${iiDir}/${server}/out")
- ''
- # wait until first PING from server arrives before joining,
- # so we don't try it too early
- ''
- ${client}.wait_until_succeeds("grep 'PING' ${iiDir}/${server}/out")
- ''
- # join ${channel}
- ''
- ${client}.succeed("echo '/j #${channel}' > ${iiDir}/${server}/in")
- ${client}.wait_for_file("${iiDir}/${server}/#${channel}/in")
- ''
- # send a greeting
- ''
- ${client}.succeed(
- "echo '${msg client}' > ${iiDir}/${server}/#${channel}/in"
- )
- ''
- # check that all greetings arrived on all clients
- ]
- ++ builtins.map (other: ''
+ testScript =
+ let
+ msg = client: "Hello, my name is ${client}";
+ clientScript =
+ client:
+ [
+ ''
+ ${client}.wait_for_unit("network.target")
+ ${client}.systemctl("start ii")
+ ${client}.wait_for_unit("ii")
+ ${client}.wait_for_file("${iiDir}/${server}/out")
+ ''
+ # wait until first PING from server arrives before joining,
+ # so we don't try it too early
+ ''
+ ${client}.wait_until_succeeds("grep 'PING' ${iiDir}/${server}/out")
+ ''
+ # join ${channel}
+ ''
+ ${client}.succeed("echo '/j #${channel}' > ${iiDir}/${server}/in")
+ ${client}.wait_for_file("${iiDir}/${server}/#${channel}/in")
+ ''
+ # send a greeting
+ ''
${client}.succeed(
- "grep '${msg other}$' ${iiDir}/${server}/#${channel}/out"
+ "echo '${msg client}' > ${iiDir}/${server}/#${channel}/in"
)
- '') clients;
+ ''
+ # check that all greetings arrived on all clients
+ ]
+ ++ builtins.map (other: ''
+ ${client}.succeed(
+ "grep '${msg other}$' ${iiDir}/${server}/#${channel}/out"
+ )
+ '') clients;
- # foldl', but requires a non-empty list instead of a start value
- reduce = f: list: builtins.foldl' f (builtins.head list) (builtins.tail list);
- in
- ''
- start_all()
- ${server}.wait_for_open_port(${toString ircPort})
+ # foldl', but requires a non-empty list instead of a start value
+ reduce = f: list: builtins.foldl' f (builtins.head list) (builtins.tail list);
+ in
+ ''
+ start_all()
+ ${server}.wait_for_open_port(${toString ircPort})
- # run clientScript for all clients so that every list
- # entry is executed by every client before advancing
- # to the next one.
- ''
- + lib.concatStrings (reduce (lib.zipListsWith (cs: c: cs + c)) (builtins.map clientScript clients));
- }
-)
+ # run clientScript for all clients so that every list
+ # entry is executed by every client before advancing
+ # to the next one.
+ ''
+ + lib.concatStrings (reduce (lib.zipListsWith (cs: c: cs + c)) (builtins.map clientScript clients));
+}
diff --git a/nixos/tests/intune.nix b/nixos/tests/intune.nix
index eeb55f053f8a..1d36f107f9e6 100644
--- a/nixos/tests/intune.nix
+++ b/nixos/tests/intune.nix
@@ -1,66 +1,64 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "intune";
- meta = {
- maintainers = with pkgs.lib.maintainers; [ rhysmdnz ];
+{ pkgs, ... }:
+{
+ name = "intune";
+ meta = {
+ maintainers = with pkgs.lib.maintainers; [ rhysmdnz ];
+ };
+ enableOCR = true;
+
+ nodes.machine =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
+ {
+ services.intune.enable = true;
+ services.gnome.gnome-keyring.enable = true;
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
+ test-support.displayManager.auto.user = user.name;
+ environment = {
+ variables.DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/${builtins.toString user.uid}/bus";
+ };
+ };
+ nodes.pam =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
+ {
+ services.intune.enable = true;
+ imports = [ ./common/user-account.nix ];
};
- enableOCR = true;
- nodes.machine =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
- {
- services.intune.enable = true;
- services.gnome.gnome-keyring.enable = true;
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
- test-support.displayManager.auto.user = user.name;
- environment = {
- variables.DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/${builtins.toString user.uid}/bus";
- };
- };
- nodes.pam =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
- {
- services.intune.enable = true;
- imports = [ ./common/user-account.nix ];
- };
+ testScript = ''
+ start_all()
- testScript = ''
- start_all()
+ # Check System Daemons successfully start
+ machine.succeed("systemctl start microsoft-identity-device-broker.service")
+ machine.succeed("systemctl start intune-daemon.service")
- # Check System Daemons successfully start
- machine.succeed("systemctl start microsoft-identity-device-broker.service")
- machine.succeed("systemctl start intune-daemon.service")
+ # Check User Daemons and intune-portal execurtable works
+ # Going any further than starting it would require internet access and a microsoft account
+ machine.wait_for_x()
+ # TODO: This needs an unlocked user keychain before it will work
+ #machine.succeed("su - alice -c 'systemctl start --user microsoft-identity-broker.service'")
+ machine.succeed("su - alice -c 'systemctl start --user intune-agent.service'")
+ machine.succeed("su - alice -c intune-portal >&2 &")
+ machine.wait_for_text("Intune Agent")
- # Check User Daemons and intune-portal execurtable works
- # Going any further than starting it would require internet access and a microsoft account
- machine.wait_for_x()
- # TODO: This needs an unlocked user keychain before it will work
- #machine.succeed("su - alice -c 'systemctl start --user microsoft-identity-broker.service'")
- machine.succeed("su - alice -c 'systemctl start --user intune-agent.service'")
- machine.succeed("su - alice -c intune-portal >&2 &")
- machine.wait_for_text("Intune Agent")
+ # Check logging in creates password file
+ def login_as_alice():
+ pam.wait_until_tty_matches("1", "login: ")
+ pam.send_chars("alice\n")
+ pam.wait_until_tty_matches("1", "Password: ")
+ pam.send_chars("foobar\n")
+ pam.wait_until_tty_matches("1", "alice\@pam")
- # Check logging in creates password file
- def login_as_alice():
- pam.wait_until_tty_matches("1", "login: ")
- pam.send_chars("alice\n")
- pam.wait_until_tty_matches("1", "Password: ")
- pam.send_chars("foobar\n")
- pam.wait_until_tty_matches("1", "alice\@pam")
-
- pam.wait_for_unit("multi-user.target")
- login_as_alice()
- pam.wait_for_file("/run/intune/1000/pwquality")
- '';
- }
-)
+ pam.wait_for_unit("multi-user.target")
+ login_as_alice()
+ pam.wait_for_file("/run/intune/1000/pwquality")
+ '';
+}
diff --git a/nixos/tests/invidious.nix b/nixos/tests/invidious.nix
index d4817cac4ebf..24efe642784a 100644
--- a/nixos/tests/invidious.nix
+++ b/nixos/tests/invidious.nix
@@ -1,154 +1,152 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "invidious";
+{ pkgs, ... }:
+{
+ name = "invidious";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ sbruder ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ sbruder ];
+ };
- nodes = {
- postgres-tcp =
- { config, pkgs, ... }:
- {
- services.postgresql = {
- enable = true;
- initialScript = pkgs.writeText "init-postgres-with-password" ''
- CREATE USER invidious WITH PASSWORD 'correct horse battery staple';
- CREATE DATABASE invidious WITH OWNER invidious;
- '';
- enableTCPIP = true;
- authentication = ''
- host invidious invidious samenet scram-sha-256
- '';
- };
- networking.firewall.allowedTCPPorts = [ config.services.postgresql.settings.port ];
+ nodes = {
+ postgres-tcp =
+ { config, pkgs, ... }:
+ {
+ services.postgresql = {
+ enable = true;
+ initialScript = pkgs.writeText "init-postgres-with-password" ''
+ CREATE USER invidious WITH PASSWORD 'correct horse battery staple';
+ CREATE DATABASE invidious WITH OWNER invidious;
+ '';
+ enableTCPIP = true;
+ authentication = ''
+ host invidious invidious samenet scram-sha-256
+ '';
+ };
+ networking.firewall.allowedTCPPorts = [ config.services.postgresql.settings.port ];
+ };
+ machine =
+ { lib, pkgs, ... }:
+ {
+ services.invidious = {
+ enable = true;
};
- machine =
- { lib, pkgs, ... }:
- {
- services.invidious = {
- enable = true;
- };
- specialisation = {
- nginx.configuration = {
- services.invidious = {
- nginx.enable = true;
- domain = "invidious.example.com";
- };
- services.nginx.virtualHosts."invidious.example.com" = {
- forceSSL = false;
- enableACME = false;
- };
- networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ specialisation = {
+ nginx.configuration = {
+ services.invidious = {
+ nginx.enable = true;
+ domain = "invidious.example.com";
};
- nginx-sig-helper.configuration = {
- services.invidious = {
- nginx.enable = true;
- domain = "invidious.example.com";
- sig-helper.enable = true;
- settings.log_level = "Trace";
- };
- services.nginx.virtualHosts."invidious.example.com" = {
- forceSSL = false;
- enableACME = false;
- };
- networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ services.nginx.virtualHosts."invidious.example.com" = {
+ forceSSL = false;
+ enableACME = false;
};
- nginx-scale.configuration = {
- services.invidious = {
- nginx.enable = true;
- domain = "invidious.example.com";
- serviceScale = 3;
- };
- services.nginx.virtualHosts."invidious.example.com" = {
- forceSSL = false;
- enableACME = false;
- };
- networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ };
+ nginx-sig-helper.configuration = {
+ services.invidious = {
+ nginx.enable = true;
+ domain = "invidious.example.com";
+ sig-helper.enable = true;
+ settings.log_level = "Trace";
};
- nginx-scale-ytproxy.configuration = {
- services.invidious = {
- nginx.enable = true;
- http3-ytproxy.enable = true;
- domain = "invidious.example.com";
- serviceScale = 3;
- };
- services.nginx.virtualHosts."invidious.example.com" = {
- forceSSL = false;
- enableACME = false;
- };
- networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ services.nginx.virtualHosts."invidious.example.com" = {
+ forceSSL = false;
+ enableACME = false;
};
- postgres-tcp.configuration = {
- services.invidious = {
- database = {
- createLocally = false;
- host = "postgres-tcp";
- passwordFile = toString (pkgs.writeText "database-password" "correct horse battery staple");
- };
+ networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ };
+ nginx-scale.configuration = {
+ services.invidious = {
+ nginx.enable = true;
+ domain = "invidious.example.com";
+ serviceScale = 3;
+ };
+ services.nginx.virtualHosts."invidious.example.com" = {
+ forceSSL = false;
+ enableACME = false;
+ };
+ networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ };
+ nginx-scale-ytproxy.configuration = {
+ services.invidious = {
+ nginx.enable = true;
+ http3-ytproxy.enable = true;
+ domain = "invidious.example.com";
+ serviceScale = 3;
+ };
+ services.nginx.virtualHosts."invidious.example.com" = {
+ forceSSL = false;
+ enableACME = false;
+ };
+ networking.hosts."127.0.0.1" = [ "invidious.example.com" ];
+ };
+ postgres-tcp.configuration = {
+ services.invidious = {
+ database = {
+ createLocally = false;
+ host = "postgres-tcp";
+ passwordFile = toString (pkgs.writeText "database-password" "correct horse battery staple");
};
};
};
};
- };
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- def curl_assert_status_code(url, code, form=None):
- assert int(machine.succeed(f"curl -s -o /dev/null -w %{{http_code}} {'-F ' + form + ' ' if form else '''}{url}")) == code
+ testScript =
+ { nodes, ... }:
+ ''
+ def curl_assert_status_code(url, code, form=None):
+ assert int(machine.succeed(f"curl -s -o /dev/null -w %{{http_code}} {'-F ' + form + ' ' if form else '''}{url}")) == code
- def activate_specialisation(name: str):
- machine.succeed(f"${nodes.machine.system.build.toplevel}/specialisation/{name}/bin/switch-to-configuration test >&2")
+ def activate_specialisation(name: str):
+ machine.succeed(f"${nodes.machine.system.build.toplevel}/specialisation/{name}/bin/switch-to-configuration test >&2")
- url = "http://localhost:${toString nodes.machine.services.invidious.port}"
- port = ${toString nodes.machine.services.invidious.port}
+ url = "http://localhost:${toString nodes.machine.services.invidious.port}"
+ port = ${toString nodes.machine.services.invidious.port}
- # start postgres vm now
- postgres_tcp.start()
+ # start postgres vm now
+ postgres_tcp.start()
- machine.wait_for_open_port(port)
- curl_assert_status_code(f"{url}/search", 200)
+ machine.wait_for_open_port(port)
+ curl_assert_status_code(f"{url}/search", 200)
- activate_specialisation("nginx")
- machine.wait_for_open_port(80)
- curl_assert_status_code("http://invidious.example.com/search", 200)
+ activate_specialisation("nginx")
+ machine.wait_for_open_port(80)
+ curl_assert_status_code("http://invidious.example.com/search", 200)
- activate_specialisation("nginx-scale")
- machine.wait_for_open_port(80)
- # this depends on nginx round-robin behaviour for the upstream servers
- curl_assert_status_code("http://invidious.example.com/search", 200)
- curl_assert_status_code("http://invidious.example.com/search", 200)
- curl_assert_status_code("http://invidious.example.com/search", 200)
- machine.succeed("journalctl -eu invidious.service | grep -o '200 GET /search'")
- machine.succeed("journalctl -eu invidious-1.service | grep -o '200 GET /search'")
- machine.succeed("journalctl -eu invidious-2.service | grep -o '200 GET /search'")
+ activate_specialisation("nginx-scale")
+ machine.wait_for_open_port(80)
+ # this depends on nginx round-robin behaviour for the upstream servers
+ curl_assert_status_code("http://invidious.example.com/search", 200)
+ curl_assert_status_code("http://invidious.example.com/search", 200)
+ curl_assert_status_code("http://invidious.example.com/search", 200)
+ machine.succeed("journalctl -eu invidious.service | grep -o '200 GET /search'")
+ machine.succeed("journalctl -eu invidious-1.service | grep -o '200 GET /search'")
+ machine.succeed("journalctl -eu invidious-2.service | grep -o '200 GET /search'")
- activate_specialisation("nginx-scale-ytproxy")
- machine.wait_for_unit("http3-ytproxy.service")
- machine.wait_for_open_port(80)
- machine.wait_until_succeeds("ls /run/http3-ytproxy/socket/http-proxy.sock")
- curl_assert_status_code("http://invidious.example.com/search", 200)
- # this should error out as no internet connectivity is available in the test
- curl_assert_status_code("http://invidious.example.com/vi/dQw4w9WgXcQ/mqdefault.jpg", 502)
- machine.succeed("journalctl -eu http3-ytproxy.service | grep -o 'dQw4w9WgXcQ'")
+ activate_specialisation("nginx-scale-ytproxy")
+ machine.wait_for_unit("http3-ytproxy.service")
+ machine.wait_for_open_port(80)
+ machine.wait_until_succeeds("ls /run/http3-ytproxy/socket/http-proxy.sock")
+ curl_assert_status_code("http://invidious.example.com/search", 200)
+ # this should error out as no internet connectivity is available in the test
+ curl_assert_status_code("http://invidious.example.com/vi/dQw4w9WgXcQ/mqdefault.jpg", 502)
+ machine.succeed("journalctl -eu http3-ytproxy.service | grep -o 'dQw4w9WgXcQ'")
- activate_specialisation("nginx-sig-helper")
- machine.wait_for_unit("invidious-sig-helper.service")
- # we can't really test the sig helper that well without internet connection...
- # invidious does connect to the sig helper though and crashes when the sig helper is not available
- machine.wait_for_open_port(80)
- curl_assert_status_code("http://invidious.example.com/search", 200)
- machine.succeed("journalctl -eu invidious.service | grep -o \"SigHelper: Using helper at 'tcp://127.0.0.1:2999'\"")
+ activate_specialisation("nginx-sig-helper")
+ machine.wait_for_unit("invidious-sig-helper.service")
+ # we can't really test the sig helper that well without internet connection...
+ # invidious does connect to the sig helper though and crashes when the sig helper is not available
+ machine.wait_for_open_port(80)
+ curl_assert_status_code("http://invidious.example.com/search", 200)
+ machine.succeed("journalctl -eu invidious.service | grep -o \"SigHelper: Using helper at 'tcp://127.0.0.1:2999'\"")
- postgres_tcp.wait_for_unit("postgresql.service")
- activate_specialisation("postgres-tcp")
- machine.wait_for_open_port(port)
- curl_assert_status_code(f"{url}/search", 200)
- '';
- }
-)
+ postgres_tcp.wait_for_unit("postgresql.service")
+ activate_specialisation("postgres-tcp")
+ machine.wait_for_open_port(port)
+ curl_assert_status_code(f"{url}/search", 200)
+ '';
+}
diff --git a/nixos/tests/iodine.nix b/nixos/tests/iodine.nix
index 573f6d7aebeb..04ed8dcfaa53 100644
--- a/nixos/tests/iodine.nix
+++ b/nixos/tests/iodine.nix
@@ -1,66 +1,64 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- domain = "whatever.example.com";
- password = "false;foo;exit;withspecialcharacters";
- in
- {
- name = "iodine";
- nodes = {
- server =
- { ... }:
+{ pkgs, ... }:
+let
+ domain = "whatever.example.com";
+ password = "false;foo;exit;withspecialcharacters";
+in
+{
+ name = "iodine";
+ nodes = {
+ server =
+ { ... }:
- {
- networking.firewall = {
- allowedUDPPorts = [ 53 ];
- trustedInterfaces = [ "dns0" ];
- };
- boot.kernel.sysctl = {
- "net.ipv4.ip_forward" = 1;
- "net.ipv6.ip_forward" = 1;
- };
-
- services.iodine.server = {
- enable = true;
- ip = "10.53.53.1/24";
- passwordFile = "${builtins.toFile "password" password}";
- inherit domain;
- };
-
- # test resource: accessible only via tunnel
- services.openssh = {
- enable = true;
- openFirewall = false;
- };
+ {
+ networking.firewall = {
+ allowedUDPPorts = [ 53 ];
+ trustedInterfaces = [ "dns0" ];
+ };
+ boot.kernel.sysctl = {
+ "net.ipv4.ip_forward" = 1;
+ "net.ipv6.ip_forward" = 1;
};
- client =
- { ... }:
- {
- services.iodine.clients.testClient = {
- # test that ProtectHome is "read-only"
- passwordFile = "/root/pw";
- relay = "server";
- server = domain;
- };
- systemd.tmpfiles.rules = [
- "f /root/pw 0666 root root - ${password}"
- ];
- environment.systemPackages = [
- pkgs.nagiosPluginsOfficial
- ];
+ services.iodine.server = {
+ enable = true;
+ ip = "10.53.53.1/24";
+ passwordFile = "${builtins.toFile "password" password}";
+ inherit domain;
};
- };
+ # test resource: accessible only via tunnel
+ services.openssh = {
+ enable = true;
+ openFirewall = false;
+ };
+ };
- testScript = ''
- start_all()
+ client =
+ { ... }:
+ {
+ services.iodine.clients.testClient = {
+ # test that ProtectHome is "read-only"
+ passwordFile = "/root/pw";
+ relay = "server";
+ server = domain;
+ };
+ systemd.tmpfiles.rules = [
+ "f /root/pw 0666 root root - ${password}"
+ ];
+ environment.systemPackages = [
+ pkgs.nagiosPluginsOfficial
+ ];
+ };
- server.wait_for_unit("sshd")
- server.wait_for_unit("iodined")
- client.wait_for_unit("iodine-testClient")
+ };
- client.succeed("check_ssh -H 10.53.53.1")
- '';
- }
-)
+ testScript = ''
+ start_all()
+
+ server.wait_for_unit("sshd")
+ server.wait_for_unit("iodined")
+ client.wait_for_unit("iodine-testClient")
+
+ client.succeed("check_ssh -H 10.53.53.1")
+ '';
+}
diff --git a/nixos/tests/iosched.nix b/nixos/tests/iosched.nix
index 92870e3ae603..c113f23f1d6d 100644
--- a/nixos/tests/iosched.nix
+++ b/nixos/tests/iosched.nix
@@ -1,71 +1,69 @@
-import ./make-test-python.nix (
- {
- pkgs,
- ...
- }:
- let
- qemu-img = pkgs.lib.getExe' pkgs.vmTools.qemu "qemu-img";
- empty = pkgs.runCommand "empty.qcow2" { } ''
- ${qemu-img} create -f qcow2 "$out" 32M
- '';
- in
- {
- name = "iosched";
- meta.maintainers = with pkgs.lib.maintainers; [ mvs ];
+{
+ pkgs,
+ ...
+}:
+let
+ qemu-img = pkgs.lib.getExe' pkgs.vmTools.qemu "qemu-img";
+ empty = pkgs.runCommand "empty.qcow2" { } ''
+ ${qemu-img} create -f qcow2 "$out" 32M
+ '';
+in
+{
+ name = "iosched";
+ meta.maintainers = with pkgs.lib.maintainers; [ mvs ];
- nodes.machine = {
- virtualisation.qemu.options = [
- "-drive"
- "id=sda,if=none,format=qcow2,readonly=on,file=${empty}"
- "-drive"
- "id=sdb,if=none,format=qcow2,readonly=on,file=${empty}"
- "-drive"
- "id=nvme0n1,if=none,format=qcow2,readonly=on,file=${empty}"
- "-drive"
- "id=mmcblk0,if=none,format=qcow2,file=./mmcblk0.qcow2"
- "-device"
- "virtio-scsi-pci,id=scsi0"
- "-device"
- "sdhci-pci"
- "-device"
- "scsi-hd,rotation_rate=1,bus=scsi0.0,drive=sda"
- "-device"
- "scsi-hd,rotation_rate=7200,bus=scsi0.0,drive=sdb"
- "-device"
- "sd-card,drive=mmcblk0"
- "-device"
- "nvme,serial=deadbeef,drive=nvme0n1"
- ];
+ nodes.machine = {
+ virtualisation.qemu.options = [
+ "-drive"
+ "id=sda,if=none,format=qcow2,readonly=on,file=${empty}"
+ "-drive"
+ "id=sdb,if=none,format=qcow2,readonly=on,file=${empty}"
+ "-drive"
+ "id=nvme0n1,if=none,format=qcow2,readonly=on,file=${empty}"
+ "-drive"
+ "id=mmcblk0,if=none,format=qcow2,file=./mmcblk0.qcow2"
+ "-device"
+ "virtio-scsi-pci,id=scsi0"
+ "-device"
+ "sdhci-pci"
+ "-device"
+ "scsi-hd,rotation_rate=1,bus=scsi0.0,drive=sda"
+ "-device"
+ "scsi-hd,rotation_rate=7200,bus=scsi0.0,drive=sdb"
+ "-device"
+ "sd-card,drive=mmcblk0"
+ "-device"
+ "nvme,serial=deadbeef,drive=nvme0n1"
+ ];
- hardware.block = {
- defaultScheduler = "none";
- defaultSchedulerRotational = "mq-deadline";
- scheduler = {
- "nvme[0-9]*" = "kyber";
- "mmcblk[0-9]*" = "bfq";
- };
+ hardware.block = {
+ defaultScheduler = "none";
+ defaultSchedulerRotational = "mq-deadline";
+ scheduler = {
+ "nvme[0-9]*" = "kyber";
+ "mmcblk[0-9]*" = "bfq";
};
};
+ };
- testScript = ''
- import subprocess
+ testScript = ''
+ import subprocess
- def check_scheduler(dev, scheduler):
- machine.succeed("grep -F -q '[{}]' /sys/block/{}/queue/scheduler".format(scheduler, dev))
+ def check_scheduler(dev, scheduler):
+ machine.succeed("grep -F -q '[{}]' /sys/block/{}/queue/scheduler".format(scheduler, dev))
- subprocess.check_call([
- "${qemu-img}", "create", "-f", "qcow2", "vm-state-machine/mmcblk0.qcow2", "32M"
- ])
+ subprocess.check_call([
+ "${qemu-img}", "create", "-f", "qcow2", "vm-state-machine/mmcblk0.qcow2", "32M"
+ ])
- machine.start()
- machine.succeed("udevadm verify --no-style")
- check_scheduler("sda", "none")
- check_scheduler("sdb", "mq-deadline")
- check_scheduler("nvme0n1", "kyber")
- check_scheduler("mmcblk0", "bfq")
+ machine.start()
+ machine.succeed("udevadm verify --no-style")
+ check_scheduler("sda", "none")
+ check_scheduler("sdb", "mq-deadline")
+ check_scheduler("nvme0n1", "kyber")
+ check_scheduler("mmcblk0", "bfq")
- machine.succeed("tmp=\"$(mktemp)\"; losetup /dev/loop0 \"$tmp\"")
- check_scheduler("loop0", "none")
- '';
- }
-)
+ machine.succeed("tmp=\"$(mktemp)\"; losetup /dev/loop0 \"$tmp\"")
+ check_scheduler("loop0", "none")
+ '';
+}
diff --git a/nixos/tests/ipv6.nix b/nixos/tests/ipv6.nix
index cc0bf895c5e3..ca25c0b4497f 100644
--- a/nixos/tests/ipv6.nix
+++ b/nixos/tests/ipv6.nix
@@ -1,133 +1,131 @@
# Test of IPv6 functionality in NixOS, including whether router
# solicication/advertisement using radvd works.
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "ipv6";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
+{ pkgs, lib, ... }:
+{
+ name = "ipv6";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
+
+ nodes = {
+ # We use lib.mkForce here to remove the interface configuration
+ # provided by makeTest, so that the interfaces are all configured
+ # implicitly.
+
+ # This client should use privacy extensions fully, having a
+ # completely-default network configuration.
+ client_defaults.networking.interfaces = lib.mkForce { };
+
+ # Both of these clients should obtain temporary addresses, but
+ # not use them as the default source IP. We thus run the same
+ # checks against them — but the configuration resulting in this
+ # behaviour is different.
+
+ # Here, by using an altered default value for the global setting...
+ client_global_setting = {
+ networking.interfaces = lib.mkForce { };
+ networking.tempAddresses = "enabled";
+ };
+ # and here, by setting this on the interface explicitly.
+ client_interface_setting = {
+ networking.tempAddresses = "disabled";
+ networking.interfaces = lib.mkForce {
+ eth1.tempAddress = "enabled";
+ };
};
- nodes = {
- # We use lib.mkForce here to remove the interface configuration
- # provided by makeTest, so that the interfaces are all configured
- # implicitly.
-
- # This client should use privacy extensions fully, having a
- # completely-default network configuration.
- client_defaults.networking.interfaces = lib.mkForce { };
-
- # Both of these clients should obtain temporary addresses, but
- # not use them as the default source IP. We thus run the same
- # checks against them — but the configuration resulting in this
- # behaviour is different.
-
- # Here, by using an altered default value for the global setting...
- client_global_setting = {
- networking.interfaces = lib.mkForce { };
- networking.tempAddresses = "enabled";
- };
- # and here, by setting this on the interface explicitly.
- client_interface_setting = {
- networking.tempAddresses = "disabled";
- networking.interfaces = lib.mkForce {
- eth1.tempAddress = "enabled";
- };
- };
-
- server = {
- services.httpd.enable = true;
- services.httpd.adminAddr = "foo@example.org";
- networking.firewall.allowedTCPPorts = [ 80 ];
- # disable testing driver's default IPv6 address.
- networking.interfaces.eth1.ipv6.addresses = lib.mkForce [ ];
- };
-
- router =
- { ... }:
- {
- services.radvd.enable = true;
- services.radvd.config = ''
- interface eth1 {
- AdvSendAdvert on;
- # ULA prefix (RFC 4193).
- prefix fd60:cc69:b537:1::/64 { };
- };
- '';
- };
+ server = {
+ services.httpd.enable = true;
+ services.httpd.adminAddr = "foo@example.org";
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ # disable testing driver's default IPv6 address.
+ networking.interfaces.eth1.ipv6.addresses = lib.mkForce [ ];
};
- testScript = ''
- import re
+ router =
+ { ... }:
+ {
+ services.radvd.enable = true;
+ services.radvd.config = ''
+ interface eth1 {
+ AdvSendAdvert on;
+ # ULA prefix (RFC 4193).
+ prefix fd60:cc69:b537:1::/64 { };
+ };
+ '';
+ };
+ };
- # Start the router first so that it respond to router solicitations.
- router.wait_for_unit("radvd")
+ testScript = ''
+ import re
- clients = [client_defaults, client_global_setting, client_interface_setting]
+ # Start the router first so that it respond to router solicitations.
+ router.wait_for_unit("radvd")
- start_all()
+ clients = [client_defaults, client_global_setting, client_interface_setting]
- for client in clients:
- client.wait_for_unit("network.target")
- server.wait_for_unit("network.target")
- server.wait_for_unit("httpd.service")
+ start_all()
- # Wait until the given interface has a non-tentative address of
- # the desired scope (i.e. has completed Duplicate Address
- # Detection).
- def wait_for_address(machine, iface, scope, temporary=False):
- temporary_flag = "temporary" if temporary else "-temporary"
- cmd = f"ip -o -6 addr show dev {iface} scope {scope} -tentative {temporary_flag}"
+ for client in clients:
+ client.wait_for_unit("network.target")
+ server.wait_for_unit("network.target")
+ server.wait_for_unit("httpd.service")
- machine.wait_until_succeeds(f"[ `{cmd} | wc -l` -eq 1 ]")
- output = machine.succeed(cmd)
- ip = re.search(r"inet6 ([0-9a-f:]{2,})/", output).group(1)
+ # Wait until the given interface has a non-tentative address of
+ # the desired scope (i.e. has completed Duplicate Address
+ # Detection).
+ def wait_for_address(machine, iface, scope, temporary=False):
+ temporary_flag = "temporary" if temporary else "-temporary"
+ cmd = f"ip -o -6 addr show dev {iface} scope {scope} -tentative {temporary_flag}"
- if temporary:
- scope = scope + " temporary"
- machine.log(f"{scope} address on {iface} is {ip}")
- return ip
+ machine.wait_until_succeeds(f"[ `{cmd} | wc -l` -eq 1 ]")
+ output = machine.succeed(cmd)
+ ip = re.search(r"inet6 ([0-9a-f:]{2,})/", output).group(1)
+
+ if temporary:
+ scope = scope + " temporary"
+ machine.log(f"{scope} address on {iface} is {ip}")
+ return ip
- with subtest("Loopback address can be pinged"):
- client_defaults.succeed("ping -c 1 ::1 >&2")
- client_defaults.fail("ping -c 1 2001:db8:: >&2")
+ with subtest("Loopback address can be pinged"):
+ client_defaults.succeed("ping -c 1 ::1 >&2")
+ client_defaults.fail("ping -c 1 2001:db8:: >&2")
- with subtest("Local link addresses can be obtained and pinged"):
- for client in clients:
- client_ip = wait_for_address(client, "eth1", "link")
- server_ip = wait_for_address(server, "eth1", "link")
- client.succeed(f"ping -c 1 {client_ip}%eth1 >&2")
- client.succeed(f"ping -c 1 {server_ip}%eth1 >&2")
+ with subtest("Local link addresses can be obtained and pinged"):
+ for client in clients:
+ client_ip = wait_for_address(client, "eth1", "link")
+ server_ip = wait_for_address(server, "eth1", "link")
+ client.succeed(f"ping -c 1 {client_ip}%eth1 >&2")
+ client.succeed(f"ping -c 1 {server_ip}%eth1 >&2")
- with subtest("Global addresses can be obtained, pinged, and reached via http"):
- for client in clients:
- client_ip = wait_for_address(client, "eth1", "global")
- server_ip = wait_for_address(server, "eth1", "global")
- client.succeed(f"ping -c 1 {client_ip} >&2")
- client.succeed(f"ping -c 1 {server_ip} >&2")
- client.succeed(f"curl --fail -g http://[{server_ip}]")
- client.fail(f"curl --fail -g http://[{client_ip}]")
+ with subtest("Global addresses can be obtained, pinged, and reached via http"):
+ for client in clients:
+ client_ip = wait_for_address(client, "eth1", "global")
+ server_ip = wait_for_address(server, "eth1", "global")
+ client.succeed(f"ping -c 1 {client_ip} >&2")
+ client.succeed(f"ping -c 1 {server_ip} >&2")
+ client.succeed(f"curl --fail -g http://[{server_ip}]")
+ client.fail(f"curl --fail -g http://[{client_ip}]")
- with subtest(
- "Privacy extensions: Global temporary address is used as default source address"
- ):
- ip = wait_for_address(client_defaults, "eth1", "global", temporary=True)
- # Default route should have "src " in it
- client_defaults.succeed(f"ip route get 2001:db8:: | grep 'src {ip}'")
+ with subtest(
+ "Privacy extensions: Global temporary address is used as default source address"
+ ):
+ ip = wait_for_address(client_defaults, "eth1", "global", temporary=True)
+ # Default route should have "src " in it
+ client_defaults.succeed(f"ip route get 2001:db8:: | grep 'src {ip}'")
- for client, setting_desc in (
- (client_global_setting, "global"),
- (client_interface_setting, "interface"),
- ):
- with subtest(f'Privacy extensions: "enabled" through {setting_desc} setting)'):
- # We should be obtaining both a temporary address and an EUI-64 address...
- ip = wait_for_address(client, "eth1", "global")
- assert "ff:fe" in ip
- ip_temp = wait_for_address(client, "eth1", "global", temporary=True)
- # But using the EUI-64 one.
- client.succeed(f"ip route get 2001:db8:: | grep 'src {ip}'")
- '';
- }
-)
+ for client, setting_desc in (
+ (client_global_setting, "global"),
+ (client_interface_setting, "interface"),
+ ):
+ with subtest(f'Privacy extensions: "enabled" through {setting_desc} setting)'):
+ # We should be obtaining both a temporary address and an EUI-64 address...
+ ip = wait_for_address(client, "eth1", "global")
+ assert "ff:fe" in ip
+ ip_temp = wait_for_address(client, "eth1", "global", temporary=True)
+ # But using the EUI-64 one.
+ client.succeed(f"ip route get 2001:db8:: | grep 'src {ip}'")
+ '';
+}
diff --git a/nixos/tests/iscsi-multipath-root.nix b/nixos/tests/iscsi-multipath-root.nix
index 56f9e1ae7cc1..45b1baf40c61 100644
--- a/nixos/tests/iscsi-multipath-root.nix
+++ b/nixos/tests/iscsi-multipath-root.nix
@@ -1,298 +1,296 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- initiatorName = "iqn.2020-08.org.linux-iscsi.initiatorhost:example";
- targetName = "iqn.2003-01.org.linux-iscsi.target.x8664:sn.acf8fd9c23af";
- in
- {
- name = "iscsi";
- meta = {
- maintainers = pkgs.lib.teams.deshaw.members;
- };
+{ pkgs, lib, ... }:
+let
+ initiatorName = "iqn.2020-08.org.linux-iscsi.initiatorhost:example";
+ targetName = "iqn.2003-01.org.linux-iscsi.target.x8664:sn.acf8fd9c23af";
+in
+{
+ name = "iscsi";
+ meta = {
+ maintainers = pkgs.lib.teams.deshaw.members;
+ };
- nodes = {
- target =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- virtualisation.vlans = [
- 1
- 2
- ];
- services.target = {
- enable = true;
- config = {
- fabric_modules = [ ];
- storage_objects = [
- {
- dev = "/dev/vdb";
- name = "test";
- plugin = "block";
- write_back = true;
- wwn = "92b17c3f-6b40-4168-b082-ceeb7b495522";
- }
- ];
- targets = [
- {
- fabric = "iscsi";
- tpgs = [
- {
- enable = true;
- attributes = {
- authentication = 0;
- generate_node_acls = 1;
- };
- luns = [
- {
- alias = "94dfe06967";
- alua_tg_pt_gp_name = "default_tg_pt_gp";
- index = 0;
- storage_object = "/backstores/block/test";
- }
- ];
- node_acls = [
- {
- mapped_luns = [
- {
- alias = "d42f5bdf8a";
- index = 0;
- tpg_lun = 0;
- write_protect = false;
- }
- ];
- node_wwn = initiatorName;
- }
- ];
- portals = [
- {
- ip_address = "0.0.0.0";
- iser = false;
- offload = false;
- port = 3260;
- }
- ];
- tag = 1;
- }
- ];
- wwn = targetName;
- }
- ];
- };
- };
-
- networking.firewall.allowedTCPPorts = [ 3260 ];
- networking.firewall.allowedUDPPorts = [ 3260 ];
-
- virtualisation.memorySize = 2048;
- virtualisation.emptyDiskImages = [ 2048 ];
- };
-
- initiatorAuto =
- {
- nodes,
- config,
- pkgs,
- ...
- }:
- {
- virtualisation.vlans = [
- 1
- 2
- ];
-
- services.multipath = {
- enable = true;
- defaults = ''
- find_multipaths yes
- user_friendly_names yes
- '';
- pathGroups = [
+ nodes = {
+ target =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ virtualisation.vlans = [
+ 1
+ 2
+ ];
+ services.target = {
+ enable = true;
+ config = {
+ fabric_modules = [ ];
+ storage_objects = [
{
- alias = 123456;
- wwid = "3600140592b17c3f6b404168b082ceeb7";
+ dev = "/dev/vdb";
+ name = "test";
+ plugin = "block";
+ write_back = true;
+ wwn = "92b17c3f-6b40-4168-b082-ceeb7b495522";
+ }
+ ];
+ targets = [
+ {
+ fabric = "iscsi";
+ tpgs = [
+ {
+ enable = true;
+ attributes = {
+ authentication = 0;
+ generate_node_acls = 1;
+ };
+ luns = [
+ {
+ alias = "94dfe06967";
+ alua_tg_pt_gp_name = "default_tg_pt_gp";
+ index = 0;
+ storage_object = "/backstores/block/test";
+ }
+ ];
+ node_acls = [
+ {
+ mapped_luns = [
+ {
+ alias = "d42f5bdf8a";
+ index = 0;
+ tpg_lun = 0;
+ write_protect = false;
+ }
+ ];
+ node_wwn = initiatorName;
+ }
+ ];
+ portals = [
+ {
+ ip_address = "0.0.0.0";
+ iser = false;
+ offload = false;
+ port = 3260;
+ }
+ ];
+ tag = 1;
+ }
+ ];
+ wwn = targetName;
}
];
};
+ };
- services.openiscsi = {
- enable = true;
- enableAutoLoginOut = true;
- discoverPortal = "target";
- name = initiatorName;
- };
+ networking.firewall.allowedTCPPorts = [ 3260 ];
+ networking.firewall.allowedUDPPorts = [ 3260 ];
- environment.systemPackages = with pkgs; [
- xfsprogs
+ virtualisation.memorySize = 2048;
+ virtualisation.emptyDiskImages = [ 2048 ];
+ };
+
+ initiatorAuto =
+ {
+ nodes,
+ config,
+ pkgs,
+ ...
+ }:
+ {
+ virtualisation.vlans = [
+ 1
+ 2
+ ];
+
+ services.multipath = {
+ enable = true;
+ defaults = ''
+ find_multipaths yes
+ user_friendly_names yes
+ '';
+ pathGroups = [
+ {
+ alias = 123456;
+ wwid = "3600140592b17c3f6b404168b082ceeb7";
+ }
];
+ };
- environment.etc."initiator-root-disk-closure".source =
- nodes.initiatorRootDisk.config.system.build.toplevel;
+ services.openiscsi = {
+ enable = true;
+ enableAutoLoginOut = true;
+ discoverPortal = "target";
+ name = initiatorName;
+ };
- nix.settings = {
- substituters = lib.mkForce [ ];
- hashed-mirrors = null;
- connect-timeout = 1;
+ environment.systemPackages = with pkgs; [
+ xfsprogs
+ ];
+
+ environment.etc."initiator-root-disk-closure".source =
+ nodes.initiatorRootDisk.config.system.build.toplevel;
+
+ nix.settings = {
+ substituters = lib.mkForce [ ];
+ hashed-mirrors = null;
+ connect-timeout = 1;
+ };
+ };
+
+ initiatorRootDisk =
+ {
+ config,
+ pkgs,
+ modulesPath,
+ lib,
+ ...
+ }:
+ {
+ boot.initrd.network.enable = true;
+ boot.loader.grub.enable = false;
+
+ boot.kernelParams = lib.mkOverride 5 ([
+ "boot.shell_on_fail"
+ "console=tty1"
+ "ip=192.168.1.1:::255.255.255.0::ens9:none"
+ "ip=192.168.2.1:::255.255.255.0::ens10:none"
+ ]);
+
+ # defaults to true, puts some code in the initrd that tries to mount an overlayfs on /nix/store
+ virtualisation.writableStore = false;
+ virtualisation.vlans = [
+ 1
+ 2
+ ];
+
+ services.multipath = {
+ enable = true;
+ defaults = ''
+ find_multipaths yes
+ user_friendly_names yes
+ '';
+ pathGroups = [
+ {
+ alias = 123456;
+ wwid = "3600140592b17c3f6b404168b082ceeb7";
+ }
+ ];
+ };
+
+ fileSystems = lib.mkOverride 5 {
+ "/" = {
+ fsType = "xfs";
+ device = "/dev/mapper/123456";
+ options = [ "_netdev" ];
};
};
- initiatorRootDisk =
- {
- config,
- pkgs,
- modulesPath,
- lib,
- ...
- }:
- {
- boot.initrd.network.enable = true;
- boot.loader.grub.enable = false;
+ boot.initrd.extraFiles."etc/multipath/wwids".source =
+ pkgs.writeText "wwids" "/3600140592b17c3f6b404168b082ceeb7/";
- boot.kernelParams = lib.mkOverride 5 ([
- "boot.shell_on_fail"
- "console=tty1"
- "ip=192.168.1.1:::255.255.255.0::ens9:none"
- "ip=192.168.2.1:::255.255.255.0::ens10:none"
- ]);
-
- # defaults to true, puts some code in the initrd that tries to mount an overlayfs on /nix/store
- virtualisation.writableStore = false;
- virtualisation.vlans = [
- 1
- 2
- ];
-
- services.multipath = {
- enable = true;
- defaults = ''
- find_multipaths yes
- user_friendly_names yes
- '';
- pathGroups = [
- {
- alias = 123456;
- wwid = "3600140592b17c3f6b404168b082ceeb7";
- }
- ];
- };
-
- fileSystems = lib.mkOverride 5 {
- "/" = {
- fsType = "xfs";
- device = "/dev/mapper/123456";
- options = [ "_netdev" ];
- };
- };
-
- boot.initrd.extraFiles."etc/multipath/wwids".source =
- pkgs.writeText "wwids" "/3600140592b17c3f6b404168b082ceeb7/";
-
- boot.iscsi-initiator = {
- discoverPortal = "target";
- name = initiatorName;
- target = targetName;
- extraIscsiCommands = ''
- iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login
- '';
- };
+ boot.iscsi-initiator = {
+ discoverPortal = "target";
+ name = initiatorName;
+ target = targetName;
+ extraIscsiCommands = ''
+ iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login
+ '';
};
+ };
- };
+ };
- testScript =
- { nodes, ... }:
- ''
- target.start()
- target.wait_for_unit("iscsi-target.service")
+ testScript =
+ { nodes, ... }:
+ ''
+ target.start()
+ target.wait_for_unit("iscsi-target.service")
- initiatorAuto.start()
+ initiatorAuto.start()
- initiatorAuto.wait_for_unit("iscsid.service")
- initiatorAuto.wait_for_unit("iscsi.service")
- initiatorAuto.get_unit_info("iscsi")
+ initiatorAuto.wait_for_unit("iscsid.service")
+ initiatorAuto.wait_for_unit("iscsi.service")
+ initiatorAuto.get_unit_info("iscsi")
- # Expecting this to fail since we should already know about 192.168.1.3
- initiatorAuto.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.1.3 --login")
- # Expecting this to succeed since we don't yet know about 192.168.2.3
- initiatorAuto.succeed("iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login")
+ # Expecting this to fail since we should already know about 192.168.1.3
+ initiatorAuto.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.1.3 --login")
+ # Expecting this to succeed since we don't yet know about 192.168.2.3
+ initiatorAuto.succeed("iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login")
- # /dev/sda is provided by iscsi on target
- initiatorAuto.succeed("set -x; while ! test -e /dev/sda; do sleep 1; done")
+ # /dev/sda is provided by iscsi on target
+ initiatorAuto.succeed("set -x; while ! test -e /dev/sda; do sleep 1; done")
- initiatorAuto.succeed("mkfs.xfs /dev/sda")
- initiatorAuto.succeed("mkdir /mnt")
+ initiatorAuto.succeed("mkfs.xfs /dev/sda")
+ initiatorAuto.succeed("mkdir /mnt")
- # Start by verifying /dev/sda and /dev/sdb are both the same disk
- initiatorAuto.succeed("mount /dev/sda /mnt")
- initiatorAuto.succeed("touch /mnt/hi")
- initiatorAuto.succeed("umount /mnt")
+ # Start by verifying /dev/sda and /dev/sdb are both the same disk
+ initiatorAuto.succeed("mount /dev/sda /mnt")
+ initiatorAuto.succeed("touch /mnt/hi")
+ initiatorAuto.succeed("umount /mnt")
- initiatorAuto.succeed("mount /dev/sdb /mnt")
- initiatorAuto.succeed("test -e /mnt/hi")
- initiatorAuto.succeed("umount /mnt")
+ initiatorAuto.succeed("mount /dev/sdb /mnt")
+ initiatorAuto.succeed("test -e /mnt/hi")
+ initiatorAuto.succeed("umount /mnt")
- initiatorAuto.succeed("systemctl restart multipathd")
- initiatorAuto.succeed("systemd-cat multipath -ll")
+ initiatorAuto.succeed("systemctl restart multipathd")
+ initiatorAuto.succeed("systemd-cat multipath -ll")
- # Install our RootDisk machine to 123456, the alias to the device that multipath is now managing
- initiatorAuto.succeed("mount /dev/mapper/123456 /mnt")
- initiatorAuto.succeed("mkdir -p /mnt/etc/{multipath,iscsi}")
- initiatorAuto.succeed("cp -r /etc/multipath/wwids /mnt/etc/multipath/wwids")
- initiatorAuto.succeed("cp -r /etc/iscsi/{nodes,send_targets} /mnt/etc/iscsi")
- initiatorAuto.succeed(
- "nixos-install --no-bootloader --no-root-passwd --system /etc/initiator-root-disk-closure"
- )
- initiatorAuto.succeed("umount /mnt")
- initiatorAuto.shutdown()
+ # Install our RootDisk machine to 123456, the alias to the device that multipath is now managing
+ initiatorAuto.succeed("mount /dev/mapper/123456 /mnt")
+ initiatorAuto.succeed("mkdir -p /mnt/etc/{multipath,iscsi}")
+ initiatorAuto.succeed("cp -r /etc/multipath/wwids /mnt/etc/multipath/wwids")
+ initiatorAuto.succeed("cp -r /etc/iscsi/{nodes,send_targets} /mnt/etc/iscsi")
+ initiatorAuto.succeed(
+ "nixos-install --no-bootloader --no-root-passwd --system /etc/initiator-root-disk-closure"
+ )
+ initiatorAuto.succeed("umount /mnt")
+ initiatorAuto.shutdown()
- initiatorRootDisk.start()
- initiatorRootDisk.wait_for_unit("multi-user.target")
- initiatorRootDisk.wait_for_unit("iscsid")
+ initiatorRootDisk.start()
+ initiatorRootDisk.wait_for_unit("multi-user.target")
+ initiatorRootDisk.wait_for_unit("iscsid")
- # Log in over both nodes
- initiatorRootDisk.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.1.3 --login")
- initiatorRootDisk.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login")
- initiatorRootDisk.succeed("systemctl restart multipathd")
- initiatorRootDisk.succeed("systemd-cat multipath -ll")
+ # Log in over both nodes
+ initiatorRootDisk.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.1.3 --login")
+ initiatorRootDisk.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login")
+ initiatorRootDisk.succeed("systemctl restart multipathd")
+ initiatorRootDisk.succeed("systemd-cat multipath -ll")
- # Verify we can write and sync the root disk
- initiatorRootDisk.succeed("mkdir /scratch")
- initiatorRootDisk.succeed("touch /scratch/both-up")
- initiatorRootDisk.succeed("sync /scratch")
+ # Verify we can write and sync the root disk
+ initiatorRootDisk.succeed("mkdir /scratch")
+ initiatorRootDisk.succeed("touch /scratch/both-up")
+ initiatorRootDisk.succeed("sync /scratch")
- # Verify we can write to the root with ens9 (sda, 192.168.1.3) down
- initiatorRootDisk.succeed("ip link set ens9 down")
- initiatorRootDisk.succeed("touch /scratch/ens9-down")
- initiatorRootDisk.succeed("sync /scratch")
- initiatorRootDisk.succeed("ip link set ens9 up")
+ # Verify we can write to the root with ens9 (sda, 192.168.1.3) down
+ initiatorRootDisk.succeed("ip link set ens9 down")
+ initiatorRootDisk.succeed("touch /scratch/ens9-down")
+ initiatorRootDisk.succeed("sync /scratch")
+ initiatorRootDisk.succeed("ip link set ens9 up")
- # todo: better way to wait until multipath notices the link is back
- initiatorRootDisk.succeed("sleep 5")
- initiatorRootDisk.succeed("touch /scratch/both-down")
- initiatorRootDisk.succeed("sync /scratch")
+ # todo: better way to wait until multipath notices the link is back
+ initiatorRootDisk.succeed("sleep 5")
+ initiatorRootDisk.succeed("touch /scratch/both-down")
+ initiatorRootDisk.succeed("sync /scratch")
- # Verify we can write to the root with ens10 (sdb, 192.168.2.3) down
- initiatorRootDisk.succeed("ip link set ens10 down")
- initiatorRootDisk.succeed("touch /scratch/ens10-down")
- initiatorRootDisk.succeed("sync /scratch")
- initiatorRootDisk.succeed("ip link set ens10 up")
- initiatorRootDisk.succeed("touch /scratch/ens10-down")
- initiatorRootDisk.succeed("sync /scratch")
+ # Verify we can write to the root with ens10 (sdb, 192.168.2.3) down
+ initiatorRootDisk.succeed("ip link set ens10 down")
+ initiatorRootDisk.succeed("touch /scratch/ens10-down")
+ initiatorRootDisk.succeed("sync /scratch")
+ initiatorRootDisk.succeed("ip link set ens10 up")
+ initiatorRootDisk.succeed("touch /scratch/ens10-down")
+ initiatorRootDisk.succeed("sync /scratch")
- initiatorRootDisk.succeed("ip link set ens9 up")
- initiatorRootDisk.succeed("ip link set ens10 up")
- initiatorRootDisk.shutdown()
+ initiatorRootDisk.succeed("ip link set ens9 up")
+ initiatorRootDisk.succeed("ip link set ens10 up")
+ initiatorRootDisk.shutdown()
- # Verify we can boot with the target's eth1 down, forcing
- # it to multipath via the second link
- target.succeed("ip link set eth1 down")
- initiatorRootDisk.start()
- initiatorRootDisk.wait_for_unit("multi-user.target")
- initiatorRootDisk.wait_for_unit("iscsid")
- initiatorRootDisk.succeed("test -e /scratch/both-up")
- '';
- }
-)
+ # Verify we can boot with the target's eth1 down, forcing
+ # it to multipath via the second link
+ target.succeed("ip link set eth1 down")
+ initiatorRootDisk.start()
+ initiatorRootDisk.wait_for_unit("multi-user.target")
+ initiatorRootDisk.wait_for_unit("iscsid")
+ initiatorRootDisk.succeed("test -e /scratch/both-up")
+ '';
+}
diff --git a/nixos/tests/iscsi-root.nix b/nixos/tests/iscsi-root.nix
index ab0ab9f89e9b..9d0b0765b311 100644
--- a/nixos/tests/iscsi-root.nix
+++ b/nixos/tests/iscsi-root.nix
@@ -1,182 +1,180 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- initiatorName = "iqn.2020-08.org.linux-iscsi.initiatorhost:example";
- targetName = "iqn.2003-01.org.linux-iscsi.target.x8664:sn.acf8fd9c23af";
- in
- {
- name = "iscsi";
- meta = {
- maintainers = lib.teams.deshaw.members ++ lib.teams.helsinki-systems.members;
- };
+{ pkgs, lib, ... }:
+let
+ initiatorName = "iqn.2020-08.org.linux-iscsi.initiatorhost:example";
+ targetName = "iqn.2003-01.org.linux-iscsi.target.x8664:sn.acf8fd9c23af";
+in
+{
+ name = "iscsi";
+ meta = {
+ maintainers = lib.teams.deshaw.members ++ lib.teams.helsinki-systems.members;
+ };
- nodes = {
- target =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- services.target = {
- enable = true;
- config = {
- fabric_modules = [ ];
- storage_objects = [
- {
- dev = "/dev/vdb";
- name = "test";
- plugin = "block";
- write_back = true;
- wwn = "92b17c3f-6b40-4168-b082-ceeb7b495522";
- }
- ];
- targets = [
- {
- fabric = "iscsi";
- tpgs = [
- {
- enable = true;
- attributes = {
- authentication = 0;
- generate_node_acls = 1;
- };
- luns = [
- {
- alias = "94dfe06967";
- alua_tg_pt_gp_name = "default_tg_pt_gp";
- index = 0;
- storage_object = "/backstores/block/test";
- }
- ];
- node_acls = [
- {
- mapped_luns = [
- {
- alias = "d42f5bdf8a";
- index = 0;
- tpg_lun = 0;
- write_protect = false;
- }
- ];
- node_wwn = initiatorName;
- }
- ];
- portals = [
- {
- ip_address = "[::]";
- iser = false;
- offload = false;
- port = 3260;
- }
- ];
- tag = 1;
- }
- ];
- wwn = targetName;
- }
- ];
- };
- };
-
- networking.firewall.allowedTCPPorts = [ 3260 ];
- networking.firewall.allowedUDPPorts = [ 3260 ];
-
- virtualisation.memorySize = 2048;
- virtualisation.emptyDiskImages = [ 2048 ];
- };
-
- initiatorAuto =
- {
- nodes,
- config,
- pkgs,
- ...
- }:
- {
- services.openiscsi = {
- enable = true;
- enableAutoLoginOut = true;
- discoverPortal = "target";
- name = initiatorName;
- };
-
- environment.systemPackages = with pkgs; [
- xfsprogs
- ];
-
- system.extraDependencies = [ nodes.initiatorRootDisk.system.build.toplevel ];
-
- nix.settings = {
- substituters = lib.mkForce [ ];
- hashed-mirrors = null;
- connect-timeout = 1;
+ nodes = {
+ target =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ services.target = {
+ enable = true;
+ config = {
+ fabric_modules = [ ];
+ storage_objects = [
+ {
+ dev = "/dev/vdb";
+ name = "test";
+ plugin = "block";
+ write_back = true;
+ wwn = "92b17c3f-6b40-4168-b082-ceeb7b495522";
+ }
+ ];
+ targets = [
+ {
+ fabric = "iscsi";
+ tpgs = [
+ {
+ enable = true;
+ attributes = {
+ authentication = 0;
+ generate_node_acls = 1;
+ };
+ luns = [
+ {
+ alias = "94dfe06967";
+ alua_tg_pt_gp_name = "default_tg_pt_gp";
+ index = 0;
+ storage_object = "/backstores/block/test";
+ }
+ ];
+ node_acls = [
+ {
+ mapped_luns = [
+ {
+ alias = "d42f5bdf8a";
+ index = 0;
+ tpg_lun = 0;
+ write_protect = false;
+ }
+ ];
+ node_wwn = initiatorName;
+ }
+ ];
+ portals = [
+ {
+ ip_address = "[::]";
+ iser = false;
+ offload = false;
+ port = 3260;
+ }
+ ];
+ tag = 1;
+ }
+ ];
+ wwn = targetName;
+ }
+ ];
};
};
- initiatorRootDisk =
- {
- config,
- pkgs,
- modulesPath,
- lib,
- ...
- }:
- {
- boot.loader.grub.enable = false;
- boot.kernelParams = lib.mkOverride 5 ([
- "boot.shell_on_fail"
- "console=tty1"
- "ip=${config.networking.primaryIPAddress}:::255.255.255.0::eth1:none"
- ]);
+ networking.firewall.allowedTCPPorts = [ 3260 ];
+ networking.firewall.allowedUDPPorts = [ 3260 ];
- # defaults to true, puts some code in the initrd that tries to mount an overlayfs on /nix/store
- virtualisation.writableStore = false;
+ virtualisation.memorySize = 2048;
+ virtualisation.emptyDiskImages = [ 2048 ];
+ };
- fileSystems = lib.mkOverride 5 {
- "/" = {
- fsType = "xfs";
- device = "/dev/sda";
- options = [ "_netdev" ];
- };
- };
+ initiatorAuto =
+ {
+ nodes,
+ config,
+ pkgs,
+ ...
+ }:
+ {
+ services.openiscsi = {
+ enable = true;
+ enableAutoLoginOut = true;
+ discoverPortal = "target";
+ name = initiatorName;
+ };
- boot.iscsi-initiator = {
- discoverPortal = "target";
- name = initiatorName;
- target = targetName;
+ environment.systemPackages = with pkgs; [
+ xfsprogs
+ ];
+
+ system.extraDependencies = [ nodes.initiatorRootDisk.system.build.toplevel ];
+
+ nix.settings = {
+ substituters = lib.mkForce [ ];
+ hashed-mirrors = null;
+ connect-timeout = 1;
+ };
+ };
+
+ initiatorRootDisk =
+ {
+ config,
+ pkgs,
+ modulesPath,
+ lib,
+ ...
+ }:
+ {
+ boot.loader.grub.enable = false;
+ boot.kernelParams = lib.mkOverride 5 ([
+ "boot.shell_on_fail"
+ "console=tty1"
+ "ip=${config.networking.primaryIPAddress}:::255.255.255.0::eth1:none"
+ ]);
+
+ # defaults to true, puts some code in the initrd that tries to mount an overlayfs on /nix/store
+ virtualisation.writableStore = false;
+
+ fileSystems = lib.mkOverride 5 {
+ "/" = {
+ fsType = "xfs";
+ device = "/dev/sda";
+ options = [ "_netdev" ];
};
};
- };
- testScript =
- { nodes, ... }:
- ''
- target.start()
- target.wait_for_unit("iscsi-target.service")
+ boot.iscsi-initiator = {
+ discoverPortal = "target";
+ name = initiatorName;
+ target = targetName;
+ };
+ };
+ };
- initiatorAuto.start()
+ testScript =
+ { nodes, ... }:
+ ''
+ target.start()
+ target.wait_for_unit("iscsi-target.service")
- initiatorAuto.wait_for_unit("iscsid.service")
- initiatorAuto.wait_for_unit("iscsi.service")
- initiatorAuto.get_unit_info("iscsi")
+ initiatorAuto.start()
- initiatorAuto.succeed("set -x; while ! test -e /dev/sda; do sleep 1; done")
+ initiatorAuto.wait_for_unit("iscsid.service")
+ initiatorAuto.wait_for_unit("iscsi.service")
+ initiatorAuto.get_unit_info("iscsi")
- initiatorAuto.succeed("mkfs.xfs /dev/sda")
- initiatorAuto.succeed("mkdir /mnt && mount /dev/sda /mnt")
- initiatorAuto.succeed(
- "nixos-install --no-bootloader --no-root-passwd --system ${nodes.initiatorRootDisk.config.system.build.toplevel}"
- )
- initiatorAuto.succeed("umount /mnt && rmdir /mnt")
- initiatorAuto.shutdown()
+ initiatorAuto.succeed("set -x; while ! test -e /dev/sda; do sleep 1; done")
- initiatorRootDisk.start()
- initiatorRootDisk.wait_for_unit("multi-user.target")
- initiatorRootDisk.wait_for_unit("iscsid")
- initiatorRootDisk.succeed("touch test")
- initiatorRootDisk.shutdown()
- '';
- }
-)
+ initiatorAuto.succeed("mkfs.xfs /dev/sda")
+ initiatorAuto.succeed("mkdir /mnt && mount /dev/sda /mnt")
+ initiatorAuto.succeed(
+ "nixos-install --no-bootloader --no-root-passwd --system ${nodes.initiatorRootDisk.config.system.build.toplevel}"
+ )
+ initiatorAuto.succeed("umount /mnt && rmdir /mnt")
+ initiatorAuto.shutdown()
+
+ initiatorRootDisk.start()
+ initiatorRootDisk.wait_for_unit("multi-user.target")
+ initiatorRootDisk.wait_for_unit("iscsid")
+ initiatorRootDisk.succeed("touch test")
+ initiatorRootDisk.shutdown()
+ '';
+}
diff --git a/nixos/tests/isolate.nix b/nixos/tests/isolate.nix
index c6f83240ad08..fe9ea18a2c6c 100644
--- a/nixos/tests/isolate.nix
+++ b/nixos/tests/isolate.nix
@@ -1,40 +1,38 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "isolate";
- meta.maintainers = with lib.maintainers; [ virchau13 ];
+{ lib, ... }:
+{
+ name = "isolate";
+ meta.maintainers = with lib.maintainers; [ virchau13 ];
- nodes.machine =
- { ... }:
- {
- security.isolate = {
- enable = true;
- };
+ nodes.machine =
+ { ... }:
+ {
+ security.isolate = {
+ enable = true;
};
+ };
- testScript = ''
- bash_path = machine.succeed('realpath $(which bash)').strip()
- sleep_path = machine.succeed('realpath $(which sleep)').strip()
- def sleep_test(walltime, sleeptime):
- return f'isolate --no-default-dirs --wall-time {walltime} ' + \
- f'--dir=/box={box_path} --dir=/nix=/nix --run -- ' + \
- f"{bash_path} -c 'exec -a sleep {sleep_path} {sleeptime}'"
+ testScript = ''
+ bash_path = machine.succeed('realpath $(which bash)').strip()
+ sleep_path = machine.succeed('realpath $(which sleep)').strip()
+ def sleep_test(walltime, sleeptime):
+ return f'isolate --no-default-dirs --wall-time {walltime} ' + \
+ f'--dir=/box={box_path} --dir=/nix=/nix --run -- ' + \
+ f"{bash_path} -c 'exec -a sleep {sleep_path} {sleeptime}'"
- def sleep_test_cg(walltime, sleeptime):
- return f'isolate --cg --no-default-dirs --wall-time {walltime} ' + \
- f'--dir=/box={box_path} --dir=/nix=/nix --processes=2 --run -- ' + \
- f"{bash_path} -c '( exec -a sleep {sleep_path} {sleeptime} )'"
+ def sleep_test_cg(walltime, sleeptime):
+ return f'isolate --cg --no-default-dirs --wall-time {walltime} ' + \
+ f'--dir=/box={box_path} --dir=/nix=/nix --processes=2 --run -- ' + \
+ f"{bash_path} -c '( exec -a sleep {sleep_path} {sleeptime} )'"
- with subtest("without cgroups"):
- box_path = machine.succeed('isolate --init').strip()
- machine.succeed(sleep_test(1, 0.5))
- machine.fail(sleep_test(0.5, 1))
- machine.succeed('isolate --cleanup')
- with subtest("with cgroups"):
- box_path = machine.succeed('isolate --cg --init').strip()
- machine.succeed(sleep_test_cg(1, 0.5))
- machine.fail(sleep_test_cg(0.5, 1))
- machine.succeed('isolate --cg --cleanup')
- '';
- }
-)
+ with subtest("without cgroups"):
+ box_path = machine.succeed('isolate --init').strip()
+ machine.succeed(sleep_test(1, 0.5))
+ machine.fail(sleep_test(0.5, 1))
+ machine.succeed('isolate --cleanup')
+ with subtest("with cgroups"):
+ box_path = machine.succeed('isolate --cg --init').strip()
+ machine.succeed(sleep_test_cg(1, 0.5))
+ machine.fail(sleep_test_cg(0.5, 1))
+ machine.succeed('isolate --cg --cleanup')
+ '';
+}
diff --git a/nixos/tests/isso.nix b/nixos/tests/isso.nix
index f3af293bf75b..a5ed88044b26 100644
--- a/nixos/tests/isso.nix
+++ b/nixos/tests/isso.nix
@@ -1,36 +1,34 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "isso";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
- };
+{ pkgs, ... }:
+{
+ name = "isso";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
- nodes.machine =
- { config, pkgs, ... }:
- {
- services.isso = {
- enable = true;
- settings = {
- general = {
- dbpath = "/var/lib/isso/comments.db";
- host = "http://localhost";
- };
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ services.isso = {
+ enable = true;
+ settings = {
+ general = {
+ dbpath = "/var/lib/isso/comments.db";
+ host = "http://localhost";
};
};
};
+ };
- testScript =
- let
- port = 8080;
- in
- ''
- machine.wait_for_unit("isso.service")
+ testScript =
+ let
+ port = 8080;
+ in
+ ''
+ machine.wait_for_unit("isso.service")
- machine.wait_for_open_port(${toString port})
+ machine.wait_for_open_port(${toString port})
- machine.succeed("curl --fail http://localhost:${toString port}/?uri")
- machine.succeed("curl --fail http://localhost:${toString port}/js/embed.min.js")
- '';
- }
-)
+ machine.succeed("curl --fail http://localhost:${toString port}/?uri")
+ machine.succeed("curl --fail http://localhost:${toString port}/js/embed.min.js")
+ '';
+}
diff --git a/nixos/tests/jackett.nix b/nixos/tests/jackett.nix
index 11931c7c96bd..9ce8209f49dd 100644
--- a/nixos/tests/jackett.nix
+++ b/nixos/tests/jackett.nix
@@ -1,25 +1,23 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- let
- jackettPort = 9117;
- in
- {
- name = "jackett";
- meta.maintainers = with lib.maintainers; [ etu ];
+let
+ jackettPort = 9117;
+in
+{
+ name = "jackett";
+ meta.maintainers = with lib.maintainers; [ etu ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.jackett.enable = true;
- services.jackett.port = jackettPort;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.jackett.enable = true;
+ services.jackett.port = jackettPort;
+ };
- testScript = ''
- machine.start()
- machine.wait_for_unit("jackett.service")
- machine.wait_for_open_port(${toString jackettPort})
- machine.succeed("curl --fail http://localhost:${toString jackettPort}/")
- '';
- }
-)
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("jackett.service")
+ machine.wait_for_open_port(${toString jackettPort})
+ machine.succeed("curl --fail http://localhost:${toString jackettPort}/")
+ '';
+}
diff --git a/nixos/tests/jellyfin.nix b/nixos/tests/jellyfin.nix
index 2b879ff83751..6b4a962e029f 100644
--- a/nixos/tests/jellyfin.nix
+++ b/nixos/tests/jellyfin.nix
@@ -1,159 +1,157 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- {
- name = "jellyfin";
- meta.maintainers = with lib.maintainers; [ minijackson ];
+{
+ name = "jellyfin";
+ meta.maintainers = with lib.maintainers; [ minijackson ];
- nodes.machine =
- { ... }:
- {
- services.jellyfin.enable = true;
- environment.systemPackages = with pkgs; [ ffmpeg ];
+ nodes.machine =
+ { ... }:
+ {
+ services.jellyfin.enable = true;
+ environment.systemPackages = with pkgs; [ ffmpeg ];
+ };
+
+ # Documentation of the Jellyfin API: https://api.jellyfin.org/
+ # Beware, this link can be resource intensive
+ testScript =
+ let
+ payloads = {
+ auth = pkgs.writeText "auth.json" (
+ builtins.toJSON {
+ Username = "jellyfin";
+ }
+ );
+ empty = pkgs.writeText "empty.json" (builtins.toJSON { });
};
+ in
+ ''
+ import json
+ from urllib.parse import urlencode
- # Documentation of the Jellyfin API: https://api.jellyfin.org/
- # Beware, this link can be resource intensive
- testScript =
- let
- payloads = {
- auth = pkgs.writeText "auth.json" (
- builtins.toJSON {
- Username = "jellyfin";
- }
- );
- empty = pkgs.writeText "empty.json" (builtins.toJSON { });
- };
- in
- ''
- import json
- from urllib.parse import urlencode
+ machine.wait_for_unit("jellyfin.service")
+ machine.wait_for_open_port(8096)
+ machine.succeed("curl --fail http://localhost:8096/")
- machine.wait_for_unit("jellyfin.service")
- machine.wait_for_open_port(8096)
- machine.succeed("curl --fail http://localhost:8096/")
+ machine.wait_until_succeeds("curl --fail http://localhost:8096/health | grep Healthy")
- machine.wait_until_succeeds("curl --fail http://localhost:8096/health | grep Healthy")
-
- auth_header = 'MediaBrowser Client="NixOS Integration Tests", DeviceId="1337", Device="Apple II", Version="20.09"'
+ auth_header = 'MediaBrowser Client="NixOS Integration Tests", DeviceId="1337", Device="Apple II", Version="20.09"'
- def api_get(path):
- return f"curl --fail 'http://localhost:8096{path}' -H 'X-Emby-Authorization:{auth_header}'"
+ def api_get(path):
+ return f"curl --fail 'http://localhost:8096{path}' -H 'X-Emby-Authorization:{auth_header}'"
- def api_post(path, json_file=None):
- if json_file:
- return f"curl --fail -X post 'http://localhost:8096{path}' -d '@{json_file}' -H Content-Type:application/json -H 'X-Emby-Authorization:{auth_header}'"
- else:
- return f"curl --fail -X post 'http://localhost:8096{path}' -H 'X-Emby-Authorization:{auth_header}'"
+ def api_post(path, json_file=None):
+ if json_file:
+ return f"curl --fail -X post 'http://localhost:8096{path}' -d '@{json_file}' -H Content-Type:application/json -H 'X-Emby-Authorization:{auth_header}'"
+ else:
+ return f"curl --fail -X post 'http://localhost:8096{path}' -H 'X-Emby-Authorization:{auth_header}'"
- with machine.nested("Wizard completes"):
- machine.wait_until_succeeds(api_get("/Startup/Configuration"))
- machine.succeed(api_get("/Startup/FirstUser"))
- machine.succeed(api_post("/Startup/Complete"))
+ with machine.nested("Wizard completes"):
+ machine.wait_until_succeeds(api_get("/Startup/Configuration"))
+ machine.succeed(api_get("/Startup/FirstUser"))
+ machine.succeed(api_post("/Startup/Complete"))
- with machine.nested("Can login"):
- auth_result_str = machine.succeed(
- api_post(
- "/Users/AuthenticateByName",
- "${payloads.auth}",
- )
- )
- auth_result = json.loads(auth_result_str)
- auth_token = auth_result["AccessToken"]
- auth_header += f", Token={auth_token}"
+ with machine.nested("Can login"):
+ auth_result_str = machine.succeed(
+ api_post(
+ "/Users/AuthenticateByName",
+ "${payloads.auth}",
+ )
+ )
+ auth_result = json.loads(auth_result_str)
+ auth_token = auth_result["AccessToken"]
+ auth_header += f", Token={auth_token}"
- sessions_result_str = machine.succeed(api_get("/Sessions"))
- sessions_result = json.loads(sessions_result_str)
+ sessions_result_str = machine.succeed(api_get("/Sessions"))
+ sessions_result = json.loads(sessions_result_str)
- this_session = [
- session for session in sessions_result if session["DeviceId"] == "1337"
- ]
- if len(this_session) != 1:
- raise Exception("Session not created")
+ this_session = [
+ session for session in sessions_result if session["DeviceId"] == "1337"
+ ]
+ if len(this_session) != 1:
+ raise Exception("Session not created")
- me_str = machine.succeed(api_get("/Users/Me"))
- me = json.loads(me_str)["Id"]
+ me_str = machine.succeed(api_get("/Users/Me"))
+ me = json.loads(me_str)["Id"]
- with machine.nested("Can add library"):
- tempdir = machine.succeed("mktemp -d -p /var/lib/jellyfin").strip()
- machine.succeed(f"chmod 755 '{tempdir}'")
+ with machine.nested("Can add library"):
+ tempdir = machine.succeed("mktemp -d -p /var/lib/jellyfin").strip()
+ machine.succeed(f"chmod 755 '{tempdir}'")
- # Generate a dummy video that we can test later
- videofile = f"{tempdir}/Big Buck Bunny (2008) [1080p].mkv"
- machine.succeed(f"ffmpeg -f lavfi -i testsrc2=duration=5 '{videofile}'")
+ # Generate a dummy video that we can test later
+ videofile = f"{tempdir}/Big Buck Bunny (2008) [1080p].mkv"
+ machine.succeed(f"ffmpeg -f lavfi -i testsrc2=duration=5 '{videofile}'")
- add_folder_query = urlencode(
- {
- "name": "My Library",
- "collectionType": "Movies",
- "paths": tempdir,
- "refreshLibrary": "true",
- }
- )
+ add_folder_query = urlencode(
+ {
+ "name": "My Library",
+ "collectionType": "Movies",
+ "paths": tempdir,
+ "refreshLibrary": "true",
+ }
+ )
- machine.succeed(
- api_post(
- f"/Library/VirtualFolders?{add_folder_query}",
- "${payloads.empty}",
- )
- )
+ machine.succeed(
+ api_post(
+ f"/Library/VirtualFolders?{add_folder_query}",
+ "${payloads.empty}",
+ )
+ )
- def is_refreshed(_):
- folders_str = machine.succeed(api_get("/Library/VirtualFolders"))
- folders = json.loads(folders_str)
- print(folders)
- return all(folder["RefreshStatus"] == "Idle" for folder in folders)
+ def is_refreshed(_):
+ folders_str = machine.succeed(api_get("/Library/VirtualFolders"))
+ folders = json.loads(folders_str)
+ print(folders)
+ return all(folder["RefreshStatus"] == "Idle" for folder in folders)
- retry(is_refreshed)
+ retry(is_refreshed)
- with machine.nested("Can identify videos"):
- items = []
+ with machine.nested("Can identify videos"):
+ items = []
- # For some reason, having the folder refreshed doesn't mean the
- # movie was scanned
- def has_movie(_):
- global items
+ # For some reason, having the folder refreshed doesn't mean the
+ # movie was scanned
+ def has_movie(_):
+ global items
- items_str = machine.succeed(
- api_get(f"/Users/{me}/Items?IncludeItemTypes=Movie&Recursive=true")
- )
- items = json.loads(items_str)["Items"]
+ items_str = machine.succeed(
+ api_get(f"/Users/{me}/Items?IncludeItemTypes=Movie&Recursive=true")
+ )
+ items = json.loads(items_str)["Items"]
- return len(items) == 1
+ return len(items) == 1
- retry(has_movie)
+ retry(has_movie)
- video = items[0]["Id"]
+ video = items[0]["Id"]
- item_info_str = machine.succeed(api_get(f"/Users/{me}/Items/{video}"))
- item_info = json.loads(item_info_str)
+ item_info_str = machine.succeed(api_get(f"/Users/{me}/Items/{video}"))
+ item_info = json.loads(item_info_str)
- if item_info["Name"] != "Big Buck Bunny":
- raise Exception("Jellyfin failed to properly identify file")
+ if item_info["Name"] != "Big Buck Bunny":
+ raise Exception("Jellyfin failed to properly identify file")
- with machine.nested("Can read videos"):
- media_source_id = item_info["MediaSources"][0]["Id"]
+ with machine.nested("Can read videos"):
+ media_source_id = item_info["MediaSources"][0]["Id"]
- machine.succeed(
- "ffmpeg"
- + f" -headers 'X-Emby-Authorization:{auth_header}'"
- + f" -i http://localhost:8096/Videos/{video}/master.m3u8?mediaSourceId={media_source_id}"
- + " /tmp/test.mkv"
- )
+ machine.succeed(
+ "ffmpeg"
+ + f" -headers 'X-Emby-Authorization:{auth_header}'"
+ + f" -i http://localhost:8096/Videos/{video}/master.m3u8?mediaSourceId={media_source_id}"
+ + " /tmp/test.mkv"
+ )
- duration = machine.succeed(
- "ffprobe /tmp/test.mkv"
- + " -show_entries format=duration"
- + " -of compact=print_section=0:nokey=1"
- )
+ duration = machine.succeed(
+ "ffprobe /tmp/test.mkv"
+ + " -show_entries format=duration"
+ + " -of compact=print_section=0:nokey=1"
+ )
- if duration.strip() != "5.000000":
- raise Exception("Downloaded video has wrong duration")
- '';
- }
-)
+ if duration.strip() != "5.000000":
+ raise Exception("Downloaded video has wrong duration")
+ '';
+}
diff --git a/nixos/tests/jenkins-cli.nix b/nixos/tests/jenkins-cli.nix
index fdd2767cf041..69167ffa3a6f 100644
--- a/nixos/tests/jenkins-cli.nix
+++ b/nixos/tests/jenkins-cli.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- rec {
- name = "jenkins-cli";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ pamplemousse ];
- };
+{ pkgs, ... }:
+rec {
+ name = "jenkins-cli";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ pamplemousse ];
+ };
- nodes = {
- machine =
- { ... }:
- {
- services.jenkins = {
- enable = true;
- withCLI = true;
- };
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.jenkins = {
+ enable = true;
+ withCLI = true;
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine.wait_for_unit("jenkins")
+ machine.wait_for_unit("jenkins")
- assert "JENKINS_URL" in machine.succeed("env")
- assert "http://0.0.0.0:8080" in machine.succeed("echo $JENKINS_URL")
+ assert "JENKINS_URL" in machine.succeed("env")
+ assert "http://0.0.0.0:8080" in machine.succeed("echo $JENKINS_URL")
- machine.succeed(
- "jenkins-cli -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword)"
- )
- '';
- }
-)
+ machine.succeed(
+ "jenkins-cli -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword)"
+ )
+ '';
+}
diff --git a/nixos/tests/jenkins.nix b/nixos/tests/jenkins.nix
index cd82214fb3ac..7a8e4ea4d0b4 100644
--- a/nixos/tests/jenkins.nix
+++ b/nixos/tests/jenkins.nix
@@ -4,140 +4,138 @@
# 3. jenkins service not started on slave node
# 4. declarative jobs can be added and removed
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "jenkins";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- bjornfor
- domenkozar
- ];
- };
+{ pkgs, ... }:
+{
+ name = "jenkins";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ bjornfor
+ domenkozar
+ ];
+ };
- nodes = {
+ nodes = {
- master =
- { ... }:
- {
- services.jenkins = {
+ master =
+ { ... }:
+ {
+ services.jenkins = {
+ enable = true;
+ jobBuilder = {
enable = true;
- jobBuilder = {
- enable = true;
- nixJobs = [
- {
- job = {
- name = "job-1";
- builders = [
- {
- shell = ''
- echo "Running job-1"
- '';
- }
- ];
- };
- }
+ nixJobs = [
+ {
+ job = {
+ name = "job-1";
+ builders = [
+ {
+ shell = ''
+ echo "Running job-1"
+ '';
+ }
+ ];
+ };
+ }
- {
- job = {
- name = "folder-1";
- project-type = "folder";
- };
- }
+ {
+ job = {
+ name = "folder-1";
+ project-type = "folder";
+ };
+ }
- {
- job = {
- name = "folder-1/job-2";
- builders = [
- {
- shell = ''
- echo "Running job-2"
- '';
- }
- ];
- };
- }
- ];
- };
+ {
+ job = {
+ name = "folder-1/job-2";
+ builders = [
+ {
+ shell = ''
+ echo "Running job-2"
+ '';
+ }
+ ];
+ };
+ }
+ ];
};
-
- specialisation.noJenkinsJobs.configuration = {
- services.jenkins.jobBuilder.nixJobs = pkgs.lib.mkForce [ ];
- };
-
- # should have no effect
- services.jenkinsSlave.enable = true;
-
- users.users.jenkins.extraGroups = [ "users" ];
-
- systemd.services.jenkins.serviceConfig.TimeoutStartSec = "6min";
-
- # Increase disk space to prevent this issue:
- #
- # WARNING h.n.DiskSpaceMonitorDescriptor#markNodeOfflineOrOnline: Making Built-In Node offline temporarily due to the lack of disk space
- virtualisation.diskSize = 2 * 1024;
};
- slave =
- { ... }:
- {
- services.jenkinsSlave.enable = true;
-
- users.users.jenkins.extraGroups = [ "users" ];
+ specialisation.noJenkinsJobs.configuration = {
+ services.jenkins.jobBuilder.nixJobs = pkgs.lib.mkForce [ ];
};
- };
+ # should have no effect
+ services.jenkinsSlave.enable = true;
- testScript =
- { nodes, ... }:
- let
- configWithoutJobs = "${nodes.master.system.build.toplevel}/specialisation/noJenkinsJobs";
- jenkinsPort = nodes.master.services.jenkins.port;
- jenkinsUrl = "http://localhost:${toString jenkinsPort}";
- in
- ''
- start_all()
+ users.users.jenkins.extraGroups = [ "users" ];
- master.wait_for_unit("default.target")
+ systemd.services.jenkins.serviceConfig.TimeoutStartSec = "6min";
- assert "Authentication required" in master.succeed("curl http://localhost:8080")
+ # Increase disk space to prevent this issue:
+ #
+ # WARNING h.n.DiskSpaceMonitorDescriptor#markNodeOfflineOrOnline: Making Built-In Node offline temporarily due to the lack of disk space
+ virtualisation.diskSize = 2 * 1024;
+ };
- for host in master, slave:
- groups = host.succeed("sudo -u jenkins groups")
- assert "jenkins" in groups
- assert "users" in groups
+ slave =
+ { ... }:
+ {
+ services.jenkinsSlave.enable = true;
- slave.fail("systemctl is-enabled jenkins.service")
+ users.users.jenkins.extraGroups = [ "users" ];
+ };
- slave.succeed("java -fullversion")
+ };
- with subtest("jobs are declarative"):
- # Check that jobs are created on disk.
- master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/job-1/config.xml")
- master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/folder-1/config.xml")
- master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/folder-1/jobs/job-2/config.xml")
+ testScript =
+ { nodes, ... }:
+ let
+ configWithoutJobs = "${nodes.master.system.build.toplevel}/specialisation/noJenkinsJobs";
+ jenkinsPort = nodes.master.services.jenkins.port;
+ jenkinsUrl = "http://localhost:${toString jenkinsPort}";
+ in
+ ''
+ start_all()
- # Verify that jenkins also sees the jobs.
- out = master.succeed("${pkgs.jenkins}/bin/jenkins-cli -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) list-jobs")
- jobs = [x.strip() for x in out.splitlines()]
- # Seeing jobs inside folders requires the Folders plugin
- # (https://plugins.jenkins.io/cloudbees-folder/), which we don't have
- # in this vanilla jenkins install, so limit ourself to non-folder jobs.
- assert jobs == ['job-1'], f"jobs != ['job-1']: {jobs}"
+ master.wait_for_unit("default.target")
- master.succeed(
- "${configWithoutJobs}/bin/switch-to-configuration test >&2"
- )
+ assert "Authentication required" in master.succeed("curl http://localhost:8080")
- # Check that jobs are removed from disk.
- master.wait_until_fails("test -f /var/lib/jenkins/jobs/job-1/config.xml")
- master.wait_until_fails("test -f /var/lib/jenkins/jobs/folder-1/config.xml")
- master.wait_until_fails("test -f /var/lib/jenkins/jobs/folder-1/jobs/job-2/config.xml")
+ for host in master, slave:
+ groups = host.succeed("sudo -u jenkins groups")
+ assert "jenkins" in groups
+ assert "users" in groups
- # Verify that jenkins also sees the jobs as removed.
- out = master.succeed("${pkgs.jenkins}/bin/jenkins-cli -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) list-jobs")
- jobs = [x.strip() for x in out.splitlines()]
- assert jobs == [], f"jobs != []: {jobs}"
- '';
- }
-)
+ slave.fail("systemctl is-enabled jenkins.service")
+
+ slave.succeed("java -fullversion")
+
+ with subtest("jobs are declarative"):
+ # Check that jobs are created on disk.
+ master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/job-1/config.xml")
+ master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/folder-1/config.xml")
+ master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/folder-1/jobs/job-2/config.xml")
+
+ # Verify that jenkins also sees the jobs.
+ out = master.succeed("${pkgs.jenkins}/bin/jenkins-cli -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) list-jobs")
+ jobs = [x.strip() for x in out.splitlines()]
+ # Seeing jobs inside folders requires the Folders plugin
+ # (https://plugins.jenkins.io/cloudbees-folder/), which we don't have
+ # in this vanilla jenkins install, so limit ourself to non-folder jobs.
+ assert jobs == ['job-1'], f"jobs != ['job-1']: {jobs}"
+
+ master.succeed(
+ "${configWithoutJobs}/bin/switch-to-configuration test >&2"
+ )
+
+ # Check that jobs are removed from disk.
+ master.wait_until_fails("test -f /var/lib/jenkins/jobs/job-1/config.xml")
+ master.wait_until_fails("test -f /var/lib/jenkins/jobs/folder-1/config.xml")
+ master.wait_until_fails("test -f /var/lib/jenkins/jobs/folder-1/jobs/job-2/config.xml")
+
+ # Verify that jenkins also sees the jobs as removed.
+ out = master.succeed("${pkgs.jenkins}/bin/jenkins-cli -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) list-jobs")
+ jobs = [x.strip() for x in out.splitlines()]
+ assert jobs == [], f"jobs != []: {jobs}"
+ '';
+}
diff --git a/nixos/tests/jibri.nix b/nixos/tests/jibri.nix
index d42e82bf1f47..2bfc41ed188d 100644
--- a/nixos/tests/jibri.nix
+++ b/nixos/tests/jibri.nix
@@ -1,74 +1,72 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "jibri";
- meta = with pkgs.lib; {
- maintainers = teams.jitsi.members;
- };
+{ pkgs, ... }:
+{
+ name = "jibri";
+ meta = with pkgs.lib; {
+ maintainers = teams.jitsi.members;
+ };
- nodes.machine =
- { config, pkgs, ... }:
- {
- virtualisation.memorySize = 5120;
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ virtualisation.memorySize = 5120;
- services.jitsi-meet = {
- enable = true;
- hostName = "machine";
- jibri.enable = true;
- };
- services.jibri.ignoreCert = true;
- services.jitsi-videobridge.openFirewall = true;
+ services.jitsi-meet = {
+ enable = true;
+ hostName = "machine";
+ jibri.enable = true;
+ };
+ services.jibri.ignoreCert = true;
+ services.jitsi-videobridge.openFirewall = true;
- networking.firewall.allowedTCPPorts = [
- 80
- 443
- ];
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
+ ];
- services.nginx.virtualHosts.machine = {
- enableACME = true;
- forceSSL = true;
- };
-
- security.acme.defaults.email = "me@example.org";
- security.acme.acceptTerms = true;
- security.acme.defaults.server = "https://example.com"; # self-signed only
+ services.nginx.virtualHosts.machine = {
+ enableACME = true;
+ forceSSL = true;
};
- testScript = ''
- machine.wait_for_unit("jitsi-videobridge2.service")
- machine.wait_for_unit("jicofo.service")
- machine.wait_for_unit("nginx.service")
- machine.wait_for_unit("prosody.service")
- machine.wait_for_unit("jibri.service")
+ security.acme.defaults.email = "me@example.org";
+ security.acme.acceptTerms = true;
+ security.acme.defaults.server = "https://example.com"; # self-signed only
+ };
- machine.wait_until_succeeds(
- "journalctl -b -u prosody -o cat | grep -q 'Authenticated as focus@auth.machine'", timeout=31
- )
- machine.wait_until_succeeds(
- "journalctl -b -u prosody -o cat | grep -q 'Authenticated as jvb@auth.machine'", timeout=32
- )
- machine.wait_until_succeeds(
- "journalctl -b -u prosody -o cat | grep -q 'Authenticated as jibri@auth.machine'", timeout=33
- )
- machine.wait_until_succeeds(
- "cat /var/log/jitsi/jibri/log.0.txt | grep -q 'Joined MUC: jibribrewery@internal.auth.machine'", timeout=34
- )
+ testScript = ''
+ machine.wait_for_unit("jitsi-videobridge2.service")
+ machine.wait_for_unit("jicofo.service")
+ machine.wait_for_unit("nginx.service")
+ machine.wait_for_unit("prosody.service")
+ machine.wait_for_unit("jibri.service")
- assert '"busyStatus":"IDLE","health":{"healthStatus":"HEALTHY"' in machine.succeed(
- "curl -X GET http://machine:2222/jibri/api/v1.0/health"
- )
- machine.succeed(
- """curl -H "Content-Type: application/json" -X POST http://localhost:2222/jibri/api/v1.0/startService -d '{"sessionId": "RecordTest","callParams":{"callUrlInfo":{"baseUrl": "https://machine","callName": "TestCall"}},"callLoginParams":{"domain": "recorder.machine", "username": "recorder", "password": "'"$(cat /var/lib/jitsi-meet/jibri-recorder-secret)"'" },"sinkType": "file"}'"""
- )
- machine.wait_until_succeeds(
- "cat /var/log/jitsi/jibri/log.0.txt | grep -q 'File recording service transitioning from state Starting up to Running'", timeout=35
- )
- machine.succeed(
- """sleep 15 && curl -H "Content-Type: application/json" -X POST http://localhost:2222/jibri/api/v1.0/stopService -d '{"sessionId": "RecordTest","callParams":{"callUrlInfo":{"baseUrl": "https://machine","callName": "TestCall"}},"callLoginParams":{"domain": "recorder.machine", "username": "recorder", "password": "'"$(cat /var/lib/jitsi-meet/jibri-recorder-secret)"'" },"sinkType": "file"}'"""
- )
- machine.wait_until_succeeds(
- "cat /var/log/jitsi/jibri/log.0.txt | grep -q 'Finalize script finished with exit value 0'", timeout=36
- )
- '';
- }
-)
+ machine.wait_until_succeeds(
+ "journalctl -b -u prosody -o cat | grep -q 'Authenticated as focus@auth.machine'", timeout=31
+ )
+ machine.wait_until_succeeds(
+ "journalctl -b -u prosody -o cat | grep -q 'Authenticated as jvb@auth.machine'", timeout=32
+ )
+ machine.wait_until_succeeds(
+ "journalctl -b -u prosody -o cat | grep -q 'Authenticated as jibri@auth.machine'", timeout=33
+ )
+ machine.wait_until_succeeds(
+ "cat /var/log/jitsi/jibri/log.0.txt | grep -q 'Joined MUC: jibribrewery@internal.auth.machine'", timeout=34
+ )
+
+ assert '"busyStatus":"IDLE","health":{"healthStatus":"HEALTHY"' in machine.succeed(
+ "curl -X GET http://machine:2222/jibri/api/v1.0/health"
+ )
+ machine.succeed(
+ """curl -H "Content-Type: application/json" -X POST http://localhost:2222/jibri/api/v1.0/startService -d '{"sessionId": "RecordTest","callParams":{"callUrlInfo":{"baseUrl": "https://machine","callName": "TestCall"}},"callLoginParams":{"domain": "recorder.machine", "username": "recorder", "password": "'"$(cat /var/lib/jitsi-meet/jibri-recorder-secret)"'" },"sinkType": "file"}'"""
+ )
+ machine.wait_until_succeeds(
+ "cat /var/log/jitsi/jibri/log.0.txt | grep -q 'File recording service transitioning from state Starting up to Running'", timeout=35
+ )
+ machine.succeed(
+ """sleep 15 && curl -H "Content-Type: application/json" -X POST http://localhost:2222/jibri/api/v1.0/stopService -d '{"sessionId": "RecordTest","callParams":{"callUrlInfo":{"baseUrl": "https://machine","callName": "TestCall"}},"callLoginParams":{"domain": "recorder.machine", "username": "recorder", "password": "'"$(cat /var/lib/jitsi-meet/jibri-recorder-secret)"'" },"sinkType": "file"}'"""
+ )
+ machine.wait_until_succeeds(
+ "cat /var/log/jitsi/jibri/log.0.txt | grep -q 'Finalize script finished with exit value 0'", timeout=36
+ )
+ '';
+}
diff --git a/nixos/tests/jirafeau.nix b/nixos/tests/jirafeau.nix
index 6cace65ed6f3..ebbd637a13ec 100644
--- a/nixos/tests/jirafeau.nix
+++ b/nixos/tests/jirafeau.nix
@@ -1,24 +1,22 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "jirafeau";
- meta.maintainers = [ ];
+{
+ name = "jirafeau";
+ meta.maintainers = [ ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.jirafeau = {
- enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.jirafeau = {
+ enable = true;
};
+ };
- testScript = ''
- machine.start()
- machine.wait_for_unit("phpfpm-jirafeau.service")
- machine.wait_for_unit("nginx.service")
- machine.wait_for_open_port(80)
- machine.succeed("curl -sSfL http://localhost/ | grep 'Jirafeau'")
- '';
- }
-)
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("phpfpm-jirafeau.service")
+ machine.wait_for_unit("nginx.service")
+ machine.wait_for_open_port(80)
+ machine.succeed("curl -sSfL http://localhost/ | grep 'Jirafeau'")
+ '';
+}
diff --git a/nixos/tests/jitsi-meet.nix b/nixos/tests/jitsi-meet.nix
index a9934700ecf3..2181ed863a88 100644
--- a/nixos/tests/jitsi-meet.nix
+++ b/nixos/tests/jitsi-meet.nix
@@ -1,80 +1,78 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "jitsi-meet";
- meta = with pkgs.lib; {
- maintainers = teams.jitsi.members;
- };
+{ pkgs, ... }:
+{
+ name = "jitsi-meet";
+ meta = with pkgs.lib; {
+ maintainers = teams.jitsi.members;
+ };
- nodes = {
- client =
- { nodes, pkgs, ... }:
- {
+ nodes = {
+ client =
+ { nodes, pkgs, ... }:
+ {
+ };
+ server =
+ { config, pkgs, ... }:
+ {
+ services.jitsi-meet = {
+ enable = true;
+ hostName = "server";
};
- server =
- { config, pkgs, ... }:
- {
- services.jitsi-meet = {
- enable = true;
- hostName = "server";
- };
- services.jitsi-videobridge.openFirewall = true;
+ services.jitsi-videobridge.openFirewall = true;
- networking.firewall.allowedTCPPorts = [
- 80
- 443
- ];
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
+ ];
- services.nginx.virtualHosts.server = {
- enableACME = true;
- forceSSL = true;
- };
+ services.nginx.virtualHosts.server = {
+ enableACME = true;
+ forceSSL = true;
+ };
- security.acme.acceptTerms = true;
- security.acme.defaults.email = "me@example.org";
- security.acme.defaults.server = "https://example.com"; # self-signed only
+ security.acme.acceptTerms = true;
+ security.acme.defaults.email = "me@example.org";
+ security.acme.defaults.server = "https://example.com"; # self-signed only
- specialisation.caddy = {
- inheritParentConfig = true;
- configuration = {
- services.jitsi-meet = {
- caddy.enable = true;
- nginx.enable = false;
- };
- services.caddy.virtualHosts.${config.services.jitsi-meet.hostName}.extraConfig = ''
- tls internal
- '';
+ specialisation.caddy = {
+ inheritParentConfig = true;
+ configuration = {
+ services.jitsi-meet = {
+ caddy.enable = true;
+ nginx.enable = false;
};
+ services.caddy.virtualHosts.${config.services.jitsi-meet.hostName}.extraConfig = ''
+ tls internal
+ '';
};
};
- };
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- server.wait_for_unit("jitsi-videobridge2.service")
- server.wait_for_unit("jicofo.service")
- server.wait_for_unit("nginx.service")
- server.wait_for_unit("prosody.service")
+ testScript =
+ { nodes, ... }:
+ ''
+ server.wait_for_unit("jitsi-videobridge2.service")
+ server.wait_for_unit("jicofo.service")
+ server.wait_for_unit("nginx.service")
+ server.wait_for_unit("prosody.service")
- server.wait_until_succeeds(
- "journalctl -b -u prosody -o cat | grep -q 'Authenticated as focus@auth.server'"
- )
- server.wait_until_succeeds(
- "journalctl -b -u prosody -o cat | grep -q 'Authenticated as jvb@auth.server'"
- )
+ server.wait_until_succeeds(
+ "journalctl -b -u prosody -o cat | grep -q 'Authenticated as focus@auth.server'"
+ )
+ server.wait_until_succeeds(
+ "journalctl -b -u prosody -o cat | grep -q 'Authenticated as jvb@auth.server'"
+ )
- client.wait_for_unit("network.target")
+ client.wait_for_unit("network.target")
- def client_curl():
- assert "Jitsi Meet" in client.succeed("curl -sSfkL http://server/")
+ def client_curl():
+ assert "Jitsi Meet" in client.succeed("curl -sSfkL http://server/")
- client_curl()
+ client_curl()
- with subtest("Testing backup service"):
- server.succeed("${nodes.server.system.build.toplevel}/specialisation/caddy/bin/switch-to-configuration test")
- server.wait_for_unit("caddy.service")
- client_curl()
- '';
- }
-)
+ with subtest("Testing backup service"):
+ server.succeed("${nodes.server.system.build.toplevel}/specialisation/caddy/bin/switch-to-configuration test")
+ server.wait_for_unit("caddy.service")
+ client_curl()
+ '';
+}
diff --git a/nixos/tests/jotta-cli.nix b/nixos/tests/jotta-cli.nix
index 27f576f93a53..caf3ebeaad78 100644
--- a/nixos/tests/jotta-cli.nix
+++ b/nixos/tests/jotta-cli.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
+{ pkgs, ... }:
+{
- name = "jotta-cli";
- meta.maintainers = with pkgs.lib.maintainers; [ evenbrenden ];
+ name = "jotta-cli";
+ meta.maintainers = with pkgs.lib.maintainers; [ evenbrenden ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.jotta-cli.enable = true;
- imports = [ ./common/user-account.nix ];
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.jotta-cli.enable = true;
+ imports = [ ./common/user-account.nix ];
+ };
- testScript =
- { nodes, ... }:
- let
- uid = toString nodes.machine.users.users.alice.uid;
- in
- ''
- machine.start()
+ testScript =
+ { nodes, ... }:
+ let
+ uid = toString nodes.machine.users.users.alice.uid;
+ in
+ ''
+ machine.start()
- machine.succeed("loginctl enable-linger alice")
- machine.wait_for_unit("user@${uid}.service")
+ machine.succeed("loginctl enable-linger alice")
+ machine.wait_for_unit("user@${uid}.service")
- machine.wait_for_unit("jottad.service", "alice")
- machine.wait_for_open_unix_socket("/run/user/${uid}/jottad/jottad.socket")
+ machine.wait_for_unit("jottad.service", "alice")
+ machine.wait_for_open_unix_socket("/run/user/${uid}/jottad/jottad.socket")
- # "jotta-cli version" should fail if jotta-cli cannot connect to jottad
- machine.succeed('XDG_RUNTIME_DIR=/run/user/${uid} su alice -c "jotta-cli version"')
- '';
- }
-)
+ # "jotta-cli version" should fail if jotta-cli cannot connect to jottad
+ machine.succeed('XDG_RUNTIME_DIR=/run/user/${uid} su alice -c "jotta-cli version"')
+ '';
+}
diff --git a/nixos/tests/kanidm-provisioning.nix b/nixos/tests/kanidm-provisioning.nix
index 8f0ca0ec0859..c6e32f35ed08 100644
--- a/nixos/tests/kanidm-provisioning.nix
+++ b/nixos/tests/kanidm-provisioning.nix
@@ -1,522 +1,520 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- certs = import ./common/acme/server/snakeoil-certs.nix;
- serverDomain = certs.domain;
+{ pkgs, ... }:
+let
+ certs = import ./common/acme/server/snakeoil-certs.nix;
+ serverDomain = certs.domain;
- # copy certs to store to work around mount namespacing
- certsPath = pkgs.runCommandNoCC "snakeoil-certs" { } ''
- mkdir $out
- cp ${certs."${serverDomain}".cert} $out/snakeoil.crt
- cp ${certs."${serverDomain}".key} $out/snakeoil.key
- '';
+ # copy certs to store to work around mount namespacing
+ certsPath = pkgs.runCommandNoCC "snakeoil-certs" { } ''
+ mkdir $out
+ cp ${certs."${serverDomain}".cert} $out/snakeoil.crt
+ cp ${certs."${serverDomain}".key} $out/snakeoil.key
+ '';
- provisionAdminPassword = "very-strong-password-for-admin";
- provisionIdmAdminPassword = "very-strong-password-for-idm-admin";
- provisionIdmAdminPassword2 = "very-strong-alternative-password-for-idm-admin";
- in
- {
- name = "kanidm-provisioning";
- meta.maintainers = with pkgs.lib.maintainers; [ oddlama ];
+ provisionAdminPassword = "very-strong-password-for-admin";
+ provisionIdmAdminPassword = "very-strong-password-for-idm-admin";
+ provisionIdmAdminPassword2 = "very-strong-alternative-password-for-idm-admin";
+in
+{
+ name = "kanidm-provisioning";
+ meta.maintainers = with pkgs.lib.maintainers; [ oddlama ];
- nodes.provision =
- { pkgs, lib, ... }:
- {
- services.kanidm = {
- package = pkgs.kanidmWithSecretProvisioning_1_6;
- enableServer = true;
- serverSettings = {
- origin = "https://${serverDomain}";
- domain = serverDomain;
- bindaddress = "[::]:443";
- ldapbindaddress = "[::1]:636";
- tls_chain = "${certsPath}/snakeoil.crt";
- tls_key = "${certsPath}/snakeoil.key";
- };
- # So we can check whether provisioning did what we wanted
- enableClient = true;
- clientSettings = {
- uri = "https://${serverDomain}";
- verify_ca = true;
- verify_hostnames = true;
+ nodes.provision =
+ { pkgs, lib, ... }:
+ {
+ services.kanidm = {
+ package = pkgs.kanidmWithSecretProvisioning_1_6;
+ enableServer = true;
+ serverSettings = {
+ origin = "https://${serverDomain}";
+ domain = serverDomain;
+ bindaddress = "[::]:443";
+ ldapbindaddress = "[::1]:636";
+ tls_chain = "${certsPath}/snakeoil.crt";
+ tls_key = "${certsPath}/snakeoil.key";
+ };
+ # So we can check whether provisioning did what we wanted
+ enableClient = true;
+ clientSettings = {
+ uri = "https://${serverDomain}";
+ verify_ca = true;
+ verify_hostnames = true;
+ };
+ };
+
+ specialisation.credentialProvision.configuration =
+ { ... }:
+ {
+ services.kanidm.provision = lib.mkForce {
+ enable = true;
+ adminPasswordFile = pkgs.writeText "admin-pw" provisionAdminPassword;
+ idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
};
};
- specialisation.credentialProvision.configuration =
- { ... }:
- {
- services.kanidm.provision = lib.mkForce {
- enable = true;
- adminPasswordFile = pkgs.writeText "admin-pw" provisionAdminPassword;
- idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
- };
+ specialisation.changedCredential.configuration =
+ { ... }:
+ {
+ services.kanidm.provision = lib.mkForce {
+ enable = true;
+ idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword2;
};
+ };
- specialisation.changedCredential.configuration =
- { ... }:
- {
- services.kanidm.provision = lib.mkForce {
- enable = true;
- idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword2;
+ specialisation.addEntities.configuration =
+ { ... }:
+ {
+ services.kanidm.provision = lib.mkForce {
+ enable = true;
+ # Test whether credential recovery works without specific idmAdmin password
+ #idmAdminPasswordFile =
+
+ groups.supergroup1 = {
+ members = [ "testgroup1" ];
};
- };
- specialisation.addEntities.configuration =
- { ... }:
- {
- services.kanidm.provision = lib.mkForce {
- enable = true;
- # Test whether credential recovery works without specific idmAdmin password
- #idmAdminPasswordFile =
+ groups.testgroup1 = { };
- groups.supergroup1 = {
- members = [ "testgroup1" ];
- };
+ persons.testuser1 = {
+ displayName = "Test User";
+ legalName = "Jane Doe";
+ mailAddresses = [ "jane.doe@example.com" ];
+ groups = [
+ "testgroup1"
+ "service1-access"
+ ];
+ };
- groups.testgroup1 = { };
+ persons.testuser2 = {
+ displayName = "Powerful Test User";
+ legalName = "Ryouiki Tenkai";
+ groups = [ "service1-admin" ];
+ };
- persons.testuser1 = {
- displayName = "Test User";
- legalName = "Jane Doe";
- mailAddresses = [ "jane.doe@example.com" ];
- groups = [
- "testgroup1"
- "service1-access"
- ];
- };
-
- persons.testuser2 = {
- displayName = "Powerful Test User";
- legalName = "Ryouiki Tenkai";
- groups = [ "service1-admin" ];
- };
-
- groups.service1-access = { };
- groups.service1-admin = { };
- systems.oauth2.service1 = {
- displayName = "Service One";
- originUrl = "https://one.example.com/";
- originLanding = "https://one.example.com/landing";
- basicSecretFile = pkgs.writeText "bs-service1" "very-strong-secret-for-service1";
- scopeMaps.service1-access = [
- "openid"
- "email"
- "profile"
- ];
- supplementaryScopeMaps.service1-admin = [ "admin" ];
- claimMaps.groups = {
- valuesByGroup.service1-admin = [ "admin" ];
- };
- };
-
- systems.oauth2.service2 = {
- displayName = "Service Two";
- originUrl = "https://two.example.com/";
- originLanding = "https://landing2.example.com/";
- # Test not setting secret
- # basicSecretFile =
- allowInsecureClientDisablePkce = true;
- preferShortUsername = true;
+ groups.service1-access = { };
+ groups.service1-admin = { };
+ systems.oauth2.service1 = {
+ displayName = "Service One";
+ originUrl = "https://one.example.com/";
+ originLanding = "https://one.example.com/landing";
+ basicSecretFile = pkgs.writeText "bs-service1" "very-strong-secret-for-service1";
+ scopeMaps.service1-access = [
+ "openid"
+ "email"
+ "profile"
+ ];
+ supplementaryScopeMaps.service1-admin = [ "admin" ];
+ claimMaps.groups = {
+ valuesByGroup.service1-admin = [ "admin" ];
};
};
- };
- specialisation.changeAttributes.configuration =
- { ... }:
- {
- services.kanidm.provision = lib.mkForce {
- enable = true;
- # Changing admin credentials at any time should not be a problem:
- idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
-
- groups.supergroup1 = {
- #members = ["testgroup1"];
- };
-
- groups.testgroup1 = { };
-
- persons.testuser1 = {
- displayName = "Test User (changed)";
- legalName = "Jane Doe (changed)";
- mailAddresses = [
- "jane.doe@example.com"
- "second.doe@example.com"
- ];
- groups = [
- #"testgroup1"
- "service1-access"
- ];
- };
-
- persons.testuser2 = {
- displayName = "Powerful Test User (changed)";
- legalName = "Ryouiki Tenkai (changed)";
- groups = [ "service1-admin" ];
- };
-
- groups.service1-access = { };
- groups.service1-admin = { };
- systems.oauth2.service1 = {
- displayName = "Service One (changed)";
- # multiple origin urls
- originUrl = [
- "https://changed-one.example.com/"
- "https://changed-one.example.org/"
- ];
- originLanding = "https://changed-one.example.com/landing-changed";
- basicSecretFile = pkgs.writeText "bs-service1" "changed-very-strong-secret-for-service1";
- scopeMaps.service1-access = [
- "openid"
- "email"
- #"profile"
- ];
- supplementaryScopeMaps.service1-admin = [ "adminchanged" ];
- claimMaps.groups = {
- valuesByGroup.service1-admin = [ "adminchanged" ];
- };
- };
-
- systems.oauth2.service2 = {
- displayName = "Service Two (changed)";
- originUrl = "https://changed-two.example.com/";
- originLanding = "https://changed-landing2.example.com/";
- # Test not setting secret
- # basicSecretFile =
- allowInsecureClientDisablePkce = false;
- preferShortUsername = false;
- };
+ systems.oauth2.service2 = {
+ displayName = "Service Two";
+ originUrl = "https://two.example.com/";
+ originLanding = "https://landing2.example.com/";
+ # Test not setting secret
+ # basicSecretFile =
+ allowInsecureClientDisablePkce = true;
+ preferShortUsername = true;
};
};
+ };
- specialisation.removeAttributes.configuration =
- { ... }:
- {
- services.kanidm.provision = lib.mkForce {
- enable = true;
- idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
+ specialisation.changeAttributes.configuration =
+ { ... }:
+ {
+ services.kanidm.provision = lib.mkForce {
+ enable = true;
+ # Changing admin credentials at any time should not be a problem:
+ idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
- groups.supergroup1 = { };
+ groups.supergroup1 = {
+ #members = ["testgroup1"];
+ };
- persons.testuser1 = {
- displayName = "Test User (changed)";
- };
+ groups.testgroup1 = { };
- persons.testuser2 = {
- displayName = "Powerful Test User (changed)";
- groups = [ "service1-admin" ];
- };
+ persons.testuser1 = {
+ displayName = "Test User (changed)";
+ legalName = "Jane Doe (changed)";
+ mailAddresses = [
+ "jane.doe@example.com"
+ "second.doe@example.com"
+ ];
+ groups = [
+ #"testgroup1"
+ "service1-access"
+ ];
+ };
- groups.service1-access = { };
- groups.service1-admin = { };
- systems.oauth2.service1 = {
- displayName = "Service One (changed)";
- originUrl = "https://changed-one.example.com/";
- originLanding = "https://changed-one.example.com/landing-changed";
- basicSecretFile = pkgs.writeText "bs-service1" "changed-very-strong-secret-for-service1";
- # Removing maps requires setting them to the empty list
- scopeMaps.service1-access = [ ];
- supplementaryScopeMaps.service1-admin = [ ];
- };
+ persons.testuser2 = {
+ displayName = "Powerful Test User (changed)";
+ legalName = "Ryouiki Tenkai (changed)";
+ groups = [ "service1-admin" ];
+ };
- systems.oauth2.service2 = {
- displayName = "Service Two (changed)";
- originUrl = "https://changed-two.example.com/";
- originLanding = "https://changed-landing2.example.com/";
+ groups.service1-access = { };
+ groups.service1-admin = { };
+ systems.oauth2.service1 = {
+ displayName = "Service One (changed)";
+ # multiple origin urls
+ originUrl = [
+ "https://changed-one.example.com/"
+ "https://changed-one.example.org/"
+ ];
+ originLanding = "https://changed-one.example.com/landing-changed";
+ basicSecretFile = pkgs.writeText "bs-service1" "changed-very-strong-secret-for-service1";
+ scopeMaps.service1-access = [
+ "openid"
+ "email"
+ #"profile"
+ ];
+ supplementaryScopeMaps.service1-admin = [ "adminchanged" ];
+ claimMaps.groups = {
+ valuesByGroup.service1-admin = [ "adminchanged" ];
};
};
- };
- specialisation.removeEntities.configuration =
- { ... }:
- {
- services.kanidm.provision = lib.mkForce {
- enable = true;
- idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
+ systems.oauth2.service2 = {
+ displayName = "Service Two (changed)";
+ originUrl = "https://changed-two.example.com/";
+ originLanding = "https://changed-landing2.example.com/";
+ # Test not setting secret
+ # basicSecretFile =
+ allowInsecureClientDisablePkce = false;
+ preferShortUsername = false;
};
};
+ };
- security.pki.certificateFiles = [ certs.ca.cert ];
+ specialisation.removeAttributes.configuration =
+ { ... }:
+ {
+ services.kanidm.provision = lib.mkForce {
+ enable = true;
+ idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
- networking.hosts."::1" = [ serverDomain ];
- networking.firewall.allowedTCPPorts = [ 443 ];
+ groups.supergroup1 = { };
- users.users.kanidm.shell = pkgs.bashInteractive;
+ persons.testuser1 = {
+ displayName = "Test User (changed)";
+ };
- environment.systemPackages = with pkgs; [
- kanidm
- openldap
- ripgrep
- jq
- ];
- };
+ persons.testuser2 = {
+ displayName = "Powerful Test User (changed)";
+ groups = [ "service1-admin" ];
+ };
- testScript =
- { nodes, ... }:
- let
- # We need access to the config file in the test script.
- filteredConfig = pkgs.lib.converge (pkgs.lib.filterAttrsRecursive (
- _: v: v != null
- )) nodes.provision.services.kanidm.serverSettings;
- serverConfigFile = (pkgs.formats.toml { }).generate "server.toml" filteredConfig;
+ groups.service1-access = { };
+ groups.service1-admin = { };
+ systems.oauth2.service1 = {
+ displayName = "Service One (changed)";
+ originUrl = "https://changed-one.example.com/";
+ originLanding = "https://changed-one.example.com/landing-changed";
+ basicSecretFile = pkgs.writeText "bs-service1" "changed-very-strong-secret-for-service1";
+ # Removing maps requires setting them to the empty list
+ scopeMaps.service1-access = [ ];
+ supplementaryScopeMaps.service1-admin = [ ];
+ };
- specialisations = "${nodes.provision.system.build.toplevel}/specialisation";
- in
- ''
- import re
+ systems.oauth2.service2 = {
+ displayName = "Service Two (changed)";
+ originUrl = "https://changed-two.example.com/";
+ originLanding = "https://changed-landing2.example.com/";
+ };
+ };
+ };
- def assert_contains(haystack, needle):
- if needle not in haystack:
- print("The haystack that will cause the following exception is:")
- print("---")
- print(haystack)
- print("---")
- raise Exception(f"Expected string '{needle}' was not found")
+ specialisation.removeEntities.configuration =
+ { ... }:
+ {
+ services.kanidm.provision = lib.mkForce {
+ enable = true;
+ idmAdminPasswordFile = pkgs.writeText "idm-admin-pw" provisionIdmAdminPassword;
+ };
+ };
- def assert_matches(haystack, expr):
- if not re.search(expr, haystack):
- print("The haystack that will cause the following exception is:")
- print("---")
- print(haystack)
- print("---")
- raise Exception(f"Expected regex '{expr}' did not match")
+ security.pki.certificateFiles = [ certs.ca.cert ];
- def assert_lacks(haystack, needle):
- if needle in haystack:
- print("The haystack that will cause the following exception is:")
- print("---")
- print(haystack, end="")
- print("---")
- raise Exception(f"Unexpected string '{needle}' was found")
+ networking.hosts."::1" = [ serverDomain ];
+ networking.firewall.allowedTCPPorts = [ 443 ];
- provision.start()
+ users.users.kanidm.shell = pkgs.bashInteractive;
- def provision_login(pw):
- provision.wait_for_unit("kanidm.service")
- provision.wait_until_succeeds("curl -Lsf https://${serverDomain} | grep Kanidm")
- if pw is None:
- pw = provision.succeed("su - kanidm -c 'kanidmd recover-account -c ${serverConfigFile} idm_admin 2>&1 | rg -o \'[A-Za-z0-9]{48}\' '").strip().removeprefix("'").removesuffix("'")
- out = provision.succeed(f"KANIDM_PASSWORD={pw} kanidm login -D idm_admin")
- assert_contains(out, "Login Success for idm_admin")
+ environment.systemPackages = with pkgs; [
+ kanidm
+ openldap
+ ripgrep
+ jq
+ ];
+ };
- with subtest("Test Provisioning - setup"):
- provision_login(None)
- provision.succeed("kanidm logout -D idm_admin")
+ testScript =
+ { nodes, ... }:
+ let
+ # We need access to the config file in the test script.
+ filteredConfig = pkgs.lib.converge (pkgs.lib.filterAttrsRecursive (
+ _: v: v != null
+ )) nodes.provision.services.kanidm.serverSettings;
+ serverConfigFile = (pkgs.formats.toml { }).generate "server.toml" filteredConfig;
- with subtest("Test Provisioning - credentialProvision"):
- provision.succeed('${specialisations}/credentialProvision/bin/switch-to-configuration test')
- provision_login("${provisionIdmAdminPassword}")
+ specialisations = "${nodes.provision.system.build.toplevel}/specialisation";
+ in
+ ''
+ import re
- # Make sure neither password is logged
- provision.fail("journalctl --since -10m --unit kanidm.service --grep '${provisionAdminPassword}'")
- provision.fail("journalctl --since -10m --unit kanidm.service --grep '${provisionIdmAdminPassword}'")
+ def assert_contains(haystack, needle):
+ if needle not in haystack:
+ print("The haystack that will cause the following exception is:")
+ print("---")
+ print(haystack)
+ print("---")
+ raise Exception(f"Expected string '{needle}' was not found")
- # Test provisioned admin pw
- out = provision.succeed("KANIDM_PASSWORD=${provisionAdminPassword} kanidm login -D admin")
- assert_contains(out, "Login Success for admin")
- provision.succeed("kanidm logout -D admin")
- provision.succeed("kanidm logout -D idm_admin")
+ def assert_matches(haystack, expr):
+ if not re.search(expr, haystack):
+ print("The haystack that will cause the following exception is:")
+ print("---")
+ print(haystack)
+ print("---")
+ raise Exception(f"Expected regex '{expr}' did not match")
- with subtest("Test Provisioning - changedCredential"):
- provision.succeed('${specialisations}/changedCredential/bin/switch-to-configuration test')
- provision_login("${provisionIdmAdminPassword2}")
- provision.succeed("kanidm logout -D idm_admin")
+ def assert_lacks(haystack, needle):
+ if needle in haystack:
+ print("The haystack that will cause the following exception is:")
+ print("---")
+ print(haystack, end="")
+ print("---")
+ raise Exception(f"Unexpected string '{needle}' was found")
- with subtest("Test Provisioning - addEntities"):
- provision.succeed('${specialisations}/addEntities/bin/switch-to-configuration test')
- # Unspecified idm admin password
- provision_login(None)
+ provision.start()
- out = provision.succeed("kanidm group get testgroup1")
- assert_contains(out, "name: testgroup1")
+ def provision_login(pw):
+ provision.wait_for_unit("kanidm.service")
+ provision.wait_until_succeeds("curl -Lsf https://${serverDomain} | grep Kanidm")
+ if pw is None:
+ pw = provision.succeed("su - kanidm -c 'kanidmd recover-account -c ${serverConfigFile} idm_admin 2>&1 | rg -o \'[A-Za-z0-9]{48}\' '").strip().removeprefix("'").removesuffix("'")
+ out = provision.succeed(f"KANIDM_PASSWORD={pw} kanidm login -D idm_admin")
+ assert_contains(out, "Login Success for idm_admin")
- out = provision.succeed("kanidm group get supergroup1")
- assert_contains(out, "name: supergroup1")
- assert_contains(out, "member: testgroup1")
+ with subtest("Test Provisioning - setup"):
+ provision_login(None)
+ provision.succeed("kanidm logout -D idm_admin")
- out = provision.succeed("kanidm person get testuser1")
- assert_contains(out, "name: testuser1")
- assert_contains(out, "displayname: Test User")
- assert_contains(out, "legalname: Jane Doe")
- assert_contains(out, "mail: jane.doe@example.com")
- assert_contains(out, "memberof: testgroup1")
- assert_contains(out, "memberof: service1-access")
+ with subtest("Test Provisioning - credentialProvision"):
+ provision.succeed('${specialisations}/credentialProvision/bin/switch-to-configuration test')
+ provision_login("${provisionIdmAdminPassword}")
- out = provision.succeed("kanidm person get testuser2")
- assert_contains(out, "name: testuser2")
- assert_contains(out, "displayname: Powerful Test User")
- assert_contains(out, "legalname: Ryouiki Tenkai")
- assert_contains(out, "memberof: service1-admin")
- assert_lacks(out, "mail:")
+ # Make sure neither password is logged
+ provision.fail("journalctl --since -10m --unit kanidm.service --grep '${provisionAdminPassword}'")
+ provision.fail("journalctl --since -10m --unit kanidm.service --grep '${provisionIdmAdminPassword}'")
- out = provision.succeed("kanidm group get service1-access")
- assert_contains(out, "name: service1-access")
+ # Test provisioned admin pw
+ out = provision.succeed("KANIDM_PASSWORD=${provisionAdminPassword} kanidm login -D admin")
+ assert_contains(out, "Login Success for admin")
+ provision.succeed("kanidm logout -D admin")
+ provision.succeed("kanidm logout -D idm_admin")
- out = provision.succeed("kanidm group get service1-admin")
- assert_contains(out, "name: service1-admin")
+ with subtest("Test Provisioning - changedCredential"):
+ provision.succeed('${specialisations}/changedCredential/bin/switch-to-configuration test')
+ provision_login("${provisionIdmAdminPassword2}")
+ provision.succeed("kanidm logout -D idm_admin")
- out = provision.succeed("kanidm system oauth2 get service1")
- assert_contains(out, "name: service1")
- assert_contains(out, "displayname: Service One")
- assert_contains(out, "oauth2_rs_origin: https://one.example.com/")
- assert_contains(out, "oauth2_rs_origin_landing: https://one.example.com/landing")
- assert_matches(out, 'oauth2_rs_scope_map: service1-access.*{"email", "openid", "profile"}')
- assert_matches(out, 'oauth2_rs_sup_scope_map: service1-admin.*{"admin"}')
- assert_matches(out, 'oauth2_rs_claim_map: groups:.*"admin"')
+ with subtest("Test Provisioning - addEntities"):
+ provision.succeed('${specialisations}/addEntities/bin/switch-to-configuration test')
+ # Unspecified idm admin password
+ provision_login(None)
- out = provision.succeed("kanidm system oauth2 show-basic-secret service1")
- assert_contains(out, "very-strong-secret-for-service1")
+ out = provision.succeed("kanidm group get testgroup1")
+ assert_contains(out, "name: testgroup1")
- out = provision.succeed("kanidm system oauth2 get service2")
- assert_contains(out, "name: service2")
- assert_contains(out, "displayname: Service Two")
- assert_contains(out, "oauth2_rs_origin: https://two.example.com/")
- assert_contains(out, "oauth2_rs_origin_landing: https://landing2.example.com/")
- assert_contains(out, "oauth2_allow_insecure_client_disable_pkce: true")
- assert_contains(out, "oauth2_prefer_short_username: true")
+ out = provision.succeed("kanidm group get supergroup1")
+ assert_contains(out, "name: supergroup1")
+ assert_contains(out, "member: testgroup1")
- provision.succeed("kanidm logout -D idm_admin")
+ out = provision.succeed("kanidm person get testuser1")
+ assert_contains(out, "name: testuser1")
+ assert_contains(out, "displayname: Test User")
+ assert_contains(out, "legalname: Jane Doe")
+ assert_contains(out, "mail: jane.doe@example.com")
+ assert_contains(out, "memberof: testgroup1")
+ assert_contains(out, "memberof: service1-access")
- with subtest("Test Provisioning - changeAttributes"):
- provision.succeed('${specialisations}/changeAttributes/bin/switch-to-configuration test')
- provision_login("${provisionIdmAdminPassword}")
+ out = provision.succeed("kanidm person get testuser2")
+ assert_contains(out, "name: testuser2")
+ assert_contains(out, "displayname: Powerful Test User")
+ assert_contains(out, "legalname: Ryouiki Tenkai")
+ assert_contains(out, "memberof: service1-admin")
+ assert_lacks(out, "mail:")
- out = provision.succeed("kanidm group get testgroup1")
- assert_contains(out, "name: testgroup1")
+ out = provision.succeed("kanidm group get service1-access")
+ assert_contains(out, "name: service1-access")
- out = provision.succeed("kanidm group get supergroup1")
- assert_contains(out, "name: supergroup1")
- assert_lacks(out, "member: testgroup1")
+ out = provision.succeed("kanidm group get service1-admin")
+ assert_contains(out, "name: service1-admin")
- out = provision.succeed("kanidm person get testuser1")
- assert_contains(out, "name: testuser1")
- assert_contains(out, "displayname: Test User (changed)")
- assert_contains(out, "legalname: Jane Doe (changed)")
- assert_contains(out, "mail: jane.doe@example.com")
- assert_contains(out, "mail: second.doe@example.com")
- assert_lacks(out, "memberof: testgroup1")
- assert_contains(out, "memberof: service1-access")
+ out = provision.succeed("kanidm system oauth2 get service1")
+ assert_contains(out, "name: service1")
+ assert_contains(out, "displayname: Service One")
+ assert_contains(out, "oauth2_rs_origin: https://one.example.com/")
+ assert_contains(out, "oauth2_rs_origin_landing: https://one.example.com/landing")
+ assert_matches(out, 'oauth2_rs_scope_map: service1-access.*{"email", "openid", "profile"}')
+ assert_matches(out, 'oauth2_rs_sup_scope_map: service1-admin.*{"admin"}')
+ assert_matches(out, 'oauth2_rs_claim_map: groups:.*"admin"')
- out = provision.succeed("kanidm person get testuser2")
- assert_contains(out, "name: testuser2")
- assert_contains(out, "displayname: Powerful Test User (changed)")
- assert_contains(out, "legalname: Ryouiki Tenkai (changed)")
- assert_contains(out, "memberof: service1-admin")
- assert_lacks(out, "mail:")
+ out = provision.succeed("kanidm system oauth2 show-basic-secret service1")
+ assert_contains(out, "very-strong-secret-for-service1")
- out = provision.succeed("kanidm group get service1-access")
- assert_contains(out, "name: service1-access")
+ out = provision.succeed("kanidm system oauth2 get service2")
+ assert_contains(out, "name: service2")
+ assert_contains(out, "displayname: Service Two")
+ assert_contains(out, "oauth2_rs_origin: https://two.example.com/")
+ assert_contains(out, "oauth2_rs_origin_landing: https://landing2.example.com/")
+ assert_contains(out, "oauth2_allow_insecure_client_disable_pkce: true")
+ assert_contains(out, "oauth2_prefer_short_username: true")
- out = provision.succeed("kanidm group get service1-admin")
- assert_contains(out, "name: service1-admin")
+ provision.succeed("kanidm logout -D idm_admin")
- out = provision.succeed("kanidm system oauth2 get service1")
- assert_contains(out, "name: service1")
- assert_contains(out, "displayname: Service One (changed)")
- assert_contains(out, "oauth2_rs_origin: https://changed-one.example.com/")
- assert_contains(out, "oauth2_rs_origin: https://changed-one.example.org/")
- assert_contains(out, "oauth2_rs_origin_landing: https://changed-one.example.com/landing")
- assert_matches(out, 'oauth2_rs_scope_map: service1-access.*{"email", "openid"}')
- assert_matches(out, 'oauth2_rs_sup_scope_map: service1-admin.*{"adminchanged"}')
- assert_matches(out, 'oauth2_rs_claim_map: groups:.*"adminchanged"')
+ with subtest("Test Provisioning - changeAttributes"):
+ provision.succeed('${specialisations}/changeAttributes/bin/switch-to-configuration test')
+ provision_login("${provisionIdmAdminPassword}")
- out = provision.succeed("kanidm system oauth2 show-basic-secret service1")
- assert_contains(out, "changed-very-strong-secret-for-service1")
+ out = provision.succeed("kanidm group get testgroup1")
+ assert_contains(out, "name: testgroup1")
- out = provision.succeed("kanidm system oauth2 get service2")
- assert_contains(out, "name: service2")
- assert_contains(out, "displayname: Service Two (changed)")
- assert_contains(out, "oauth2_rs_origin: https://changed-two.example.com/")
- assert_contains(out, "oauth2_rs_origin_landing: https://changed-landing2.example.com/")
- assert_lacks(out, "oauth2_allow_insecure_client_disable_pkce: true")
- assert_lacks(out, "oauth2_prefer_short_username: true")
+ out = provision.succeed("kanidm group get supergroup1")
+ assert_contains(out, "name: supergroup1")
+ assert_lacks(out, "member: testgroup1")
- provision.succeed("kanidm logout -D idm_admin")
+ out = provision.succeed("kanidm person get testuser1")
+ assert_contains(out, "name: testuser1")
+ assert_contains(out, "displayname: Test User (changed)")
+ assert_contains(out, "legalname: Jane Doe (changed)")
+ assert_contains(out, "mail: jane.doe@example.com")
+ assert_contains(out, "mail: second.doe@example.com")
+ assert_lacks(out, "memberof: testgroup1")
+ assert_contains(out, "memberof: service1-access")
- with subtest("Test Provisioning - removeAttributes"):
- provision.succeed('${specialisations}/removeAttributes/bin/switch-to-configuration test')
- provision_login("${provisionIdmAdminPassword}")
+ out = provision.succeed("kanidm person get testuser2")
+ assert_contains(out, "name: testuser2")
+ assert_contains(out, "displayname: Powerful Test User (changed)")
+ assert_contains(out, "legalname: Ryouiki Tenkai (changed)")
+ assert_contains(out, "memberof: service1-admin")
+ assert_lacks(out, "mail:")
- out = provision.succeed("kanidm group get testgroup1")
- assert_lacks(out, "name: testgroup1")
+ out = provision.succeed("kanidm group get service1-access")
+ assert_contains(out, "name: service1-access")
- out = provision.succeed("kanidm group get supergroup1")
- assert_contains(out, "name: supergroup1")
- assert_lacks(out, "member: testgroup1")
+ out = provision.succeed("kanidm group get service1-admin")
+ assert_contains(out, "name: service1-admin")
- out = provision.succeed("kanidm person get testuser1")
- assert_contains(out, "name: testuser1")
- assert_contains(out, "displayname: Test User (changed)")
- assert_lacks(out, "legalname: Jane Doe (changed)")
- assert_lacks(out, "mail: jane.doe@example.com")
- assert_lacks(out, "mail: second.doe@example.com")
- assert_lacks(out, "memberof: testgroup1")
- assert_lacks(out, "memberof: service1-access")
+ out = provision.succeed("kanidm system oauth2 get service1")
+ assert_contains(out, "name: service1")
+ assert_contains(out, "displayname: Service One (changed)")
+ assert_contains(out, "oauth2_rs_origin: https://changed-one.example.com/")
+ assert_contains(out, "oauth2_rs_origin: https://changed-one.example.org/")
+ assert_contains(out, "oauth2_rs_origin_landing: https://changed-one.example.com/landing")
+ assert_matches(out, 'oauth2_rs_scope_map: service1-access.*{"email", "openid"}')
+ assert_matches(out, 'oauth2_rs_sup_scope_map: service1-admin.*{"adminchanged"}')
+ assert_matches(out, 'oauth2_rs_claim_map: groups:.*"adminchanged"')
- out = provision.succeed("kanidm person get testuser2")
- assert_contains(out, "name: testuser2")
- assert_contains(out, "displayname: Powerful Test User (changed)")
- assert_lacks(out, "legalname: Ryouiki Tenkai (changed)")
- assert_contains(out, "memberof: service1-admin")
- assert_lacks(out, "mail:")
+ out = provision.succeed("kanidm system oauth2 show-basic-secret service1")
+ assert_contains(out, "changed-very-strong-secret-for-service1")
- out = provision.succeed("kanidm group get service1-access")
- assert_contains(out, "name: service1-access")
+ out = provision.succeed("kanidm system oauth2 get service2")
+ assert_contains(out, "name: service2")
+ assert_contains(out, "displayname: Service Two (changed)")
+ assert_contains(out, "oauth2_rs_origin: https://changed-two.example.com/")
+ assert_contains(out, "oauth2_rs_origin_landing: https://changed-landing2.example.com/")
+ assert_lacks(out, "oauth2_allow_insecure_client_disable_pkce: true")
+ assert_lacks(out, "oauth2_prefer_short_username: true")
- out = provision.succeed("kanidm group get service1-admin")
- assert_contains(out, "name: service1-admin")
+ provision.succeed("kanidm logout -D idm_admin")
- out = provision.succeed("kanidm system oauth2 get service1")
- assert_contains(out, "name: service1")
- assert_contains(out, "displayname: Service One (changed)")
- assert_contains(out, "oauth2_rs_origin: https://changed-one.example.com/")
- assert_lacks(out, "oauth2_rs_origin: https://changed-one.example.org/")
- assert_contains(out, "oauth2_rs_origin_landing: https://changed-one.example.com/landing")
- assert_lacks(out, "oauth2_rs_scope_map")
- assert_lacks(out, "oauth2_rs_sup_scope_map")
- assert_lacks(out, "oauth2_rs_claim_map")
+ with subtest("Test Provisioning - removeAttributes"):
+ provision.succeed('${specialisations}/removeAttributes/bin/switch-to-configuration test')
+ provision_login("${provisionIdmAdminPassword}")
- out = provision.succeed("kanidm system oauth2 show-basic-secret service1")
- assert_contains(out, "changed-very-strong-secret-for-service1")
+ out = provision.succeed("kanidm group get testgroup1")
+ assert_lacks(out, "name: testgroup1")
- out = provision.succeed("kanidm system oauth2 get service2")
- assert_contains(out, "name: service2")
- assert_contains(out, "displayname: Service Two (changed)")
- assert_contains(out, "oauth2_rs_origin: https://changed-two.example.com/")
- assert_contains(out, "oauth2_rs_origin_landing: https://changed-landing2.example.com/")
- assert_lacks(out, "oauth2_allow_insecure_client_disable_pkce: true")
- assert_lacks(out, "oauth2_prefer_short_username: true")
+ out = provision.succeed("kanidm group get supergroup1")
+ assert_contains(out, "name: supergroup1")
+ assert_lacks(out, "member: testgroup1")
- provision.succeed("kanidm logout -D idm_admin")
+ out = provision.succeed("kanidm person get testuser1")
+ assert_contains(out, "name: testuser1")
+ assert_contains(out, "displayname: Test User (changed)")
+ assert_lacks(out, "legalname: Jane Doe (changed)")
+ assert_lacks(out, "mail: jane.doe@example.com")
+ assert_lacks(out, "mail: second.doe@example.com")
+ assert_lacks(out, "memberof: testgroup1")
+ assert_lacks(out, "memberof: service1-access")
- with subtest("Test Provisioning - removeEntities"):
- provision.succeed('${specialisations}/removeEntities/bin/switch-to-configuration test')
- provision_login("${provisionIdmAdminPassword}")
+ out = provision.succeed("kanidm person get testuser2")
+ assert_contains(out, "name: testuser2")
+ assert_contains(out, "displayname: Powerful Test User (changed)")
+ assert_lacks(out, "legalname: Ryouiki Tenkai (changed)")
+ assert_contains(out, "memberof: service1-admin")
+ assert_lacks(out, "mail:")
- out = provision.succeed("kanidm group get testgroup1")
- assert_lacks(out, "name: testgroup1")
+ out = provision.succeed("kanidm group get service1-access")
+ assert_contains(out, "name: service1-access")
- out = provision.succeed("kanidm group get supergroup1")
- assert_lacks(out, "name: supergroup1")
+ out = provision.succeed("kanidm group get service1-admin")
+ assert_contains(out, "name: service1-admin")
- out = provision.succeed("kanidm person get testuser1")
- assert_lacks(out, "name: testuser1")
+ out = provision.succeed("kanidm system oauth2 get service1")
+ assert_contains(out, "name: service1")
+ assert_contains(out, "displayname: Service One (changed)")
+ assert_contains(out, "oauth2_rs_origin: https://changed-one.example.com/")
+ assert_lacks(out, "oauth2_rs_origin: https://changed-one.example.org/")
+ assert_contains(out, "oauth2_rs_origin_landing: https://changed-one.example.com/landing")
+ assert_lacks(out, "oauth2_rs_scope_map")
+ assert_lacks(out, "oauth2_rs_sup_scope_map")
+ assert_lacks(out, "oauth2_rs_claim_map")
- out = provision.succeed("kanidm person get testuser2")
- assert_lacks(out, "name: testuser2")
+ out = provision.succeed("kanidm system oauth2 show-basic-secret service1")
+ assert_contains(out, "changed-very-strong-secret-for-service1")
- out = provision.succeed("kanidm group get service1-access")
- assert_lacks(out, "name: service1-access")
+ out = provision.succeed("kanidm system oauth2 get service2")
+ assert_contains(out, "name: service2")
+ assert_contains(out, "displayname: Service Two (changed)")
+ assert_contains(out, "oauth2_rs_origin: https://changed-two.example.com/")
+ assert_contains(out, "oauth2_rs_origin_landing: https://changed-landing2.example.com/")
+ assert_lacks(out, "oauth2_allow_insecure_client_disable_pkce: true")
+ assert_lacks(out, "oauth2_prefer_short_username: true")
- out = provision.succeed("kanidm group get service1-admin")
- assert_lacks(out, "name: service1-admin")
+ provision.succeed("kanidm logout -D idm_admin")
- out = provision.succeed("kanidm system oauth2 get service1")
- assert_lacks(out, "name: service1")
+ with subtest("Test Provisioning - removeEntities"):
+ provision.succeed('${specialisations}/removeEntities/bin/switch-to-configuration test')
+ provision_login("${provisionIdmAdminPassword}")
- out = provision.succeed("kanidm system oauth2 get service2")
- assert_lacks(out, "name: service2")
+ out = provision.succeed("kanidm group get testgroup1")
+ assert_lacks(out, "name: testgroup1")
- provision.succeed("kanidm logout -D idm_admin")
- '';
- }
-)
+ out = provision.succeed("kanidm group get supergroup1")
+ assert_lacks(out, "name: supergroup1")
+
+ out = provision.succeed("kanidm person get testuser1")
+ assert_lacks(out, "name: testuser1")
+
+ out = provision.succeed("kanidm person get testuser2")
+ assert_lacks(out, "name: testuser2")
+
+ out = provision.succeed("kanidm group get service1-access")
+ assert_lacks(out, "name: service1-access")
+
+ out = provision.succeed("kanidm group get service1-admin")
+ assert_lacks(out, "name: service1-admin")
+
+ out = provision.succeed("kanidm system oauth2 get service1")
+ assert_lacks(out, "name: service1")
+
+ out = provision.succeed("kanidm system oauth2 get service2")
+ assert_lacks(out, "name: service2")
+
+ provision.succeed("kanidm logout -D idm_admin")
+ '';
+}
diff --git a/nixos/tests/kanidm.nix b/nixos/tests/kanidm.nix
index 69dac0de6865..f2f4981da276 100644
--- a/nixos/tests/kanidm.nix
+++ b/nixos/tests/kanidm.nix
@@ -1,154 +1,152 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- certs = import ./common/acme/server/snakeoil-certs.nix;
- serverDomain = certs.domain;
+{ pkgs, ... }:
+let
+ certs = import ./common/acme/server/snakeoil-certs.nix;
+ serverDomain = certs.domain;
- testCredentials = {
- password = "Password1_cZPEwpCWvrReripJmAZdmVIZd8HHoHcl";
+ testCredentials = {
+ password = "Password1_cZPEwpCWvrReripJmAZdmVIZd8HHoHcl";
+ };
+
+ # copy certs to store to work around mount namespacing
+ certsPath = pkgs.runCommandNoCC "snakeoil-certs" { } ''
+ mkdir $out
+ cp ${certs."${serverDomain}".cert} $out/snakeoil.crt
+ cp ${certs."${serverDomain}".key} $out/snakeoil.key
+ '';
+in
+{
+ name = "kanidm";
+ meta.maintainers = with pkgs.lib.maintainers; [
+ Flakebi
+ oddlama
+ ];
+
+ nodes.server =
+ { pkgs, ... }:
+ {
+ services.kanidm = {
+ package = pkgs.kanidm_1_6;
+ enableServer = true;
+ serverSettings = {
+ origin = "https://${serverDomain}";
+ domain = serverDomain;
+ bindaddress = "[::]:443";
+ ldapbindaddress = "[::1]:636";
+ tls_chain = "${certsPath}/snakeoil.crt";
+ tls_key = "${certsPath}/snakeoil.key";
+ };
+ };
+
+ security.pki.certificateFiles = [ certs.ca.cert ];
+
+ networking.hosts."::1" = [ serverDomain ];
+ networking.firewall.allowedTCPPorts = [ 443 ];
+
+ users.users.kanidm.shell = pkgs.bashInteractive;
+
+ environment.systemPackages = with pkgs; [
+ kanidm
+ openldap
+ ripgrep
+ ];
};
- # copy certs to store to work around mount namespacing
- certsPath = pkgs.runCommandNoCC "snakeoil-certs" { } ''
- mkdir $out
- cp ${certs."${serverDomain}".cert} $out/snakeoil.crt
- cp ${certs."${serverDomain}".key} $out/snakeoil.key
+ nodes.client =
+ { nodes, ... }:
+ {
+ services.kanidm = {
+ package = pkgs.kanidm_1_6;
+ enableClient = true;
+ clientSettings = {
+ uri = "https://${serverDomain}";
+ verify_ca = true;
+ verify_hostnames = true;
+ };
+ enablePam = true;
+ unixSettings = {
+ pam_allowed_login_groups = [ "shell" ];
+ };
+ };
+
+ networking.hosts."${nodes.server.networking.primaryIPAddress}" = [ serverDomain ];
+
+ security.pki.certificateFiles = [ certs.ca.cert ];
+ };
+
+ testScript =
+ { nodes, ... }:
+ let
+ ldapBaseDN = builtins.concatStringsSep "," (
+ map (s: "dc=" + s) (pkgs.lib.splitString "." serverDomain)
+ );
+
+ # We need access to the config file in the test script.
+ filteredConfig = pkgs.lib.converge (pkgs.lib.filterAttrsRecursive (
+ _: v: v != null
+ )) nodes.server.services.kanidm.serverSettings;
+ serverConfigFile = (pkgs.formats.toml { }).generate "server.toml" filteredConfig;
+ in
+ ''
+ server.start()
+ client.start()
+ server.wait_for_unit("kanidm.service")
+ client.systemctl("start network-online.target")
+ client.wait_for_unit("network-online.target")
+
+ with subtest("Test HTTP interface"):
+ server.wait_until_succeeds("curl -Lsf https://${serverDomain} | grep Kanidm")
+
+ with subtest("Test LDAP interface"):
+ server.succeed("ldapsearch -H ldaps://${serverDomain}:636 -b '${ldapBaseDN}' -x '(name=test)'")
+
+ with subtest("Recover idm_admin account"):
+ idm_admin_password = server.succeed("su - kanidm -c 'kanidmd recover-account -c ${serverConfigFile} idm_admin 2>&1 | rg -o \'[A-Za-z0-9]{48}\' '").strip().removeprefix("'").removesuffix("'")
+
+ with subtest("Test CLI login"):
+ client.wait_until_tty_matches("1", "login: ")
+ client.send_chars("root\n")
+ client.send_chars("kanidm login -D idm_admin\n")
+ client.wait_until_tty_matches("1", "Enter password: ")
+ client.send_chars(f"{idm_admin_password}\n")
+ client.wait_until_tty_matches("1", "Login Success for idm_admin")
+
+ with subtest("Test unixd connection"):
+ client.wait_for_unit("kanidm-unixd.service")
+ client.wait_for_file("/run/kanidm-unixd/sock")
+ client.wait_until_succeeds("kanidm-unix status | grep online")
+
+ with subtest("Test user creation"):
+ client.wait_for_unit("getty@tty1.service")
+ client.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+ client.succeed("kanidm person create testuser TestUser")
+ client.succeed("kanidm person posix set --shell \"$SHELL\" testuser")
+ client.send_chars("kanidm person posix set-password testuser\n")
+ client.wait_until_tty_matches("1", "Enter new")
+ client.send_chars("${testCredentials.password}\n")
+ client.wait_until_tty_matches("1", "Reenter")
+ client.send_chars("${testCredentials.password}\n")
+ output = client.succeed("getent passwd testuser")
+ assert "TestUser" in output
+ client.succeed("kanidm group create shell")
+ client.succeed("kanidm group posix set shell")
+ client.succeed("kanidm group add-members shell testuser")
+
+ with subtest("Test user login"):
+ client.send_key("alt-f2")
+ client.wait_until_succeeds("[ $(fgconsole) = 2 ]")
+ client.wait_for_unit("getty@tty2.service")
+ client.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
+ client.wait_until_tty_matches("2", "login: ")
+ client.send_chars("testuser\n")
+ client.wait_until_tty_matches("2", "login: testuser")
+ client.wait_until_succeeds("pgrep login")
+ client.wait_until_tty_matches("2", "Password: ")
+ client.send_chars("${testCredentials.password}\n")
+ client.wait_until_succeeds("systemctl is-active user@$(id -u testuser).service")
+ client.send_chars("touch done\n")
+ client.wait_for_file("/home/testuser@${serverDomain}/done")
+
+ server.shutdown()
+ client.shutdown()
'';
- in
- {
- name = "kanidm";
- meta.maintainers = with pkgs.lib.maintainers; [
- Flakebi
- oddlama
- ];
-
- nodes.server =
- { pkgs, ... }:
- {
- services.kanidm = {
- package = pkgs.kanidm_1_6;
- enableServer = true;
- serverSettings = {
- origin = "https://${serverDomain}";
- domain = serverDomain;
- bindaddress = "[::]:443";
- ldapbindaddress = "[::1]:636";
- tls_chain = "${certsPath}/snakeoil.crt";
- tls_key = "${certsPath}/snakeoil.key";
- };
- };
-
- security.pki.certificateFiles = [ certs.ca.cert ];
-
- networking.hosts."::1" = [ serverDomain ];
- networking.firewall.allowedTCPPorts = [ 443 ];
-
- users.users.kanidm.shell = pkgs.bashInteractive;
-
- environment.systemPackages = with pkgs; [
- kanidm
- openldap
- ripgrep
- ];
- };
-
- nodes.client =
- { nodes, ... }:
- {
- services.kanidm = {
- package = pkgs.kanidm_1_6;
- enableClient = true;
- clientSettings = {
- uri = "https://${serverDomain}";
- verify_ca = true;
- verify_hostnames = true;
- };
- enablePam = true;
- unixSettings = {
- pam_allowed_login_groups = [ "shell" ];
- };
- };
-
- networking.hosts."${nodes.server.networking.primaryIPAddress}" = [ serverDomain ];
-
- security.pki.certificateFiles = [ certs.ca.cert ];
- };
-
- testScript =
- { nodes, ... }:
- let
- ldapBaseDN = builtins.concatStringsSep "," (
- map (s: "dc=" + s) (pkgs.lib.splitString "." serverDomain)
- );
-
- # We need access to the config file in the test script.
- filteredConfig = pkgs.lib.converge (pkgs.lib.filterAttrsRecursive (
- _: v: v != null
- )) nodes.server.services.kanidm.serverSettings;
- serverConfigFile = (pkgs.formats.toml { }).generate "server.toml" filteredConfig;
- in
- ''
- server.start()
- client.start()
- server.wait_for_unit("kanidm.service")
- client.systemctl("start network-online.target")
- client.wait_for_unit("network-online.target")
-
- with subtest("Test HTTP interface"):
- server.wait_until_succeeds("curl -Lsf https://${serverDomain} | grep Kanidm")
-
- with subtest("Test LDAP interface"):
- server.succeed("ldapsearch -H ldaps://${serverDomain}:636 -b '${ldapBaseDN}' -x '(name=test)'")
-
- with subtest("Recover idm_admin account"):
- idm_admin_password = server.succeed("su - kanidm -c 'kanidmd recover-account -c ${serverConfigFile} idm_admin 2>&1 | rg -o \'[A-Za-z0-9]{48}\' '").strip().removeprefix("'").removesuffix("'")
-
- with subtest("Test CLI login"):
- client.wait_until_tty_matches("1", "login: ")
- client.send_chars("root\n")
- client.send_chars("kanidm login -D idm_admin\n")
- client.wait_until_tty_matches("1", "Enter password: ")
- client.send_chars(f"{idm_admin_password}\n")
- client.wait_until_tty_matches("1", "Login Success for idm_admin")
-
- with subtest("Test unixd connection"):
- client.wait_for_unit("kanidm-unixd.service")
- client.wait_for_file("/run/kanidm-unixd/sock")
- client.wait_until_succeeds("kanidm-unix status | grep online")
-
- with subtest("Test user creation"):
- client.wait_for_unit("getty@tty1.service")
- client.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
- client.succeed("kanidm person create testuser TestUser")
- client.succeed("kanidm person posix set --shell \"$SHELL\" testuser")
- client.send_chars("kanidm person posix set-password testuser\n")
- client.wait_until_tty_matches("1", "Enter new")
- client.send_chars("${testCredentials.password}\n")
- client.wait_until_tty_matches("1", "Reenter")
- client.send_chars("${testCredentials.password}\n")
- output = client.succeed("getent passwd testuser")
- assert "TestUser" in output
- client.succeed("kanidm group create shell")
- client.succeed("kanidm group posix set shell")
- client.succeed("kanidm group add-members shell testuser")
-
- with subtest("Test user login"):
- client.send_key("alt-f2")
- client.wait_until_succeeds("[ $(fgconsole) = 2 ]")
- client.wait_for_unit("getty@tty2.service")
- client.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
- client.wait_until_tty_matches("2", "login: ")
- client.send_chars("testuser\n")
- client.wait_until_tty_matches("2", "login: testuser")
- client.wait_until_succeeds("pgrep login")
- client.wait_until_tty_matches("2", "Password: ")
- client.send_chars("${testCredentials.password}\n")
- client.wait_until_succeeds("systemctl is-active user@$(id -u testuser).service")
- client.send_chars("touch done\n")
- client.wait_for_file("/home/testuser@${serverDomain}/done")
-
- server.shutdown()
- client.shutdown()
- '';
- }
-)
+}
diff --git a/nixos/tests/karma.nix b/nixos/tests/karma.nix
index 2e80aa97fbb5..7d21d99bc505 100644
--- a/nixos/tests/karma.nix
+++ b/nixos/tests/karma.nix
@@ -1,89 +1,87 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "karma";
- nodes = {
- server =
- { ... }:
- {
- services.prometheus.alertmanager = {
- enable = true;
- logLevel = "debug";
- port = 9093;
- openFirewall = true;
- configuration = {
- global = {
- resolve_timeout = "1m";
- };
- route = {
- # Root route node
- receiver = "test";
- group_by = [ "..." ];
- continue = false;
- group_wait = "1s";
- group_interval = "15s";
- repeat_interval = "24h";
- };
- receivers = [
+{ lib, pkgs, ... }:
+{
+ name = "karma";
+ nodes = {
+ server =
+ { ... }:
+ {
+ services.prometheus.alertmanager = {
+ enable = true;
+ logLevel = "debug";
+ port = 9093;
+ openFirewall = true;
+ configuration = {
+ global = {
+ resolve_timeout = "1m";
+ };
+ route = {
+ # Root route node
+ receiver = "test";
+ group_by = [ "..." ];
+ continue = false;
+ group_wait = "1s";
+ group_interval = "15s";
+ repeat_interval = "24h";
+ };
+ receivers = [
+ {
+ name = "test";
+ webhook_configs = [
+ {
+ url = "http://localhost:1234";
+ send_resolved = true;
+ max_alerts = 0;
+ }
+ ];
+ }
+ ];
+ };
+ };
+ services.karma = {
+ enable = true;
+ openFirewall = true;
+ settings = {
+ listen = {
+ address = "0.0.0.0";
+ port = 8081;
+ };
+ alertmanager = {
+ servers = [
{
- name = "test";
- webhook_configs = [
- {
- url = "http://localhost:1234";
- send_resolved = true;
- max_alerts = 0;
- }
- ];
+ name = "alertmanager";
+ uri = "https://127.0.0.1:9093";
}
];
};
- };
- services.karma = {
- enable = true;
- openFirewall = true;
- settings = {
- listen = {
- address = "0.0.0.0";
- port = 8081;
- };
- alertmanager = {
- servers = [
- {
- name = "alertmanager";
- uri = "https://127.0.0.1:9093";
- }
- ];
- };
- karma.name = "test-dashboard";
- log.config = true;
- log.requests = true;
- log.timestamp = true;
- };
+ karma.name = "test-dashboard";
+ log.config = true;
+ log.requests = true;
+ log.timestamp = true;
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- with subtest("Wait for server to come up"):
+ with subtest("Wait for server to come up"):
- server.wait_for_unit("alertmanager.service")
- server.wait_for_unit("karma.service")
+ server.wait_for_unit("alertmanager.service")
+ server.wait_for_unit("karma.service")
- server.sleep(5) # wait for both services to settle
+ server.sleep(5) # wait for both services to settle
- server.wait_for_open_port(9093)
- server.wait_for_open_port(8081)
+ server.wait_for_open_port(9093)
+ server.wait_for_open_port(8081)
- with subtest("Test alertmanager readiness"):
- server.succeed("curl -s http://127.0.0.1:9093/-/ready")
+ with subtest("Test alertmanager readiness"):
+ server.succeed("curl -s http://127.0.0.1:9093/-/ready")
- # Karma only starts serving the dashboard once it has established connectivity to all alertmanagers in its config
- # Therefore, this will fail if karma isn't able to reach alertmanager
- server.succeed("curl -s http://127.0.0.1:8081")
+ # Karma only starts serving the dashboard once it has established connectivity to all alertmanagers in its config
+ # Therefore, this will fail if karma isn't able to reach alertmanager
+ server.succeed("curl -s http://127.0.0.1:8081")
- server.shutdown()
- '';
- }
-)
+ server.shutdown()
+ '';
+}
diff --git a/nixos/tests/kavita.nix b/nixos/tests/kavita.nix
index f9f51ebb80f8..6749c98f4d83 100644
--- a/nixos/tests/kavita.nix
+++ b/nixos/tests/kavita.nix
@@ -1,47 +1,45 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "kavita";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ misterio77 ];
- };
+{ pkgs, ... }:
+{
+ name = "kavita";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ misterio77 ];
+ };
- nodes = {
- kavita =
- { config, pkgs, ... }:
- {
- services.kavita = {
- enable = true;
- tokenKeyFile = builtins.toFile "kavita.key" "d26ba694b455271a8872415830fb7b5c58f8da98f9ef7f58b2ca4c34bd406512";
- };
+ nodes = {
+ kavita =
+ { config, pkgs, ... }:
+ {
+ services.kavita = {
+ enable = true;
+ tokenKeyFile = builtins.toFile "kavita.key" "d26ba694b455271a8872415830fb7b5c58f8da98f9ef7f58b2ca4c34bd406512";
};
- };
+ };
+ };
- testScript =
- let
- regUrl = "http://kavita:5000/api/Account/register";
- loginUrl = "http://kavita:5000/api/Account/login";
- localeUrl = "http://kavita:5000/api/locale";
- in
- ''
- import json
+ testScript =
+ let
+ regUrl = "http://kavita:5000/api/Account/register";
+ loginUrl = "http://kavita:5000/api/Account/login";
+ localeUrl = "http://kavita:5000/api/locale";
+ in
+ ''
+ import json
- kavita.start
- kavita.wait_for_unit("kavita.service")
+ kavita.start
+ kavita.wait_for_unit("kavita.service")
- # Check that static assets are working
- kavita.wait_until_succeeds("curl http://kavita:5000/site.webmanifest | grep Kavita")
+ # Check that static assets are working
+ kavita.wait_until_succeeds("curl http://kavita:5000/site.webmanifest | grep Kavita")
- # Check that registration is working
- kavita.succeed("""curl -fX POST ${regUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'""")
- # But only for the first one
- kavita.fail("""curl -fX POST ${regUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'""")
+ # Check that registration is working
+ kavita.succeed("""curl -fX POST ${regUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'""")
+ # But only for the first one
+ kavita.fail("""curl -fX POST ${regUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'""")
- # Log in and retrieve token
- session = json.loads(kavita.succeed("""curl -fX POST ${loginUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'"""))
- # Check list of locales
- locales = json.loads(kavita.succeed(f"curl -fX GET ${localeUrl} -H 'Authorization: Bearer {session['token']}'"))
- assert len(locales) > 0, "expected a list of locales"
- '';
- }
-)
+ # Log in and retrieve token
+ session = json.loads(kavita.succeed("""curl -fX POST ${loginUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'"""))
+ # Check list of locales
+ locales = json.loads(kavita.succeed(f"curl -fX GET ${localeUrl} -H 'Authorization: Bearer {session['token']}'"))
+ assert len(locales) > 0, "expected a list of locales"
+ '';
+}
diff --git a/nixos/tests/kbd-setfont-decompress.nix b/nixos/tests/kbd-setfont-decompress.nix
index 07ecf2c8979d..a6ad57d46fd2 100644
--- a/nixos/tests/kbd-setfont-decompress.nix
+++ b/nixos/tests/kbd-setfont-decompress.nix
@@ -1,23 +1,21 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "kbd-setfont-decompress";
+{ lib, pkgs, ... }:
+{
+ name = "kbd-setfont-decompress";
- meta.maintainers = with lib.maintainers; [ oxalica ];
+ meta.maintainers = with lib.maintainers; [ oxalica ];
- nodes.machine = { ... }: { };
+ nodes.machine = { ... }: { };
- testScript = ''
- machine.succeed("gzip -cd ${pkgs.terminus_font}/share/consolefonts/ter-v16b.psf.gz >font.psf")
- machine.succeed("gzip font.psf.gz")
- machine.succeed("bzip2 font.psf.bz2")
- machine.succeed("xz font.psf.xz")
- machine.succeed("zstd font.psf.zst")
- # setfont returns 0 even on error.
- assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.gz 2>&1") == ""
- assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.bz2 2>&1") == ""
- assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.xz 2>&1") == ""
- assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.zst 2>&1") == ""
- '';
- }
-)
+ testScript = ''
+ machine.succeed("gzip -cd ${pkgs.terminus_font}/share/consolefonts/ter-v16b.psf.gz >font.psf")
+ machine.succeed("gzip font.psf.gz")
+ machine.succeed("bzip2 font.psf.bz2")
+ machine.succeed("xz font.psf.xz")
+ machine.succeed("zstd font.psf.zst")
+ # setfont returns 0 even on error.
+ assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.gz 2>&1") == ""
+ assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.bz2 2>&1") == ""
+ assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.xz 2>&1") == ""
+ assert machine.succeed("PATH= ${pkgs.kbd}/bin/setfont font.psf.zst 2>&1") == ""
+ '';
+}
diff --git a/nixos/tests/kbd-update-search-paths-patch.nix b/nixos/tests/kbd-update-search-paths-patch.nix
index da2cf99b44a6..7c1c36174f8a 100644
--- a/nixos/tests/kbd-update-search-paths-patch.nix
+++ b/nixos/tests/kbd-update-search-paths-patch.nix
@@ -1,24 +1,22 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "kbd-update-search-paths-patch";
+{ pkgs, ... }:
+{
+ name = "kbd-update-search-paths-patch";
- nodes.machine =
- { pkgs, options, ... }:
- {
- console = {
- packages = options.console.packages.default ++ [ pkgs.terminus_font ];
- };
+ nodes.machine =
+ { pkgs, options, ... }:
+ {
+ console = {
+ packages = options.console.packages.default ++ [ pkgs.terminus_font ];
};
+ };
- testScript = ''
- command = "${pkgs.kbd}/bin/setfont ter-112n 2>&1"
- (status, out) = machine.execute(command)
- import re
- pattern = re.compile(r".*Unable to find file:.*")
- match = pattern.match(out)
- if match:
- raise Exception("command `{}` failed".format(command))
- '';
- }
-)
+ testScript = ''
+ command = "${pkgs.kbd}/bin/setfont ter-112n 2>&1"
+ (status, out) = machine.execute(command)
+ import re
+ pattern = re.compile(r".*Unable to find file:.*")
+ match = pattern.match(out)
+ if match:
+ raise Exception("command `{}` failed".format(command))
+ '';
+}
diff --git a/nixos/tests/keepalived.nix b/nixos/tests/keepalived.nix
index ba75dde8c5dc..d5ffa6e9838d 100644
--- a/nixos/tests/keepalived.nix
+++ b/nixos/tests/keepalived.nix
@@ -1,50 +1,48 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "keepalived";
- meta.maintainers = [ lib.maintainers.raitobezarius ];
+{ pkgs, lib, ... }:
+{
+ name = "keepalived";
+ meta.maintainers = [ lib.maintainers.raitobezarius ];
- nodes = {
- node1 =
- { pkgs, ... }:
- {
- services.keepalived.enable = true;
- services.keepalived.openFirewall = true;
- services.keepalived.vrrpInstances.test = {
- interface = "eth1";
- state = "MASTER";
- priority = 50;
- virtualIps = [ { addr = "192.168.1.200"; } ];
- virtualRouterId = 1;
- };
- environment.systemPackages = [ pkgs.tcpdump ];
+ nodes = {
+ node1 =
+ { pkgs, ... }:
+ {
+ services.keepalived.enable = true;
+ services.keepalived.openFirewall = true;
+ services.keepalived.vrrpInstances.test = {
+ interface = "eth1";
+ state = "MASTER";
+ priority = 50;
+ virtualIps = [ { addr = "192.168.1.200"; } ];
+ virtualRouterId = 1;
};
- node2 =
- { pkgs, ... }:
- {
- services.keepalived.enable = true;
- services.keepalived.openFirewall = true;
- services.keepalived.vrrpInstances.test = {
- interface = "eth1";
- state = "MASTER";
- priority = 100;
- virtualIps = [ { addr = "192.168.1.200"; } ];
- virtualRouterId = 1;
- };
- environment.systemPackages = [ pkgs.tcpdump ];
+ environment.systemPackages = [ pkgs.tcpdump ];
+ };
+ node2 =
+ { pkgs, ... }:
+ {
+ services.keepalived.enable = true;
+ services.keepalived.openFirewall = true;
+ services.keepalived.vrrpInstances.test = {
+ interface = "eth1";
+ state = "MASTER";
+ priority = 100;
+ virtualIps = [ { addr = "192.168.1.200"; } ];
+ virtualRouterId = 1;
};
- };
+ environment.systemPackages = [ pkgs.tcpdump ];
+ };
+ };
- testScript = ''
- # wait for boot time delay to pass
- for node in [node1, node2]:
- node.wait_until_succeeds(
- "systemctl show -p LastTriggerUSecMonotonic keepalived-boot-delay.timer | grep -vq 'LastTriggerUSecMonotonic=0'"
- )
- node.wait_for_unit("keepalived")
- node2.wait_until_succeeds("ip addr show dev eth1 | grep -q 192.168.1.200")
- node1.fail("ip addr show dev eth1 | grep -q 192.168.1.200")
- node1.succeed("ping -c1 192.168.1.200")
- '';
- }
-)
+ testScript = ''
+ # wait for boot time delay to pass
+ for node in [node1, node2]:
+ node.wait_until_succeeds(
+ "systemctl show -p LastTriggerUSecMonotonic keepalived-boot-delay.timer | grep -vq 'LastTriggerUSecMonotonic=0'"
+ )
+ node.wait_for_unit("keepalived")
+ node2.wait_until_succeeds("ip addr show dev eth1 | grep -q 192.168.1.200")
+ node1.fail("ip addr show dev eth1 | grep -q 192.168.1.200")
+ node1.succeed("ping -c1 192.168.1.200")
+ '';
+}
diff --git a/nixos/tests/keepassxc.nix b/nixos/tests/keepassxc.nix
index c2d68e29b798..1cdbdb445c3d 100644
--- a/nixos/tests/keepassxc.nix
+++ b/nixos/tests/keepassxc.nix
@@ -1,94 +1,92 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "keepassxc";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ turion ];
- timeout = 1800;
- };
+{
+ name = "keepassxc";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ turion ];
+ timeout = 1800;
+ };
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
+ {
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
- services.xserver.enable = true;
+ services.xserver.enable = true;
- # for better OCR
- environment.etc."icewm/prefoverride".text = ''
- ColorActiveTitleBar = "rgb:FF/FF/FF"
- '';
+ # for better OCR
+ environment.etc."icewm/prefoverride".text = ''
+ ColorActiveTitleBar = "rgb:FF/FF/FF"
+ '';
- # Regression test for https://github.com/NixOS/nixpkgs/issues/163482
- qt = {
- enable = true;
- platformTheme = "gnome";
- style = "adwaita-dark";
- };
-
- test-support.displayManager.auto.user = "alice";
- environment.systemPackages = with pkgs; [
- keepassxc
- xdotool
- ];
+ # Regression test for https://github.com/NixOS/nixpkgs/issues/163482
+ qt = {
+ enable = true;
+ platformTheme = "gnome";
+ style = "adwaita-dark";
};
- enableOCR = true;
+ test-support.displayManager.auto.user = "alice";
+ environment.systemPackages = with pkgs; [
+ keepassxc
+ xdotool
+ ];
+ };
- testScript =
- { nodes, ... }:
- let
- aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");'';
- in
- ''
- with subtest("Ensure X starts"):
- start_all()
- machine.wait_for_x()
+ enableOCR = true;
- with subtest("Can create database and entry with CLI"):
- ${aliceDo "keepassxc-cli db-create --set-key-file foo.keyfile foo.kdbx"}
- ${aliceDo "keepassxc-cli add --no-password -k foo.keyfile foo.kdbx bar"}
+ testScript =
+ { nodes, ... }:
+ let
+ aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");'';
+ in
+ ''
+ with subtest("Ensure X starts"):
+ start_all()
+ machine.wait_for_x()
- with subtest("Ensure KeePassXC starts"):
- # start KeePassXC window
- ${aliceDo "keepassxc >&2 &"}
+ with subtest("Can create database and entry with CLI"):
+ ${aliceDo "keepassxc-cli db-create --set-key-file foo.keyfile foo.kdbx"}
+ ${aliceDo "keepassxc-cli add --no-password -k foo.keyfile foo.kdbx bar"}
- machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}")
- machine.screenshot("KeePassXC")
+ with subtest("Ensure KeePassXC starts"):
+ # start KeePassXC window
+ ${aliceDo "keepassxc >&2 &"}
- with subtest("Can open existing database"):
- machine.send_key("ctrl-o")
- machine.sleep(5)
- # Regression #163482: keepassxc did not crash
- machine.succeed("ps -e | grep keepassxc")
- machine.wait_for_text("Open database")
- machine.send_key("ret")
+ machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}")
+ machine.screenshot("KeePassXC")
- # Wait for the enter password screen to appear.
- machine.wait_for_text("/home/alice/foo.kdbx")
+ with subtest("Can open existing database"):
+ machine.send_key("ctrl-o")
+ machine.sleep(5)
+ # Regression #163482: keepassxc did not crash
+ machine.succeed("ps -e | grep keepassxc")
+ machine.wait_for_text("Open database")
+ machine.send_key("ret")
- # Click on "I have key file" button to open keyfile dialog
- machine.send_key("tab")
- machine.send_key("tab")
- machine.send_key("tab")
- machine.send_key("ret")
+ # Wait for the enter password screen to appear.
+ machine.wait_for_text("/home/alice/foo.kdbx")
- # Select keyfile
- machine.wait_for_text("Select key file")
- machine.send_chars("/home/alice/foo.keyfile")
- machine.send_key("ret")
+ # Click on "I have key file" button to open keyfile dialog
+ machine.send_key("tab")
+ machine.send_key("tab")
+ machine.send_key("tab")
+ machine.send_key("ret")
- # Open database
- machine.wait_for_text("foo.kdbx \\[Locked] - KeePassXC")
- machine.send_key("ret")
+ # Select keyfile
+ machine.wait_for_text("Select key file")
+ machine.send_chars("/home/alice/foo.keyfile")
+ machine.send_key("ret")
- # Database is unlocked (doesn't have "[Locked]" in the title anymore)
- machine.wait_for_text("foo.kdbx - KeePassXC")
- '';
- }
-)
+ # Open database
+ machine.wait_for_text("foo.kdbx \\[Locked] - KeePassXC")
+ machine.send_key("ret")
+
+ # Database is unlocked (doesn't have "[Locked]" in the title anymore)
+ machine.wait_for_text("foo.kdbx - KeePassXC")
+ '';
+}
diff --git a/nixos/tests/kernel-latest-ath-user-regd.nix b/nixos/tests/kernel-latest-ath-user-regd.nix
index ede82d7d340a..f60b42ac6741 100644
--- a/nixos/tests/kernel-latest-ath-user-regd.nix
+++ b/nixos/tests/kernel-latest-ath-user-regd.nix
@@ -1,20 +1,18 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "kernel-latest-ath-user-regd";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ veehaitch ];
+{ pkgs, ... }:
+{
+ name = "kernel-latest-ath-user-regd";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ veehaitch ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ boot.kernelPackages = pkgs.linuxPackages_latest;
+ networking.wireless.athUserRegulatoryDomain = true;
};
- nodes.machine =
- { pkgs, ... }:
- {
- boot.kernelPackages = pkgs.linuxPackages_latest;
- networking.wireless.athUserRegulatoryDomain = true;
- };
-
- testScript = ''
- assert "CONFIG_ATH_USER_REGD=y" in machine.succeed("zcat /proc/config.gz")
- '';
- }
-)
+ testScript = ''
+ assert "CONFIG_ATH_USER_REGD=y" in machine.succeed("zcat /proc/config.gz")
+ '';
+}
diff --git a/nixos/tests/keter.nix b/nixos/tests/keter.nix
index d42b30d869d9..129ed25803cc 100644
--- a/nixos/tests/keter.nix
+++ b/nixos/tests/keter.nix
@@ -1,47 +1,45 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- port = 81;
- in
- {
- name = "keter";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ jappie ];
- };
+{ pkgs, ... }:
+let
+ port = 81;
+in
+{
+ name = "keter";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ jappie ];
+ };
- nodes.machine =
- { config, pkgs, ... }:
- {
- services.keter = {
- enable = true;
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ services.keter = {
+ enable = true;
- globalKeterConfig = {
- cli-port = 123; # just adding this to test the freeform
- listeners = [
- {
- host = "*4";
- inherit port;
- }
- ];
- };
- bundle = {
- appName = "test-bundle";
- domain = "localhost";
- executable = pkgs.writeShellScript "run" ''
- ${pkgs.python3}/bin/python -m http.server $PORT
- '';
- };
+ globalKeterConfig = {
+ cli-port = 123; # just adding this to test the freeform
+ listeners = [
+ {
+ host = "*4";
+ inherit port;
+ }
+ ];
+ };
+ bundle = {
+ appName = "test-bundle";
+ domain = "localhost";
+ executable = pkgs.writeShellScript "run" ''
+ ${pkgs.python3}/bin/python -m http.server $PORT
+ '';
};
};
+ };
- testScript = ''
- machine.wait_for_unit("keter.service")
+ testScript = ''
+ machine.wait_for_unit("keter.service")
- machine.wait_for_open_port(${toString port})
- machine.wait_for_console_text("Activating app test-bundle with hosts: localhost")
+ machine.wait_for_open_port(${toString port})
+ machine.wait_for_console_text("Activating app test-bundle with hosts: localhost")
- machine.succeed("curl --fail http://localhost:${toString port}/")
- '';
- }
-)
+ machine.succeed("curl --fail http://localhost:${toString port}/")
+ '';
+}
diff --git a/nixos/tests/komga.nix b/nixos/tests/komga.nix
index 22c63d8cac6b..8d3ef130a5cd 100644
--- a/nixos/tests/komga.nix
+++ b/nixos/tests/komga.nix
@@ -1,23 +1,21 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "komga";
- meta.maintainers = with lib.maintainers; [ govanify ];
+{
+ name = "komga";
+ meta.maintainers = with lib.maintainers; [ govanify ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.komga = {
- enable = true;
- settings.server.port = 1234;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.komga = {
+ enable = true;
+ settings.server.port = 1234;
};
+ };
- testScript = ''
- machine.wait_for_unit("komga.service")
- machine.wait_for_open_port(1234)
- machine.succeed("curl --fail http://localhost:1234/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("komga.service")
+ machine.wait_for_open_port(1234)
+ machine.succeed("curl --fail http://localhost:1234/")
+ '';
+}
diff --git a/nixos/tests/ksm.nix b/nixos/tests/ksm.nix
index 73ef3bdc8eb0..2268843268ff 100644
--- a/nixos/tests/ksm.nix
+++ b/nixos/tests/ksm.nix
@@ -1,25 +1,23 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "ksm";
- meta = with lib.maintainers; {
- maintainers = [ rnhmjoj ];
+{
+ name = "ksm";
+ meta = with lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+
+ hardware.ksm.enable = true;
+ hardware.ksm.sleep = 300;
};
- nodes.machine =
- { ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
-
- hardware.ksm.enable = true;
- hardware.ksm.sleep = 300;
- };
-
- testScript = ''
- machine.start()
- machine.wait_until_succeeds("test $(Hello world
' > page.html")
- machine.execute("Ladybird file://$(pwd)/page.html >&2 &")
- machine.wait_for_window("Ladybird")
- machine.sleep(5)
- machine.wait_for_text("Hello world")
- machine.screenshot("screen")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_x()
+ machine.succeed("echo 'Hello world
' > page.html")
+ machine.execute("Ladybird file://$(pwd)/page.html >&2 &")
+ machine.wait_for_window("Ladybird")
+ machine.sleep(5)
+ machine.wait_for_text("Hello world")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/languagetool.nix b/nixos/tests/languagetool.nix
index 35ab59b5d861..bbd6f3bf97c3 100644
--- a/nixos/tests/languagetool.nix
+++ b/nixos/tests/languagetool.nix
@@ -1,26 +1,24 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- port = 8082;
- in
- {
- name = "languagetool";
- meta = with lib.maintainers; {
- maintainers = [ fbeffa ];
+{ pkgs, lib, ... }:
+let
+ port = 8082;
+in
+{
+ name = "languagetool";
+ meta = with lib.maintainers; {
+ maintainers = [ fbeffa ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ services.languagetool.enable = true;
+ services.languagetool.port = port;
};
- nodes.machine =
- { ... }:
- {
- services.languagetool.enable = true;
- services.languagetool.port = port;
- };
-
- testScript = ''
- machine.start()
- machine.wait_for_unit("languagetool.service")
- machine.wait_for_open_port(${toString port})
- machine.wait_until_succeeds('curl -d "language=en-US" -d "text=a simple test" http://localhost:${toString port}/v2/check')
- '';
- }
-)
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("languagetool.service")
+ machine.wait_for_open_port(${toString port})
+ machine.wait_until_succeeds('curl -d "language=en-US" -d "text=a simple test" http://localhost:${toString port}/v2/check')
+ '';
+}
diff --git a/nixos/tests/lanraragi.nix b/nixos/tests/lanraragi.nix
index 21a065845c64..ccc95a5e0483 100644
--- a/nixos/tests/lanraragi.nix
+++ b/nixos/tests/lanraragi.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "lanraragi";
- meta.maintainers = with lib.maintainers; [ tomasajt ];
+{ pkgs, lib, ... }:
+{
+ name = "lanraragi";
+ meta.maintainers = with lib.maintainers; [ tomasajt ];
- nodes = {
- machine1 =
- { pkgs, ... }:
- {
- services.lanraragi.enable = true;
- };
- machine2 =
- { pkgs, ... }:
- {
- services.lanraragi = {
- enable = true;
- passwordFile = pkgs.writeText "lrr-test-pass" ''
- Ultra-secure-p@ssword-"with-spec1al\chars
+ nodes = {
+ machine1 =
+ { pkgs, ... }:
+ {
+ services.lanraragi.enable = true;
+ };
+ machine2 =
+ { pkgs, ... }:
+ {
+ services.lanraragi = {
+ enable = true;
+ passwordFile = pkgs.writeText "lrr-test-pass" ''
+ Ultra-secure-p@ssword-"with-spec1al\chars
+ '';
+ port = 4000;
+ redis = {
+ port = 4001;
+ passwordFile = pkgs.writeText "redis-lrr-test-pass" ''
+ 123-redis-PASS
'';
- port = 4000;
- redis = {
- port = 4001;
- passwordFile = pkgs.writeText "redis-lrr-test-pass" ''
- 123-redis-PASS
- '';
- };
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine1.wait_for_unit("lanraragi.service")
- machine1.wait_until_succeeds("curl -f localhost:3000")
- machine1.succeed("[ $(curl -o /dev/null -X post 'http://localhost:3000/login' --data-raw 'password=kamimamita' -w '%{http_code}') -eq 302 ]")
+ machine1.wait_for_unit("lanraragi.service")
+ machine1.wait_until_succeeds("curl -f localhost:3000")
+ machine1.succeed("[ $(curl -o /dev/null -X post 'http://localhost:3000/login' --data-raw 'password=kamimamita' -w '%{http_code}') -eq 302 ]")
- machine2.wait_for_unit("lanraragi.service")
- machine2.wait_until_succeeds("curl -f localhost:4000")
- machine2.succeed("[ $(curl -o /dev/null -X post 'http://localhost:4000/login' --data-raw 'password=Ultra-secure-p@ssword-\"with-spec1al\\chars' -w '%{http_code}') -eq 302 ]")
- '';
- }
-)
+ machine2.wait_for_unit("lanraragi.service")
+ machine2.wait_until_succeeds("curl -f localhost:4000")
+ machine2.succeed("[ $(curl -o /dev/null -X post 'http://localhost:4000/login' --data-raw 'password=Ultra-secure-p@ssword-\"with-spec1al\\chars' -w '%{http_code}') -eq 302 ]")
+ '';
+}
diff --git a/nixos/tests/leaps.nix b/nixos/tests/leaps.nix
index 92847d83eaeb..dd26ca181a5a 100644
--- a/nixos/tests/leaps.nix
+++ b/nixos/tests/leaps.nix
@@ -1,32 +1,30 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "leaps";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ qknight ];
- };
+{
+ name = "leaps";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ qknight ];
+ };
- nodes = {
- client = { };
+ nodes = {
+ client = { };
- server = {
- services.leaps = {
- enable = true;
- port = 6666;
- path = "/leaps/";
- };
- networking.firewall.enable = false;
+ server = {
+ services.leaps = {
+ enable = true;
+ port = 6666;
+ path = "/leaps/";
};
+ networking.firewall.enable = false;
};
+ };
- testScript = ''
- start_all()
- server.wait_for_open_port(6666)
- client.wait_for_unit("network.target")
- assert "leaps" in client.succeed(
- "${pkgs.curl}/bin/curl -f http://server:6666/leaps/"
- )
- '';
- }
-)
+ testScript = ''
+ start_all()
+ server.wait_for_open_port(6666)
+ client.wait_for_unit("network.target")
+ assert "leaps" in client.succeed(
+ "${pkgs.curl}/bin/curl -f http://server:6666/leaps/"
+ )
+ '';
+}
diff --git a/nixos/tests/legit.nix b/nixos/tests/legit.nix
index 405c69a52fad..d107e74fedd9 100644
--- a/nixos/tests/legit.nix
+++ b/nixos/tests/legit.nix
@@ -1,59 +1,57 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- let
- port = 5000;
- scanPath = "/var/lib/legit";
- in
- {
- name = "legit-web";
- meta.maintainers = [ lib.maintainers.ratsclub ];
+{ lib, pkgs, ... }:
+let
+ port = 5000;
+ scanPath = "/var/lib/legit";
+in
+{
+ name = "legit-web";
+ meta.maintainers = [ lib.maintainers.ratsclub ];
- nodes = {
- server =
- { config, pkgs, ... }:
- {
- services.legit = {
- enable = true;
- settings = {
- server.port = 5000;
- repo = { inherit scanPath; };
- };
+ nodes = {
+ server =
+ { config, pkgs, ... }:
+ {
+ services.legit = {
+ enable = true;
+ settings = {
+ server.port = 5000;
+ repo = { inherit scanPath; };
};
-
- environment.systemPackages = [ pkgs.git ];
};
- };
- testScript =
- { nodes, ... }:
- let
- strPort = builtins.toString port;
- in
- ''
- start_all()
+ environment.systemPackages = [ pkgs.git ];
+ };
+ };
- server.wait_for_unit("network.target")
- server.wait_for_unit("legit.service")
+ testScript =
+ { nodes, ... }:
+ let
+ strPort = builtins.toString port;
+ in
+ ''
+ start_all()
- server.wait_until_succeeds(
- "curl -f http://localhost:${strPort}"
- )
+ server.wait_for_unit("network.target")
+ server.wait_for_unit("legit.service")
- server.succeed("${pkgs.writeShellScript "setup-legit-test-repo" ''
- set -e
- git init --bare -b master ${scanPath}/some-repo
- git init -b master reference
- cd reference
- git remote add origin ${scanPath}/some-repo
- date > date.txt
- git add date.txt
- git -c user.name=test -c user.email=test@localhost commit -m 'add date'
- git push -u origin master
- ''}")
+ server.wait_until_succeeds(
+ "curl -f http://localhost:${strPort}"
+ )
- server.wait_until_succeeds(
- "curl -f http://localhost:${strPort}/some-repo"
- )
- '';
- }
-)
+ server.succeed("${pkgs.writeShellScript "setup-legit-test-repo" ''
+ set -e
+ git init --bare -b master ${scanPath}/some-repo
+ git init -b master reference
+ cd reference
+ git remote add origin ${scanPath}/some-repo
+ date > date.txt
+ git add date.txt
+ git -c user.name=test -c user.email=test@localhost commit -m 'add date'
+ git push -u origin master
+ ''}")
+
+ server.wait_until_succeeds(
+ "curl -f http://localhost:${strPort}/some-repo"
+ )
+ '';
+}
diff --git a/nixos/tests/lemmy.nix b/nixos/tests/lemmy.nix
index 5dc8cf107316..31eef526f29c 100644
--- a/nixos/tests/lemmy.nix
+++ b/nixos/tests/lemmy.nix
@@ -1,104 +1,102 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- uiPort = 1234;
- backendPort = 5678;
- lemmyNodeName = "server";
- in
- {
- name = "lemmy";
- meta = with lib.maintainers; {
- maintainers = [ mightyiam ];
- };
+{ pkgs, lib, ... }:
+let
+ uiPort = 1234;
+ backendPort = 5678;
+ lemmyNodeName = "server";
+in
+{
+ name = "lemmy";
+ meta = with lib.maintainers; {
+ maintainers = [ mightyiam ];
+ };
- nodes = {
- client = { };
+ nodes = {
+ client = { };
- "${lemmyNodeName}" = {
- services.lemmy = {
- enable = true;
- ui.port = uiPort;
- database.createLocally = true;
- settings = {
- hostname = "http://${lemmyNodeName}";
- port = backendPort;
- # Without setup, the /feeds/* and /nodeinfo/* API endpoints won't return 200
- setup = {
- admin_username = "mightyiam";
- site_name = "Lemmy FTW";
- admin_email = "mightyiam@example.com";
- };
+ "${lemmyNodeName}" = {
+ services.lemmy = {
+ enable = true;
+ ui.port = uiPort;
+ database.createLocally = true;
+ settings = {
+ hostname = "http://${lemmyNodeName}";
+ port = backendPort;
+ # Without setup, the /feeds/* and /nodeinfo/* API endpoints won't return 200
+ setup = {
+ admin_username = "mightyiam";
+ site_name = "Lemmy FTW";
+ admin_email = "mightyiam@example.com";
};
- adminPasswordFile = /etc/lemmy-admin-password.txt;
- caddy.enable = true;
};
-
- environment.etc."lemmy-admin-password.txt".text = "ThisIsWhatIUseEverywhereTryIt";
-
- networking.firewall.allowedTCPPorts = [ 80 ];
-
- # pict-rs seems to need more than 1025114112 bytes
- virtualisation.memorySize = 2000;
+ adminPasswordFile = /etc/lemmy-admin-password.txt;
+ caddy.enable = true;
};
+
+ environment.etc."lemmy-admin-password.txt".text = "ThisIsWhatIUseEverywhereTryIt";
+
+ networking.firewall.allowedTCPPorts = [ 80 ];
+
+ # pict-rs seems to need more than 1025114112 bytes
+ virtualisation.memorySize = 2000;
};
+ };
- testScript = ''
- server = ${lemmyNodeName}
+ testScript = ''
+ server = ${lemmyNodeName}
- with subtest("the merged config is secure"):
- server.wait_for_unit("lemmy.service")
- config_permissions = server.succeed("stat --format %A /run/lemmy/config.hjson").rstrip()
- assert config_permissions == "-rw-------", f"merged config permissions {config_permissions} are insecure"
- directory_permissions = server.succeed("stat --format %A /run/lemmy").rstrip()
- assert directory_permissions[5] == directory_permissions[8] == "-", "merged config can be replaced"
+ with subtest("the merged config is secure"):
+ server.wait_for_unit("lemmy.service")
+ config_permissions = server.succeed("stat --format %A /run/lemmy/config.hjson").rstrip()
+ assert config_permissions == "-rw-------", f"merged config permissions {config_permissions} are insecure"
+ directory_permissions = server.succeed("stat --format %A /run/lemmy").rstrip()
+ assert directory_permissions[5] == directory_permissions[8] == "-", "merged config can be replaced"
- with subtest("the backend starts and responds"):
- server.wait_for_open_port(${toString backendPort})
- # wait until succeeds, it just needs few seconds for migrations, but lets give it 50s max
- server.wait_until_succeeds("curl --fail localhost:${toString backendPort}/api/v3/site", 50)
+ with subtest("the backend starts and responds"):
+ server.wait_for_open_port(${toString backendPort})
+ # wait until succeeds, it just needs few seconds for migrations, but lets give it 50s max
+ server.wait_until_succeeds("curl --fail localhost:${toString backendPort}/api/v3/site", 50)
- with subtest("the UI starts and responds"):
- server.wait_for_unit("lemmy-ui.service")
- server.wait_for_open_port(${toString uiPort})
- server.succeed("curl --fail localhost:${toString uiPort}")
+ with subtest("the UI starts and responds"):
+ server.wait_for_unit("lemmy-ui.service")
+ server.wait_for_open_port(${toString uiPort})
+ server.succeed("curl --fail localhost:${toString uiPort}")
- with subtest("Lemmy-UI responds through the caddy reverse proxy"):
- server.systemctl("start network-online.target")
- server.wait_for_unit("network-online.target")
- server.wait_for_unit("caddy.service")
- server.wait_for_open_port(80)
- body = server.execute("curl --fail --location ${lemmyNodeName}")[1]
- assert "Lemmy" in body, f"String Lemmy not found in response for ${lemmyNodeName}: \n{body}"
+ with subtest("Lemmy-UI responds through the caddy reverse proxy"):
+ server.systemctl("start network-online.target")
+ server.wait_for_unit("network-online.target")
+ server.wait_for_unit("caddy.service")
+ server.wait_for_open_port(80)
+ body = server.execute("curl --fail --location ${lemmyNodeName}")[1]
+ assert "Lemmy" in body, f"String Lemmy not found in response for ${lemmyNodeName}: \n{body}"
- with subtest("the server is exposed externally"):
- client.systemctl("start network-online.target")
- client.wait_for_unit("network-online.target")
- client.succeed("curl -v --fail ${lemmyNodeName}")
+ with subtest("the server is exposed externally"):
+ client.systemctl("start network-online.target")
+ client.wait_for_unit("network-online.target")
+ client.succeed("curl -v --fail ${lemmyNodeName}")
- with subtest("caddy correctly routes backend requests"):
- # Make sure we are not hitting frontend
- server.execute("systemctl stop lemmy-ui.service")
+ with subtest("caddy correctly routes backend requests"):
+ # Make sure we are not hitting frontend
+ server.execute("systemctl stop lemmy-ui.service")
- def assert_http_code(url, expected_http_code, extra_curl_args=""):
- _, http_code = server.execute(f'curl --location --silent -o /dev/null {extra_curl_args} --fail --write-out "%{{http_code}}" {url}')
- assert http_code == str(expected_http_code), f"expected http code {expected_http_code}, got {http_code}"
+ def assert_http_code(url, expected_http_code, extra_curl_args=""):
+ _, http_code = server.execute(f'curl --location --silent -o /dev/null {extra_curl_args} --fail --write-out "%{{http_code}}" {url}')
+ assert http_code == str(expected_http_code), f"expected http code {expected_http_code}, got {http_code}"
- # Caddy responds with HTTP code 502 if it cannot handle the requested path
- assert_http_code("${lemmyNodeName}/obviously-wrong-path/", 502)
+ # Caddy responds with HTTP code 502 if it cannot handle the requested path
+ assert_http_code("${lemmyNodeName}/obviously-wrong-path/", 502)
- assert_http_code("${lemmyNodeName}/static/js/client.js", 200)
- assert_http_code("${lemmyNodeName}/api/v3/site", 200)
+ assert_http_code("${lemmyNodeName}/static/js/client.js", 200)
+ assert_http_code("${lemmyNodeName}/api/v3/site", 200)
- # A 404 confirms that the request goes to the backend
- # No path can return 200 until after we upload an image to pict-rs
- assert_http_code("${lemmyNodeName}/pictrs/", 404)
+ # A 404 confirms that the request goes to the backend
+ # No path can return 200 until after we upload an image to pict-rs
+ assert_http_code("${lemmyNodeName}/pictrs/", 404)
- assert_http_code("${lemmyNodeName}/feeds/all.xml", 200)
- assert_http_code("${lemmyNodeName}/nodeinfo/2.0.json", 200)
+ assert_http_code("${lemmyNodeName}/feeds/all.xml", 200)
+ assert_http_code("${lemmyNodeName}/nodeinfo/2.0.json", 200)
- assert_http_code("${lemmyNodeName}/some-other-made-up-path/", 404, "-X POST")
- assert_http_code("${lemmyNodeName}/some-other-path", 404, "-H 'Accept: application/activity+json'")
- assert_http_code("${lemmyNodeName}/some-other-path", 404, "-H 'Accept: application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"'")
- '';
- }
-)
+ assert_http_code("${lemmyNodeName}/some-other-made-up-path/", 404, "-X POST")
+ assert_http_code("${lemmyNodeName}/some-other-path", 404, "-H 'Accept: application/activity+json'")
+ assert_http_code("${lemmyNodeName}/some-other-path", 404, "-H 'Accept: application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"'")
+ '';
+}
diff --git a/nixos/tests/libinput.nix b/nixos/tests/libinput.nix
index 32858c80da85..47084fca53d2 100644
--- a/nixos/tests/libinput.nix
+++ b/nixos/tests/libinput.nix
@@ -1,41 +1,39 @@
-import ./make-test-python.nix (
- { ... }:
+{ ... }:
- {
- name = "libinput";
+{
+ name = "libinput";
- nodes.machine =
- { ... }:
- {
- imports = [
- ./common/x11.nix
- ./common/user-account.nix
- ];
+ nodes.machine =
+ { ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ./common/user-account.nix
+ ];
- test-support.displayManager.auto.user = "alice";
+ test-support.displayManager.auto.user = "alice";
- services.libinput = {
- enable = true;
- mouse = {
- naturalScrolling = true;
- leftHanded = true;
- middleEmulation = false;
- horizontalScrolling = false;
- };
+ services.libinput = {
+ enable = true;
+ mouse = {
+ naturalScrolling = true;
+ leftHanded = true;
+ middleEmulation = false;
+ horizontalScrolling = false;
};
};
+ };
- testScript = ''
- def expect_xserver_option(option, value):
- machine.succeed(f"""cat /var/log/X.0.log | grep -F 'Option "{option}" "{value}"'""")
+ testScript = ''
+ def expect_xserver_option(option, value):
+ machine.succeed(f"""cat /var/log/X.0.log | grep -F 'Option "{option}" "{value}"'""")
- machine.start()
- machine.wait_for_x()
- machine.succeed("""cat /var/log/X.0.log | grep -F "Using input driver 'libinput'" """)
- expect_xserver_option("NaturalScrolling", "on")
- expect_xserver_option("LeftHanded", "on")
- expect_xserver_option("MiddleEmulation", "off")
- expect_xserver_option("HorizontalScrolling", "off")
- '';
- }
-)
+ machine.start()
+ machine.wait_for_x()
+ machine.succeed("""cat /var/log/X.0.log | grep -F "Using input driver 'libinput'" """)
+ expect_xserver_option("NaturalScrolling", "on")
+ expect_xserver_option("LeftHanded", "on")
+ expect_xserver_option("MiddleEmulation", "off")
+ expect_xserver_option("HorizontalScrolling", "off")
+ '';
+}
diff --git a/nixos/tests/libresprite.nix b/nixos/tests/libresprite.nix
index d03911788750..76417b80ee2e 100644
--- a/nixos/tests/libresprite.nix
+++ b/nixos/tests/libresprite.nix
@@ -1,34 +1,32 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "libresprite";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fgaz ];
+{ pkgs, ... }:
+{
+ name = "libresprite";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fgaz ];
+ };
+
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ];
+
+ services.xserver.enable = true;
+ environment.systemPackages = [
+ pkgs.imagemagick
+ pkgs.libresprite
+ ];
};
- nodes.machine =
- { config, pkgs, ... }:
- {
- imports = [
- ./common/x11.nix
- ];
+ enableOCR = true;
- services.xserver.enable = true;
- environment.systemPackages = [
- pkgs.imagemagick
- pkgs.libresprite
- ];
- };
-
- enableOCR = true;
-
- testScript = ''
- machine.wait_for_x()
- machine.succeed("convert -font DejaVu-Sans +antialias label:'IT WORKS' image.png")
- machine.execute("libresprite image.png >&2 &")
- machine.wait_for_window("LibreSprite ${pkgs.libresprite.version}-dev")
- machine.wait_for_text("IT WORKS")
- machine.screenshot("screen")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_x()
+ machine.succeed("convert -font DejaVu-Sans +antialias label:'IT WORKS' image.png")
+ machine.execute("libresprite image.png >&2 &")
+ machine.wait_for_window("LibreSprite ${pkgs.libresprite.version}-dev")
+ machine.wait_for_text("IT WORKS")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/libuiohook.nix b/nixos/tests/libuiohook.nix
index bd0cdcc7696a..34a200bd0349 100644
--- a/nixos/tests/libuiohook.nix
+++ b/nixos/tests/libuiohook.nix
@@ -1,35 +1,33 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "libuiohook";
- meta = with lib.maintainers; {
- maintainers = [ anoa ];
+{ pkgs, lib, ... }:
+{
+ name = "libuiohook";
+ meta = with lib.maintainers; {
+ maintainers = [ anoa ];
+ };
+
+ nodes.client =
+ { nodes, ... }:
+ let
+ user = nodes.client.config.users.users.alice;
+ in
+ {
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
+
+ environment.systemPackages = [ pkgs.libuiohook.test ];
+
+ test-support.displayManager.auto.user = user.name;
};
- nodes.client =
- { nodes, ... }:
- let
- user = nodes.client.config.users.users.alice;
- in
- {
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
-
- environment.systemPackages = [ pkgs.libuiohook.test ];
-
- test-support.displayManager.auto.user = user.name;
- };
-
- testScript =
- { nodes, ... }:
- let
- user = nodes.client.config.users.users.alice;
- in
- ''
- client.wait_for_x()
- client.succeed("su - alice -c ${pkgs.libuiohook.test}/share/uiohook_tests >&2 &")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.client.config.users.users.alice;
+ in
+ ''
+ client.wait_for_x()
+ client.succeed("su - alice -c ${pkgs.libuiohook.test}/share/uiohook_tests >&2 &")
+ '';
+}
diff --git a/nixos/tests/libvirtd.nix b/nixos/tests/libvirtd.nix
index 3f996cdcde4a..d7df4c560177 100644
--- a/nixos/tests/libvirtd.nix
+++ b/nixos/tests/libvirtd.nix
@@ -1,78 +1,76 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "libvirtd";
- meta.maintainers = with pkgs.lib.maintainers; [ fpletz ];
+{ pkgs, ... }:
+{
+ name = "libvirtd";
+ meta.maintainers = with pkgs.lib.maintainers; [ fpletz ];
- nodes = {
- virthost =
- { pkgs, ... }:
- {
- virtualisation = {
- cores = 2;
- memorySize = 2048;
+ nodes = {
+ virthost =
+ { pkgs, ... }:
+ {
+ virtualisation = {
+ cores = 2;
+ memorySize = 2048;
- libvirtd.enable = true;
- libvirtd.hooks.qemu.is_working = "${pkgs.writeShellScript "testHook.sh" ''
- touch /tmp/qemu_hook_is_working
- ''}";
- libvirtd.nss.enable = true;
- };
- boot.supportedFilesystems = [ "zfs" ];
- networking.hostId = "deadbeef"; # needed for zfs
- security.polkit.enable = true;
- environment.systemPackages = with pkgs; [ virt-manager ];
-
- # This adds `resolve` to the `hosts` line of /etc/nsswitch.conf; NSS modules placed after it
- # will not be consulted. Therefore this tests that the libvirtd NSS modules will be
- # be placed early enough for name resolution to work.
- services.resolved.enable = true;
+ libvirtd.enable = true;
+ libvirtd.hooks.qemu.is_working = "${pkgs.writeShellScript "testHook.sh" ''
+ touch /tmp/qemu_hook_is_working
+ ''}";
+ libvirtd.nss.enable = true;
};
- };
+ boot.supportedFilesystems = [ "zfs" ];
+ networking.hostId = "deadbeef"; # needed for zfs
+ security.polkit.enable = true;
+ environment.systemPackages = with pkgs; [ virt-manager ];
- testScript =
- let
- nixosInstallISO = (import ../release.nix { }).iso_minimal.${pkgs.stdenv.hostPlatform.system};
- virshShutdownCmd = if pkgs.stdenv.hostPlatform.isx86_64 then "shutdown" else "destroy";
- in
- ''
- start_all()
+ # This adds `resolve` to the `hosts` line of /etc/nsswitch.conf; NSS modules placed after it
+ # will not be consulted. Therefore this tests that the libvirtd NSS modules will be
+ # be placed early enough for name resolution to work.
+ services.resolved.enable = true;
+ };
+ };
+ testScript =
+ let
+ nixosInstallISO = (import ../release.nix { }).iso_minimal.${pkgs.stdenv.hostPlatform.system};
+ virshShutdownCmd = if pkgs.stdenv.hostPlatform.isx86_64 then "shutdown" else "destroy";
+ in
+ ''
+ start_all()
+
+ virthost.wait_for_unit("multi-user.target")
+
+ with subtest("enable default network"):
+ virthost.succeed("virsh net-start default")
+ virthost.succeed("virsh net-autostart default")
+ virthost.succeed("virsh net-info default")
+
+ with subtest("check if partition disk pools works with parted"):
+ virthost.succeed("fallocate -l100m /tmp/foo; losetup /dev/loop0 /tmp/foo; echo 'label: dos' | sfdisk /dev/loop0")
+ virthost.succeed("virsh pool-create-as foo disk --source-dev /dev/loop0 --target /dev")
+ virthost.succeed("virsh vol-create-as foo loop0p1 25MB")
+ virthost.succeed("virsh vol-create-as foo loop0p2 50MB")
+
+ with subtest("check if virsh zfs pools work"):
+ virthost.succeed("fallocate -l100m /tmp/zfs; losetup /dev/loop1 /tmp/zfs;")
+ virthost.succeed("zpool create zfs_loop /dev/loop1")
+ virthost.succeed("virsh pool-define-as --name zfs_storagepool --source-name zfs_loop --type zfs")
+ virthost.succeed("virsh pool-start zfs_storagepool")
+ virthost.succeed("virsh vol-create-as zfs_storagepool disk1 25MB")
+
+ with subtest("check if nixos install iso boots, network and autostart works"):
+ virthost.succeed(
+ "virt-install -n nixos --osinfo nixos-unstable --memory 1024 --graphics none --disk `find ${nixosInstallISO}/iso -type f | head -n1`,readonly=on --import --noautoconsole --autostart"
+ )
+ virthost.succeed("virsh domstate nixos | grep running")
+ virthost.wait_until_succeeds("ping -c 1 nixos")
+ virthost.succeed("virsh ${virshShutdownCmd} nixos")
+ virthost.wait_until_succeeds("virsh domstate nixos | grep 'shut off'")
+ virthost.shutdown()
virthost.wait_for_unit("multi-user.target")
+ virthost.wait_until_succeeds("ping -c 1 nixos")
- with subtest("enable default network"):
- virthost.succeed("virsh net-start default")
- virthost.succeed("virsh net-autostart default")
- virthost.succeed("virsh net-info default")
-
- with subtest("check if partition disk pools works with parted"):
- virthost.succeed("fallocate -l100m /tmp/foo; losetup /dev/loop0 /tmp/foo; echo 'label: dos' | sfdisk /dev/loop0")
- virthost.succeed("virsh pool-create-as foo disk --source-dev /dev/loop0 --target /dev")
- virthost.succeed("virsh vol-create-as foo loop0p1 25MB")
- virthost.succeed("virsh vol-create-as foo loop0p2 50MB")
-
- with subtest("check if virsh zfs pools work"):
- virthost.succeed("fallocate -l100m /tmp/zfs; losetup /dev/loop1 /tmp/zfs;")
- virthost.succeed("zpool create zfs_loop /dev/loop1")
- virthost.succeed("virsh pool-define-as --name zfs_storagepool --source-name zfs_loop --type zfs")
- virthost.succeed("virsh pool-start zfs_storagepool")
- virthost.succeed("virsh vol-create-as zfs_storagepool disk1 25MB")
-
- with subtest("check if nixos install iso boots, network and autostart works"):
- virthost.succeed(
- "virt-install -n nixos --osinfo nixos-unstable --memory 1024 --graphics none --disk `find ${nixosInstallISO}/iso -type f | head -n1`,readonly=on --import --noautoconsole --autostart"
- )
- virthost.succeed("virsh domstate nixos | grep running")
- virthost.wait_until_succeeds("ping -c 1 nixos")
- virthost.succeed("virsh ${virshShutdownCmd} nixos")
- virthost.wait_until_succeeds("virsh domstate nixos | grep 'shut off'")
- virthost.shutdown()
- virthost.wait_for_unit("multi-user.target")
- virthost.wait_until_succeeds("ping -c 1 nixos")
-
- with subtest("test if hooks are linked and run"):
- virthost.succeed("ls /var/lib/libvirt/hooks/qemu.d/is_working")
- virthost.succeed("ls /tmp/qemu_hook_is_working")
- '';
- }
-)
+ with subtest("test if hooks are linked and run"):
+ virthost.succeed("ls /var/lib/libvirt/hooks/qemu.d/is_working")
+ virthost.succeed("ls /tmp/qemu_hook_is_working")
+ '';
+}
diff --git a/nixos/tests/lidarr.nix b/nixos/tests/lidarr.nix
index 411d4a782390..8f32ce14673f 100644
--- a/nixos/tests/lidarr.nix
+++ b/nixos/tests/lidarr.nix
@@ -1,22 +1,20 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "lidarr";
- meta.maintainers = with lib.maintainers; [ etu ];
+{
+ name = "lidarr";
+ meta.maintainers = with lib.maintainers; [ etu ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.lidarr.enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.lidarr.enable = true;
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine.wait_for_unit("lidarr.service")
- machine.wait_for_open_port(8686)
- machine.succeed("curl --fail http://localhost:8686/")
- '';
- }
-)
+ machine.wait_for_unit("lidarr.service")
+ machine.wait_for_open_port(8686)
+ machine.succeed("curl --fail http://localhost:8686/")
+ '';
+}
diff --git a/nixos/tests/lightdm.nix b/nixos/tests/lightdm.nix
index 8490f0a6ffaa..3d51924af8de 100644
--- a/nixos/tests/lightdm.nix
+++ b/nixos/tests/lightdm.nix
@@ -1,36 +1,34 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "lightdm";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ aszlig ];
+{ pkgs, ... }:
+{
+ name = "lightdm";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ aszlig ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.xserver.displayManager.lightdm.enable = true;
+ services.displayManager.defaultSession = "none+icewm";
+ services.xserver.windowManager.icewm.enable = true;
};
- nodes.machine =
- { ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.xserver.displayManager.lightdm.enable = true;
- services.displayManager.defaultSession = "none+icewm";
- services.xserver.windowManager.icewm.enable = true;
- };
+ enableOCR = true;
- enableOCR = true;
-
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.config.users.users.alice;
- in
- ''
- start_all()
- machine.wait_for_text("${user.description}")
- machine.screenshot("lightdm")
- machine.send_chars("${user.password}\n")
- machine.wait_for_file("${user.home}/.Xauthority")
- machine.succeed("xauth merge ${user.home}/.Xauthority")
- machine.wait_for_window("^IceWM ")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.config.users.users.alice;
+ in
+ ''
+ start_all()
+ machine.wait_for_text("${user.description}")
+ machine.screenshot("lightdm")
+ machine.send_chars("${user.password}\n")
+ machine.wait_for_file("${user.home}/.Xauthority")
+ machine.succeed("xauth merge ${user.home}/.Xauthority")
+ machine.wait_for_window("^IceWM ")
+ '';
+}
diff --git a/nixos/tests/limesurvey.nix b/nixos/tests/limesurvey.nix
index af6092b40193..9f90b4d16820 100644
--- a/nixos/tests/limesurvey.nix
+++ b/nixos/tests/limesurvey.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "limesurvey";
- meta.maintainers = [ lib.maintainers.aanderse ];
+{ lib, pkgs, ... }:
+{
+ name = "limesurvey";
+ meta.maintainers = [ lib.maintainers.aanderse ];
- nodes.machine =
- { ... }:
- {
- services.limesurvey = {
- enable = true;
- virtualHost = {
- hostName = "example.local";
- adminAddr = "root@example.local";
- };
- encryptionKeyFile = pkgs.writeText "key" (lib.strings.replicate 32 "0");
- encryptionNonceFile = pkgs.writeText "nonce" (lib.strings.replicate 24 "0");
+ nodes.machine =
+ { ... }:
+ {
+ services.limesurvey = {
+ enable = true;
+ virtualHost = {
+ hostName = "example.local";
+ adminAddr = "root@example.local";
};
-
- # limesurvey won't work without a dot in the hostname
- networking.hosts."127.0.0.1" = [ "example.local" ];
+ encryptionKeyFile = pkgs.writeText "key" (lib.strings.replicate 32 "0");
+ encryptionNonceFile = pkgs.writeText "nonce" (lib.strings.replicate 24 "0");
};
- testScript = ''
- start_all()
+ # limesurvey won't work without a dot in the hostname
+ networking.hosts."127.0.0.1" = [ "example.local" ];
+ };
- machine.wait_for_unit("phpfpm-limesurvey.service")
- assert "The following surveys are available" in machine.succeed(
- "curl -f http://example.local/"
- )
- '';
- }
-)
+ testScript = ''
+ start_all()
+
+ machine.wait_for_unit("phpfpm-limesurvey.service")
+ assert "The following surveys are available" in machine.succeed(
+ "curl -f http://example.local/"
+ )
+ '';
+}
diff --git a/nixos/tests/litestream.nix b/nixos/tests/litestream.nix
index 24fe804f3a9e..1ecf08cf5014 100644
--- a/nixos/tests/litestream.nix
+++ b/nixos/tests/litestream.nix
@@ -1,114 +1,112 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "litestream";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ jwygoda ];
- };
+{ pkgs, ... }:
+{
+ name = "litestream";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ jwygoda ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- services.litestream = {
- enable = true;
- settings = {
- dbs = [
- {
- path = "/var/lib/grafana/data/grafana.db";
- replicas = [
- {
- url = "sftp://foo:bar@127.0.0.1:22/home/foo/grafana";
- }
- ];
- }
- ];
- };
- };
- systemd.services.grafana.serviceConfig.ExecStartPost =
- "+"
- + pkgs.writeShellScript "grant-grafana-permissions" ''
- timeout=10
-
- while [ ! -f /var/lib/grafana/data/grafana.db ];
- do
- if [ "$timeout" == 0 ]; then
- echo "ERROR: Timeout while waiting for /var/lib/grafana/data/grafana.db."
- exit 1
- fi
-
- sleep 1
-
- ((timeout--))
- done
-
- find /var/lib/grafana -type d -exec chmod -v 775 {} \;
- find /var/lib/grafana -type f -exec chmod -v 660 {} \;
- '';
- services.openssh = {
- enable = true;
- allowSFTP = true;
- listenAddresses = [
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.litestream = {
+ enable = true;
+ settings = {
+ dbs = [
{
- addr = "127.0.0.1";
- port = 22;
+ path = "/var/lib/grafana/data/grafana.db";
+ replicas = [
+ {
+ url = "sftp://foo:bar@127.0.0.1:22/home/foo/grafana";
+ }
+ ];
}
];
};
- services.grafana = {
- enable = true;
- settings = {
- security = {
- admin_user = "admin";
- admin_password = "admin";
- };
+ };
+ systemd.services.grafana.serviceConfig.ExecStartPost =
+ "+"
+ + pkgs.writeShellScript "grant-grafana-permissions" ''
+ timeout=10
- server = {
- http_addr = "localhost";
- http_port = 3000;
- };
+ while [ ! -f /var/lib/grafana/data/grafana.db ];
+ do
+ if [ "$timeout" == 0 ]; then
+ echo "ERROR: Timeout while waiting for /var/lib/grafana/data/grafana.db."
+ exit 1
+ fi
- database = {
- type = "sqlite3";
- path = "/var/lib/grafana/data/grafana.db";
- wal = true;
- };
+ sleep 1
+
+ ((timeout--))
+ done
+
+ find /var/lib/grafana -type d -exec chmod -v 775 {} \;
+ find /var/lib/grafana -type f -exec chmod -v 660 {} \;
+ '';
+ services.openssh = {
+ enable = true;
+ allowSFTP = true;
+ listenAddresses = [
+ {
+ addr = "127.0.0.1";
+ port = 22;
+ }
+ ];
+ };
+ services.grafana = {
+ enable = true;
+ settings = {
+ security = {
+ admin_user = "admin";
+ admin_password = "admin";
+ };
+
+ server = {
+ http_addr = "localhost";
+ http_port = 3000;
+ };
+
+ database = {
+ type = "sqlite3";
+ path = "/var/lib/grafana/data/grafana.db";
+ wal = true;
};
};
- users.users.foo = {
- isNormalUser = true;
- password = "bar";
- };
- users.users.litestream.extraGroups = [ "grafana" ];
};
+ users.users.foo = {
+ isNormalUser = true;
+ password = "bar";
+ };
+ users.users.litestream.extraGroups = [ "grafana" ];
+ };
- testScript = ''
- start_all()
- machine.wait_until_succeeds("test -d /home/foo/grafana")
- machine.wait_for_open_port(3000)
- machine.succeed("""
- curl -sSfN -X PUT -H "Content-Type: application/json" -d '{
- "oldPassword": "admin",
- "newPassword": "newpass",
- "confirmNew": "newpass"
- }' http://admin:admin@127.0.0.1:3000/api/user/password
- """)
- # https://litestream.io/guides/systemd/#simulating-a-disaster
- machine.systemctl("stop litestream.service")
- machine.succeed(
- "rm -f /var/lib/grafana/data/grafana.db "
- "/var/lib/grafana/data/grafana.db-shm "
- "/var/lib/grafana/data/grafana.db-wal"
- )
- machine.succeed(
- "litestream restore /var/lib/grafana/data/grafana.db "
- "&& chown grafana:grafana /var/lib/grafana/data/grafana.db "
- "&& chmod 660 /var/lib/grafana/data/grafana.db"
- )
- machine.systemctl("restart grafana.service")
- machine.wait_for_open_port(3000)
- machine.succeed(
- "curl -sSfN -u admin:newpass http://127.0.0.1:3000/api/org/users | grep admin\@localhost"
- )
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_until_succeeds("test -d /home/foo/grafana")
+ machine.wait_for_open_port(3000)
+ machine.succeed("""
+ curl -sSfN -X PUT -H "Content-Type: application/json" -d '{
+ "oldPassword": "admin",
+ "newPassword": "newpass",
+ "confirmNew": "newpass"
+ }' http://admin:admin@127.0.0.1:3000/api/user/password
+ """)
+ # https://litestream.io/guides/systemd/#simulating-a-disaster
+ machine.systemctl("stop litestream.service")
+ machine.succeed(
+ "rm -f /var/lib/grafana/data/grafana.db "
+ "/var/lib/grafana/data/grafana.db-shm "
+ "/var/lib/grafana/data/grafana.db-wal"
+ )
+ machine.succeed(
+ "litestream restore /var/lib/grafana/data/grafana.db "
+ "&& chown grafana:grafana /var/lib/grafana/data/grafana.db "
+ "&& chmod 660 /var/lib/grafana/data/grafana.db"
+ )
+ machine.systemctl("restart grafana.service")
+ machine.wait_for_open_port(3000)
+ machine.succeed(
+ "curl -sSfN -u admin:newpass http://127.0.0.1:3000/api/org/users | grep admin\@localhost"
+ )
+ '';
+}
diff --git a/nixos/tests/livebook-service.nix b/nixos/tests/livebook-service.nix
index 140b056c48d4..b84fd894692c 100644
--- a/nixos/tests/livebook-service.nix
+++ b/nixos/tests/livebook-service.nix
@@ -1,48 +1,46 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "livebook-service";
+{ lib, pkgs, ... }:
+{
+ name = "livebook-service";
- nodes = {
- machine =
- { config, pkgs, ... }:
- {
- imports = [
- ./common/user-account.nix
- ];
-
- services.livebook = {
- enableUserService = true;
- environment = {
- LIVEBOOK_PORT = 20123;
- };
- environmentFile = pkgs.writeText "livebook.env" ''
- LIVEBOOK_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
- '';
- };
- };
- };
-
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- sudo = lib.concatStringsSep " " [
- "XDG_RUNTIME_DIR=/run/user/${toString user.uid}"
- "sudo"
- "--preserve-env=XDG_RUNTIME_DIR"
- "-u"
- "alice"
+ nodes = {
+ machine =
+ { config, pkgs, ... }:
+ {
+ imports = [
+ ./common/user-account.nix
];
- in
- ''
- machine.wait_for_unit("multi-user.target")
- machine.succeed("loginctl enable-linger alice")
- machine.wait_until_succeeds("${sudo} systemctl --user is-active livebook.service")
- machine.wait_for_open_port(20123, timeout=10)
+ services.livebook = {
+ enableUserService = true;
+ environment = {
+ LIVEBOOK_PORT = 20123;
+ };
+ environmentFile = pkgs.writeText "livebook.env" ''
+ LIVEBOOK_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+ '';
+ };
+ };
+ };
- machine.succeed("curl -L localhost:20123 | grep 'Type password'")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ sudo = lib.concatStringsSep " " [
+ "XDG_RUNTIME_DIR=/run/user/${toString user.uid}"
+ "sudo"
+ "--preserve-env=XDG_RUNTIME_DIR"
+ "-u"
+ "alice"
+ ];
+ in
+ ''
+ machine.wait_for_unit("multi-user.target")
+
+ machine.succeed("loginctl enable-linger alice")
+ machine.wait_until_succeeds("${sudo} systemctl --user is-active livebook.service")
+ machine.wait_for_open_port(20123, timeout=10)
+
+ machine.succeed("curl -L localhost:20123 | grep 'Type password'")
+ '';
+}
diff --git a/nixos/tests/lldap.nix b/nixos/tests/lldap.nix
index 610bda27b1cc..c2e48525a5f3 100644
--- a/nixos/tests/lldap.nix
+++ b/nixos/tests/lldap.nix
@@ -1,31 +1,29 @@
-import ./make-test-python.nix (
- { ... }:
- {
- name = "lldap";
+{ ... }:
+{
+ name = "lldap";
- nodes.machine =
- { pkgs, ... }:
- {
- services.lldap = {
- enable = true;
- settings = {
- verbose = true;
- ldap_base_dn = "dc=example,dc=com";
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.lldap = {
+ enable = true;
+ settings = {
+ verbose = true;
+ ldap_base_dn = "dc=example,dc=com";
};
- environment.systemPackages = [ pkgs.openldap ];
};
+ environment.systemPackages = [ pkgs.openldap ];
+ };
- testScript = ''
- machine.wait_for_unit("lldap.service")
- machine.wait_for_open_port(3890)
- machine.wait_for_open_port(17170)
+ testScript = ''
+ machine.wait_for_unit("lldap.service")
+ machine.wait_for_open_port(3890)
+ machine.wait_for_open_port(17170)
- machine.succeed("curl --location --fail http://localhost:17170/")
+ machine.succeed("curl --location --fail http://localhost:17170/")
- print(
- machine.succeed('ldapsearch -H ldap://localhost:3890 -D uid=admin,ou=people,dc=example,dc=com -b "ou=people,dc=example,dc=com" -w password')
- )
- '';
- }
-)
+ print(
+ machine.succeed('ldapsearch -H ldap://localhost:3890 -D uid=admin,ou=people,dc=example,dc=com -b "ou=people,dc=example,dc=com" -w password')
+ )
+ '';
+}
diff --git a/nixos/tests/localsend.nix b/nixos/tests/localsend.nix
index 551b6dd73ce8..047a3d1598c9 100644
--- a/nixos/tests/localsend.nix
+++ b/nixos/tests/localsend.nix
@@ -1,22 +1,20 @@
-import ./make-test-python.nix (
- { ... }:
- {
- name = "localsend";
+{ ... }:
+{
+ name = "localsend";
- nodes.machine =
- { ... }:
- {
- imports = [ ./common/x11.nix ];
- programs.localsend.enable = true;
- };
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ./common/x11.nix ];
+ programs.localsend.enable = true;
+ };
- testScript = ''
- machine.wait_for_x()
- machine.succeed("localsend_app >&2 &")
- machine.wait_for_open_port(53317)
- machine.wait_for_window("LocalSend", 10)
- machine.succeed("netstat --listening --program --tcp | grep -P 'tcp.*53317.*localsend'")
- machine.succeed("netstat --listening --program --udp | grep -P 'udp.*53317.*localsend'")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_x()
+ machine.succeed("localsend_app >&2 &")
+ machine.wait_for_open_port(53317)
+ machine.wait_for_window("LocalSend", 10)
+ machine.succeed("netstat --listening --program --tcp | grep -P 'tcp.*53317.*localsend'")
+ machine.succeed("netstat --listening --program --udp | grep -P 'udp.*53317.*localsend'")
+ '';
+}
diff --git a/nixos/tests/locate.nix b/nixos/tests/locate.nix
index ce66d7fd3afc..559868128560 100644
--- a/nixos/tests/locate.nix
+++ b/nixos/tests/locate.nix
@@ -1,66 +1,64 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- let
- inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
- in
- {
- name = "locate";
- meta.maintainers = with pkgs.lib.maintainers; [ chkno ];
+{ lib, pkgs, ... }:
+let
+ inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
+in
+{
+ name = "locate";
+ meta.maintainers = with pkgs.lib.maintainers; [ chkno ];
- nodes = rec {
- a = {
- environment.systemPackages = with pkgs; [ sshfs ];
- virtualisation.fileSystems = {
- "/ssh" = {
- device = "alice@b:/";
- fsType = "fuse.sshfs";
- options = [
- "allow_other"
- "IdentityFile=/privkey"
- "noauto"
- "StrictHostKeyChecking=no"
- "UserKnownHostsFile=/dev/null"
- ];
- };
- };
- services.locate = {
- enable = true;
- interval = "*:*:0/5";
+ nodes = rec {
+ a = {
+ environment.systemPackages = with pkgs; [ sshfs ];
+ virtualisation.fileSystems = {
+ "/ssh" = {
+ device = "alice@b:/";
+ fsType = "fuse.sshfs";
+ options = [
+ "allow_other"
+ "IdentityFile=/privkey"
+ "noauto"
+ "StrictHostKeyChecking=no"
+ "UserKnownHostsFile=/dev/null"
+ ];
};
};
- b = {
- services.openssh.enable = true;
- users.users.alice = {
- isNormalUser = true;
- openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
- };
+ services.locate = {
+ enable = true;
+ interval = "*:*:0/5";
};
};
+ b = {
+ services.openssh.enable = true;
+ users.users.alice = {
+ isNormalUser = true;
+ openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
+ };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- # Set up sshfs mount
- a.succeed(
- "(umask 077; cat ${snakeOilPrivateKey} > /privkey)"
- )
- b.succeed("touch /file-on-b-machine")
- b.wait_for_open_port(22)
- a.succeed("mkdir /ssh")
- a.succeed("mount /ssh")
+ # Set up sshfs mount
+ a.succeed(
+ "(umask 077; cat ${snakeOilPrivateKey} > /privkey)"
+ )
+ b.succeed("touch /file-on-b-machine")
+ b.wait_for_open_port(22)
+ a.succeed("mkdir /ssh")
+ a.succeed("mount /ssh")
- # Core locatedb functionality
- a.succeed("touch /file-on-a-machine-1")
- a.wait_for_file("/var/cache/locatedb")
- a.wait_until_succeeds("locate file-on-a-machine-1")
+ # Core locatedb functionality
+ a.succeed("touch /file-on-a-machine-1")
+ a.wait_for_file("/var/cache/locatedb")
+ a.wait_until_succeeds("locate file-on-a-machine-1")
- # Wait for a second update to make sure we're using a locatedb from a run
- # that began after the sshfs mount
- a.succeed("touch /file-on-a-machine-2")
- a.wait_until_succeeds("locate file-on-a-machine-2")
+ # Wait for a second update to make sure we're using a locatedb from a run
+ # that began after the sshfs mount
+ a.succeed("touch /file-on-a-machine-2")
+ a.wait_until_succeeds("locate file-on-a-machine-2")
- # We shouldn't be able to see files on the other machine
- a.fail("locate file-on-b-machine")
- '';
- }
-)
+ # We shouldn't be able to see files on the other machine
+ a.fail("locate file-on-b-machine")
+ '';
+}
diff --git a/nixos/tests/login.nix b/nixos/tests/login.nix
index acfb270193ab..b5b710215ca2 100644
--- a/nixos/tests/login.nix
+++ b/nixos/tests/login.nix
@@ -1,74 +1,72 @@
-import ./make-test-python.nix (
- {
- pkgs,
- latestKernel ? false,
- ...
- }:
+{
+ pkgs,
+ latestKernel ? false,
+ ...
+}:
- {
- name = "login";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
+{
+ name = "login";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
+
+ nodes.machine =
+ { pkgs, lib, ... }:
+ {
+ boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
};
- nodes.machine =
- { pkgs, lib, ... }:
- {
- boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
- };
+ testScript = ''
+ machine.start(allow_reboot = True)
- testScript = ''
- machine.start(allow_reboot = True)
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+ machine.screenshot("postboot")
- machine.wait_for_unit("multi-user.target")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
- machine.screenshot("postboot")
+ with subtest("create user"):
+ machine.succeed("useradd -m alice")
+ machine.succeed("(echo foobar; echo foobar) | passwd alice")
- with subtest("create user"):
- machine.succeed("useradd -m alice")
- machine.succeed("(echo foobar; echo foobar) | passwd alice")
+ with subtest("Check whether switching VTs works"):
+ machine.fail("pgrep -f 'agetty.*tty2'")
+ machine.send_key("alt-f2")
+ machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
+ machine.wait_for_unit("getty@tty2.service")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
- with subtest("Check whether switching VTs works"):
- machine.fail("pgrep -f 'agetty.*tty2'")
- machine.send_key("alt-f2")
- machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
- machine.wait_for_unit("getty@tty2.service")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
+ with subtest("Log in as alice on a virtual console"):
+ machine.wait_until_tty_matches("2", "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches("2", "login: alice")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches("2", "Password: ")
+ machine.send_chars("foobar\n")
+ machine.wait_until_succeeds("pgrep -u alice bash")
+ machine.send_chars("touch done\n")
+ machine.wait_for_file("/home/alice/done")
- with subtest("Log in as alice on a virtual console"):
- machine.wait_until_tty_matches("2", "login: ")
- machine.send_chars("alice\n")
- machine.wait_until_tty_matches("2", "login: alice")
- machine.wait_until_succeeds("pgrep login")
- machine.wait_until_tty_matches("2", "Password: ")
- machine.send_chars("foobar\n")
- machine.wait_until_succeeds("pgrep -u alice bash")
- machine.send_chars("touch done\n")
- machine.wait_for_file("/home/alice/done")
+ with subtest("Systemd gives and removes device ownership as needed"):
+ machine.succeed("getfacl /dev/snd/timer | grep -q alice")
+ machine.send_key("alt-f1")
+ machine.wait_until_succeeds("[ $(fgconsole) = 1 ]")
+ machine.fail("getfacl /dev/snd/timer | grep -q alice")
+ machine.succeed("chvt 2")
+ machine.wait_until_succeeds("getfacl /dev/snd/timer | grep -q alice")
- with subtest("Systemd gives and removes device ownership as needed"):
- machine.succeed("getfacl /dev/snd/timer | grep -q alice")
- machine.send_key("alt-f1")
- machine.wait_until_succeeds("[ $(fgconsole) = 1 ]")
- machine.fail("getfacl /dev/snd/timer | grep -q alice")
- machine.succeed("chvt 2")
- machine.wait_until_succeeds("getfacl /dev/snd/timer | grep -q alice")
+ with subtest("Virtual console logout"):
+ machine.send_chars("exit\n")
+ machine.wait_until_fails("pgrep -u alice bash")
+ machine.screenshot("getty")
- with subtest("Virtual console logout"):
- machine.send_chars("exit\n")
- machine.wait_until_fails("pgrep -u alice bash")
- machine.screenshot("getty")
+ with subtest("Check whether ctrl-alt-delete works"):
+ boot_id1 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
+ assert boot_id1 != ""
- with subtest("Check whether ctrl-alt-delete works"):
- boot_id1 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
- assert boot_id1 != ""
+ machine.reboot()
- machine.reboot()
+ boot_id2 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
+ assert boot_id2 != ""
- boot_id2 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
- assert boot_id2 != ""
-
- assert boot_id1 != boot_id2
- '';
- }
-)
+ assert boot_id1 != boot_id2
+ '';
+}
diff --git a/nixos/tests/loki.nix b/nixos/tests/loki.nix
index 8f5e23c3ac08..9c08c4312c97 100644
--- a/nixos/tests/loki.nix
+++ b/nixos/tests/loki.nix
@@ -1,65 +1,63 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- {
- name = "loki";
+{
+ name = "loki";
- meta = with lib.maintainers; {
- maintainers = [ willibutz ];
- };
+ meta = with lib.maintainers; {
+ maintainers = [ willibutz ];
+ };
- nodes.machine =
- { ... }:
- {
- services.loki = {
- enable = true;
+ nodes.machine =
+ { ... }:
+ {
+ services.loki = {
+ enable = true;
- # FIXME(globin) revert to original file when upstream fix released
- # configFile = "${pkgs.grafana-loki.src}/cmd/loki/loki-local-config.yaml";
- configFile = pkgs.runCommandNoCC "patched-loki-cfg.yml" { } ''
- sed '/metric_aggregation/!b;n;/enable/d' "${pkgs.grafana-loki.src}/cmd/loki/loki-local-config.yaml" > $out
- '';
- };
- services.promtail = {
- enable = true;
- configuration = {
- server = {
- http_listen_port = 9080;
- grpc_listen_port = 0;
- };
- clients = [ { url = "http://localhost:3100/loki/api/v1/push"; } ];
- scrape_configs = [
- {
- job_name = "system";
- static_configs = [
- {
- targets = [ "localhost" ];
- labels = {
- job = "varlogs";
- __path__ = "/var/log/*log";
- };
- }
- ];
- }
- ];
+ # FIXME(globin) revert to original file when upstream fix released
+ # configFile = "${pkgs.grafana-loki.src}/cmd/loki/loki-local-config.yaml";
+ configFile = pkgs.runCommandNoCC "patched-loki-cfg.yml" { } ''
+ sed '/metric_aggregation/!b;n;/enable/d' "${pkgs.grafana-loki.src}/cmd/loki/loki-local-config.yaml" > $out
+ '';
+ };
+ services.promtail = {
+ enable = true;
+ configuration = {
+ server = {
+ http_listen_port = 9080;
+ grpc_listen_port = 0;
};
+ clients = [ { url = "http://localhost:3100/loki/api/v1/push"; } ];
+ scrape_configs = [
+ {
+ job_name = "system";
+ static_configs = [
+ {
+ targets = [ "localhost" ];
+ labels = {
+ job = "varlogs";
+ __path__ = "/var/log/*log";
+ };
+ }
+ ];
+ }
+ ];
};
};
+ };
- testScript = ''
- machine.start
- machine.wait_for_unit("loki.service")
- machine.wait_for_unit("promtail.service")
- machine.wait_for_open_port(3100)
- machine.wait_for_open_port(9080)
- machine.succeed("echo 'Loki Ingestion Test' > /var/log/testlog")
- # should not have access to journal unless specified
- machine.fail(
- "systemctl show --property=SupplementaryGroups promtail | grep -q systemd-journal"
- )
- machine.wait_until_succeeds(
- "${pkgs.grafana-loki}/bin/logcli --addr='http://localhost:3100' query --no-labels '{job=\"varlogs\",filename=\"/var/log/testlog\"}' | grep -q 'Loki Ingestion Test'"
- )
- '';
- }
-)
+ testScript = ''
+ machine.start
+ machine.wait_for_unit("loki.service")
+ machine.wait_for_unit("promtail.service")
+ machine.wait_for_open_port(3100)
+ machine.wait_for_open_port(9080)
+ machine.succeed("echo 'Loki Ingestion Test' > /var/log/testlog")
+ # should not have access to journal unless specified
+ machine.fail(
+ "systemctl show --property=SupplementaryGroups promtail | grep -q systemd-journal"
+ )
+ machine.wait_until_succeeds(
+ "${pkgs.grafana-loki}/bin/logcli --addr='http://localhost:3100' query --no-labels '{job=\"varlogs\",filename=\"/var/log/testlog\"}' | grep -q 'Loki Ingestion Test'"
+ )
+ '';
+}
diff --git a/nixos/tests/luks.nix b/nixos/tests/luks.nix
index 15489343b707..685643c4c9dc 100644
--- a/nixos/tests/luks.nix
+++ b/nixos/tests/luks.nix
@@ -1,81 +1,79 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "luks";
+{ lib, pkgs, ... }:
+{
+ name = "luks";
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ./common/auto-format-root-device.nix ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ./common/auto-format-root-device.nix ];
- # Use systemd-boot
- virtualisation = {
- emptyDiskImages = [
- 512
- 512
- ];
- useBootLoader = true;
- useEFIBoot = true;
- # To boot off the encrypted disk, we need to have a init script which comes from the Nix store
- mountHostNixStore = true;
- };
- boot.loader.systemd-boot.enable = true;
-
- boot.kernelParams = lib.mkOverride 5 [ "console=tty1" ];
-
- environment.systemPackages = with pkgs; [ cryptsetup ];
-
- specialisation = rec {
- boot-luks.configuration = {
- boot.initrd.luks.devices = lib.mkVMOverride {
- # We have two disks and only type one password - key reuse is in place
- cryptroot.device = "/dev/vdb";
- cryptroot2.device = "/dev/vdc";
- };
- virtualisation.rootDevice = "/dev/mapper/cryptroot";
- };
- boot-luks-custom-keymap.configuration = lib.mkMerge [
- boot-luks.configuration
- {
- console.keyMap = "neo";
- }
- ];
- };
+ # Use systemd-boot
+ virtualisation = {
+ emptyDiskImages = [
+ 512
+ 512
+ ];
+ useBootLoader = true;
+ useEFIBoot = true;
+ # To boot off the encrypted disk, we need to have a init script which comes from the Nix store
+ mountHostNixStore = true;
};
+ boot.loader.systemd-boot.enable = true;
- enableOCR = true;
+ boot.kernelParams = lib.mkOverride 5 [ "console=tty1" ];
- testScript = ''
- # Create encrypted volume
- machine.wait_for_unit("multi-user.target")
- machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdb -")
- machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdc -")
+ environment.systemPackages = with pkgs; [ cryptsetup ];
- # Boot from the encrypted disk
- machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks.conf")
- machine.succeed("sync")
- machine.crash()
+ specialisation = rec {
+ boot-luks.configuration = {
+ boot.initrd.luks.devices = lib.mkVMOverride {
+ # We have two disks and only type one password - key reuse is in place
+ cryptroot.device = "/dev/vdb";
+ cryptroot2.device = "/dev/vdc";
+ };
+ virtualisation.rootDevice = "/dev/mapper/cryptroot";
+ };
+ boot-luks-custom-keymap.configuration = lib.mkMerge [
+ boot-luks.configuration
+ {
+ console.keyMap = "neo";
+ }
+ ];
+ };
+ };
- # Boot and decrypt the disk
- machine.start()
- machine.wait_for_text("Passphrase for")
- machine.send_chars("supersecret\n")
- machine.wait_for_unit("multi-user.target")
+ enableOCR = true;
- assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
+ testScript = ''
+ # Create encrypted volume
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdb -")
+ machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdc -")
- # Boot from the encrypted disk with custom keymap
- machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks-custom-keymap.conf")
- machine.succeed("sync")
- machine.crash()
+ # Boot from the encrypted disk
+ machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks.conf")
+ machine.succeed("sync")
+ machine.crash()
- # Boot and decrypt the disk
- machine.start()
- machine.wait_for_text("Passphrase for")
- machine.send_chars("havfkhfrkfl\n")
- machine.wait_for_unit("multi-user.target")
+ # Boot and decrypt the disk
+ machine.start()
+ machine.wait_for_text("Passphrase for")
+ machine.send_chars("supersecret\n")
+ machine.wait_for_unit("multi-user.target")
- assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
- '';
- }
-)
+ assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
+
+ # Boot from the encrypted disk with custom keymap
+ machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks-custom-keymap.conf")
+ machine.succeed("sync")
+ machine.crash()
+
+ # Boot and decrypt the disk
+ machine.start()
+ machine.wait_for_text("Passphrase for")
+ machine.send_chars("havfkhfrkfl\n")
+ machine.wait_for_unit("multi-user.target")
+
+ assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
+ '';
+}
diff --git a/nixos/tests/lxd-image-server.nix b/nixos/tests/lxd-image-server.nix
index 4b0b1259f404..498f17ef56a2 100644
--- a/nixos/tests/lxd-image-server.nix
+++ b/nixos/tests/lxd-image-server.nix
@@ -1,102 +1,100 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- lxd-image = import ../release.nix {
- configuration = {
- # Building documentation makes the test unnecessarily take a longer time:
- documentation.enable = lib.mkForce false;
- };
+let
+ lxd-image = import ../release.nix {
+ configuration = {
+ # Building documentation makes the test unnecessarily take a longer time:
+ documentation.enable = lib.mkForce false;
};
+ };
- lxd-image-metadata = lxd-image.lxdContainerMeta.${pkgs.stdenv.hostPlatform.system};
- lxd-image-rootfs = lxd-image.lxdContainerImage.${pkgs.stdenv.hostPlatform.system};
+ lxd-image-metadata = lxd-image.lxdContainerMeta.${pkgs.stdenv.hostPlatform.system};
+ lxd-image-rootfs = lxd-image.lxdContainerImage.${pkgs.stdenv.hostPlatform.system};
- in
- {
- name = "lxd-image-server";
+in
+{
+ name = "lxd-image-server";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- mkg20001
- patryk27
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ mkg20001
+ patryk27
+ ];
+ };
+
+ nodes.machine =
+ { lib, ... }:
+ {
+ virtualisation = {
+ cores = 2;
+
+ memorySize = 2048;
+ diskSize = 4096;
+
+ lxc.lxcfs.enable = true;
+ lxd.enable = true;
+ };
+
+ security.pki.certificates = [
+ (builtins.readFile ./common/acme/server/ca.cert.pem)
];
- };
- nodes.machine =
- { lib, ... }:
- {
- virtualisation = {
- cores = 2;
+ services.nginx = {
+ enable = true;
+ };
- memorySize = 2048;
- diskSize = 4096;
-
- lxc.lxcfs.enable = true;
- lxd.enable = true;
- };
-
- security.pki.certificates = [
- (builtins.readFile ./common/acme/server/ca.cert.pem)
- ];
-
- services.nginx = {
+ services.lxd-image-server = {
+ enable = true;
+ nginx = {
enable = true;
- };
-
- services.lxd-image-server = {
- enable = true;
- nginx = {
- enable = true;
- domain = "acme.test";
- };
- };
-
- services.nginx.virtualHosts."acme.test" = {
- enableACME = false;
- sslCertificate = ./common/acme/server/acme.test.cert.pem;
- sslCertificateKey = ./common/acme/server/acme.test.key.pem;
- };
-
- networking.hosts = {
- "::1" = [ "acme.test" ];
+ domain = "acme.test";
};
};
- testScript = ''
- machine.wait_for_unit("sockets.target")
- machine.wait_for_unit("lxd.service")
- machine.wait_for_file("/var/lib/lxd/unix.socket")
+ services.nginx.virtualHosts."acme.test" = {
+ enableACME = false;
+ sslCertificate = ./common/acme/server/acme.test.cert.pem;
+ sslCertificateKey = ./common/acme/server/acme.test.key.pem;
+ };
- # Wait for lxd to settle
- machine.succeed("lxd waitready")
+ networking.hosts = {
+ "::1" = [ "acme.test" ];
+ };
+ };
- # lxd expects the pool's directory to already exist
- machine.succeed("mkdir /var/lxd-pool")
+ testScript = ''
+ machine.wait_for_unit("sockets.target")
+ machine.wait_for_unit("lxd.service")
+ machine.wait_for_file("/var/lib/lxd/unix.socket")
- machine.succeed(
- "lxd init --minimal"
- )
+ # Wait for lxd to settle
+ machine.succeed("lxd waitready")
- machine.succeed(
- "lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-rootfs}/*/*.tar.xz --alias nixos"
- )
+ # lxd expects the pool's directory to already exist
+ machine.succeed("mkdir /var/lxd-pool")
- loc = "/var/www/simplestreams/images/iats/nixos/amd64/default/v1"
+ machine.succeed(
+ "lxd init --minimal"
+ )
- with subtest("push image to server"):
- machine.succeed("lxc launch nixos test")
- machine.sleep(5)
- machine.succeed("lxc stop -f test")
- machine.succeed("lxc publish --public test --alias=testimg")
- machine.succeed("lxc image export testimg")
- machine.succeed("ls >&2")
- machine.succeed("mkdir -p " + loc)
- machine.succeed("mv *.tar.gz " + loc)
+ machine.succeed(
+ "lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-rootfs}/*/*.tar.xz --alias nixos"
+ )
- with subtest("pull image from server"):
- machine.succeed("lxc remote add img https://acme.test --protocol=simplestreams")
- machine.succeed("lxc image list img: >&2")
- '';
- }
-)
+ loc = "/var/www/simplestreams/images/iats/nixos/amd64/default/v1"
+
+ with subtest("push image to server"):
+ machine.succeed("lxc launch nixos test")
+ machine.sleep(5)
+ machine.succeed("lxc stop -f test")
+ machine.succeed("lxc publish --public test --alias=testimg")
+ machine.succeed("lxc image export testimg")
+ machine.succeed("ls >&2")
+ machine.succeed("mkdir -p " + loc)
+ machine.succeed("mv *.tar.gz " + loc)
+
+ with subtest("pull image from server"):
+ machine.succeed("lxc remote add img https://acme.test --protocol=simplestreams")
+ machine.succeed("lxc image list img: >&2")
+ '';
+}
diff --git a/nixos/tests/lxqt.nix b/nixos/tests/lxqt.nix
index f2d5bb513ce8..a685a21536bb 100644
--- a/nixos/tests/lxqt.nix
+++ b/nixos/tests/lxqt.nix
@@ -1,80 +1,78 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- {
- name = "lxqt";
+{
+ name = "lxqt";
- meta.maintainers = lib.teams.lxqt.members ++ [ lib.maintainers.bobby285271 ];
+ meta.maintainers = lib.teams.lxqt.members ++ [ lib.maintainers.bobby285271 ];
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [ ./common/user-account.nix ];
+ {
+ imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.xserver.desktopManager.lxqt.enable = true;
+ services.xserver.enable = true;
+ services.xserver.desktopManager.lxqt.enable = true;
- services.displayManager = {
- sddm.enable = true;
- defaultSession = "lxqt";
- autoLogin = {
- enable = true;
- user = "alice";
- };
+ services.displayManager = {
+ sddm.enable = true;
+ defaultSession = "lxqt";
+ autoLogin = {
+ enable = true;
+ user = "alice";
};
};
+ };
- enableOCR = true;
+ enableOCR = true;
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
- ''
- machine.wait_for_unit("display-manager.service")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
+ ''
+ machine.wait_for_unit("display-manager.service")
- with subtest("Wait for login"):
- machine.wait_for_x()
- machine.wait_for_file("/tmp/xauth_*")
- machine.succeed("xauth merge /tmp/xauth_*")
- machine.succeed("su - ${user.name} -c 'xauth merge /tmp/xauth_*'")
+ with subtest("Wait for login"):
+ machine.wait_for_x()
+ machine.wait_for_file("/tmp/xauth_*")
+ machine.succeed("xauth merge /tmp/xauth_*")
+ machine.succeed("su - ${user.name} -c 'xauth merge /tmp/xauth_*'")
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Check if LXQt components actually start"):
- for i in ["openbox", "lxqt-session", "pcmanfm-qt", "lxqt-panel", "lxqt-runner"]:
- machine.wait_until_succeeds(f"pgrep {i}")
- machine.wait_for_window("pcmanfm-desktop0")
- machine.wait_for_window("lxqt-panel")
- machine.wait_for_text("(Computer|Network|Trash)")
+ with subtest("Check if LXQt components actually start"):
+ for i in ["openbox", "lxqt-session", "pcmanfm-qt", "lxqt-panel", "lxqt-runner"]:
+ machine.wait_until_succeeds(f"pgrep {i}")
+ machine.wait_for_window("pcmanfm-desktop0")
+ machine.wait_for_window("lxqt-panel")
+ machine.wait_for_text("(Computer|Network|Trash)")
- with subtest("Open QTerminal"):
- machine.succeed("su - ${user.name} -c 'DISPLAY=:0 qterminal >&2 &'")
- machine.wait_until_succeeds("pgrep qterminal")
- machine.wait_for_window("${user.name}@machine: ~")
+ with subtest("Open QTerminal"):
+ machine.succeed("su - ${user.name} -c 'DISPLAY=:0 qterminal >&2 &'")
+ machine.wait_until_succeeds("pgrep qterminal")
+ machine.wait_for_window("${user.name}@machine: ~")
- with subtest("Open PCManFM-Qt"):
- machine.succeed("mkdir -p /tmp/test/test")
- machine.succeed("su - ${user.name} -c 'DISPLAY=:0 QT_SCALE_FACTOR=2 pcmanfm-qt /tmp/test >&2 &'")
- machine.wait_for_window("test")
- machine.wait_for_text("(test|Bookmarks|Reload)")
+ with subtest("Open PCManFM-Qt"):
+ machine.succeed("mkdir -p /tmp/test/test")
+ machine.succeed("su - ${user.name} -c 'DISPLAY=:0 QT_SCALE_FACTOR=2 pcmanfm-qt /tmp/test >&2 &'")
+ machine.wait_for_window("test")
+ machine.wait_for_text("(test|Bookmarks|Reload)")
- with subtest("Check if various environment variables are set"):
- cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf /run/current-system/sw/bin/lxqt-panel)/environ"
- machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP=LXQt'")
- machine.succeed(f"{cmd} | grep 'QT_PLATFORM_PLUGIN=lxqt'")
- # From login shell.
- machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE=1'")
- # See the nixos/lxqt module.
- machine.succeed(f"{cmd} | grep 'XDG_CONFIG_DIRS' | grep '${nodes.machine.system.path}'")
+ with subtest("Check if various environment variables are set"):
+ cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf /run/current-system/sw/bin/lxqt-panel)/environ"
+ machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP=LXQt'")
+ machine.succeed(f"{cmd} | grep 'QT_PLATFORM_PLUGIN=lxqt'")
+ # From login shell.
+ machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE=1'")
+ # See the nixos/lxqt module.
+ machine.succeed(f"{cmd} | grep 'XDG_CONFIG_DIRS' | grep '${nodes.machine.system.path}'")
- with subtest("Check if any coredumps are found"):
- machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'")
- machine.sleep(10)
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Check if any coredumps are found"):
+ machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'")
+ machine.sleep(10)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/ly.nix b/nixos/tests/ly.nix
index 04c6ed9c7774..4791bf8056f2 100644
--- a/nixos/tests/ly.nix
+++ b/nixos/tests/ly.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { ... }:
+{ ... }:
- {
- name = "ly";
+{
+ name = "ly";
- nodes.machine =
- { ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.displayManager.ly = {
- enable = true;
- settings = {
- load = false;
- save = false;
- };
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ./common/user-account.nix ];
+ services.displayManager.ly = {
+ enable = true;
+ settings = {
+ load = false;
+ save = false;
};
- services.xserver.enable = true;
- services.displayManager.defaultSession = "none+icewm";
- services.xserver.windowManager.icewm.enable = true;
};
+ services.xserver.enable = true;
+ services.displayManager.defaultSession = "none+icewm";
+ services.xserver.windowManager.icewm.enable = true;
+ };
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
- ''
- start_all()
- machine.wait_until_tty_matches("2", "password:")
- machine.send_key("ctrl-alt-f2")
- machine.sleep(1)
- machine.screenshot("ly")
- machine.send_chars("alice")
- machine.send_key("tab")
- machine.send_chars("${user.password}")
- machine.send_key("ret")
- machine.wait_for_file("/run/user/${toString user.uid}/lyxauth")
- machine.succeed("xauth merge /run/user/${toString user.uid}/lyxauth")
- machine.wait_for_window("^IceWM ")
- machine.screenshot("icewm")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
+ ''
+ start_all()
+ machine.wait_until_tty_matches("2", "password:")
+ machine.send_key("ctrl-alt-f2")
+ machine.sleep(1)
+ machine.screenshot("ly")
+ machine.send_chars("alice")
+ machine.send_key("tab")
+ machine.send_chars("${user.password}")
+ machine.send_key("ret")
+ machine.wait_for_file("/run/user/${toString user.uid}/lyxauth")
+ machine.succeed("xauth merge /run/user/${toString user.uid}/lyxauth")
+ machine.wait_for_window("^IceWM ")
+ machine.screenshot("icewm")
+ '';
+}
diff --git a/nixos/tests/maestral.nix b/nixos/tests/maestral.nix
index aa510897d0d7..9b42b2d59e28 100644
--- a/nixos/tests/maestral.nix
+++ b/nixos/tests/maestral.nix
@@ -1,83 +1,81 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "maestral";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ peterhoeg ];
+{ pkgs, ... }:
+{
+ name = "maestral";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ peterhoeg ];
+ };
+
+ nodes =
+ let
+ common =
+ attrs:
+ pkgs.lib.recursiveUpdate {
+ imports = [ ./common/user-account.nix ];
+ systemd.user.services.maestral = {
+ description = "Maestral Dropbox Client";
+ serviceConfig.Type = "exec";
+ };
+ } attrs;
+
+ in
+ {
+ cli =
+ { ... }:
+ common {
+ systemd.user.services.maestral = {
+ wantedBy = [ "default.target" ];
+ serviceConfig.ExecStart = "${pkgs.maestral}/bin/maestral start --foreground";
+ };
+ };
+
+ gui =
+ { ... }:
+ common {
+ services.xserver = {
+ enable = true;
+ desktopManager.plasma5.enable = true;
+ desktopManager.plasma5.runUsingSystemd = true;
+ };
+
+ services.displayManager = {
+ sddm.enable = true;
+ defaultSession = "plasma";
+ autoLogin = {
+ enable = true;
+ user = "alice";
+ };
+ };
+
+ systemd.user.services = {
+ maestral = {
+ wantedBy = [ "graphical-session.target" ];
+ serviceConfig.ExecStart = "${pkgs.maestral-gui}/bin/maestral_qt";
+ };
+ # PowerDevil doesn't like our VM
+ plasma-powerdevil.enable = false;
+ };
+ };
};
- nodes =
- let
- common =
- attrs:
- pkgs.lib.recursiveUpdate {
- imports = [ ./common/user-account.nix ];
- systemd.user.services.maestral = {
- description = "Maestral Dropbox Client";
- serviceConfig.Type = "exec";
- };
- } attrs;
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.cli.users.users.alice;
+ in
+ ''
+ start_all()
- in
- {
- cli =
- { ... }:
- common {
- systemd.user.services.maestral = {
- wantedBy = [ "default.target" ];
- serviceConfig.ExecStart = "${pkgs.maestral}/bin/maestral start --foreground";
- };
- };
+ with subtest("CLI"):
+ # we need SOME way to give the user an active login session
+ cli.execute("loginctl enable-linger ${user.name}")
+ cli.systemctl("start user@${toString user.uid}")
+ cli.wait_for_unit("maestral.service", "${user.name}")
- gui =
- { ... }:
- common {
- services.xserver = {
- enable = true;
- desktopManager.plasma5.enable = true;
- desktopManager.plasma5.runUsingSystemd = true;
- };
-
- services.displayManager = {
- sddm.enable = true;
- defaultSession = "plasma";
- autoLogin = {
- enable = true;
- user = "alice";
- };
- };
-
- systemd.user.services = {
- maestral = {
- wantedBy = [ "graphical-session.target" ];
- serviceConfig.ExecStart = "${pkgs.maestral-gui}/bin/maestral_qt";
- };
- # PowerDevil doesn't like our VM
- plasma-powerdevil.enable = false;
- };
- };
- };
-
- testScript =
- { nodes, ... }:
- let
- user = nodes.cli.users.users.alice;
- in
- ''
- start_all()
-
- with subtest("CLI"):
- # we need SOME way to give the user an active login session
- cli.execute("loginctl enable-linger ${user.name}")
- cli.systemctl("start user@${toString user.uid}")
- cli.wait_for_unit("maestral.service", "${user.name}")
-
- with subtest("GUI"):
- gui.wait_for_x()
- gui.wait_for_file("/tmp/xauth_*")
- gui.succeed("xauth merge /tmp/xauth_*")
- gui.wait_for_window("^Desktop ")
- gui.wait_for_unit("maestral.service", "${user.name}")
- '';
- }
-)
+ with subtest("GUI"):
+ gui.wait_for_x()
+ gui.wait_for_file("/tmp/xauth_*")
+ gui.succeed("xauth merge /tmp/xauth_*")
+ gui.wait_for_window("^Desktop ")
+ gui.wait_for_unit("maestral.service", "${user.name}")
+ '';
+}
diff --git a/nixos/tests/magnetico.nix b/nixos/tests/magnetico.nix
index 279d19d87778..294762fe146b 100644
--- a/nixos/tests/magnetico.nix
+++ b/nixos/tests/magnetico.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- port = 8081;
- in
- {
- name = "magnetico";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ rnhmjoj ];
+let
+ port = 8081;
+in
+{
+ name = "magnetico";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+
+ networking.firewall.allowedTCPPorts = [ 9000 ];
+
+ services.magnetico = {
+ enable = true;
+ crawler.port = 9000;
+ web.port = port;
+ web.credentials.user = "$2y$12$P88ZF6soFthiiAeXnz64aOWDsY3Dw7Yw8fZ6GtiqFNjknD70zDmNe";
+ };
};
- nodes.machine =
- { ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
-
- networking.firewall.allowedTCPPorts = [ 9000 ];
-
- services.magnetico = {
- enable = true;
- crawler.port = 9000;
- web.port = port;
- web.credentials.user = "$2y$12$P88ZF6soFthiiAeXnz64aOWDsY3Dw7Yw8fZ6GtiqFNjknD70zDmNe";
- };
- };
-
- testScript = ''
- start_all()
- machine.wait_for_unit("magneticod")
- machine.wait_for_unit("magneticow")
- machine.wait_for_open_port(${toString port})
- machine.succeed(
- "${pkgs.curl}/bin/curl --fail "
- + "-u user:password http://localhost:${toString port}"
- )
- machine.fail(
- "${pkgs.curl}/bin/curl --fail "
- + "-u user:wrongpwd http://localhost:${toString port}"
- )
- machine.shutdown()
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("magneticod")
+ machine.wait_for_unit("magneticow")
+ machine.wait_for_open_port(${toString port})
+ machine.succeed(
+ "${pkgs.curl}/bin/curl --fail "
+ + "-u user:password http://localhost:${toString port}"
+ )
+ machine.fail(
+ "${pkgs.curl}/bin/curl --fail "
+ + "-u user:wrongpwd http://localhost:${toString port}"
+ )
+ machine.shutdown()
+ '';
+}
diff --git a/nixos/tests/marytts.nix b/nixos/tests/marytts.nix
index 4c80cf5cc4e1..101f20662ea5 100644
--- a/nixos/tests/marytts.nix
+++ b/nixos/tests/marytts.nix
@@ -1,87 +1,85 @@
-import ./make-test-python.nix (
- { lib, ... }:
- let
- port = 59126;
- in
- {
- name = "marytts";
- meta.maintainers = with lib.maintainers; [ pluiedev ];
+{ lib, ... }:
+let
+ port = 59126;
+in
+{
+ name = "marytts";
+ meta.maintainers = with lib.maintainers; [ pluiedev ];
- nodes.machine =
- { pkgs, ... }:
- {
- networking.firewall.enable = false;
- networking.useDHCP = false;
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ networking.firewall.enable = false;
+ networking.useDHCP = false;
- services.marytts = {
- enable = true;
- inherit port;
+ services.marytts = {
+ enable = true;
+ inherit port;
- voices = [
- (pkgs.fetchzip {
- url = "https://github.com/marytts/voice-bits1-hsmm/releases/download/v5.2/voice-bits1-hsmm-5.2.zip";
- hash = "sha256-1nK+qZxjumMev7z5lgKr660NCKH5FDwvZ9sw/YYYeaA=";
- })
- ];
+ voices = [
+ (pkgs.fetchzip {
+ url = "https://github.com/marytts/voice-bits1-hsmm/releases/download/v5.2/voice-bits1-hsmm-5.2.zip";
+ hash = "sha256-1nK+qZxjumMev7z5lgKr660NCKH5FDwvZ9sw/YYYeaA=";
+ })
+ ];
- userDictionaries = [
- (pkgs.writeTextFile {
- name = "userdict-en_US.txt";
- destination = "/userdict-en_US.txt";
- text = ''
- amogus | @ - ' m @U - g @ s
- Nixpkgs | n I k s - ' p { - k @ - dZ @ s
- '';
- })
- ];
- };
+ userDictionaries = [
+ (pkgs.writeTextFile {
+ name = "userdict-en_US.txt";
+ destination = "/userdict-en_US.txt";
+ text = ''
+ amogus | @ - ' m @U - g @ s
+ Nixpkgs | n I k s - ' p { - k @ - dZ @ s
+ '';
+ })
+ ];
};
+ };
- testScript = ''
- from xml.etree import ElementTree
- from urllib.parse import urlencode
+ testScript = ''
+ from xml.etree import ElementTree
+ from urllib.parse import urlencode
- machine.wait_for_unit("marytts.service")
+ machine.wait_for_unit("marytts.service")
- with subtest("Checking health of MaryTTS server"):
- machine.wait_for_open_port(${toString port})
- assert 'Mary TTS server' in machine.succeed("curl 'localhost:${toString port}/version'")
+ with subtest("Checking health of MaryTTS server"):
+ machine.wait_for_open_port(${toString port})
+ assert 'Mary TTS server' in machine.succeed("curl 'localhost:${toString port}/version'")
- with subtest("Generating example MaryXML"):
- query = urlencode({
- 'datatype': 'RAWMARYXML',
- 'locale': 'en_US',
- })
- xml = machine.succeed(f"curl 'localhost:${toString port}/exampletext?{query}'")
- root = ElementTree.fromstring(xml)
- text = " ".join(root.itertext()).strip()
- assert text == "Welcome to the world of speech synthesis!"
+ with subtest("Generating example MaryXML"):
+ query = urlencode({
+ 'datatype': 'RAWMARYXML',
+ 'locale': 'en_US',
+ })
+ xml = machine.succeed(f"curl 'localhost:${toString port}/exampletext?{query}'")
+ root = ElementTree.fromstring(xml)
+ text = " ".join(root.itertext()).strip()
+ assert text == "Welcome to the world of speech synthesis!"
- with subtest("Detecting custom voice"):
- assert "bits1-hsmm" in machine.succeed("curl 'localhost:${toString port}/voices'")
+ with subtest("Detecting custom voice"):
+ assert "bits1-hsmm" in machine.succeed("curl 'localhost:${toString port}/voices'")
- with subtest("Finding user dictionary"):
- query = urlencode({
- 'INPUT_TEXT': 'amogus',
- 'INPUT_TYPE': 'TEXT',
- 'OUTPUT_TYPE': 'PHONEMES',
- 'LOCALE': 'en_US',
- })
- phonemes = machine.succeed(f"curl 'localhost:${toString port}/process?{query}'")
- phonemes_tree = ElementTree.fromstring(phonemes)
- print([i.get('ph') for i in phonemes_tree.iter('{http://mary.dfki.de/2002/MaryXML}t')])
- assert ["@ - ' m @U - g @ s"] == [i.get('ph') for i in phonemes_tree.iter('{http://mary.dfki.de/2002/MaryXML}t')]
+ with subtest("Finding user dictionary"):
+ query = urlencode({
+ 'INPUT_TEXT': 'amogus',
+ 'INPUT_TYPE': 'TEXT',
+ 'OUTPUT_TYPE': 'PHONEMES',
+ 'LOCALE': 'en_US',
+ })
+ phonemes = machine.succeed(f"curl 'localhost:${toString port}/process?{query}'")
+ phonemes_tree = ElementTree.fromstring(phonemes)
+ print([i.get('ph') for i in phonemes_tree.iter('{http://mary.dfki.de/2002/MaryXML}t')])
+ assert ["@ - ' m @U - g @ s"] == [i.get('ph') for i in phonemes_tree.iter('{http://mary.dfki.de/2002/MaryXML}t')]
- with subtest("Synthesizing"):
- query = urlencode({
- 'INPUT_TEXT': 'Nixpkgs is a collection of over 100,000 software packages that can be installed with the Nix package manager.',
- 'INPUT_TYPE': 'TEXT',
- 'OUTPUT_TYPE': 'AUDIO',
- 'AUDIO': 'WAVE_FILE',
- 'LOCALE': 'en_US',
- })
- machine.succeed(f"curl 'localhost:${toString port}/process?{query}' -o ./audio.wav")
- machine.copy_from_vm("./audio.wav")
- '';
- }
-)
+ with subtest("Synthesizing"):
+ query = urlencode({
+ 'INPUT_TEXT': 'Nixpkgs is a collection of over 100,000 software packages that can be installed with the Nix package manager.',
+ 'INPUT_TYPE': 'TEXT',
+ 'OUTPUT_TYPE': 'AUDIO',
+ 'AUDIO': 'WAVE_FILE',
+ 'LOCALE': 'en_US',
+ })
+ machine.succeed(f"curl 'localhost:${toString port}/process?{query}' -o ./audio.wav")
+ machine.copy_from_vm("./audio.wav")
+ '';
+}
diff --git a/nixos/tests/mate-wayland.nix b/nixos/tests/mate-wayland.nix
index bf0989b2cf1d..42b88439357a 100644
--- a/nixos/tests/mate-wayland.nix
+++ b/nixos/tests/mate-wayland.nix
@@ -1,67 +1,65 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "mate-wayland";
+{ pkgs, lib, ... }:
+{
+ name = "mate-wayland";
- meta.maintainers = lib.teams.mate.members;
+ meta.maintainers = lib.teams.mate.members;
- nodes.machine =
- { ... }:
- {
- imports = [
- ./common/user-account.nix
- ];
+ nodes.machine =
+ { ... }:
+ {
+ imports = [
+ ./common/user-account.nix
+ ];
- services.xserver.enable = true;
- services.displayManager = {
- sddm.enable = true; # https://github.com/canonical/lightdm/issues/63
- sddm.wayland.enable = true;
- defaultSession = "MATE";
- autoLogin = {
- enable = true;
- user = "alice";
- };
+ services.xserver.enable = true;
+ services.displayManager = {
+ sddm.enable = true; # https://github.com/canonical/lightdm/issues/63
+ sddm.wayland.enable = true;
+ defaultSession = "MATE";
+ autoLogin = {
+ enable = true;
+ user = "alice";
};
- services.xserver.desktopManager.mate.enableWaylandSession = true;
-
- # Need to switch to a different GPU driver than the default one (-vga std) so that wayfire can launch:
- virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
};
+ services.xserver.desktopManager.mate.enableWaylandSession = true;
- enableOCR = true;
+ # Need to switch to a different GPU driver than the default one (-vga std) so that wayfire can launch:
+ virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
+ };
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
- ''
- machine.wait_for_unit("display-manager.service")
+ enableOCR = true;
- with subtest("Wait for Wayland server"):
- machine.wait_for_file("/run/user/${toString user.uid}/wayland-1")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
+ ''
+ machine.wait_for_unit("display-manager.service")
- with subtest("Check if MATE session components actually start"):
- for i in ["wayfire", "mate-panel", "mate-wayland.sh"]:
- machine.wait_until_succeeds(f"pgrep {i}")
- machine.wait_until_succeeds("pgrep -f mate-wayland-components.sh")
- # It is expected that WorkspaceSwitcherApplet doesn't work in Wayland
- machine.wait_for_text('(panel|Factory|Workspace|Switcher|Applet|configuration)')
+ with subtest("Wait for Wayland server"):
+ machine.wait_for_file("/run/user/${toString user.uid}/wayland-1")
- with subtest("Check if various environment variables are set"):
- cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf mate-panel)/environ"
- machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
- machine.succeed(f"{cmd} | grep 'XDG_SESSION_DESKTOP' | grep 'MATE'")
- machine.succeed(f"{cmd} | grep 'MATE_PANEL_APPLETS_DIR' | grep '${pkgs.mate.mate-panel-with-applets.pname}'")
+ with subtest("Check if MATE session components actually start"):
+ for i in ["wayfire", "mate-panel", "mate-wayland.sh"]:
+ machine.wait_until_succeeds(f"pgrep {i}")
+ machine.wait_until_succeeds("pgrep -f mate-wayland-components.sh")
+ # It is expected that WorkspaceSwitcherApplet doesn't work in Wayland
+ machine.wait_for_text('(panel|Factory|Workspace|Switcher|Applet|configuration)')
- with subtest("Check if Wayfire config is properly configured"):
- for i in ["button_style = mate", "firedecor", "mate-wayland-components.sh"]:
- machine.wait_until_succeeds(f"cat /home/${user.name}/.config/mate/wayfire.ini | grep '{i}'")
+ with subtest("Check if various environment variables are set"):
+ cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf mate-panel)/environ"
+ machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
+ machine.succeed(f"{cmd} | grep 'XDG_SESSION_DESKTOP' | grep 'MATE'")
+ machine.succeed(f"{cmd} | grep 'MATE_PANEL_APPLETS_DIR' | grep '${pkgs.mate.mate-panel-with-applets.pname}'")
- with subtest("Check if Wayfire has ever coredumped"):
- machine.fail("coredumpctl --json=short | grep wayfire")
- machine.sleep(10)
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Check if Wayfire config is properly configured"):
+ for i in ["button_style = mate", "firedecor", "mate-wayland-components.sh"]:
+ machine.wait_until_succeeds(f"cat /home/${user.name}/.config/mate/wayfire.ini | grep '{i}'")
+
+ with subtest("Check if Wayfire has ever coredumped"):
+ machine.fail("coredumpctl --json=short | grep wayfire")
+ machine.sleep(10)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/mate.nix b/nixos/tests/mate.nix
index d0847be5ffa9..6112044837db 100644
--- a/nixos/tests/mate.nix
+++ b/nixos/tests/mate.nix
@@ -1,92 +1,90 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "mate";
+{ pkgs, lib, ... }:
+{
+ name = "mate";
- meta = {
- maintainers = lib.teams.mate.members;
- };
+ meta = {
+ maintainers = lib.teams.mate.members;
+ };
- nodes.machine =
- { ... }:
- {
- imports = [
- ./common/user-account.nix
- ];
+ nodes.machine =
+ { ... }:
+ {
+ imports = [
+ ./common/user-account.nix
+ ];
- services.xserver.enable = true;
+ services.xserver.enable = true;
- services.xserver.displayManager = {
- lightdm.enable = true;
- autoLogin = {
- enable = true;
- user = "alice";
- };
+ services.xserver.displayManager = {
+ lightdm.enable = true;
+ autoLogin = {
+ enable = true;
+ user = "alice";
};
-
- services.xserver.desktopManager.mate.enable = true;
};
- enableOCR = true;
+ services.xserver.desktopManager.mate.enable = true;
+ };
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- env = "DISPLAY=:0.0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus";
- in
- ''
- with subtest("Wait for login"):
- machine.wait_for_x()
- machine.wait_for_file("${user.home}/.Xauthority")
- machine.succeed("xauth merge ${user.home}/.Xauthority")
+ enableOCR = true;
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ env = "DISPLAY=:0.0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus";
+ in
+ ''
+ with subtest("Wait for login"):
+ machine.wait_for_x()
+ machine.wait_for_file("${user.home}/.Xauthority")
+ machine.succeed("xauth merge ${user.home}/.Xauthority")
- with subtest("Check if MATE session components actually start"):
- machine.wait_until_succeeds("pgrep marco")
- machine.wait_for_window("marco")
- machine.wait_until_succeeds("pgrep mate-panel")
- machine.wait_for_window("Top Panel")
- machine.wait_for_window("Bottom Panel")
- machine.wait_until_succeeds("pgrep caja")
- machine.wait_for_window("Caja")
- machine.wait_for_text('(Applications|Places|System)')
- machine.wait_for_text('(Computer|Home|Trash)')
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Check if various environment variables are set"):
- machine.succeed("xargs --null --max-args=1 echo < /proc/$(pgrep -xf marco)/environ | grep 'XDG_CURRENT_DESKTOP' | grep 'MATE'")
- # From mate-panel-with-applets packaging
- machine.succeed("xargs --null --max-args=1 echo < /proc/$(pgrep -xf mate-panel)/environ | grep 'MATE_PANEL_APPLETS_DIR' | grep '${pkgs.mate.mate-panel-with-applets.pname}'")
+ with subtest("Check if MATE session components actually start"):
+ machine.wait_until_succeeds("pgrep marco")
+ machine.wait_for_window("marco")
+ machine.wait_until_succeeds("pgrep mate-panel")
+ machine.wait_for_window("Top Panel")
+ machine.wait_for_window("Bottom Panel")
+ machine.wait_until_succeeds("pgrep caja")
+ machine.wait_for_window("Caja")
+ machine.wait_for_text('(Applications|Places|System)')
+ machine.wait_for_text('(Computer|Home|Trash)')
- with subtest("Check if applets are built with in-process support"):
- # This is needed for Wayland support
- machine.fail("pgrep -fa clock-applet")
+ with subtest("Check if various environment variables are set"):
+ machine.succeed("xargs --null --max-args=1 echo < /proc/$(pgrep -xf marco)/environ | grep 'XDG_CURRENT_DESKTOP' | grep 'MATE'")
+ # From mate-panel-with-applets packaging
+ machine.succeed("xargs --null --max-args=1 echo < /proc/$(pgrep -xf mate-panel)/environ | grep 'MATE_PANEL_APPLETS_DIR' | grep '${pkgs.mate.mate-panel-with-applets.pname}'")
- with subtest("Lock the screen"):
- machine.wait_until_succeeds("su - ${user.name} -c '${env} mate-screensaver-command -q' | grep 'The screensaver is inactive'")
- machine.succeed("su - ${user.name} -c '${env} mate-screensaver-command -l >&2 &'")
- machine.wait_until_succeeds("su - ${user.name} -c '${env} mate-screensaver-command -q' | grep 'The screensaver is active'")
- machine.sleep(2)
- machine.send_chars("${user.password}", delay=0.2)
- machine.wait_for_text("${user.description}")
- machine.screenshot("screensaver")
- machine.send_chars("\n")
- machine.wait_until_succeeds("su - ${user.name} -c '${env} mate-screensaver-command -q' | grep 'The screensaver is inactive'")
+ with subtest("Check if applets are built with in-process support"):
+ # This is needed for Wayland support
+ machine.fail("pgrep -fa clock-applet")
- with subtest("Open MATE control center"):
- machine.succeed("su - ${user.name} -c '${env} mate-control-center >&2 &'")
- machine.wait_for_window("Control Center")
- machine.wait_for_text('(Groups|Administration|Hardware)')
+ with subtest("Lock the screen"):
+ machine.wait_until_succeeds("su - ${user.name} -c '${env} mate-screensaver-command -q' | grep 'The screensaver is inactive'")
+ machine.succeed("su - ${user.name} -c '${env} mate-screensaver-command -l >&2 &'")
+ machine.wait_until_succeeds("su - ${user.name} -c '${env} mate-screensaver-command -q' | grep 'The screensaver is active'")
+ machine.sleep(2)
+ machine.send_chars("${user.password}", delay=0.2)
+ machine.wait_for_text("${user.description}")
+ machine.screenshot("screensaver")
+ machine.send_chars("\n")
+ machine.wait_until_succeeds("su - ${user.name} -c '${env} mate-screensaver-command -q' | grep 'The screensaver is inactive'")
- with subtest("Open MATE terminal"):
- machine.succeed("su - ${user.name} -c '${env} mate-terminal >&2 &'")
- machine.wait_for_window("Terminal")
+ with subtest("Open MATE control center"):
+ machine.succeed("su - ${user.name} -c '${env} mate-control-center >&2 &'")
+ machine.wait_for_window("Control Center")
+ machine.wait_for_text('(Groups|Administration|Hardware)')
- with subtest("Check if MATE has ever coredumped"):
- machine.fail("coredumpctl --json=short | grep -E 'mate|marco|caja'")
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Open MATE terminal"):
+ machine.succeed("su - ${user.name} -c '${env} mate-terminal >&2 &'")
+ machine.wait_for_window("Terminal")
+
+ with subtest("Check if MATE has ever coredumped"):
+ machine.fail("coredumpctl --json=short | grep -E 'mate|marco|caja'")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/matrix/conduit.nix b/nixos/tests/matrix/conduit.nix
index b38549b23ab4..874e7672812b 100644
--- a/nixos/tests/matrix/conduit.nix
+++ b/nixos/tests/matrix/conduit.nix
@@ -1,98 +1,96 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
- name = "conduit";
- in
- {
- name = "matrix-conduit";
+{ pkgs, ... }:
+let
+ name = "conduit";
+in
+{
+ name = "matrix-conduit";
- nodes = {
- conduit = args: {
- services.matrix-conduit = {
- enable = true;
- settings.global.server_name = name;
- settings.global.allow_registration = true;
- extraEnvironment.RUST_BACKTRACE = "yes";
- };
- services.nginx = {
- enable = true;
- virtualHosts.${name} = {
- enableACME = false;
- forceSSL = false;
- enableSSL = false;
+ nodes = {
+ conduit = args: {
+ services.matrix-conduit = {
+ enable = true;
+ settings.global.server_name = name;
+ settings.global.allow_registration = true;
+ extraEnvironment.RUST_BACKTRACE = "yes";
+ };
+ services.nginx = {
+ enable = true;
+ virtualHosts.${name} = {
+ enableACME = false;
+ forceSSL = false;
+ enableSSL = false;
- locations."/_matrix" = {
- proxyPass = "http://[::1]:6167";
- };
+ locations."/_matrix" = {
+ proxyPass = "http://[::1]:6167";
};
};
- networking.firewall.allowedTCPPorts = [ 80 ];
};
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [
- (pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
- import asyncio
-
- from nio import AsyncClient
-
-
- async def main() -> None:
- # Connect to conduit
- client = AsyncClient("http://conduit:80", "alice")
-
- # Register as user alice
- response = await client.register("alice", "my-secret-password")
-
- # Log in as user alice
- response = await client.login("my-secret-password")
-
- # Create a new room
- response = await client.room_create(federate=False)
- room_id = response.room_id
-
- # Join the room
- response = await client.join(room_id)
-
- # Send a message to the room
- response = await client.room_send(
- room_id=room_id,
- message_type="m.room.message",
- content={
- "msgtype": "m.text",
- "body": "Hello conduit!"
- }
- )
-
- # Sync responses
- response = await client.sync(timeout=30000)
-
- # Check the message was received by conduit
- last_message = response.rooms.join[room_id].timeline.events[-1].body
- assert last_message == "Hello conduit!"
-
- # Leave the room
- response = await client.room_leave(room_id)
-
- # Close the client
- await client.close()
-
- asyncio.get_event_loop().run_until_complete(main())
- '')
- ];
- };
+ networking.firewall.allowedTCPPorts = [ 80 ];
};
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [
+ (pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
+ import asyncio
- testScript = ''
- start_all()
+ from nio import AsyncClient
- with subtest("start conduit"):
- conduit.wait_for_unit("conduit.service")
- conduit.wait_for_open_port(80)
- with subtest("ensure messages can be exchanged"):
- client.succeed("do_test")
- '';
- }
-)
+ async def main() -> None:
+ # Connect to conduit
+ client = AsyncClient("http://conduit:80", "alice")
+
+ # Register as user alice
+ response = await client.register("alice", "my-secret-password")
+
+ # Log in as user alice
+ response = await client.login("my-secret-password")
+
+ # Create a new room
+ response = await client.room_create(federate=False)
+ room_id = response.room_id
+
+ # Join the room
+ response = await client.join(room_id)
+
+ # Send a message to the room
+ response = await client.room_send(
+ room_id=room_id,
+ message_type="m.room.message",
+ content={
+ "msgtype": "m.text",
+ "body": "Hello conduit!"
+ }
+ )
+
+ # Sync responses
+ response = await client.sync(timeout=30000)
+
+ # Check the message was received by conduit
+ last_message = response.rooms.join[room_id].timeline.events[-1].body
+ assert last_message == "Hello conduit!"
+
+ # Leave the room
+ response = await client.room_leave(room_id)
+
+ # Close the client
+ await client.close()
+
+ asyncio.get_event_loop().run_until_complete(main())
+ '')
+ ];
+ };
+ };
+
+ testScript = ''
+ start_all()
+
+ with subtest("start conduit"):
+ conduit.wait_for_unit("conduit.service")
+ conduit.wait_for_open_port(80)
+
+ with subtest("ensure messages can be exchanged"):
+ client.succeed("do_test")
+ '';
+}
diff --git a/nixos/tests/matrix/dendrite.nix b/nixos/tests/matrix/dendrite.nix
index 9796423a5bb7..4477f522a37b 100644
--- a/nixos/tests/matrix/dendrite.nix
+++ b/nixos/tests/matrix/dendrite.nix
@@ -1,102 +1,100 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
- homeserverUrl = "http://homeserver:8008";
+{ pkgs, ... }:
+let
+ homeserverUrl = "http://homeserver:8008";
- private_key = pkgs.runCommand "matrix_key.pem" {
- buildInputs = [ pkgs.dendrite ];
- } "generate-keys --private-key $out";
- in
- {
- name = "dendrite";
- meta = with pkgs.lib; {
- maintainers = teams.matrix.members;
- };
+ private_key = pkgs.runCommand "matrix_key.pem" {
+ buildInputs = [ pkgs.dendrite ];
+ } "generate-keys --private-key $out";
+in
+{
+ name = "dendrite";
+ meta = with pkgs.lib; {
+ maintainers = teams.matrix.members;
+ };
- nodes = {
- homeserver =
- { pkgs, ... }:
- {
- services.dendrite = {
- enable = true;
- loadCredential = [ "test_private_key:${private_key}" ];
- openRegistration = true;
- settings = {
- global.server_name = "test-dendrite-server.com";
- global.private_key = "$CREDENTIALS_DIRECTORY/test_private_key";
- client_api.registration_disabled = false;
- };
+ nodes = {
+ homeserver =
+ { pkgs, ... }:
+ {
+ services.dendrite = {
+ enable = true;
+ loadCredential = [ "test_private_key:${private_key}" ];
+ openRegistration = true;
+ settings = {
+ global.server_name = "test-dendrite-server.com";
+ global.private_key = "$CREDENTIALS_DIRECTORY/test_private_key";
+ client_api.registration_disabled = false;
};
-
- networking.firewall.allowedTCPPorts = [ 8008 ];
};
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [
- (pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
- import asyncio
+ networking.firewall.allowedTCPPorts = [ 8008 ];
+ };
- from nio import AsyncClient
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [
+ (pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
+ import asyncio
+
+ from nio import AsyncClient
- async def main() -> None:
- # Connect to dendrite
- client = AsyncClient("http://homeserver:8008", "alice")
+ async def main() -> None:
+ # Connect to dendrite
+ client = AsyncClient("http://homeserver:8008", "alice")
- # Register as user alice
- response = await client.register("alice", "my-secret-password")
+ # Register as user alice
+ response = await client.register("alice", "my-secret-password")
- # Log in as user alice
- response = await client.login("my-secret-password")
+ # Log in as user alice
+ response = await client.login("my-secret-password")
- # Create a new room
- response = await client.room_create(federate=False)
- room_id = response.room_id
+ # Create a new room
+ response = await client.room_create(federate=False)
+ room_id = response.room_id
- # Join the room
- response = await client.join(room_id)
+ # Join the room
+ response = await client.join(room_id)
- # Send a message to the room
- response = await client.room_send(
- room_id=room_id,
- message_type="m.room.message",
- content={
- "msgtype": "m.text",
- "body": "Hello world!"
- }
- )
+ # Send a message to the room
+ response = await client.room_send(
+ room_id=room_id,
+ message_type="m.room.message",
+ content={
+ "msgtype": "m.text",
+ "body": "Hello world!"
+ }
+ )
- # Sync responses
- response = await client.sync(timeout=30000)
+ # Sync responses
+ response = await client.sync(timeout=30000)
- # Check the message was received by dendrite
- last_message = response.rooms.join[room_id].timeline.events[-1].body
- assert last_message == "Hello world!"
+ # Check the message was received by dendrite
+ last_message = response.rooms.join[room_id].timeline.events[-1].body
+ assert last_message == "Hello world!"
- # Leave the room
- response = await client.room_leave(room_id)
+ # Leave the room
+ response = await client.room_leave(room_id)
- # Close the client
- await client.close()
+ # Close the client
+ await client.close()
- asyncio.get_event_loop().run_until_complete(main())
- '')
- ];
- };
- };
+ asyncio.get_event_loop().run_until_complete(main())
+ '')
+ ];
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- with subtest("start the homeserver"):
- homeserver.wait_for_unit("dendrite.service")
- homeserver.wait_for_open_port(8008)
+ with subtest("start the homeserver"):
+ homeserver.wait_for_unit("dendrite.service")
+ homeserver.wait_for_open_port(8008)
- with subtest("ensure messages can be exchanged"):
- client.succeed("do_test")
- '';
+ with subtest("ensure messages can be exchanged"):
+ client.succeed("do_test")
+ '';
- }
-)
+}
diff --git a/nixos/tests/matrix/mautrix-meta-postgres.nix b/nixos/tests/matrix/mautrix-meta-postgres.nix
index 99ed56477df3..72f12aa8db6a 100644
--- a/nixos/tests/matrix/mautrix-meta-postgres.nix
+++ b/nixos/tests/matrix/mautrix-meta-postgres.nix
@@ -1,236 +1,234 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
- homeserverDomain = "server";
- homeserverUrl = "http://server:8008";
- userName = "alice";
- botUserName = "instagrambot";
+{ pkgs, ... }:
+let
+ homeserverDomain = "server";
+ homeserverUrl = "http://server:8008";
+ userName = "alice";
+ botUserName = "instagrambot";
- asToken = "this-is-my-totally-randomly-generated-as-token";
- hsToken = "this-is-my-totally-randomly-generated-hs-token";
- in
- {
- name = "mautrix-meta-postgres";
- meta.maintainers = pkgs.mautrix-meta.meta.maintainers;
+ asToken = "this-is-my-totally-randomly-generated-as-token";
+ hsToken = "this-is-my-totally-randomly-generated-hs-token";
+in
+{
+ name = "mautrix-meta-postgres";
+ meta.maintainers = pkgs.mautrix-meta.meta.maintainers;
- nodes = {
- server =
- { config, pkgs, ... }:
- {
- services.postgresql = {
- enable = true;
+ nodes = {
+ server =
+ { config, pkgs, ... }:
+ {
+ services.postgresql = {
+ enable = true;
- ensureUsers = [
- {
- name = "mautrix-meta-instagram";
- ensureDBOwnership = true;
- }
- ];
+ ensureUsers = [
+ {
+ name = "mautrix-meta-instagram";
+ ensureDBOwnership = true;
+ }
+ ];
- ensureDatabases = [
- "mautrix-meta-instagram"
- ];
- };
-
- systemd.services.mautrix-meta-instagram = {
- wants = [ "postgres.service" ];
- after = [ "postgres.service" ];
- };
-
- services.matrix-synapse = {
- enable = true;
- settings = {
- database.name = "sqlite3";
-
- enable_registration = true;
-
- # don't use this in production, always use some form of verification
- enable_registration_without_verification = true;
-
- listeners = [
- {
- # The default but tls=false
- bind_addresses = [
- "0.0.0.0"
- ];
- port = 8008;
- resources = [
- {
- "compress" = true;
- "names" = [ "client" ];
- }
- {
- "compress" = false;
- "names" = [ "federation" ];
- }
- ];
- tls = false;
- type = "http";
- }
- ];
- };
- };
-
- services.mautrix-meta.instances.instagram = {
- enable = true;
-
- environmentFile = pkgs.writeText ''my-secrets'' ''
- AS_TOKEN=${asToken}
- HS_TOKEN=${hsToken}
- '';
-
- settings = {
- homeserver = {
- address = homeserverUrl;
- domain = homeserverDomain;
- };
-
- appservice = {
- port = 8009;
-
- as_token = "$AS_TOKEN";
- hs_token = "$HS_TOKEN";
-
- database = {
- type = "postgres";
- uri = "postgres:///mautrix-meta-instagram?host=/var/run/postgresql";
- };
-
- bot.username = botUserName;
- };
-
- bridge.permissions."@${userName}:server" = "user";
- };
- };
-
- networking.firewall.allowedTCPPorts = [
- 8008
- 8009
+ ensureDatabases = [
+ "mautrix-meta-instagram"
];
};
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [
- (pkgs.writers.writePython3Bin "do_test"
+ systemd.services.mautrix-meta-instagram = {
+ wants = [ "postgres.service" ];
+ after = [ "postgres.service" ];
+ };
+
+ services.matrix-synapse = {
+ enable = true;
+ settings = {
+ database.name = "sqlite3";
+
+ enable_registration = true;
+
+ # don't use this in production, always use some form of verification
+ enable_registration_without_verification = true;
+
+ listeners = [
{
- libraries = [ pkgs.python3Packages.matrix-nio ];
- flakeIgnore = [
- # We don't live in the dark ages anymore.
- # Languages like Python that are whitespace heavy will overrun
- # 79 characters..
- "E501"
+ # The default but tls=false
+ bind_addresses = [
+ "0.0.0.0"
];
+ port = 8008;
+ resources = [
+ {
+ "compress" = true;
+ "names" = [ "client" ];
+ }
+ {
+ "compress" = false;
+ "names" = [ "federation" ];
+ }
+ ];
+ tls = false;
+ type = "http";
}
- ''
- import sys
- import functools
- import asyncio
-
- from nio import AsyncClient, RoomMessageNotice, RoomCreateResponse, RoomInviteResponse
-
-
- async def message_callback(matrix: AsyncClient, msg: str, _r, e):
- print("Received matrix text message: ", e)
- assert msg in e.body
- exit(0) # Success!
-
-
- async def run(homeserver: str):
- matrix = AsyncClient(homeserver)
- response = await matrix.register("${userName}", "foobar")
- print("Matrix register response: ", response)
-
- # Open a DM with the bridge bot
- response = await matrix.room_create()
- print("Matrix create room response:", response)
- assert isinstance(response, RoomCreateResponse)
- room_id = response.room_id
-
- response = await matrix.room_invite(room_id, "@${botUserName}:${homeserverDomain}")
- assert isinstance(response, RoomInviteResponse)
-
- callback = functools.partial(
- message_callback, matrix, "Hello, I'm an Instagram bridge bot."
- )
- matrix.add_event_callback(callback, RoomMessageNotice)
-
- print("Waiting for matrix message...")
- await matrix.sync_forever(timeout=30000)
-
-
- if __name__ == "__main__":
- asyncio.run(run(sys.argv[1]))
- ''
- )
- ];
+ ];
+ };
};
- };
- testScript = ''
- def extract_token(data):
- stdout = data[1]
- stdout = stdout.strip()
- line = stdout.split('\n')[-1]
- return line.split(':')[-1].strip("\" '\n")
+ services.mautrix-meta.instances.instagram = {
+ enable = true;
- def get_token_from(token, file):
- data = server.execute(f"cat {file} | grep {token}")
- return extract_token(data)
+ environmentFile = pkgs.writeText ''my-secrets'' ''
+ AS_TOKEN=${asToken}
+ HS_TOKEN=${hsToken}
+ '';
- def get_as_token_from(file):
- return get_token_from("as_token", file)
+ settings = {
+ homeserver = {
+ address = homeserverUrl;
+ domain = homeserverDomain;
+ };
- def get_hs_token_from(file):
- return get_token_from("hs_token", file)
+ appservice = {
+ port = 8009;
- config_yaml = "/var/lib/mautrix-meta-instagram/config.yaml"
- registration_yaml = "/var/lib/mautrix-meta-instagram/meta-registration.yaml"
+ as_token = "$AS_TOKEN";
+ hs_token = "$HS_TOKEN";
- expected_as_token = "${asToken}"
- expected_hs_token = "${hsToken}"
+ database = {
+ type = "postgres";
+ uri = "postgres:///mautrix-meta-instagram?host=/var/run/postgresql";
+ };
- start_all()
+ bot.username = botUserName;
+ };
- with subtest("start the server"):
- # bridge
- server.wait_for_unit("mautrix-meta-instagram.service")
+ bridge.permissions."@${userName}:server" = "user";
+ };
+ };
- # homeserver
- server.wait_for_unit("matrix-synapse.service")
+ networking.firewall.allowedTCPPorts = [
+ 8008
+ 8009
+ ];
+ };
- server.wait_for_open_port(8008)
- # Bridge only opens the port after it contacts the homeserver
- server.wait_for_open_port(8009)
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [
+ (pkgs.writers.writePython3Bin "do_test"
+ {
+ libraries = [ pkgs.python3Packages.matrix-nio ];
+ flakeIgnore = [
+ # We don't live in the dark ages anymore.
+ # Languages like Python that are whitespace heavy will overrun
+ # 79 characters..
+ "E501"
+ ];
+ }
+ ''
+ import sys
+ import functools
+ import asyncio
- with subtest("ensure messages can be exchanged"):
- client.succeed("do_test ${homeserverUrl} >&2")
+ from nio import AsyncClient, RoomMessageNotice, RoomCreateResponse, RoomInviteResponse
- with subtest("ensure as_token, hs_token match from environment file"):
- as_token = get_as_token_from(config_yaml)
- hs_token = get_hs_token_from(config_yaml)
- as_token_registration = get_as_token_from(registration_yaml)
- hs_token_registration = get_hs_token_from(registration_yaml)
- assert as_token == expected_as_token, f"as_token in config should match the one specified (is: {as_token}, expected: {expected_as_token})"
- assert hs_token == expected_hs_token, f"hs_token in config should match the one specified (is: {hs_token}, expected: {expected_hs_token})"
- assert as_token_registration == expected_as_token, f"as_token in registration should match the one specified (is: {as_token_registration}, expected: {expected_as_token})"
- assert hs_token_registration == expected_hs_token, f"hs_token in registration should match the one specified (is: {hs_token_registration}, expected: {expected_hs_token})"
+ async def message_callback(matrix: AsyncClient, msg: str, _r, e):
+ print("Received matrix text message: ", e)
+ assert msg in e.body
+ exit(0) # Success!
- with subtest("ensure as_token and hs_token stays same after restart"):
- server.systemctl("restart mautrix-meta-instagram")
- server.wait_for_open_port(8009)
- as_token = get_as_token_from(config_yaml)
- hs_token = get_hs_token_from(config_yaml)
- as_token_registration = get_as_token_from(registration_yaml)
- hs_token_registration = get_hs_token_from(registration_yaml)
+ async def run(homeserver: str):
+ matrix = AsyncClient(homeserver)
+ response = await matrix.register("${userName}", "foobar")
+ print("Matrix register response: ", response)
- assert as_token == expected_as_token, f"as_token in config should match the one specified (is: {as_token}, expected: {expected_as_token})"
- assert hs_token == expected_hs_token, f"hs_token in config should match the one specified (is: {hs_token}, expected: {expected_hs_token})"
- assert as_token_registration == expected_as_token, f"as_token in registration should match the one specified (is: {as_token_registration}, expected: {expected_as_token})"
- assert hs_token_registration == expected_hs_token, f"hs_token in registration should match the one specified (is: {hs_token_registration}, expected: {expected_hs_token})"
- '';
- }
-)
+ # Open a DM with the bridge bot
+ response = await matrix.room_create()
+ print("Matrix create room response:", response)
+ assert isinstance(response, RoomCreateResponse)
+ room_id = response.room_id
+
+ response = await matrix.room_invite(room_id, "@${botUserName}:${homeserverDomain}")
+ assert isinstance(response, RoomInviteResponse)
+
+ callback = functools.partial(
+ message_callback, matrix, "Hello, I'm an Instagram bridge bot."
+ )
+ matrix.add_event_callback(callback, RoomMessageNotice)
+
+ print("Waiting for matrix message...")
+ await matrix.sync_forever(timeout=30000)
+
+
+ if __name__ == "__main__":
+ asyncio.run(run(sys.argv[1]))
+ ''
+ )
+ ];
+ };
+ };
+
+ testScript = ''
+ def extract_token(data):
+ stdout = data[1]
+ stdout = stdout.strip()
+ line = stdout.split('\n')[-1]
+ return line.split(':')[-1].strip("\" '\n")
+
+ def get_token_from(token, file):
+ data = server.execute(f"cat {file} | grep {token}")
+ return extract_token(data)
+
+ def get_as_token_from(file):
+ return get_token_from("as_token", file)
+
+ def get_hs_token_from(file):
+ return get_token_from("hs_token", file)
+
+ config_yaml = "/var/lib/mautrix-meta-instagram/config.yaml"
+ registration_yaml = "/var/lib/mautrix-meta-instagram/meta-registration.yaml"
+
+ expected_as_token = "${asToken}"
+ expected_hs_token = "${hsToken}"
+
+ start_all()
+
+ with subtest("start the server"):
+ # bridge
+ server.wait_for_unit("mautrix-meta-instagram.service")
+
+ # homeserver
+ server.wait_for_unit("matrix-synapse.service")
+
+ server.wait_for_open_port(8008)
+ # Bridge only opens the port after it contacts the homeserver
+ server.wait_for_open_port(8009)
+
+ with subtest("ensure messages can be exchanged"):
+ client.succeed("do_test ${homeserverUrl} >&2")
+
+ with subtest("ensure as_token, hs_token match from environment file"):
+ as_token = get_as_token_from(config_yaml)
+ hs_token = get_hs_token_from(config_yaml)
+ as_token_registration = get_as_token_from(registration_yaml)
+ hs_token_registration = get_hs_token_from(registration_yaml)
+
+ assert as_token == expected_as_token, f"as_token in config should match the one specified (is: {as_token}, expected: {expected_as_token})"
+ assert hs_token == expected_hs_token, f"hs_token in config should match the one specified (is: {hs_token}, expected: {expected_hs_token})"
+ assert as_token_registration == expected_as_token, f"as_token in registration should match the one specified (is: {as_token_registration}, expected: {expected_as_token})"
+ assert hs_token_registration == expected_hs_token, f"hs_token in registration should match the one specified (is: {hs_token_registration}, expected: {expected_hs_token})"
+
+ with subtest("ensure as_token and hs_token stays same after restart"):
+ server.systemctl("restart mautrix-meta-instagram")
+ server.wait_for_open_port(8009)
+
+ as_token = get_as_token_from(config_yaml)
+ hs_token = get_hs_token_from(config_yaml)
+ as_token_registration = get_as_token_from(registration_yaml)
+ hs_token_registration = get_hs_token_from(registration_yaml)
+
+ assert as_token == expected_as_token, f"as_token in config should match the one specified (is: {as_token}, expected: {expected_as_token})"
+ assert hs_token == expected_hs_token, f"hs_token in config should match the one specified (is: {hs_token}, expected: {expected_hs_token})"
+ assert as_token_registration == expected_as_token, f"as_token in registration should match the one specified (is: {as_token_registration}, expected: {expected_as_token})"
+ assert hs_token_registration == expected_hs_token, f"hs_token in registration should match the one specified (is: {hs_token_registration}, expected: {expected_hs_token})"
+ '';
+}
diff --git a/nixos/tests/matrix/mautrix-meta-sqlite.nix b/nixos/tests/matrix/mautrix-meta-sqlite.nix
index ddd38e8f0b00..d4692dec718e 100644
--- a/nixos/tests/matrix/mautrix-meta-sqlite.nix
+++ b/nixos/tests/matrix/mautrix-meta-sqlite.nix
@@ -1,260 +1,258 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
- homeserverDomain = "server";
- homeserverUrl = "http://server:8008";
- username = "alice";
- instagramBotUsername = "instagrambot";
- facebookBotUsername = "facebookbot";
- in
- {
- name = "mautrix-meta-sqlite";
- meta.maintainers = pkgs.mautrix-meta.meta.maintainers;
+{ pkgs, ... }:
+let
+ homeserverDomain = "server";
+ homeserverUrl = "http://server:8008";
+ username = "alice";
+ instagramBotUsername = "instagrambot";
+ facebookBotUsername = "facebookbot";
+in
+{
+ name = "mautrix-meta-sqlite";
+ meta.maintainers = pkgs.mautrix-meta.meta.maintainers;
- nodes = {
- server =
- { config, pkgs, ... }:
- {
- services.matrix-synapse = {
- enable = true;
- settings = {
- database.name = "sqlite3";
+ nodes = {
+ server =
+ { config, pkgs, ... }:
+ {
+ services.matrix-synapse = {
+ enable = true;
+ settings = {
+ database.name = "sqlite3";
- enable_registration = true;
+ enable_registration = true;
- # don't use this in production, always use some form of verification
- enable_registration_without_verification = true;
+ # don't use this in production, always use some form of verification
+ enable_registration_without_verification = true;
- listeners = [
- {
- # The default but tls=false
- bind_addresses = [
- "0.0.0.0"
- ];
- port = 8008;
- resources = [
- {
- "compress" = true;
- "names" = [ "client" ];
- }
- {
- "compress" = false;
- "names" = [ "federation" ];
- }
- ];
- tls = false;
- type = "http";
- }
+ listeners = [
+ {
+ # The default but tls=false
+ bind_addresses = [
+ "0.0.0.0"
+ ];
+ port = 8008;
+ resources = [
+ {
+ "compress" = true;
+ "names" = [ "client" ];
+ }
+ {
+ "compress" = false;
+ "names" = [ "federation" ];
+ }
+ ];
+ tls = false;
+ type = "http";
+ }
+ ];
+ };
+ };
+
+ services.mautrix-meta.instances.facebook = {
+ enable = true;
+
+ settings = {
+ homeserver = {
+ address = homeserverUrl;
+ domain = homeserverDomain;
+ };
+
+ appservice = {
+ port = 8009;
+
+ bot.username = facebookBotUsername;
+ };
+
+ bridge.permissions."@${username}:server" = "user";
+ };
+ };
+
+ services.mautrix-meta.instances.instagram = {
+ enable = true;
+
+ settings = {
+ homeserver = {
+ address = homeserverUrl;
+ domain = homeserverDomain;
+ };
+
+ appservice = {
+ port = 8010;
+
+ bot.username = instagramBotUsername;
+ };
+
+ bridge.permissions."@${username}:server" = "user";
+ };
+ };
+
+ networking.firewall.allowedTCPPorts = [ 8008 ];
+ };
+
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [
+ (pkgs.writers.writePython3Bin "register_user"
+ {
+ libraries = [ pkgs.python3Packages.matrix-nio ];
+ flakeIgnore = [
+ # We don't live in the dark ages anymore.
+ # Languages like Python that are whitespace heavy will overrun
+ # 79 characters..
+ "E501"
];
- };
- };
+ }
+ ''
+ import sys
+ import asyncio
- services.mautrix-meta.instances.facebook = {
- enable = true;
-
- settings = {
- homeserver = {
- address = homeserverUrl;
- domain = homeserverDomain;
- };
-
- appservice = {
- port = 8009;
-
- bot.username = facebookBotUsername;
- };
-
- bridge.permissions."@${username}:server" = "user";
- };
- };
-
- services.mautrix-meta.instances.instagram = {
- enable = true;
-
- settings = {
- homeserver = {
- address = homeserverUrl;
- domain = homeserverDomain;
- };
-
- appservice = {
- port = 8010;
-
- bot.username = instagramBotUsername;
- };
-
- bridge.permissions."@${username}:server" = "user";
- };
- };
-
- networking.firewall.allowedTCPPorts = [ 8008 ];
- };
-
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [
- (pkgs.writers.writePython3Bin "register_user"
- {
- libraries = [ pkgs.python3Packages.matrix-nio ];
- flakeIgnore = [
- # We don't live in the dark ages anymore.
- # Languages like Python that are whitespace heavy will overrun
- # 79 characters..
- "E501"
- ];
- }
- ''
- import sys
- import asyncio
-
- from nio import AsyncClient
+ from nio import AsyncClient
- async def run(username: str, homeserver: str):
- matrix = AsyncClient(homeserver)
+ async def run(username: str, homeserver: str):
+ matrix = AsyncClient(homeserver)
- response = await matrix.register(username, "foobar")
- print("Matrix register response: ", response)
+ response = await matrix.register(username, "foobar")
+ print("Matrix register response: ", response)
- if __name__ == "__main__":
- asyncio.run(run(sys.argv[1], sys.argv[2]))
- ''
- )
- (pkgs.writers.writePython3Bin "do_test"
- {
- libraries = [ pkgs.python3Packages.matrix-nio ];
- flakeIgnore = [
- # We don't live in the dark ages anymore.
- # Languages like Python that are whitespace heavy will overrun
- # 79 characters..
- "E501"
- ];
- }
- ''
- import sys
- import functools
- import asyncio
+ if __name__ == "__main__":
+ asyncio.run(run(sys.argv[1], sys.argv[2]))
+ ''
+ )
+ (pkgs.writers.writePython3Bin "do_test"
+ {
+ libraries = [ pkgs.python3Packages.matrix-nio ];
+ flakeIgnore = [
+ # We don't live in the dark ages anymore.
+ # Languages like Python that are whitespace heavy will overrun
+ # 79 characters..
+ "E501"
+ ];
+ }
+ ''
+ import sys
+ import functools
+ import asyncio
- from nio import AsyncClient, RoomMessageNotice, RoomCreateResponse, RoomInviteResponse
+ from nio import AsyncClient, RoomMessageNotice, RoomCreateResponse, RoomInviteResponse
- async def message_callback(matrix: AsyncClient, msg: str, _r, e):
- print("Received matrix text message: ", e)
- assert msg in e.body
- exit(0) # Success!
+ async def message_callback(matrix: AsyncClient, msg: str, _r, e):
+ print("Received matrix text message: ", e)
+ assert msg in e.body
+ exit(0) # Success!
- async def run(username: str, bot_username: str, homeserver: str):
- matrix = AsyncClient(homeserver, f"@{username}:${homeserverDomain}")
+ async def run(username: str, bot_username: str, homeserver: str):
+ matrix = AsyncClient(homeserver, f"@{username}:${homeserverDomain}")
- response = await matrix.login("foobar")
- print("Matrix login response: ", response)
+ response = await matrix.login("foobar")
+ print("Matrix login response: ", response)
- # Open a DM with the bridge bot
- response = await matrix.room_create()
- print("Matrix create room response:", response)
- assert isinstance(response, RoomCreateResponse)
- room_id = response.room_id
+ # Open a DM with the bridge bot
+ response = await matrix.room_create()
+ print("Matrix create room response:", response)
+ assert isinstance(response, RoomCreateResponse)
+ room_id = response.room_id
- response = await matrix.room_invite(room_id, f"@{bot_username}:${homeserverDomain}")
- assert isinstance(response, RoomInviteResponse)
+ response = await matrix.room_invite(room_id, f"@{bot_username}:${homeserverDomain}")
+ assert isinstance(response, RoomInviteResponse)
- callback = functools.partial(
- message_callback, matrix, "Hello, I'm an Instagram bridge bot."
- )
- matrix.add_event_callback(callback, RoomMessageNotice)
+ callback = functools.partial(
+ message_callback, matrix, "Hello, I'm an Instagram bridge bot."
+ )
+ matrix.add_event_callback(callback, RoomMessageNotice)
- print("Waiting for matrix message...")
- await matrix.sync_forever(timeout=30000)
+ print("Waiting for matrix message...")
+ await matrix.sync_forever(timeout=30000)
- if __name__ == "__main__":
- asyncio.run(run(sys.argv[1], sys.argv[2], sys.argv[3]))
- ''
- )
- ];
- };
- };
+ if __name__ == "__main__":
+ asyncio.run(run(sys.argv[1], sys.argv[2], sys.argv[3]))
+ ''
+ )
+ ];
+ };
+ };
- testScript = ''
- def extract_token(data):
- stdout = data[1]
- stdout = stdout.strip()
- line = stdout.split('\n')[-1]
- return line.split(':')[-1].strip("\" '\n")
+ testScript = ''
+ def extract_token(data):
+ stdout = data[1]
+ stdout = stdout.strip()
+ line = stdout.split('\n')[-1]
+ return line.split(':')[-1].strip("\" '\n")
- def get_token_from(token, file):
- data = server.execute(f"cat {file} | grep {token}")
- return extract_token(data)
+ def get_token_from(token, file):
+ data = server.execute(f"cat {file} | grep {token}")
+ return extract_token(data)
- def get_as_token_from(file):
- return get_token_from("as_token", file)
+ def get_as_token_from(file):
+ return get_token_from("as_token", file)
- def get_hs_token_from(file):
- return get_token_from("hs_token", file)
+ def get_hs_token_from(file):
+ return get_token_from("hs_token", file)
- config_yaml = "/var/lib/mautrix-meta-facebook/config.yaml"
- registration_yaml = "/var/lib/mautrix-meta-facebook/meta-registration.yaml"
+ config_yaml = "/var/lib/mautrix-meta-facebook/config.yaml"
+ registration_yaml = "/var/lib/mautrix-meta-facebook/meta-registration.yaml"
- start_all()
+ start_all()
- with subtest("wait for bridges and homeserver"):
- # bridge
- server.wait_for_unit("mautrix-meta-facebook.service")
- server.wait_for_unit("mautrix-meta-instagram.service")
+ with subtest("wait for bridges and homeserver"):
+ # bridge
+ server.wait_for_unit("mautrix-meta-facebook.service")
+ server.wait_for_unit("mautrix-meta-instagram.service")
- # homeserver
- server.wait_for_unit("matrix-synapse.service")
+ # homeserver
+ server.wait_for_unit("matrix-synapse.service")
- server.wait_for_open_port(8008)
- # Bridges only open the port after they contact the homeserver
- server.wait_for_open_port(8009)
- server.wait_for_open_port(8010)
+ server.wait_for_open_port(8008)
+ # Bridges only open the port after they contact the homeserver
+ server.wait_for_open_port(8009)
+ server.wait_for_open_port(8010)
- with subtest("register user"):
- client.succeed("register_user ${username} ${homeserverUrl} >&2")
+ with subtest("register user"):
+ client.succeed("register_user ${username} ${homeserverUrl} >&2")
- with subtest("ensure messages can be exchanged"):
- client.succeed("do_test ${username} ${facebookBotUsername} ${homeserverUrl} >&2")
- client.succeed("do_test ${username} ${instagramBotUsername} ${homeserverUrl} >&2")
+ with subtest("ensure messages can be exchanged"):
+ client.succeed("do_test ${username} ${facebookBotUsername} ${homeserverUrl} >&2")
+ client.succeed("do_test ${username} ${instagramBotUsername} ${homeserverUrl} >&2")
- with subtest("ensure as_token and hs_token stays same after restart"):
- generated_as_token_facebook = get_as_token_from(config_yaml)
- generated_hs_token_facebook = get_hs_token_from(config_yaml)
+ with subtest("ensure as_token and hs_token stays same after restart"):
+ generated_as_token_facebook = get_as_token_from(config_yaml)
+ generated_hs_token_facebook = get_hs_token_from(config_yaml)
- generated_as_token_facebook_registration = get_as_token_from(registration_yaml)
- generated_hs_token_facebook_registration = get_hs_token_from(registration_yaml)
+ generated_as_token_facebook_registration = get_as_token_from(registration_yaml)
+ generated_hs_token_facebook_registration = get_hs_token_from(registration_yaml)
- # Indirectly checks the as token is not set to something like empty string or "null"
- assert len(generated_as_token_facebook) > 20, f"as_token ({generated_as_token_facebook}) is too short, something went wrong"
- assert len(generated_hs_token_facebook) > 20, f"hs_token ({generated_hs_token_facebook}) is too short, something went wrong"
+ # Indirectly checks the as token is not set to something like empty string or "null"
+ assert len(generated_as_token_facebook) > 20, f"as_token ({generated_as_token_facebook}) is too short, something went wrong"
+ assert len(generated_hs_token_facebook) > 20, f"hs_token ({generated_hs_token_facebook}) is too short, something went wrong"
- assert generated_as_token_facebook == generated_as_token_facebook_registration, f"as_token should be the same in registration ({generated_as_token_facebook_registration}) and configuration ({generated_as_token_facebook}) files"
- assert generated_hs_token_facebook == generated_hs_token_facebook_registration, f"hs_token should be the same in registration ({generated_hs_token_facebook_registration}) and configuration ({generated_hs_token_facebook}) files"
+ assert generated_as_token_facebook == generated_as_token_facebook_registration, f"as_token should be the same in registration ({generated_as_token_facebook_registration}) and configuration ({generated_as_token_facebook}) files"
+ assert generated_hs_token_facebook == generated_hs_token_facebook_registration, f"hs_token should be the same in registration ({generated_hs_token_facebook_registration}) and configuration ({generated_hs_token_facebook}) files"
- server.systemctl("restart mautrix-meta-facebook")
- server.systemctl("restart mautrix-meta-instagram")
+ server.systemctl("restart mautrix-meta-facebook")
+ server.systemctl("restart mautrix-meta-instagram")
- server.wait_for_open_port(8009)
- server.wait_for_open_port(8010)
+ server.wait_for_open_port(8009)
+ server.wait_for_open_port(8010)
- new_as_token_facebook = get_as_token_from(config_yaml)
- new_hs_token_facebook = get_hs_token_from(config_yaml)
+ new_as_token_facebook = get_as_token_from(config_yaml)
+ new_hs_token_facebook = get_hs_token_from(config_yaml)
- assert generated_as_token_facebook == new_as_token_facebook, f"as_token should stay the same after restart inside the configuration file (is: {new_as_token_facebook}, was: {generated_as_token_facebook})"
- assert generated_hs_token_facebook == new_hs_token_facebook, f"hs_token should stay the same after restart inside the configuration file (is: {new_hs_token_facebook}, was: {generated_hs_token_facebook})"
+ assert generated_as_token_facebook == new_as_token_facebook, f"as_token should stay the same after restart inside the configuration file (is: {new_as_token_facebook}, was: {generated_as_token_facebook})"
+ assert generated_hs_token_facebook == new_hs_token_facebook, f"hs_token should stay the same after restart inside the configuration file (is: {new_hs_token_facebook}, was: {generated_hs_token_facebook})"
- new_as_token_facebook = get_as_token_from(registration_yaml)
- new_hs_token_facebook = get_hs_token_from(registration_yaml)
+ new_as_token_facebook = get_as_token_from(registration_yaml)
+ new_hs_token_facebook = get_hs_token_from(registration_yaml)
- assert generated_as_token_facebook == new_as_token_facebook, f"as_token should stay the same after restart inside the registration file (is: {new_as_token_facebook}, was: {generated_as_token_facebook})"
- assert generated_hs_token_facebook == new_hs_token_facebook, f"hs_token should stay the same after restart inside the registration file (is: {new_hs_token_facebook}, was: {generated_hs_token_facebook})"
+ assert generated_as_token_facebook == new_as_token_facebook, f"as_token should stay the same after restart inside the registration file (is: {new_as_token_facebook}, was: {generated_as_token_facebook})"
+ assert generated_hs_token_facebook == new_hs_token_facebook, f"hs_token should stay the same after restart inside the registration file (is: {new_hs_token_facebook}, was: {generated_hs_token_facebook})"
- with subtest("ensure messages can be exchanged after restart"):
- client.succeed("do_test ${username} ${instagramBotUsername} ${homeserverUrl} >&2")
- client.succeed("do_test ${username} ${facebookBotUsername} ${homeserverUrl} >&2")
- '';
- }
-)
+ with subtest("ensure messages can be exchanged after restart"):
+ client.succeed("do_test ${username} ${instagramBotUsername} ${homeserverUrl} >&2")
+ client.succeed("do_test ${username} ${facebookBotUsername} ${homeserverUrl} >&2")
+ '';
+}
diff --git a/nixos/tests/matrix/mjolnir.nix b/nixos/tests/matrix/mjolnir.nix
index a4a4426758d3..bc74902c7f20 100644
--- a/nixos/tests/matrix/mjolnir.nix
+++ b/nixos/tests/matrix/mjolnir.nix
@@ -1,187 +1,185 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
- # Set up SSL certs for Synapse to be happy.
- runWithOpenSSL =
- file: cmd:
- pkgs.runCommand file {
- buildInputs = [ pkgs.openssl ];
- } cmd;
+{ pkgs, ... }:
+let
+ # Set up SSL certs for Synapse to be happy.
+ runWithOpenSSL =
+ file: cmd:
+ pkgs.runCommand file {
+ buildInputs = [ pkgs.openssl ];
+ } cmd;
- ca_key = runWithOpenSSL "ca-key.pem" "openssl genrsa -out $out 2048";
- ca_pem = runWithOpenSSL "ca.pem" ''
- openssl req \
- -x509 -new -nodes -key ${ca_key} \
- -days 10000 -out $out -subj "/CN=snakeoil-ca"
- '';
- key = runWithOpenSSL "matrix_key.pem" "openssl genrsa -out $out 2048";
- csr = runWithOpenSSL "matrix.csr" ''
- openssl req \
- -new -key ${key} \
- -out $out -subj "/CN=localhost" \
- '';
- cert = runWithOpenSSL "matrix_cert.pem" ''
- openssl x509 \
- -req -in ${csr} \
- -CA ${ca_pem} -CAkey ${ca_key} \
- -CAcreateserial -out $out \
- -days 365
- '';
- in
- {
- name = "mjolnir";
- meta = {
- inherit (pkgs.mjolnir.meta) maintainers;
- };
+ ca_key = runWithOpenSSL "ca-key.pem" "openssl genrsa -out $out 2048";
+ ca_pem = runWithOpenSSL "ca.pem" ''
+ openssl req \
+ -x509 -new -nodes -key ${ca_key} \
+ -days 10000 -out $out -subj "/CN=snakeoil-ca"
+ '';
+ key = runWithOpenSSL "matrix_key.pem" "openssl genrsa -out $out 2048";
+ csr = runWithOpenSSL "matrix.csr" ''
+ openssl req \
+ -new -key ${key} \
+ -out $out -subj "/CN=localhost" \
+ '';
+ cert = runWithOpenSSL "matrix_cert.pem" ''
+ openssl x509 \
+ -req -in ${csr} \
+ -CA ${ca_pem} -CAkey ${ca_key} \
+ -CAcreateserial -out $out \
+ -days 365
+ '';
+in
+{
+ name = "mjolnir";
+ meta = {
+ inherit (pkgs.mjolnir.meta) maintainers;
+ };
- nodes = {
- homeserver =
- { pkgs, ... }:
- {
- services.matrix-synapse = {
- enable = true;
- settings = {
- database.name = "sqlite3";
- tls_certificate_path = "${cert}";
- tls_private_key_path = "${key}";
- enable_registration = true;
- enable_registration_without_verification = true;
- registration_shared_secret = "supersecret-registration";
+ nodes = {
+ homeserver =
+ { pkgs, ... }:
+ {
+ services.matrix-synapse = {
+ enable = true;
+ settings = {
+ database.name = "sqlite3";
+ tls_certificate_path = "${cert}";
+ tls_private_key_path = "${key}";
+ enable_registration = true;
+ enable_registration_without_verification = true;
+ registration_shared_secret = "supersecret-registration";
- listeners = [
- {
- # The default but tls=false
- bind_addresses = [
- "0.0.0.0"
- ];
- port = 8448;
- resources = [
- {
- compress = true;
- names = [ "client" ];
- }
- {
- compress = false;
- names = [ "federation" ];
- }
- ];
- tls = false;
- type = "http";
- x_forwarded = false;
- }
- ];
- };
- };
-
- networking.firewall.allowedTCPPorts = [ 8448 ];
-
- environment.systemPackages = [
- (pkgs.writeShellScriptBin "register_mjolnir_user" ''
- exec ${pkgs.matrix-synapse}/bin/register_new_matrix_user \
- -u mjolnir \
- -p mjolnir-password \
- --admin \
- --shared-secret supersecret-registration \
- http://localhost:8448
- '')
- (pkgs.writeShellScriptBin "register_moderator_user" ''
- exec ${pkgs.matrix-synapse}/bin/register_new_matrix_user \
- -u moderator \
- -p moderator-password \
- --no-admin \
- --shared-secret supersecret-registration \
- http://localhost:8448
- '')
- ];
- };
-
- mjolnir =
- { pkgs, ... }:
- {
- services.mjolnir = {
- enable = true;
- homeserverUrl = "http://homeserver:8448";
- pantalaimon = {
- enable = true;
- username = "mjolnir";
- passwordFile = pkgs.writeText "password.txt" "mjolnir-password";
- # otherwise mjolnir tries to connect to ::1, which is not listened by pantalaimon
- options.listenAddress = "127.0.0.1";
- };
- managementRoom = "#moderators:homeserver";
- };
- };
-
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = [
- (pkgs.writers.writePython3Bin "create_management_room_and_invite_mjolnir"
+ listeners = [
{
- libraries = with pkgs.python3Packages; [
- (matrix-nio.override { withOlm = true; })
+ # The default but tls=false
+ bind_addresses = [
+ "0.0.0.0"
];
+ port = 8448;
+ resources = [
+ {
+ compress = true;
+ names = [ "client" ];
+ }
+ {
+ compress = false;
+ names = [ "federation" ];
+ }
+ ];
+ tls = false;
+ type = "http";
+ x_forwarded = false;
}
- ''
- import asyncio
-
- from nio import (
- AsyncClient,
- EnableEncryptionBuilder
- )
-
-
- async def main() -> None:
- client = AsyncClient("http://homeserver:8448", "moderator")
-
- await client.login("moderator-password")
-
- room = await client.room_create(
- name="Moderators",
- alias="moderators",
- initial_state=[EnableEncryptionBuilder().as_dict()],
- )
-
- await client.join(room.room_id)
- await client.room_invite(room.room_id, "@mjolnir:homeserver")
-
- asyncio.run(main())
- ''
- )
- ];
+ ];
+ };
};
- };
- testScript = ''
- with subtest("start homeserver"):
- homeserver.start()
+ networking.firewall.allowedTCPPorts = [ 8448 ];
- homeserver.wait_for_unit("matrix-synapse.service")
- homeserver.wait_until_succeeds("curl --fail -L http://localhost:8448/")
+ environment.systemPackages = [
+ (pkgs.writeShellScriptBin "register_mjolnir_user" ''
+ exec ${pkgs.matrix-synapse}/bin/register_new_matrix_user \
+ -u mjolnir \
+ -p mjolnir-password \
+ --admin \
+ --shared-secret supersecret-registration \
+ http://localhost:8448
+ '')
+ (pkgs.writeShellScriptBin "register_moderator_user" ''
+ exec ${pkgs.matrix-synapse}/bin/register_new_matrix_user \
+ -u moderator \
+ -p moderator-password \
+ --no-admin \
+ --shared-secret supersecret-registration \
+ http://localhost:8448
+ '')
+ ];
+ };
- with subtest("register users"):
- # register mjolnir user
- homeserver.succeed("register_mjolnir_user")
- # register moderator user
- homeserver.succeed("register_moderator_user")
+ mjolnir =
+ { pkgs, ... }:
+ {
+ services.mjolnir = {
+ enable = true;
+ homeserverUrl = "http://homeserver:8448";
+ pantalaimon = {
+ enable = true;
+ username = "mjolnir";
+ passwordFile = pkgs.writeText "password.txt" "mjolnir-password";
+ # otherwise mjolnir tries to connect to ::1, which is not listened by pantalaimon
+ options.listenAddress = "127.0.0.1";
+ };
+ managementRoom = "#moderators:homeserver";
+ };
+ };
- with subtest("start mjolnir"):
- mjolnir.start()
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [
+ (pkgs.writers.writePython3Bin "create_management_room_and_invite_mjolnir"
+ {
+ libraries = with pkgs.python3Packages; [
+ (matrix-nio.override { withOlm = true; })
+ ];
+ }
+ ''
+ import asyncio
- # wait for pantalaimon to be ready
- mjolnir.wait_for_unit("pantalaimon-mjolnir.service")
- mjolnir.wait_for_unit("mjolnir.service")
+ from nio import (
+ AsyncClient,
+ EnableEncryptionBuilder
+ )
- mjolnir.wait_until_succeeds("curl --fail -L http://localhost:8009/")
- with subtest("ensure mjolnir can be invited to the management room"):
- client.start()
+ async def main() -> None:
+ client = AsyncClient("http://homeserver:8448", "moderator")
- client.wait_until_succeeds("curl --fail -L http://homeserver:8448/")
+ await client.login("moderator-password")
- client.succeed("create_management_room_and_invite_mjolnir")
+ room = await client.room_create(
+ name="Moderators",
+ alias="moderators",
+ initial_state=[EnableEncryptionBuilder().as_dict()],
+ )
- mjolnir.wait_for_console_text("Startup complete. Now monitoring rooms")
- '';
- }
-)
+ await client.join(room.room_id)
+ await client.room_invite(room.room_id, "@mjolnir:homeserver")
+
+ asyncio.run(main())
+ ''
+ )
+ ];
+ };
+ };
+
+ testScript = ''
+ with subtest("start homeserver"):
+ homeserver.start()
+
+ homeserver.wait_for_unit("matrix-synapse.service")
+ homeserver.wait_until_succeeds("curl --fail -L http://localhost:8448/")
+
+ with subtest("register users"):
+ # register mjolnir user
+ homeserver.succeed("register_mjolnir_user")
+ # register moderator user
+ homeserver.succeed("register_moderator_user")
+
+ with subtest("start mjolnir"):
+ mjolnir.start()
+
+ # wait for pantalaimon to be ready
+ mjolnir.wait_for_unit("pantalaimon-mjolnir.service")
+ mjolnir.wait_for_unit("mjolnir.service")
+
+ mjolnir.wait_until_succeeds("curl --fail -L http://localhost:8009/")
+
+ with subtest("ensure mjolnir can be invited to the management room"):
+ client.start()
+
+ client.wait_until_succeeds("curl --fail -L http://homeserver:8448/")
+
+ client.succeed("create_management_room_and_invite_mjolnir")
+
+ mjolnir.wait_for_console_text("Startup complete. Now monitoring rooms")
+ '';
+}
diff --git a/nixos/tests/matrix/pantalaimon.nix b/nixos/tests/matrix/pantalaimon.nix
index 6ff4cf8cda06..eb2123ee3ca6 100644
--- a/nixos/tests/matrix/pantalaimon.nix
+++ b/nixos/tests/matrix/pantalaimon.nix
@@ -1,95 +1,93 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
- pantalaimonInstanceName = "testing";
+{ pkgs, ... }:
+let
+ pantalaimonInstanceName = "testing";
- # Set up SSL certs for Synapse to be happy.
- runWithOpenSSL =
- file: cmd:
- pkgs.runCommand file {
- buildInputs = [ pkgs.openssl ];
- } cmd;
+ # Set up SSL certs for Synapse to be happy.
+ runWithOpenSSL =
+ file: cmd:
+ pkgs.runCommand file {
+ buildInputs = [ pkgs.openssl ];
+ } cmd;
- ca_key = runWithOpenSSL "ca-key.pem" "openssl genrsa -out $out 2048";
- ca_pem = runWithOpenSSL "ca.pem" ''
- openssl req \
- -x509 -new -nodes -key ${ca_key} \
- -days 10000 -out $out -subj "/CN=snakeoil-ca"
- '';
- key = runWithOpenSSL "matrix_key.pem" "openssl genrsa -out $out 2048";
- csr = runWithOpenSSL "matrix.csr" ''
- openssl req \
- -new -key ${key} \
- -out $out -subj "/CN=localhost" \
- '';
- cert = runWithOpenSSL "matrix_cert.pem" ''
- openssl x509 \
- -req -in ${csr} \
- -CA ${ca_pem} -CAkey ${ca_key} \
- -CAcreateserial -out $out \
- -days 365
- '';
- in
- {
- name = "pantalaimon";
- meta = with pkgs.lib; {
- maintainers = teams.matrix.members;
- };
+ ca_key = runWithOpenSSL "ca-key.pem" "openssl genrsa -out $out 2048";
+ ca_pem = runWithOpenSSL "ca.pem" ''
+ openssl req \
+ -x509 -new -nodes -key ${ca_key} \
+ -days 10000 -out $out -subj "/CN=snakeoil-ca"
+ '';
+ key = runWithOpenSSL "matrix_key.pem" "openssl genrsa -out $out 2048";
+ csr = runWithOpenSSL "matrix.csr" ''
+ openssl req \
+ -new -key ${key} \
+ -out $out -subj "/CN=localhost" \
+ '';
+ cert = runWithOpenSSL "matrix_cert.pem" ''
+ openssl x509 \
+ -req -in ${csr} \
+ -CA ${ca_pem} -CAkey ${ca_key} \
+ -CAcreateserial -out $out \
+ -days 365
+ '';
+in
+{
+ name = "pantalaimon";
+ meta = with pkgs.lib; {
+ maintainers = teams.matrix.members;
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- services.pantalaimon-headless.instances.${pantalaimonInstanceName} = {
- homeserver = "https://localhost:8448";
- listenAddress = "0.0.0.0";
- listenPort = 8888;
- logLevel = "debug";
- ssl = false;
- };
-
- services.matrix-synapse = {
- enable = true;
- settings = {
- listeners = [
- {
- port = 8448;
- bind_addresses = [
- "127.0.0.1"
- "::1"
- ];
- type = "http";
- tls = true;
- x_forwarded = false;
- resources = [
- {
- names = [
- "client"
- ];
- compress = true;
- }
- {
- names = [
- "federation"
- ];
- compress = false;
- }
- ];
- }
- ];
- database.name = "sqlite3";
- tls_certificate_path = "${cert}";
- tls_private_key_path = "${key}";
- };
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.pantalaimon-headless.instances.${pantalaimonInstanceName} = {
+ homeserver = "https://localhost:8448";
+ listenAddress = "0.0.0.0";
+ listenPort = 8888;
+ logLevel = "debug";
+ ssl = false;
};
- testScript = ''
- start_all()
- machine.wait_for_unit("pantalaimon-${pantalaimonInstanceName}.service")
- machine.wait_for_unit("matrix-synapse.service")
- machine.wait_until_succeeds(
- "curl --fail -L http://localhost:8888/"
- )
- '';
- }
-)
+ services.matrix-synapse = {
+ enable = true;
+ settings = {
+ listeners = [
+ {
+ port = 8448;
+ bind_addresses = [
+ "127.0.0.1"
+ "::1"
+ ];
+ type = "http";
+ tls = true;
+ x_forwarded = false;
+ resources = [
+ {
+ names = [
+ "client"
+ ];
+ compress = true;
+ }
+ {
+ names = [
+ "federation"
+ ];
+ compress = false;
+ }
+ ];
+ }
+ ];
+ database.name = "sqlite3";
+ tls_certificate_path = "${cert}";
+ tls_private_key_path = "${key}";
+ };
+ };
+ };
+
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("pantalaimon-${pantalaimonInstanceName}.service")
+ machine.wait_for_unit("matrix-synapse.service")
+ machine.wait_until_succeeds(
+ "curl --fail -L http://localhost:8888/"
+ )
+ '';
+}
diff --git a/nixos/tests/matrix/synapse-workers.nix b/nixos/tests/matrix/synapse-workers.nix
index f75a0528769a..949658caac47 100644
--- a/nixos/tests/matrix/synapse-workers.nix
+++ b/nixos/tests/matrix/synapse-workers.nix
@@ -1,55 +1,53 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- {
- name = "matrix-synapse-workers";
- meta = {
- inherit (pkgs.matrix-synapse.meta) maintainers;
- };
+{ pkgs, ... }:
+{
+ name = "matrix-synapse-workers";
+ meta = {
+ inherit (pkgs.matrix-synapse.meta) maintainers;
+ };
- nodes = {
- homeserver =
- {
- pkgs,
- nodes,
- ...
- }:
- {
- services.postgresql = {
- enable = true;
- initialScript = pkgs.writeText "synapse-init.sql" ''
- CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
- CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
- TEMPLATE template0
- LC_COLLATE = "C"
- LC_CTYPE = "C";
- '';
+ nodes = {
+ homeserver =
+ {
+ pkgs,
+ nodes,
+ ...
+ }:
+ {
+ services.postgresql = {
+ enable = true;
+ initialScript = pkgs.writeText "synapse-init.sql" ''
+ CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
+ CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
+ TEMPLATE template0
+ LC_COLLATE = "C"
+ LC_CTYPE = "C";
+ '';
+ };
+
+ services.matrix-synapse = {
+ enable = true;
+ settings = {
+ database = {
+ name = "psycopg2";
+ args.password = "synapse";
+ };
+ enable_registration = true;
+ enable_registration_without_verification = true;
+
+ federation_sender_instances = [ "federation_sender" ];
};
-
- services.matrix-synapse = {
- enable = true;
- settings = {
- database = {
- name = "psycopg2";
- args.password = "synapse";
- };
- enable_registration = true;
- enable_registration_without_verification = true;
-
- federation_sender_instances = [ "federation_sender" ];
- };
- configureRedisLocally = true;
- workers = {
- "federation_sender" = { };
- };
+ configureRedisLocally = true;
+ workers = {
+ "federation_sender" = { };
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- homeserver.wait_for_unit("matrix-synapse.service");
- homeserver.wait_for_unit("matrix-synapse-worker-federation_sender.service");
- '';
- }
-)
+ homeserver.wait_for_unit("matrix-synapse.service");
+ homeserver.wait_for_unit("matrix-synapse-worker-federation_sender.service");
+ '';
+}
diff --git a/nixos/tests/matrix/synapse.nix b/nixos/tests/matrix/synapse.nix
index c16182a46cd2..323fa25ccb6c 100644
--- a/nixos/tests/matrix/synapse.nix
+++ b/nixos/tests/matrix/synapse.nix
@@ -1,248 +1,246 @@
-import ../make-test-python.nix (
- { pkgs, ... }:
- let
+{ pkgs, ... }:
+let
- ca_key = mailerCerts.ca.key;
- ca_pem = mailerCerts.ca.cert;
+ ca_key = mailerCerts.ca.key;
+ ca_pem = mailerCerts.ca.cert;
- bundle =
- pkgs.runCommand "bundle"
- {
- nativeBuildInputs = [ pkgs.minica ];
- }
- ''
- minica -ca-cert ${ca_pem} -ca-key ${ca_key} \
- -domains localhost
- install -Dm444 -t $out localhost/{key,cert}.pem
- '';
-
- mailerCerts = import ../common/acme/server/snakeoil-certs.nix;
- mailerDomain = mailerCerts.domain;
- registrationSharedSecret = "unsecure123";
- testUser = "alice";
- testPassword = "alicealice";
- testEmail = "alice@example.com";
-
- listeners = [
+ bundle =
+ pkgs.runCommand "bundle"
{
- port = 8448;
- bind_addresses = [
- "127.0.0.1"
- "::1"
- ];
- type = "http";
- tls = true;
- x_forwarded = false;
- resources = [
- {
- names = [
- "client"
- ];
- compress = true;
- }
- {
- names = [
- "federation"
- ];
- compress = false;
- }
- ];
+ nativeBuildInputs = [ pkgs.minica ];
}
- ];
+ ''
+ minica -ca-cert ${ca_pem} -ca-key ${ca_key} \
+ -domains localhost
+ install -Dm444 -t $out localhost/{key,cert}.pem
+ '';
- in
- {
+ mailerCerts = import ../common/acme/server/snakeoil-certs.nix;
+ mailerDomain = mailerCerts.domain;
+ registrationSharedSecret = "unsecure123";
+ testUser = "alice";
+ testPassword = "alicealice";
+ testEmail = "alice@example.com";
- name = "matrix-synapse";
- meta = {
- inherit (pkgs.matrix-synapse.meta) maintainers;
- };
-
- nodes = {
- # Since 0.33.0, matrix-synapse doesn't allow underscores in server names
- serverpostgres =
+ listeners = [
+ {
+ port = 8448;
+ bind_addresses = [
+ "127.0.0.1"
+ "::1"
+ ];
+ type = "http";
+ tls = true;
+ x_forwarded = false;
+ resources = [
{
- pkgs,
- nodes,
- config,
- ...
- }:
- let
- mailserverIP = nodes.mailserver.config.networking.primaryIPAddress;
- in
- {
- services.matrix-synapse = {
- enable = true;
- settings = {
- inherit listeners;
- database = {
- name = "psycopg2";
- args.password = "synapse";
- };
- redis = {
- enabled = true;
- host = "localhost";
- port = config.services.redis.servers.matrix-synapse.port;
- };
- tls_certificate_path = "${bundle}/cert.pem";
- tls_private_key_path = "${bundle}/key.pem";
- registration_shared_secret = registrationSharedSecret;
- public_baseurl = "https://example.com";
- email = {
- smtp_host = mailerDomain;
- smtp_port = 25;
- require_transport_security = true;
- notif_from = "matrix ";
- app_name = "Matrix";
- };
- };
- };
- services.postgresql = {
- enable = true;
-
- # The database name and user are configured by the following options:
- # - services.matrix-synapse.database_name
- # - services.matrix-synapse.database_user
- #
- # The values used here represent the default values of the module.
- initialScript = pkgs.writeText "synapse-init.sql" ''
- CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
- CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
- TEMPLATE template0
- LC_COLLATE = "C"
- LC_CTYPE = "C";
- '';
- };
-
- services.redis.servers.matrix-synapse = {
- enable = true;
- port = 6380;
- };
-
- networking.extraHosts = ''
- ${mailserverIP} ${mailerDomain}
- '';
-
- security.pki.certificateFiles = [
- mailerCerts.ca.cert
- ca_pem
+ names = [
+ "client"
];
-
- environment.systemPackages =
- let
- sendTestMailStarttls = pkgs.writeScriptBin "send-testmail-starttls" ''
- #!${pkgs.python3.interpreter}
- import smtplib
- import ssl
-
- ctx = ssl.create_default_context()
-
- with smtplib.SMTP('${mailerDomain}') as smtp:
- smtp.ehlo()
- smtp.starttls(context=ctx)
- smtp.ehlo()
- smtp.sendmail('matrix@${mailerDomain}', '${testEmail}', 'Subject: Test STARTTLS\n\nTest data.')
- smtp.quit()
- '';
-
- obtainTokenAndRegisterEmail =
- let
- # adding the email through the API is quite complicated as it involves more than one step and some
- # client-side calculation
- insertEmailForAlice = pkgs.writeText "alice-email.sql" ''
- INSERT INTO user_threepids (user_id, medium, address, validated_at, added_at) VALUES ('${testUser}@serverpostgres', 'email', '${testEmail}', '1629149927271', '1629149927270');
- '';
- in
- pkgs.writeScriptBin "obtain-token-and-register-email" ''
- #!${pkgs.runtimeShell}
- set -o errexit
- set -o pipefail
- set -o nounset
- su postgres -c "psql -d matrix-synapse -f ${insertEmailForAlice}"
- curl --fail -XPOST 'https://localhost:8448/_matrix/client/r0/account/password/email/requestToken' -d '{"email":"${testEmail}","client_secret":"foobar","send_attempt":1}' -v
- '';
- in
- [
- sendTestMailStarttls
- pkgs.matrix-synapse
- obtainTokenAndRegisterEmail
- ];
- };
-
- # test mail delivery
- mailserver =
- args:
- let
- in
+ compress = true;
+ }
{
- security.pki.certificateFiles = [
- mailerCerts.ca.cert
+ names = [
+ "federation"
];
+ compress = false;
+ }
+ ];
+ }
+ ];
- networking.firewall.enable = false;
+in
+{
- services.postfix = {
- enable = true;
- hostname = "${mailerDomain}";
- # open relay for subnet
- networksStyle = "subnet";
- enableSubmission = true;
- tlsTrustedAuthorities = "${mailerCerts.ca.cert}";
- sslCert = "${mailerCerts.${mailerDomain}.cert}";
- sslKey = "${mailerCerts.${mailerDomain}.key}";
+ name = "matrix-synapse";
+ meta = {
+ inherit (pkgs.matrix-synapse.meta) maintainers;
+ };
- # blackhole transport
- transport = "example.com discard:silently";
-
- config = {
- debug_peer_level = "10";
- smtpd_relay_restrictions = [
- "permit_mynetworks"
- "reject_unauth_destination"
- ];
-
- # disable obsolete protocols, something old versions of twisted are still using
- smtpd_tls_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
- smtp_tls_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
- smtpd_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
- smtp_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
- };
- };
- };
-
- serversqlite = args: {
+ nodes = {
+ # Since 0.33.0, matrix-synapse doesn't allow underscores in server names
+ serverpostgres =
+ {
+ pkgs,
+ nodes,
+ config,
+ ...
+ }:
+ let
+ mailserverIP = nodes.mailserver.config.networking.primaryIPAddress;
+ in
+ {
services.matrix-synapse = {
enable = true;
settings = {
inherit listeners;
- database.name = "sqlite3";
+ database = {
+ name = "psycopg2";
+ args.password = "synapse";
+ };
+ redis = {
+ enabled = true;
+ host = "localhost";
+ port = config.services.redis.servers.matrix-synapse.port;
+ };
tls_certificate_path = "${bundle}/cert.pem";
tls_private_key_path = "${bundle}/key.pem";
+ registration_shared_secret = registrationSharedSecret;
+ public_baseurl = "https://example.com";
+ email = {
+ smtp_host = mailerDomain;
+ smtp_port = 25;
+ require_transport_security = true;
+ notif_from = "matrix ";
+ app_name = "Matrix";
+ };
+ };
+ };
+ services.postgresql = {
+ enable = true;
+
+ # The database name and user are configured by the following options:
+ # - services.matrix-synapse.database_name
+ # - services.matrix-synapse.database_user
+ #
+ # The values used here represent the default values of the module.
+ initialScript = pkgs.writeText "synapse-init.sql" ''
+ CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
+ CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
+ TEMPLATE template0
+ LC_COLLATE = "C"
+ LC_CTYPE = "C";
+ '';
+ };
+
+ services.redis.servers.matrix-synapse = {
+ enable = true;
+ port = 6380;
+ };
+
+ networking.extraHosts = ''
+ ${mailserverIP} ${mailerDomain}
+ '';
+
+ security.pki.certificateFiles = [
+ mailerCerts.ca.cert
+ ca_pem
+ ];
+
+ environment.systemPackages =
+ let
+ sendTestMailStarttls = pkgs.writeScriptBin "send-testmail-starttls" ''
+ #!${pkgs.python3.interpreter}
+ import smtplib
+ import ssl
+
+ ctx = ssl.create_default_context()
+
+ with smtplib.SMTP('${mailerDomain}') as smtp:
+ smtp.ehlo()
+ smtp.starttls(context=ctx)
+ smtp.ehlo()
+ smtp.sendmail('matrix@${mailerDomain}', '${testEmail}', 'Subject: Test STARTTLS\n\nTest data.')
+ smtp.quit()
+ '';
+
+ obtainTokenAndRegisterEmail =
+ let
+ # adding the email through the API is quite complicated as it involves more than one step and some
+ # client-side calculation
+ insertEmailForAlice = pkgs.writeText "alice-email.sql" ''
+ INSERT INTO user_threepids (user_id, medium, address, validated_at, added_at) VALUES ('${testUser}@serverpostgres', 'email', '${testEmail}', '1629149927271', '1629149927270');
+ '';
+ in
+ pkgs.writeScriptBin "obtain-token-and-register-email" ''
+ #!${pkgs.runtimeShell}
+ set -o errexit
+ set -o pipefail
+ set -o nounset
+ su postgres -c "psql -d matrix-synapse -f ${insertEmailForAlice}"
+ curl --fail -XPOST 'https://localhost:8448/_matrix/client/r0/account/password/email/requestToken' -d '{"email":"${testEmail}","client_secret":"foobar","send_attempt":1}' -v
+ '';
+ in
+ [
+ sendTestMailStarttls
+ pkgs.matrix-synapse
+ obtainTokenAndRegisterEmail
+ ];
+ };
+
+ # test mail delivery
+ mailserver =
+ args:
+ let
+ in
+ {
+ security.pki.certificateFiles = [
+ mailerCerts.ca.cert
+ ];
+
+ networking.firewall.enable = false;
+
+ services.postfix = {
+ enable = true;
+ hostname = "${mailerDomain}";
+ # open relay for subnet
+ networksStyle = "subnet";
+ enableSubmission = true;
+ tlsTrustedAuthorities = "${mailerCerts.ca.cert}";
+ sslCert = "${mailerCerts.${mailerDomain}.cert}";
+ sslKey = "${mailerCerts.${mailerDomain}.key}";
+
+ # blackhole transport
+ transport = "example.com discard:silently";
+
+ config = {
+ debug_peer_level = "10";
+ smtpd_relay_restrictions = [
+ "permit_mynetworks"
+ "reject_unauth_destination"
+ ];
+
+ # disable obsolete protocols, something old versions of twisted are still using
+ smtpd_tls_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
+ smtp_tls_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
+ smtpd_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
+ smtp_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3";
};
};
};
+
+ serversqlite = args: {
+ services.matrix-synapse = {
+ enable = true;
+ settings = {
+ inherit listeners;
+ database.name = "sqlite3";
+ tls_certificate_path = "${bundle}/cert.pem";
+ tls_private_key_path = "${bundle}/key.pem";
+ };
+ };
};
+ };
- testScript = ''
- start_all()
- mailserver.wait_for_unit("postfix.service")
- serverpostgres.succeed("send-testmail-starttls")
- serverpostgres.wait_for_unit("matrix-synapse.service")
- serverpostgres.wait_until_succeeds(
- "curl --fail -L --cacert ${ca_pem} https://localhost:8448/"
- )
- serverpostgres.wait_until_succeeds(
- "journalctl -u matrix-synapse.service | grep -q 'Connected to redis'"
- )
- serverpostgres.require_unit_state("postgresql.service")
- serverpostgres.succeed("REQUESTS_CA_BUNDLE=${ca_pem} register_new_matrix_user -u ${testUser} -p ${testPassword} -a -k ${registrationSharedSecret} https://localhost:8448/")
- serverpostgres.succeed("obtain-token-and-register-email")
- serversqlite.wait_for_unit("matrix-synapse.service")
- serversqlite.wait_until_succeeds(
- "curl --fail -L --cacert ${ca_pem} https://localhost:8448/"
- )
- serversqlite.succeed("[ -e /var/lib/matrix-synapse/homeserver.db ]")
- '';
+ testScript = ''
+ start_all()
+ mailserver.wait_for_unit("postfix.service")
+ serverpostgres.succeed("send-testmail-starttls")
+ serverpostgres.wait_for_unit("matrix-synapse.service")
+ serverpostgres.wait_until_succeeds(
+ "curl --fail -L --cacert ${ca_pem} https://localhost:8448/"
+ )
+ serverpostgres.wait_until_succeeds(
+ "journalctl -u matrix-synapse.service | grep -q 'Connected to redis'"
+ )
+ serverpostgres.require_unit_state("postgresql.service")
+ serverpostgres.succeed("REQUESTS_CA_BUNDLE=${ca_pem} register_new_matrix_user -u ${testUser} -p ${testPassword} -a -k ${registrationSharedSecret} https://localhost:8448/")
+ serverpostgres.succeed("obtain-token-and-register-email")
+ serversqlite.wait_for_unit("matrix-synapse.service")
+ serversqlite.wait_until_succeeds(
+ "curl --fail -L --cacert ${ca_pem} https://localhost:8448/"
+ )
+ serversqlite.succeed("[ -e /var/lib/matrix-synapse/homeserver.db ]")
+ '';
- }
-)
+}
diff --git a/nixos/tests/matter-server.nix b/nixos/tests/matter-server.nix
index e302a8e91427..167cee21e07b 100644
--- a/nixos/tests/matter-server.nix
+++ b/nixos/tests/matter-server.nix
@@ -1,52 +1,50 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- chipVersion = pkgs.python311Packages.home-assistant-chip-core.version;
- in
+let
+ chipVersion = pkgs.python311Packages.home-assistant-chip-core.version;
+in
- {
- name = "matter-server";
- meta.maintainers = with lib.maintainers; [ leonm1 ];
- meta.timeout = 120; # Timeout after two minutes
+{
+ name = "matter-server";
+ meta.maintainers = with lib.maintainers; [ leonm1 ];
+ meta.timeout = 120; # Timeout after two minutes
- nodes = {
- machine =
- { config, ... }:
- {
- services.matter-server = {
- enable = true;
- port = 1234;
- };
+ nodes = {
+ machine =
+ { config, ... }:
+ {
+ services.matter-server = {
+ enable = true;
+ port = 1234;
};
- };
+ };
+ };
- testScript = # python
- ''
- @polling_condition
- def matter_server_running():
- machine.succeed("systemctl status matter-server")
+ testScript = # python
+ ''
+ @polling_condition
+ def matter_server_running():
+ machine.succeed("systemctl status matter-server")
- start_all()
+ start_all()
- machine.wait_for_unit("matter-server.service", timeout=20)
- machine.wait_for_open_port(1234, timeout=20)
+ machine.wait_for_unit("matter-server.service", timeout=20)
+ machine.wait_for_open_port(1234, timeout=20)
- with matter_server_running: # type: ignore[union-attr]
- with subtest("Check websocket server initialized"):
- output = machine.succeed("echo \"\" | ${pkgs.websocat}/bin/websocat ws://localhost:1234/ws")
- machine.log(output)
+ with matter_server_running: # type: ignore[union-attr]
+ with subtest("Check websocket server initialized"):
+ output = machine.succeed("echo \"\" | ${pkgs.websocat}/bin/websocat ws://localhost:1234/ws")
+ machine.log(output)
- assert '"fabric_id": 1' in output, (
- "fabric_id not propagated to server"
- )
+ assert '"fabric_id": 1' in output, (
+ "fabric_id not propagated to server"
+ )
- with subtest("Check storage directory is created"):
- machine.succeed("ls /var/lib/matter-server/chip.json")
+ with subtest("Check storage directory is created"):
+ machine.succeed("ls /var/lib/matter-server/chip.json")
- with subtest("Check systemd hardening"):
- _, output = machine.execute("systemd-analyze security matter-server.service | grep -v '✓'")
- machine.log(output)
- '';
- }
-)
+ with subtest("Check systemd hardening"):
+ _, output = machine.execute("systemd-analyze security matter-server.service | grep -v '✓'")
+ machine.log(output)
+ '';
+}
diff --git a/nixos/tests/mealie.nix b/nixos/tests/mealie.nix
index e296d5180ecd..97dd4d048f48 100644
--- a/nixos/tests/mealie.nix
+++ b/nixos/tests/mealie.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "mealie";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- litchipi
- anoa
- ];
+{
+ name = "mealie";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ litchipi
+ anoa
+ ];
+ };
+
+ nodes =
+ let
+ sqlite = {
+ services.mealie = {
+ enable = true;
+ port = 9001;
+ };
+ };
+ postgres = {
+ imports = [ sqlite ];
+ services.mealie.database.createLocally = true;
+ };
+ in
+ {
+ inherit sqlite postgres;
};
- nodes =
- let
- sqlite = {
- services.mealie = {
- enable = true;
- port = 9001;
- };
- };
- postgres = {
- imports = [ sqlite ];
- services.mealie.database.createLocally = true;
- };
- in
- {
- inherit sqlite postgres;
- };
+ testScript = ''
+ start_all()
- testScript = ''
- start_all()
+ def test_mealie(node):
+ node.wait_for_unit("mealie.service")
+ node.wait_for_open_port(9001)
+ node.succeed("curl --fail http://localhost:9001")
- def test_mealie(node):
- node.wait_for_unit("mealie.service")
- node.wait_for_open_port(9001)
- node.succeed("curl --fail http://localhost:9001")
-
- test_mealie(sqlite)
- sqlite.send_monitor_command("quit")
- sqlite.wait_for_shutdown()
- test_mealie(postgres)
- '';
- }
-)
+ test_mealie(sqlite)
+ sqlite.send_monitor_command("quit")
+ sqlite.wait_for_shutdown()
+ test_mealie(postgres)
+ '';
+}
diff --git a/nixos/tests/mediamtx.nix b/nixos/tests/mediamtx.nix
index f40c4a8cb583..7f7d40d3e12a 100644
--- a/nixos/tests/mediamtx.nix
+++ b/nixos/tests/mediamtx.nix
@@ -1,60 +1,58 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- {
- name = "mediamtx";
- meta.maintainers = with lib.maintainers; [ fpletz ];
+{
+ name = "mediamtx";
+ meta.maintainers = with lib.maintainers; [ fpletz ];
- nodes = {
- machine = {
- services.mediamtx = {
- enable = true;
- settings = {
- metrics = true;
- paths.all.source = "publisher";
- };
+ nodes = {
+ machine = {
+ services.mediamtx = {
+ enable = true;
+ settings = {
+ metrics = true;
+ paths.all.source = "publisher";
};
+ };
- systemd.services.rtmp-publish = {
- description = "Publish an RTMP stream to mediamtx";
- after = [ "mediamtx.service" ];
- bindsTo = [ "mediamtx.service" ];
- wantedBy = [ "multi-user.target" ];
- serviceConfig = {
- DynamicUser = true;
- Restart = "on-failure";
- RestartSec = "1s";
- TimeoutStartSec = "10s";
- ExecStart = "${lib.getBin pkgs.ffmpeg-headless}/bin/ffmpeg -re -f lavfi -i smptebars=size=800x600:rate=10 -c libx264 -f flv rtmp://localhost:1935/test";
- };
+ systemd.services.rtmp-publish = {
+ description = "Publish an RTMP stream to mediamtx";
+ after = [ "mediamtx.service" ];
+ bindsTo = [ "mediamtx.service" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ DynamicUser = true;
+ Restart = "on-failure";
+ RestartSec = "1s";
+ TimeoutStartSec = "10s";
+ ExecStart = "${lib.getBin pkgs.ffmpeg-headless}/bin/ffmpeg -re -f lavfi -i smptebars=size=800x600:rate=10 -c libx264 -f flv rtmp://localhost:1935/test";
};
+ };
- systemd.services.rtmp-receive = {
- description = "Receive an RTMP stream from mediamtx";
- after = [ "rtmp-publish.service" ];
- bindsTo = [ "rtmp-publish.service" ];
- wantedBy = [ "multi-user.target" ];
- serviceConfig = {
- DynamicUser = true;
- Restart = "on-failure";
- RestartSec = "1s";
- TimeoutStartSec = "10s";
- ExecStart = "${lib.getBin pkgs.ffmpeg-headless}/bin/ffmpeg -y -re -i rtmp://localhost:1935/test -f flv /dev/null";
- };
+ systemd.services.rtmp-receive = {
+ description = "Receive an RTMP stream from mediamtx";
+ after = [ "rtmp-publish.service" ];
+ bindsTo = [ "rtmp-publish.service" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ DynamicUser = true;
+ Restart = "on-failure";
+ RestartSec = "1s";
+ TimeoutStartSec = "10s";
+ ExecStart = "${lib.getBin pkgs.ffmpeg-headless}/bin/ffmpeg -y -re -i rtmp://localhost:1935/test -f flv /dev/null";
};
};
};
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine.wait_for_unit("mediamtx.service")
- machine.wait_for_unit("rtmp-publish.service")
- machine.sleep(10)
- machine.wait_for_unit("rtmp-receive.service")
- machine.wait_for_open_port(9998)
- machine.succeed("curl http://localhost:9998/metrics | grep '^rtmp_conns.*state=\"publish\".*1$'")
- machine.succeed("curl http://localhost:9998/metrics | grep '^rtmp_conns.*state=\"read\".*1$'")
- '';
- }
-)
+ machine.wait_for_unit("mediamtx.service")
+ machine.wait_for_unit("rtmp-publish.service")
+ machine.sleep(10)
+ machine.wait_for_unit("rtmp-receive.service")
+ machine.wait_for_open_port(9998)
+ machine.succeed("curl http://localhost:9998/metrics | grep '^rtmp_conns.*state=\"publish\".*1$'")
+ machine.succeed("curl http://localhost:9998/metrics | grep '^rtmp_conns.*state=\"read\".*1$'")
+ '';
+}
diff --git a/nixos/tests/meilisearch.nix b/nixos/tests/meilisearch.nix
index a73abbba3a48..ae88b8e07157 100644
--- a/nixos/tests/meilisearch.nix
+++ b/nixos/tests/meilisearch.nix
@@ -1,69 +1,67 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- listenAddress = "127.0.0.1";
- listenPort = 7700;
- apiUrl = "http://${listenAddress}:${toString listenPort}";
- uid = "movies";
- indexJSON = pkgs.writeText "index.json" (builtins.toJSON { inherit uid; });
- moviesJSON = pkgs.fetchurl {
- url = "https://github.com/meilisearch/meilisearch/raw/v0.23.1/datasets/movies/movies.json";
- sha256 = "1r3srld63dpmg9yrmysm6xl175661j5cspi93mk5q2wf8xwn50c5";
- };
- in
- {
- name = "meilisearch";
- meta.maintainers = with lib.maintainers; [ Br1ght0ne ];
+{ pkgs, lib, ... }:
+let
+ listenAddress = "127.0.0.1";
+ listenPort = 7700;
+ apiUrl = "http://${listenAddress}:${toString listenPort}";
+ uid = "movies";
+ indexJSON = pkgs.writeText "index.json" (builtins.toJSON { inherit uid; });
+ moviesJSON = pkgs.fetchurl {
+ url = "https://github.com/meilisearch/meilisearch/raw/v0.23.1/datasets/movies/movies.json";
+ sha256 = "1r3srld63dpmg9yrmysm6xl175661j5cspi93mk5q2wf8xwn50c5";
+ };
+in
+{
+ name = "meilisearch";
+ meta.maintainers = with lib.maintainers; [ Br1ght0ne ];
- nodes.machine =
- { ... }:
- {
- environment.systemPackages = with pkgs; [
- curl
- jq
- ];
- services.meilisearch = {
- enable = true;
- inherit listenAddress listenPort;
- };
+ nodes.machine =
+ { ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ curl
+ jq
+ ];
+ services.meilisearch = {
+ enable = true;
+ inherit listenAddress listenPort;
};
+ };
- testScript = ''
- import json
+ testScript = ''
+ import json
- start_all()
+ start_all()
- machine.wait_for_unit("meilisearch")
- machine.wait_for_open_port(7700)
+ machine.wait_for_unit("meilisearch")
+ machine.wait_for_open_port(7700)
- with subtest("check version"):
- version = json.loads(machine.succeed("curl ${apiUrl}/version"))
- assert version["pkgVersion"] == "${pkgs.meilisearch.version}"
+ with subtest("check version"):
+ version = json.loads(machine.succeed("curl ${apiUrl}/version"))
+ assert version["pkgVersion"] == "${pkgs.meilisearch.version}"
- with subtest("create index"):
- machine.succeed(
- "curl -X POST -H 'Content-Type: application/json' ${apiUrl}/indexes --data @${indexJSON}"
- )
- indexes = json.loads(machine.succeed("curl ${apiUrl}/indexes"))
- assert indexes["total"] == 1, "index wasn't created"
+ with subtest("create index"):
+ machine.succeed(
+ "curl -X POST -H 'Content-Type: application/json' ${apiUrl}/indexes --data @${indexJSON}"
+ )
+ indexes = json.loads(machine.succeed("curl ${apiUrl}/indexes"))
+ assert indexes["total"] == 1, "index wasn't created"
- with subtest("add documents"):
- response = json.loads(
- machine.succeed(
- "curl -X POST -H 'Content-Type: application/json' ${apiUrl}/indexes/${uid}/documents --data-binary @${moviesJSON}"
- )
- )
- task_uid = response["taskUid"]
- machine.wait_until_succeeds(
- f"curl ${apiUrl}/tasks/{task_uid} | jq -e '.status == \"succeeded\"'"
- )
+ with subtest("add documents"):
+ response = json.loads(
+ machine.succeed(
+ "curl -X POST -H 'Content-Type: application/json' ${apiUrl}/indexes/${uid}/documents --data-binary @${moviesJSON}"
+ )
+ )
+ task_uid = response["taskUid"]
+ machine.wait_until_succeeds(
+ f"curl ${apiUrl}/tasks/{task_uid} | jq -e '.status == \"succeeded\"'"
+ )
- with subtest("search"):
- response = json.loads(
- machine.succeed("curl ${apiUrl}/indexes/movies/search?q=hero")
- )
- print(response)
- assert len(response["hits"]) >= 1, "no results found"
- '';
- }
-)
+ with subtest("search"):
+ response = json.loads(
+ machine.succeed("curl ${apiUrl}/indexes/movies/search?q=hero")
+ )
+ print(response)
+ assert len(response["hits"]) >= 1, "no results found"
+ '';
+}
diff --git a/nixos/tests/merecat.nix b/nixos/tests/merecat.nix
index 072d8dd933de..db790dff41e8 100644
--- a/nixos/tests/merecat.nix
+++ b/nixos/tests/merecat.nix
@@ -1,35 +1,33 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "merecat";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fgaz ];
- };
+{ pkgs, ... }:
+{
+ name = "merecat";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fgaz ];
+ };
- nodes.machine =
- { config, pkgs, ... }:
- {
- services.merecat = {
- enable = true;
- settings = {
- hostname = "localhost";
- virtual-host = true;
- directory = toString (
- pkgs.runCommand "merecat-webdir" { } ''
- mkdir -p $out/foo.localhost $out/bar.localhost
- echo 'Hello foo
' > $out/foo.localhost/index.html
- echo 'Hello bar
' > $out/bar.localhost/index.html
- ''
- );
- };
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ services.merecat = {
+ enable = true;
+ settings = {
+ hostname = "localhost";
+ virtual-host = true;
+ directory = toString (
+ pkgs.runCommand "merecat-webdir" { } ''
+ mkdir -p $out/foo.localhost $out/bar.localhost
+ echo 'Hello foo
' > $out/foo.localhost/index.html
+ echo 'Hello bar
' > $out/bar.localhost/index.html
+ ''
+ );
};
};
+ };
- testScript = ''
- machine.wait_for_unit("merecat")
- machine.wait_for_open_port(80)
- machine.succeed("curl --fail foo.localhost | grep 'Hello foo'")
- machine.succeed("curl --fail bar.localhost | grep 'Hello bar'")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("merecat")
+ machine.wait_for_open_port(80)
+ machine.succeed("curl --fail foo.localhost | grep 'Hello foo'")
+ machine.succeed("curl --fail bar.localhost | grep 'Hello bar'")
+ '';
+}
diff --git a/nixos/tests/metabase.nix b/nixos/tests/metabase.nix
index f86c51b108fc..bf606d5d32cf 100644
--- a/nixos/tests/metabase.nix
+++ b/nixos/tests/metabase.nix
@@ -1,24 +1,22 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "metabase";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ mmahut ];
- };
+{ pkgs, ... }:
+{
+ name = "metabase";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ mmahut ];
+ };
- nodes = {
- machine =
- { ... }:
- {
- services.metabase.enable = true;
- };
- };
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.metabase.enable = true;
+ };
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("metabase.service")
- machine.wait_for_open_port(3000)
- machine.wait_until_succeeds("curl -fL http://localhost:3000/setup | grep Metabase")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("metabase.service")
+ machine.wait_for_open_port(3000)
+ machine.wait_until_succeeds("curl -fL http://localhost:3000/setup | grep Metabase")
+ '';
+}
diff --git a/nixos/tests/mihomo.nix b/nixos/tests/mihomo.nix
index 4e16750a63b5..aa6bde4810fd 100644
--- a/nixos/tests/mihomo.nix
+++ b/nixos/tests/mihomo.nix
@@ -1,49 +1,47 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "mihomo";
- meta.maintainers = with pkgs.lib.maintainers; [ Guanran928 ];
+{ pkgs, ... }:
+{
+ name = "mihomo";
+ meta.maintainers = with pkgs.lib.maintainers; [ Guanran928 ];
- nodes.machine = {
- environment.systemPackages = [ pkgs.curl ];
+ nodes.machine = {
+ environment.systemPackages = [ pkgs.curl ];
- services.nginx = {
- enable = true;
- statusPage = true;
- };
-
- services.mihomo = {
- enable = true;
- configFile = pkgs.writeTextFile {
- name = "config.yaml";
- text = ''
- mixed-port: 7890
- external-controller: 127.0.0.1:9090
- authentication:
- - "user:supersecret"
- '';
- };
- };
+ services.nginx = {
+ enable = true;
+ statusPage = true;
};
- testScript = ''
- # Wait until it starts
- machine.wait_for_unit("nginx.service")
- machine.wait_for_unit("mihomo.service")
- machine.wait_for_open_port(80)
- machine.wait_for_open_port(7890)
- machine.wait_for_open_port(9090)
+ services.mihomo = {
+ enable = true;
+ configFile = pkgs.writeTextFile {
+ name = "config.yaml";
+ text = ''
+ mixed-port: 7890
+ external-controller: 127.0.0.1:9090
+ authentication:
+ - "user:supersecret"
+ '';
+ };
+ };
+ };
- # Proxy
- machine.succeed("curl --fail --max-time 10 --proxy http://user:supersecret@localhost:7890 http://localhost")
- machine.succeed("curl --fail --max-time 10 --proxy socks5://user:supersecret@localhost:7890 http://localhost")
- machine.fail("curl --fail --max-time 10 --proxy http://user:supervillain@localhost:7890 http://localhost")
- machine.fail("curl --fail --max-time 10 --proxy socks5://user:supervillain@localhost:7890 http://localhost")
+ testScript = ''
+ # Wait until it starts
+ machine.wait_for_unit("nginx.service")
+ machine.wait_for_unit("mihomo.service")
+ machine.wait_for_open_port(80)
+ machine.wait_for_open_port(7890)
+ machine.wait_for_open_port(9090)
- # Web UI
- result = machine.succeed("curl --fail http://localhost:9090")
- target = '{"hello":"mihomo"}\n'
- assert result == target, f"{result!r} != {target!r}"
- '';
- }
-)
+ # Proxy
+ machine.succeed("curl --fail --max-time 10 --proxy http://user:supersecret@localhost:7890 http://localhost")
+ machine.succeed("curl --fail --max-time 10 --proxy socks5://user:supersecret@localhost:7890 http://localhost")
+ machine.fail("curl --fail --max-time 10 --proxy http://user:supervillain@localhost:7890 http://localhost")
+ machine.fail("curl --fail --max-time 10 --proxy socks5://user:supervillain@localhost:7890 http://localhost")
+
+ # Web UI
+ result = machine.succeed("curl --fail http://localhost:9090")
+ target = '{"hello":"mihomo"}\n'
+ assert result == target, f"{result!r} != {target!r}"
+ '';
+}
diff --git a/nixos/tests/mimir.nix b/nixos/tests/mimir.nix
index 981990b93a1d..9922487751df 100644
--- a/nixos/tests/mimir.nix
+++ b/nixos/tests/mimir.nix
@@ -1,55 +1,53 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "mimir";
- nodes = {
- server =
- { ... }:
- {
- environment.systemPackages = [ pkgs.jq ];
- services.mimir.enable = true;
- services.mimir.configuration = {
- ingester.ring.replication_factor = 1;
+{ pkgs, ... }:
+{
+ name = "mimir";
+ nodes = {
+ server =
+ { ... }:
+ {
+ environment.systemPackages = [ pkgs.jq ];
+ services.mimir.enable = true;
+ services.mimir.configuration = {
+ ingester.ring.replication_factor = 1;
+ };
+
+ services.telegraf.enable = true;
+ services.telegraf.extraConfig = {
+ agent.interval = "1s";
+ agent.flush_interval = "1s";
+ inputs.exec = {
+ commands = [
+ "${pkgs.coreutils}/bin/echo 'foo i=42i'"
+ ];
+ data_format = "influx";
};
+ outputs = {
+ http = {
+ # test remote write
+ url = "http://localhost:8080/api/v1/push";
- services.telegraf.enable = true;
- services.telegraf.extraConfig = {
- agent.interval = "1s";
- agent.flush_interval = "1s";
- inputs.exec = {
- commands = [
- "${pkgs.coreutils}/bin/echo 'foo i=42i'"
- ];
- data_format = "influx";
- };
- outputs = {
- http = {
- # test remote write
- url = "http://localhost:8080/api/v1/push";
+ # Data format to output.
+ data_format = "prometheusremotewrite";
- # Data format to output.
- data_format = "prometheusremotewrite";
-
- headers = {
- Content-Type = "application/x-protobuf";
- Content-Encoding = "snappy";
- X-Scope-OrgID = "nixos";
- X-Prometheus-Remote-Write-Version = "0.1.0";
- };
+ headers = {
+ Content-Type = "application/x-protobuf";
+ Content-Encoding = "snappy";
+ X-Scope-OrgID = "nixos";
+ X-Prometheus-Remote-Write-Version = "0.1.0";
};
};
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
- server.wait_for_unit("mimir.service")
- server.wait_for_unit("telegraf.service")
- server.wait_for_open_port(8080)
- server.wait_until_succeeds(
- "curl -H 'X-Scope-OrgID: nixos' http://127.0.0.1:8080/prometheus/api/v1/label/host/values | jq -r '.data[0]' | grep server"
- )
- '';
- }
-)
+ testScript = ''
+ start_all()
+ server.wait_for_unit("mimir.service")
+ server.wait_for_unit("telegraf.service")
+ server.wait_for_open_port(8080)
+ server.wait_until_succeeds(
+ "curl -H 'X-Scope-OrgID: nixos' http://127.0.0.1:8080/prometheus/api/v1/label/host/values | jq -r '.data[0]' | grep server"
+ )
+ '';
+}
diff --git a/nixos/tests/mindustry.nix b/nixos/tests/mindustry.nix
index 3ec5fb32a0d3..d140520b1d19 100644
--- a/nixos/tests/mindustry.nix
+++ b/nixos/tests/mindustry.nix
@@ -1,32 +1,30 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "mindustry";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fgaz ];
+{ pkgs, ... }:
+{
+ name = "mindustry";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fgaz ];
+ };
+
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ];
+
+ services.xserver.enable = true;
+ environment.systemPackages = [ pkgs.mindustry ];
};
- nodes.machine =
- { config, pkgs, ... }:
- {
- imports = [
- ./common/x11.nix
- ];
+ enableOCR = true;
- services.xserver.enable = true;
- environment.systemPackages = [ pkgs.mindustry ];
- };
-
- enableOCR = true;
-
- testScript = ''
- machine.wait_for_x()
- machine.execute("mindustry >&2 &")
- machine.wait_for_window("Mindustry")
- # Loading can take a while. Avoid wasting cycles on OCR during that time
- machine.sleep(60)
- machine.wait_for_text(r"(Play|Database|Editor|Mods|Settings|Quit)")
- machine.screenshot("screen")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_x()
+ machine.execute("mindustry >&2 &")
+ machine.wait_for_window("Mindustry")
+ # Loading can take a while. Avoid wasting cycles on OCR during that time
+ machine.sleep(60)
+ machine.wait_for_text(r"(Play|Database|Editor|Mods|Settings|Quit)")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/minecraft-server.nix b/nixos/tests/minecraft-server.nix
index f8edf0aefb7a..3630025ec224 100644
--- a/nixos/tests/minecraft-server.nix
+++ b/nixos/tests/minecraft-server.nix
@@ -3,46 +3,44 @@ let
rcon-pass = "foobar";
rcon-port = 43000;
in
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "minecraft-server";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ nequissimus ];
- };
+{ pkgs, ... }:
+{
+ name = "minecraft-server";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ nequissimus ];
+ };
- nodes.server =
- { ... }:
- {
- environment.systemPackages = [ pkgs.mcrcon ];
+ nodes.server =
+ { ... }:
+ {
+ environment.systemPackages = [ pkgs.mcrcon ];
- nixpkgs.config.allowUnfree = true;
+ nixpkgs.config.allowUnfree = true;
- services.minecraft-server = {
- declarative = true;
- enable = true;
- eula = true;
- serverProperties = {
- enable-rcon = true;
- level-seed = seed;
- level-type = "flat";
- generate-structures = false;
- online-mode = false;
- "rcon.password" = rcon-pass;
- "rcon.port" = rcon-port;
- };
+ services.minecraft-server = {
+ declarative = true;
+ enable = true;
+ eula = true;
+ serverProperties = {
+ enable-rcon = true;
+ level-seed = seed;
+ level-type = "flat";
+ generate-structures = false;
+ online-mode = false;
+ "rcon.password" = rcon-pass;
+ "rcon.port" = rcon-port;
};
-
- virtualisation.memorySize = 2047;
};
- testScript = ''
- server.wait_for_unit("minecraft-server")
- server.wait_for_open_port(${toString rcon-port})
- assert "${seed}" in server.succeed(
- "mcrcon -H localhost -P ${toString rcon-port} -p '${rcon-pass}' -c 'seed'"
- )
- server.succeed("systemctl stop minecraft-server")
- '';
- }
-)
+ virtualisation.memorySize = 2047;
+ };
+
+ testScript = ''
+ server.wait_for_unit("minecraft-server")
+ server.wait_for_open_port(${toString rcon-port})
+ assert "${seed}" in server.succeed(
+ "mcrcon -H localhost -P ${toString rcon-port} -p '${rcon-pass}' -c 'seed'"
+ )
+ server.succeed("systemctl stop minecraft-server")
+ '';
+}
diff --git a/nixos/tests/minecraft.nix b/nixos/tests/minecraft.nix
index 5f75669900a2..db577a573b23 100644
--- a/nixos/tests/minecraft.nix
+++ b/nixos/tests/minecraft.nix
@@ -1,42 +1,40 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "minecraft";
- meta = with lib.maintainers; {
- maintainers = [ nequissimus ];
+{ pkgs, lib, ... }:
+{
+ name = "minecraft";
+ meta = with lib.maintainers; {
+ maintainers = [ nequissimus ];
+ };
+
+ nodes.client =
+ { nodes, ... }:
+ let
+ user = nodes.client.config.users.users.alice;
+ in
+ {
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
+
+ environment.systemPackages = [ pkgs.minecraft ];
+
+ nixpkgs.config.allowUnfree = true;
+
+ test-support.displayManager.auto.user = user.name;
};
- nodes.client =
- { nodes, ... }:
- let
- user = nodes.client.config.users.users.alice;
- in
- {
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
+ enableOCR = true;
- environment.systemPackages = [ pkgs.minecraft ];
-
- nixpkgs.config.allowUnfree = true;
-
- test-support.displayManager.auto.user = user.name;
- };
-
- enableOCR = true;
-
- testScript =
- { nodes, ... }:
- let
- user = nodes.client.config.users.users.alice;
- in
- ''
- client.wait_for_x()
- client.execute("su - alice -c minecraft-launcher >&2 &")
- client.wait_for_text("Create a new Microsoft account")
- client.sleep(10)
- client.screenshot("launcher")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.client.config.users.users.alice;
+ in
+ ''
+ client.wait_for_x()
+ client.execute("su - alice -c minecraft-launcher >&2 &")
+ client.wait_for_text("Create a new Microsoft account")
+ client.sleep(10)
+ client.screenshot("launcher")
+ '';
+}
diff --git a/nixos/tests/minidlna.nix b/nixos/tests/minidlna.nix
index a1add4ba4836..5e32190a9623 100644
--- a/nixos/tests/minidlna.nix
+++ b/nixos/tests/minidlna.nix
@@ -1,42 +1,40 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "minidlna";
+{ pkgs, ... }:
+{
+ name = "minidlna";
- nodes = {
- server =
- { ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
- services.minidlna.enable = true;
- services.minidlna.openFirewall = true;
- services.minidlna.settings = {
- log_level = "error";
- media_dir = [
- "PV,/tmp/stuff"
- ];
- friendly_name = "rpi3";
- root_container = "B";
- notify_interval = 60;
- album_art_names = [
- "Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg"
- "AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg"
- "Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg"
- ];
- };
+ nodes = {
+ server =
+ { ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+ services.minidlna.enable = true;
+ services.minidlna.openFirewall = true;
+ services.minidlna.settings = {
+ log_level = "error";
+ media_dir = [
+ "PV,/tmp/stuff"
+ ];
+ friendly_name = "rpi3";
+ root_container = "B";
+ notify_interval = 60;
+ album_art_names = [
+ "Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg"
+ "AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg"
+ "Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg"
+ ];
};
- client = { ... }: { };
- };
+ };
+ client = { ... }: { };
+ };
- testScript = ''
- start_all()
- server.succeed("mkdir -p /tmp/stuff && chown minidlna: /tmp/stuff")
- server.wait_for_unit("minidlna")
- server.wait_for_open_port(8200)
- # requests must be made *by IP* to avoid triggering minidlna's
- # DNS-rebinding protection
- server.succeed("curl --fail http://$(getent ahostsv4 localhost | head -n1 | cut -f 1 -d ' '):8200/")
- client.succeed("curl --fail http://$(getent ahostsv4 server | head -n1 | cut -f 1 -d ' '):8200/")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ server.succeed("mkdir -p /tmp/stuff && chown minidlna: /tmp/stuff")
+ server.wait_for_unit("minidlna")
+ server.wait_for_open_port(8200)
+ # requests must be made *by IP* to avoid triggering minidlna's
+ # DNS-rebinding protection
+ server.succeed("curl --fail http://$(getent ahostsv4 localhost | head -n1 | cut -f 1 -d ' '):8200/")
+ client.succeed("curl --fail http://$(getent ahostsv4 server | head -n1 | cut -f 1 -d ' '):8200/")
+ '';
+}
diff --git a/nixos/tests/miniflux.nix b/nixos/tests/miniflux.nix
index f349a7a2c45c..e13214a148a8 100644
--- a/nixos/tests/miniflux.nix
+++ b/nixos/tests/miniflux.nix
@@ -1,132 +1,130 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- port = 3142;
- username = "alice";
- password = "correcthorsebatterystaple";
- defaultPort = 8080;
- defaultUsername = "admin";
- defaultPassword = "password";
- adminCredentialsFile = pkgs.writeText "admin-credentials" ''
- ADMIN_USERNAME=${defaultUsername}
- ADMIN_PASSWORD=${defaultPassword}
- '';
- customAdminCredentialsFile = pkgs.writeText "admin-credentials" ''
- ADMIN_USERNAME=${username}
- ADMIN_PASSWORD=${password}
- '';
- postgresPassword = "correcthorsebatterystaple";
- postgresPasswordFile = pkgs.writeText "pgpass" ''
- *:*:*:*:${postgresPassword}
- '';
+let
+ port = 3142;
+ username = "alice";
+ password = "correcthorsebatterystaple";
+ defaultPort = 8080;
+ defaultUsername = "admin";
+ defaultPassword = "password";
+ adminCredentialsFile = pkgs.writeText "admin-credentials" ''
+ ADMIN_USERNAME=${defaultUsername}
+ ADMIN_PASSWORD=${defaultPassword}
+ '';
+ customAdminCredentialsFile = pkgs.writeText "admin-credentials" ''
+ ADMIN_USERNAME=${username}
+ ADMIN_PASSWORD=${password}
+ '';
+ postgresPassword = "correcthorsebatterystaple";
+ postgresPasswordFile = pkgs.writeText "pgpass" ''
+ *:*:*:*:${postgresPassword}
+ '';
- in
- {
- name = "miniflux";
- meta.maintainers = [ ];
+in
+{
+ name = "miniflux";
+ meta.maintainers = [ ];
- nodes = {
- default =
- { ... }:
- {
- security.apparmor.enable = true;
- services.miniflux = {
- enable = true;
- inherit adminCredentialsFile;
- };
+ nodes = {
+ default =
+ { ... }:
+ {
+ security.apparmor.enable = true;
+ services.miniflux = {
+ enable = true;
+ inherit adminCredentialsFile;
};
+ };
- withoutSudo =
- { ... }:
- {
- security.apparmor.enable = true;
- services.miniflux = {
- enable = true;
- inherit adminCredentialsFile;
- };
- security.sudo.enable = false;
+ withoutSudo =
+ { ... }:
+ {
+ security.apparmor.enable = true;
+ services.miniflux = {
+ enable = true;
+ inherit adminCredentialsFile;
};
+ security.sudo.enable = false;
+ };
- customized =
- { ... }:
- {
- security.apparmor.enable = true;
- services.miniflux = {
- enable = true;
- config = {
- CLEANUP_FREQUENCY = "48";
- LISTEN_ADDR = "localhost:${toString port}";
- };
- adminCredentialsFile = customAdminCredentialsFile;
+ customized =
+ { ... }:
+ {
+ security.apparmor.enable = true;
+ services.miniflux = {
+ enable = true;
+ config = {
+ CLEANUP_FREQUENCY = "48";
+ LISTEN_ADDR = "localhost:${toString port}";
};
+ adminCredentialsFile = customAdminCredentialsFile;
};
+ };
- postgresTcp =
- {
- config,
- pkgs,
- lib,
- ...
- }:
- {
- services.postgresql = {
- enable = true;
- initialScript = pkgs.writeText "init-postgres" ''
- CREATE USER miniflux WITH PASSWORD '${postgresPassword}';
- CREATE DATABASE miniflux WITH OWNER miniflux;
- '';
- enableTCPIP = true;
- authentication = ''
- host sameuser miniflux samenet scram-sha-256
- '';
- };
- systemd.services.postgresql.postStart = lib.mkAfter ''
- $PSQL -tAd miniflux -c 'CREATE EXTENSION hstore;'
+ postgresTcp =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ {
+ services.postgresql = {
+ enable = true;
+ initialScript = pkgs.writeText "init-postgres" ''
+ CREATE USER miniflux WITH PASSWORD '${postgresPassword}';
+ CREATE DATABASE miniflux WITH OWNER miniflux;
'';
- networking.firewall.allowedTCPPorts = [ config.services.postgresql.settings.port ];
- };
- externalDb =
- { ... }:
- {
- security.apparmor.enable = true;
- services.miniflux = {
- enable = true;
- createDatabaseLocally = false;
- inherit adminCredentialsFile;
- config = {
- DATABASE_URL = "user=miniflux host=postgresTcp dbname=miniflux sslmode=disable";
- PGPASSFILE = "/run/miniflux/pgpass";
- };
- };
- systemd.services.miniflux.preStart = ''
- cp ${postgresPasswordFile} /run/miniflux/pgpass
- chmod 600 /run/miniflux/pgpass
+ enableTCPIP = true;
+ authentication = ''
+ host sameuser miniflux samenet scram-sha-256
'';
};
- };
- testScript = ''
- def runTest(machine, port, user):
- machine.wait_for_unit("miniflux.service")
- machine.wait_for_open_port(port)
- machine.succeed(f"curl --fail 'http://localhost:{port}/healthcheck' | grep OK")
- machine.succeed(
- f"curl 'http://localhost:{port}/v1/me' -u '{user}' -H Content-Type:application/json | grep '\"is_admin\":true'"
- )
- machine.fail('journalctl -b --no-pager --grep "^audit: .*apparmor=\\"DENIED\\""')
+ systemd.services.postgresql.postStart = lib.mkAfter ''
+ $PSQL -tAd miniflux -c 'CREATE EXTENSION hstore;'
+ '';
+ networking.firewall.allowedTCPPorts = [ config.services.postgresql.settings.port ];
+ };
+ externalDb =
+ { ... }:
+ {
+ security.apparmor.enable = true;
+ services.miniflux = {
+ enable = true;
+ createDatabaseLocally = false;
+ inherit adminCredentialsFile;
+ config = {
+ DATABASE_URL = "user=miniflux host=postgresTcp dbname=miniflux sslmode=disable";
+ PGPASSFILE = "/run/miniflux/pgpass";
+ };
+ };
+ systemd.services.miniflux.preStart = ''
+ cp ${postgresPasswordFile} /run/miniflux/pgpass
+ chmod 600 /run/miniflux/pgpass
+ '';
+ };
+ };
+ testScript = ''
+ def runTest(machine, port, user):
+ machine.wait_for_unit("miniflux.service")
+ machine.wait_for_open_port(port)
+ machine.succeed(f"curl --fail 'http://localhost:{port}/healthcheck' | grep OK")
+ machine.succeed(
+ f"curl 'http://localhost:{port}/v1/me' -u '{user}' -H Content-Type:application/json | grep '\"is_admin\":true'"
+ )
+ machine.fail('journalctl -b --no-pager --grep "^audit: .*apparmor=\\"DENIED\\""')
- default.start()
- withoutSudo.start()
- customized.start()
- postgresTcp.start()
+ default.start()
+ withoutSudo.start()
+ customized.start()
+ postgresTcp.start()
- runTest(default, ${toString defaultPort}, "${defaultUsername}:${defaultPassword}")
- runTest(withoutSudo, ${toString defaultPort}, "${defaultUsername}:${defaultPassword}")
- runTest(customized, ${toString port}, "${username}:${password}")
+ runTest(default, ${toString defaultPort}, "${defaultUsername}:${defaultPassword}")
+ runTest(withoutSudo, ${toString defaultPort}, "${defaultUsername}:${defaultPassword}")
+ runTest(customized, ${toString port}, "${username}:${password}")
- postgresTcp.wait_for_unit("postgresql.service")
- externalDb.start()
- runTest(externalDb, ${toString defaultPort}, "${defaultUsername}:${defaultPassword}")
- '';
- }
-)
+ postgresTcp.wait_for_unit("postgresql.service")
+ externalDb.start()
+ runTest(externalDb, ${toString defaultPort}, "${defaultUsername}:${defaultPassword}")
+ '';
+}
diff --git a/nixos/tests/minio.nix b/nixos/tests/minio.nix
index d4d34ea660f0..dfe7f169def1 100644
--- a/nixos/tests/minio.nix
+++ b/nixos/tests/minio.nix
@@ -1,116 +1,114 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
- openssl req \
- -x509 -newkey rsa:4096 -sha256 -days 365 \
- -nodes -out cert.pem -keyout key.pem \
- -subj '/CN=minio' -addext "subjectAltName=DNS:localhost"
+{ pkgs, ... }:
+let
+ tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
+ openssl req \
+ -x509 -newkey rsa:4096 -sha256 -days 365 \
+ -nodes -out cert.pem -keyout key.pem \
+ -subj '/CN=minio' -addext "subjectAltName=DNS:localhost"
- mkdir -p $out
- cp key.pem cert.pem $out
- '';
+ mkdir -p $out
+ cp key.pem cert.pem $out
+ '';
- accessKey = "BKIKJAA5BMMU2RHO6IBB";
- secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
- minioPythonScript = pkgs.writeScript "minio-test.py" ''
- #! ${pkgs.python3.withPackages (ps: [ ps.minio ])}/bin/python
- import io
- import os
- import sys
- from minio import Minio
+ accessKey = "BKIKJAA5BMMU2RHO6IBB";
+ secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
+ minioPythonScript = pkgs.writeScript "minio-test.py" ''
+ #! ${pkgs.python3.withPackages (ps: [ ps.minio ])}/bin/python
+ import io
+ import os
+ import sys
+ from minio import Minio
- if len(sys.argv) > 1 and sys.argv[1] == 'tls':
- tls = True
- else:
- tls = False
+ if len(sys.argv) > 1 and sys.argv[1] == 'tls':
+ tls = True
+ else:
+ tls = False
- minioClient = Minio('localhost:9000',
- access_key='${accessKey}',
- secret_key='${secretKey}',
- secure=tls,
- cert_check=False)
- sio = io.BytesIO()
- sio.write(b'Test from Python')
- sio.seek(0, os.SEEK_END)
- sio_len = sio.tell()
- sio.seek(0)
- minioClient.put_object('test-bucket', 'test.txt', sio, sio_len, content_type='text/plain')
- '';
- rootCredentialsFile = "/etc/nixos/minio-root-credentials";
- credsPartial = pkgs.writeText "minio-credentials-partial" ''
- MINIO_ROOT_USER=${accessKey}
- '';
- credsFull = pkgs.writeText "minio-credentials-full" ''
- MINIO_ROOT_USER=${accessKey}
- MINIO_ROOT_PASSWORD=${secretKey}
- '';
- in
- {
- name = "minio";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ bachp ];
- };
+ minioClient = Minio('localhost:9000',
+ access_key='${accessKey}',
+ secret_key='${secretKey}',
+ secure=tls,
+ cert_check=False)
+ sio = io.BytesIO()
+ sio.write(b'Test from Python')
+ sio.seek(0, os.SEEK_END)
+ sio_len = sio.tell()
+ sio.seek(0)
+ minioClient.put_object('test-bucket', 'test.txt', sio, sio_len, content_type='text/plain')
+ '';
+ rootCredentialsFile = "/etc/nixos/minio-root-credentials";
+ credsPartial = pkgs.writeText "minio-credentials-partial" ''
+ MINIO_ROOT_USER=${accessKey}
+ '';
+ credsFull = pkgs.writeText "minio-credentials-full" ''
+ MINIO_ROOT_USER=${accessKey}
+ MINIO_ROOT_PASSWORD=${secretKey}
+ '';
+in
+{
+ name = "minio";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ bachp ];
+ };
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.minio = {
- enable = true;
- inherit rootCredentialsFile;
- };
- environment.systemPackages = [ pkgs.minio-client ];
-
- # Minio requires at least 1GiB of free disk space to run.
- virtualisation.diskSize = 4 * 1024;
-
- # Minio pre allocates 2GiB or memory, reserve some more
- virtualisation.memorySize = 4096;
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.minio = {
+ enable = true;
+ inherit rootCredentialsFile;
};
- };
+ environment.systemPackages = [ pkgs.minio-client ];
- testScript = ''
+ # Minio requires at least 1GiB of free disk space to run.
+ virtualisation.diskSize = 4 * 1024;
- start_all()
- # simulate manually editing root credentials file
- machine.wait_for_unit("multi-user.target")
- machine.copy_from_host("${credsFull}", "${rootCredentialsFile}")
+ # Minio pre allocates 2GiB or memory, reserve some more
+ virtualisation.memorySize = 4096;
+ };
+ };
- # Test non-TLS server
- machine.wait_for_unit("minio.service")
- machine.wait_for_open_port(9000)
+ testScript = ''
- # Create a test bucket on the server
- machine.succeed(
- "mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
- )
- machine.succeed("mc mb minio/test-bucket")
- machine.succeed("${minioPythonScript}")
- assert "test-bucket" in machine.succeed("mc ls minio")
- assert "Test from Python" in machine.succeed("mc cat minio/test-bucket/test.txt")
- machine.succeed("mc rb --force minio/test-bucket")
- machine.systemctl("stop minio.service")
+ start_all()
+ # simulate manually editing root credentials file
+ machine.wait_for_unit("multi-user.target")
+ machine.copy_from_host("${credsFull}", "${rootCredentialsFile}")
- # Test TLS server
- machine.copy_from_host("${tls-cert}/cert.pem", "/var/lib/minio/certs/public.crt")
- machine.copy_from_host("${tls-cert}/key.pem", "/var/lib/minio/certs/private.key")
+ # Test non-TLS server
+ machine.wait_for_unit("minio.service")
+ machine.wait_for_open_port(9000)
- machine.systemctl("start minio.service")
- machine.wait_for_unit("minio.service")
- machine.wait_for_open_port(9000)
+ # Create a test bucket on the server
+ machine.succeed(
+ "mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
+ )
+ machine.succeed("mc mb minio/test-bucket")
+ machine.succeed("${minioPythonScript}")
+ assert "test-bucket" in machine.succeed("mc ls minio")
+ assert "Test from Python" in machine.succeed("mc cat minio/test-bucket/test.txt")
+ machine.succeed("mc rb --force minio/test-bucket")
+ machine.systemctl("stop minio.service")
- # Create a test bucket on the server
- machine.succeed(
- "mc config host add minio https://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
- )
- machine.succeed("mc --insecure mb minio/test-bucket")
- machine.succeed("${minioPythonScript} tls")
- assert "test-bucket" in machine.succeed("mc --insecure ls minio")
- assert "Test from Python" in machine.succeed("mc --insecure cat minio/test-bucket/test.txt")
- machine.succeed("mc --insecure rb --force minio/test-bucket")
+ # Test TLS server
+ machine.copy_from_host("${tls-cert}/cert.pem", "/var/lib/minio/certs/public.crt")
+ machine.copy_from_host("${tls-cert}/key.pem", "/var/lib/minio/certs/private.key")
- machine.shutdown()
- '';
- }
-)
+ machine.systemctl("start minio.service")
+ machine.wait_for_unit("minio.service")
+ machine.wait_for_open_port(9000)
+
+ # Create a test bucket on the server
+ machine.succeed(
+ "mc config host add minio https://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
+ )
+ machine.succeed("mc --insecure mb minio/test-bucket")
+ machine.succeed("${minioPythonScript} tls")
+ assert "test-bucket" in machine.succeed("mc --insecure ls minio")
+ assert "Test from Python" in machine.succeed("mc --insecure cat minio/test-bucket/test.txt")
+ machine.succeed("mc --insecure rb --force minio/test-bucket")
+
+ machine.shutdown()
+ '';
+}
diff --git a/nixos/tests/misc.nix b/nixos/tests/misc.nix
index 55d719aeafbb..50efcbd28999 100644
--- a/nixos/tests/misc.nix
+++ b/nixos/tests/misc.nix
@@ -1,170 +1,168 @@
# Miscellaneous small tests that don't warrant their own VM run.
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- let
- foo = pkgs.writeText "foo" "Hello World";
- in
- {
- name = "misc";
- meta.maintainers = with lib.maintainers; [ eelco ];
+{ lib, pkgs, ... }:
+let
+ foo = pkgs.writeText "foo" "Hello World";
+in
+{
+ name = "misc";
+ meta.maintainers = with lib.maintainers; [ eelco ];
- nodes.machine =
- { lib, ... }:
- {
- swapDevices = lib.mkOverride 0 [
- {
- device = "/root/swapfile";
- size = 128;
- }
- ];
- environment.variables.EDITOR = lib.mkOverride 0 "emacs";
- systemd.tmpfiles.rules = [ "d /tmp 1777 root root 10d" ];
- systemd.tmpfiles.settings."10-test"."/tmp/somefile".d = { };
- virtualisation.fileSystems = {
- "/tmp2" = {
- fsType = "tmpfs";
- options = [
- "mode=1777"
- "noauto"
- ];
- };
- # Tests https://discourse.nixos.org/t/how-to-make-a-derivations-executables-have-the-s-permission/8555
- "/user-mount/point" = {
- device = "/user-mount/source";
- fsType = "none";
- options = [
- "bind"
- "rw"
- "user"
- "noauto"
- ];
- };
- "/user-mount/denied-point" = {
- device = "/user-mount/denied-source";
- fsType = "none";
- options = [
- "bind"
- "rw"
- "noauto"
- ];
- };
+ nodes.machine =
+ { lib, ... }:
+ {
+ swapDevices = lib.mkOverride 0 [
+ {
+ device = "/root/swapfile";
+ size = 128;
+ }
+ ];
+ environment.variables.EDITOR = lib.mkOverride 0 "emacs";
+ systemd.tmpfiles.rules = [ "d /tmp 1777 root root 10d" ];
+ systemd.tmpfiles.settings."10-test"."/tmp/somefile".d = { };
+ virtualisation.fileSystems = {
+ "/tmp2" = {
+ fsType = "tmpfs";
+ options = [
+ "mode=1777"
+ "noauto"
+ ];
};
- systemd.automounts = lib.singleton {
- wantedBy = [ "multi-user.target" ];
- where = "/tmp2";
+ # Tests https://discourse.nixos.org/t/how-to-make-a-derivations-executables-have-the-s-permission/8555
+ "/user-mount/point" = {
+ device = "/user-mount/source";
+ fsType = "none";
+ options = [
+ "bind"
+ "rw"
+ "user"
+ "noauto"
+ ];
};
- users.users.sybil = {
- isNormalUser = true;
- group = "wheel";
+ "/user-mount/denied-point" = {
+ device = "/user-mount/denied-source";
+ fsType = "none";
+ options = [
+ "bind"
+ "rw"
+ "noauto"
+ ];
};
- users.users.alice = {
- isNormalUser = true;
- };
- security.sudo = {
- enable = true;
- wheelNeedsPassword = false;
- };
- boot.kernel.sysctl."vm.swappiness" = 1;
- boot.kernelParams = [ "vsyscall=emulate" ];
- system.extraDependencies = [ foo ];
};
+ systemd.automounts = lib.singleton {
+ wantedBy = [ "multi-user.target" ];
+ where = "/tmp2";
+ };
+ users.users.sybil = {
+ isNormalUser = true;
+ group = "wheel";
+ };
+ users.users.alice = {
+ isNormalUser = true;
+ };
+ security.sudo = {
+ enable = true;
+ wheelNeedsPassword = false;
+ };
+ boot.kernel.sysctl."vm.swappiness" = 1;
+ boot.kernelParams = [ "vsyscall=emulate" ];
+ system.extraDependencies = [ foo ];
+ };
- testScript = ''
- with subtest("nixos-version"):
- machine.succeed("[ `nixos-version | wc -w` = 2 ]")
+ testScript = ''
+ with subtest("nixos-version"):
+ machine.succeed("[ `nixos-version | wc -w` = 2 ]")
- with subtest("nixos-rebuild"):
- assert "NixOS module" in machine.succeed("nixos-rebuild --help")
+ with subtest("nixos-rebuild"):
+ assert "NixOS module" in machine.succeed("nixos-rebuild --help")
- with subtest("Sanity check for uid/gid assignment"):
- assert "4" == machine.succeed("id -u messagebus").strip()
- assert "4" == machine.succeed("id -g messagebus").strip()
- assert "users:x:100:" == machine.succeed("getent group users").strip()
+ with subtest("Sanity check for uid/gid assignment"):
+ assert "4" == machine.succeed("id -u messagebus").strip()
+ assert "4" == machine.succeed("id -g messagebus").strip()
+ assert "users:x:100:" == machine.succeed("getent group users").strip()
- with subtest("Regression test for GMP aborts on QEMU."):
- machine.succeed("expr 1 + 2")
+ with subtest("Regression test for GMP aborts on QEMU."):
+ machine.succeed("expr 1 + 2")
- with subtest("the swap file got created"):
- machine.wait_for_unit("root-swapfile.swap")
- machine.succeed("ls -l /root/swapfile | grep 134217728")
+ with subtest("the swap file got created"):
+ machine.wait_for_unit("root-swapfile.swap")
+ machine.succeed("ls -l /root/swapfile | grep 134217728")
- with subtest("whether kernel.poweroff_cmd is set"):
- machine.succeed('[ -x "$(cat /proc/sys/kernel/poweroff_cmd)" ]')
+ with subtest("whether kernel.poweroff_cmd is set"):
+ machine.succeed('[ -x "$(cat /proc/sys/kernel/poweroff_cmd)" ]')
- with subtest("whether the io cgroupv2 controller is properly enabled"):
- machine.succeed("grep -q '\\bio\\b' /sys/fs/cgroup/cgroup.controllers")
+ with subtest("whether the io cgroupv2 controller is properly enabled"):
+ machine.succeed("grep -q '\\bio\\b' /sys/fs/cgroup/cgroup.controllers")
- with subtest("whether we have a reboot record in wtmp"):
- machine.shutdown
- machine.wait_for_unit("multi-user.target")
- machine.succeed("last | grep reboot >&2")
+ with subtest("whether we have a reboot record in wtmp"):
+ machine.shutdown
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("last | grep reboot >&2")
- with subtest("whether we can override environment variables"):
- machine.succeed('[ "$EDITOR" = emacs ]')
+ with subtest("whether we can override environment variables"):
+ machine.succeed('[ "$EDITOR" = emacs ]')
- with subtest("whether hostname (and by extension nss_myhostname) works"):
- assert "machine" == machine.succeed("hostname").strip()
- assert "machine" == machine.succeed("hostname -s").strip()
+ with subtest("whether hostname (and by extension nss_myhostname) works"):
+ assert "machine" == machine.succeed("hostname").strip()
+ assert "machine" == machine.succeed("hostname -s").strip()
- with subtest("whether systemd-udevd automatically loads modules for our hardware"):
- machine.succeed("systemctl start systemd-udev-settle.service")
- machine.wait_for_unit("systemd-udev-settle.service")
- assert "mousedev" in machine.succeed("lsmod")
+ with subtest("whether systemd-udevd automatically loads modules for our hardware"):
+ machine.succeed("systemctl start systemd-udev-settle.service")
+ machine.wait_for_unit("systemd-udev-settle.service")
+ assert "mousedev" in machine.succeed("lsmod")
- with subtest("whether systemd-tmpfiles-clean works"):
- machine.succeed(
- "touch /tmp/foo", "systemctl start systemd-tmpfiles-clean", "[ -e /tmp/foo ]"
- )
- # move into the future
- machine.succeed(
- 'date -s "@$(($(date +%s) + 1000000))"',
- "systemctl start systemd-tmpfiles-clean",
- )
- machine.fail("[ -e /tmp/foo ]")
+ with subtest("whether systemd-tmpfiles-clean works"):
+ machine.succeed(
+ "touch /tmp/foo", "systemctl start systemd-tmpfiles-clean", "[ -e /tmp/foo ]"
+ )
+ # move into the future
+ machine.succeed(
+ 'date -s "@$(($(date +%s) + 1000000))"',
+ "systemctl start systemd-tmpfiles-clean",
+ )
+ machine.fail("[ -e /tmp/foo ]")
- with subtest("whether systemd-tmpfiles settings works"):
- machine.succeed("[ -e /tmp/somefile ]")
+ with subtest("whether systemd-tmpfiles settings works"):
+ machine.succeed("[ -e /tmp/somefile ]")
- with subtest("/etc/mtab"):
- assert "/proc/mounts" == machine.succeed("readlink --no-newline /etc/mtab")
+ with subtest("/etc/mtab"):
+ assert "/proc/mounts" == machine.succeed("readlink --no-newline /etc/mtab")
- with subtest("whether automounting works"):
- machine.fail("grep '/tmp2 tmpfs' /proc/mounts")
- machine.succeed("touch /tmp2/x")
- machine.succeed("grep '/tmp2 tmpfs' /proc/mounts")
+ with subtest("whether automounting works"):
+ machine.fail("grep '/tmp2 tmpfs' /proc/mounts")
+ machine.succeed("touch /tmp2/x")
+ machine.succeed("grep '/tmp2 tmpfs' /proc/mounts")
- with subtest(
- "Whether mounting by a user is possible with the `user` option in fstab (#95444)"
- ):
- machine.succeed("mkdir -p /user-mount/source")
- machine.succeed("touch /user-mount/source/file")
- machine.succeed("chmod -R a+Xr /user-mount/source")
- machine.succeed("mkdir /user-mount/point")
- machine.succeed("chown alice:users /user-mount/point")
- machine.succeed("su - alice -c 'mount /user-mount/point'")
- machine.succeed("su - alice -c 'ls /user-mount/point/file'")
- with subtest(
- "Whether mounting by a user is denied without the `user` option in fstab"
- ):
- machine.succeed("mkdir -p /user-mount/denied-source")
- machine.succeed("touch /user-mount/denied-source/file")
- machine.succeed("chmod -R a+Xr /user-mount/denied-source")
- machine.succeed("mkdir /user-mount/denied-point")
- machine.succeed("chown alice:users /user-mount/denied-point")
- machine.fail("su - alice -c 'mount /user-mount/denied-point'")
+ with subtest(
+ "Whether mounting by a user is possible with the `user` option in fstab (#95444)"
+ ):
+ machine.succeed("mkdir -p /user-mount/source")
+ machine.succeed("touch /user-mount/source/file")
+ machine.succeed("chmod -R a+Xr /user-mount/source")
+ machine.succeed("mkdir /user-mount/point")
+ machine.succeed("chown alice:users /user-mount/point")
+ machine.succeed("su - alice -c 'mount /user-mount/point'")
+ machine.succeed("su - alice -c 'ls /user-mount/point/file'")
+ with subtest(
+ "Whether mounting by a user is denied without the `user` option in fstab"
+ ):
+ machine.succeed("mkdir -p /user-mount/denied-source")
+ machine.succeed("touch /user-mount/denied-source/file")
+ machine.succeed("chmod -R a+Xr /user-mount/denied-source")
+ machine.succeed("mkdir /user-mount/denied-point")
+ machine.succeed("chown alice:users /user-mount/denied-point")
+ machine.fail("su - alice -c 'mount /user-mount/denied-point'")
- with subtest("shell-vars"):
- machine.succeed('[ -n "$NIX_PATH" ]')
+ with subtest("shell-vars"):
+ machine.succeed('[ -n "$NIX_PATH" ]')
- with subtest("Test sysctl"):
- machine.wait_for_unit("systemd-sysctl.service")
- assert "1" == machine.succeed("sysctl -ne vm.swappiness").strip()
- machine.execute("sysctl vm.swappiness=60")
- assert "60" == machine.succeed("sysctl -ne vm.swappiness").strip()
+ with subtest("Test sysctl"):
+ machine.wait_for_unit("systemd-sysctl.service")
+ assert "1" == machine.succeed("sysctl -ne vm.swappiness").strip()
+ machine.execute("sysctl vm.swappiness=60")
+ assert "60" == machine.succeed("sysctl -ne vm.swappiness").strip()
- with subtest("Test boot parameters"):
- assert "vsyscall=emulate" in machine.succeed("cat /proc/cmdline")
- '';
- }
-)
+ with subtest("Test boot parameters"):
+ assert "vsyscall=emulate" in machine.succeed("cat /proc/cmdline")
+ '';
+}
diff --git a/nixos/tests/misskey.nix b/nixos/tests/misskey.nix
index 1a450c518aae..9afa7aa0cee4 100644
--- a/nixos/tests/misskey.nix
+++ b/nixos/tests/misskey.nix
@@ -1,29 +1,27 @@
-import ./make-test-python.nix (
- { lib, ... }:
- let
- port = 61812;
- in
- {
- name = "misskey";
+{ lib, ... }:
+let
+ port = 61812;
+in
+{
+ name = "misskey";
- meta.maintainers = [ lib.maintainers.feathecutie ];
+ meta.maintainers = [ lib.maintainers.feathecutie ];
- nodes.machine = {
- services.misskey = {
- enable = true;
- settings = {
- url = "http://misskey.local";
- inherit port;
- };
- database.createLocally = true;
- redis.createLocally = true;
+ nodes.machine = {
+ services.misskey = {
+ enable = true;
+ settings = {
+ url = "http://misskey.local";
+ inherit port;
};
+ database.createLocally = true;
+ redis.createLocally = true;
};
+ };
- testScript = ''
- machine.wait_for_unit("misskey.service")
- machine.wait_for_open_port(${toString port})
- machine.succeed("curl --fail http://localhost:${toString port}/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("misskey.service")
+ machine.wait_for_open_port(${toString port})
+ machine.succeed("curl --fail http://localhost:${toString port}/")
+ '';
+}
diff --git a/nixos/tests/mod_perl.nix b/nixos/tests/mod_perl.nix
index 677f2bcbc969..6bcca2b914f4 100644
--- a/nixos/tests/mod_perl.nix
+++ b/nixos/tests/mod_perl.nix
@@ -1,65 +1,63 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "mod_perl";
+{ pkgs, lib, ... }:
+{
+ name = "mod_perl";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ sgo ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ sgo ];
+ };
- nodes.machine =
- {
- config,
- lib,
- pkgs,
- ...
- }:
- {
- services.httpd = {
- enable = true;
- adminAddr = "admin@localhost";
- virtualHosts."modperl" =
- let
- inc = pkgs.writeTextDir "ModPerlTest.pm" ''
- package ModPerlTest;
- use strict;
- use Apache2::RequestRec ();
- use Apache2::RequestIO ();
- use Apache2::Const -compile => qw(OK);
- sub handler {
- my $r = shift;
- $r->content_type('text/plain');
- print "Hello mod_perl!\n";
- return Apache2::Const::OK;
- }
- 1;
- '';
- startup = pkgs.writeScript "startup.pl" ''
- use lib "${inc}",
- split ":","${with pkgs.perl.pkgs; makeFullPerlPath ([ mod_perl2 ])}";
- 1;
- '';
- in
- {
+ nodes.machine =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ services.httpd = {
+ enable = true;
+ adminAddr = "admin@localhost";
+ virtualHosts."modperl" =
+ let
+ inc = pkgs.writeTextDir "ModPerlTest.pm" ''
+ package ModPerlTest;
+ use strict;
+ use Apache2::RequestRec ();
+ use Apache2::RequestIO ();
+ use Apache2::Const -compile => qw(OK);
+ sub handler {
+ my $r = shift;
+ $r->content_type('text/plain');
+ print "Hello mod_perl!\n";
+ return Apache2::Const::OK;
+ }
+ 1;
+ '';
+ startup = pkgs.writeScript "startup.pl" ''
+ use lib "${inc}",
+ split ":","${with pkgs.perl.pkgs; makeFullPerlPath ([ mod_perl2 ])}";
+ 1;
+ '';
+ in
+ {
+ extraConfig = ''
+ PerlRequire ${startup}
+ '';
+ locations."/modperl" = {
extraConfig = ''
- PerlRequire ${startup}
+ SetHandler perl-script
+ PerlResponseHandler ModPerlTest
'';
- locations."/modperl" = {
- extraConfig = ''
- SetHandler perl-script
- PerlResponseHandler ModPerlTest
- '';
- };
};
- enablePerl = true;
- };
+ };
+ enablePerl = true;
};
- testScript =
- { ... }:
- ''
- machine.wait_for_unit("httpd.service")
- response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/modperl")
- assert "Hello mod_perl!" in response, "/modperl handler did not respond"
- '';
- }
-)
+ };
+ testScript =
+ { ... }:
+ ''
+ machine.wait_for_unit("httpd.service")
+ response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/modperl")
+ assert "Hello mod_perl!" in response, "/modperl handler did not respond"
+ '';
+}
diff --git a/nixos/tests/molly-brown.nix b/nixos/tests/molly-brown.nix
index 72e42c4a5be8..56d969ae79bf 100644
--- a/nixos/tests/molly-brown.nix
+++ b/nixos/tests/molly-brown.nix
@@ -1,79 +1,77 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- testString = "NixOS Gemini test successful";
- in
- {
+let
+ testString = "NixOS Gemini test successful";
+in
+{
- name = "molly-brown";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ehmry ];
- };
+ name = "molly-brown";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ehmry ];
+ };
- nodes = {
+ nodes = {
- geminiServer =
- { config, pkgs, ... }:
- let
- inherit (config.networking) hostName;
- cfg = config.services.molly-brown;
- in
- {
+ geminiServer =
+ { config, pkgs, ... }:
+ let
+ inherit (config.networking) hostName;
+ cfg = config.services.molly-brown;
+ in
+ {
- environment.systemPackages = [
- (pkgs.writeScriptBin "test-gemini" ''
- #!${pkgs.python3}/bin/python
+ environment.systemPackages = [
+ (pkgs.writeScriptBin "test-gemini" ''
+ #!${pkgs.python3}/bin/python
- import socket
- import ssl
- import tempfile
- import textwrap
- import urllib.parse
+ import socket
+ import ssl
+ import tempfile
+ import textwrap
+ import urllib.parse
- url = "gemini://geminiServer/init.gmi"
- parsed_url = urllib.parse.urlparse(url)
+ url = "gemini://geminiServer/init.gmi"
+ parsed_url = urllib.parse.urlparse(url)
- s = socket.create_connection((parsed_url.netloc, 1965))
- context = ssl.SSLContext()
- context.check_hostname = False
- context.verify_mode = ssl.CERT_NONE
- s = context.wrap_socket(s, server_hostname=parsed_url.netloc)
- s.sendall((url + "\r\n").encode("UTF-8"))
- fp = s.makefile("rb")
- print(fp.readline().strip())
- print(fp.readline().strip())
- print(fp.readline().strip())
- '')
- ];
+ s = socket.create_connection((parsed_url.netloc, 1965))
+ context = ssl.SSLContext()
+ context.check_hostname = False
+ context.verify_mode = ssl.CERT_NONE
+ s = context.wrap_socket(s, server_hostname=parsed_url.netloc)
+ s.sendall((url + "\r\n").encode("UTF-8"))
+ fp = s.makefile("rb")
+ print(fp.readline().strip())
+ print(fp.readline().strip())
+ print(fp.readline().strip())
+ '')
+ ];
- networking.firewall.allowedTCPPorts = [ cfg.settings.Port ];
+ networking.firewall.allowedTCPPorts = [ cfg.settings.Port ];
- services.molly-brown = {
- enable = true;
- docBase = "/tmp/docs";
- certPath = "/tmp/cert.pem";
- keyPath = "/tmp/key.pem";
- };
-
- systemd.services.molly-brown.preStart = ''
- ${pkgs.openssl}/bin/openssl genrsa -out "/tmp/key.pem"
- ${pkgs.openssl}/bin/openssl req -new \
- -subj "/CN=${config.networking.hostName}" \
- -key "/tmp/key.pem" -out /tmp/request.pem
- ${pkgs.openssl}/bin/openssl x509 -req -days 3650 \
- -in /tmp/request.pem -signkey "/tmp/key.pem" -out "/tmp/cert.pem"
-
- mkdir -p "${cfg.settings.DocBase}"
- echo "${testString}" > "${cfg.settings.DocBase}/test.gmi"
- '';
+ services.molly-brown = {
+ enable = true;
+ docBase = "/tmp/docs";
+ certPath = "/tmp/cert.pem";
+ keyPath = "/tmp/key.pem";
};
- };
- testScript = ''
- geminiServer.wait_for_unit("molly-brown")
- geminiServer.wait_for_open_port(1965)
- geminiServer.succeed("test-gemini")
- '';
- }
-)
+ systemd.services.molly-brown.preStart = ''
+ ${pkgs.openssl}/bin/openssl genrsa -out "/tmp/key.pem"
+ ${pkgs.openssl}/bin/openssl req -new \
+ -subj "/CN=${config.networking.hostName}" \
+ -key "/tmp/key.pem" -out /tmp/request.pem
+ ${pkgs.openssl}/bin/openssl x509 -req -days 3650 \
+ -in /tmp/request.pem -signkey "/tmp/key.pem" -out "/tmp/cert.pem"
+
+ mkdir -p "${cfg.settings.DocBase}"
+ echo "${testString}" > "${cfg.settings.DocBase}/test.gmi"
+ '';
+ };
+ };
+ testScript = ''
+ geminiServer.wait_for_unit("molly-brown")
+ geminiServer.wait_for_open_port(1965)
+ geminiServer.succeed("test-gemini")
+ '';
+
+}
diff --git a/nixos/tests/mollysocket.nix b/nixos/tests/mollysocket.nix
index ccfc20fdda6b..b4acbb1095cb 100644
--- a/nixos/tests/mollysocket.nix
+++ b/nixos/tests/mollysocket.nix
@@ -1,30 +1,28 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- port = 1234;
- in
- {
- name = "mollysocket";
- meta.maintainers = with lib.maintainers; [ dotlambda ];
+let
+ port = 1234;
+in
+{
+ name = "mollysocket";
+ meta.maintainers = with lib.maintainers; [ dotlambda ];
- nodes.mollysocket =
- { ... }:
- {
- services.mollysocket = {
- enable = true;
- settings = {
- inherit port;
- };
+ nodes.mollysocket =
+ { ... }:
+ {
+ services.mollysocket = {
+ enable = true;
+ settings = {
+ inherit port;
};
};
+ };
- testScript = ''
- mollysocket.wait_for_unit("mollysocket.service")
- mollysocket.wait_for_open_port(${toString port})
+ testScript = ''
+ mollysocket.wait_for_unit("mollysocket.service")
+ mollysocket.wait_for_open_port(${toString port})
- out = mollysocket.succeed("curl --fail http://127.0.0.1:${toString port}")
- assert "Version ${pkgs.mollysocket.version}" in out
- '';
- }
-)
+ out = mollysocket.succeed("curl --fail http://127.0.0.1:${toString port}")
+ assert "Version ${pkgs.mollysocket.version}" in out
+ '';
+}
diff --git a/nixos/tests/monado.nix b/nixos/tests/monado.nix
index 9b7e636d1f66..609b0fa647e5 100644
--- a/nixos/tests/monado.nix
+++ b/nixos/tests/monado.nix
@@ -1,51 +1,49 @@
-import ./make-test-python.nix (
- { ... }:
- {
- name = "monado";
+{ ... }:
+{
+ name = "monado";
- nodes.machine =
- { pkgs, ... }:
+ nodes.machine =
+ { pkgs, ... }:
- {
- hardware.graphics.enable = true;
- users.users.alice = {
- isNormalUser = true;
- uid = 1000;
- };
-
- services.monado = {
- enable = true;
- defaultRuntime = true;
-
- forceDefaultRuntime = true;
- };
- # Stop Monado from probing for any hardware
- systemd.user.services.monado.environment.SIMULATED_ENABLE = "1";
-
- environment.systemPackages = with pkgs; [ openxr-loader ];
+ {
+ hardware.graphics.enable = true;
+ users.users.alice = {
+ isNormalUser = true;
+ uid = 1000;
};
- testScript =
- { nodes, ... }:
- let
- userId = toString nodes.machine.users.users.alice.uid;
- runtimePath = "/run/user/${userId}";
- in
- ''
- # for defaultRuntime
- machine.succeed("stat /etc/xdg/openxr/1/active_runtime.json")
+ services.monado = {
+ enable = true;
+ defaultRuntime = true;
- machine.succeed("loginctl enable-linger alice")
- machine.wait_for_unit("user@${userId}.service")
+ forceDefaultRuntime = true;
+ };
+ # Stop Monado from probing for any hardware
+ systemd.user.services.monado.environment.SIMULATED_ENABLE = "1";
- machine.wait_for_unit("monado.socket", "alice")
- machine.systemctl("start monado.service", "alice")
- machine.wait_for_unit("monado.service", "alice")
+ environment.systemPackages = with pkgs; [ openxr-loader ];
+ };
- # for forceDefaultRuntime
- machine.succeed("stat /home/alice/.config/openxr/1/active_runtime.json")
+ testScript =
+ { nodes, ... }:
+ let
+ userId = toString nodes.machine.users.users.alice.uid;
+ runtimePath = "/run/user/${userId}";
+ in
+ ''
+ # for defaultRuntime
+ machine.succeed("stat /etc/xdg/openxr/1/active_runtime.json")
- machine.succeed("su -- alice -c env XDG_RUNTIME_DIR=${runtimePath} openxr_runtime_list")
- '';
- }
-)
+ machine.succeed("loginctl enable-linger alice")
+ machine.wait_for_unit("user@${userId}.service")
+
+ machine.wait_for_unit("monado.socket", "alice")
+ machine.systemctl("start monado.service", "alice")
+ machine.wait_for_unit("monado.service", "alice")
+
+ # for forceDefaultRuntime
+ machine.succeed("stat /home/alice/.config/openxr/1/active_runtime.json")
+
+ machine.succeed("su -- alice -c env XDG_RUNTIME_DIR=${runtimePath} openxr_runtime_list")
+ '';
+}
diff --git a/nixos/tests/monetdb.nix b/nixos/tests/monetdb.nix
index 53c732338554..0ea2d2843635 100644
--- a/nixos/tests/monetdb.nix
+++ b/nixos/tests/monetdb.nix
@@ -1,81 +1,79 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- creds = pkgs.writeText ".monetdb" ''
- user=monetdb
- password=monetdb
- '';
- createUser = pkgs.writeText "createUser.sql" ''
- CREATE USER "voc" WITH PASSWORD 'voc' NAME 'VOC Explorer' SCHEMA "sys";
- CREATE SCHEMA "voc" AUTHORIZATION "voc";
- ALTER USER "voc" SET SCHEMA "voc";
- '';
- credsVoc = pkgs.writeText ".monetdb" ''
- user=voc
- password=voc
- '';
- transaction = pkgs.writeText "transaction" ''
- START TRANSACTION;
- CREATE TABLE test (id int, data varchar(30));
- ROLLBACK;
- '';
- vocData = pkgs.fetchzip {
- url = "https://dev.monetdb.org/Assets/VOC/voc_dump.zip";
- hash = "sha256-sQ5acTsSAiXQfOgt2PhN7X7Z9TZGZtLrPPxgQT2pCGQ=";
- };
- onboardPeople = pkgs.writeText "onboardPeople" ''
- CREATE VIEW onboard_people AS
- SELECT * FROM (
- SELECT 'craftsmen' AS type, craftsmen.* FROM craftsmen
- UNION ALL
- SELECT 'impotenten' AS type, impotenten.* FROM impotenten
- UNION ALL
- SELECT 'passengers' AS type, passengers.* FROM passengers
- UNION ALL
- SELECT 'seafarers' AS type, seafarers.* FROM seafarers
- UNION ALL
- SELECT 'soldiers' AS type, soldiers.* FROM soldiers
- UNION ALL
- SELECT 'total' AS type, total.* FROM total
- ) AS onboard_people_table;
- SELECT type, COUNT(*) AS total
- FROM onboard_people GROUP BY type ORDER BY type;
- '';
- onboardExpected = pkgs.lib.strings.replaceStrings [ "\n" ] [ "\\n" ] ''
- +------------+-------+
- | type | total |
- +============+=======+
- | craftsmen | 2349 |
- | impotenten | 938 |
- | passengers | 2813 |
- | seafarers | 4468 |
- | soldiers | 4177 |
- | total | 2467 |
- +------------+-------+
- '';
- in
- {
- name = "monetdb";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ StillerHarpo ];
- };
- nodes.machine.services.monetdb.enable = true;
- testScript = ''
- machine.start()
- machine.wait_for_unit("monetdb")
- machine.succeed("monetdbd create mydbfarm")
- machine.succeed("monetdbd start mydbfarm")
- machine.succeed("monetdb create voc")
- machine.succeed("monetdb release voc")
- machine.succeed("cp ${creds} ./.monetdb")
- assert "hello world" in machine.succeed("mclient -d voc -s \"SELECT 'hello world'\"")
- machine.succeed("mclient -d voc ${createUser}")
- machine.succeed("cp ${credsVoc} ./.monetdb")
- machine.succeed("mclient -d voc ${transaction}")
- machine.succeed("mclient -d voc ${vocData}/voc_dump.sql")
- assert "8131" in machine.succeed("mclient -d voc -s \"SELECT count(*) FROM voyages\"")
- assert "${onboardExpected}" in machine.succeed("mclient -d voc ${onboardPeople}")
+{ pkgs, ... }:
+let
+ creds = pkgs.writeText ".monetdb" ''
+ user=monetdb
+ password=monetdb
+ '';
+ createUser = pkgs.writeText "createUser.sql" ''
+ CREATE USER "voc" WITH PASSWORD 'voc' NAME 'VOC Explorer' SCHEMA "sys";
+ CREATE SCHEMA "voc" AUTHORIZATION "voc";
+ ALTER USER "voc" SET SCHEMA "voc";
+ '';
+ credsVoc = pkgs.writeText ".monetdb" ''
+ user=voc
+ password=voc
+ '';
+ transaction = pkgs.writeText "transaction" ''
+ START TRANSACTION;
+ CREATE TABLE test (id int, data varchar(30));
+ ROLLBACK;
+ '';
+ vocData = pkgs.fetchzip {
+ url = "https://dev.monetdb.org/Assets/VOC/voc_dump.zip";
+ hash = "sha256-sQ5acTsSAiXQfOgt2PhN7X7Z9TZGZtLrPPxgQT2pCGQ=";
+ };
+ onboardPeople = pkgs.writeText "onboardPeople" ''
+ CREATE VIEW onboard_people AS
+ SELECT * FROM (
+ SELECT 'craftsmen' AS type, craftsmen.* FROM craftsmen
+ UNION ALL
+ SELECT 'impotenten' AS type, impotenten.* FROM impotenten
+ UNION ALL
+ SELECT 'passengers' AS type, passengers.* FROM passengers
+ UNION ALL
+ SELECT 'seafarers' AS type, seafarers.* FROM seafarers
+ UNION ALL
+ SELECT 'soldiers' AS type, soldiers.* FROM soldiers
+ UNION ALL
+ SELECT 'total' AS type, total.* FROM total
+ ) AS onboard_people_table;
+ SELECT type, COUNT(*) AS total
+ FROM onboard_people GROUP BY type ORDER BY type;
+ '';
+ onboardExpected = pkgs.lib.strings.replaceStrings [ "\n" ] [ "\\n" ] ''
+ +------------+-------+
+ | type | total |
+ +============+=======+
+ | craftsmen | 2349 |
+ | impotenten | 938 |
+ | passengers | 2813 |
+ | seafarers | 4468 |
+ | soldiers | 4177 |
+ | total | 2467 |
+ +------------+-------+
+ '';
+in
+{
+ name = "monetdb";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ StillerHarpo ];
+ };
+ nodes.machine.services.monetdb.enable = true;
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("monetdb")
+ machine.succeed("monetdbd create mydbfarm")
+ machine.succeed("monetdbd start mydbfarm")
+ machine.succeed("monetdb create voc")
+ machine.succeed("monetdb release voc")
+ machine.succeed("cp ${creds} ./.monetdb")
+ assert "hello world" in machine.succeed("mclient -d voc -s \"SELECT 'hello world'\"")
+ machine.succeed("mclient -d voc ${createUser}")
+ machine.succeed("cp ${credsVoc} ./.monetdb")
+ machine.succeed("mclient -d voc ${transaction}")
+ machine.succeed("mclient -d voc ${vocData}/voc_dump.sql")
+ assert "8131" in machine.succeed("mclient -d voc -s \"SELECT count(*) FROM voyages\"")
+ assert "${onboardExpected}" in machine.succeed("mclient -d voc ${onboardPeople}")
- '';
- }
-)
+ '';
+}
diff --git a/nixos/tests/moonraker.nix b/nixos/tests/moonraker.nix
index 7eb43b68d1ee..fdefb64c852b 100644
--- a/nixos/tests/moonraker.nix
+++ b/nixos/tests/moonraker.nix
@@ -1,53 +1,51 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "moonraker";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ zhaofengli ];
- };
+{ pkgs, ... }:
+{
+ name = "moonraker";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ zhaofengli ];
+ };
- nodes = {
- printer =
- { config, pkgs, ... }:
- {
- security.polkit.enable = true;
+ nodes = {
+ printer =
+ { config, pkgs, ... }:
+ {
+ security.polkit.enable = true;
- services.moonraker = {
- enable = true;
- allowSystemControl = true;
+ services.moonraker = {
+ enable = true;
+ allowSystemControl = true;
- settings = {
- authorization = {
- trusted_clients = [
- "127.0.0.0/8"
- "::1/128"
- ];
- };
+ settings = {
+ authorization = {
+ trusted_clients = [
+ "127.0.0.0/8"
+ "::1/128"
+ ];
};
};
-
- services.klipper = {
- enable = true;
-
- user = "moonraker";
- group = "moonraker";
-
- # No mcu configured so won't even enter `ready` state
- settings = { };
- };
};
- };
- testScript = ''
- printer.start()
+ services.klipper = {
+ enable = true;
- printer.wait_for_unit("klipper.service")
- printer.wait_for_unit("moonraker.service")
- printer.wait_until_succeeds("curl http://localhost:7125/printer/info | grep -v 'Not Found' >&2", timeout=30)
+ user = "moonraker";
+ group = "moonraker";
- with subtest("Check that we can perform system-level operations"):
- printer.succeed("curl -X POST http://localhost:7125/machine/services/stop?service=klipper | grep ok >&2")
- printer.wait_until_succeeds("systemctl --no-pager show klipper.service | grep ActiveState=inactive", timeout=10)
- '';
- }
-)
+ # No mcu configured so won't even enter `ready` state
+ settings = { };
+ };
+ };
+ };
+
+ testScript = ''
+ printer.start()
+
+ printer.wait_for_unit("klipper.service")
+ printer.wait_for_unit("moonraker.service")
+ printer.wait_until_succeeds("curl http://localhost:7125/printer/info | grep -v 'Not Found' >&2", timeout=30)
+
+ with subtest("Check that we can perform system-level operations"):
+ printer.succeed("curl -X POST http://localhost:7125/machine/services/stop?service=klipper | grep ok >&2")
+ printer.wait_until_succeeds("systemctl --no-pager show klipper.service | grep ActiveState=inactive", timeout=10)
+ '';
+}
diff --git a/nixos/tests/moosefs.nix b/nixos/tests/moosefs.nix
index 633e872f0d30..3166d34bf14a 100644
--- a/nixos/tests/moosefs.nix
+++ b/nixos/tests/moosefs.nix
@@ -1,99 +1,97 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- master =
- { pkgs, ... }:
- {
- # data base is stored in memory
- # server crashes with default memory size
- virtualisation.memorySize = 1024;
+let
+ master =
+ { pkgs, ... }:
+ {
+ # data base is stored in memory
+ # server crashes with default memory size
+ virtualisation.memorySize = 1024;
- services.moosefs.master = {
- enable = true;
- openFirewall = true;
- autoInit = true;
- exports = [
- "* / rw,alldirs,admin,maproot=0:0"
- "* . rw"
- ];
- };
+ services.moosefs.master = {
+ enable = true;
+ openFirewall = true;
+ autoInit = true;
+ exports = [
+ "* / rw,alldirs,admin,maproot=0:0"
+ "* . rw"
+ ];
};
-
- chunkserver =
- { pkgs, ... }:
- {
- virtualisation.emptyDiskImages = [ 4096 ];
- boot.initrd.postDeviceCommands = ''
- ${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
- '';
-
- fileSystems = pkgs.lib.mkVMOverride {
- "/data" = {
- device = "/dev/disk/by-label/data";
- fsType = "ext4";
- };
- };
-
- services.moosefs = {
- masterHost = "master";
- chunkserver = {
- openFirewall = true;
- enable = true;
- hdds = [ "~/data" ];
- };
- };
- };
-
- metalogger =
- { pkgs, ... }:
- {
- services.moosefs = {
- masterHost = "master";
- metalogger.enable = true;
- };
- };
-
- client =
- { pkgs, ... }:
- {
- services.moosefs.client.enable = true;
- };
-
- in
- {
- name = "moosefs";
-
- nodes = {
- inherit master;
- inherit metalogger;
- chunkserver1 = chunkserver;
- chunkserver2 = chunkserver;
- client1 = client;
- client2 = client;
};
- testScript = ''
- # prepare master server
- master.start()
- master.wait_for_unit("multi-user.target")
- master.wait_for_unit("mfs-master.service")
+ chunkserver =
+ { pkgs, ... }:
+ {
+ virtualisation.emptyDiskImages = [ 4096 ];
+ boot.initrd.postDeviceCommands = ''
+ ${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
+ '';
- metalogger.wait_for_unit("mfs-metalogger.service")
+ fileSystems = pkgs.lib.mkVMOverride {
+ "/data" = {
+ device = "/dev/disk/by-label/data";
+ fsType = "ext4";
+ };
+ };
- for chunkserver in [chunkserver1, chunkserver2]:
- chunkserver.wait_for_unit("multi-user.target")
- chunkserver.succeed("chown moosefs:moosefs /data")
- chunkserver.succeed("systemctl restart mfs-chunkserver")
- chunkserver.wait_for_unit("mfs-chunkserver.service")
+ services.moosefs = {
+ masterHost = "master";
+ chunkserver = {
+ openFirewall = true;
+ enable = true;
+ hdds = [ "~/data" ];
+ };
+ };
+ };
- for client in [client1, client2]:
- client.wait_for_unit("multi-user.target")
- client.succeed("mkdir /moosefs")
- client.succeed("mount -t moosefs master:/ /moosefs")
+ metalogger =
+ { pkgs, ... }:
+ {
+ services.moosefs = {
+ masterHost = "master";
+ metalogger.enable = true;
+ };
+ };
- client1.succeed("echo test > /moosefs/file")
- client2.succeed("grep test /moosefs/file")
- '';
- }
-)
+ client =
+ { pkgs, ... }:
+ {
+ services.moosefs.client.enable = true;
+ };
+
+in
+{
+ name = "moosefs";
+
+ nodes = {
+ inherit master;
+ inherit metalogger;
+ chunkserver1 = chunkserver;
+ chunkserver2 = chunkserver;
+ client1 = client;
+ client2 = client;
+ };
+
+ testScript = ''
+ # prepare master server
+ master.start()
+ master.wait_for_unit("multi-user.target")
+ master.wait_for_unit("mfs-master.service")
+
+ metalogger.wait_for_unit("mfs-metalogger.service")
+
+ for chunkserver in [chunkserver1, chunkserver2]:
+ chunkserver.wait_for_unit("multi-user.target")
+ chunkserver.succeed("chown moosefs:moosefs /data")
+ chunkserver.succeed("systemctl restart mfs-chunkserver")
+ chunkserver.wait_for_unit("mfs-chunkserver.service")
+
+ for client in [client1, client2]:
+ client.wait_for_unit("multi-user.target")
+ client.succeed("mkdir /moosefs")
+ client.succeed("mount -t moosefs master:/ /moosefs")
+
+ client1.succeed("echo test > /moosefs/file")
+ client2.succeed("grep test /moosefs/file")
+ '';
+}
diff --git a/nixos/tests/mopidy.nix b/nixos/tests/mopidy.nix
index e8447af8c75a..305a12f5aa2e 100644
--- a/nixos/tests/mopidy.nix
+++ b/nixos/tests/mopidy.nix
@@ -1,17 +1,15 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "mopidy";
+{ pkgs, ... }:
+{
+ name = "mopidy";
- nodes.machine =
- { ... }:
- {
- services.mopidy.enable = true;
- };
+ nodes.machine =
+ { ... }:
+ {
+ services.mopidy.enable = true;
+ };
- testScript = ''
- machine.wait_for_unit("mopidy")
- machine.wait_for_open_port(6680)
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("mopidy")
+ machine.wait_for_open_port(6680)
+ '';
+}
diff --git a/nixos/tests/morty.nix b/nixos/tests/morty.nix
index 4ec44e31d487..b8e490fbbcb5 100644
--- a/nixos/tests/morty.nix
+++ b/nixos/tests/morty.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "morty";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ leenaars ];
- };
+{
+ name = "morty";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ leenaars ];
+ };
- nodes = {
- mortyProxyWithKey =
+ nodes = {
+ mortyProxyWithKey =
- { ... }:
- {
- services.morty = {
- enable = true;
- key = "78a9cd0cfee20c672f78427efb2a2a96036027f0";
- port = 3001;
- };
- };
-
- };
-
- testScript =
{ ... }:
- ''
- mortyProxyWithKey.wait_for_unit("default.target")
- mortyProxyWithKey.wait_for_open_port(3001)
- mortyProxyWithKey.succeed("curl -fL 127.0.0.1:3001 | grep MortyProxy")
- '';
+ {
+ services.morty = {
+ enable = true;
+ key = "78a9cd0cfee20c672f78427efb2a2a96036027f0";
+ port = 3001;
+ };
+ };
- }
-)
+ };
+
+ testScript =
+ { ... }:
+ ''
+ mortyProxyWithKey.wait_for_unit("default.target")
+ mortyProxyWithKey.wait_for_open_port(3001)
+ mortyProxyWithKey.succeed("curl -fL 127.0.0.1:3001 | grep MortyProxy")
+ '';
+
+}
diff --git a/nixos/tests/mtp.nix b/nixos/tests/mtp.nix
index b4efef0318aa..6eab7ad995a6 100644
--- a/nixos/tests/mtp.nix
+++ b/nixos/tests/mtp.nix
@@ -1,121 +1,119 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "mtp";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- matthewcroughan
- nixinator
- ];
- };
+{ pkgs, ... }:
+{
+ name = "mtp";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ matthewcroughan
+ nixinator
+ ];
+ };
- nodes = {
- client =
- { config, pkgs, ... }:
- {
- # DBUS runs only once a user session is created, which means a user has to
- # login. Here, we log in as root. Once logged in, the gvfs-daemon service runs
- # as UID 0 in User-0.service
- services.getty.autologinUser = "root";
+ nodes = {
+ client =
+ { config, pkgs, ... }:
+ {
+ # DBUS runs only once a user session is created, which means a user has to
+ # login. Here, we log in as root. Once logged in, the gvfs-daemon service runs
+ # as UID 0 in User-0.service
+ services.getty.autologinUser = "root";
- # XDG_RUNTIME_DIR is needed for running systemd-user services such as
- # gvfs-daemon as root.
- environment.variables.XDG_RUNTIME_DIR = "/run/user/0";
+ # XDG_RUNTIME_DIR is needed for running systemd-user services such as
+ # gvfs-daemon as root.
+ environment.variables.XDG_RUNTIME_DIR = "/run/user/0";
- environment.systemPackages = with pkgs; [
- usbutils
- glib
- jmtpfs
- tree
- ];
- services.gvfs.enable = true;
+ environment.systemPackages = with pkgs; [
+ usbutils
+ glib
+ jmtpfs
+ tree
+ ];
+ services.gvfs.enable = true;
- # Creates a usb-mtp device inside the VM, which is mapped to the host's
- # /tmp folder, it is able to write files to this location, but only has
- # permissions to read its own creations.
- virtualisation.qemu.options = [
- "-usb"
- "-device usb-mtp,rootdir=/tmp,readonly=false"
- ];
- };
- };
+ # Creates a usb-mtp device inside the VM, which is mapped to the host's
+ # /tmp folder, it is able to write files to this location, but only has
+ # permissions to read its own creations.
+ virtualisation.qemu.options = [
+ "-usb"
+ "-device usb-mtp,rootdir=/tmp,readonly=false"
+ ];
+ };
+ };
- testScript =
- { nodes, ... }:
- let
- # Creates a list of QEMU MTP devices matching USB ID (46f4:0004). This
- # value can be sourced in a shell script. This is so we can loop over the
- # devices we find, as this test may want to use more than one MTP device
- # in future.
- mtpDevices = pkgs.writeScript "mtpDevices.sh" ''
- export mtpDevices=$(lsusb -d 46f4:0004 | awk {'print $2","$4'} | sed 's/[:-]/ /g')
- '';
- # Qemu is only capable of creating an MTP device with Picture Transfer
- # Protocol. This means that gvfs must use gphoto2:// rather than mtp://
- # when mounting.
- # https://github.com/qemu/qemu/blob/970bc16f60937bcfd334f14c614bd4407c247961/hw/usb/dev-mtp.c#L278
- gvfs = rec {
- mountAllMtpDevices = pkgs.writeScript "mountAllMtpDevices.sh" ''
- set -e
- source ${mtpDevices}
- for i in $mtpDevices
- do
- gio mount "gphoto2://[usb:$i]/"
- done
- '';
- unmountAllMtpDevices = pkgs.writeScript "unmountAllMtpDevices.sh" ''
- set -e
- source ${mtpDevices}
- for i in $mtpDevices
- do
- gio mount -u "gphoto2://[usb:$i]/"
- done
- '';
- # gvfsTest:
- # 1. Creates a 10M test file
- # 2. Copies it to the device using GIO tools
- # 3. Checks for corruption with `diff`
- # 4. Removes the file, then unmounts the disks.
- gvfsTest = pkgs.writeScript "gvfsTest.sh" ''
- set -e
- source ${mtpDevices}
- ${mountAllMtpDevices}
- dd if=/dev/urandom of=testFile10M bs=1M count=10
- for i in $mtpDevices
- do
- gio copy ./testFile10M gphoto2://[usb:$i]/
- ls -lah /run/user/0/gvfs/*/testFile10M
- gio remove gphoto2://[usb:$i]/testFile10M
- done
- ${unmountAllMtpDevices}
- '';
- };
- jmtpfs = {
- # jmtpfsTest:
- # 1. Mounts the device on a dir named `phone` using jmtpfs
- # 2. Puts the current Nixpkgs libmtp version into a file
- # 3. Checks for corruption with `diff`
- # 4. Prints the directory tree
- jmtpfsTest = pkgs.writeScript "jmtpfsTest.sh" ''
- set -e
- mkdir phone
- jmtpfs phone
- echo "${pkgs.libmtp.version}" > phone/tmp/testFile
- echo "${pkgs.libmtp.version}" > testFile
- diff phone/tmp/testFile testFile
- tree phone
- '';
- };
- in
- # Using >&2 allows the results of the scripts to be printed to the terminal
- # when building this test with Nix. Scripts would otherwise complete
- # silently.
- ''
- start_all()
- client.wait_for_unit("multi-user.target")
- client.wait_for_unit("dbus.service")
- client.succeed("${gvfs.gvfsTest} >&2")
- client.succeed("${jmtpfs.jmtpfsTest} >&2")
+ testScript =
+ { nodes, ... }:
+ let
+ # Creates a list of QEMU MTP devices matching USB ID (46f4:0004). This
+ # value can be sourced in a shell script. This is so we can loop over the
+ # devices we find, as this test may want to use more than one MTP device
+ # in future.
+ mtpDevices = pkgs.writeScript "mtpDevices.sh" ''
+ export mtpDevices=$(lsusb -d 46f4:0004 | awk {'print $2","$4'} | sed 's/[:-]/ /g')
'';
- }
-)
+ # Qemu is only capable of creating an MTP device with Picture Transfer
+ # Protocol. This means that gvfs must use gphoto2:// rather than mtp://
+ # when mounting.
+ # https://github.com/qemu/qemu/blob/970bc16f60937bcfd334f14c614bd4407c247961/hw/usb/dev-mtp.c#L278
+ gvfs = rec {
+ mountAllMtpDevices = pkgs.writeScript "mountAllMtpDevices.sh" ''
+ set -e
+ source ${mtpDevices}
+ for i in $mtpDevices
+ do
+ gio mount "gphoto2://[usb:$i]/"
+ done
+ '';
+ unmountAllMtpDevices = pkgs.writeScript "unmountAllMtpDevices.sh" ''
+ set -e
+ source ${mtpDevices}
+ for i in $mtpDevices
+ do
+ gio mount -u "gphoto2://[usb:$i]/"
+ done
+ '';
+ # gvfsTest:
+ # 1. Creates a 10M test file
+ # 2. Copies it to the device using GIO tools
+ # 3. Checks for corruption with `diff`
+ # 4. Removes the file, then unmounts the disks.
+ gvfsTest = pkgs.writeScript "gvfsTest.sh" ''
+ set -e
+ source ${mtpDevices}
+ ${mountAllMtpDevices}
+ dd if=/dev/urandom of=testFile10M bs=1M count=10
+ for i in $mtpDevices
+ do
+ gio copy ./testFile10M gphoto2://[usb:$i]/
+ ls -lah /run/user/0/gvfs/*/testFile10M
+ gio remove gphoto2://[usb:$i]/testFile10M
+ done
+ ${unmountAllMtpDevices}
+ '';
+ };
+ jmtpfs = {
+ # jmtpfsTest:
+ # 1. Mounts the device on a dir named `phone` using jmtpfs
+ # 2. Puts the current Nixpkgs libmtp version into a file
+ # 3. Checks for corruption with `diff`
+ # 4. Prints the directory tree
+ jmtpfsTest = pkgs.writeScript "jmtpfsTest.sh" ''
+ set -e
+ mkdir phone
+ jmtpfs phone
+ echo "${pkgs.libmtp.version}" > phone/tmp/testFile
+ echo "${pkgs.libmtp.version}" > testFile
+ diff phone/tmp/testFile testFile
+ tree phone
+ '';
+ };
+ in
+ # Using >&2 allows the results of the scripts to be printed to the terminal
+ # when building this test with Nix. Scripts would otherwise complete
+ # silently.
+ ''
+ start_all()
+ client.wait_for_unit("multi-user.target")
+ client.wait_for_unit("dbus.service")
+ client.succeed("${gvfs.gvfsTest} >&2")
+ client.succeed("${jmtpfs.jmtpfsTest} >&2")
+ '';
+}
diff --git a/nixos/tests/multipass.nix b/nixos/tests/multipass.nix
index da63a7a41fbb..33919cde81ed 100644
--- a/nixos/tests/multipass.nix
+++ b/nixos/tests/multipass.nix
@@ -1,41 +1,39 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- multipass-image = import ../release.nix {
- configuration = {
- # Building documentation makes the test unnecessarily take a longer time:
- documentation.enable = lib.mkForce false;
+let
+ multipass-image = import ../release.nix {
+ configuration = {
+ # Building documentation makes the test unnecessarily take a longer time:
+ documentation.enable = lib.mkForce false;
+ };
+ };
+
+in
+{
+ name = "multipass";
+
+ meta.maintainers = [ lib.maintainers.jnsgruk ];
+
+ nodes.machine =
+ { lib, ... }:
+ {
+ virtualisation = {
+ cores = 1;
+ memorySize = 1024;
+ diskSize = 4096;
+
+ multipass.enable = true;
};
};
- in
- {
- name = "multipass";
+ testScript = ''
+ machine.wait_for_unit("sockets.target")
+ machine.wait_for_unit("multipass.service")
+ machine.wait_for_file("/var/lib/multipass/data/multipassd/network/multipass_subnet")
- meta.maintainers = [ lib.maintainers.jnsgruk ];
+ # Wait for Multipass to settle
+ machine.sleep(1)
- nodes.machine =
- { lib, ... }:
- {
- virtualisation = {
- cores = 1;
- memorySize = 1024;
- diskSize = 4096;
-
- multipass.enable = true;
- };
- };
-
- testScript = ''
- machine.wait_for_unit("sockets.target")
- machine.wait_for_unit("multipass.service")
- machine.wait_for_file("/var/lib/multipass/data/multipassd/network/multipass_subnet")
-
- # Wait for Multipass to settle
- machine.sleep(1)
-
- machine.succeed("multipass list")
- '';
- }
-)
+ machine.succeed("multipass list")
+ '';
+}
diff --git a/nixos/tests/munin.nix b/nixos/tests/munin.nix
index b28562bbaa2e..fad3f2b52fae 100644
--- a/nixos/tests/munin.nix
+++ b/nixos/tests/munin.nix
@@ -1,49 +1,47 @@
# This test runs basic munin setup with node and cron job running on the same
# machine.
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "munin";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ domenkozar ];
- };
+{ pkgs, ... }:
+{
+ name = "munin";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ domenkozar ];
+ };
- nodes = {
- one =
- { config, ... }:
- {
- services = {
- munin-node = {
- enable = true;
- # disable a failing plugin to prevent irrelevant error message, see #23049
- disabledPlugins = [ "apc_nis" ];
- };
- munin-cron = {
- enable = true;
- hosts = ''
- [${config.networking.hostName}]
- address localhost
- '';
- };
+ nodes = {
+ one =
+ { config, ... }:
+ {
+ services = {
+ munin-node = {
+ enable = true;
+ # disable a failing plugin to prevent irrelevant error message, see #23049
+ disabledPlugins = [ "apc_nis" ];
+ };
+ munin-cron = {
+ enable = true;
+ hosts = ''
+ [${config.networking.hostName}]
+ address localhost
+ '';
};
-
- # increase the systemd timer interval so it fires more often
- systemd.timers.munin-cron.timerConfig.OnCalendar = pkgs.lib.mkForce "*:*:0/10";
};
- };
- testScript = ''
- start_all()
+ # increase the systemd timer interval so it fires more often
+ systemd.timers.munin-cron.timerConfig.OnCalendar = pkgs.lib.mkForce "*:*:0/10";
+ };
+ };
- with subtest("ensure munin-node starts and listens on 4949"):
- one.wait_for_unit("munin-node.service")
- one.wait_for_open_port(4949)
+ testScript = ''
+ start_all()
- with subtest("ensure munin-cron output is correct"):
- one.wait_for_file("/var/lib/munin/one/one-uptime-uptime-g.rrd")
- one.wait_for_file("/var/www/munin/one/index.html")
- one.wait_for_file("/var/www/munin/one/one/diskstat_iops_vda-day.png", timeout=60)
- '';
- }
-)
+ with subtest("ensure munin-node starts and listens on 4949"):
+ one.wait_for_unit("munin-node.service")
+ one.wait_for_open_port(4949)
+
+ with subtest("ensure munin-cron output is correct"):
+ one.wait_for_file("/var/lib/munin/one/one-uptime-uptime-g.rrd")
+ one.wait_for_file("/var/www/munin/one/index.html")
+ one.wait_for_file("/var/www/munin/one/one/diskstat_iops_vda-day.png", timeout=60)
+ '';
+}
diff --git a/nixos/tests/mutable-users.nix b/nixos/tests/mutable-users.nix
index e4e35f2d7220..3b262ff0821f 100644
--- a/nixos/tests/mutable-users.nix
+++ b/nixos/tests/mutable-users.nix
@@ -1,76 +1,74 @@
# Mutable users tests.
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "mutable-users";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ gleber ];
- };
+{ pkgs, ... }:
+{
+ name = "mutable-users";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ gleber ];
+ };
- nodes = {
- machine = {
- specialisation.immutable.configuration = {
- users.mutableUsers = false;
- };
+ nodes = {
+ machine = {
+ specialisation.immutable.configuration = {
+ users.mutableUsers = false;
+ };
- specialisation.mutable.configuration = {
- users.mutableUsers = true;
- users.users.dry-test.isNormalUser = true;
- };
+ specialisation.mutable.configuration = {
+ users.mutableUsers = true;
+ users.users.dry-test.isNormalUser = true;
};
};
+ };
- testScript = ''
- machine.start()
- machine.wait_for_unit("default.target")
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("default.target")
- # Machine starts in immutable mode. Add a user and test if reactivating
- # configuration removes the user.
- with subtest("Machine in immutable mode"):
- assert "foobar" not in machine.succeed("cat /etc/passwd")
- machine.succeed("sudo useradd foobar")
- assert "foobar" in machine.succeed("cat /etc/passwd")
- machine.succeed(
- "/run/booted-system/specialisation/immutable/bin/switch-to-configuration test"
- )
- assert "foobar" not in machine.succeed("cat /etc/passwd")
+ # Machine starts in immutable mode. Add a user and test if reactivating
+ # configuration removes the user.
+ with subtest("Machine in immutable mode"):
+ assert "foobar" not in machine.succeed("cat /etc/passwd")
+ machine.succeed("sudo useradd foobar")
+ assert "foobar" in machine.succeed("cat /etc/passwd")
+ machine.succeed(
+ "/run/booted-system/specialisation/immutable/bin/switch-to-configuration test"
+ )
+ assert "foobar" not in machine.succeed("cat /etc/passwd")
- # In immutable mode passwd is not wrapped, while in mutable mode it is
- # wrapped.
- with subtest("Password is wrapped in mutable mode"):
- assert "/run/current-system/" in machine.succeed("which passwd")
- machine.succeed(
- "/run/booted-system/specialisation/mutable/bin/switch-to-configuration test"
- )
- assert "/run/wrappers/" in machine.succeed("which passwd")
+ # In immutable mode passwd is not wrapped, while in mutable mode it is
+ # wrapped.
+ with subtest("Password is wrapped in mutable mode"):
+ assert "/run/current-system/" in machine.succeed("which passwd")
+ machine.succeed(
+ "/run/booted-system/specialisation/mutable/bin/switch-to-configuration test"
+ )
+ assert "/run/wrappers/" in machine.succeed("which passwd")
- with subtest("dry-activation does not change files"):
- machine.succeed('test -e /home/dry-test') # home was created
- machine.succeed('rm -rf /home/dry-test')
+ with subtest("dry-activation does not change files"):
+ machine.succeed('test -e /home/dry-test') # home was created
+ machine.succeed('rm -rf /home/dry-test')
- files_to_check = ['/etc/group',
- '/etc/passwd',
- '/etc/shadow',
- '/etc/subuid',
- '/etc/subgid',
- '/var/lib/nixos/uid-map',
- '/var/lib/nixos/gid-map',
- '/var/lib/nixos/declarative-groups',
- '/var/lib/nixos/declarative-users'
- ]
- expected_hashes = {}
- expected_stats = {}
- for file in files_to_check:
- expected_hashes[file] = machine.succeed(f"sha256sum {file}")
- expected_stats[file] = machine.succeed(f"stat {file}")
+ files_to_check = ['/etc/group',
+ '/etc/passwd',
+ '/etc/shadow',
+ '/etc/subuid',
+ '/etc/subgid',
+ '/var/lib/nixos/uid-map',
+ '/var/lib/nixos/gid-map',
+ '/var/lib/nixos/declarative-groups',
+ '/var/lib/nixos/declarative-users'
+ ]
+ expected_hashes = {}
+ expected_stats = {}
+ for file in files_to_check:
+ expected_hashes[file] = machine.succeed(f"sha256sum {file}")
+ expected_stats[file] = machine.succeed(f"stat {file}")
- machine.succeed("/run/booted-system/specialisation/mutable/bin/switch-to-configuration dry-activate")
+ machine.succeed("/run/booted-system/specialisation/mutable/bin/switch-to-configuration dry-activate")
- machine.fail('test -e /home/dry-test') # home was not recreated
- for file in files_to_check:
- assert machine.succeed(f"sha256sum {file}") == expected_hashes[file]
- assert machine.succeed(f"stat {file}") == expected_stats[file]
- '';
- }
-)
+ machine.fail('test -e /home/dry-test') # home was not recreated
+ for file in files_to_check:
+ assert machine.succeed(f"sha256sum {file}") == expected_hashes[file]
+ assert machine.succeed(f"stat {file}") == expected_stats[file]
+ '';
+}
diff --git a/nixos/tests/mympd.nix b/nixos/tests/mympd.nix
index 20c5603da69d..8d599dd3ad39 100644
--- a/nixos/tests/mympd.nix
+++ b/nixos/tests/mympd.nix
@@ -1,30 +1,28 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "mympd";
+{ pkgs, lib, ... }:
+{
+ name = "mympd";
- nodes.mympd = {
- services.mympd = {
- enable = true;
- settings = {
- http_port = 8081;
- };
+ nodes.mympd = {
+ services.mympd = {
+ enable = true;
+ settings = {
+ http_port = 8081;
};
-
- services.mpd.enable = true;
};
- testScript = ''
- start_all();
- machine.wait_for_unit("mympd.service");
+ services.mpd.enable = true;
+ };
- # Ensure that mympd can connect to mpd
- machine.wait_until_succeeds(
- "journalctl -eu mympd -o cat | grep 'Connected to MPD'"
- )
+ testScript = ''
+ start_all();
+ machine.wait_for_unit("mympd.service");
- # Ensure that the web server is working
- machine.succeed("curl http://localhost:8081 --compressed | grep -o myMPD")
- '';
- }
-)
+ # Ensure that mympd can connect to mpd
+ machine.wait_until_succeeds(
+ "journalctl -eu mympd -o cat | grep 'Connected to MPD'"
+ )
+
+ # Ensure that the web server is working
+ machine.succeed("curl http://localhost:8081 --compressed | grep -o myMPD")
+ '';
+}
diff --git a/nixos/tests/nar-serve.nix b/nixos/tests/nar-serve.nix
index fde57eb4f670..d05d3f136251 100644
--- a/nixos/tests/nar-serve.nix
+++ b/nixos/tests/nar-serve.nix
@@ -1,51 +1,49 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "nar-serve";
- meta.maintainers = [ lib.maintainers.rizary ];
- nodes = {
- server =
- { pkgs, ... }:
- {
- services.nginx = {
- enable = true;
- virtualHosts.default.root = "/var/www";
- };
- services.nar-serve = {
- enable = true;
- # Connect to the localhost nginx instead of the default
- # https://cache.nixos.org
- cacheURL = "http://localhost/";
- };
- environment.systemPackages = [
- pkgs.hello
- pkgs.curl
- ];
-
- networking.firewall.allowedTCPPorts = [ 8383 ];
-
- # virtualisation.diskSize = 2 * 1024;
+{ pkgs, lib, ... }:
+{
+ name = "nar-serve";
+ meta.maintainers = [ lib.maintainers.rizary ];
+ nodes = {
+ server =
+ { pkgs, ... }:
+ {
+ services.nginx = {
+ enable = true;
+ virtualHosts.default.root = "/var/www";
};
- };
- testScript = ''
- import os
+ services.nar-serve = {
+ enable = true;
+ # Connect to the localhost nginx instead of the default
+ # https://cache.nixos.org
+ cacheURL = "http://localhost/";
+ };
+ environment.systemPackages = [
+ pkgs.hello
+ pkgs.curl
+ ];
- start_all()
+ networking.firewall.allowedTCPPorts = [ 8383 ];
- # Create a fake cache with Nginx service the static files
- server.succeed(
- "nix --experimental-features nix-command copy --to file:///var/www ${pkgs.hello}"
- )
- server.wait_for_unit("nginx.service")
- server.wait_for_open_port(80)
+ # virtualisation.diskSize = 2 * 1024;
+ };
+ };
+ testScript = ''
+ import os
- # Check that nar-serve can return the content of the derivation
- drvName = os.path.basename("${pkgs.hello}")
- drvHash = drvName.split("-")[0]
- server.wait_for_unit("nar-serve.service")
- server.succeed(
- "curl -o hello -f http://localhost:8383/nix/store/{}/bin/hello".format(drvHash)
- )
- '';
- }
-)
+ start_all()
+
+ # Create a fake cache with Nginx service the static files
+ server.succeed(
+ "nix --experimental-features nix-command copy --to file:///var/www ${pkgs.hello}"
+ )
+ server.wait_for_unit("nginx.service")
+ server.wait_for_open_port(80)
+
+ # Check that nar-serve can return the content of the derivation
+ drvName = os.path.basename("${pkgs.hello}")
+ drvHash = drvName.split("-")[0]
+ server.wait_for_unit("nar-serve.service")
+ server.succeed(
+ "curl -o hello -f http://localhost:8383/nix/store/{}/bin/hello".format(drvHash)
+ )
+ '';
+}
diff --git a/nixos/tests/nats.nix b/nixos/tests/nats.nix
index b62b9201101a..2ed97ee86b09 100644
--- a/nixos/tests/nats.nix
+++ b/nixos/tests/nats.nix
@@ -6,75 +6,73 @@ let
topic = "foo.bar";
in
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "nats";
- meta = with pkgs.lib; {
- maintainers = with maintainers; [ c0deaddict ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "nats";
+ meta = with pkgs.lib; {
+ maintainers = with maintainers; [ c0deaddict ];
+ };
- nodes =
- let
- client =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [ natscli ];
- };
- in
- {
- server =
- { pkgs, ... }:
- {
- networking.firewall.allowedTCPPorts = [ port ];
- services.nats = {
- inherit port;
- enable = true;
- settings = {
- authorization = {
- users = [
- {
- user = username;
- inherit password;
- }
- ];
- };
+ nodes =
+ let
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [ natscli ];
+ };
+ in
+ {
+ server =
+ { pkgs, ... }:
+ {
+ networking.firewall.allowedTCPPorts = [ port ];
+ services.nats = {
+ inherit port;
+ enable = true;
+ settings = {
+ authorization = {
+ users = [
+ {
+ user = username;
+ inherit password;
+ }
+ ];
};
};
};
+ };
- client1 = client;
- client2 = client;
- };
+ client1 = client;
+ client2 = client;
+ };
- testScript =
- let
- file = "/tmp/msg";
- in
- ''
- def nats_cmd(*args):
- return (
- "nats "
- "--server=nats://server:${toString port} "
- "--user=${username} "
- "--password=${password} "
- "{}"
- ).format(" ".join(args))
+ testScript =
+ let
+ file = "/tmp/msg";
+ in
+ ''
+ def nats_cmd(*args):
+ return (
+ "nats "
+ "--server=nats://server:${toString port} "
+ "--user=${username} "
+ "--password=${password} "
+ "{}"
+ ).format(" ".join(args))
- def parallel(*fns):
- from threading import Thread
- threads = [ Thread(target=fn) for fn in fns ]
- for t in threads: t.start()
- for t in threads: t.join()
+ def parallel(*fns):
+ from threading import Thread
+ threads = [ Thread(target=fn) for fn in fns ]
+ for t in threads: t.start()
+ for t in threads: t.join()
- start_all()
- server.wait_for_unit("nats.service")
+ start_all()
+ server.wait_for_unit("nats.service")
- with subtest("pub sub"):
- parallel(
- lambda: client1.succeed(nats_cmd("sub", "--count", "1", "${topic}")),
- lambda: client2.succeed("sleep 2 && {}".format(nats_cmd("pub", "${topic}", "hello"))),
- )
- '';
- }
-)
+ with subtest("pub sub"):
+ parallel(
+ lambda: client1.succeed(nats_cmd("sub", "--count", "1", "${topic}")),
+ lambda: client2.succeed("sleep 2 && {}".format(nats_cmd("pub", "${topic}", "hello"))),
+ )
+ '';
+}
diff --git a/nixos/tests/navidrome.nix b/nixos/tests/navidrome.nix
index b6afad8e56c7..e57cec0d2830 100644
--- a/nixos/tests/navidrome.nix
+++ b/nixos/tests/navidrome.nix
@@ -1,17 +1,15 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "navidrome";
+{ pkgs, ... }:
+{
+ name = "navidrome";
- nodes.machine =
- { ... }:
- {
- services.navidrome.enable = true;
- };
+ nodes.machine =
+ { ... }:
+ {
+ services.navidrome.enable = true;
+ };
- testScript = ''
- machine.wait_for_unit("navidrome")
- machine.wait_for_open_port(4533)
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("navidrome")
+ machine.wait_for_open_port(4533)
+ '';
+}
diff --git a/nixos/tests/nbd.nix b/nixos/tests/nbd.nix
index 7905a4a6127e..088e35c2df6a 100644
--- a/nixos/tests/nbd.nix
+++ b/nixos/tests/nbd.nix
@@ -1,116 +1,114 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- listenPort = 30123;
- testString = "It works!";
- mkCreateSmallFileService =
- {
- path,
- loop ? false,
- }:
- {
- script = ''
- ${pkgs.coreutils}/bin/dd if=/dev/zero of=${path} bs=1K count=100
- ${pkgs.lib.optionalString loop "${pkgs.util-linux}/bin/losetup --find ${path}"}
- '';
- serviceConfig = {
- Type = "oneshot";
- };
- wantedBy = [ "multi-user.target" ];
- before = [ "nbd-server.service" ];
+{ pkgs, ... }:
+let
+ listenPort = 30123;
+ testString = "It works!";
+ mkCreateSmallFileService =
+ {
+ path,
+ loop ? false,
+ }:
+ {
+ script = ''
+ ${pkgs.coreutils}/bin/dd if=/dev/zero of=${path} bs=1K count=100
+ ${pkgs.lib.optionalString loop "${pkgs.util-linux}/bin/losetup --find ${path}"}
+ '';
+ serviceConfig = {
+ Type = "oneshot";
};
- in
- {
- name = "nbd";
-
- nodes = {
- server =
- { config, pkgs, ... }:
- {
- # Create some small files of zeros to use as the ndb disks
- ## `vault-pub.disk` is accessible from any IP
- systemd.services.create-pub-file = mkCreateSmallFileService { path = "/vault-pub.disk"; };
- ## `vault-priv.disk` is accessible only from localhost.
- ## It's also a loopback device to test exporting /dev/...
- systemd.services.create-priv-file = mkCreateSmallFileService {
- path = "/vault-priv.disk";
- loop = true;
- };
- ## `aaa.disk` is just here because "[aaa]" sorts before
- ## "[generic]" lexicographically, and nbd-server breaks if
- ## "[generic]" isn't the first section.
- systemd.services.create-aaa-file = mkCreateSmallFileService { path = "/aaa.disk"; };
-
- # Needed only for nbd-client used in the tests.
- environment.systemPackages = [ pkgs.nbd ];
-
- # Open the nbd port in the firewall
- networking.firewall.allowedTCPPorts = [ listenPort ];
-
- # Run the nbd server and expose the small file created above
- services.nbd.server = {
- enable = true;
- exports = {
- aaa = {
- path = "/aaa.disk";
- };
- vault-pub = {
- path = "/vault-pub.disk";
- };
- vault-priv = {
- path = "/dev/loop0";
- allowAddresses = [
- "127.0.0.1"
- "::1"
- ];
- };
- };
- listenAddress = "0.0.0.0";
- listenPort = listenPort;
- };
- };
-
- client =
- { config, pkgs, ... }:
- {
- programs.nbd.enable = true;
- };
+ wantedBy = [ "multi-user.target" ];
+ before = [ "nbd-server.service" ];
};
+in
+{
+ name = "nbd";
- testScript = ''
- testString = "${testString}"
+ nodes = {
+ server =
+ { config, pkgs, ... }:
+ {
+ # Create some small files of zeros to use as the ndb disks
+ ## `vault-pub.disk` is accessible from any IP
+ systemd.services.create-pub-file = mkCreateSmallFileService { path = "/vault-pub.disk"; };
+ ## `vault-priv.disk` is accessible only from localhost.
+ ## It's also a loopback device to test exporting /dev/...
+ systemd.services.create-priv-file = mkCreateSmallFileService {
+ path = "/vault-priv.disk";
+ loop = true;
+ };
+ ## `aaa.disk` is just here because "[aaa]" sorts before
+ ## "[generic]" lexicographically, and nbd-server breaks if
+ ## "[generic]" isn't the first section.
+ systemd.services.create-aaa-file = mkCreateSmallFileService { path = "/aaa.disk"; };
- start_all()
- server.wait_for_open_port(${toString listenPort})
+ # Needed only for nbd-client used in the tests.
+ environment.systemPackages = [ pkgs.nbd ];
- # Client: Connect to the server, write a small string to the nbd disk, and cleanly disconnect
- client.succeed("nbd-client server ${toString listenPort} /dev/nbd0 -name vault-pub -persist")
- client.succeed(f"echo '{testString}' | dd of=/dev/nbd0 conv=notrunc")
- client.succeed("nbd-client -d /dev/nbd0")
+ # Open the nbd port in the firewall
+ networking.firewall.allowedTCPPorts = [ listenPort ];
- # Server: Check that the string written by the client is indeed in the file
- foundString = server.succeed(f"dd status=none if=/vault-pub.disk count={len(testString)}")[:len(testString)]
- if foundString != testString:
- raise Exception(f"Read the wrong string from nbd disk. Expected: '{testString}'. Found: '{foundString}'")
+ # Run the nbd server and expose the small file created above
+ services.nbd.server = {
+ enable = true;
+ exports = {
+ aaa = {
+ path = "/aaa.disk";
+ };
+ vault-pub = {
+ path = "/vault-pub.disk";
+ };
+ vault-priv = {
+ path = "/dev/loop0";
+ allowAddresses = [
+ "127.0.0.1"
+ "::1"
+ ];
+ };
+ };
+ listenAddress = "0.0.0.0";
+ listenPort = listenPort;
+ };
+ };
- # Client: Fail to connect to the private disk
- client.fail("nbd-client server ${toString listenPort} /dev/nbd0 -name vault-priv -persist")
+ client =
+ { config, pkgs, ... }:
+ {
+ programs.nbd.enable = true;
+ };
+ };
- # Server: Successfully connect to the private disk
- server.succeed("nbd-client localhost ${toString listenPort} /dev/nbd0 -name vault-priv -persist")
- server.succeed(f"echo '{testString}' | dd of=/dev/nbd0 conv=notrunc")
- foundString = server.succeed(f"dd status=none if=/dev/loop0 count={len(testString)}")[:len(testString)]
- if foundString != testString:
- raise Exception(f"Read the wrong string from nbd disk. Expected: '{testString}'. Found: '{foundString}'")
- server.succeed("nbd-client -d /dev/nbd0")
+ testScript = ''
+ testString = "${testString}"
- # Server: Successfully connect to the aaa disk
- server.succeed("nbd-client localhost ${toString listenPort} /dev/nbd0 -name aaa -persist")
- server.succeed(f"echo '{testString}' | dd of=/dev/nbd0 conv=notrunc")
- foundString = server.succeed(f"dd status=none if=/aaa.disk count={len(testString)}")[:len(testString)]
- if foundString != testString:
- raise Exception(f"Read the wrong string from nbd disk. Expected: '{testString}'. Found: '{foundString}'")
- server.succeed("nbd-client -d /dev/nbd0")
- '';
- }
-)
+ start_all()
+ server.wait_for_open_port(${toString listenPort})
+
+ # Client: Connect to the server, write a small string to the nbd disk, and cleanly disconnect
+ client.succeed("nbd-client server ${toString listenPort} /dev/nbd0 -name vault-pub -persist")
+ client.succeed(f"echo '{testString}' | dd of=/dev/nbd0 conv=notrunc")
+ client.succeed("nbd-client -d /dev/nbd0")
+
+ # Server: Check that the string written by the client is indeed in the file
+ foundString = server.succeed(f"dd status=none if=/vault-pub.disk count={len(testString)}")[:len(testString)]
+ if foundString != testString:
+ raise Exception(f"Read the wrong string from nbd disk. Expected: '{testString}'. Found: '{foundString}'")
+
+ # Client: Fail to connect to the private disk
+ client.fail("nbd-client server ${toString listenPort} /dev/nbd0 -name vault-priv -persist")
+
+ # Server: Successfully connect to the private disk
+ server.succeed("nbd-client localhost ${toString listenPort} /dev/nbd0 -name vault-priv -persist")
+ server.succeed(f"echo '{testString}' | dd of=/dev/nbd0 conv=notrunc")
+ foundString = server.succeed(f"dd status=none if=/dev/loop0 count={len(testString)}")[:len(testString)]
+ if foundString != testString:
+ raise Exception(f"Read the wrong string from nbd disk. Expected: '{testString}'. Found: '{foundString}'")
+ server.succeed("nbd-client -d /dev/nbd0")
+
+ # Server: Successfully connect to the aaa disk
+ server.succeed("nbd-client localhost ${toString listenPort} /dev/nbd0 -name aaa -persist")
+ server.succeed(f"echo '{testString}' | dd of=/dev/nbd0 conv=notrunc")
+ foundString = server.succeed(f"dd status=none if=/aaa.disk count={len(testString)}")[:len(testString)]
+ if foundString != testString:
+ raise Exception(f"Read the wrong string from nbd disk. Expected: '{testString}'. Found: '{foundString}'")
+ server.succeed("nbd-client -d /dev/nbd0")
+ '';
+}
diff --git a/nixos/tests/ncdns.nix b/nixos/tests/ncdns.nix
index 48f17ed16b85..97f509250475 100644
--- a/nixos/tests/ncdns.nix
+++ b/nixos/tests/ncdns.nix
@@ -1,97 +1,95 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- let
- fakeReply = pkgs.writeText "namecoin-reply.json" ''
- { "error": null,
- "id": 1,
- "result": {
- "address": "T31q8ucJ4dI1xzhxQ5QispfECld5c7Xw",
- "expired": false,
- "expires_in": 2248,
- "height": 438155,
- "name": "d/test",
- "txid": "db61c0b2540ba0c1a2c8cc92af703a37002e7566ecea4dbf8727c7191421edfb",
- "value": "{\"ip\": \"1.2.3.4\", \"email\": \"root@test.bit\",\"info\": \"Fake record\"}",
- "vout": 0
- }
+{ lib, pkgs, ... }:
+let
+ fakeReply = pkgs.writeText "namecoin-reply.json" ''
+ { "error": null,
+ "id": 1,
+ "result": {
+ "address": "T31q8ucJ4dI1xzhxQ5QispfECld5c7Xw",
+ "expired": false,
+ "expires_in": 2248,
+ "height": 438155,
+ "name": "d/test",
+ "txid": "db61c0b2540ba0c1a2c8cc92af703a37002e7566ecea4dbf8727c7191421edfb",
+ "value": "{\"ip\": \"1.2.3.4\", \"email\": \"root@test.bit\",\"info\": \"Fake record\"}",
+ "vout": 0
}
- '';
+ }
+ '';
- # Disabled because DNSSEC does not currently validate,
- # see https://github.com/namecoin/ncdns/issues/127
- dnssec = false;
+ # Disabled because DNSSEC does not currently validate,
+ # see https://github.com/namecoin/ncdns/issues/127
+ dnssec = false;
- in
+in
- {
- name = "ncdns";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ rnhmjoj ];
- };
+{
+ name = "ncdns";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
- nodes.server =
- { ... }:
- {
- networking.nameservers = [ "::1" ];
+ nodes.server =
+ { ... }:
+ {
+ networking.nameservers = [ "::1" ];
- services.namecoind.rpc = {
- address = "::1";
- user = "namecoin";
- password = "secret";
- port = 8332;
- };
-
- # Fake namecoin RPC server because we can't
- # run a full node in a test.
- systemd.services.namecoind = {
- wantedBy = [ "multi-user.target" ];
- script = ''
- while true; do
- echo -e "HTTP/1.1 200 OK\n\n $(<${fakeReply})\n" \
- | ${pkgs.netcat}/bin/nc -N -l ::1 8332
- done
- '';
- };
-
- services.ncdns = {
- enable = true;
- dnssec.enable = dnssec;
- identity.hostname = "example.com";
- identity.hostmaster = "root@example.com";
- identity.address = "1.0.0.1";
- };
-
- services.pdns-recursor.enable = true;
- services.pdns-recursor.resolveNamecoin = true;
-
- environment.systemPackages = [ pkgs.dnsutils ];
+ services.namecoind.rpc = {
+ address = "::1";
+ user = "namecoin";
+ password = "secret";
+ port = 8332;
};
- testScript =
- (lib.optionalString dnssec ''
- with subtest("DNSSEC keys have been generated"):
- server.wait_for_unit("ncdns")
- server.wait_for_file("/var/lib/ncdns/bit.key")
- server.wait_for_file("/var/lib/ncdns/bit-zone.key")
+ # Fake namecoin RPC server because we can't
+ # run a full node in a test.
+ systemd.services.namecoind = {
+ wantedBy = [ "multi-user.target" ];
+ script = ''
+ while true; do
+ echo -e "HTTP/1.1 200 OK\n\n $(<${fakeReply})\n" \
+ | ${pkgs.netcat}/bin/nc -N -l ::1 8332
+ done
+ '';
+ };
- with subtest("DNSKEY bit record is present"):
- server.wait_for_unit("pdns-recursor")
- server.wait_for_open_port(53)
- server.succeed("host -t DNSKEY bit")
- '')
- + ''
- with subtest("can resolve a .bit name"):
- server.wait_for_unit("namecoind")
- server.wait_for_unit("ncdns")
- server.wait_for_open_port(8332)
- assert "1.2.3.4" in server.succeed("dig @localhost -p 5333 test.bit")
+ services.ncdns = {
+ enable = true;
+ dnssec.enable = dnssec;
+ identity.hostname = "example.com";
+ identity.hostmaster = "root@example.com";
+ identity.address = "1.0.0.1";
+ };
- with subtest("SOA record has identity information"):
- assert "example.com" in server.succeed("dig SOA @localhost -p 5333 bit")
+ services.pdns-recursor.enable = true;
+ services.pdns-recursor.resolveNamecoin = true;
- with subtest("bit. zone forwarding works"):
- server.wait_for_unit("pdns-recursor")
- assert "1.2.3.4" in server.succeed("host test.bit")
- '';
- }
-)
+ environment.systemPackages = [ pkgs.dnsutils ];
+ };
+
+ testScript =
+ (lib.optionalString dnssec ''
+ with subtest("DNSSEC keys have been generated"):
+ server.wait_for_unit("ncdns")
+ server.wait_for_file("/var/lib/ncdns/bit.key")
+ server.wait_for_file("/var/lib/ncdns/bit-zone.key")
+
+ with subtest("DNSKEY bit record is present"):
+ server.wait_for_unit("pdns-recursor")
+ server.wait_for_open_port(53)
+ server.succeed("host -t DNSKEY bit")
+ '')
+ + ''
+ with subtest("can resolve a .bit name"):
+ server.wait_for_unit("namecoind")
+ server.wait_for_unit("ncdns")
+ server.wait_for_open_port(8332)
+ assert "1.2.3.4" in server.succeed("dig @localhost -p 5333 test.bit")
+
+ with subtest("SOA record has identity information"):
+ assert "example.com" in server.succeed("dig SOA @localhost -p 5333 bit")
+
+ with subtest("bit. zone forwarding works"):
+ server.wait_for_unit("pdns-recursor")
+ assert "1.2.3.4" in server.succeed("host test.bit")
+ '';
+}
diff --git a/nixos/tests/ndppd.nix b/nixos/tests/ndppd.nix
index 23f1826cc3f7..465e86bfa77d 100644
--- a/nixos/tests/ndppd.nix
+++ b/nixos/tests/ndppd.nix
@@ -1,74 +1,72 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "ndppd";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fpletz ];
- };
+{ pkgs, lib, ... }:
+{
+ name = "ndppd";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fpletz ];
+ };
- nodes = {
- upstream =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.tcpdump ];
- networking.useDHCP = false;
- networking.interfaces = {
- eth1 = {
- ipv6.addresses = [
- {
- address = "fd23::1";
- prefixLength = 112;
- }
- ];
- ipv6.routes = [
- {
- address = "fd42::";
- prefixLength = 112;
- }
- ];
- };
+ nodes = {
+ upstream =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.tcpdump ];
+ networking.useDHCP = false;
+ networking.interfaces = {
+ eth1 = {
+ ipv6.addresses = [
+ {
+ address = "fd23::1";
+ prefixLength = 112;
+ }
+ ];
+ ipv6.routes = [
+ {
+ address = "fd42::";
+ prefixLength = 112;
+ }
+ ];
};
};
- server =
- { pkgs, ... }:
- {
- boot.kernel.sysctl = {
- "net.ipv6.conf.all.forwarding" = "1";
- "net.ipv6.conf.default.forwarding" = "1";
- };
- environment.systemPackages = [ pkgs.tcpdump ];
- networking.useDHCP = false;
- networking.interfaces = {
- eth1 = {
- ipv6.addresses = [
- {
- address = "fd23::2";
- prefixLength = 112;
- }
- ];
- };
- };
- services.ndppd = {
- enable = true;
- proxies.eth1.rules."fd42::/112" = { };
- };
- containers.client = {
- autoStart = true;
- privateNetwork = true;
- hostAddress = "192.168.255.1";
- localAddress = "192.168.255.2";
- hostAddress6 = "fd42::1";
- localAddress6 = "fd42::2";
- config = { };
+ };
+ server =
+ { pkgs, ... }:
+ {
+ boot.kernel.sysctl = {
+ "net.ipv6.conf.all.forwarding" = "1";
+ "net.ipv6.conf.default.forwarding" = "1";
+ };
+ environment.systemPackages = [ pkgs.tcpdump ];
+ networking.useDHCP = false;
+ networking.interfaces = {
+ eth1 = {
+ ipv6.addresses = [
+ {
+ address = "fd23::2";
+ prefixLength = 112;
+ }
+ ];
};
};
- };
+ services.ndppd = {
+ enable = true;
+ proxies.eth1.rules."fd42::/112" = { };
+ };
+ containers.client = {
+ autoStart = true;
+ privateNetwork = true;
+ hostAddress = "192.168.255.1";
+ localAddress = "192.168.255.2";
+ hostAddress6 = "fd42::1";
+ localAddress6 = "fd42::2";
+ config = { };
+ };
+ };
+ };
- testScript = ''
- start_all()
- server.wait_for_unit("multi-user.target")
- upstream.wait_for_unit("multi-user.target")
- upstream.wait_until_succeeds("ping -c5 fd42::2")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ server.wait_for_unit("multi-user.target")
+ upstream.wait_for_unit("multi-user.target")
+ upstream.wait_until_succeeds("ping -c5 fd42::2")
+ '';
+}
diff --git a/nixos/tests/nebula.nix b/nixos/tests/nebula.nix
index 68a48d4c86a2..68f60f8388fd 100644
--- a/nixos/tests/nebula.nix
+++ b/nixos/tests/nebula.nix
@@ -1,426 +1,424 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
+{ pkgs, lib, ... }:
+let
- # We'll need to be able to trade cert files between nodes via scp.
- inherit (import ./ssh-keys.nix pkgs)
- snakeOilPrivateKey
- snakeOilPublicKey
- ;
+ # We'll need to be able to trade cert files between nodes via scp.
+ inherit (import ./ssh-keys.nix pkgs)
+ snakeOilPrivateKey
+ snakeOilPublicKey
+ ;
- makeNebulaNode =
- { config, ... }:
- name: extraConfig:
- lib.mkMerge [
- {
- # Expose nebula for doing cert signing.
- environment.systemPackages = [
- pkgs.dig
- pkgs.nebula
- ];
- users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
- services.openssh.enable = true;
- networking.firewall.enable = true; # Implicitly true, but let's make sure.
- networking.interfaces.eth1.useDHCP = false;
+ makeNebulaNode =
+ { config, ... }:
+ name: extraConfig:
+ lib.mkMerge [
+ {
+ # Expose nebula for doing cert signing.
+ environment.systemPackages = [
+ pkgs.dig
+ pkgs.nebula
+ ];
+ users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
+ services.openssh.enable = true;
+ networking.firewall.enable = true; # Implicitly true, but let's make sure.
+ networking.interfaces.eth1.useDHCP = false;
- services.nebula.networks.smoke = {
- # Note that these paths won't exist when the machine is first booted.
- ca = "/etc/nebula/ca.crt";
- cert = "/etc/nebula/${name}.crt";
- key = "/etc/nebula/${name}.key";
- listen = {
- host = "0.0.0.0";
- port =
- if
- (
- config.services.nebula.networks.smoke.isLighthouse || config.services.nebula.networks.smoke.isRelay
- )
- then
- 4242
- else
- 0;
- };
+ services.nebula.networks.smoke = {
+ # Note that these paths won't exist when the machine is first booted.
+ ca = "/etc/nebula/ca.crt";
+ cert = "/etc/nebula/${name}.crt";
+ key = "/etc/nebula/${name}.key";
+ listen = {
+ host = "0.0.0.0";
+ port =
+ if
+ (
+ config.services.nebula.networks.smoke.isLighthouse || config.services.nebula.networks.smoke.isRelay
+ )
+ then
+ 4242
+ else
+ 0;
};
- }
- extraConfig
- ];
+ };
+ }
+ extraConfig
+ ];
- in
- {
- name = "nebula";
+in
+{
+ name = "nebula";
- nodes = {
+ nodes = {
- lighthouse =
- { ... }@args:
- makeNebulaNode args "lighthouse" {
- networking.firewall.allowedUDPPorts = [ 53 ];
- networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
- {
- address = "192.168.1.1";
- prefixLength = 24;
- }
- ];
+ lighthouse =
+ { ... }@args:
+ makeNebulaNode args "lighthouse" {
+ networking.firewall.allowedUDPPorts = [ 53 ];
+ networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
+ {
+ address = "192.168.1.1";
+ prefixLength = 24;
+ }
+ ];
- services.nebula.networks.smoke = {
- isLighthouse = true;
- isRelay = true;
- firewall = {
- outbound = [
- {
- port = "any";
- proto = "any";
- host = "any";
- }
- ];
- inbound = [
- {
- port = "any";
- proto = "any";
- host = "any";
- }
- ];
- };
- lighthouse = {
- dns = {
- enable = true;
- host = "10.0.100.1"; # bind to lighthouse interface
- port = 53; # answer on standard DNS port
- };
+ services.nebula.networks.smoke = {
+ isLighthouse = true;
+ isRelay = true;
+ firewall = {
+ outbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "any";
+ }
+ ];
+ inbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "any";
+ }
+ ];
+ };
+ lighthouse = {
+ dns = {
+ enable = true;
+ host = "10.0.100.1"; # bind to lighthouse interface
+ port = 53; # answer on standard DNS port
};
};
};
+ };
- allowAny =
- { ... }@args:
- makeNebulaNode args "allowAny" {
- networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
- {
- address = "192.168.1.2";
- prefixLength = 24;
- }
- ];
+ allowAny =
+ { ... }@args:
+ makeNebulaNode args "allowAny" {
+ networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
+ {
+ address = "192.168.1.2";
+ prefixLength = 24;
+ }
+ ];
- services.nebula.networks.smoke = {
- staticHostMap = {
- "10.0.100.1" = [ "192.168.1.1:4242" ];
- };
- isLighthouse = false;
- lighthouses = [ "10.0.100.1" ];
- relays = [ "10.0.100.1" ];
- firewall = {
- outbound = [
- {
- port = "any";
- proto = "any";
- host = "any";
- }
- ];
- inbound = [
- {
- port = "any";
- proto = "any";
- host = "any";
- }
- ];
- };
+ services.nebula.networks.smoke = {
+ staticHostMap = {
+ "10.0.100.1" = [ "192.168.1.1:4242" ];
+ };
+ isLighthouse = false;
+ lighthouses = [ "10.0.100.1" ];
+ relays = [ "10.0.100.1" ];
+ firewall = {
+ outbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "any";
+ }
+ ];
+ inbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "any";
+ }
+ ];
};
};
+ };
- allowFromLighthouse =
- { ... }@args:
- makeNebulaNode args "allowFromLighthouse" {
- networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
- {
- address = "192.168.1.3";
- prefixLength = 24;
- }
- ];
+ allowFromLighthouse =
+ { ... }@args:
+ makeNebulaNode args "allowFromLighthouse" {
+ networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
+ {
+ address = "192.168.1.3";
+ prefixLength = 24;
+ }
+ ];
- services.nebula.networks.smoke = {
- staticHostMap = {
- "10.0.100.1" = [ "192.168.1.1:4242" ];
- };
- isLighthouse = false;
- lighthouses = [ "10.0.100.1" ];
- relays = [ "10.0.100.1" ];
- firewall = {
- outbound = [
- {
- port = "any";
- proto = "any";
- host = "any";
- }
- ];
- inbound = [
- {
- port = "any";
- proto = "any";
- host = "lighthouse";
- }
- ];
- };
+ services.nebula.networks.smoke = {
+ staticHostMap = {
+ "10.0.100.1" = [ "192.168.1.1:4242" ];
+ };
+ isLighthouse = false;
+ lighthouses = [ "10.0.100.1" ];
+ relays = [ "10.0.100.1" ];
+ firewall = {
+ outbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "any";
+ }
+ ];
+ inbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "lighthouse";
+ }
+ ];
};
};
+ };
- allowToLighthouse =
- { ... }@args:
- makeNebulaNode args "allowToLighthouse" {
- networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
- {
- address = "192.168.1.4";
- prefixLength = 24;
- }
- ];
+ allowToLighthouse =
+ { ... }@args:
+ makeNebulaNode args "allowToLighthouse" {
+ networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
+ {
+ address = "192.168.1.4";
+ prefixLength = 24;
+ }
+ ];
- services.nebula.networks.smoke = {
- enable = true;
- staticHostMap = {
- "10.0.100.1" = [ "192.168.1.1:4242" ];
- };
- isLighthouse = false;
- lighthouses = [ "10.0.100.1" ];
- relays = [ "10.0.100.1" ];
- firewall = {
- outbound = [
- {
- port = "any";
- proto = "any";
- host = "lighthouse";
- }
- ];
- inbound = [
- {
- port = "any";
- proto = "any";
- host = "any";
- }
- ];
- };
+ services.nebula.networks.smoke = {
+ enable = true;
+ staticHostMap = {
+ "10.0.100.1" = [ "192.168.1.1:4242" ];
+ };
+ isLighthouse = false;
+ lighthouses = [ "10.0.100.1" ];
+ relays = [ "10.0.100.1" ];
+ firewall = {
+ outbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "lighthouse";
+ }
+ ];
+ inbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "any";
+ }
+ ];
};
};
+ };
- disabled =
- { ... }@args:
- makeNebulaNode args "disabled" {
- networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
- {
- address = "192.168.1.5";
- prefixLength = 24;
- }
- ];
+ disabled =
+ { ... }@args:
+ makeNebulaNode args "disabled" {
+ networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
+ {
+ address = "192.168.1.5";
+ prefixLength = 24;
+ }
+ ];
- services.nebula.networks.smoke = {
- enable = false;
- staticHostMap = {
- "10.0.100.1" = [ "192.168.1.1:4242" ];
- };
- isLighthouse = false;
- lighthouses = [ "10.0.100.1" ];
- relays = [ "10.0.100.1" ];
- firewall = {
- outbound = [
- {
- port = "any";
- proto = "any";
- host = "lighthouse";
- }
- ];
- inbound = [
- {
- port = "any";
- proto = "any";
- host = "any";
- }
- ];
- };
+ services.nebula.networks.smoke = {
+ enable = false;
+ staticHostMap = {
+ "10.0.100.1" = [ "192.168.1.1:4242" ];
+ };
+ isLighthouse = false;
+ lighthouses = [ "10.0.100.1" ];
+ relays = [ "10.0.100.1" ];
+ firewall = {
+ outbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "lighthouse";
+ }
+ ];
+ inbound = [
+ {
+ port = "any";
+ proto = "any";
+ host = "any";
+ }
+ ];
};
};
+ };
- };
+ };
- testScript =
- let
+ testScript =
+ let
- setUpPrivateKey = name: ''
- ${name}.start()
- ${name}.succeed(
- "mkdir -p /root/.ssh",
- "chmod 700 /root/.ssh",
- "cat '${snakeOilPrivateKey}' > /root/.ssh/id_snakeoil",
- "chmod 600 /root/.ssh/id_snakeoil",
- "mkdir -p /root"
- )
- '';
-
- # From what I can tell, StrictHostKeyChecking=no is necessary for ssh to work between machines.
- sshOpts = "-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oIdentityFile=/root/.ssh/id_snakeoil";
-
- restartAndCheckNebula = name: ip: ''
- ${name}.systemctl("restart nebula@smoke.service")
- ${name}.succeed("ping -c5 ${ip}")
- '';
-
- # Create a keypair on the client node, then use the public key to sign a cert on the lighthouse.
- signKeysFor = name: ip: ''
- lighthouse.wait_for_unit("sshd.service")
- ${name}.wait_for_unit("sshd.service")
- ${name}.succeed(
- "mkdir -p /etc/nebula",
- "nebula-cert keygen -out-key /etc/nebula/${name}.key -out-pub /etc/nebula/${name}.pub",
- "scp ${sshOpts} /etc/nebula/${name}.pub root@192.168.1.1:/root/${name}.pub",
- )
- lighthouse.succeed(
- 'nebula-cert sign -ca-crt /etc/nebula/ca.crt -ca-key /etc/nebula/ca.key -name "${name}" -groups "${name}" -ip "${ip}" -in-pub /root/${name}.pub -out-crt /root/${name}.crt'
- )
- ${name}.succeed(
- "scp ${sshOpts} root@192.168.1.1:/root/${name}.crt /etc/nebula/${name}.crt",
- "scp ${sshOpts} root@192.168.1.1:/etc/nebula/ca.crt /etc/nebula/ca.crt",
- '(id nebula-smoke >/dev/null && chown -R nebula-smoke:nebula-smoke /etc/nebula) || true'
- )
- '';
-
- getPublicIp = node: ''
- ${node}.succeed("ip --brief addr show eth1 | awk '{print $3}' | tail -n1 | cut -d/ -f1").strip()
- '';
-
- # Never do this for anything security critical! (Thankfully it's just a test.)
- # Restart Nebula right after the mutual block and/or restore so the state is fresh.
- blockTrafficBetween = nodeA: nodeB: ''
- node_a = ${getPublicIp nodeA}
- node_b = ${getPublicIp nodeB}
- ${nodeA}.succeed("iptables -I INPUT -s " + node_b + " -j DROP")
- ${nodeB}.succeed("iptables -I INPUT -s " + node_a + " -j DROP")
- ${nodeA}.systemctl("restart nebula@smoke.service")
- ${nodeB}.systemctl("restart nebula@smoke.service")
- '';
- allowTrafficBetween = nodeA: nodeB: ''
- node_a = ${getPublicIp nodeA}
- node_b = ${getPublicIp nodeB}
- ${nodeA}.succeed("iptables -D INPUT -s " + node_b + " -j DROP")
- ${nodeB}.succeed("iptables -D INPUT -s " + node_a + " -j DROP")
- ${nodeA}.systemctl("restart nebula@smoke.service")
- ${nodeB}.systemctl("restart nebula@smoke.service")
- '';
- in
- ''
- # Create the certificate and sign the lighthouse's keys.
- ${setUpPrivateKey "lighthouse"}
- lighthouse.succeed(
- "mkdir -p /etc/nebula",
- 'nebula-cert ca -name "Smoke Test" -out-crt /etc/nebula/ca.crt -out-key /etc/nebula/ca.key',
- 'nebula-cert sign -ca-crt /etc/nebula/ca.crt -ca-key /etc/nebula/ca.key -name "lighthouse" -groups "lighthouse" -ip "10.0.100.1/24" -out-crt /etc/nebula/lighthouse.crt -out-key /etc/nebula/lighthouse.key',
- 'chown -R nebula-smoke:nebula-smoke /etc/nebula'
+ setUpPrivateKey = name: ''
+ ${name}.start()
+ ${name}.succeed(
+ "mkdir -p /root/.ssh",
+ "chmod 700 /root/.ssh",
+ "cat '${snakeOilPrivateKey}' > /root/.ssh/id_snakeoil",
+ "chmod 600 /root/.ssh/id_snakeoil",
+ "mkdir -p /root"
)
-
- # Reboot the lighthouse and verify that the nebula service comes up on boot.
- # Since rebooting takes a while, we'll just restart the service on the other nodes.
- lighthouse.shutdown()
- lighthouse.start()
- lighthouse.wait_for_unit("nebula@smoke.service")
- lighthouse.succeed("ping -c5 10.0.100.1")
-
- # Create keys for allowAny's nebula service and test that it comes up.
- ${setUpPrivateKey "allowAny"}
- ${signKeysFor "allowAny" "10.0.100.2/24"}
- ${restartAndCheckNebula "allowAny" "10.0.100.2"}
-
- # Create keys for allowFromLighthouse's nebula service and test that it comes up.
- ${setUpPrivateKey "allowFromLighthouse"}
- ${signKeysFor "allowFromLighthouse" "10.0.100.3/24"}
- ${restartAndCheckNebula "allowFromLighthouse" "10.0.100.3"}
-
- # Create keys for allowToLighthouse's nebula service and test that it comes up.
- ${setUpPrivateKey "allowToLighthouse"}
- ${signKeysFor "allowToLighthouse" "10.0.100.4/24"}
- ${restartAndCheckNebula "allowToLighthouse" "10.0.100.4"}
-
- # Create keys for disabled's nebula service and test that it does not come up.
- ${setUpPrivateKey "disabled"}
- ${signKeysFor "disabled" "10.0.100.5/24"}
- disabled.fail("systemctl status nebula@smoke.service")
- disabled.fail("ping -c5 10.0.100.5")
-
- # The lighthouse can ping allowAny and allowFromLighthouse but not disabled
- lighthouse.succeed("ping -c3 10.0.100.2")
- lighthouse.succeed("ping -c3 10.0.100.3")
- lighthouse.fail("ping -c3 10.0.100.5")
-
- # allowAny can ping the lighthouse, but not allowFromLighthouse because of its inbound firewall
- allowAny.succeed("ping -c3 10.0.100.1")
- allowAny.fail("ping -c3 10.0.100.3")
- # allowAny can also resolve DNS on lighthouse
- allowAny.succeed("dig @10.0.100.1 allowToLighthouse | grep -E 'allowToLighthouse\.\s+[0-9]+\s+IN\s+A\s+10\.0\.100\.4'")
-
- # allowFromLighthouse can ping the lighthouse and allowAny
- allowFromLighthouse.succeed("ping -c3 10.0.100.1")
- allowFromLighthouse.succeed("ping -c3 10.0.100.2")
-
- # block allowFromLighthouse <-> allowAny, and allowFromLighthouse -> allowAny should still work.
- ${blockTrafficBetween "allowFromLighthouse" "allowAny"}
- allowFromLighthouse.succeed("ping -c10 10.0.100.2")
- ${allowTrafficBetween "allowFromLighthouse" "allowAny"}
- allowFromLighthouse.succeed("ping -c10 10.0.100.2")
-
- # allowToLighthouse can ping the lighthouse but not allowAny or allowFromLighthouse
- allowToLighthouse.succeed("ping -c3 10.0.100.1")
- allowToLighthouse.fail("ping -c3 10.0.100.2")
- allowToLighthouse.fail("ping -c3 10.0.100.3")
-
- # allowAny can ping allowFromLighthouse now that allowFromLighthouse pinged it first
- allowAny.succeed("ping -c3 10.0.100.3")
-
- # block allowAny <-> allowFromLighthouse, and allowAny -> allowFromLighthouse should still work.
- ${blockTrafficBetween "allowAny" "allowFromLighthouse"}
- allowFromLighthouse.succeed("ping -c10 10.0.100.2")
- allowAny.succeed("ping -c10 10.0.100.3")
- ${allowTrafficBetween "allowAny" "allowFromLighthouse"}
- allowFromLighthouse.succeed("ping -c10 10.0.100.2")
- allowAny.succeed("ping -c10 10.0.100.3")
-
- # allowToLighthouse can ping allowAny if allowAny pings it first
- allowAny.succeed("ping -c3 10.0.100.4")
- allowToLighthouse.succeed("ping -c3 10.0.100.2")
-
- # block allowToLighthouse <-> allowAny, and allowAny <-> allowToLighthouse should still work.
- ${blockTrafficBetween "allowAny" "allowToLighthouse"}
- allowAny.succeed("ping -c10 10.0.100.4")
- allowToLighthouse.succeed("ping -c10 10.0.100.2")
- ${allowTrafficBetween "allowAny" "allowToLighthouse"}
- allowAny.succeed("ping -c10 10.0.100.4")
- allowToLighthouse.succeed("ping -c10 10.0.100.2")
-
- # block lighthouse <-> allowFromLighthouse and allowAny <-> allowFromLighthouse; allowFromLighthouse won't get to allowAny
- ${blockTrafficBetween "allowFromLighthouse" "lighthouse"}
- ${blockTrafficBetween "allowFromLighthouse" "allowAny"}
- allowFromLighthouse.fail("ping -c3 10.0.100.2")
- ${allowTrafficBetween "allowFromLighthouse" "lighthouse"}
- ${allowTrafficBetween "allowFromLighthouse" "allowAny"}
- allowFromLighthouse.succeed("ping -c3 10.0.100.2")
-
- # block lighthouse <-> allowAny, allowAny <-> allowFromLighthouse, and allowAny <-> allowToLighthouse; it won't get to allowFromLighthouse or allowToLighthouse
- ${blockTrafficBetween "allowAny" "lighthouse"}
- ${blockTrafficBetween "allowAny" "allowFromLighthouse"}
- ${blockTrafficBetween "allowAny" "allowToLighthouse"}
- allowFromLighthouse.fail("ping -c3 10.0.100.2")
- allowAny.fail("ping -c3 10.0.100.3")
- allowAny.fail("ping -c3 10.0.100.4")
- ${allowTrafficBetween "allowAny" "lighthouse"}
- ${allowTrafficBetween "allowAny" "allowFromLighthouse"}
- ${allowTrafficBetween "allowAny" "allowToLighthouse"}
- allowFromLighthouse.succeed("ping -c3 10.0.100.2")
- allowAny.succeed("ping -c3 10.0.100.3")
- allowAny.succeed("ping -c3 10.0.100.4")
-
- # block lighthouse <-> allowToLighthouse and allowToLighthouse <-> allowAny; it won't get to allowAny
- ${blockTrafficBetween "allowToLighthouse" "lighthouse"}
- ${blockTrafficBetween "allowToLighthouse" "allowAny"}
- allowAny.fail("ping -c3 10.0.100.4")
- allowToLighthouse.fail("ping -c3 10.0.100.2")
- ${allowTrafficBetween "allowToLighthouse" "lighthouse"}
- ${allowTrafficBetween "allowToLighthouse" "allowAny"}
- allowAny.succeed("ping -c3 10.0.100.4")
- allowToLighthouse.succeed("ping -c3 10.0.100.2")
'';
- }
-)
+
+ # From what I can tell, StrictHostKeyChecking=no is necessary for ssh to work between machines.
+ sshOpts = "-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oIdentityFile=/root/.ssh/id_snakeoil";
+
+ restartAndCheckNebula = name: ip: ''
+ ${name}.systemctl("restart nebula@smoke.service")
+ ${name}.succeed("ping -c5 ${ip}")
+ '';
+
+ # Create a keypair on the client node, then use the public key to sign a cert on the lighthouse.
+ signKeysFor = name: ip: ''
+ lighthouse.wait_for_unit("sshd.service")
+ ${name}.wait_for_unit("sshd.service")
+ ${name}.succeed(
+ "mkdir -p /etc/nebula",
+ "nebula-cert keygen -out-key /etc/nebula/${name}.key -out-pub /etc/nebula/${name}.pub",
+ "scp ${sshOpts} /etc/nebula/${name}.pub root@192.168.1.1:/root/${name}.pub",
+ )
+ lighthouse.succeed(
+ 'nebula-cert sign -ca-crt /etc/nebula/ca.crt -ca-key /etc/nebula/ca.key -name "${name}" -groups "${name}" -ip "${ip}" -in-pub /root/${name}.pub -out-crt /root/${name}.crt'
+ )
+ ${name}.succeed(
+ "scp ${sshOpts} root@192.168.1.1:/root/${name}.crt /etc/nebula/${name}.crt",
+ "scp ${sshOpts} root@192.168.1.1:/etc/nebula/ca.crt /etc/nebula/ca.crt",
+ '(id nebula-smoke >/dev/null && chown -R nebula-smoke:nebula-smoke /etc/nebula) || true'
+ )
+ '';
+
+ getPublicIp = node: ''
+ ${node}.succeed("ip --brief addr show eth1 | awk '{print $3}' | tail -n1 | cut -d/ -f1").strip()
+ '';
+
+ # Never do this for anything security critical! (Thankfully it's just a test.)
+ # Restart Nebula right after the mutual block and/or restore so the state is fresh.
+ blockTrafficBetween = nodeA: nodeB: ''
+ node_a = ${getPublicIp nodeA}
+ node_b = ${getPublicIp nodeB}
+ ${nodeA}.succeed("iptables -I INPUT -s " + node_b + " -j DROP")
+ ${nodeB}.succeed("iptables -I INPUT -s " + node_a + " -j DROP")
+ ${nodeA}.systemctl("restart nebula@smoke.service")
+ ${nodeB}.systemctl("restart nebula@smoke.service")
+ '';
+ allowTrafficBetween = nodeA: nodeB: ''
+ node_a = ${getPublicIp nodeA}
+ node_b = ${getPublicIp nodeB}
+ ${nodeA}.succeed("iptables -D INPUT -s " + node_b + " -j DROP")
+ ${nodeB}.succeed("iptables -D INPUT -s " + node_a + " -j DROP")
+ ${nodeA}.systemctl("restart nebula@smoke.service")
+ ${nodeB}.systemctl("restart nebula@smoke.service")
+ '';
+ in
+ ''
+ # Create the certificate and sign the lighthouse's keys.
+ ${setUpPrivateKey "lighthouse"}
+ lighthouse.succeed(
+ "mkdir -p /etc/nebula",
+ 'nebula-cert ca -name "Smoke Test" -out-crt /etc/nebula/ca.crt -out-key /etc/nebula/ca.key',
+ 'nebula-cert sign -ca-crt /etc/nebula/ca.crt -ca-key /etc/nebula/ca.key -name "lighthouse" -groups "lighthouse" -ip "10.0.100.1/24" -out-crt /etc/nebula/lighthouse.crt -out-key /etc/nebula/lighthouse.key',
+ 'chown -R nebula-smoke:nebula-smoke /etc/nebula'
+ )
+
+ # Reboot the lighthouse and verify that the nebula service comes up on boot.
+ # Since rebooting takes a while, we'll just restart the service on the other nodes.
+ lighthouse.shutdown()
+ lighthouse.start()
+ lighthouse.wait_for_unit("nebula@smoke.service")
+ lighthouse.succeed("ping -c5 10.0.100.1")
+
+ # Create keys for allowAny's nebula service and test that it comes up.
+ ${setUpPrivateKey "allowAny"}
+ ${signKeysFor "allowAny" "10.0.100.2/24"}
+ ${restartAndCheckNebula "allowAny" "10.0.100.2"}
+
+ # Create keys for allowFromLighthouse's nebula service and test that it comes up.
+ ${setUpPrivateKey "allowFromLighthouse"}
+ ${signKeysFor "allowFromLighthouse" "10.0.100.3/24"}
+ ${restartAndCheckNebula "allowFromLighthouse" "10.0.100.3"}
+
+ # Create keys for allowToLighthouse's nebula service and test that it comes up.
+ ${setUpPrivateKey "allowToLighthouse"}
+ ${signKeysFor "allowToLighthouse" "10.0.100.4/24"}
+ ${restartAndCheckNebula "allowToLighthouse" "10.0.100.4"}
+
+ # Create keys for disabled's nebula service and test that it does not come up.
+ ${setUpPrivateKey "disabled"}
+ ${signKeysFor "disabled" "10.0.100.5/24"}
+ disabled.fail("systemctl status nebula@smoke.service")
+ disabled.fail("ping -c5 10.0.100.5")
+
+ # The lighthouse can ping allowAny and allowFromLighthouse but not disabled
+ lighthouse.succeed("ping -c3 10.0.100.2")
+ lighthouse.succeed("ping -c3 10.0.100.3")
+ lighthouse.fail("ping -c3 10.0.100.5")
+
+ # allowAny can ping the lighthouse, but not allowFromLighthouse because of its inbound firewall
+ allowAny.succeed("ping -c3 10.0.100.1")
+ allowAny.fail("ping -c3 10.0.100.3")
+ # allowAny can also resolve DNS on lighthouse
+ allowAny.succeed("dig @10.0.100.1 allowToLighthouse | grep -E 'allowToLighthouse\.\s+[0-9]+\s+IN\s+A\s+10\.0\.100\.4'")
+
+ # allowFromLighthouse can ping the lighthouse and allowAny
+ allowFromLighthouse.succeed("ping -c3 10.0.100.1")
+ allowFromLighthouse.succeed("ping -c3 10.0.100.2")
+
+ # block allowFromLighthouse <-> allowAny, and allowFromLighthouse -> allowAny should still work.
+ ${blockTrafficBetween "allowFromLighthouse" "allowAny"}
+ allowFromLighthouse.succeed("ping -c10 10.0.100.2")
+ ${allowTrafficBetween "allowFromLighthouse" "allowAny"}
+ allowFromLighthouse.succeed("ping -c10 10.0.100.2")
+
+ # allowToLighthouse can ping the lighthouse but not allowAny or allowFromLighthouse
+ allowToLighthouse.succeed("ping -c3 10.0.100.1")
+ allowToLighthouse.fail("ping -c3 10.0.100.2")
+ allowToLighthouse.fail("ping -c3 10.0.100.3")
+
+ # allowAny can ping allowFromLighthouse now that allowFromLighthouse pinged it first
+ allowAny.succeed("ping -c3 10.0.100.3")
+
+ # block allowAny <-> allowFromLighthouse, and allowAny -> allowFromLighthouse should still work.
+ ${blockTrafficBetween "allowAny" "allowFromLighthouse"}
+ allowFromLighthouse.succeed("ping -c10 10.0.100.2")
+ allowAny.succeed("ping -c10 10.0.100.3")
+ ${allowTrafficBetween "allowAny" "allowFromLighthouse"}
+ allowFromLighthouse.succeed("ping -c10 10.0.100.2")
+ allowAny.succeed("ping -c10 10.0.100.3")
+
+ # allowToLighthouse can ping allowAny if allowAny pings it first
+ allowAny.succeed("ping -c3 10.0.100.4")
+ allowToLighthouse.succeed("ping -c3 10.0.100.2")
+
+ # block allowToLighthouse <-> allowAny, and allowAny <-> allowToLighthouse should still work.
+ ${blockTrafficBetween "allowAny" "allowToLighthouse"}
+ allowAny.succeed("ping -c10 10.0.100.4")
+ allowToLighthouse.succeed("ping -c10 10.0.100.2")
+ ${allowTrafficBetween "allowAny" "allowToLighthouse"}
+ allowAny.succeed("ping -c10 10.0.100.4")
+ allowToLighthouse.succeed("ping -c10 10.0.100.2")
+
+ # block lighthouse <-> allowFromLighthouse and allowAny <-> allowFromLighthouse; allowFromLighthouse won't get to allowAny
+ ${blockTrafficBetween "allowFromLighthouse" "lighthouse"}
+ ${blockTrafficBetween "allowFromLighthouse" "allowAny"}
+ allowFromLighthouse.fail("ping -c3 10.0.100.2")
+ ${allowTrafficBetween "allowFromLighthouse" "lighthouse"}
+ ${allowTrafficBetween "allowFromLighthouse" "allowAny"}
+ allowFromLighthouse.succeed("ping -c3 10.0.100.2")
+
+ # block lighthouse <-> allowAny, allowAny <-> allowFromLighthouse, and allowAny <-> allowToLighthouse; it won't get to allowFromLighthouse or allowToLighthouse
+ ${blockTrafficBetween "allowAny" "lighthouse"}
+ ${blockTrafficBetween "allowAny" "allowFromLighthouse"}
+ ${blockTrafficBetween "allowAny" "allowToLighthouse"}
+ allowFromLighthouse.fail("ping -c3 10.0.100.2")
+ allowAny.fail("ping -c3 10.0.100.3")
+ allowAny.fail("ping -c3 10.0.100.4")
+ ${allowTrafficBetween "allowAny" "lighthouse"}
+ ${allowTrafficBetween "allowAny" "allowFromLighthouse"}
+ ${allowTrafficBetween "allowAny" "allowToLighthouse"}
+ allowFromLighthouse.succeed("ping -c3 10.0.100.2")
+ allowAny.succeed("ping -c3 10.0.100.3")
+ allowAny.succeed("ping -c3 10.0.100.4")
+
+ # block lighthouse <-> allowToLighthouse and allowToLighthouse <-> allowAny; it won't get to allowAny
+ ${blockTrafficBetween "allowToLighthouse" "lighthouse"}
+ ${blockTrafficBetween "allowToLighthouse" "allowAny"}
+ allowAny.fail("ping -c3 10.0.100.4")
+ allowToLighthouse.fail("ping -c3 10.0.100.2")
+ ${allowTrafficBetween "allowToLighthouse" "lighthouse"}
+ ${allowTrafficBetween "allowToLighthouse" "allowAny"}
+ allowAny.succeed("ping -c3 10.0.100.4")
+ allowToLighthouse.succeed("ping -c3 10.0.100.2")
+ '';
+}
diff --git a/nixos/tests/netbird.nix b/nixos/tests/netbird.nix
index f684a3104265..581c6eeeab2e 100644
--- a/nixos/tests/netbird.nix
+++ b/nixos/tests/netbird.nix
@@ -1,59 +1,57 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "netbird";
+{ pkgs, lib, ... }:
+{
+ name = "netbird";
- meta.maintainers = with pkgs.lib.maintainers; [
- nazarewk
- ];
+ meta.maintainers = with pkgs.lib.maintainers; [
+ nazarewk
+ ];
- nodes = {
- clients =
- { ... }:
- {
- services.netbird.enable = true;
- services.netbird.clients.custom.port = 51819;
- };
- };
+ nodes = {
+ clients =
+ { ... }:
+ {
+ services.netbird.enable = true;
+ services.netbird.clients.custom.port = 51819;
+ };
+ };
- # TODO: confirm the whole solution is working end-to-end when netbird server is implemented
- testScript = ''
- start_all()
- def did_start(node, name):
- node.wait_for_unit(f"{name}.service")
- node.wait_for_file(f"/var/run/{name}/sock")
- output = node.succeed(f"{name} status")
+ # TODO: confirm the whole solution is working end-to-end when netbird server is implemented
+ testScript = ''
+ start_all()
+ def did_start(node, name):
+ node.wait_for_unit(f"{name}.service")
+ node.wait_for_file(f"/var/run/{name}/sock")
+ output = node.succeed(f"{name} status")
- # not sure why, but it can print either of:
- # - Daemon status: NeedsLogin
- # - Management: Disconnected
- expected = [
- "Disconnected",
- "NeedsLogin",
- ]
- assert any(msg in output for msg in expected)
+ # not sure why, but it can print either of:
+ # - Daemon status: NeedsLogin
+ # - Management: Disconnected
+ expected = [
+ "Disconnected",
+ "NeedsLogin",
+ ]
+ assert any(msg in output for msg in expected)
- did_start(clients, "netbird")
- did_start(clients, "netbird-custom")
- '';
+ did_start(clients, "netbird")
+ did_start(clients, "netbird-custom")
+ '';
- /*
- `netbird status` used to print `Daemon status: NeedsLogin`
- https://github.com/netbirdio/netbird/blob/23a14737974e3849fa86408d136cc46db8a885d0/client/cmd/status.go#L154-L164
- as the first line, but now it is just:
+ /*
+ `netbird status` used to print `Daemon status: NeedsLogin`
+ https://github.com/netbirdio/netbird/blob/23a14737974e3849fa86408d136cc46db8a885d0/client/cmd/status.go#L154-L164
+ as the first line, but now it is just:
- Daemon version: 0.26.3
- CLI version: 0.26.3
- Management: Disconnected
- Signal: Disconnected
- Relays: 0/0 Available
- Nameservers: 0/0 Available
- FQDN:
- NetBird IP: N/A
- Interface type: N/A
- Quantum resistance: false
- Routes: -
- Peers count: 0/0 Connected
- */
- }
-)
+ Daemon version: 0.26.3
+ CLI version: 0.26.3
+ Management: Disconnected
+ Signal: Disconnected
+ Relays: 0/0 Available
+ Nameservers: 0/0 Available
+ FQDN:
+ NetBird IP: N/A
+ Interface type: N/A
+ Quantum resistance: false
+ Routes: -
+ Peers count: 0/0 Connected
+ */
+}
diff --git a/nixos/tests/netdata.nix b/nixos/tests/netdata.nix
index 77c34e70e7d0..2a85c11f0542 100644
--- a/nixos/tests/netdata.nix
+++ b/nixos/tests/netdata.nix
@@ -1,57 +1,55 @@
# This test runs netdata and checks for data via apps.plugin
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "netdata";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- cransom
- raitobezarius
- ];
- };
+{ pkgs, ... }:
+{
+ name = "netdata";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ cransom
+ raitobezarius
+ ];
+ };
- nodes = {
- netdata =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [
- curl
- jq
- netdata
- ];
- services.netdata = {
- enable = true;
- package = pkgs.netdataCloud;
- python.recommendedPythonPackages = true;
+ nodes = {
+ netdata =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ curl
+ jq
+ netdata
+ ];
+ services.netdata = {
+ enable = true;
+ package = pkgs.netdataCloud;
+ python.recommendedPythonPackages = true;
- configDir."apps_groups.conf" = pkgs.writeText "apps_groups.conf" ''
- netdata_test: netdata
- '';
- };
+ configDir."apps_groups.conf" = pkgs.writeText "apps_groups.conf" ''
+ netdata_test: netdata
+ '';
};
- };
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- netdata.wait_for_unit("netdata.service")
+ netdata.wait_for_unit("netdata.service")
- # wait for the service to listen before sending a request
- netdata.wait_for_open_port(19999)
+ # wait for the service to listen before sending a request
+ netdata.wait_for_open_port(19999)
- # check if the netdata main page loads.
- netdata.succeed("curl --fail http://127.0.0.1:19999")
- netdata.succeed("sleep 4")
+ # check if the netdata main page loads.
+ netdata.succeed("curl --fail http://127.0.0.1:19999")
+ netdata.succeed("sleep 4")
- # check if netdata api shows correct os
- url = "http://127.0.0.1:19999/api/v3/info"
- filter = '.agents[0].application.os.os | . == "NixOS"'
- cmd = f"curl -s {url} | jq -e '{filter}'"
- netdata.wait_until_succeeds(cmd)
+ # check if netdata api shows correct os
+ url = "http://127.0.0.1:19999/api/v3/info"
+ filter = '.agents[0].application.os.os | . == "NixOS"'
+ cmd = f"curl -s {url} | jq -e '{filter}'"
+ netdata.wait_until_succeeds(cmd)
- # check if the control socket is available
- netdata.succeed("sudo netdatacli ping")
- '';
- }
-)
+ # check if the control socket is available
+ netdata.succeed("sudo netdatacli ping")
+ '';
+}
diff --git a/nixos/tests/networking-proxy.nix b/nixos/tests/networking-proxy.nix
index 4592bffec9e3..c20dd297328f 100644
--- a/nixos/tests/networking-proxy.nix
+++ b/nixos/tests/networking-proxy.nix
@@ -11,130 +11,128 @@ let
};
in
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "networking-proxy";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
- };
+{ pkgs, ... }:
+{
+ name = "networking-proxy";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
- nodes = {
- # no proxy
- machine =
- { ... }:
+ nodes = {
+ # no proxy
+ machine =
+ { ... }:
- default-config;
+ default-config;
- # proxy default
- machine2 =
- { ... }:
+ # proxy default
+ machine2 =
+ { ... }:
- default-config
- // {
- networking.proxy.default = "http://user:pass@host:port";
+ default-config
+ // {
+ networking.proxy.default = "http://user:pass@host:port";
+ };
+
+ # specific proxy options
+ machine3 =
+ { ... }:
+
+ default-config
+ // {
+ networking.proxy = {
+ # useless because overridden by the next options
+ default = "http://user:pass@host:port";
+ # advanced proxy setup
+ httpProxy = "123-http://user:pass@http-host:port";
+ httpsProxy = "456-http://user:pass@https-host:port";
+ rsyncProxy = "789-http://user:pass@rsync-host:port";
+ ftpProxy = "101112-http://user:pass@ftp-host:port";
+ noProxy = "131415-127.0.0.1,localhost,.localdomain";
};
+ };
- # specific proxy options
- machine3 =
- { ... }:
+ # mix default + proxy options
+ machine4 =
+ { ... }:
- default-config
- // {
- networking.proxy = {
- # useless because overridden by the next options
- default = "http://user:pass@host:port";
- # advanced proxy setup
- httpProxy = "123-http://user:pass@http-host:port";
- httpsProxy = "456-http://user:pass@https-host:port";
- rsyncProxy = "789-http://user:pass@rsync-host:port";
- ftpProxy = "101112-http://user:pass@ftp-host:port";
- noProxy = "131415-127.0.0.1,localhost,.localdomain";
- };
+ default-config
+ // {
+ networking.proxy = {
+ # open for all *_proxy env var
+ default = "000-http://user:pass@default-host:port";
+ # except for those 2
+ rsyncProxy = "123-http://user:pass@http-host:port";
+ noProxy = "131415-127.0.0.1,localhost,.localdomain";
};
+ };
+ };
- # mix default + proxy options
- machine4 =
- { ... }:
-
- default-config
- // {
- networking.proxy = {
- # open for all *_proxy env var
- default = "000-http://user:pass@default-host:port";
- # except for those 2
- rsyncProxy = "123-http://user:pass@http-host:port";
- noProxy = "131415-127.0.0.1,localhost,.localdomain";
- };
- };
- };
-
- testScript = ''
- from typing import Dict, Optional
+ testScript = ''
+ from typing import Dict, Optional
- def get_machine_env(machine: Machine, user: Optional[str] = None) -> Dict[str, str]:
- """
- Gets the environment from a given machine, and returns it as a
- dictionary in the form:
- {"lowercase_var_name": "value"}
+ def get_machine_env(machine: Machine, user: Optional[str] = None) -> Dict[str, str]:
+ """
+ Gets the environment from a given machine, and returns it as a
+ dictionary in the form:
+ {"lowercase_var_name": "value"}
- Duplicate environment variables with the same name
- (e.g. "foo" and "FOO") are handled in an undefined manner.
- """
- if user is not None:
- env = machine.succeed("su - {} -c 'env -0'".format(user))
- else:
- env = machine.succeed("env -0")
- ret = {}
- for line in env.split("\0"):
- if "=" not in line:
- continue
+ Duplicate environment variables with the same name
+ (e.g. "foo" and "FOO") are handled in an undefined manner.
+ """
+ if user is not None:
+ env = machine.succeed("su - {} -c 'env -0'".format(user))
+ else:
+ env = machine.succeed("env -0")
+ ret = {}
+ for line in env.split("\0"):
+ if "=" not in line:
+ continue
- key, val = line.split("=", 1)
- ret[key.lower()] = val
- return ret
+ key, val = line.split("=", 1)
+ ret[key.lower()] = val
+ return ret
- start_all()
+ start_all()
- with subtest("no proxy"):
- assert "proxy" not in machine.succeed("env").lower()
- assert "proxy" not in machine.succeed("su - alice -c env").lower()
+ with subtest("no proxy"):
+ assert "proxy" not in machine.succeed("env").lower()
+ assert "proxy" not in machine.succeed("su - alice -c env").lower()
- with subtest("default proxy"):
- assert "proxy" in machine2.succeed("env").lower()
- assert "proxy" in machine2.succeed("su - alice -c env").lower()
+ with subtest("default proxy"):
+ assert "proxy" in machine2.succeed("env").lower()
+ assert "proxy" in machine2.succeed("su - alice -c env").lower()
- with subtest("explicitly-set proxy"):
- env = get_machine_env(machine3)
- assert "123" in env["http_proxy"]
- assert "456" in env["https_proxy"]
- assert "789" in env["rsync_proxy"]
- assert "101112" in env["ftp_proxy"]
- assert "131415" in env["no_proxy"]
+ with subtest("explicitly-set proxy"):
+ env = get_machine_env(machine3)
+ assert "123" in env["http_proxy"]
+ assert "456" in env["https_proxy"]
+ assert "789" in env["rsync_proxy"]
+ assert "101112" in env["ftp_proxy"]
+ assert "131415" in env["no_proxy"]
- env = get_machine_env(machine3, "alice")
- assert "123" in env["http_proxy"]
- assert "456" in env["https_proxy"]
- assert "789" in env["rsync_proxy"]
- assert "101112" in env["ftp_proxy"]
- assert "131415" in env["no_proxy"]
+ env = get_machine_env(machine3, "alice")
+ assert "123" in env["http_proxy"]
+ assert "456" in env["https_proxy"]
+ assert "789" in env["rsync_proxy"]
+ assert "101112" in env["ftp_proxy"]
+ assert "131415" in env["no_proxy"]
- with subtest("default proxy + some other specifics"):
- env = get_machine_env(machine4)
- assert "000" in env["http_proxy"]
- assert "000" in env["https_proxy"]
- assert "123" in env["rsync_proxy"]
- assert "000" in env["ftp_proxy"]
- assert "131415" in env["no_proxy"]
+ with subtest("default proxy + some other specifics"):
+ env = get_machine_env(machine4)
+ assert "000" in env["http_proxy"]
+ assert "000" in env["https_proxy"]
+ assert "123" in env["rsync_proxy"]
+ assert "000" in env["ftp_proxy"]
+ assert "131415" in env["no_proxy"]
- env = get_machine_env(machine4, "alice")
- assert "000" in env["http_proxy"]
- assert "000" in env["https_proxy"]
- assert "123" in env["rsync_proxy"]
- assert "000" in env["ftp_proxy"]
- assert "131415" in env["no_proxy"]
- '';
- }
-)
+ env = get_machine_env(machine4, "alice")
+ assert "000" in env["http_proxy"]
+ assert "000" in env["https_proxy"]
+ assert "123" in env["rsync_proxy"]
+ assert "000" in env["ftp_proxy"]
+ assert "131415" in env["no_proxy"]
+ '';
+}
diff --git a/nixos/tests/nexus.nix b/nixos/tests/nexus.nix
index 9c3e65daf317..d8cad38500ed 100644
--- a/nixos/tests/nexus.nix
+++ b/nixos/tests/nexus.nix
@@ -3,34 +3,32 @@
# 2. nexus service can startup on server (creating database and all other initial stuff)
# 3. the web application is reachable via HTTP
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "nexus";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ironpinguin ];
- };
+{ pkgs, ... }:
+{
+ name = "nexus";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ironpinguin ];
+ };
- nodes = {
+ nodes = {
- server =
- { ... }:
- {
- virtualisation.memorySize = 2047; # qemu-system-i386 has a 2047M limit
- virtualisation.diskSize = 8192;
+ server =
+ { ... }:
+ {
+ virtualisation.memorySize = 2047; # qemu-system-i386 has a 2047M limit
+ virtualisation.diskSize = 8192;
- services.nexus.enable = true;
- };
+ services.nexus.enable = true;
+ };
- };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- server.wait_for_unit("nexus")
- server.wait_for_open_port(8081)
+ server.wait_for_unit("nexus")
+ server.wait_for_open_port(8081)
- server.succeed("curl -f 127.0.0.1:8081")
- '';
- }
-)
+ server.succeed("curl -f 127.0.0.1:8081")
+ '';
+}
diff --git a/nixos/tests/nghttpx.nix b/nixos/tests/nghttpx.nix
index 15acb81b12c1..a9f5cf112e2d 100644
--- a/nixos/tests/nghttpx.nix
+++ b/nixos/tests/nghttpx.nix
@@ -1,66 +1,64 @@
let
nginxRoot = "/run/nginx";
in
-import ./make-test-python.nix (
- { ... }:
- {
- name = "nghttpx";
- nodes = {
- webserver = {
- networking.firewall.allowedTCPPorts = [ 80 ];
- systemd.services.nginx = {
- preStart = ''
- mkdir -p ${nginxRoot}
- echo "Hello world!" > ${nginxRoot}/hello-world.txt
- '';
- };
-
- services.nginx = {
- enable = true;
- virtualHosts.server = {
- locations."/".root = nginxRoot;
- };
- };
+{ ... }:
+{
+ name = "nghttpx";
+ nodes = {
+ webserver = {
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ systemd.services.nginx = {
+ preStart = ''
+ mkdir -p ${nginxRoot}
+ echo "Hello world!" > ${nginxRoot}/hello-world.txt
+ '';
};
- proxy = {
- networking.firewall.allowedTCPPorts = [ 80 ];
- services.nghttpx = {
- enable = true;
- frontends = [
- {
- server = {
- host = "*";
- port = 80;
- };
-
- params = {
- tls = "no-tls";
- };
- }
- ];
- backends = [
- {
- server = {
- host = "webserver";
- port = 80;
- };
- patterns = [ "/" ];
- params.proto = "http/1.1";
- }
- ];
+ services.nginx = {
+ enable = true;
+ virtualHosts.server = {
+ locations."/".root = nginxRoot;
};
};
-
- client = { };
};
- testScript = ''
- start_all()
+ proxy = {
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ services.nghttpx = {
+ enable = true;
+ frontends = [
+ {
+ server = {
+ host = "*";
+ port = 80;
+ };
- webserver.wait_for_open_port(80)
- proxy.wait_for_open_port(80)
- client.wait_until_succeeds("curl -s --fail http://proxy/hello-world.txt")
- '';
- }
-)
+ params = {
+ tls = "no-tls";
+ };
+ }
+ ];
+ backends = [
+ {
+ server = {
+ host = "webserver";
+ port = 80;
+ };
+ patterns = [ "/" ];
+ params.proto = "http/1.1";
+ }
+ ];
+ };
+ };
+
+ client = { };
+ };
+
+ testScript = ''
+ start_all()
+
+ webserver.wait_for_open_port(80)
+ proxy.wait_for_open_port(80)
+ client.wait_until_succeeds("curl -s --fail http://proxy/hello-world.txt")
+ '';
+}
diff --git a/nixos/tests/nginx-njs.nix b/nixos/tests/nginx-njs.nix
index 7e9e911ee02f..a64bbad08e10 100644
--- a/nixos/tests/nginx-njs.nix
+++ b/nixos/tests/nginx-njs.nix
@@ -1,37 +1,35 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "nginx-njs";
+{ pkgs, lib, ... }:
+{
+ name = "nginx-njs";
- nodes.machine =
- {
- config,
- lib,
- pkgs,
- ...
- }:
- {
- services.nginx = {
- enable = true;
- additionalModules = [ pkgs.nginxModules.njs ];
- commonHttpConfig = ''
- js_import http from ${builtins.toFile "http.js" ''
- function hello(r) {
- r.return(200, "Hello world!");
- }
- export default {hello};
- ''};
- '';
- virtualHosts."localhost".locations."/".extraConfig = ''
- js_content http.hello;
- '';
- };
+ nodes.machine =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ services.nginx = {
+ enable = true;
+ additionalModules = [ pkgs.nginxModules.njs ];
+ commonHttpConfig = ''
+ js_import http from ${builtins.toFile "http.js" ''
+ function hello(r) {
+ r.return(200, "Hello world!");
+ }
+ export default {hello};
+ ''};
+ '';
+ virtualHosts."localhost".locations."/".extraConfig = ''
+ js_content http.hello;
+ '';
};
- testScript = ''
- machine.wait_for_unit("nginx")
+ };
+ testScript = ''
+ machine.wait_for_unit("nginx")
- response = machine.wait_until_succeeds("curl -fvvv -s http://127.0.0.1/")
- assert "Hello world!" == response, f"Expected 'Hello world!', got '{response}'"
- '';
- }
-)
+ response = machine.wait_until_succeeds("curl -fvvv -s http://127.0.0.1/")
+ assert "Hello world!" == response, f"Expected 'Hello world!', got '{response}'"
+ '';
+}
diff --git a/nixos/tests/nimdow.nix b/nixos/tests/nimdow.nix
index d71fcf35acd8..7d1d815bcd13 100644
--- a/nixos/tests/nimdow.nix
+++ b/nixos/tests/nimdow.nix
@@ -1,35 +1,33 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "nimdow";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ marcusramberg ];
+{ pkgs, ... }:
+{
+ name = "nimdow";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ marcusramberg ];
+ };
+
+ nodes.machine =
+ { lib, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ./common/user-account.nix
+ ];
+ test-support.displayManager.auto.user = "alice";
+ services.displayManager.defaultSession = lib.mkForce "none+nimdow";
+ services.xserver.windowManager.nimdow.enable = true;
};
- nodes.machine =
- { lib, ... }:
- {
- imports = [
- ./common/x11.nix
- ./common/user-account.nix
- ];
- test-support.displayManager.auto.user = "alice";
- services.displayManager.defaultSession = lib.mkForce "none+nimdow";
- services.xserver.windowManager.nimdow.enable = true;
- };
+ testScript =
+ { ... }:
+ ''
+ with subtest("ensure x starts"):
+ machine.wait_for_x()
+ machine.wait_for_file("/home/alice/.Xauthority")
+ machine.succeed("xauth merge ~alice/.Xauthority")
- testScript =
- { ... }:
- ''
- with subtest("ensure x starts"):
- machine.wait_for_x()
- machine.wait_for_file("/home/alice/.Xauthority")
- machine.succeed("xauth merge ~alice/.Xauthority")
-
- with subtest("ensure we can open a new terminal"):
- machine.send_key("meta_l-ret")
- machine.wait_for_window(r"alice.*?machine")
- machine.screenshot("terminal")
- '';
- }
-)
+ with subtest("ensure we can open a new terminal"):
+ machine.send_key("meta_l-ret")
+ machine.wait_for_window(r"alice.*?machine")
+ machine.screenshot("terminal")
+ '';
+}
diff --git a/nixos/tests/nitter.nix b/nixos/tests/nitter.nix
index 3b063c9f19ae..4678652927e5 100644
--- a/nixos/tests/nitter.nix
+++ b/nixos/tests/nitter.nix
@@ -1,35 +1,33 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- # In a real deployment this should naturally not common from the nix store
- # and be seeded via agenix or as a non-nix managed file.
- #
- # These credentials are from the nitter wiki and are expired. We must provide
- # credentials in the correct format, otherwise nitter fails to start. They
- # must not be valid, as unauthorized errors are handled gracefully.
- sessionsFile = pkgs.writeText "sessions.jsonl" ''
- {"oauth_token":"1719213587296620928-BsXY2RIJEw7fjxoNwbBemgjJhueK0m","oauth_token_secret":"N0WB0xhL4ng6WTN44aZO82SUJjz7ssI3hHez2CUhTiYqy"}
- '';
- in
- {
- name = "nitter";
- meta.maintainers = with pkgs.lib.maintainers; [ erdnaxe ];
+let
+ # In a real deployment this should naturally not common from the nix store
+ # and be seeded via agenix or as a non-nix managed file.
+ #
+ # These credentials are from the nitter wiki and are expired. We must provide
+ # credentials in the correct format, otherwise nitter fails to start. They
+ # must not be valid, as unauthorized errors are handled gracefully.
+ sessionsFile = pkgs.writeText "sessions.jsonl" ''
+ {"oauth_token":"1719213587296620928-BsXY2RIJEw7fjxoNwbBemgjJhueK0m","oauth_token_secret":"N0WB0xhL4ng6WTN44aZO82SUJjz7ssI3hHez2CUhTiYqy"}
+ '';
+in
+{
+ name = "nitter";
+ meta.maintainers = with pkgs.lib.maintainers; [ erdnaxe ];
- nodes.machine = {
- services.nitter = {
- enable = true;
- # Test CAP_NET_BIND_SERVICE
- server.port = 80;
- # Provide dummy guest accounts
- inherit sessionsFile;
- };
+ nodes.machine = {
+ services.nitter = {
+ enable = true;
+ # Test CAP_NET_BIND_SERVICE
+ server.port = 80;
+ # Provide dummy guest accounts
+ inherit sessionsFile;
};
+ };
- testScript = ''
- machine.wait_for_unit("nitter.service")
- machine.wait_for_open_port(80)
- machine.succeed("curl --fail http://localhost:80/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("nitter.service")
+ machine.wait_for_open_port(80)
+ machine.succeed("curl --fail http://localhost:80/")
+ '';
+}
diff --git a/nixos/tests/nix-config.nix b/nixos/tests/nix-config.nix
index 18fa3ae347aa..b39baf3f6b50 100644
--- a/nixos/tests/nix-config.nix
+++ b/nixos/tests/nix-config.nix
@@ -1,22 +1,20 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "nix-config";
- nodes.machine =
- { pkgs, ... }:
- {
- nix.settings = {
- nix-path = [ "nonextra=/etc/value.nix" ];
- extra-nix-path = [ "extra=/etc/value.nix" ];
- };
- environment.etc."value.nix".text = "42";
+{ pkgs, ... }:
+{
+ name = "nix-config";
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ nix.settings = {
+ nix-path = [ "nonextra=/etc/value.nix" ];
+ extra-nix-path = [ "extra=/etc/value.nix" ];
};
- testScript = ''
- start_all()
- machine.wait_for_unit("nix-daemon.socket")
- # regression test for the workaround for https://github.com/NixOS/nix/issues/9487
- print(machine.succeed("nix-instantiate --find-file extra"))
- print(machine.succeed("nix-instantiate --find-file nonextra"))
- '';
- }
-)
+ environment.etc."value.nix".text = "42";
+ };
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("nix-daemon.socket")
+ # regression test for the workaround for https://github.com/NixOS/nix/issues/9487
+ print(machine.succeed("nix-instantiate --find-file extra"))
+ print(machine.succeed("nix-instantiate --find-file nonextra"))
+ '';
+}
diff --git a/nixos/tests/nix-serve-ssh.nix b/nixos/tests/nix-serve-ssh.nix
index 554ea5a69f20..e5b3adc37b3a 100644
--- a/nixos/tests/nix-serve-ssh.nix
+++ b/nixos/tests/nix-serve-ssh.nix
@@ -1,50 +1,48 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- inherit (import ./ssh-keys.nix pkgs)
- snakeOilPrivateKey
- snakeOilPublicKey
- ;
- ssh-config = builtins.toFile "ssh.conf" ''
- UserKnownHostsFile=/dev/null
- StrictHostKeyChecking=no
- '';
- in
- {
- name = "nix-ssh-serve";
- meta.maintainers = [ lib.maintainers.shlevy ];
- nodes = {
- server.nix.sshServe = {
- enable = true;
- keys = [ snakeOilPublicKey ];
- protocol = "ssh-ng";
- };
- server.nix.package = pkgs.nix;
- client.nix.package = pkgs.nix;
+{ pkgs, lib, ... }:
+let
+ inherit (import ./ssh-keys.nix pkgs)
+ snakeOilPrivateKey
+ snakeOilPublicKey
+ ;
+ ssh-config = builtins.toFile "ssh.conf" ''
+ UserKnownHostsFile=/dev/null
+ StrictHostKeyChecking=no
+ '';
+in
+{
+ name = "nix-ssh-serve";
+ meta.maintainers = [ lib.maintainers.shlevy ];
+ nodes = {
+ server.nix.sshServe = {
+ enable = true;
+ keys = [ snakeOilPublicKey ];
+ protocol = "ssh-ng";
};
- testScript = ''
- start_all()
+ server.nix.package = pkgs.nix;
+ client.nix.package = pkgs.nix;
+ };
+ testScript = ''
+ start_all()
- client.succeed("mkdir -m 700 /root/.ssh")
- client.succeed(
- "cat ${ssh-config} > /root/.ssh/config"
- )
- client.succeed(
- "cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"
- )
- client.succeed("chmod 600 /root/.ssh/id_ecdsa")
+ client.succeed("mkdir -m 700 /root/.ssh")
+ client.succeed(
+ "cat ${ssh-config} > /root/.ssh/config"
+ )
+ client.succeed(
+ "cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"
+ )
+ client.succeed("chmod 600 /root/.ssh/id_ecdsa")
- client.succeed("nix-store --add /etc/machine-id > mach-id-path")
+ client.succeed("nix-store --add /etc/machine-id > mach-id-path")
- server.wait_for_unit("sshd")
+ server.wait_for_unit("sshd")
- client.fail("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
- # Currently due to shared store this is a noop :(
- client.succeed("nix copy --experimental-features 'nix-command' --to ssh-ng://nix-ssh@server $(cat mach-id-path)")
- client.succeed(
- "nix-store --realise $(cat mach-id-path) --store /root/other-store --substituters ssh-ng://nix-ssh@server"
- )
- client.succeed("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
- '';
- }
-)
+ client.fail("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
+ # Currently due to shared store this is a noop :(
+ client.succeed("nix copy --experimental-features 'nix-command' --to ssh-ng://nix-ssh@server $(cat mach-id-path)")
+ client.succeed(
+ "nix-store --realise $(cat mach-id-path) --store /root/other-store --substituters ssh-ng://nix-ssh@server"
+ )
+ client.succeed("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
+ '';
+}
diff --git a/nixos/tests/nixos-generate-config.nix b/nixos/tests/nixos-generate-config.nix
index d9b2f502365e..6579b3646e21 100644
--- a/nixos/tests/nixos-generate-config.nix
+++ b/nixos/tests/nixos-generate-config.nix
@@ -1,52 +1,50 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "nixos-generate-config";
- meta.maintainers = with lib.maintainers; [ basvandijk ];
- nodes.machine = {
- system.nixos-generate-config.configuration = ''
- # OVERRIDDEN
- { config, pkgs, ... }: {
- imports = [ ./hardware-configuration.nix ];
- $bootLoaderConfig
- $desktopConfiguration
- }
- '';
-
- system.nixos-generate-config.desktopConfiguration = [
- ''
- # DESKTOP
- services.xserver.displayManager.gdm.enable = true;
- services.xserver.desktopManager.gnome.enable = true;
- ''
- ];
- };
- testScript = ''
- start_all()
- machine.wait_for_unit("multi-user.target")
- machine.succeed("nixos-generate-config")
-
- machine.succeed("nix-instantiate --parse /etc/nixos/configuration.nix /etc/nixos/hardware-configuration.nix")
-
- # Test if the configuration really is overridden
- machine.succeed("grep 'OVERRIDDEN' /etc/nixos/configuration.nix")
-
- # Test if desktop configuration really is overridden
- machine.succeed("grep 'DESKTOP' /etc/nixos/configuration.nix")
-
- # Test of if the Perl variable $bootLoaderConfig is spliced correctly:
- machine.succeed(
- "grep 'boot\\.loader\\.grub\\.enable = true;' /etc/nixos/configuration.nix"
- )
-
- # Test if the Perl variable $desktopConfiguration is spliced correctly
- machine.succeed(
- "grep 'services\\.xserver\\.desktopManager\\.gnome\\.enable = true;' /etc/nixos/configuration.nix"
- )
-
- machine.succeed("rm -rf /etc/nixos")
- machine.succeed("nixos-generate-config --flake")
- machine.succeed("nix-instantiate --parse /etc/nixos/flake.nix /etc/nixos/configuration.nix /etc/nixos/hardware-configuration.nix")
+{ lib, ... }:
+{
+ name = "nixos-generate-config";
+ meta.maintainers = with lib.maintainers; [ basvandijk ];
+ nodes.machine = {
+ system.nixos-generate-config.configuration = ''
+ # OVERRIDDEN
+ { config, pkgs, ... }: {
+ imports = [ ./hardware-configuration.nix ];
+ $bootLoaderConfig
+ $desktopConfiguration
+ }
'';
- }
-)
+
+ system.nixos-generate-config.desktopConfiguration = [
+ ''
+ # DESKTOP
+ services.xserver.displayManager.gdm.enable = true;
+ services.xserver.desktopManager.gnome.enable = true;
+ ''
+ ];
+ };
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("nixos-generate-config")
+
+ machine.succeed("nix-instantiate --parse /etc/nixos/configuration.nix /etc/nixos/hardware-configuration.nix")
+
+ # Test if the configuration really is overridden
+ machine.succeed("grep 'OVERRIDDEN' /etc/nixos/configuration.nix")
+
+ # Test if desktop configuration really is overridden
+ machine.succeed("grep 'DESKTOP' /etc/nixos/configuration.nix")
+
+ # Test of if the Perl variable $bootLoaderConfig is spliced correctly:
+ machine.succeed(
+ "grep 'boot\\.loader\\.grub\\.enable = true;' /etc/nixos/configuration.nix"
+ )
+
+ # Test if the Perl variable $desktopConfiguration is spliced correctly
+ machine.succeed(
+ "grep 'services\\.xserver\\.desktopManager\\.gnome\\.enable = true;' /etc/nixos/configuration.nix"
+ )
+
+ machine.succeed("rm -rf /etc/nixos")
+ machine.succeed("nixos-generate-config --flake")
+ machine.succeed("nix-instantiate --parse /etc/nixos/flake.nix /etc/nixos/configuration.nix /etc/nixos/hardware-configuration.nix")
+ '';
+}
diff --git a/nixos/tests/nixos-test-driver/extra-python-packages.nix b/nixos/tests/nixos-test-driver/extra-python-packages.nix
index 6c187e605591..700299c6a118 100644
--- a/nixos/tests/nixos-test-driver/extra-python-packages.nix
+++ b/nixos/tests/nixos-test-driver/extra-python-packages.nix
@@ -1,15 +1,13 @@
-import ../make-test-python.nix (
- { ... }:
- {
- name = "extra-python-packages";
+{ ... }:
+{
+ name = "extra-python-packages";
- extraPythonPackages = p: [ p.numpy ];
+ extraPythonPackages = p: [ p.numpy ];
- nodes = { };
+ nodes = { };
- testScript = ''
- import numpy as np
- assert str(np.zeros(4) == "array([0., 0., 0., 0.])")
- '';
- }
-)
+ testScript = ''
+ import numpy as np
+ assert str(np.zeros(4) == "array([0., 0., 0., 0.])")
+ '';
+}
diff --git a/nixos/tests/nixseparatedebuginfod.nix b/nixos/tests/nixseparatedebuginfod.nix
index bb9f8c9f43be..39fd6356340d 100644
--- a/nixos/tests/nixseparatedebuginfod.nix
+++ b/nixos/tests/nixseparatedebuginfod.nix
@@ -1,84 +1,82 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- secret-key = "key-name:/COlMSRbehSh6YSruJWjL+R0JXQUKuPEn96fIb+pLokEJUjcK/2Gv8Ai96D7JGay5gDeUTx5wdpPgNvum9YtwA==";
- public-key = "key-name:BCVI3Cv9hr/AIveg+yRmsuYA3lE8ecHaT4Db7pvWLcA=";
- in
- {
- name = "nixseparatedebuginfod";
- # A binary cache with debug info and source for nix
- nodes.cache =
- { pkgs, ... }:
- {
- services.nix-serve = {
- enable = true;
- secretKeyFile = builtins.toFile "secret-key" secret-key;
- openFirewall = true;
- };
- system.extraDependencies = [
- pkgs.nix.debug
- pkgs.nix.src
- pkgs.sl
- ];
+{ pkgs, lib, ... }:
+let
+ secret-key = "key-name:/COlMSRbehSh6YSruJWjL+R0JXQUKuPEn96fIb+pLokEJUjcK/2Gv8Ai96D7JGay5gDeUTx5wdpPgNvum9YtwA==";
+ public-key = "key-name:BCVI3Cv9hr/AIveg+yRmsuYA3lE8ecHaT4Db7pvWLcA=";
+in
+{
+ name = "nixseparatedebuginfod";
+ # A binary cache with debug info and source for nix
+ nodes.cache =
+ { pkgs, ... }:
+ {
+ services.nix-serve = {
+ enable = true;
+ secretKeyFile = builtins.toFile "secret-key" secret-key;
+ openFirewall = true;
};
- # the machine where we need the debuginfo
- nodes.machine = {
- imports = [
- ../modules/installer/cd-dvd/channel.nix
- ];
- services.nixseparatedebuginfod.enable = true;
- nix.settings = {
- substituters = lib.mkForce [ "http://cache:5000" ];
- trusted-public-keys = [ public-key ];
- };
- environment.systemPackages = [
- pkgs.valgrind
- pkgs.gdb
- (pkgs.writeShellScriptBin "wait_for_indexation" ''
- set -x
- while debuginfod-find debuginfo /run/current-system/sw/bin/nix |& grep 'File too large'; do
- sleep 1;
- done
- '')
+ system.extraDependencies = [
+ pkgs.nix.debug
+ pkgs.nix.src
+ pkgs.sl
];
};
- testScript = ''
- start_all()
- cache.wait_for_unit("nix-serve.service")
- cache.wait_for_open_port(5000)
- machine.wait_for_unit("nixseparatedebuginfod.service")
- machine.wait_for_open_port(1949)
+ # the machine where we need the debuginfo
+ nodes.machine = {
+ imports = [
+ ../modules/installer/cd-dvd/channel.nix
+ ];
+ services.nixseparatedebuginfod.enable = true;
+ nix.settings = {
+ substituters = lib.mkForce [ "http://cache:5000" ];
+ trusted-public-keys = [ public-key ];
+ };
+ environment.systemPackages = [
+ pkgs.valgrind
+ pkgs.gdb
+ (pkgs.writeShellScriptBin "wait_for_indexation" ''
+ set -x
+ while debuginfod-find debuginfo /run/current-system/sw/bin/nix |& grep 'File too large'; do
+ sleep 1;
+ done
+ '')
+ ];
+ };
+ testScript = ''
+ start_all()
+ cache.wait_for_unit("nix-serve.service")
+ cache.wait_for_open_port(5000)
+ machine.wait_for_unit("nixseparatedebuginfod.service")
+ machine.wait_for_open_port(1949)
- with subtest("show the config to debug the test"):
- machine.succeed("nix --extra-experimental-features nix-command show-config |& logger")
- machine.succeed("cat /etc/nix/nix.conf |& logger")
- with subtest("check that the binary cache works"):
- machine.succeed("nix-store -r ${pkgs.sl}")
+ with subtest("show the config to debug the test"):
+ machine.succeed("nix --extra-experimental-features nix-command show-config |& logger")
+ machine.succeed("cat /etc/nix/nix.conf |& logger")
+ with subtest("check that the binary cache works"):
+ machine.succeed("nix-store -r ${pkgs.sl}")
- # nixseparatedebuginfod needs .drv to associate executable -> source
- # on regular systems this would be provided by nixos-rebuild
- machine.succeed("nix-instantiate '' -A nix")
+ # nixseparatedebuginfod needs .drv to associate executable -> source
+ # on regular systems this would be provided by nixos-rebuild
+ machine.succeed("nix-instantiate '' -A nix")
- machine.succeed("timeout 600 wait_for_indexation")
+ machine.succeed("timeout 600 wait_for_indexation")
- # test debuginfod-find
- machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/nix")
+ # test debuginfod-find
+ machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/nix")
- # test that gdb can fetch source
- out = machine.succeed("gdb /run/current-system/sw/bin/nix --batch -x ${builtins.toFile "commands" ''
- start
- l
- ''}")
- print(out)
- assert 'int main(' in out
+ # test that gdb can fetch source
+ out = machine.succeed("gdb /run/current-system/sw/bin/nix --batch -x ${builtins.toFile "commands" ''
+ start
+ l
+ ''}")
+ print(out)
+ assert 'int main(' in out
- # test that valgrind can display location information
- # this relies on the fact that valgrind complains about nix
- # libgc helps in this regard, and we also ask valgrind to show leak kinds
- # which are usually false positives.
- out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all nix-env --version 2>&1")
- print(out)
- assert 'main.cc' in out
- '';
- }
-)
+ # test that valgrind can display location information
+ # this relies on the fact that valgrind complains about nix
+ # libgc helps in this regard, and we also ask valgrind to show leak kinds
+ # which are usually false positives.
+ out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all nix-env --version 2>&1")
+ print(out)
+ assert 'main.cc' in out
+ '';
+}
diff --git a/nixos/tests/noto-fonts-cjk-qt-default-weight.nix b/nixos/tests/noto-fonts-cjk-qt-default-weight.nix
index 44d9cf8083c1..636dfa3cfb72 100644
--- a/nixos/tests/noto-fonts-cjk-qt-default-weight.nix
+++ b/nixos/tests/noto-fonts-cjk-qt-default-weight.nix
@@ -1,37 +1,35 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "noto-fonts-cjk-qt";
- meta.maintainers = with lib.maintainers; [ oxalica ];
+{ pkgs, lib, ... }:
+{
+ name = "noto-fonts-cjk-qt";
+ meta.maintainers = with lib.maintainers; [ oxalica ];
- nodes.machine = {
- imports = [ ./common/x11.nix ];
- fonts = {
- enableDefaultPackages = false;
- fonts = [ pkgs.noto-fonts-cjk-sans ];
- };
+ nodes.machine = {
+ imports = [ ./common/x11.nix ];
+ fonts = {
+ enableDefaultPackages = false;
+ fonts = [ pkgs.noto-fonts-cjk-sans ];
};
+ };
- testScript =
- let
- script =
- pkgs.writers.writePython3 "qt-default-weight"
- {
- libraries = [ pkgs.python3Packages.pyqt6 ];
- }
- ''
- from PyQt6.QtWidgets import QApplication
- from PyQt6.QtGui import QFont, QRawFont
+ testScript =
+ let
+ script =
+ pkgs.writers.writePython3 "qt-default-weight"
+ {
+ libraries = [ pkgs.python3Packages.pyqt6 ];
+ }
+ ''
+ from PyQt6.QtWidgets import QApplication
+ from PyQt6.QtGui import QFont, QRawFont
- app = QApplication([])
- f = QRawFont.fromFont(QFont("Noto Sans CJK SC", 20))
+ app = QApplication([])
+ f = QRawFont.fromFont(QFont("Noto Sans CJK SC", 20))
- assert f.styleName() == "Regular", f.styleName()
- '';
- in
- ''
- machine.wait_for_x()
- machine.succeed("${script}")
- '';
- }
-)
+ assert f.styleName() == "Regular", f.styleName()
+ '';
+ in
+ ''
+ machine.wait_for_x()
+ machine.succeed("${script}")
+ '';
+}
diff --git a/nixos/tests/npmrc.nix b/nixos/tests/npmrc.nix
index 0377124433f9..d4209d0f85cd 100644
--- a/nixos/tests/npmrc.nix
+++ b/nixos/tests/npmrc.nix
@@ -1,24 +1,22 @@
-import ./make-test-python.nix (
- { ... }:
- let
- machineName = "machine";
- settingName = "prefix";
- settingValue = "/some/path";
- in
- {
- name = "npmrc";
+{ ... }:
+let
+ machineName = "machine";
+ settingName = "prefix";
+ settingValue = "/some/path";
+in
+{
+ name = "npmrc";
- nodes."${machineName}".programs.npm = {
- enable = true;
- npmrc = ''
- ${settingName} = ${settingValue}
- '';
- };
-
- testScript = ''
- ${machineName}.start()
-
- assert ${machineName}.succeed("npm config get ${settingName}") == "${settingValue}\n"
+ nodes."${machineName}".programs.npm = {
+ enable = true;
+ npmrc = ''
+ ${settingName} = ${settingValue}
'';
- }
-)
+ };
+
+ testScript = ''
+ ${machineName}.start()
+
+ assert ${machineName}.succeed("npm config get ${settingName}") == "${settingValue}\n"
+ '';
+}
diff --git a/nixos/tests/nscd.nix b/nixos/tests/nscd.nix
index 75e478725d49..475660e91090 100644
--- a/nixos/tests/nscd.nix
+++ b/nixos/tests/nscd.nix
@@ -1,151 +1,149 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- # build a getent that itself doesn't see anything in /etc/hosts and
- # /etc/nsswitch.conf, by using libredirect to steer its own requests to
- # /dev/null.
- # This means is /has/ to go via nscd to actually resolve any of the
- # additionally configured hosts.
- getent' = pkgs.writeScript "getent-without-etc-hosts" ''
- export NIX_REDIRECTS=/etc/hosts=/dev/null:/etc/nsswitch.conf=/dev/null
- export LD_PRELOAD=${pkgs.libredirect}/lib/libredirect.so
- exec getent $@
- '';
- in
- {
- name = "nscd";
+{ pkgs, ... }:
+let
+ # build a getent that itself doesn't see anything in /etc/hosts and
+ # /etc/nsswitch.conf, by using libredirect to steer its own requests to
+ # /dev/null.
+ # This means is /has/ to go via nscd to actually resolve any of the
+ # additionally configured hosts.
+ getent' = pkgs.writeScript "getent-without-etc-hosts" ''
+ export NIX_REDIRECTS=/etc/hosts=/dev/null:/etc/nsswitch.conf=/dev/null
+ export LD_PRELOAD=${pkgs.libredirect}/lib/libredirect.so
+ exec getent $@
+ '';
+in
+{
+ name = "nscd";
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ common/user-account.nix ];
- networking.extraHosts = ''
- 2001:db8::1 somehost.test
- 192.0.2.1 somehost.test
- '';
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ common/user-account.nix ];
+ networking.extraHosts = ''
+ 2001:db8::1 somehost.test
+ 192.0.2.1 somehost.test
+ '';
- systemd.services.sockdump = {
- wantedBy = [ "multi-user.target" ];
- path = [
- # necessary for bcc to unpack kernel headers and invoke modprobe
- pkgs.gnutar
- pkgs.xz.bin
- pkgs.kmod
- ];
- environment.PYTHONUNBUFFERED = "1";
+ systemd.services.sockdump = {
+ wantedBy = [ "multi-user.target" ];
+ path = [
+ # necessary for bcc to unpack kernel headers and invoke modprobe
+ pkgs.gnutar
+ pkgs.xz.bin
+ pkgs.kmod
+ ];
+ environment.PYTHONUNBUFFERED = "1";
- serviceConfig = {
- ExecStart = "${pkgs.sockdump}/bin/sockdump /var/run/nscd/socket";
- Restart = "on-failure";
- RestartSec = "1";
- Type = "simple";
- };
- };
-
- specialisation = {
- withGlibcNscd.configuration =
- { ... }:
- {
- services.nscd.enableNsncd = false;
- };
- withUnscd.configuration =
- { ... }:
- {
- services.nscd.enableNsncd = false;
- services.nscd.package = pkgs.unscd;
- };
+ serviceConfig = {
+ ExecStart = "${pkgs.sockdump}/bin/sockdump /var/run/nscd/socket";
+ Restart = "on-failure";
+ RestartSec = "1";
+ Type = "simple";
};
};
- testScript =
- { nodes, ... }:
- let
- specialisations = "${nodes.machine.system.build.toplevel}/specialisation";
- in
- ''
- # Regression test for https://github.com/NixOS/nixpkgs/issues/50273
- def test_dynamic_user():
- with subtest("DynamicUser actually allocates a user"):
- assert "iamatest" in machine.succeed(
- "systemd-run --pty --property=Type=oneshot --property=DynamicUser=yes --property=User=iamatest whoami"
- )
+ specialisation = {
+ withGlibcNscd.configuration =
+ { ... }:
+ {
+ services.nscd.enableNsncd = false;
+ };
+ withUnscd.configuration =
+ { ... }:
+ {
+ services.nscd.enableNsncd = false;
+ services.nscd.package = pkgs.unscd;
+ };
+ };
+ };
- # Test resolution of somehost.test with getent', to make sure we go via
- # nscd protocol
- def test_host_lookups():
- with subtest("host lookups via nscd protocol"):
- # ahosts
- output = machine.succeed("${getent'} ahosts somehost.test")
- assert "192.0.2.1" in output
- assert "2001:db8::1" in output
+ testScript =
+ { nodes, ... }:
+ let
+ specialisations = "${nodes.machine.system.build.toplevel}/specialisation";
+ in
+ ''
+ # Regression test for https://github.com/NixOS/nixpkgs/issues/50273
+ def test_dynamic_user():
+ with subtest("DynamicUser actually allocates a user"):
+ assert "iamatest" in machine.succeed(
+ "systemd-run --pty --property=Type=oneshot --property=DynamicUser=yes --property=User=iamatest whoami"
+ )
- # ahostsv4
- output = machine.succeed("${getent'} ahostsv4 somehost.test")
- assert "192.0.2.1" in output
- assert "2001:db8::1" not in output
+ # Test resolution of somehost.test with getent', to make sure we go via
+ # nscd protocol
+ def test_host_lookups():
+ with subtest("host lookups via nscd protocol"):
+ # ahosts
+ output = machine.succeed("${getent'} ahosts somehost.test")
+ assert "192.0.2.1" in output
+ assert "2001:db8::1" in output
- # ahostsv6
- output = machine.succeed("${getent'} ahostsv6 somehost.test")
- assert "192.0.2.1" not in output
- assert "2001:db8::1" in output
+ # ahostsv4
+ output = machine.succeed("${getent'} ahostsv4 somehost.test")
+ assert "192.0.2.1" in output
+ assert "2001:db8::1" not in output
- # reverse lookups (hosts)
- assert "somehost.test" in machine.succeed("${getent'} hosts 2001:db8::1")
- assert "somehost.test" in machine.succeed("${getent'} hosts 192.0.2.1")
+ # ahostsv6
+ output = machine.succeed("${getent'} ahostsv6 somehost.test")
+ assert "192.0.2.1" not in output
+ assert "2001:db8::1" in output
+
+ # reverse lookups (hosts)
+ assert "somehost.test" in machine.succeed("${getent'} hosts 2001:db8::1")
+ assert "somehost.test" in machine.succeed("${getent'} hosts 192.0.2.1")
- # Test host resolution via nss modules works
- # We rely on nss-myhostname in this case, which resolves *.localhost and
- # _gateway.
- # We don't need to use getent' here, as non-glibc nss modules can only be
- # discovered via nscd.
- def test_nss_myhostname():
- with subtest("nss-myhostname provides hostnames (ahosts)"):
- # ahosts
- output = machine.succeed("getent ahosts foobar.localhost")
- assert "::1" in output
- assert "127.0.0.1" in output
+ # Test host resolution via nss modules works
+ # We rely on nss-myhostname in this case, which resolves *.localhost and
+ # _gateway.
+ # We don't need to use getent' here, as non-glibc nss modules can only be
+ # discovered via nscd.
+ def test_nss_myhostname():
+ with subtest("nss-myhostname provides hostnames (ahosts)"):
+ # ahosts
+ output = machine.succeed("getent ahosts foobar.localhost")
+ assert "::1" in output
+ assert "127.0.0.1" in output
- # ahostsv4
- output = machine.succeed("getent ahostsv4 foobar.localhost")
- assert "::1" not in output
- assert "127.0.0.1" in output
+ # ahostsv4
+ output = machine.succeed("getent ahostsv4 foobar.localhost")
+ assert "::1" not in output
+ assert "127.0.0.1" in output
- # ahostsv6
- output = machine.succeed("getent ahostsv6 foobar.localhost")
- assert "::1" in output
- assert "127.0.0.1" not in output
+ # ahostsv6
+ output = machine.succeed("getent ahostsv6 foobar.localhost")
+ assert "::1" in output
+ assert "127.0.0.1" not in output
- start_all()
- machine.wait_for_unit("default.target")
+ start_all()
+ machine.wait_for_unit("default.target")
- # give sockdump some time to finish attaching.
- machine.sleep(5)
+ # give sockdump some time to finish attaching.
+ machine.sleep(5)
- # Test all tests with glibc-nscd.
- test_dynamic_user()
- test_host_lookups()
- test_nss_myhostname()
+ # Test all tests with glibc-nscd.
+ test_dynamic_user()
+ test_host_lookups()
+ test_nss_myhostname()
- with subtest("glibc-nscd"):
- machine.succeed('${specialisations}/withGlibcNscd/bin/switch-to-configuration test')
- machine.wait_for_unit("default.target")
+ with subtest("glibc-nscd"):
+ machine.succeed('${specialisations}/withGlibcNscd/bin/switch-to-configuration test')
+ machine.wait_for_unit("default.target")
- test_dynamic_user()
- test_host_lookups()
- test_nss_myhostname()
+ test_dynamic_user()
+ test_host_lookups()
+ test_nss_myhostname()
- with subtest("unscd"):
- machine.succeed('${specialisations}/withUnscd/bin/switch-to-configuration test')
- machine.wait_for_unit("default.target")
+ with subtest("unscd"):
+ machine.succeed('${specialisations}/withUnscd/bin/switch-to-configuration test')
+ machine.wait_for_unit("default.target")
- # known to fail, unscd doesn't load external NSS modules
- # test_dynamic_user()
+ # known to fail, unscd doesn't load external NSS modules
+ # test_dynamic_user()
- test_host_lookups()
+ test_host_lookups()
- # known to fail, unscd doesn't load external NSS modules
- # test_nss_myhostname()
- '';
- }
-)
+ # known to fail, unscd doesn't load external NSS modules
+ # test_nss_myhostname()
+ '';
+}
diff --git a/nixos/tests/nsd.nix b/nixos/tests/nsd.nix
index b77e28d80504..747d691a87d6 100644
--- a/nixos/tests/nsd.nix
+++ b/nixos/tests/nsd.nix
@@ -8,129 +8,127 @@ let
environment.systemPackages = [ pkgs.bind ];
};
in
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "nsd";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ aszlig ];
- };
+{ pkgs, ... }:
+{
+ name = "nsd";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ aszlig ];
+ };
- nodes = {
- clientv4 =
- { lib, nodes, ... }:
- {
- imports = [ common ];
- networking.nameservers = lib.mkForce [
- (lib.head nodes.server.config.networking.interfaces.eth1.ipv4.addresses).address
- ];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "192.168.0.2";
- prefixLength = 24;
- }
- ];
- };
+ nodes = {
+ clientv4 =
+ { lib, nodes, ... }:
+ {
+ imports = [ common ];
+ networking.nameservers = lib.mkForce [
+ (lib.head nodes.server.config.networking.interfaces.eth1.ipv4.addresses).address
+ ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "192.168.0.2";
+ prefixLength = 24;
+ }
+ ];
+ };
- clientv6 =
- { lib, nodes, ... }:
- {
- imports = [ common ];
- networking.nameservers = lib.mkForce [
- (lib.head nodes.server.config.networking.interfaces.eth1.ipv6.addresses).address
- ];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "dead:beef::2";
- prefixLength = 24;
- }
- ];
- };
+ clientv6 =
+ { lib, nodes, ... }:
+ {
+ imports = [ common ];
+ networking.nameservers = lib.mkForce [
+ (lib.head nodes.server.config.networking.interfaces.eth1.ipv6.addresses).address
+ ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "dead:beef::2";
+ prefixLength = 24;
+ }
+ ];
+ };
- server =
- { lib, ... }:
- {
- imports = [ common ];
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "192.168.0.1";
- prefixLength = 24;
- }
- ];
- networking.interfaces.eth1.ipv6.addresses = [
- {
- address = "dead:beef::1";
- prefixLength = 64;
- }
- ];
- services.nsd.enable = true;
- services.nsd.rootServer = true;
- services.nsd.interfaces = lib.mkForce [ ];
- services.nsd.keys."tsig.example.com." = {
- algorithm = "hmac-sha256";
- keyFile = pkgs.writeTextFile {
- name = "tsig.example.com.";
- text = "aR3FJA92+bxRSyosadsJ8Aeeav5TngQW/H/EF9veXbc=";
- };
+ server =
+ { lib, ... }:
+ {
+ imports = [ common ];
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "192.168.0.1";
+ prefixLength = 24;
+ }
+ ];
+ networking.interfaces.eth1.ipv6.addresses = [
+ {
+ address = "dead:beef::1";
+ prefixLength = 64;
+ }
+ ];
+ services.nsd.enable = true;
+ services.nsd.rootServer = true;
+ services.nsd.interfaces = lib.mkForce [ ];
+ services.nsd.keys."tsig.example.com." = {
+ algorithm = "hmac-sha256";
+ keyFile = pkgs.writeTextFile {
+ name = "tsig.example.com.";
+ text = "aR3FJA92+bxRSyosadsJ8Aeeav5TngQW/H/EF9veXbc=";
};
- services.nsd.zones."example.com.".data = ''
- @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
- ipv4 A 1.2.3.4
- ipv6 AAAA abcd::eeff
- deleg NS ns.example.com
- ns A 192.168.0.1
- ns AAAA dead:beef::1
- '';
- services.nsd.zones."example.com.".provideXFR = [ "0.0.0.0 tsig.example.com." ];
- services.nsd.zones."deleg.example.com.".data = ''
- @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
- @ A 9.8.7.6
- @ AAAA fedc::bbaa
- '';
- services.nsd.zones.".".data = ''
- @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
- root A 1.8.7.4
- root AAAA acbd::4
- '';
};
- };
+ services.nsd.zones."example.com.".data = ''
+ @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
+ ipv4 A 1.2.3.4
+ ipv6 AAAA abcd::eeff
+ deleg NS ns.example.com
+ ns A 192.168.0.1
+ ns AAAA dead:beef::1
+ '';
+ services.nsd.zones."example.com.".provideXFR = [ "0.0.0.0 tsig.example.com." ];
+ services.nsd.zones."deleg.example.com.".data = ''
+ @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
+ @ A 9.8.7.6
+ @ AAAA fedc::bbaa
+ '';
+ services.nsd.zones.".".data = ''
+ @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
+ root A 1.8.7.4
+ root AAAA acbd::4
+ '';
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- clientv4.wait_for_unit("network.target")
- clientv6.wait_for_unit("network.target")
- server.wait_for_unit("nsd.service")
+ clientv4.wait_for_unit("network.target")
+ clientv6.wait_for_unit("network.target")
+ server.wait_for_unit("nsd.service")
- with subtest("server tsig.example.com."):
- expected_tsig = " secret: \"aR3FJA92+bxRSyosadsJ8Aeeav5TngQW/H/EF9veXbc=\"\n"
- tsig=server.succeed("cat /var/lib/nsd/private/tsig.example.com.")
- assert expected_tsig == tsig, f"Expected /var/lib/nsd/private/tsig.example.com. to contain '{expected_tsig}', but found '{tsig}'"
+ with subtest("server tsig.example.com."):
+ expected_tsig = " secret: \"aR3FJA92+bxRSyosadsJ8Aeeav5TngQW/H/EF9veXbc=\"\n"
+ tsig=server.succeed("cat /var/lib/nsd/private/tsig.example.com.")
+ assert expected_tsig == tsig, f"Expected /var/lib/nsd/private/tsig.example.com. to contain '{expected_tsig}', but found '{tsig}'"
- def assert_host(type, rr, query, expected):
- self = clientv4 if type == 4 else clientv6
- out = self.succeed(f"host -{type} -t {rr} {query}").rstrip()
- self.log(f"output: {out}")
- import re
- assert re.search(
- expected, out
- ), f"DNS IPv{type} query on {query} gave '{out}' instead of '{expected}'"
+ def assert_host(type, rr, query, expected):
+ self = clientv4 if type == 4 else clientv6
+ out = self.succeed(f"host -{type} -t {rr} {query}").rstrip()
+ self.log(f"output: {out}")
+ import re
+ assert re.search(
+ expected, out
+ ), f"DNS IPv{type} query on {query} gave '{out}' instead of '{expected}'"
- for ipv in 4, 6:
- with subtest(f"IPv{ipv}"):
- assert_host(ipv, "a", "example.com", "has no [^ ]+ record")
- assert_host(ipv, "aaaa", "example.com", "has no [^ ]+ record")
+ for ipv in 4, 6:
+ with subtest(f"IPv{ipv}"):
+ assert_host(ipv, "a", "example.com", "has no [^ ]+ record")
+ assert_host(ipv, "aaaa", "example.com", "has no [^ ]+ record")
- assert_host(ipv, "soa", "example.com", "SOA.*?noc\.example\.com")
- assert_host(ipv, "a", "ipv4.example.com", "address 1.2.3.4$")
- assert_host(ipv, "aaaa", "ipv6.example.com", "address abcd::eeff$")
+ assert_host(ipv, "soa", "example.com", "SOA.*?noc\.example\.com")
+ assert_host(ipv, "a", "ipv4.example.com", "address 1.2.3.4$")
+ assert_host(ipv, "aaaa", "ipv6.example.com", "address abcd::eeff$")
- assert_host(ipv, "a", "deleg.example.com", "address 9.8.7.6$")
- assert_host(ipv, "aaaa", "deleg.example.com", "address fedc::bbaa$")
+ assert_host(ipv, "a", "deleg.example.com", "address 9.8.7.6$")
+ assert_host(ipv, "aaaa", "deleg.example.com", "address fedc::bbaa$")
- assert_host(ipv, "a", "root", "address 1.8.7.4$")
- assert_host(ipv, "aaaa", "root", "address acbd::4$")
- '';
- }
-)
+ assert_host(ipv, "a", "root", "address 1.8.7.4$")
+ assert_host(ipv, "aaaa", "root", "address acbd::4$")
+ '';
+}
diff --git a/nixos/tests/ntpd-rs.nix b/nixos/tests/ntpd-rs.nix
index 9459a9f4ac51..050d0a20f57d 100644
--- a/nixos/tests/ntpd-rs.nix
+++ b/nixos/tests/ntpd-rs.nix
@@ -1,77 +1,75 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "ntpd-rs";
+{ lib, ... }:
+{
+ name = "ntpd-rs";
- meta = {
- maintainers = with lib.maintainers; [ fpletz ];
- };
+ meta = {
+ maintainers = with lib.maintainers; [ fpletz ];
+ };
- nodes = {
- client = {
- services.ntpd-rs = {
- enable = true;
- metrics.enable = false;
- useNetworkingTimeServers = false;
- settings = {
- source = [
- {
- mode = "server";
- address = "server";
- }
- ];
- synchronization = {
- minimum-agreeing-sources = 1;
- };
- };
- };
- };
- server = {
- networking.firewall = {
- allowedTCPPorts = [
- 9975
+ nodes = {
+ client = {
+ services.ntpd-rs = {
+ enable = true;
+ metrics.enable = false;
+ useNetworkingTimeServers = false;
+ settings = {
+ source = [
+ {
+ mode = "server";
+ address = "server";
+ }
];
- allowedUDPPorts = [
- 123
- ];
- };
-
- services.ntpd-rs = {
- enable = true;
- metrics.enable = true;
- settings = {
- observability = {
- metrics-exporter-listen = "[::]:9975";
- };
- server = [
- { listen = "[::]:123"; }
- ];
+ synchronization = {
+ minimum-agreeing-sources = 1;
};
};
};
};
+ server = {
+ networking.firewall = {
+ allowedTCPPorts = [
+ 9975
+ ];
+ allowedUDPPorts = [
+ 123
+ ];
+ };
- testScript =
- { nodes, ... }:
- ''
- start_all()
+ services.ntpd-rs = {
+ enable = true;
+ metrics.enable = true;
+ settings = {
+ observability = {
+ metrics-exporter-listen = "[::]:9975";
+ };
+ server = [
+ { listen = "[::]:123"; }
+ ];
+ };
+ };
+ };
+ };
- for machine in (server, client):
- machine.wait_for_unit('multi-user.target')
- machine.succeed('systemctl is-active ntpd-rs.service')
+ testScript =
+ { nodes, ... }:
+ ''
+ start_all()
- client.fail('systemctl is-active ntpd-rs-metrics.service')
- server.succeed('systemctl is-active ntpd-rs-metrics.service')
+ for machine in (server, client):
+ machine.wait_for_unit('multi-user.target')
+ machine.succeed('systemctl is-active ntpd-rs.service')
- server.wait_for_open_port(9975)
- client.succeed('curl http://server:9975/metrics | grep ntp_uptime_seconds')
- server.fail('curl --fail --connect-timeout 2 http://client:9975/metrics | grep ntp_uptime_seconds')
+ client.fail('systemctl is-active ntpd-rs-metrics.service')
+ server.succeed('systemctl is-active ntpd-rs-metrics.service')
- client.succeed("ntp-ctl status | grep server:123")
- server.succeed("ntp-ctl status | grep '\[::\]:123'")
+ server.wait_for_open_port(9975)
+ client.succeed('curl http://server:9975/metrics | grep ntp_uptime_seconds')
+ server.fail('curl --fail --connect-timeout 2 http://client:9975/metrics | grep ntp_uptime_seconds')
- client.succeed("grep '^mode = \"server\"' $(systemctl status ntpd-rs | grep -oE '/nix/store[^ ]*ntpd-rs.toml')")
- server.succeed("grep '^mode = \"pool\"' $(systemctl status ntpd-rs | grep -oE '/nix/store[^ ]*ntpd-rs.toml')")
- '';
- }
-)
+ client.succeed("ntp-ctl status | grep server:123")
+ server.succeed("ntp-ctl status | grep '\[::\]:123'")
+
+ client.succeed("grep '^mode = \"server\"' $(systemctl status ntpd-rs | grep -oE '/nix/store[^ ]*ntpd-rs.toml')")
+ server.succeed("grep '^mode = \"pool\"' $(systemctl status ntpd-rs | grep -oE '/nix/store[^ ]*ntpd-rs.toml')")
+ '';
+}
diff --git a/nixos/tests/ntpd.nix b/nixos/tests/ntpd.nix
index 67a5a95e6fe5..e961cb7614a7 100644
--- a/nixos/tests/ntpd.nix
+++ b/nixos/tests/ntpd.nix
@@ -1,27 +1,25 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "ntpd";
+{ lib, ... }:
+{
+ name = "ntpd";
- meta = {
- maintainers = with lib.maintainers; [ pyrox0 ];
+ meta = {
+ maintainers = with lib.maintainers; [ pyrox0 ];
+ };
+
+ nodes.machine = {
+ services.ntp = {
+ enable = true;
};
+ };
- nodes.machine = {
- services.ntp = {
- enable = true;
- };
- };
+ testScript = ''
+ start_all()
- testScript = ''
- start_all()
-
- machine.wait_for_unit('ntpd.service')
- machine.wait_for_console_text('Listen normally on 10 eth*')
- machine.succeed('systemctl is-active ntpd.service')
- machine.succeed('ntpq -p')
- # ntp user must be able to create drift files
- machine.succeed('su -s /bin/sh -c "touch /var/lib/ntp/ntp.drift" ntp')
- '';
- }
-)
+ machine.wait_for_unit('ntpd.service')
+ machine.wait_for_console_text('Listen normally on 10 eth*')
+ machine.succeed('systemctl is-active ntpd.service')
+ machine.succeed('ntpq -p')
+ # ntp user must be able to create drift files
+ machine.succeed('su -s /bin/sh -c "touch /var/lib/ntp/ntp.drift" ntp')
+ '';
+}
diff --git a/nixos/tests/nvmetcfg.nix b/nixos/tests/nvmetcfg.nix
index 6f937251bb35..4720ac754378 100644
--- a/nixos/tests/nvmetcfg.nix
+++ b/nixos/tests/nvmetcfg.nix
@@ -1,54 +1,52 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "nvmetcfg";
+{ lib, ... }:
+{
+ name = "nvmetcfg";
- meta = {
- maintainers = with lib.maintainers; [ nickcao ];
- };
+ meta = {
+ maintainers = with lib.maintainers; [ nickcao ];
+ };
- nodes = {
- server =
- { pkgs, ... }:
- {
- boot.kernelModules = [ "nvmet" ];
- environment.systemPackages = [ pkgs.nvmetcfg ];
- networking.firewall.allowedTCPPorts = [ 4420 ];
- virtualisation.emptyDiskImages = [ 512 ];
- };
- client =
- { pkgs, ... }:
- {
- boot.kernelModules = [ "nvme-fabrics" ];
- environment.systemPackages = [ pkgs.nvme-cli ];
- };
- };
+ nodes = {
+ server =
+ { pkgs, ... }:
+ {
+ boot.kernelModules = [ "nvmet" ];
+ environment.systemPackages = [ pkgs.nvmetcfg ];
+ networking.firewall.allowedTCPPorts = [ 4420 ];
+ virtualisation.emptyDiskImages = [ 512 ];
+ };
+ client =
+ { pkgs, ... }:
+ {
+ boot.kernelModules = [ "nvme-fabrics" ];
+ environment.systemPackages = [ pkgs.nvme-cli ];
+ };
+ };
- testScript =
- let
- subsystem = "nqn.2014-08.org.nixos:server";
- in
- ''
- import json
+ testScript =
+ let
+ subsystem = "nqn.2014-08.org.nixos:server";
+ in
+ ''
+ import json
- with subtest("Create subsystem and namespace"):
- server.succeed("nvmet subsystem add ${subsystem}")
- server.succeed("nvmet namespace add ${subsystem} 1 /dev/vdb")
+ with subtest("Create subsystem and namespace"):
+ server.succeed("nvmet subsystem add ${subsystem}")
+ server.succeed("nvmet namespace add ${subsystem} 1 /dev/vdb")
- with subtest("Bind subsystem to port"):
- server.wait_for_unit("network-online.target")
- server.succeed("nvmet port add 1 tcp [::]:4420")
- server.succeed("nvmet port add-subsystem 1 ${subsystem}")
+ with subtest("Bind subsystem to port"):
+ server.wait_for_unit("network-online.target")
+ server.succeed("nvmet port add 1 tcp [::]:4420")
+ server.succeed("nvmet port add-subsystem 1 ${subsystem}")
- with subtest("Discover and connect to available subsystems"):
- client.wait_for_unit("network-online.target")
- assert "subnqn: ${subsystem}" in client.succeed("nvme discover --transport=tcp --traddr=server --trsvcid=4420")
- client.succeed("nvme connect-all --transport=tcp --traddr=server --trsvcid=4420")
+ with subtest("Discover and connect to available subsystems"):
+ client.wait_for_unit("network-online.target")
+ assert "subnqn: ${subsystem}" in client.succeed("nvme discover --transport=tcp --traddr=server --trsvcid=4420")
+ client.succeed("nvme connect-all --transport=tcp --traddr=server --trsvcid=4420")
- with subtest("Write to the connected subsystem"):
- devices = json.loads(client.succeed("lsblk --nvme --paths --json"))["blockdevices"]
- assert len(devices) == 1
- client.succeed(f"dd if=/dev/zero of={devices[0]['name']} bs=1M count=64")
- '';
- }
-)
+ with subtest("Write to the connected subsystem"):
+ devices = json.loads(client.succeed("lsblk --nvme --paths --json"))["blockdevices"]
+ assert len(devices) == 1
+ client.succeed(f"dd if=/dev/zero of={devices[0]['name']} bs=1M count=64")
+ '';
+}
diff --git a/nixos/tests/nzbget.nix b/nixos/tests/nzbget.nix
index 0fd80c6d554a..3b5ee0ce0c43 100644
--- a/nixos/tests/nzbget.nix
+++ b/nixos/tests/nzbget.nix
@@ -1,56 +1,54 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "nzbget";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- aanderse
- flokli
- ];
- };
+{ pkgs, ... }:
+{
+ name = "nzbget";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ aanderse
+ flokli
+ ];
+ };
- nodes = {
- server =
- { ... }:
- {
- services.nzbget.enable = true;
+ nodes = {
+ server =
+ { ... }:
+ {
+ services.nzbget.enable = true;
- # provide some test settings
- services.nzbget.settings = {
- "MainDir" = "/var/lib/nzbget";
- "DirectRename" = true;
- "DiskSpace" = 0;
- "Server1.Name" = "this is a test";
- };
-
- # hack, don't add (unfree) unrar to nzbget's path,
- # so we can run this test in CI
- systemd.services.nzbget.path = pkgs.lib.mkForce [ pkgs.p7zip ];
+ # provide some test settings
+ services.nzbget.settings = {
+ "MainDir" = "/var/lib/nzbget";
+ "DirectRename" = true;
+ "DiskSpace" = 0;
+ "Server1.Name" = "this is a test";
};
- };
- testScript =
- { nodes, ... }:
- ''
- start_all()
+ # hack, don't add (unfree) unrar to nzbget's path,
+ # so we can run this test in CI
+ systemd.services.nzbget.path = pkgs.lib.mkForce [ pkgs.p7zip ];
+ };
+ };
- server.wait_for_unit("nzbget.service")
- server.wait_for_unit("network.target")
- server.wait_for_open_port(6789)
- assert "This file is part of nzbget" in server.succeed(
- "curl -f -s -u nzbget:tegbzn6789 http://127.0.0.1:6789"
- )
- server.succeed(
- "${pkgs.nzbget}/bin/nzbget -n -o Control_iP=127.0.0.1 -o Control_port=6789 -o Control_password=tegbzn6789 -V"
- )
+ testScript =
+ { nodes, ... }:
+ ''
+ start_all()
- config = server.succeed("${nodes.server.systemd.services.nzbget.serviceConfig.ExecStart} --printconfig")
+ server.wait_for_unit("nzbget.service")
+ server.wait_for_unit("network.target")
+ server.wait_for_open_port(6789)
+ assert "This file is part of nzbget" in server.succeed(
+ "curl -f -s -u nzbget:tegbzn6789 http://127.0.0.1:6789"
+ )
+ server.succeed(
+ "${pkgs.nzbget}/bin/nzbget -n -o Control_iP=127.0.0.1 -o Control_port=6789 -o Control_password=tegbzn6789 -V"
+ )
- # confirm the test settings are applied
- assert 'MainDir = "/var/lib/nzbget"' in config
- assert 'DirectRename = "yes"' in config
- assert 'DiskSpace = "0"' in config
- assert 'Server1.Name = "this is a test"' in config
- '';
- }
-)
+ config = server.succeed("${nodes.server.systemd.services.nzbget.serviceConfig.ExecStart} --printconfig")
+
+ # confirm the test settings are applied
+ assert 'MainDir = "/var/lib/nzbget"' in config
+ assert 'DirectRename = "yes"' in config
+ assert 'DiskSpace = "0"' in config
+ assert 'Server1.Name = "this is a test"' in config
+ '';
+}
diff --git a/nixos/tests/nzbhydra2.nix b/nixos/tests/nzbhydra2.nix
index 9f6f2e98423a..b446d8236977 100644
--- a/nixos/tests/nzbhydra2.nix
+++ b/nixos/tests/nzbhydra2.nix
@@ -1,20 +1,18 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "nzbhydra2";
- meta.maintainers = with lib.maintainers; [ matteopacini ];
+{ lib, ... }:
+{
+ name = "nzbhydra2";
+ meta.maintainers = with lib.maintainers; [ matteopacini ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.nzbhydra2.enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.nzbhydra2.enable = true;
+ };
- testScript = ''
- machine.start()
- machine.wait_for_unit("nzbhydra2.service")
- machine.wait_for_open_port(5076)
- machine.succeed("curl --fail http://localhost:5076/")
- '';
- }
-)
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("nzbhydra2.service")
+ machine.wait_for_open_port(5076)
+ machine.succeed("curl --fail http://localhost:5076/")
+ '';
+}
diff --git a/nixos/tests/ocis.nix b/nixos/tests/ocis.nix
index a529b4385663..275a13799035 100644
--- a/nixos/tests/ocis.nix
+++ b/nixos/tests/ocis.nix
@@ -1,217 +1,215 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- let
- # this is a demo user created by IDM_CREATE_DEMO_USERS=true
- demoUser = "einstein";
- demoPassword = "relativity";
+let
+ # this is a demo user created by IDM_CREATE_DEMO_USERS=true
+ demoUser = "einstein";
+ demoPassword = "relativity";
- adminUser = "admin";
- adminPassword = "hunter2";
- testRunner =
- pkgs.writers.writePython3Bin "test-runner"
- {
- libraries = [ pkgs.python3Packages.selenium ];
- flakeIgnore = [ "E501" ];
- }
- ''
- import sys
- from selenium.webdriver.common.by import By
- from selenium.webdriver import Firefox
- from selenium.webdriver.firefox.options import Options
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
+ adminUser = "admin";
+ adminPassword = "hunter2";
+ testRunner =
+ pkgs.writers.writePython3Bin "test-runner"
+ {
+ libraries = [ pkgs.python3Packages.selenium ];
+ flakeIgnore = [ "E501" ];
+ }
+ ''
+ import sys
+ from selenium.webdriver.common.by import By
+ from selenium.webdriver import Firefox
+ from selenium.webdriver.firefox.options import Options
+ from selenium.webdriver.support.ui import WebDriverWait
+ from selenium.webdriver.support import expected_conditions as EC
- options = Options()
- options.add_argument('--headless')
- driver = Firefox(options=options)
+ options = Options()
+ options.add_argument('--headless')
+ driver = Firefox(options=options)
- user = sys.argv[1]
- password = sys.argv[2]
- driver.implicitly_wait(20)
- driver.get('https://localhost:9200/login')
- wait = WebDriverWait(driver, 10)
- wait.until(EC.title_contains("Sign in"))
- driver.find_element(By.XPATH, '//*[@id="oc-login-username"]').send_keys(user)
- driver.find_element(By.XPATH, '//*[@id="oc-login-password"]').send_keys(password)
- driver.find_element(By.XPATH, '//*[@id="root"]//button').click()
- wait.until(EC.title_contains("Personal"))
- '';
+ user = sys.argv[1]
+ password = sys.argv[2]
+ driver.implicitly_wait(20)
+ driver.get('https://localhost:9200/login')
+ wait = WebDriverWait(driver, 10)
+ wait.until(EC.title_contains("Sign in"))
+ driver.find_element(By.XPATH, '//*[@id="oc-login-username"]').send_keys(user)
+ driver.find_element(By.XPATH, '//*[@id="oc-login-password"]').send_keys(password)
+ driver.find_element(By.XPATH, '//*[@id="root"]//button').click()
+ wait.until(EC.title_contains("Personal"))
+ '';
- # This was generated with `ocis init --config-path testconfig/ --admin-password "hunter2" --insecure true`.
- testConfig = ''
- token_manager:
- jwt_secret: kaKYgfso*d9GA-yTM.&BTOUEuMz%Ai0H
- machine_auth_api_key: sGWRG1JZ&qe&pe@N1HKK4#qH*B&@xLnO
- system_user_api_key: h+m4aHPUtOtUJFKrc5B2=04C=7fDZaT-
- transfer_secret: 4-R6AfUjQn0P&+h2+$skf0lJqmre$j=x
- system_user_id: db180e0a-b38a-4edf-a4cd-a3d358248537
- admin_user_id: ea623f50-742d-4fd0-95bb-c61767b070d4
- graph:
- application:
- id: 11971eab-d560-4b95-a2d4-50726676bbd0
- events:
- tls_insecure: true
- spaces:
- insecure: true
- identity:
- ldap:
- bind_password: ^F&Vn7@mYGYGuxr$#qm^gGy@FVq=.w=y
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
- idp:
+ # This was generated with `ocis init --config-path testconfig/ --admin-password "hunter2" --insecure true`.
+ testConfig = ''
+ token_manager:
+ jwt_secret: kaKYgfso*d9GA-yTM.&BTOUEuMz%Ai0H
+ machine_auth_api_key: sGWRG1JZ&qe&pe@N1HKK4#qH*B&@xLnO
+ system_user_api_key: h+m4aHPUtOtUJFKrc5B2=04C=7fDZaT-
+ transfer_secret: 4-R6AfUjQn0P&+h2+$skf0lJqmre$j=x
+ system_user_id: db180e0a-b38a-4edf-a4cd-a3d358248537
+ admin_user_id: ea623f50-742d-4fd0-95bb-c61767b070d4
+ graph:
+ application:
+ id: 11971eab-d560-4b95-a2d4-50726676bbd0
+ events:
+ tls_insecure: true
+ spaces:
+ insecure: true
+ identity:
ldap:
- bind_password: bv53IjS28x.nxth*%aRbE70%4TGNXbLU
- idm:
- service_user_passwords:
- admin_password: hunter2
- idm_password: ^F&Vn7@mYGYGuxr$#qm^gGy@FVq=.w=y
- reva_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
- idp_password: bv53IjS28x.nxth*%aRbE70%4TGNXbLU
- proxy:
+ bind_password: ^F&Vn7@mYGYGuxr$#qm^gGy@FVq=.w=y
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ idp:
+ ldap:
+ bind_password: bv53IjS28x.nxth*%aRbE70%4TGNXbLU
+ idm:
+ service_user_passwords:
+ admin_password: hunter2
+ idm_password: ^F&Vn7@mYGYGuxr$#qm^gGy@FVq=.w=y
+ reva_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
+ idp_password: bv53IjS28x.nxth*%aRbE70%4TGNXbLU
+ proxy:
+ oidc:
+ insecure: true
+ insecure_backends: true
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ frontend:
+ app_handler:
+ insecure: true
+ archiver:
+ insecure: true
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ auth_basic:
+ auth_providers:
+ ldap:
+ bind_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
+ auth_bearer:
+ auth_providers:
oidc:
insecure: true
- insecure_backends: true
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
- frontend:
- app_handler:
- insecure: true
- archiver:
- insecure: true
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
- auth_basic:
- auth_providers:
- ldap:
- bind_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
- auth_bearer:
- auth_providers:
- oidc:
- insecure: true
- users:
- drivers:
- ldap:
- bind_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
- groups:
- drivers:
- ldap:
- bind_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
- ocdav:
- insecure: true
- ocm:
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
- thumbnails:
- thumbnail:
- transfer_secret: 2%11!zAu*AYE&=d*8dfoZs8jK&5ZMm*%
- webdav_allow_insecure: true
- cs3_allow_insecure: true
- search:
- events:
- tls_insecure: true
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
- audit:
- events:
- tls_insecure: true
- settings:
- service_account_ids:
- - df39a290-3f3e-4e39-b67b-8b810ca2abac
- sharing:
- events:
- tls_insecure: true
- storage_users:
- events:
- tls_insecure: true
- mount_id: ef72cb8b-809c-4592-bfd2-1df603295205
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ users:
+ drivers:
+ ldap:
+ bind_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
+ groups:
+ drivers:
+ ldap:
+ bind_password: z-%@fWipLliR8lD#fl.0teC#9QbhJ^eb
+ ocdav:
+ insecure: true
+ ocm:
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ thumbnails:
+ thumbnail:
+ transfer_secret: 2%11!zAu*AYE&=d*8dfoZs8jK&5ZMm*%
+ webdav_allow_insecure: true
+ cs3_allow_insecure: true
+ search:
+ events:
+ tls_insecure: true
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ audit:
+ events:
+ tls_insecure: true
+ settings:
+ service_account_ids:
+ - df39a290-3f3e-4e39-b67b-8b810ca2abac
+ sharing:
+ events:
+ tls_insecure: true
+ storage_users:
+ events:
+ tls_insecure: true
+ mount_id: ef72cb8b-809c-4592-bfd2-1df603295205
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ notifications:
notifications:
- notifications:
- events:
- tls_insecure: true
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ events:
+ tls_insecure: true
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ nats:
nats:
- nats:
- tls_skip_verify_client_cert: true
- gateway:
- storage_registry:
- storage_users_mount_id: ef72cb8b-809c-4592-bfd2-1df603295205
- userlog:
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
- auth_service:
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
- clientlog:
- service_account:
- service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
- service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE'';
- in
+ tls_skip_verify_client_cert: true
+ gateway:
+ storage_registry:
+ storage_users_mount_id: ef72cb8b-809c-4592-bfd2-1df603295205
+ userlog:
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ auth_service:
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE
+ clientlog:
+ service_account:
+ service_account_id: df39a290-3f3e-4e39-b67b-8b810ca2abac
+ service_account_secret: .demKypQ$=pGl+yRar!#YaFjLYCr4YwE'';
+in
- {
- name = "ocis";
+{
+ name = "ocis";
- meta.maintainers = with lib.maintainers; [
- bhankas
- ramblurr
- ];
+ meta.maintainers = with lib.maintainers; [
+ bhankas
+ ramblurr
+ ];
- nodes.machine =
- { config, ... }:
- {
- virtualisation.memorySize = 2048;
- environment.systemPackages = [
- pkgs.firefox-unwrapped
- pkgs.geckodriver
- testRunner
- ];
+ nodes.machine =
+ { config, ... }:
+ {
+ virtualisation.memorySize = 2048;
+ environment.systemPackages = [
+ pkgs.firefox-unwrapped
+ pkgs.geckodriver
+ testRunner
+ ];
- # if you do this in production, dont put secrets in this file because it will be written to the world readable nix store
- environment.etc."ocis/ocis.env".text = ''
- ADMIN_PASSWORD=${adminPassword}
- IDM_CREATE_DEMO_USERS=true
- '';
+ # if you do this in production, dont put secrets in this file because it will be written to the world readable nix store
+ environment.etc."ocis/ocis.env".text = ''
+ ADMIN_PASSWORD=${adminPassword}
+ IDM_CREATE_DEMO_USERS=true
+ '';
- # if you do this in production, dont put secrets in this file because it will be written to the world readable nix store
- environment.etc."ocis/config/ocis.yaml".text = testConfig;
+ # if you do this in production, dont put secrets in this file because it will be written to the world readable nix store
+ environment.etc."ocis/config/ocis.yaml".text = testConfig;
- services.ocis = {
- enable = true;
- configDir = "/etc/ocis/config";
- environment = {
- OCIS_INSECURE = "true";
- };
- environmentFile = "/etc/ocis/ocis.env";
+ services.ocis = {
+ enable = true;
+ configDir = "/etc/ocis/config";
+ environment = {
+ OCIS_INSECURE = "true";
};
+ environmentFile = "/etc/ocis/ocis.env";
};
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("ocis.service")
- machine.wait_for_open_port(9200)
- # wait for ocis to fully come up
- machine.sleep(5)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("ocis.service")
+ machine.wait_for_open_port(9200)
+ # wait for ocis to fully come up
+ machine.sleep(5)
- with subtest("ocis bin works"):
- machine.succeed("${lib.getExe pkgs.ocis_5-bin} version")
+ with subtest("ocis bin works"):
+ machine.succeed("${lib.getExe pkgs.ocis_5-bin} version")
- with subtest("use the web interface to log in with a demo user"):
- machine.succeed("PYTHONUNBUFFERED=1 systemd-cat -t test-runner test-runner ${demoUser} ${demoPassword}")
+ with subtest("use the web interface to log in with a demo user"):
+ machine.succeed("PYTHONUNBUFFERED=1 systemd-cat -t test-runner test-runner ${demoUser} ${demoPassword}")
- with subtest("use the web interface to log in with the provisioned admin user"):
- machine.succeed("PYTHONUNBUFFERED=1 systemd-cat -t test-runner test-runner ${adminUser} ${adminPassword}")
- '';
- }
-)
+ with subtest("use the web interface to log in with the provisioned admin user"):
+ machine.succeed("PYTHONUNBUFFERED=1 systemd-cat -t test-runner test-runner ${adminUser} ${adminPassword}")
+ '';
+}
diff --git a/nixos/tests/octoprint.nix b/nixos/tests/octoprint.nix
index 9473797d5047..805b7c764b61 100644
--- a/nixos/tests/octoprint.nix
+++ b/nixos/tests/octoprint.nix
@@ -1,69 +1,67 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- apikey = "testapikey";
- in
- {
- name = "octoprint";
- meta.maintainers = with lib.maintainers; [ gador ];
+let
+ apikey = "testapikey";
+in
+{
+ name = "octoprint";
+ meta.maintainers = with lib.maintainers; [ gador ];
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [ jq ];
- services.octoprint = {
- enable = true;
- extraConfig = {
- server = {
- firstRun = false;
- };
- api = {
- enabled = true;
- key = apikey;
- };
- plugins = {
- # these need internet access and pollute the output with connection failed errors
- _disabled = [
- "softwareupdate"
- "announcements"
- "pluginmanager"
- ];
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [ jq ];
+ services.octoprint = {
+ enable = true;
+ extraConfig = {
+ server = {
+ firstRun = false;
+ };
+ api = {
+ enabled = true;
+ key = apikey;
+ };
+ plugins = {
+ # these need internet access and pollute the output with connection failed errors
+ _disabled = [
+ "softwareupdate"
+ "announcements"
+ "pluginmanager"
+ ];
};
};
};
+ };
- testScript = ''
- import json
+ testScript = ''
+ import json
- @polling_condition
- def octoprint_running():
- machine.succeed("pgrep octoprint")
+ @polling_condition
+ def octoprint_running():
+ machine.succeed("pgrep octoprint")
- with subtest("Wait for octoprint service to start"):
- machine.wait_for_unit("octoprint.service")
- machine.wait_until_succeeds("pgrep octoprint")
+ with subtest("Wait for octoprint service to start"):
+ machine.wait_for_unit("octoprint.service")
+ machine.wait_until_succeeds("pgrep octoprint")
- with subtest("Wait for final boot"):
- # this appears whe octoprint is almost finished starting
- machine.wait_for_file("/var/lib/octoprint/uploads")
+ with subtest("Wait for final boot"):
+ # this appears whe octoprint is almost finished starting
+ machine.wait_for_file("/var/lib/octoprint/uploads")
- # octoprint takes some time to start. This makes sure we'll retry just in case it takes longer
- # retry-all-errors in necessary, since octoprint will report a 404 error when not yet ready
- curl_cmd = "curl --retry-all-errors --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 0 \
- --retry-max-time 40 -X GET --header 'X-API-Key: ${apikey}' "
+ # octoprint takes some time to start. This makes sure we'll retry just in case it takes longer
+ # retry-all-errors in necessary, since octoprint will report a 404 error when not yet ready
+ curl_cmd = "curl --retry-all-errors --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 0 \
+ --retry-max-time 40 -X GET --header 'X-API-Key: ${apikey}' "
- # used to fail early, in case octoprint first starts and then crashes
- with octoprint_running: # type: ignore[union-attr]
- with subtest("Check for web interface"):
- machine.wait_until_succeeds("curl -s localhost:5000")
+ # used to fail early, in case octoprint first starts and then crashes
+ with octoprint_running: # type: ignore[union-attr]
+ with subtest("Check for web interface"):
+ machine.wait_until_succeeds("curl -s localhost:5000")
- with subtest("Check API"):
- version = json.loads(machine.succeed(curl_cmd + "localhost:5000/api/version"))
- server = json.loads(machine.succeed(curl_cmd + "localhost:5000/api/server"))
- assert version["server"] == str("${pkgs.octoprint.version}")
- assert server["safemode"] == None
- '';
- }
-)
+ with subtest("Check API"):
+ version = json.loads(machine.succeed(curl_cmd + "localhost:5000/api/version"))
+ server = json.loads(machine.succeed(curl_cmd + "localhost:5000/api/server"))
+ assert version["server"] == str("${pkgs.octoprint.version}")
+ assert server["safemode"] == None
+ '';
+}
diff --git a/nixos/tests/odoo.nix b/nixos/tests/odoo.nix
index 54120b234364..7749fec7f3d9 100644
--- a/nixos/tests/odoo.nix
+++ b/nixos/tests/odoo.nix
@@ -1,39 +1,37 @@
-import ./make-test-python.nix (
- {
- pkgs,
- lib,
- package ? pkgs.odoo,
- ...
- }:
- {
- name = "odoo";
- meta.maintainers = with lib.maintainers; [ mkg20001 ];
+{
+ pkgs,
+ lib,
+ package ? pkgs.odoo,
+ ...
+}:
+{
+ name = "odoo";
+ meta.maintainers = with lib.maintainers; [ mkg20001 ];
- nodes = {
- server =
- { ... }:
- {
- services.nginx = {
- enable = true;
- recommendedProxySettings = true;
- };
-
- services.odoo = {
- enable = true;
- package = package;
- autoInit = true;
- autoInitExtraFlags = [ "--without-demo=all" ];
- domain = "localhost";
- };
+ nodes = {
+ server =
+ { ... }:
+ {
+ services.nginx = {
+ enable = true;
+ recommendedProxySettings = true;
};
- };
- testScript =
- { nodes, ... }:
- ''
- server.wait_for_unit("odoo.service")
- server.wait_until_succeeds("curl -s http://localhost:8069/web/database/selector | grep 'Odoo'")
- server.succeed("curl -s http://localhost/web/database/selector | grep 'Odoo'")
- '';
- }
-)
+ services.odoo = {
+ enable = true;
+ package = package;
+ autoInit = true;
+ autoInitExtraFlags = [ "--without-demo=all" ];
+ domain = "localhost";
+ };
+ };
+ };
+
+ testScript =
+ { nodes, ... }:
+ ''
+ server.wait_for_unit("odoo.service")
+ server.wait_until_succeeds("curl -s http://localhost:8069/web/database/selector | grep 'Odoo'")
+ server.succeed("curl -s http://localhost/web/database/selector | grep 'Odoo'")
+ '';
+}
diff --git a/nixos/tests/oh-my-zsh.nix b/nixos/tests/oh-my-zsh.nix
index 25c4e8ebfe97..026e8628c11c 100644
--- a/nixos/tests/oh-my-zsh.nix
+++ b/nixos/tests/oh-my-zsh.nix
@@ -1,22 +1,20 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "oh-my-zsh";
+{ pkgs, ... }:
+{
+ name = "oh-my-zsh";
- nodes.machine =
- { pkgs, ... }:
+ nodes.machine =
+ { pkgs, ... }:
- {
- programs.zsh = {
- enable = true;
- ohMyZsh.enable = true;
- };
+ {
+ programs.zsh = {
+ enable = true;
+ ohMyZsh.enable = true;
};
+ };
- testScript = ''
- start_all()
- machine.succeed("touch ~/.zshrc")
- machine.succeed("zsh -c 'source /etc/zshrc && echo $ZSH | grep oh-my-zsh-${pkgs.oh-my-zsh.version}'")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.succeed("touch ~/.zshrc")
+ machine.succeed("zsh -c 'source /etc/zshrc && echo $ZSH | grep oh-my-zsh-${pkgs.oh-my-zsh.version}'")
+ '';
+}
diff --git a/nixos/tests/ombi.nix b/nixos/tests/ombi.nix
index eeeaba5e2d0e..6d77aa3c5b70 100644
--- a/nixos/tests/ombi.nix
+++ b/nixos/tests/ombi.nix
@@ -1,20 +1,18 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "ombi";
- meta.maintainers = with lib.maintainers; [ woky ];
+{
+ name = "ombi";
+ meta.maintainers = with lib.maintainers; [ woky ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.ombi.enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.ombi.enable = true;
+ };
- testScript = ''
- machine.wait_for_unit("ombi.service")
- machine.wait_for_open_port(5000)
- machine.succeed("curl --fail http://localhost:5000/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("ombi.service")
+ machine.wait_for_open_port(5000)
+ machine.succeed("curl --fail http://localhost:5000/")
+ '';
+}
diff --git a/nixos/tests/openarena.nix b/nixos/tests/openarena.nix
index 6ac38729d3f1..2d514bac4c73 100644
--- a/nixos/tests/openarena.nix
+++ b/nixos/tests/openarena.nix
@@ -1,79 +1,77 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- client =
- { pkgs, ... }:
+let
+ client =
+ { pkgs, ... }:
- {
- imports = [ ./common/x11.nix ];
- hardware.graphics.enable = true;
- environment.systemPackages = [ pkgs.openarena ];
- };
-
- in
- {
- name = "openarena";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fpletz ];
+ {
+ imports = [ ./common/x11.nix ];
+ hardware.graphics.enable = true;
+ environment.systemPackages = [ pkgs.openarena ];
};
- nodes = {
- server = {
- services.openarena = {
- enable = true;
- extraFlags = [
- "+set g_gametype 0"
- "+map oa_dm7"
- "+addbot Angelyss"
- "+addbot Arachna"
- ];
- openPorts = true;
- };
- };
+in
+{
+ name = "openarena";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fpletz ];
+ };
- client1 = client;
- client2 = client;
+ nodes = {
+ server = {
+ services.openarena = {
+ enable = true;
+ extraFlags = [
+ "+set g_gametype 0"
+ "+map oa_dm7"
+ "+addbot Angelyss"
+ "+addbot Arachna"
+ ];
+ openPorts = true;
+ };
};
- testScript = ''
- start_all()
+ client1 = client;
+ client2 = client;
+ };
- server.wait_for_unit("openarena")
- server.wait_until_succeeds("ss --numeric --udp --listening | grep -q 27960")
+ testScript = ''
+ start_all()
- client1.wait_for_x()
- client2.wait_for_x()
+ server.wait_for_unit("openarena")
+ server.wait_until_succeeds("ss --numeric --udp --listening | grep -q 27960")
- client1.execute("openarena +set r_fullscreen 0 +set name Foo +connect server >&2 &")
- client2.execute("openarena +set r_fullscreen 0 +set name Bar +connect server >&2 &")
+ client1.wait_for_x()
+ client2.wait_for_x()
- server.wait_until_succeeds(
- "journalctl -u openarena -e | grep -q 'Foo.*entered the game'"
- )
- server.wait_until_succeeds(
- "journalctl -u openarena -e | grep -q 'Bar.*entered the game'"
- )
+ client1.execute("openarena +set r_fullscreen 0 +set name Foo +connect server >&2 &")
+ client2.execute("openarena +set r_fullscreen 0 +set name Bar +connect server >&2 &")
- server.sleep(10) # wait for a while to get a nice screenshot
+ server.wait_until_succeeds(
+ "journalctl -u openarena -e | grep -q 'Foo.*entered the game'"
+ )
+ server.wait_until_succeeds(
+ "journalctl -u openarena -e | grep -q 'Bar.*entered the game'"
+ )
- client1.screenshot("screen_client1_1")
- client2.screenshot("screen_client2_1")
+ server.sleep(10) # wait for a while to get a nice screenshot
- client1.block()
+ client1.screenshot("screen_client1_1")
+ client2.screenshot("screen_client2_1")
- server.sleep(10)
+ client1.block()
- client1.screenshot("screen_client1_2")
- client2.screenshot("screen_client2_2")
+ server.sleep(10)
- client1.unblock()
+ client1.screenshot("screen_client1_2")
+ client2.screenshot("screen_client2_2")
- server.sleep(10)
+ client1.unblock()
- client1.screenshot("screen_client1_3")
- client2.screenshot("screen_client2_3")
- '';
+ server.sleep(10)
- }
-)
+ client1.screenshot("screen_client1_3")
+ client2.screenshot("screen_client2_3")
+ '';
+
+}
diff --git a/nixos/tests/openldap.nix b/nixos/tests/openldap.nix
index f66aaec78048..49af853cb9a3 100644
--- a/nixos/tests/openldap.nix
+++ b/nixos/tests/openldap.nix
@@ -1,177 +1,175 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- dbContents = ''
- dn: dc=example
- objectClass: domain
- dc: example
+{ pkgs, ... }:
+let
+ dbContents = ''
+ dn: dc=example
+ objectClass: domain
+ dc: example
- dn: ou=users,dc=example
- objectClass: organizationalUnit
- ou: users
- '';
+ dn: ou=users,dc=example
+ objectClass: organizationalUnit
+ ou: users
+ '';
- ldifConfig = ''
- dn: cn=config
- cn: config
- objectClass: olcGlobal
- olcLogLevel: stats
+ ldifConfig = ''
+ dn: cn=config
+ cn: config
+ objectClass: olcGlobal
+ olcLogLevel: stats
- dn: cn=schema,cn=config
- cn: schema
- objectClass: olcSchemaConfig
+ dn: cn=schema,cn=config
+ cn: schema
+ objectClass: olcSchemaConfig
- include: file://${pkgs.openldap}/etc/schema/core.ldif
- include: file://${pkgs.openldap}/etc/schema/cosine.ldif
- include: file://${pkgs.openldap}/etc/schema/inetorgperson.ldif
+ include: file://${pkgs.openldap}/etc/schema/core.ldif
+ include: file://${pkgs.openldap}/etc/schema/cosine.ldif
+ include: file://${pkgs.openldap}/etc/schema/inetorgperson.ldif
- dn: olcDatabase={0}config,cn=config
- olcDatabase: {0}config
- objectClass: olcDatabaseConfig
- olcRootDN: cn=root,cn=config
- olcRootPW: configpassword
+ dn: olcDatabase={0}config,cn=config
+ olcDatabase: {0}config
+ objectClass: olcDatabaseConfig
+ olcRootDN: cn=root,cn=config
+ olcRootPW: configpassword
- dn: olcDatabase={1}mdb,cn=config
- objectClass: olcDatabaseConfig
- objectClass: olcMdbConfig
- olcDatabase: {1}mdb
- olcDbDirectory: /var/db/openldap
- olcDbIndex: objectClass eq
- olcSuffix: dc=example
- olcRootDN: cn=root,dc=example
- olcRootPW: notapassword
- '';
+ dn: olcDatabase={1}mdb,cn=config
+ objectClass: olcDatabaseConfig
+ objectClass: olcMdbConfig
+ olcDatabase: {1}mdb
+ olcDbDirectory: /var/db/openldap
+ olcDbIndex: objectClass eq
+ olcSuffix: dc=example
+ olcRootDN: cn=root,dc=example
+ olcRootPW: notapassword
+ '';
- ldapClientConfig = {
- enable = true;
- loginPam = false;
- nsswitch = false;
- server = "ldap://";
- base = "dc=example";
- };
+ ldapClientConfig = {
+ enable = true;
+ loginPam = false;
+ nsswitch = false;
+ server = "ldap://";
+ base = "dc=example";
+ };
- in
- {
- name = "openldap";
+in
+{
+ name = "openldap";
- nodes.machine =
- { pkgs, ... }:
- {
- environment.etc."openldap/root_password".text = "notapassword";
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.etc."openldap/root_password".text = "notapassword";
- users.ldap = ldapClientConfig;
+ users.ldap = ldapClientConfig;
- services.openldap = {
- enable = true;
- urlList = [
- "ldapi:///"
- "ldap://"
- ];
- settings = {
- children = {
- "cn=schema".includes = [
- "${pkgs.openldap}/etc/schema/core.ldif"
- "${pkgs.openldap}/etc/schema/cosine.ldif"
- "${pkgs.openldap}/etc/schema/inetorgperson.ldif"
- "${pkgs.openldap}/etc/schema/nis.ldif"
- ];
- "olcDatabase={0}config" = {
- attrs = {
- objectClass = [ "olcDatabaseConfig" ];
- olcDatabase = "{0}config";
- olcRootDN = "cn=root,cn=config";
- olcRootPW = "configpassword";
- };
+ services.openldap = {
+ enable = true;
+ urlList = [
+ "ldapi:///"
+ "ldap://"
+ ];
+ settings = {
+ children = {
+ "cn=schema".includes = [
+ "${pkgs.openldap}/etc/schema/core.ldif"
+ "${pkgs.openldap}/etc/schema/cosine.ldif"
+ "${pkgs.openldap}/etc/schema/inetorgperson.ldif"
+ "${pkgs.openldap}/etc/schema/nis.ldif"
+ ];
+ "olcDatabase={0}config" = {
+ attrs = {
+ objectClass = [ "olcDatabaseConfig" ];
+ olcDatabase = "{0}config";
+ olcRootDN = "cn=root,cn=config";
+ olcRootPW = "configpassword";
};
- "olcDatabase={1}mdb" = {
- # This tests string, base64 and path values, as well as lists of string values
- attrs = {
- objectClass = [
- "olcDatabaseConfig"
- "olcMdbConfig"
- ];
- olcDatabase = "{1}mdb";
- olcDbDirectory = "/var/lib/openldap/db";
- olcSuffix = "dc=example";
- olcRootDN = {
- # cn=root,dc=example
- base64 = "Y249cm9vdCxkYz1leGFtcGxl";
- };
- olcRootPW = {
- path = "/etc/openldap/root_password";
- };
+ };
+ "olcDatabase={1}mdb" = {
+ # This tests string, base64 and path values, as well as lists of string values
+ attrs = {
+ objectClass = [
+ "olcDatabaseConfig"
+ "olcMdbConfig"
+ ];
+ olcDatabase = "{1}mdb";
+ olcDbDirectory = "/var/lib/openldap/db";
+ olcSuffix = "dc=example";
+ olcRootDN = {
+ # cn=root,dc=example
+ base64 = "Y249cm9vdCxkYz1leGFtcGxl";
+ };
+ olcRootPW = {
+ path = "/etc/openldap/root_password";
};
};
};
};
};
-
- specialisation = {
- declarativeContents.configuration =
- { ... }:
- {
- services.openldap.declarativeContents."dc=example" = dbContents;
- };
- mutableConfig.configuration =
- { ... }:
- {
- services.openldap = {
- declarativeContents."dc=example" = dbContents;
- mutableConfig = true;
- };
- };
- manualConfigDir = {
- inheritParentConfig = false;
- configuration =
- { ... }:
- {
- users.ldap = ldapClientConfig;
- services.openldap = {
- enable = true;
- configDir = "/var/db/slapd.d";
- };
- };
- };
- };
};
- testScript =
- { nodes, ... }:
- let
- specializations = "${nodes.machine.system.build.toplevel}/specialisation";
- changeRootPw = ''
- dn: olcDatabase={1}mdb,cn=config
- changetype: modify
- replace: olcRootPW
- olcRootPW: foobar
- '';
- in
- ''
- # Test startup with empty DB
- machine.wait_for_unit("openldap.service")
- with subtest("declarative contents"):
- machine.succeed('${specializations}/declarativeContents/bin/switch-to-configuration test')
- machine.wait_for_unit("openldap.service")
- machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword')
- machine.fail('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
-
- with subtest("mutable config"):
- machine.succeed('${specializations}/mutableConfig/bin/switch-to-configuration test')
- machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword')
- machine.succeed('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
- machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w foobar')
-
- with subtest("manual config dir"):
- machine.succeed(
- 'mkdir /var/db/slapd.d /var/db/openldap',
- 'slapadd -F /var/db/slapd.d -n0 -l ${pkgs.writeText "config.ldif" ldifConfig}',
- 'slapadd -F /var/db/slapd.d -n1 -l ${pkgs.writeText "contents.ldif" dbContents}',
- 'chown -R openldap:openldap /var/db/slapd.d /var/db/openldap',
- '${specializations}/manualConfigDir/bin/switch-to-configuration test',
- )
- machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword')
- machine.succeed('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
- machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w foobar')
+ specialisation = {
+ declarativeContents.configuration =
+ { ... }:
+ {
+ services.openldap.declarativeContents."dc=example" = dbContents;
+ };
+ mutableConfig.configuration =
+ { ... }:
+ {
+ services.openldap = {
+ declarativeContents."dc=example" = dbContents;
+ mutableConfig = true;
+ };
+ };
+ manualConfigDir = {
+ inheritParentConfig = false;
+ configuration =
+ { ... }:
+ {
+ users.ldap = ldapClientConfig;
+ services.openldap = {
+ enable = true;
+ configDir = "/var/db/slapd.d";
+ };
+ };
+ };
+ };
+ };
+ testScript =
+ { nodes, ... }:
+ let
+ specializations = "${nodes.machine.system.build.toplevel}/specialisation";
+ changeRootPw = ''
+ dn: olcDatabase={1}mdb,cn=config
+ changetype: modify
+ replace: olcRootPW
+ olcRootPW: foobar
'';
- }
-)
+ in
+ ''
+ # Test startup with empty DB
+ machine.wait_for_unit("openldap.service")
+
+ with subtest("declarative contents"):
+ machine.succeed('${specializations}/declarativeContents/bin/switch-to-configuration test')
+ machine.wait_for_unit("openldap.service")
+ machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword')
+ machine.fail('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
+
+ with subtest("mutable config"):
+ machine.succeed('${specializations}/mutableConfig/bin/switch-to-configuration test')
+ machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword')
+ machine.succeed('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
+ machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w foobar')
+
+ with subtest("manual config dir"):
+ machine.succeed(
+ 'mkdir /var/db/slapd.d /var/db/openldap',
+ 'slapadd -F /var/db/slapd.d -n0 -l ${pkgs.writeText "config.ldif" ldifConfig}',
+ 'slapadd -F /var/db/slapd.d -n1 -l ${pkgs.writeText "contents.ldif" dbContents}',
+ 'chown -R openldap:openldap /var/db/slapd.d /var/db/openldap',
+ '${specializations}/manualConfigDir/bin/switch-to-configuration test',
+ )
+ machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword')
+ machine.succeed('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
+ machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w foobar')
+ '';
+}
diff --git a/nixos/tests/openresty-lua.nix b/nixos/tests/openresty-lua.nix
index 7141ef181039..8af2a0720eda 100644
--- a/nixos/tests/openresty-lua.nix
+++ b/nixos/tests/openresty-lua.nix
@@ -1,105 +1,103 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- luaLibs = [
- pkgs.lua.pkgs.markdown
- ];
+{ pkgs, lib, ... }:
+let
+ luaLibs = [
+ pkgs.lua.pkgs.markdown
+ ];
- getLuaPath = lib: "${lib}/share/lua/${pkgs.lua.luaversion}/?.lua";
- luaPath = lib.concatStringsSep ";" (map getLuaPath luaLibs);
- in
- {
- name = "openresty-lua";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ bbigras ];
- };
+ getLuaPath = lib: "${lib}/share/lua/${pkgs.lua.luaversion}/?.lua";
+ luaPath = lib.concatStringsSep ";" (map getLuaPath luaLibs);
+in
+{
+ name = "openresty-lua";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ bbigras ];
+ };
- nodes = {
- webserver =
- { pkgs, lib, ... }:
- {
- networking = {
- extraHosts = ''
- 127.0.0.1 default.test
- 127.0.0.1 sandbox.test
- '';
- };
- services.nginx = {
- enable = true;
- package = pkgs.openresty;
+ nodes = {
+ webserver =
+ { pkgs, lib, ... }:
+ {
+ networking = {
+ extraHosts = ''
+ 127.0.0.1 default.test
+ 127.0.0.1 sandbox.test
+ '';
+ };
+ services.nginx = {
+ enable = true;
+ package = pkgs.openresty;
- commonHttpConfig = ''
- lua_package_path '${luaPath};;';
- '';
+ commonHttpConfig = ''
+ lua_package_path '${luaPath};;';
+ '';
- virtualHosts."default.test" = {
- default = true;
- locations."/" = {
- extraConfig = ''
- default_type text/html;
- access_by_lua '
- local markdown = require "markdown"
- markdown("source")
- ';
- '';
- };
+ virtualHosts."default.test" = {
+ default = true;
+ locations."/" = {
+ extraConfig = ''
+ default_type text/html;
+ access_by_lua '
+ local markdown = require "markdown"
+ markdown("source")
+ ';
+ '';
};
+ };
- virtualHosts."sandbox.test" = {
- locations."/test1-write" = {
- extraConfig = ''
- content_by_lua_block {
- local create = os.execute('${pkgs.coreutils}/bin/mkdir /tmp/test1-read')
- local create = os.execute('${pkgs.coreutils}/bin/touch /tmp/test1-read/foo.txt')
- local echo = os.execute('${pkgs.coreutils}/bin/echo worked > /tmp/test1-read/foo.txt')
- }
- '';
- };
- locations."/test1-read" = {
- root = "/tmp";
- };
- locations."/test2-write" = {
- extraConfig = ''
- content_by_lua_block {
- local create = os.execute('${pkgs.coreutils}/bin/mkdir /var/web/test2-read')
- local create = os.execute('${pkgs.coreutils}/bin/touch /var/web/test2-read/bar.txt')
- local echo = os.execute('${pkgs.coreutils}/bin/echo error-worked > /var/web/test2-read/bar.txt')
- }
- '';
- };
- locations."/test2-read" = {
- root = "/var/web";
- };
+ virtualHosts."sandbox.test" = {
+ locations."/test1-write" = {
+ extraConfig = ''
+ content_by_lua_block {
+ local create = os.execute('${pkgs.coreutils}/bin/mkdir /tmp/test1-read')
+ local create = os.execute('${pkgs.coreutils}/bin/touch /tmp/test1-read/foo.txt')
+ local echo = os.execute('${pkgs.coreutils}/bin/echo worked > /tmp/test1-read/foo.txt')
+ }
+ '';
+ };
+ locations."/test1-read" = {
+ root = "/tmp";
+ };
+ locations."/test2-write" = {
+ extraConfig = ''
+ content_by_lua_block {
+ local create = os.execute('${pkgs.coreutils}/bin/mkdir /var/web/test2-read')
+ local create = os.execute('${pkgs.coreutils}/bin/touch /var/web/test2-read/bar.txt')
+ local echo = os.execute('${pkgs.coreutils}/bin/echo error-worked > /var/web/test2-read/bar.txt')
+ }
+ '';
+ };
+ locations."/test2-read" = {
+ root = "/var/web";
};
};
};
- };
+ };
+ };
- testScript =
- { nodes, ... }:
- ''
- url = "http://localhost"
+ testScript =
+ { nodes, ... }:
+ ''
+ url = "http://localhost"
- webserver.wait_for_unit("nginx")
- webserver.wait_for_open_port(80)
+ webserver.wait_for_unit("nginx")
+ webserver.wait_for_open_port(80)
- http_code = webserver.succeed(
- f"curl -w '%{{http_code}}' --head --fail {url}"
- )
- assert http_code.split("\n")[-1] == "200"
+ http_code = webserver.succeed(
+ f"curl -w '%{{http_code}}' --head --fail {url}"
+ )
+ assert http_code.split("\n")[-1] == "200"
- # This test checks the creation and reading of a file in sandbox mode.
- # Checking write in temporary folder
- webserver.succeed("$(curl -vvv http://sandbox.test/test1-write)")
- webserver.succeed('test "$(curl -fvvv http://sandbox.test/test1-read/foo.txt)" = worked')
- # Checking write in protected folder. In sandbox mode for the nginx service, the folder /var/web is mounted
- # in read-only mode.
- webserver.succeed("mkdir -p /var/web")
- webserver.succeed("chown nginx:nginx /var/web")
- webserver.succeed("$(curl -vvv http://sandbox.test/test2-write)")
- assert "404 Not Found" in machine.succeed(
- "curl -vvv -s http://sandbox.test/test2-read/bar.txt"
- )
- '';
- }
-)
+ # This test checks the creation and reading of a file in sandbox mode.
+ # Checking write in temporary folder
+ webserver.succeed("$(curl -vvv http://sandbox.test/test1-write)")
+ webserver.succeed('test "$(curl -fvvv http://sandbox.test/test1-read/foo.txt)" = worked')
+ # Checking write in protected folder. In sandbox mode for the nginx service, the folder /var/web is mounted
+ # in read-only mode.
+ webserver.succeed("mkdir -p /var/web")
+ webserver.succeed("chown nginx:nginx /var/web")
+ webserver.succeed("$(curl -vvv http://sandbox.test/test2-write)")
+ assert "404 Not Found" in machine.succeed(
+ "curl -vvv -s http://sandbox.test/test2-read/bar.txt"
+ )
+ '';
+}
diff --git a/nixos/tests/opensnitch.nix b/nixos/tests/opensnitch.nix
index dbb536e9a769..3f279037df2e 100644
--- a/nixos/tests/opensnitch.nix
+++ b/nixos/tests/opensnitch.nix
@@ -1,85 +1,83 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- monitorMethods = [
- "ebpf"
- "proc"
- "ftrace"
- "audit"
- ];
- in
- {
- name = "opensnitch";
+{ pkgs, lib, ... }:
+let
+ monitorMethods = [
+ "ebpf"
+ "proc"
+ "ftrace"
+ "audit"
+ ];
+in
+{
+ name = "opensnitch";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ onny ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ onny ];
+ };
- nodes =
- {
- server = {
- networking.firewall.allowedTCPPorts = [ 80 ];
- services.caddy = {
- enable = true;
- virtualHosts."localhost".extraConfig = ''
- respond "Hello, world!"
- '';
- };
+ nodes =
+ {
+ server = {
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ services.caddy = {
+ enable = true;
+ virtualHosts."localhost".extraConfig = ''
+ respond "Hello, world!"
+ '';
};
- }
- // (lib.listToAttrs (
- map (
- m:
- lib.nameValuePair "client_blocked_${m}" {
- services.opensnitch = {
- enable = true;
- settings.DefaultAction = "deny";
- settings.ProcMonitorMethod = m;
- };
- }
- ) monitorMethods
- ))
- // (lib.listToAttrs (
- map (
- m:
- lib.nameValuePair "client_allowed_${m}" {
- services.opensnitch = {
- enable = true;
- settings.DefaultAction = "deny";
- settings.ProcMonitorMethod = m;
- rules = {
- curl = {
- name = "curl";
- enabled = true;
- action = "allow";
- duration = "always";
- operator = {
- type = "simple";
- sensitive = false;
- operand = "process.path";
- data = "${pkgs.curl}/bin/curl";
- };
+ };
+ }
+ // (lib.listToAttrs (
+ map (
+ m:
+ lib.nameValuePair "client_blocked_${m}" {
+ services.opensnitch = {
+ enable = true;
+ settings.DefaultAction = "deny";
+ settings.ProcMonitorMethod = m;
+ };
+ }
+ ) monitorMethods
+ ))
+ // (lib.listToAttrs (
+ map (
+ m:
+ lib.nameValuePair "client_allowed_${m}" {
+ services.opensnitch = {
+ enable = true;
+ settings.DefaultAction = "deny";
+ settings.ProcMonitorMethod = m;
+ rules = {
+ curl = {
+ name = "curl";
+ enabled = true;
+ action = "allow";
+ duration = "always";
+ operator = {
+ type = "simple";
+ sensitive = false;
+ operand = "process.path";
+ data = "${pkgs.curl}/bin/curl";
};
};
};
- }
- ) monitorMethods
- ));
+ };
+ }
+ ) monitorMethods
+ ));
- testScript =
- ''
- start_all()
- server.wait_for_unit("caddy.service")
- server.wait_for_open_port(80)
- ''
- + lib.concatLines (
- map (m: ''
- client_blocked_${m}.wait_for_unit("opensnitchd.service")
- client_blocked_${m}.fail("curl http://server")
+ testScript =
+ ''
+ start_all()
+ server.wait_for_unit("caddy.service")
+ server.wait_for_open_port(80)
+ ''
+ + lib.concatLines (
+ map (m: ''
+ client_blocked_${m}.wait_for_unit("opensnitchd.service")
+ client_blocked_${m}.fail("curl http://server")
- client_allowed_${m}.wait_for_unit("opensnitchd.service")
- client_allowed_${m}.succeed("curl http://server")
- '') monitorMethods
- );
- }
-)
+ client_allowed_${m}.wait_for_unit("opensnitchd.service")
+ client_allowed_${m}.succeed("curl http://server")
+ '') monitorMethods
+ );
+}
diff --git a/nixos/tests/openssh.nix b/nixos/tests/openssh.nix
index d7ddf478d91a..5f2b3e7969d1 100644
--- a/nixos/tests/openssh.nix
+++ b/nixos/tests/openssh.nix
@@ -1,359 +1,357 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- inherit (import ./ssh-keys.nix pkgs)
- snakeOilPrivateKey
- snakeOilPublicKey
- snakeOilEd25519PrivateKey
- snakeOilEd25519PublicKey
- ;
- in
- {
- name = "openssh";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ aszlig ];
- };
+let
+ inherit (import ./ssh-keys.nix pkgs)
+ snakeOilPrivateKey
+ snakeOilPublicKey
+ snakeOilEd25519PrivateKey
+ snakeOilEd25519PublicKey
+ ;
+in
+{
+ name = "openssh";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ aszlig ];
+ };
- nodes = {
+ nodes = {
- server =
- { ... }:
+ server =
+ { ... }:
- {
- services.openssh.enable = true;
- security.pam.services.sshd.limits = [
- {
- domain = "*";
- item = "memlock";
- type = "-";
- value = 1024;
- }
- ];
- users.users.root.openssh.authorizedKeys.keys = [
- snakeOilPublicKey
- ];
- };
-
- server-allowed-users =
- { ... }:
-
- {
- services.openssh = {
- enable = true;
- settings.AllowUsers = [
- "alice"
- "bob"
- ];
- };
- users.groups = {
- alice = { };
- bob = { };
- carol = { };
- };
- users.users = {
- alice = {
- isNormalUser = true;
- group = "alice";
- openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
- };
- bob = {
- isNormalUser = true;
- group = "bob";
- openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
- };
- carol = {
- isNormalUser = true;
- group = "carol";
- openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
- };
- };
- };
-
- server-lazy =
- { ... }:
-
- {
- services.openssh = {
- enable = true;
- startWhenNeeded = true;
- };
- security.pam.services.sshd.limits = [
- {
- domain = "*";
- item = "memlock";
- type = "-";
- value = 1024;
- }
- ];
- users.users.root.openssh.authorizedKeys.keys = [
- snakeOilPublicKey
- ];
- };
-
- server-lazy-socket = {
- virtualisation.vlans = [
- 1
- 2
+ {
+ services.openssh.enable = true;
+ security.pam.services.sshd.limits = [
+ {
+ domain = "*";
+ item = "memlock";
+ type = "-";
+ value = 1024;
+ }
];
+ users.users.root.openssh.authorizedKeys.keys = [
+ snakeOilPublicKey
+ ];
+ };
+
+ server-allowed-users =
+ { ... }:
+
+ {
+ services.openssh = {
+ enable = true;
+ settings.AllowUsers = [
+ "alice"
+ "bob"
+ ];
+ };
+ users.groups = {
+ alice = { };
+ bob = { };
+ carol = { };
+ };
+ users.users = {
+ alice = {
+ isNormalUser = true;
+ group = "alice";
+ openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
+ };
+ bob = {
+ isNormalUser = true;
+ group = "bob";
+ openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
+ };
+ carol = {
+ isNormalUser = true;
+ group = "carol";
+ openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
+ };
+ };
+ };
+
+ server-lazy =
+ { ... }:
+
+ {
services.openssh = {
enable = true;
startWhenNeeded = true;
- ports = [ 2222 ];
- listenAddresses = [ { addr = "0.0.0.0"; } ];
+ };
+ security.pam.services.sshd.limits = [
+ {
+ domain = "*";
+ item = "memlock";
+ type = "-";
+ value = 1024;
+ }
+ ];
+ users.users.root.openssh.authorizedKeys.keys = [
+ snakeOilPublicKey
+ ];
+ };
+
+ server-lazy-socket = {
+ virtualisation.vlans = [
+ 1
+ 2
+ ];
+ services.openssh = {
+ enable = true;
+ startWhenNeeded = true;
+ ports = [ 2222 ];
+ listenAddresses = [ { addr = "0.0.0.0"; } ];
+ };
+ users.users.root.openssh.authorizedKeys.keys = [
+ snakeOilPublicKey
+ ];
+ };
+
+ server-localhost-only =
+ { ... }:
+
+ {
+ services.openssh = {
+ enable = true;
+ listenAddresses = [
+ {
+ addr = "127.0.0.1";
+ port = 22;
+ }
+ ];
+ };
+ };
+
+ server-localhost-only-lazy =
+ { ... }:
+
+ {
+ services.openssh = {
+ enable = true;
+ startWhenNeeded = true;
+ listenAddresses = [
+ {
+ addr = "127.0.0.1";
+ port = 22;
+ }
+ ];
+ };
+ };
+
+ server-match-rule =
+ { ... }:
+
+ {
+ services.openssh = {
+ enable = true;
+ listenAddresses = [
+ {
+ addr = "127.0.0.1";
+ port = 22;
+ }
+ {
+ addr = "[::]";
+ port = 22;
+ }
+ ];
+ extraConfig = ''
+ # Combined test for two (predictable) Match criterias
+ Match LocalAddress 127.0.0.1 LocalPort 22
+ PermitRootLogin yes
+
+ # Separate tests for Match criterias
+ Match User root
+ PermitRootLogin yes
+ Match Group root
+ PermitRootLogin yes
+ Match Host nohost.example
+ PermitRootLogin yes
+ Match LocalAddress 127.0.0.1
+ PermitRootLogin yes
+ Match LocalPort 22
+ PermitRootLogin yes
+ Match RDomain nohost.example
+ PermitRootLogin yes
+ Match Address 127.0.0.1
+ PermitRootLogin yes
+ '';
+ };
+ };
+
+ server-no-openssl =
+ { ... }:
+ {
+ services.openssh = {
+ enable = true;
+ package = pkgs.opensshPackages.openssh.override {
+ linkOpenssl = false;
+ };
+ hostKeys = [
+ {
+ type = "ed25519";
+ path = "/etc/ssh/ssh_host_ed25519_key";
+ }
+ ];
+ settings = {
+ # Since this test is against an OpenSSH-without-OpenSSL,
+ # we have to override NixOS's defaults ciphers (which require OpenSSL)
+ # and instead set these to null, which will mean OpenSSH uses its defaults.
+ # Expectedly, OpenSSH's defaults don't require OpenSSL when it's compiled
+ # without OpenSSL.
+ Ciphers = null;
+ KexAlgorithms = null;
+ Macs = null;
+ };
+ };
+ users.users.root.openssh.authorizedKeys.keys = [
+ snakeOilEd25519PublicKey
+ ];
+ };
+
+ server-no-pam =
+ { pkgs, ... }:
+ {
+ services.openssh = {
+ enable = true;
+ package = pkgs.opensshPackages.openssh.override {
+ withPAM = false;
+ };
+ settings = {
+ UsePAM = false;
+ };
};
users.users.root.openssh.authorizedKeys.keys = [
snakeOilPublicKey
];
};
- server-localhost-only =
- { ... }:
+ client =
+ { ... }:
+ {
+ virtualisation.vlans = [
+ 1
+ 2
+ ];
+ };
- {
- services.openssh = {
- enable = true;
- listenAddresses = [
- {
- addr = "127.0.0.1";
- port = 22;
- }
- ];
- };
- };
+ };
- server-localhost-only-lazy =
- { ... }:
+ testScript = ''
+ start_all()
- {
- services.openssh = {
- enable = true;
- startWhenNeeded = true;
- listenAddresses = [
- {
- addr = "127.0.0.1";
- port = 22;
- }
- ];
- };
- };
+ server.wait_for_unit("sshd", timeout=30)
+ server_allowed_users.wait_for_unit("sshd", timeout=30)
+ server_localhost_only.wait_for_unit("sshd", timeout=30)
+ server_match_rule.wait_for_unit("sshd", timeout=30)
+ server_no_openssl.wait_for_unit("sshd", timeout=30)
+ server_no_pam.wait_for_unit("sshd", timeout=30)
- server-match-rule =
- { ... }:
+ server_lazy.wait_for_unit("sshd.socket", timeout=30)
+ server_localhost_only_lazy.wait_for_unit("sshd.socket", timeout=30)
+ server_lazy_socket.wait_for_unit("sshd.socket", timeout=30)
- {
- services.openssh = {
- enable = true;
- listenAddresses = [
- {
- addr = "127.0.0.1";
- port = 22;
- }
- {
- addr = "[::]";
- port = 22;
- }
- ];
- extraConfig = ''
- # Combined test for two (predictable) Match criterias
- Match LocalAddress 127.0.0.1 LocalPort 22
- PermitRootLogin yes
+ with subtest("manual-authkey"):
+ client.succeed(
+ '${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""'
+ )
+ public_key = client.succeed(
+ "${pkgs.openssh}/bin/ssh-keygen -y -f /root/.ssh/id_ed25519"
+ )
+ public_key = public_key.strip()
+ client.succeed("chmod 600 /root/.ssh/id_ed25519")
- # Separate tests for Match criterias
- Match User root
- PermitRootLogin yes
- Match Group root
- PermitRootLogin yes
- Match Host nohost.example
- PermitRootLogin yes
- Match LocalAddress 127.0.0.1
- PermitRootLogin yes
- Match LocalPort 22
- PermitRootLogin yes
- Match RDomain nohost.example
- PermitRootLogin yes
- Match Address 127.0.0.1
- PermitRootLogin yes
- '';
- };
- };
+ server.succeed("echo '{}' > /root/.ssh/authorized_keys".format(public_key))
+ server_lazy.succeed("echo '{}' > /root/.ssh/authorized_keys".format(public_key))
- server-no-openssl =
- { ... }:
- {
- services.openssh = {
- enable = true;
- package = pkgs.opensshPackages.openssh.override {
- linkOpenssl = false;
- };
- hostKeys = [
- {
- type = "ed25519";
- path = "/etc/ssh/ssh_host_ed25519_key";
- }
- ];
- settings = {
- # Since this test is against an OpenSSH-without-OpenSSL,
- # we have to override NixOS's defaults ciphers (which require OpenSSL)
- # and instead set these to null, which will mean OpenSSH uses its defaults.
- # Expectedly, OpenSSH's defaults don't require OpenSSL when it's compiled
- # without OpenSSL.
- Ciphers = null;
- KexAlgorithms = null;
- Macs = null;
- };
- };
- users.users.root.openssh.authorizedKeys.keys = [
- snakeOilEd25519PublicKey
- ];
- };
+ client.wait_for_unit("network.target")
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'echo hello world' >&2",
+ timeout=30
+ )
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'ulimit -l' | grep 1024",
+ timeout=30
+ )
- server-no-pam =
- { pkgs, ... }:
- {
- services.openssh = {
- enable = true;
- package = pkgs.opensshPackages.openssh.override {
- withPAM = false;
- };
- settings = {
- UsePAM = false;
- };
- };
- users.users.root.openssh.authorizedKeys.keys = [
- snakeOilPublicKey
- ];
- };
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server-lazy 'echo hello world' >&2",
+ timeout=30
+ )
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server-lazy 'ulimit -l' | grep 1024",
+ timeout=30
+ )
- client =
- { ... }:
- {
- virtualisation.vlans = [
- 1
- 2
- ];
- };
+ with subtest("socket activation on a non-standard port"):
+ client.succeed(
+ "cat ${snakeOilPrivateKey} > privkey.snakeoil"
+ )
+ client.succeed("chmod 600 privkey.snakeoil")
+ # The final segment in this IP is allocated according to the alphabetical order of machines in this test.
+ client.succeed(
+ "ssh -p 2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil root@192.168.2.5 true",
+ timeout=30
+ )
- };
+ with subtest("configured-authkey"):
+ client.succeed(
+ "cat ${snakeOilPrivateKey} > privkey.snakeoil"
+ )
+ client.succeed("chmod 600 privkey.snakeoil")
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server true",
+ timeout=30
+ )
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server-lazy true",
+ timeout=30
+ )
- testScript = ''
- start_all()
+ with subtest("localhost-only"):
+ server_localhost_only.succeed("ss -nlt | grep '127.0.0.1:22'")
+ server_localhost_only_lazy.succeed("ss -nlt | grep '127.0.0.1:22'")
- server.wait_for_unit("sshd", timeout=30)
- server_allowed_users.wait_for_unit("sshd", timeout=30)
- server_localhost_only.wait_for_unit("sshd", timeout=30)
- server_match_rule.wait_for_unit("sshd", timeout=30)
- server_no_openssl.wait_for_unit("sshd", timeout=30)
- server_no_pam.wait_for_unit("sshd", timeout=30)
+ with subtest("match-rules"):
+ server_match_rule.succeed("ss -nlt | grep '127.0.0.1:22'")
- server_lazy.wait_for_unit("sshd.socket", timeout=30)
- server_localhost_only_lazy.wait_for_unit("sshd.socket", timeout=30)
- server_lazy_socket.wait_for_unit("sshd.socket", timeout=30)
+ with subtest("allowed-users"):
+ client.succeed(
+ "cat ${snakeOilPrivateKey} > privkey.snakeoil"
+ )
+ client.succeed("chmod 600 privkey.snakeoil")
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil alice@server-allowed-users true",
+ timeout=30
+ )
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil bob@server-allowed-users true",
+ timeout=30
+ )
+ client.fail(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil carol@server-allowed-users true",
+ timeout=30
+ )
- with subtest("manual-authkey"):
- client.succeed(
- '${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""'
- )
- public_key = client.succeed(
- "${pkgs.openssh}/bin/ssh-keygen -y -f /root/.ssh/id_ed25519"
- )
- public_key = public_key.strip()
- client.succeed("chmod 600 /root/.ssh/id_ed25519")
+ with subtest("no-openssl"):
+ client.succeed(
+ "cat ${snakeOilEd25519PrivateKey} > privkey.snakeoil"
+ )
+ client.succeed("chmod 600 privkey.snakeoil")
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server-no-openssl true",
+ timeout=30
+ )
- server.succeed("echo '{}' > /root/.ssh/authorized_keys".format(public_key))
- server_lazy.succeed("echo '{}' > /root/.ssh/authorized_keys".format(public_key))
+ with subtest("no-pam"):
+ client.succeed(
+ "cat ${snakeOilPrivateKey} > privkey.snakeoil"
+ )
+ client.succeed("chmod 600 privkey.snakeoil")
+ client.succeed(
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server-no-pam true",
+ timeout=30
+ )
- client.wait_for_unit("network.target")
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'echo hello world' >&2",
- timeout=30
- )
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'ulimit -l' | grep 1024",
- timeout=30
- )
-
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server-lazy 'echo hello world' >&2",
- timeout=30
- )
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server-lazy 'ulimit -l' | grep 1024",
- timeout=30
- )
-
- with subtest("socket activation on a non-standard port"):
- client.succeed(
- "cat ${snakeOilPrivateKey} > privkey.snakeoil"
- )
- client.succeed("chmod 600 privkey.snakeoil")
- # The final segment in this IP is allocated according to the alphabetical order of machines in this test.
- client.succeed(
- "ssh -p 2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil root@192.168.2.5 true",
- timeout=30
- )
-
- with subtest("configured-authkey"):
- client.succeed(
- "cat ${snakeOilPrivateKey} > privkey.snakeoil"
- )
- client.succeed("chmod 600 privkey.snakeoil")
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server true",
- timeout=30
- )
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server-lazy true",
- timeout=30
- )
-
- with subtest("localhost-only"):
- server_localhost_only.succeed("ss -nlt | grep '127.0.0.1:22'")
- server_localhost_only_lazy.succeed("ss -nlt | grep '127.0.0.1:22'")
-
- with subtest("match-rules"):
- server_match_rule.succeed("ss -nlt | grep '127.0.0.1:22'")
-
- with subtest("allowed-users"):
- client.succeed(
- "cat ${snakeOilPrivateKey} > privkey.snakeoil"
- )
- client.succeed("chmod 600 privkey.snakeoil")
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil alice@server-allowed-users true",
- timeout=30
- )
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil bob@server-allowed-users true",
- timeout=30
- )
- client.fail(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil carol@server-allowed-users true",
- timeout=30
- )
-
- with subtest("no-openssl"):
- client.succeed(
- "cat ${snakeOilEd25519PrivateKey} > privkey.snakeoil"
- )
- client.succeed("chmod 600 privkey.snakeoil")
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server-no-openssl true",
- timeout=30
- )
-
- with subtest("no-pam"):
- client.succeed(
- "cat ${snakeOilPrivateKey} > privkey.snakeoil"
- )
- client.succeed("chmod 600 privkey.snakeoil")
- client.succeed(
- "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i privkey.snakeoil server-no-pam true",
- timeout=30
- )
-
- # None of the per-connection units should have failed.
- server_lazy.fail("systemctl is-failed 'sshd@*.service'")
- '';
- }
-)
+ # None of the per-connection units should have failed.
+ server_lazy.fail("systemctl is-failed 'sshd@*.service'")
+ '';
+}
diff --git a/nixos/tests/opentabletdriver.nix b/nixos/tests/opentabletdriver.nix
index b7bdb16bf005..e97e3a5fe123 100644
--- a/nixos/tests/opentabletdriver.nix
+++ b/nixos/tests/opentabletdriver.nix
@@ -1,36 +1,34 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- testUser = "alice";
- in
- {
- name = "opentabletdriver";
- meta = {
- maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
+{ pkgs, ... }:
+let
+ testUser = "alice";
+in
+{
+ name = "opentabletdriver";
+ meta = {
+ maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
+ test-support.displayManager.auto.user = testUser;
+ hardware.opentabletdriver.enable = true;
};
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
- test-support.displayManager.auto.user = testUser;
- hardware.opentabletdriver.enable = true;
- };
+ testScript = ''
+ machine.start()
+ machine.wait_for_x()
- testScript = ''
- machine.start()
- machine.wait_for_x()
+ machine.wait_for_unit('graphical.target')
+ machine.wait_for_unit("opentabletdriver.service", "${testUser}")
- machine.wait_for_unit('graphical.target')
- machine.wait_for_unit("opentabletdriver.service", "${testUser}")
-
- machine.succeed("cat /etc/udev/rules.d/70-opentabletdriver.rules")
- # Will fail if service is not running
- # Needs to run as the same user that started the service
- machine.succeed("su - ${testUser} -c 'otd detect'")
- '';
- }
-)
+ machine.succeed("cat /etc/udev/rules.d/70-opentabletdriver.rules")
+ # Will fail if service is not running
+ # Needs to run as the same user that started the service
+ machine.succeed("su - ${testUser} -c 'otd detect'")
+ '';
+}
diff --git a/nixos/tests/opentelemetry-collector.nix b/nixos/tests/opentelemetry-collector.nix
index 1d8d4ea815c4..df319e5c7df9 100644
--- a/nixos/tests/opentelemetry-collector.nix
+++ b/nixos/tests/opentelemetry-collector.nix
@@ -1,87 +1,85 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- port = 4318;
- in
- {
- name = "opentelemetry-collector";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ tylerjl ];
- };
+{ pkgs, ... }:
+let
+ port = 4318;
+in
+{
+ name = "opentelemetry-collector";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ tylerjl ];
+ };
- nodes.machine =
- { ... }:
- {
- networking.firewall.allowedTCPPorts = [ port ];
- services.opentelemetry-collector = {
- enable = true;
- settings = {
- exporters.logging.verbosity = "detailed";
- receivers.otlp.protocols = {
- http.endpoint = "0.0.0.0:${toString port}";
- };
- service = {
- pipelines.logs = {
- receivers = [ "otlp" ];
- exporters = [ "logging" ];
- };
+ nodes.machine =
+ { ... }:
+ {
+ networking.firewall.allowedTCPPorts = [ port ];
+ services.opentelemetry-collector = {
+ enable = true;
+ settings = {
+ exporters.logging.verbosity = "detailed";
+ receivers.otlp.protocols = {
+ http.endpoint = "0.0.0.0:${toString port}";
+ };
+ service = {
+ pipelines.logs = {
+ receivers = [ "otlp" ];
+ exporters = [ "logging" ];
};
};
};
- virtualisation.forwardPorts = [
- {
- host.port = port;
- guest.port = port;
- }
- ];
};
-
- extraPythonPackages = p: [
- p.requests
- p.types-requests
- ];
-
- # Send a log event through the OTLP pipeline and check for its
- # presence in the collector logs.
- testScript = # python
- ''
- import requests
- import time
-
- from uuid import uuid4
-
- flag = str(uuid4())
-
- machine.wait_for_unit("opentelemetry-collector.service")
- machine.wait_for_open_port(${toString port})
-
- event = {
- "resourceLogs": [
- {
- "resource": {"attributes": []},
- "scopeLogs": [
- {
- "logRecords": [
- {
- "timeUnixNano": str(time.time_ns()),
- "severityNumber": 9,
- "severityText": "Info",
- "name": "logTest",
- "body": {
- "stringValue": flag
- },
- "attributes": []
- },
- ]
- }
- ]
- }
- ]
+ virtualisation.forwardPorts = [
+ {
+ host.port = port;
+ guest.port = port;
}
+ ];
+ };
- response = requests.post("http://localhost:${toString port}/v1/logs", json=event)
- assert response.status_code == 200
- assert flag in machine.execute("journalctl -u opentelemetry-collector")[-1]
- '';
- }
-)
+ extraPythonPackages = p: [
+ p.requests
+ p.types-requests
+ ];
+
+ # Send a log event through the OTLP pipeline and check for its
+ # presence in the collector logs.
+ testScript = # python
+ ''
+ import requests
+ import time
+
+ from uuid import uuid4
+
+ flag = str(uuid4())
+
+ machine.wait_for_unit("opentelemetry-collector.service")
+ machine.wait_for_open_port(${toString port})
+
+ event = {
+ "resourceLogs": [
+ {
+ "resource": {"attributes": []},
+ "scopeLogs": [
+ {
+ "logRecords": [
+ {
+ "timeUnixNano": str(time.time_ns()),
+ "severityNumber": 9,
+ "severityText": "Info",
+ "name": "logTest",
+ "body": {
+ "stringValue": flag
+ },
+ "attributes": []
+ },
+ ]
+ }
+ ]
+ }
+ ]
+ }
+
+ response = requests.post("http://localhost:${toString port}/v1/logs", json=event)
+ assert response.status_code == 200
+ assert flag in machine.execute("journalctl -u opentelemetry-collector")[-1]
+ '';
+}
diff --git a/nixos/tests/openvscode-server.nix b/nixos/tests/openvscode-server.nix
index eaef459530ba..89d3817b2cf3 100644
--- a/nixos/tests/openvscode-server.nix
+++ b/nixos/tests/openvscode-server.nix
@@ -1,26 +1,24 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "openvscode-server";
+{ pkgs, lib, ... }:
+{
+ name = "openvscode-server";
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.openvscode-server = {
- enable = true;
- withoutConnectionToken = true;
- };
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.openvscode-server = {
+ enable = true;
+ withoutConnectionToken = true;
};
- };
+ };
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("openvscode-server.service")
- machine.wait_for_open_port(3000)
- machine.succeed("curl -k --fail http://localhost:3000", timeout=10)
- '';
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("openvscode-server.service")
+ machine.wait_for_open_port(3000)
+ machine.succeed("curl -k --fail http://localhost:3000", timeout=10)
+ '';
- meta.maintainers = [ lib.maintainers.drupol ];
- }
-)
+ meta.maintainers = [ lib.maintainers.drupol ];
+}
diff --git a/nixos/tests/orangefs.nix b/nixos/tests/orangefs.nix
index d388826dbf62..fe9335f74981 100644
--- a/nixos/tests/orangefs.nix
+++ b/nixos/tests/orangefs.nix
@@ -1,91 +1,89 @@
-import ./make-test-python.nix (
- { ... }:
+{ ... }:
- let
- server =
- { pkgs, ... }:
- {
- networking.firewall.allowedTCPPorts = [ 3334 ];
- boot.initrd.postDeviceCommands = ''
- ${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
- '';
+let
+ server =
+ { pkgs, ... }:
+ {
+ networking.firewall.allowedTCPPorts = [ 3334 ];
+ boot.initrd.postDeviceCommands = ''
+ ${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
+ '';
- virtualisation.emptyDiskImages = [ 4096 ];
+ virtualisation.emptyDiskImages = [ 4096 ];
- virtualisation.fileSystems = {
- "/data" = {
- device = "/dev/disk/by-label/data";
- fsType = "ext4";
- };
- };
-
- services.orangefs.server = {
- enable = true;
- dataStorageSpace = "/data/storage";
- metadataStorageSpace = "/data/meta";
- servers = {
- server1 = "tcp://server1:3334";
- server2 = "tcp://server2:3334";
- };
+ virtualisation.fileSystems = {
+ "/data" = {
+ device = "/dev/disk/by-label/data";
+ fsType = "ext4";
};
};
- client =
- { lib, ... }:
- {
- networking.firewall.enable = true;
-
- services.orangefs.client = {
- enable = true;
- fileSystems = [
- {
- target = "tcp://server1:3334/orangefs";
- mountPoint = "/orangefs";
- }
- ];
+ services.orangefs.server = {
+ enable = true;
+ dataStorageSpace = "/data/storage";
+ metadataStorageSpace = "/data/meta";
+ servers = {
+ server1 = "tcp://server1:3334";
+ server2 = "tcp://server2:3334";
};
};
-
- in
- {
- name = "orangefs";
-
- nodes = {
- server1 = server;
- server2 = server;
-
- client1 = client;
- client2 = client;
};
- testScript = ''
- # format storage
- for server in server1, server2:
- server.start()
- server.wait_for_unit("multi-user.target")
- server.succeed("mkdir -p /data/storage /data/meta")
- server.succeed("chown orangefs:orangefs /data/storage /data/meta")
- server.succeed("chmod 0770 /data/storage /data/meta")
- server.succeed(
- "sudo -g orangefs -u orangefs pvfs2-server -f /etc/orangefs/server.conf"
- )
+ client =
+ { lib, ... }:
+ {
+ networking.firewall.enable = true;
- # start services after storage is formatted on all machines
- for server in server1, server2:
- server.succeed("systemctl start orangefs-server.service")
+ services.orangefs.client = {
+ enable = true;
+ fileSystems = [
+ {
+ target = "tcp://server1:3334/orangefs";
+ mountPoint = "/orangefs";
+ }
+ ];
+ };
+ };
- with subtest("clients can reach and mount the FS"):
- for client in client1, client2:
- client.start()
- client.wait_for_unit("orangefs-client.service")
- # Both servers need to be reachable
- client.succeed("pvfs2-check-server -h server1 -f orangefs -n tcp -p 3334")
- client.succeed("pvfs2-check-server -h server2 -f orangefs -n tcp -p 3334")
- client.wait_for_unit("orangefs.mount")
+in
+{
+ name = "orangefs";
- with subtest("R/W test between clients"):
- client1.succeed("echo test > /orangefs/file1")
- client2.succeed("grep test /orangefs/file1")
- '';
- }
-)
+ nodes = {
+ server1 = server;
+ server2 = server;
+
+ client1 = client;
+ client2 = client;
+ };
+
+ testScript = ''
+ # format storage
+ for server in server1, server2:
+ server.start()
+ server.wait_for_unit("multi-user.target")
+ server.succeed("mkdir -p /data/storage /data/meta")
+ server.succeed("chown orangefs:orangefs /data/storage /data/meta")
+ server.succeed("chmod 0770 /data/storage /data/meta")
+ server.succeed(
+ "sudo -g orangefs -u orangefs pvfs2-server -f /etc/orangefs/server.conf"
+ )
+
+ # start services after storage is formatted on all machines
+ for server in server1, server2:
+ server.succeed("systemctl start orangefs-server.service")
+
+ with subtest("clients can reach and mount the FS"):
+ for client in client1, client2:
+ client.start()
+ client.wait_for_unit("orangefs-client.service")
+ # Both servers need to be reachable
+ client.succeed("pvfs2-check-server -h server1 -f orangefs -n tcp -p 3334")
+ client.succeed("pvfs2-check-server -h server2 -f orangefs -n tcp -p 3334")
+ client.wait_for_unit("orangefs.mount")
+
+ with subtest("R/W test between clients"):
+ client1.succeed("echo test > /orangefs/file1")
+ client2.succeed("grep test /orangefs/file1")
+ '';
+}
diff --git a/nixos/tests/osrm-backend.nix b/nixos/tests/osrm-backend.nix
index 304450430888..ad9485d6a944 100644
--- a/nixos/tests/osrm-backend.nix
+++ b/nixos/tests/osrm-backend.nix
@@ -1,66 +1,64 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- port = 5000;
- in
- {
- name = "osrm-backend";
- meta.maintainers = [ lib.maintainers.erictapen ];
+{ pkgs, lib, ... }:
+let
+ port = 5000;
+in
+{
+ name = "osrm-backend";
+ meta.maintainers = [ lib.maintainers.erictapen ];
- nodes.machine =
- { config, pkgs, ... }:
- {
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
- services.osrm = {
- enable = true;
- inherit port;
- dataFile =
- let
- filename = "monaco";
- osrm-data = pkgs.stdenv.mkDerivation {
- name = "osrm-data";
+ services.osrm = {
+ enable = true;
+ inherit port;
+ dataFile =
+ let
+ filename = "monaco";
+ osrm-data = pkgs.stdenv.mkDerivation {
+ name = "osrm-data";
- buildInputs = [ pkgs.osrm-backend ];
+ buildInputs = [ pkgs.osrm-backend ];
- # This is a pbf file of monaco, downloaded at 2019-01-04 from
- # http://download.geofabrik.de/europe/monaco-latest.osm.pbf
- # as apparently no provider of OSM files guarantees immutability,
- # this is hosted as a gist on GitHub.
- src = pkgs.fetchgit {
- url = "https://gist.github.com/erictapen/01e39f73a6c856eac53ba809a94cdb83";
- rev = "9b1ff0f24deb40e5cf7df51f843dbe860637b8ce";
- sha256 = "1scqhmrfnpwsy5i2a9jpggqnvfgj4hv9p4qyvc79321pzkbv59nx";
- };
-
- buildCommand = ''
- cp $src/${filename}.osm.pbf .
- ${pkgs.osrm-backend}/bin/osrm-extract -p ${pkgs.osrm-backend}/share/osrm/profiles/car.lua ${filename}.osm.pbf
- ${pkgs.osrm-backend}/bin/osrm-partition ${filename}.osrm
- ${pkgs.osrm-backend}/bin/osrm-customize ${filename}.osrm
- mkdir -p $out
- cp ${filename}* $out/
- '';
+ # This is a pbf file of monaco, downloaded at 2019-01-04 from
+ # http://download.geofabrik.de/europe/monaco-latest.osm.pbf
+ # as apparently no provider of OSM files guarantees immutability,
+ # this is hosted as a gist on GitHub.
+ src = pkgs.fetchgit {
+ url = "https://gist.github.com/erictapen/01e39f73a6c856eac53ba809a94cdb83";
+ rev = "9b1ff0f24deb40e5cf7df51f843dbe860637b8ce";
+ sha256 = "1scqhmrfnpwsy5i2a9jpggqnvfgj4hv9p4qyvc79321pzkbv59nx";
};
- in
- "${osrm-data}/${filename}.osrm";
- };
- environment.systemPackages = [ pkgs.jq ];
+ buildCommand = ''
+ cp $src/${filename}.osm.pbf .
+ ${pkgs.osrm-backend}/bin/osrm-extract -p ${pkgs.osrm-backend}/share/osrm/profiles/car.lua ${filename}.osm.pbf
+ ${pkgs.osrm-backend}/bin/osrm-partition ${filename}.osrm
+ ${pkgs.osrm-backend}/bin/osrm-customize ${filename}.osrm
+ mkdir -p $out
+ cp ${filename}* $out/
+ '';
+ };
+ in
+ "${osrm-data}/${filename}.osrm";
};
- testScript =
- let
- query = "http://localhost:${toString port}/route/v1/driving/7.41720,43.73304;7.42463,43.73886?steps=true";
- in
- ''
- machine.wait_for_unit("osrm.service")
- machine.wait_for_open_port(${toString port})
- assert "Boulevard Rainier III" in machine.succeed(
- "curl --fail --silent '${query}' | jq .waypoints[0].name"
- )
- assert "Avenue de la Costa" in machine.succeed(
- "curl --fail --silent '${query}' | jq .waypoints[1].name"
- )
- '';
- }
-)
+ environment.systemPackages = [ pkgs.jq ];
+ };
+
+ testScript =
+ let
+ query = "http://localhost:${toString port}/route/v1/driving/7.41720,43.73304;7.42463,43.73886?steps=true";
+ in
+ ''
+ machine.wait_for_unit("osrm.service")
+ machine.wait_for_open_port(${toString port})
+ assert "Boulevard Rainier III" in machine.succeed(
+ "curl --fail --silent '${query}' | jq .waypoints[0].name"
+ )
+ assert "Avenue de la Costa" in machine.succeed(
+ "curl --fail --silent '${query}' | jq .waypoints[1].name"
+ )
+ '';
+}
diff --git a/nixos/tests/outline.nix b/nixos/tests/outline.nix
index 52f46f533878..4beb58a3c408 100644
--- a/nixos/tests/outline.nix
+++ b/nixos/tests/outline.nix
@@ -1,57 +1,55 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- accessKey = "BKIKJAA5BMMU2RHO6IBB";
- secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
- secretKeyFile = pkgs.writeText "outline-secret-key" ''
- ${secretKey}
- '';
- rootCredentialsFile = pkgs.writeText "minio-credentials-full" ''
- MINIO_ROOT_USER=${accessKey}
- MINIO_ROOT_PASSWORD=${secretKey}
- '';
- in
- {
- name = "outline";
+{ pkgs, lib, ... }:
+let
+ accessKey = "BKIKJAA5BMMU2RHO6IBB";
+ secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
+ secretKeyFile = pkgs.writeText "outline-secret-key" ''
+ ${secretKey}
+ '';
+ rootCredentialsFile = pkgs.writeText "minio-credentials-full" ''
+ MINIO_ROOT_USER=${accessKey}
+ MINIO_ROOT_PASSWORD=${secretKey}
+ '';
+in
+{
+ name = "outline";
- meta.maintainers = lib.teams.cyberus.members;
+ meta.maintainers = lib.teams.cyberus.members;
- nodes = {
- outline =
- { pkgs, config, ... }:
- {
- nixpkgs.config.allowUnfree = true;
- environment.systemPackages = [ pkgs.minio-client ];
- services.outline = {
- enable = true;
- forceHttps = false;
- storage = {
- inherit accessKey secretKeyFile;
- uploadBucketUrl = "http://localhost:9000";
- uploadBucketName = "outline";
- region = config.services.minio.region;
- };
- };
- services.minio = {
- enable = true;
- inherit rootCredentialsFile;
+ nodes = {
+ outline =
+ { pkgs, config, ... }:
+ {
+ nixpkgs.config.allowUnfree = true;
+ environment.systemPackages = [ pkgs.minio-client ];
+ services.outline = {
+ enable = true;
+ forceHttps = false;
+ storage = {
+ inherit accessKey secretKeyFile;
+ uploadBucketUrl = "http://localhost:9000";
+ uploadBucketName = "outline";
+ region = config.services.minio.region;
};
};
- };
+ services.minio = {
+ enable = true;
+ inherit rootCredentialsFile;
+ };
+ };
+ };
- testScript = ''
- machine.wait_for_unit("minio.service")
- machine.wait_for_open_port(9000)
+ testScript = ''
+ machine.wait_for_unit("minio.service")
+ machine.wait_for_open_port(9000)
- # Create a test bucket on the server
- machine.succeed(
- "mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
- )
- machine.succeed("mc mb minio/outline")
+ # Create a test bucket on the server
+ machine.succeed(
+ "mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
+ )
+ machine.succeed("mc mb minio/outline")
- outline.wait_for_unit("outline.service")
- outline.wait_for_open_port(3000)
- outline.succeed("curl --fail http://localhost:3000/")
- '';
- }
-)
+ outline.wait_for_unit("outline.service")
+ outline.wait_for_open_port(3000)
+ outline.succeed("curl --fail http://localhost:3000/")
+ '';
+}
diff --git a/nixos/tests/overlayfs.nix b/nixos/tests/overlayfs.nix
index cd4843229943..93300ed8e812 100644
--- a/nixos/tests/overlayfs.nix
+++ b/nixos/tests/overlayfs.nix
@@ -1,52 +1,50 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "overlayfs";
- meta.maintainers = with pkgs.lib.maintainers; [ bachp ];
+{ pkgs, ... }:
+{
+ name = "overlayfs";
+ meta.maintainers = with pkgs.lib.maintainers; [ bachp ];
- nodes.machine =
- { pkgs, ... }:
- {
- virtualisation.emptyDiskImages = [ 512 ];
- networking.hostId = "deadbeef";
- environment.systemPackages = with pkgs; [ parted ];
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ virtualisation.emptyDiskImages = [ 512 ];
+ networking.hostId = "deadbeef";
+ environment.systemPackages = with pkgs; [ parted ];
+ };
- testScript = ''
- machine.succeed("ls /dev")
+ testScript = ''
+ machine.succeed("ls /dev")
- machine.succeed("mkdir -p /tmp/mnt")
+ machine.succeed("mkdir -p /tmp/mnt")
- # Test ext4 + overlayfs
- machine.succeed(
- 'mkfs.ext4 -F -L overlay-ext4 /dev/vdb',
- 'mount -t ext4 /dev/vdb /tmp/mnt',
- 'mkdir -p /tmp/mnt/upper /tmp/mnt/lower /tmp/mnt/work /tmp/mnt/merged',
- # Setup some existing files
- 'echo Replace > /tmp/mnt/lower/replace.txt',
- 'echo Append > /tmp/mnt/lower/append.txt',
- 'echo Overwrite > /tmp/mnt/lower/overwrite.txt',
- 'mount -t overlay overlay -o lowerdir=/tmp/mnt/lower,upperdir=/tmp/mnt/upper,workdir=/tmp/mnt/work /tmp/mnt/merged',
- # Test new
- 'echo New > /tmp/mnt/merged/new.txt',
- '[[ "$(cat /tmp/mnt/merged/new.txt)" == New ]]',
- # Test replace
- '[[ "$(cat /tmp/mnt/merged/replace.txt)" == Replace ]]',
- 'echo Replaced > /tmp/mnt/merged/replace-tmp.txt',
- 'mv /tmp/mnt/merged/replace-tmp.txt /tmp/mnt/merged/replace.txt',
- '[[ "$(cat /tmp/mnt/merged/replace.txt)" == Replaced ]]',
- # Overwrite
- '[[ "$(cat /tmp/mnt/merged/overwrite.txt)" == Overwrite ]]',
- 'echo Overwritten > /tmp/mnt/merged/overwrite.txt',
- '[[ "$(cat /tmp/mnt/merged/overwrite.txt)" == Overwritten ]]',
- # Test append
- '[[ "$(cat /tmp/mnt/merged/append.txt)" == Append ]]',
- 'echo ed >> /tmp/mnt/merged/append.txt',
- '[[ "$(cat /tmp/mnt/merged/append.txt)" == "Append\ned" ]]',
- 'umount /tmp/mnt/merged',
- 'umount /tmp/mnt',
- 'udevadm settle',
- )
- '';
- }
-)
+ # Test ext4 + overlayfs
+ machine.succeed(
+ 'mkfs.ext4 -F -L overlay-ext4 /dev/vdb',
+ 'mount -t ext4 /dev/vdb /tmp/mnt',
+ 'mkdir -p /tmp/mnt/upper /tmp/mnt/lower /tmp/mnt/work /tmp/mnt/merged',
+ # Setup some existing files
+ 'echo Replace > /tmp/mnt/lower/replace.txt',
+ 'echo Append > /tmp/mnt/lower/append.txt',
+ 'echo Overwrite > /tmp/mnt/lower/overwrite.txt',
+ 'mount -t overlay overlay -o lowerdir=/tmp/mnt/lower,upperdir=/tmp/mnt/upper,workdir=/tmp/mnt/work /tmp/mnt/merged',
+ # Test new
+ 'echo New > /tmp/mnt/merged/new.txt',
+ '[[ "$(cat /tmp/mnt/merged/new.txt)" == New ]]',
+ # Test replace
+ '[[ "$(cat /tmp/mnt/merged/replace.txt)" == Replace ]]',
+ 'echo Replaced > /tmp/mnt/merged/replace-tmp.txt',
+ 'mv /tmp/mnt/merged/replace-tmp.txt /tmp/mnt/merged/replace.txt',
+ '[[ "$(cat /tmp/mnt/merged/replace.txt)" == Replaced ]]',
+ # Overwrite
+ '[[ "$(cat /tmp/mnt/merged/overwrite.txt)" == Overwrite ]]',
+ 'echo Overwritten > /tmp/mnt/merged/overwrite.txt',
+ '[[ "$(cat /tmp/mnt/merged/overwrite.txt)" == Overwritten ]]',
+ # Test append
+ '[[ "$(cat /tmp/mnt/merged/append.txt)" == Append ]]',
+ 'echo ed >> /tmp/mnt/merged/append.txt',
+ '[[ "$(cat /tmp/mnt/merged/append.txt)" == "Append\ned" ]]',
+ 'umount /tmp/mnt/merged',
+ 'umount /tmp/mnt',
+ 'udevadm settle',
+ )
+ '';
+}
diff --git a/nixos/tests/owncast.nix b/nixos/tests/owncast.nix
index a081cd5b544d..14fa2a737a71 100644
--- a/nixos/tests/owncast.nix
+++ b/nixos/tests/owncast.nix
@@ -1,75 +1,73 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "owncast";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ MayNiklas ];
- };
+{ pkgs, ... }:
+{
+ name = "owncast";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ MayNiklas ];
+ };
- nodes = {
- client =
- { pkgs, ... }:
- with pkgs.lib;
- {
- networking = {
- dhcpcd.enable = false;
- interfaces.eth1.ipv6.addresses = mkOverride 0 [
- {
- address = "fd00::2";
- prefixLength = 64;
- }
- ];
- interfaces.eth1.ipv4.addresses = mkOverride 0 [
- {
- address = "192.168.1.2";
- prefixLength = 24;
- }
- ];
- };
+ nodes = {
+ client =
+ { pkgs, ... }:
+ with pkgs.lib;
+ {
+ networking = {
+ dhcpcd.enable = false;
+ interfaces.eth1.ipv6.addresses = mkOverride 0 [
+ {
+ address = "fd00::2";
+ prefixLength = 64;
+ }
+ ];
+ interfaces.eth1.ipv4.addresses = mkOverride 0 [
+ {
+ address = "192.168.1.2";
+ prefixLength = 24;
+ }
+ ];
};
- server =
- { pkgs, ... }:
- with pkgs.lib;
- {
- networking = {
- dhcpcd.enable = false;
- useNetworkd = true;
- useDHCP = false;
- interfaces.eth1.ipv6.addresses = mkOverride 0 [
- {
- address = "fd00::1";
- prefixLength = 64;
- }
- ];
- interfaces.eth1.ipv4.addresses = mkOverride 0 [
- {
- address = "192.168.1.1";
- prefixLength = 24;
- }
- ];
+ };
+ server =
+ { pkgs, ... }:
+ with pkgs.lib;
+ {
+ networking = {
+ dhcpcd.enable = false;
+ useNetworkd = true;
+ useDHCP = false;
+ interfaces.eth1.ipv6.addresses = mkOverride 0 [
+ {
+ address = "fd00::1";
+ prefixLength = 64;
+ }
+ ];
+ interfaces.eth1.ipv4.addresses = mkOverride 0 [
+ {
+ address = "192.168.1.1";
+ prefixLength = 24;
+ }
+ ];
- firewall.allowedTCPPorts = [ 8080 ];
- };
-
- services.owncast = {
- enable = true;
- listen = "0.0.0.0";
- };
+ firewall.allowedTCPPorts = [ 8080 ];
};
- };
- testScript = ''
- start_all()
+ services.owncast = {
+ enable = true;
+ listen = "0.0.0.0";
+ };
+ };
+ };
- client.systemctl("start network-online.target")
- server.systemctl("start network-online.target")
- client.wait_for_unit("network-online.target")
- server.wait_for_unit("network-online.target")
- server.wait_for_unit("owncast.service")
- server.wait_until_succeeds("ss -ntl | grep -q 8080")
+ testScript = ''
+ start_all()
- client.succeed("curl http://192.168.1.1:8080/api/status")
- client.succeed("curl http://[fd00::1]:8080/api/status")
- '';
- }
-)
+ client.systemctl("start network-online.target")
+ server.systemctl("start network-online.target")
+ client.wait_for_unit("network-online.target")
+ server.wait_for_unit("network-online.target")
+ server.wait_for_unit("owncast.service")
+ server.wait_until_succeeds("ss -ntl | grep -q 8080")
+
+ client.succeed("curl http://192.168.1.1:8080/api/status")
+ client.succeed("curl http://[fd00::1]:8080/api/status")
+ '';
+}
diff --git a/nixos/tests/pacemaker.nix b/nixos/tests/pacemaker.nix
index 6b711ad94552..826c4be7df14 100644
--- a/nixos/tests/pacemaker.nix
+++ b/nixos/tests/pacemaker.nix
@@ -1,118 +1,116 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- rec {
- name = "pacemaker";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ astro ];
+{ pkgs, lib, ... }:
+rec {
+ name = "pacemaker";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ astro ];
+ };
+
+ nodes =
+ let
+ node = i: {
+ networking.interfaces.eth1.ipv4.addresses = [
+ {
+ address = "192.168.0.${toString i}";
+ prefixLength = 24;
+ }
+ ];
+
+ services.corosync = {
+ enable = true;
+ clusterName = "zentralwerk-network";
+ nodelist = lib.imap (i: name: {
+ nodeid = i;
+ inherit name;
+ ring_addrs = [
+ (builtins.head nodes.${name}.networking.interfaces.eth1.ipv4.addresses).address
+ ];
+ }) (builtins.attrNames nodes);
+ };
+ environment.etc."corosync/authkey" = {
+ source =
+ builtins.toFile "authkey"
+ # minimum length: 128 bytes
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
+ mode = "0400";
+ };
+
+ services.pacemaker.enable = true;
+
+ # used for pacemaker resource
+ systemd.services.ha-cat = {
+ description = "Highly available netcat";
+ serviceConfig.ExecStart = "${pkgs.netcat}/bin/nc -l discard";
+ };
+ };
+ in
+ {
+ node1 = node 1;
+ node2 = node 2;
+ node3 = node 3;
};
- nodes =
- let
- node = i: {
- networking.interfaces.eth1.ipv4.addresses = [
- {
- address = "192.168.0.${toString i}";
- prefixLength = 24;
- }
- ];
-
- services.corosync = {
- enable = true;
- clusterName = "zentralwerk-network";
- nodelist = lib.imap (i: name: {
- nodeid = i;
- inherit name;
- ring_addrs = [
- (builtins.head nodes.${name}.networking.interfaces.eth1.ipv4.addresses).address
- ];
- }) (builtins.attrNames nodes);
- };
- environment.etc."corosync/authkey" = {
- source =
- builtins.toFile "authkey"
- # minimum length: 128 bytes
- "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
- mode = "0400";
- };
-
- services.pacemaker.enable = true;
-
- # used for pacemaker resource
- systemd.services.ha-cat = {
- description = "Highly available netcat";
- serviceConfig.ExecStart = "${pkgs.netcat}/bin/nc -l discard";
- };
- };
- in
- {
- node1 = node 1;
- node2 = node 2;
- node3 = node 3;
- };
-
- # sets up pacemaker with resources configuration, then crashes a
- # node and waits for service restart on another node
- testScript =
- let
- resources = builtins.toFile "cib-resources.xml" ''
-
-
-
-
-
-
-
-
-
- '';
- in
- ''
- import re
- import time
-
- start_all()
-
- ${lib.concatMapStrings (node: ''
- ${node}.wait_until_succeeds("corosync-quorumtool")
- ${node}.wait_for_unit("pacemaker.service")
- '') (builtins.attrNames nodes)}
-
- # No STONITH device
- node1.succeed("crm_attribute -t crm_config -n stonith-enabled -v false")
- # Configure the cat resource
- node1.succeed("cibadmin --replace --scope resources --xml-file ${resources}")
-
- # wait until the service is started
- while True:
- output = node1.succeed("crm_resource -r cat --locate")
- match = re.search("is running on: (.+)", output)
- if match:
- for machine in machines:
- if machine.name == match.group(1):
- current_node = machine
- break
- time.sleep(1)
-
- current_node.log("Service running here!")
- current_node.crash()
-
- # pick another node that's still up
- for machine in machines:
- if machine.booted:
- check_node = machine
- # find where the service has been started next
- while True:
- output = check_node.succeed("crm_resource -r cat --locate")
- match = re.search("is running on: (.+)", output)
- # output will remain the old current_node until the crash is detected by pacemaker
- if match and match.group(1) != current_node.name:
- for machine in machines:
- if machine.name == match.group(1):
- next_node = machine
- break
- time.sleep(1)
-
- next_node.log("Service migrated here!")
+ # sets up pacemaker with resources configuration, then crashes a
+ # node and waits for service restart on another node
+ testScript =
+ let
+ resources = builtins.toFile "cib-resources.xml" ''
+
+
+
+
+
+
+
+
+
'';
- }
-)
+ in
+ ''
+ import re
+ import time
+
+ start_all()
+
+ ${lib.concatMapStrings (node: ''
+ ${node}.wait_until_succeeds("corosync-quorumtool")
+ ${node}.wait_for_unit("pacemaker.service")
+ '') (builtins.attrNames nodes)}
+
+ # No STONITH device
+ node1.succeed("crm_attribute -t crm_config -n stonith-enabled -v false")
+ # Configure the cat resource
+ node1.succeed("cibadmin --replace --scope resources --xml-file ${resources}")
+
+ # wait until the service is started
+ while True:
+ output = node1.succeed("crm_resource -r cat --locate")
+ match = re.search("is running on: (.+)", output)
+ if match:
+ for machine in machines:
+ if machine.name == match.group(1):
+ current_node = machine
+ break
+ time.sleep(1)
+
+ current_node.log("Service running here!")
+ current_node.crash()
+
+ # pick another node that's still up
+ for machine in machines:
+ if machine.booted:
+ check_node = machine
+ # find where the service has been started next
+ while True:
+ output = check_node.succeed("crm_resource -r cat --locate")
+ match = re.search("is running on: (.+)", output)
+ # output will remain the old current_node until the crash is detected by pacemaker
+ if match and match.group(1) != current_node.name:
+ for machine in machines:
+ if machine.name == match.group(1):
+ next_node = machine
+ break
+ time.sleep(1)
+
+ next_node.log("Service migrated here!")
+ '';
+}
diff --git a/nixos/tests/packagekit.nix b/nixos/tests/packagekit.nix
index 1dc248217b11..edeaabc5463f 100644
--- a/nixos/tests/packagekit.nix
+++ b/nixos/tests/packagekit.nix
@@ -1,30 +1,28 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "packagekit";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ peterhoeg ];
+{ pkgs, ... }:
+{
+ name = "packagekit";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ peterhoeg ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ environment.systemPackages = with pkgs; [ dbus ];
+ services.packagekit = {
+ enable = true;
+ };
};
- nodes.machine =
- { ... }:
- {
- environment.systemPackages = with pkgs; [ dbus ];
- services.packagekit = {
- enable = true;
- };
- };
+ testScript = ''
+ start_all()
- testScript = ''
- start_all()
+ # send a dbus message to activate the service
+ machine.succeed(
+ "dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.DBus.Introspectable.Introspect"
+ )
- # send a dbus message to activate the service
- machine.succeed(
- "dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.DBus.Introspectable.Introspect"
- )
-
- # so now it should be running
- machine.wait_for_unit("packagekit.service")
- '';
- }
-)
+ # so now it should be running
+ machine.wait_for_unit("packagekit.service")
+ '';
+}
diff --git a/nixos/tests/pam/pam-file-contents.nix b/nixos/tests/pam/pam-file-contents.nix
index 50551d8fd340..c0342ebaaf7b 100644
--- a/nixos/tests/pam/pam-file-contents.nix
+++ b/nixos/tests/pam/pam-file-contents.nix
@@ -1,32 +1,30 @@
let
name = "pam";
in
-import ../make-test-python.nix (
- { pkgs, ... }:
- {
- name = "pam-file-contents";
+{ pkgs, ... }:
+{
+ name = "pam-file-contents";
- nodes.machine =
- { ... }:
- {
- imports = [ ../../modules/profiles/minimal.nix ];
+ nodes.machine =
+ { ... }:
+ {
+ imports = [ ../../modules/profiles/minimal.nix ];
- security.krb5.enable = true;
+ security.krb5.enable = true;
+ users = {
+ mutableUsers = false;
users = {
- mutableUsers = false;
- users = {
- user = {
- isNormalUser = true;
- };
+ user = {
+ isNormalUser = true;
};
};
};
+ };
- testScript =
- builtins.replaceStrings
- [ "@@pam@@" "@@pam_ccreds@@" "@@pam_krb5@@" ]
- [ pkgs.pam.outPath pkgs.pam_ccreds.outPath pkgs.pam_krb5.outPath ]
- (builtins.readFile ./test_chfn.py);
- }
-)
+ testScript =
+ builtins.replaceStrings
+ [ "@@pam@@" "@@pam_ccreds@@" "@@pam_krb5@@" ]
+ [ pkgs.pam.outPath pkgs.pam_ccreds.outPath pkgs.pam_krb5.outPath ]
+ (builtins.readFile ./test_chfn.py);
+}
diff --git a/nixos/tests/pam/pam-oath-login.nix b/nixos/tests/pam/pam-oath-login.nix
index 25602b72d35c..f22d5607db4f 100644
--- a/nixos/tests/pam/pam-oath-login.nix
+++ b/nixos/tests/pam/pam-oath-login.nix
@@ -1,109 +1,107 @@
-import ../make-test-python.nix (
- { ... }:
+{ ... }:
- let
- oathSnakeoilSecret = "cdd4083ef8ff1fa9178c6d46bfb1a3";
+let
+ oathSnakeoilSecret = "cdd4083ef8ff1fa9178c6d46bfb1a3";
- # With HOTP mode the password is calculated based on a counter of
- # how many passwords have been made. In this env, we'll always be on
- # the 0th counter, so the password is static.
- #
- # Generated in nix-shell -p oath-toolkit
- # via: oathtool -v -d6 -w10 cdd4083ef8ff1fa9178c6d46bfb1a3
- # and picking a the first 4:
- oathSnakeOilPassword1 = "143349";
- oathSnakeOilPassword2 = "801753";
+ # With HOTP mode the password is calculated based on a counter of
+ # how many passwords have been made. In this env, we'll always be on
+ # the 0th counter, so the password is static.
+ #
+ # Generated in nix-shell -p oath-toolkit
+ # via: oathtool -v -d6 -w10 cdd4083ef8ff1fa9178c6d46bfb1a3
+ # and picking a the first 4:
+ oathSnakeOilPassword1 = "143349";
+ oathSnakeOilPassword2 = "801753";
- alicePassword = "foobar";
- # Generated via: mkpasswd -m sha-512 and passing in "foobar"
- hashedAlicePassword = "$6$MsMrE1q.1HrCgTS$Vq2e/uILzYjSN836TobAyN9xh9oi7EmCmucnZID25qgPoibkw8qTCugiAPnn4eCGvn1A.7oEBFJaaGUaJsQQY.";
+ alicePassword = "foobar";
+ # Generated via: mkpasswd -m sha-512 and passing in "foobar"
+ hashedAlicePassword = "$6$MsMrE1q.1HrCgTS$Vq2e/uILzYjSN836TobAyN9xh9oi7EmCmucnZID25qgPoibkw8qTCugiAPnn4eCGvn1A.7oEBFJaaGUaJsQQY.";
- in
- {
- name = "pam-oath-login";
+in
+{
+ name = "pam-oath-login";
- nodes.machine =
- { ... }:
- {
- security.pam.oath = {
- enable = true;
- };
-
- users.users.alice = {
- isNormalUser = true;
- name = "alice";
- uid = 1000;
- hashedPassword = hashedAlicePassword;
- extraGroups = [ "wheel" ];
- createHome = true;
- home = "/home/alice";
- };
-
- systemd.services.setupOathSnakeoilFile = {
- wantedBy = [ "default.target" ];
- before = [ "default.target" ];
- unitConfig = {
- type = "oneshot";
- RemainAfterExit = true;
- };
- script = ''
- touch /etc/users.oath
- chmod 600 /etc/users.oath
- chown root /etc/users.oath
- echo "HOTP/E/6 alice - ${oathSnakeoilSecret}" > /etc/users.oath
- '';
- };
+ nodes.machine =
+ { ... }:
+ {
+ security.pam.oath = {
+ enable = true;
};
- testScript = ''
- def switch_to_tty(tty_number):
- machine.fail(f"pgrep -f 'agetty.*tty{tty_number}'")
- machine.send_key(f"alt-f{tty_number}")
- machine.wait_until_succeeds(f"[ $(fgconsole) = {tty_number} ]")
- machine.wait_for_unit(f"getty@tty{tty_number}.service")
- machine.wait_until_succeeds(f"pgrep -f 'agetty.*tty{tty_number}'")
+ users.users.alice = {
+ isNormalUser = true;
+ name = "alice";
+ uid = 1000;
+ hashedPassword = hashedAlicePassword;
+ extraGroups = [ "wheel" ];
+ createHome = true;
+ home = "/home/alice";
+ };
+
+ systemd.services.setupOathSnakeoilFile = {
+ wantedBy = [ "default.target" ];
+ before = [ "default.target" ];
+ unitConfig = {
+ type = "oneshot";
+ RemainAfterExit = true;
+ };
+ script = ''
+ touch /etc/users.oath
+ chmod 600 /etc/users.oath
+ chown root /etc/users.oath
+ echo "HOTP/E/6 alice - ${oathSnakeoilSecret}" > /etc/users.oath
+ '';
+ };
+ };
+
+ testScript = ''
+ def switch_to_tty(tty_number):
+ machine.fail(f"pgrep -f 'agetty.*tty{tty_number}'")
+ machine.send_key(f"alt-f{tty_number}")
+ machine.wait_until_succeeds(f"[ $(fgconsole) = {tty_number} ]")
+ machine.wait_for_unit(f"getty@tty{tty_number}.service")
+ machine.wait_until_succeeds(f"pgrep -f 'agetty.*tty{tty_number}'")
- def enter_user_alice(tty_number):
- machine.wait_until_tty_matches(tty_number, "login: ")
- machine.send_chars("alice\n")
- machine.wait_until_tty_matches(tty_number, "login: alice")
- machine.wait_until_succeeds("pgrep login")
- machine.wait_until_tty_matches(tty_number, "One-time password")
+ def enter_user_alice(tty_number):
+ machine.wait_until_tty_matches(tty_number, "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches(tty_number, "login: alice")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches(tty_number, "One-time password")
- machine.wait_for_unit("multi-user.target")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
- machine.screenshot("postboot")
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+ machine.screenshot("postboot")
- with subtest("Invalid password"):
- switch_to_tty("2")
- enter_user_alice("2")
+ with subtest("Invalid password"):
+ switch_to_tty("2")
+ enter_user_alice("2")
- machine.send_chars("${oathSnakeOilPassword1}\n")
- machine.wait_until_tty_matches("2", "Password: ")
- machine.send_chars("blorg\n")
- machine.wait_until_tty_matches("2", "Login incorrect")
+ machine.send_chars("${oathSnakeOilPassword1}\n")
+ machine.wait_until_tty_matches("2", "Password: ")
+ machine.send_chars("blorg\n")
+ machine.wait_until_tty_matches("2", "Login incorrect")
- with subtest("Invalid oath token"):
- switch_to_tty("3")
- enter_user_alice("3")
+ with subtest("Invalid oath token"):
+ switch_to_tty("3")
+ enter_user_alice("3")
- machine.send_chars("000000\n")
- machine.wait_until_tty_matches("3", "Login incorrect")
- machine.wait_until_tty_matches("3", "login:")
+ machine.send_chars("000000\n")
+ machine.wait_until_tty_matches("3", "Login incorrect")
+ machine.wait_until_tty_matches("3", "login:")
- with subtest("Happy path: Both passwords are mandatory to get us in"):
- switch_to_tty("4")
- enter_user_alice("4")
+ with subtest("Happy path: Both passwords are mandatory to get us in"):
+ switch_to_tty("4")
+ enter_user_alice("4")
- machine.send_chars("${oathSnakeOilPassword2}\n")
- machine.wait_until_tty_matches("4", "Password: ")
- machine.send_chars("${alicePassword}\n")
+ machine.send_chars("${oathSnakeOilPassword2}\n")
+ machine.wait_until_tty_matches("4", "Password: ")
+ machine.send_chars("${alicePassword}\n")
- machine.wait_until_succeeds("pgrep -u alice bash")
- machine.send_chars("touch done4\n")
- machine.wait_for_file("/home/alice/done4")
- '';
- }
-)
+ machine.wait_until_succeeds("pgrep -u alice bash")
+ machine.send_chars("touch done4\n")
+ machine.wait_for_file("/home/alice/done4")
+ '';
+}
diff --git a/nixos/tests/pam/pam-u2f.nix b/nixos/tests/pam/pam-u2f.nix
index c889cb9ee2fa..17b9e19e4cc5 100644
--- a/nixos/tests/pam/pam-u2f.nix
+++ b/nixos/tests/pam/pam-u2f.nix
@@ -1,31 +1,29 @@
-import ../make-test-python.nix (
- { ... }:
+{ ... }:
- {
- name = "pam-u2f";
+{
+ name = "pam-u2f";
- nodes.machine =
- { ... }:
- {
- security.pam.u2f = {
- enable = true;
- control = "required";
- settings = {
- cue = true;
- debug = true;
- interactive = true;
- origin = "nixos-test";
- # Freeform option
- userpresence = 1;
- };
+ nodes.machine =
+ { ... }:
+ {
+ security.pam.u2f = {
+ enable = true;
+ control = "required";
+ settings = {
+ cue = true;
+ debug = true;
+ interactive = true;
+ origin = "nixos-test";
+ # Freeform option
+ userpresence = 1;
};
};
+ };
- testScript = ''
- machine.wait_for_unit("multi-user.target")
- machine.succeed(
- 'egrep "auth required .*/lib/security/pam_u2f.so.*cue.*debug.*interactive.*origin=nixos-test.*userpresence=1" /etc/pam.d/ -R'
- )
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed(
+ 'egrep "auth required .*/lib/security/pam_u2f.so.*cue.*debug.*interactive.*origin=nixos-test.*userpresence=1" /etc/pam.d/ -R'
+ )
+ '';
+}
diff --git a/nixos/tests/pam/pam-ussh.nix b/nixos/tests/pam/pam-ussh.nix
index c5eefd12aa3b..bdbbfe16b0fa 100644
--- a/nixos/tests/pam/pam-ussh.nix
+++ b/nixos/tests/pam/pam-ussh.nix
@@ -1,83 +1,81 @@
-import ../make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
- testOnlySSHCredentials =
- pkgs.runCommand "pam-ussh-test-ca"
- {
- nativeBuildInputs = [ pkgs.openssh ];
- }
- ''
- mkdir $out
- ssh-keygen -t ed25519 -N "" -f $out/ca
-
- ssh-keygen -t ed25519 -N "" -f $out/alice
- ssh-keygen -s $out/ca -I "alice user key" -n "alice,root" -V 19700101:forever $out/alice.pub
-
- ssh-keygen -t ed25519 -N "" -f $out/bob
- ssh-keygen -s $out/ca -I "bob user key" -n "bob" -V 19700101:forever $out/bob.pub
- '';
- makeTestScript =
- user:
- pkgs.writeShellScript "pam-ussh-${user}-test-script" ''
- set -euo pipefail
-
- eval $(${pkgs.openssh}/bin/ssh-agent)
-
- mkdir -p $HOME/.ssh
- chmod 700 $HOME/.ssh
- cp ${testOnlySSHCredentials}/${user}{,.pub,-cert.pub} $HOME/.ssh
- chmod 600 $HOME/.ssh/${user}
- chmod 644 $HOME/.ssh/${user}{,-cert}.pub
-
- set -x
-
- ${pkgs.openssh}/bin/ssh-add $HOME/.ssh/${user}
- ${pkgs.openssh}/bin/ssh-add -l &>2
-
- exec sudo id -u -n
- '';
- in
- {
- name = "pam-ussh";
- meta.maintainers = with lib.maintainers; [ lukegb ];
-
- machine =
- { ... }:
+let
+ testOnlySSHCredentials =
+ pkgs.runCommand "pam-ussh-test-ca"
{
- users.users.alice = {
- isNormalUser = true;
- extraGroups = [ "wheel" ];
- };
- users.users.bob = {
- isNormalUser = true;
- extraGroups = [ "wheel" ];
- };
+ nativeBuildInputs = [ pkgs.openssh ];
+ }
+ ''
+ mkdir $out
+ ssh-keygen -t ed25519 -N "" -f $out/ca
- security.pam.ussh = {
- enable = true;
- authorizedPrincipals = "root";
- caFile = "${testOnlySSHCredentials}/ca.pub";
- };
+ ssh-keygen -t ed25519 -N "" -f $out/alice
+ ssh-keygen -s $out/ca -I "alice user key" -n "alice,root" -V 19700101:forever $out/alice.pub
- security.sudo = {
- enable = true;
- extraConfig = ''
- Defaults lecture="never"
- '';
- };
+ ssh-keygen -t ed25519 -N "" -f $out/bob
+ ssh-keygen -s $out/ca -I "bob user key" -n "bob" -V 19700101:forever $out/bob.pub
+ '';
+ makeTestScript =
+ user:
+ pkgs.writeShellScript "pam-ussh-${user}-test-script" ''
+ set -euo pipefail
+
+ eval $(${pkgs.openssh}/bin/ssh-agent)
+
+ mkdir -p $HOME/.ssh
+ chmod 700 $HOME/.ssh
+ cp ${testOnlySSHCredentials}/${user}{,.pub,-cert.pub} $HOME/.ssh
+ chmod 600 $HOME/.ssh/${user}
+ chmod 644 $HOME/.ssh/${user}{,-cert}.pub
+
+ set -x
+
+ ${pkgs.openssh}/bin/ssh-add $HOME/.ssh/${user}
+ ${pkgs.openssh}/bin/ssh-add -l &>2
+
+ exec sudo id -u -n
+ '';
+in
+{
+ name = "pam-ussh";
+ meta.maintainers = with lib.maintainers; [ lukegb ];
+
+ machine =
+ { ... }:
+ {
+ users.users.alice = {
+ isNormalUser = true;
+ extraGroups = [ "wheel" ];
+ };
+ users.users.bob = {
+ isNormalUser = true;
+ extraGroups = [ "wheel" ];
};
- testScript = ''
- with subtest("alice should be allowed to escalate to root"):
- machine.succeed(
- 'su -c "${makeTestScript "alice"}" -l alice | grep root'
- )
+ security.pam.ussh = {
+ enable = true;
+ authorizedPrincipals = "root";
+ caFile = "${testOnlySSHCredentials}/ca.pub";
+ };
- with subtest("bob should not be allowed to escalate to root"):
- machine.fail(
- 'su -c "${makeTestScript "bob"}" -l bob | grep root'
- )
- '';
- }
-)
+ security.sudo = {
+ enable = true;
+ extraConfig = ''
+ Defaults lecture="never"
+ '';
+ };
+ };
+
+ testScript = ''
+ with subtest("alice should be allowed to escalate to root"):
+ machine.succeed(
+ 'su -c "${makeTestScript "alice"}" -l alice | grep root'
+ )
+
+ with subtest("bob should not be allowed to escalate to root"):
+ machine.fail(
+ 'su -c "${makeTestScript "bob"}" -l bob | grep root'
+ )
+ '';
+}
diff --git a/nixos/tests/pam/zfs-key.nix b/nixos/tests/pam/zfs-key.nix
index 2a494eaa5702..9251a3a9173c 100644
--- a/nixos/tests/pam/zfs-key.nix
+++ b/nixos/tests/pam/zfs-key.nix
@@ -1,86 +1,84 @@
-import ../make-test-python.nix (
- { ... }:
+{ ... }:
- let
- userPassword = "password";
- mismatchPass = "mismatch";
- in
- {
- name = "pam-zfs-key";
+let
+ userPassword = "password";
+ mismatchPass = "mismatch";
+in
+{
+ name = "pam-zfs-key";
- nodes.machine =
- { ... }:
- {
- boot.supportedFilesystems = [ "zfs" ];
+ nodes.machine =
+ { ... }:
+ {
+ boot.supportedFilesystems = [ "zfs" ];
- networking.hostId = "12345678";
+ networking.hostId = "12345678";
- security.pam.zfs.enable = true;
+ security.pam.zfs.enable = true;
- users.users = {
- alice = {
- isNormalUser = true;
- password = userPassword;
- };
- bob = {
- isNormalUser = true;
- password = userPassword;
- };
+ users.users = {
+ alice = {
+ isNormalUser = true;
+ password = userPassword;
+ };
+ bob = {
+ isNormalUser = true;
+ password = userPassword;
};
};
+ };
- testScript =
- { nodes, ... }:
- let
- homes = nodes.machine.security.pam.zfs.homes;
- pool = builtins.head (builtins.split "/" homes);
- in
- ''
- machine.wait_for_unit("multi-user.target")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+ testScript =
+ { nodes, ... }:
+ let
+ homes = nodes.machine.security.pam.zfs.homes;
+ pool = builtins.head (builtins.split "/" homes);
+ in
+ ''
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
- with subtest("Create encrypted ZFS datasets"):
- machine.succeed("truncate -s 64M /testpool.img")
- machine.succeed("zpool create -O canmount=off '${pool}' /testpool.img")
- machine.succeed("zfs create -o canmount=off -p '${homes}'")
- machine.succeed("echo ${userPassword} | zfs create -o canmount=noauto -o encryption=on -o keyformat=passphrase '${homes}/alice'")
- machine.succeed("zfs unload-key '${homes}/alice'")
- machine.succeed("echo ${mismatchPass} | zfs create -o canmount=noauto -o encryption=on -o keyformat=passphrase '${homes}/bob'")
- machine.succeed("zfs unload-key '${homes}/bob'")
+ with subtest("Create encrypted ZFS datasets"):
+ machine.succeed("truncate -s 64M /testpool.img")
+ machine.succeed("zpool create -O canmount=off '${pool}' /testpool.img")
+ machine.succeed("zfs create -o canmount=off -p '${homes}'")
+ machine.succeed("echo ${userPassword} | zfs create -o canmount=noauto -o encryption=on -o keyformat=passphrase '${homes}/alice'")
+ machine.succeed("zfs unload-key '${homes}/alice'")
+ machine.succeed("echo ${mismatchPass} | zfs create -o canmount=noauto -o encryption=on -o keyformat=passphrase '${homes}/bob'")
+ machine.succeed("zfs unload-key '${homes}/bob'")
- with subtest("Switch to tty2"):
- machine.fail("pgrep -f 'agetty.*tty2'")
- machine.send_key("alt-f2")
- machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
- machine.wait_for_unit("getty@tty2.service")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
+ with subtest("Switch to tty2"):
+ machine.fail("pgrep -f 'agetty.*tty2'")
+ machine.send_key("alt-f2")
+ machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
+ machine.wait_for_unit("getty@tty2.service")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
- with subtest("Log in as user with home locked by login password"):
- machine.wait_until_tty_matches("2", "login: ")
- machine.send_chars("alice\n")
- machine.wait_until_tty_matches("2", "login: alice")
- machine.wait_until_succeeds("pgrep login")
- machine.wait_until_tty_matches("2", "Password: ")
- machine.send_chars("${userPassword}\n")
- machine.wait_until_succeeds("pgrep -u alice bash")
- machine.succeed("mount | grep ${homes}/alice")
+ with subtest("Log in as user with home locked by login password"):
+ machine.wait_until_tty_matches("2", "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches("2", "login: alice")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches("2", "Password: ")
+ machine.send_chars("${userPassword}\n")
+ machine.wait_until_succeeds("pgrep -u alice bash")
+ machine.succeed("mount | grep ${homes}/alice")
- with subtest("Switch to tty3"):
- machine.fail("pgrep -f 'agetty.*tty3'")
- machine.send_key("alt-f3")
- machine.wait_until_succeeds("[ $(fgconsole) = 3 ]")
- machine.wait_for_unit("getty@tty3.service")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty3'")
+ with subtest("Switch to tty3"):
+ machine.fail("pgrep -f 'agetty.*tty3'")
+ machine.send_key("alt-f3")
+ machine.wait_until_succeeds("[ $(fgconsole) = 3 ]")
+ machine.wait_for_unit("getty@tty3.service")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty3'")
- with subtest("Log in as user with home locked by password different from login"):
- machine.wait_until_tty_matches("3", "login: ")
- machine.send_chars("bob\n")
- machine.wait_until_tty_matches("3", "login: bob")
- machine.wait_until_succeeds("pgrep login")
- machine.wait_until_tty_matches("3", "Password: ")
- machine.send_chars("${userPassword}\n")
- machine.wait_until_succeeds("pgrep -u bob bash")
- machine.fail("mount | grep ${homes}/bob")
- '';
- }
-)
+ with subtest("Log in as user with home locked by password different from login"):
+ machine.wait_until_tty_matches("3", "login: ")
+ machine.send_chars("bob\n")
+ machine.wait_until_tty_matches("3", "login: bob")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches("3", "Password: ")
+ machine.send_chars("${userPassword}\n")
+ machine.wait_until_succeeds("pgrep -u bob bash")
+ machine.fail("mount | grep ${homes}/bob")
+ '';
+}
diff --git a/nixos/tests/pantheon-wayland.nix b/nixos/tests/pantheon-wayland.nix
index 74bc57eae78c..6bda9e508ef2 100644
--- a/nixos/tests/pantheon-wayland.nix
+++ b/nixos/tests/pantheon-wayland.nix
@@ -1,104 +1,102 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- {
- name = "pantheon-wayland";
+{
+ name = "pantheon-wayland";
- meta.maintainers = lib.teams.pantheon.members;
+ meta.maintainers = lib.teams.pantheon.members;
- nodes.machine =
- { nodes, ... }:
+ nodes.machine =
+ { nodes, ... }:
- let
- videosAutostart = pkgs.writeTextFile {
- name = "autostart-elementary-videos";
- destination = "/etc/xdg/autostart/io.elementary.videos.desktop";
- text = ''
- [Desktop Entry]
- Version=1.0
- Name=Videos
- Type=Application
- Terminal=false
- Exec=io.elementary.videos %U
- '';
- };
- in
- {
- imports = [ ./common/user-account.nix ];
+ let
+ videosAutostart = pkgs.writeTextFile {
+ name = "autostart-elementary-videos";
+ destination = "/etc/xdg/autostart/io.elementary.videos.desktop";
+ text = ''
+ [Desktop Entry]
+ Version=1.0
+ Name=Videos
+ Type=Application
+ Terminal=false
+ Exec=io.elementary.videos %U
+ '';
+ };
+ in
+ {
+ imports = [ ./common/user-account.nix ];
- # Workaround ".gala-wrapped invoked oom-killer"
- virtualisation.memorySize = 2047;
+ # Workaround ".gala-wrapped invoked oom-killer"
+ virtualisation.memorySize = 2047;
- services.xserver.enable = true;
- services.xserver.desktopManager.pantheon.enable = true;
- services.displayManager = {
- autoLogin.enable = true;
- autoLogin.user = nodes.machine.users.users.alice.name;
- defaultSession = "pantheon-wayland";
- };
-
- # We ship pantheon.appcenter by default when this is enabled.
- services.flatpak.enable = true;
-
- # For basic OCR tests.
- environment.systemPackages = [ videosAutostart ];
-
- # We don't ship gnome-text-editor in Pantheon module, we add this line mainly
- # to catch eval issues related to this option.
- environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];
+ services.xserver.enable = true;
+ services.xserver.desktopManager.pantheon.enable = true;
+ services.displayManager = {
+ autoLogin.enable = true;
+ autoLogin.user = nodes.machine.users.users.alice.name;
+ defaultSession = "pantheon-wayland";
};
- enableOCR = true;
+ # We ship pantheon.appcenter by default when this is enabled.
+ services.flatpak.enable = true;
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- in
- ''
- machine.wait_for_unit("display-manager.service")
+ # For basic OCR tests.
+ environment.systemPackages = [ videosAutostart ];
- with subtest("Wait for wayland server"):
- machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
+ # We don't ship gnome-text-editor in Pantheon module, we add this line mainly
+ # to catch eval issues related to this option.
+ environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];
+ };
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ enableOCR = true;
- with subtest("Check if Pantheon components actually start"):
- # We specifically check gsd-xsettings here since it is manually pulled up by gala.
- # https://github.com/elementary/gala/pull/2140
- for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "gsd-xsettings", "io.elementary.desktop.agent-polkit"]:
- machine.wait_until_succeeds(f"pgrep -f {i}")
- machine.wait_until_succeeds("pgrep -xf ${pkgs.pantheon.elementary-files}/libexec/io.elementary.files.xdg-desktop-portal")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ in
+ ''
+ machine.wait_for_unit("display-manager.service")
- with subtest("Check if various environment variables are set"):
- cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
- machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
- machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
- # Hopefully from the sessionPath option.
- machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
- # Hopefully from login shell.
- machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
+ with subtest("Wait for wayland server"):
+ machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
- with subtest("Wait for elementary videos autostart"):
- machine.wait_until_succeeds("pgrep -f io.elementary.videos")
- machine.wait_for_text("No Videos Open")
- machine.screenshot("videos")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Trigger multitasking view"):
- cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
- env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"
- machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
- machine.sleep(5)
- machine.screenshot("multitasking")
- machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
+ with subtest("Check if Pantheon components actually start"):
+ # We specifically check gsd-xsettings here since it is manually pulled up by gala.
+ # https://github.com/elementary/gala/pull/2140
+ for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "gsd-xsettings", "io.elementary.desktop.agent-polkit"]:
+ machine.wait_until_succeeds(f"pgrep -f {i}")
+ machine.wait_until_succeeds("pgrep -xf ${pkgs.pantheon.elementary-files}/libexec/io.elementary.files.xdg-desktop-portal")
- with subtest("Check if gala has ever coredumped"):
- machine.fail("coredumpctl --json=short | grep gala")
- # So we can see the dock.
- machine.execute("pkill -f -9 io.elementary.videos")
- machine.sleep(10)
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Check if various environment variables are set"):
+ cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
+ machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
+ machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
+ # Hopefully from the sessionPath option.
+ machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
+ # Hopefully from login shell.
+ machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
+
+ with subtest("Wait for elementary videos autostart"):
+ machine.wait_until_succeeds("pgrep -f io.elementary.videos")
+ machine.wait_for_text("No Videos Open")
+ machine.screenshot("videos")
+
+ with subtest("Trigger multitasking view"):
+ cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
+ env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"
+ machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
+ machine.sleep(5)
+ machine.screenshot("multitasking")
+ machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
+
+ with subtest("Check if gala has ever coredumped"):
+ machine.fail("coredumpctl --json=short | grep gala")
+ # So we can see the dock.
+ machine.execute("pkill -f -9 io.elementary.videos")
+ machine.sleep(10)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/pantheon.nix b/nixos/tests/pantheon.nix
index 6392d193a34c..b8cb0512c542 100644
--- a/nixos/tests/pantheon.nix
+++ b/nixos/tests/pantheon.nix
@@ -1,116 +1,114 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- {
- name = "pantheon";
+{
+ name = "pantheon";
- meta.maintainers = lib.teams.pantheon.members;
+ meta.maintainers = lib.teams.pantheon.members;
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [ ./common/user-account.nix ];
+ {
+ imports = [ ./common/user-account.nix ];
- # Workaround ".gala-wrapped invoked oom-killer"
- virtualisation.memorySize = 2047;
+ # Workaround ".gala-wrapped invoked oom-killer"
+ virtualisation.memorySize = 2047;
- services.xserver.enable = true;
- services.xserver.desktopManager.pantheon.enable = true;
+ services.xserver.enable = true;
+ services.xserver.desktopManager.pantheon.enable = true;
- # We ship pantheon.appcenter by default when this is enabled.
- services.flatpak.enable = true;
+ # We ship pantheon.appcenter by default when this is enabled.
+ services.flatpak.enable = true;
- # We don't ship gnome-text-editor in Pantheon module, we add this line mainly
- # to catch eval issues related to this option.
- environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];
+ # We don't ship gnome-text-editor in Pantheon module, we add this line mainly
+ # to catch eval issues related to this option.
+ environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];
- environment.systemPackages = [ pkgs.xdotool ];
- };
+ environment.systemPackages = [ pkgs.xdotool ];
+ };
- enableOCR = true;
+ enableOCR = true;
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- bob = nodes.machine.users.users.bob;
- in
- ''
- machine.wait_for_unit("display-manager.service")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ bob = nodes.machine.users.users.bob;
+ in
+ ''
+ machine.wait_for_unit("display-manager.service")
- with subtest("Test we can see usernames in elementary-greeter"):
- machine.wait_for_text("${user.description}")
- machine.wait_until_succeeds("pgrep -f io.elementary.greeter-compositor")
- # OCR was struggling with this one.
- # machine.wait_for_text("${bob.description}")
- # Ensure the password box is focused by clicking it.
- # Workaround for https://github.com/NixOS/nixpkgs/issues/211366.
- machine.succeed("XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0 xdotool mousemove 512 505 click 1")
- machine.sleep(2)
- machine.screenshot("elementary_greeter_lightdm")
+ with subtest("Test we can see usernames in elementary-greeter"):
+ machine.wait_for_text("${user.description}")
+ machine.wait_until_succeeds("pgrep -f io.elementary.greeter-compositor")
+ # OCR was struggling with this one.
+ # machine.wait_for_text("${bob.description}")
+ # Ensure the password box is focused by clicking it.
+ # Workaround for https://github.com/NixOS/nixpkgs/issues/211366.
+ machine.succeed("XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0 xdotool mousemove 512 505 click 1")
+ machine.sleep(2)
+ machine.screenshot("elementary_greeter_lightdm")
- with subtest("Login with elementary-greeter"):
- machine.send_chars("${user.password}\n")
- machine.wait_for_x()
- machine.wait_for_file("${user.home}/.Xauthority")
- machine.succeed("xauth merge ${user.home}/.Xauthority")
- machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"')
+ with subtest("Login with elementary-greeter"):
+ machine.send_chars("${user.password}\n")
+ machine.wait_for_x()
+ machine.wait_for_file("${user.home}/.Xauthority")
+ machine.succeed("xauth merge ${user.home}/.Xauthority")
+ machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"')
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Check if Pantheon components actually start"):
- for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "io.elementary.desktop.agent-polkit"]:
- machine.wait_until_succeeds(f"pgrep -f {i}")
- for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock"]:
- machine.wait_for_window(i)
- machine.wait_until_succeeds("pgrep -xf ${pkgs.pantheon.elementary-files}/libexec/io.elementary.files.xdg-desktop-portal")
+ with subtest("Check if Pantheon components actually start"):
+ for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "io.elementary.desktop.agent-polkit"]:
+ machine.wait_until_succeeds(f"pgrep -f {i}")
+ for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock"]:
+ machine.wait_for_window(i)
+ machine.wait_until_succeeds("pgrep -xf ${pkgs.pantheon.elementary-files}/libexec/io.elementary.files.xdg-desktop-portal")
- with subtest("Check if various environment variables are set"):
- cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
- machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
- # Hopefully from the sessionPath option.
- machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
- # Hopefully from login shell.
- machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
+ with subtest("Check if various environment variables are set"):
+ cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
+ machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
+ # Hopefully from the sessionPath option.
+ machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
+ # Hopefully from login shell.
+ machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
- with subtest("Open elementary videos"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.videos >&2 &'")
- machine.sleep(2)
- machine.wait_for_window("io.elementary.videos")
- machine.wait_for_text("No Videos Open")
+ with subtest("Open elementary videos"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.videos >&2 &'")
+ machine.sleep(2)
+ machine.wait_for_window("io.elementary.videos")
+ machine.wait_for_text("No Videos Open")
- with subtest("Open elementary calendar"):
- machine.wait_until_succeeds("pgrep -f evolution-calendar-factory")
- machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.calendar >&2 &'")
- machine.sleep(2)
- machine.wait_for_window("io.elementary.calendar")
+ with subtest("Open elementary calendar"):
+ machine.wait_until_succeeds("pgrep -f evolution-calendar-factory")
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.calendar >&2 &'")
+ machine.sleep(2)
+ machine.wait_for_window("io.elementary.calendar")
- with subtest("Open system settings"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.settings >&2 &'")
- # Wait for all plugins to be loaded before we check if the window is still there.
- machine.sleep(5)
- machine.wait_for_window("io.elementary.settings")
+ with subtest("Open system settings"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.settings >&2 &'")
+ # Wait for all plugins to be loaded before we check if the window is still there.
+ machine.sleep(5)
+ machine.wait_for_window("io.elementary.settings")
- with subtest("Open elementary terminal"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.terminal >&2 &'")
- machine.wait_for_window("io.elementary.terminal")
+ with subtest("Open elementary terminal"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.terminal >&2 &'")
+ machine.wait_for_window("io.elementary.terminal")
- with subtest("Trigger multitasking view"):
- cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
- env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0"
- machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
- machine.sleep(5)
- machine.screenshot("multitasking")
- machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
+ with subtest("Trigger multitasking view"):
+ cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
+ env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0"
+ machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
+ machine.sleep(5)
+ machine.screenshot("multitasking")
+ machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
- with subtest("Check if gala has ever coredumped"):
- machine.fail("coredumpctl --json=short | grep gala")
- # So you can see the dock in the below screenshot.
- machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xdotool mousemove 450 1000 >&2 &'")
- machine.sleep(10)
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Check if gala has ever coredumped"):
+ machine.fail("coredumpctl --json=short | grep gala")
+ # So you can see the dock in the below screenshot.
+ machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xdotool mousemove 450 1000 >&2 &'")
+ machine.sleep(10)
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/paperless.nix b/nixos/tests/paperless.nix
index 28ec877f2435..d35d909e690f 100644
--- a/nixos/tests/paperless.nix
+++ b/nixos/tests/paperless.nix
@@ -1,127 +1,125 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "paperless";
- meta.maintainers = with lib.maintainers; [
- leona
- SuperSandro2000
- erikarvstedt
- ];
+{ lib, ... }:
+{
+ name = "paperless";
+ meta.maintainers = with lib.maintainers; [
+ leona
+ SuperSandro2000
+ erikarvstedt
+ ];
- nodes =
- let
- self = {
- simple =
- { pkgs, ... }:
- {
- environment.systemPackages = with pkgs; [
- imagemagick
- jq
- ];
- services.paperless = {
+ nodes =
+ let
+ self = {
+ simple =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ imagemagick
+ jq
+ ];
+ services.paperless = {
+ enable = true;
+ passwordFile = builtins.toFile "password" "admin";
+
+ exporter = {
enable = true;
- passwordFile = builtins.toFile "password" "admin";
- exporter = {
- enable = true;
-
- settings = {
- "no-color" = lib.mkForce false; # override a default option
- "no-thumbnail" = true; # add a new option
- };
+ settings = {
+ "no-color" = lib.mkForce false; # override a default option
+ "no-thumbnail" = true; # add a new option
};
};
};
- postgres =
- { config, pkgs, ... }:
- {
- imports = [ self.simple ];
- services.paperless.database.createLocally = true;
- services.paperless.settings = {
- PAPERLESS_OCR_LANGUAGE = "deu";
- };
+ };
+ postgres =
+ { config, pkgs, ... }:
+ {
+ imports = [ self.simple ];
+ services.paperless.database.createLocally = true;
+ services.paperless.settings = {
+ PAPERLESS_OCR_LANGUAGE = "deu";
};
- };
- in
- self;
+ };
+ };
+ in
+ self;
- testScript = ''
- import json
+ testScript = ''
+ import json
- def test_paperless(node):
- node.wait_for_unit("paperless-consumer.service")
+ def test_paperless(node):
+ node.wait_for_unit("paperless-consumer.service")
- with subtest("Add a document via the file system"):
- node.succeed(
- "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
- "-annotate +5+20 'hello world 16-10-2005' /var/lib/paperless/consume/doc.png"
- )
+ with subtest("Add a document via the file system"):
+ node.succeed(
+ "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
+ "-annotate +5+20 'hello world 16-10-2005' /var/lib/paperless/consume/doc.png"
+ )
- with subtest("Web interface gets ready"):
+ with subtest("Web interface gets ready"):
+ node.wait_for_unit("paperless-web.service")
+ # Wait until server accepts connections
+ node.wait_until_succeeds("curl -fs localhost:28981")
+
+ # Required for consuming documents via the web interface
+ with subtest("Task-queue gets ready"):
+ node.wait_for_unit("paperless-task-queue.service")
+
+ with subtest("Add a png document via the web interface"):
+ node.succeed(
+ "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
+ "-annotate +5+20 'hello web 16-10-2005' /tmp/webdoc.png"
+ )
+ node.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.png -fs localhost:28981/api/documents/post_document/")
+
+ with subtest("Add a txt document via the web interface"):
+ node.succeed(
+ "echo 'hello web 16-10-2005' > /tmp/webdoc.txt"
+ )
+ node.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.txt -fs localhost:28981/api/documents/post_document/")
+
+ with subtest("Documents are consumed"):
+ node.wait_until_succeeds(
+ "(($(curl -u admin:admin -fs localhost:28981/api/documents/ | jq .count) == 3))"
+ )
+ docs = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/"))['results']
+ assert "2005-10-16" in docs[0]['created']
+ assert "2005-10-16" in docs[1]['created']
+ assert "2005-10-16" in docs[2]['created']
+
+ # Detects gunicorn issues, see PR #190888
+ with subtest("Document metadata can be accessed"):
+ metadata = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/1/metadata/"))
+ assert "original_checksum" in metadata
+
+ metadata = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/2/metadata/"))
+ assert "original_checksum" in metadata
+
+ metadata = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/3/metadata/"))
+ assert "original_checksum" in metadata
+
+ with subtest("Exporter"):
+ node.succeed("systemctl start --wait paperless-exporter")
node.wait_for_unit("paperless-web.service")
- # Wait until server accepts connections
- node.wait_until_succeeds("curl -fs localhost:28981")
-
- # Required for consuming documents via the web interface
- with subtest("Task-queue gets ready"):
+ node.wait_for_unit("paperless-consumer.service")
+ node.wait_for_unit("paperless-scheduler.service")
node.wait_for_unit("paperless-task-queue.service")
- with subtest("Add a png document via the web interface"):
- node.succeed(
- "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
- "-annotate +5+20 'hello web 16-10-2005' /tmp/webdoc.png"
- )
- node.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.png -fs localhost:28981/api/documents/post_document/")
+ node.succeed("ls -lah /var/lib/paperless/export/manifest.json")
- with subtest("Add a txt document via the web interface"):
- node.succeed(
- "echo 'hello web 16-10-2005' > /tmp/webdoc.txt"
- )
- node.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.txt -fs localhost:28981/api/documents/post_document/")
+ timers = node.succeed("systemctl list-timers paperless-exporter")
+ print(timers)
+ assert "paperless-exporter.timer paperless-exporter.service" in timers, "missing timer"
+ assert "1 timers listed." in timers, "incorrect number of timers"
- with subtest("Documents are consumed"):
- node.wait_until_succeeds(
- "(($(curl -u admin:admin -fs localhost:28981/api/documents/ | jq .count) == 3))"
- )
- docs = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/"))['results']
- assert "2005-10-16" in docs[0]['created']
- assert "2005-10-16" in docs[1]['created']
- assert "2005-10-16" in docs[2]['created']
+ # Double check that our attrset option override works as expected
+ cmdline = node.succeed("grep 'paperless-manage' $(systemctl cat paperless-exporter | grep ExecStart | cut -f 2 -d=)")
+ print(f"Exporter command line {cmdline!r}")
+ assert cmdline.strip() == "paperless-manage document_exporter /var/lib/paperless/export --compare-checksums --delete --no-progress-bar --no-thumbnail", "Unexpected exporter command line"
- # Detects gunicorn issues, see PR #190888
- with subtest("Document metadata can be accessed"):
- metadata = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/1/metadata/"))
- assert "original_checksum" in metadata
-
- metadata = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/2/metadata/"))
- assert "original_checksum" in metadata
-
- metadata = json.loads(node.succeed("curl -u admin:admin -fs localhost:28981/api/documents/3/metadata/"))
- assert "original_checksum" in metadata
-
- with subtest("Exporter"):
- node.succeed("systemctl start --wait paperless-exporter")
- node.wait_for_unit("paperless-web.service")
- node.wait_for_unit("paperless-consumer.service")
- node.wait_for_unit("paperless-scheduler.service")
- node.wait_for_unit("paperless-task-queue.service")
-
- node.succeed("ls -lah /var/lib/paperless/export/manifest.json")
-
- timers = node.succeed("systemctl list-timers paperless-exporter")
- print(timers)
- assert "paperless-exporter.timer paperless-exporter.service" in timers, "missing timer"
- assert "1 timers listed." in timers, "incorrect number of timers"
-
- # Double check that our attrset option override works as expected
- cmdline = node.succeed("grep 'paperless-manage' $(systemctl cat paperless-exporter | grep ExecStart | cut -f 2 -d=)")
- print(f"Exporter command line {cmdline!r}")
- assert cmdline.strip() == "paperless-manage document_exporter /var/lib/paperless/export --compare-checksums --delete --no-progress-bar --no-thumbnail", "Unexpected exporter command line"
-
- test_paperless(simple)
- simple.send_monitor_command("quit")
- simple.wait_for_shutdown()
- test_paperless(postgres)
- '';
- }
-)
+ test_paperless(simple)
+ simple.send_monitor_command("quit")
+ simple.wait_for_shutdown()
+ test_paperless(postgres)
+ '';
+}
diff --git a/nixos/tests/pass-secret-service.nix b/nixos/tests/pass-secret-service.nix
index 9e85dd30610b..de07cfd47a49 100644
--- a/nixos/tests/pass-secret-service.nix
+++ b/nixos/tests/pass-secret-service.nix
@@ -1,75 +1,73 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "pass-secret-service";
- meta.maintainers = [ lib.maintainers.aidalgol ];
+{ pkgs, lib, ... }:
+{
+ name = "pass-secret-service";
+ meta.maintainers = [ lib.maintainers.aidalgol ];
- nodes.machine =
- { nodes, pkgs, ... }:
- {
- imports = [ ./common/user-account.nix ];
+ nodes.machine =
+ { nodes, pkgs, ... }:
+ {
+ imports = [ ./common/user-account.nix ];
- services.passSecretService.enable = true;
+ services.passSecretService.enable = true;
- environment.systemPackages = [
- # Create a script that tries to make a request to the D-Bus secrets API.
- (pkgs.writers.writePython3Bin "secrets-dbus-init"
- {
- libraries = [ pkgs.python3Packages.secretstorage ];
- }
- ''
- import secretstorage
- print("Initializing dbus connection...")
- connection = secretstorage.dbus_init()
- print("Requesting default collection...")
- collection = secretstorage.get_default_collection(connection)
- print("Done! dbus-org.freedesktop.secrets should now be active.")
- ''
- )
- pkgs.pass
- ];
+ environment.systemPackages = [
+ # Create a script that tries to make a request to the D-Bus secrets API.
+ (pkgs.writers.writePython3Bin "secrets-dbus-init"
+ {
+ libraries = [ pkgs.python3Packages.secretstorage ];
+ }
+ ''
+ import secretstorage
+ print("Initializing dbus connection...")
+ connection = secretstorage.dbus_init()
+ print("Requesting default collection...")
+ collection = secretstorage.get_default_collection(connection)
+ print("Done! dbus-org.freedesktop.secrets should now be active.")
+ ''
+ )
+ pkgs.pass
+ ];
- programs.gnupg = {
- agent.enable = true;
- dirmngr.enable = true;
- };
+ programs.gnupg = {
+ agent.enable = true;
+ dirmngr.enable = true;
};
+ };
- # Some of the commands are run via a virtual console because they need to be
- # run under a real login session, with D-Bus running in the environment.
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.config.users.users.alice;
- gpg-uid = "alice@example.net";
- gpg-pw = "foobar9000";
- ready-file = "/tmp/secrets-dbus-init.done";
- in
- ''
- # Initialise the pass(1) storage.
- machine.succeed("""
- sudo -u alice gpg --pinentry-mode loopback --batch --passphrase ${gpg-pw} \
- --quick-gen-key ${gpg-uid} \
- """)
- machine.succeed("sudo -u alice pass init ${gpg-uid}")
+ # Some of the commands are run via a virtual console because they need to be
+ # run under a real login session, with D-Bus running in the environment.
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.config.users.users.alice;
+ gpg-uid = "alice@example.net";
+ gpg-pw = "foobar9000";
+ ready-file = "/tmp/secrets-dbus-init.done";
+ in
+ ''
+ # Initialise the pass(1) storage.
+ machine.succeed("""
+ sudo -u alice gpg --pinentry-mode loopback --batch --passphrase ${gpg-pw} \
+ --quick-gen-key ${gpg-uid} \
+ """)
+ machine.succeed("sudo -u alice pass init ${gpg-uid}")
- with subtest("Service is not running on login"):
- machine.wait_until_tty_matches("1", "login: ")
- machine.send_chars("alice\n")
- machine.wait_until_tty_matches("1", "login: alice")
- machine.wait_until_succeeds("pgrep login")
- machine.wait_until_tty_matches("1", "Password: ")
- machine.send_chars("${user.password}\n")
- machine.wait_until_succeeds("pgrep -u alice bash")
+ with subtest("Service is not running on login"):
+ machine.wait_until_tty_matches("1", "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches("1", "login: alice")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches("1", "Password: ")
+ machine.send_chars("${user.password}\n")
+ machine.wait_until_succeeds("pgrep -u alice bash")
- _, output = machine.systemctl("status dbus-org.freedesktop.secrets --no-pager", "alice")
- assert "Active: inactive (dead)" in output
+ _, output = machine.systemctl("status dbus-org.freedesktop.secrets --no-pager", "alice")
+ assert "Active: inactive (dead)" in output
- with subtest("Service starts after a client tries to talk to the D-Bus API"):
- machine.send_chars("secrets-dbus-init; touch ${ready-file}\n")
- machine.wait_for_file("${ready-file}")
- _, output = machine.systemctl("status dbus-org.freedesktop.secrets --no-pager", "alice")
- assert "Active: active (running)" in output
- '';
- }
-)
+ with subtest("Service starts after a client tries to talk to the D-Bus API"):
+ machine.send_chars("secrets-dbus-init; touch ${ready-file}\n")
+ machine.wait_for_file("${ready-file}")
+ _, output = machine.systemctl("status dbus-org.freedesktop.secrets --no-pager", "alice")
+ assert "Active: active (running)" in output
+ '';
+}
diff --git a/nixos/tests/password-option-override-ordering.nix b/nixos/tests/password-option-override-ordering.nix
index 5b06ab0bdbff..c2e4b1768108 100644
--- a/nixos/tests/password-option-override-ordering.nix
+++ b/nixos/tests/password-option-override-ordering.nix
@@ -6,166 +6,164 @@ let
hashed_sha512crypt = "$6$ymzs8WINZ5wGwQcV$VC2S0cQiX8NVukOLymysTPn4v1zJoJp3NGyhnqyv/dAf4NWZsBWYveQcj6gEJr4ZUjRBRjM0Pj1L8TCQ8hUUp0"; # meow
in
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "password-option-override-ordering";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fidgetingbits ];
- };
+{ pkgs, ... }:
+{
+ name = "password-option-override-ordering";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fidgetingbits ];
+ };
- nodes =
- let
- # The following users are expected to have the same behavior between immutable and mutable systems
- # NOTE: Below given A -> B it implies B overrides A . Each entry below builds off the next
- users = {
- # mutable true/false: initialHashedPassword -> hashedPassword
- fran = {
- isNormalUser = true;
- initialHashedPassword = hashed_yeshash;
- hashedPassword = hashed_sha512crypt;
- };
-
- # mutable false: initialHashedPassword -> hashedPassword -> initialPassword
- # mutable true: initialHashedPassword -> initialPassword -> hashedPassword
- greg = {
- isNormalUser = true;
- hashedPassword = hashed_sha512crypt;
- initialPassword = password1;
- };
-
- # mutable false: initialHashedPassword -> hashedPassword -> initialPassword -> password
- # mutable true: initialHashedPassword -> initialPassword -> hashedPassword -> password
- egon = {
- isNormalUser = true;
- initialPassword = password2;
- password = password1;
- };
-
- # mutable true/false: hashedPassword -> password
- # NOTE: minor duplication of test above, but to verify no initialXXX use is consistent
- alice = {
- isNormalUser = true;
- hashedPassword = hashed_sha512crypt;
- password = password1;
- };
-
- # mutable false: initialHashedPassword -> hashedPassword -> initialPassword -> password -> hashedPasswordFile
- # mutable true: initialHashedPassword -> initialPassword -> hashedPassword -> password -> hashedPasswordFile
- bob = {
- isNormalUser = true;
- hashedPassword = hashed_sha512crypt;
- password = password1;
- hashedPasswordFile = (pkgs.writeText "hashed_bcrypt" hashed_bcrypt).outPath; # Expect override of everything above
- };
-
- # Show hashedPassword -> password -> hashedPasswordFile -> initialPassword is false
- # to explicitly show the following lib.trace warning in users-groups.nix (which was
- # the wording prior to PR 310484) is in fact wrong:
- # ```
- # The user 'root' has multiple of the options
- # `hashedPassword`, `password`, `hashedPasswordFile`, `initialPassword`
- # & `initialHashedPassword` set to a non-null value.
- # The options silently discard others by the order of precedence
- # given above which can lead to surprising results. To resolve this warning,
- # set at most one of the options above to a non-`null` value.
- # ```
- cat = {
- isNormalUser = true;
- hashedPassword = hashed_sha512crypt;
- password = password1;
- hashedPasswordFile = (pkgs.writeText "hashed_bcrypt" hashed_bcrypt).outPath;
- initialPassword = password2; # lib.trace message implies this overrides everything above
- };
-
- # Show hashedPassword -> password -> hashedPasswordFile -> initialHashedPassword is false
- # to also explicitly show the lib.trace explained above (see cat user) is wrong
- dan = {
- isNormalUser = true;
- hashedPassword = hashed_sha512crypt;
- initialPassword = password2;
- password = password1;
- hashedPasswordFile = (pkgs.writeText "hashed_bcrypt" hashed_bcrypt).outPath;
- initialHashedPassword = hashed_yeshash; # lib.trace message implies this overrides everything above
- };
+ nodes =
+ let
+ # The following users are expected to have the same behavior between immutable and mutable systems
+ # NOTE: Below given A -> B it implies B overrides A . Each entry below builds off the next
+ users = {
+ # mutable true/false: initialHashedPassword -> hashedPassword
+ fran = {
+ isNormalUser = true;
+ initialHashedPassword = hashed_yeshash;
+ hashedPassword = hashed_sha512crypt;
};
- mkTestMachine = mutable: {
- environment.systemPackages = [ pkgs.shadow ];
- users = {
- mutableUsers = mutable;
- inherit users;
- };
+ # mutable false: initialHashedPassword -> hashedPassword -> initialPassword
+ # mutable true: initialHashedPassword -> initialPassword -> hashedPassword
+ greg = {
+ isNormalUser = true;
+ hashedPassword = hashed_sha512crypt;
+ initialPassword = password1;
+ };
+
+ # mutable false: initialHashedPassword -> hashedPassword -> initialPassword -> password
+ # mutable true: initialHashedPassword -> initialPassword -> hashedPassword -> password
+ egon = {
+ isNormalUser = true;
+ initialPassword = password2;
+ password = password1;
+ };
+
+ # mutable true/false: hashedPassword -> password
+ # NOTE: minor duplication of test above, but to verify no initialXXX use is consistent
+ alice = {
+ isNormalUser = true;
+ hashedPassword = hashed_sha512crypt;
+ password = password1;
+ };
+
+ # mutable false: initialHashedPassword -> hashedPassword -> initialPassword -> password -> hashedPasswordFile
+ # mutable true: initialHashedPassword -> initialPassword -> hashedPassword -> password -> hashedPasswordFile
+ bob = {
+ isNormalUser = true;
+ hashedPassword = hashed_sha512crypt;
+ password = password1;
+ hashedPasswordFile = (pkgs.writeText "hashed_bcrypt" hashed_bcrypt).outPath; # Expect override of everything above
+ };
+
+ # Show hashedPassword -> password -> hashedPasswordFile -> initialPassword is false
+ # to explicitly show the following lib.trace warning in users-groups.nix (which was
+ # the wording prior to PR 310484) is in fact wrong:
+ # ```
+ # The user 'root' has multiple of the options
+ # `hashedPassword`, `password`, `hashedPasswordFile`, `initialPassword`
+ # & `initialHashedPassword` set to a non-null value.
+ # The options silently discard others by the order of precedence
+ # given above which can lead to surprising results. To resolve this warning,
+ # set at most one of the options above to a non-`null` value.
+ # ```
+ cat = {
+ isNormalUser = true;
+ hashedPassword = hashed_sha512crypt;
+ password = password1;
+ hashedPasswordFile = (pkgs.writeText "hashed_bcrypt" hashed_bcrypt).outPath;
+ initialPassword = password2; # lib.trace message implies this overrides everything above
+ };
+
+ # Show hashedPassword -> password -> hashedPasswordFile -> initialHashedPassword is false
+ # to also explicitly show the lib.trace explained above (see cat user) is wrong
+ dan = {
+ isNormalUser = true;
+ hashedPassword = hashed_sha512crypt;
+ initialPassword = password2;
+ password = password1;
+ hashedPasswordFile = (pkgs.writeText "hashed_bcrypt" hashed_bcrypt).outPath;
+ initialHashedPassword = hashed_yeshash; # lib.trace message implies this overrides everything above
};
- in
- {
- immutable = mkTestMachine false;
- mutable = mkTestMachine true;
};
- testScript = ''
- import crypt
+ mkTestMachine = mutable: {
+ environment.systemPackages = [ pkgs.shadow ];
+ users = {
+ mutableUsers = mutable;
+ inherit users;
+ };
+ };
+ in
+ {
+ immutable = mkTestMachine false;
+ mutable = mkTestMachine true;
+ };
- def assert_password_match(machine, username, password):
- shadow_entry = machine.succeed(f"getent shadow {username}")
- print(shadow_entry)
- hash = shadow_entry.split(":")[1]
- seed = "$".join(hash.split("$")[:-1])
- assert crypt.crypt(password, seed) == hash, f"{username} user password does not match"
+ testScript = ''
+ import crypt
- with subtest("alice user has correct password"):
- for machine in machines:
- assert_password_match(machine, "alice", "${password1}")
- assert "${hashed_sha512crypt}" not in machine.succeed("getent shadow alice"), f"{machine}: alice user password is not correct"
-
- with subtest("bob user has correct password"):
- for machine in machines:
- print(machine.succeed("getent shadow bob"))
- assert "${hashed_bcrypt}" in machine.succeed("getent shadow bob"), f"{machine}: bob user password is not correct"
-
- with subtest("cat user has correct password"):
- for machine in machines:
- print(machine.succeed("getent shadow cat"))
- assert "${hashed_bcrypt}" in machine.succeed("getent shadow cat"), f"{machine}: cat user password is not correct"
-
- with subtest("dan user has correct password"):
- for machine in machines:
- print(machine.succeed("getent shadow dan"))
- assert "${hashed_bcrypt}" in machine.succeed("getent shadow dan"), f"{machine}: dan user password is not correct"
-
- with subtest("greg user has correct password"):
- print(mutable.succeed("getent shadow greg"))
- assert "${hashed_sha512crypt}" in mutable.succeed("getent shadow greg"), "greg user password is not correct"
-
- assert_password_match(immutable, "greg", "${password1}")
- assert "${hashed_sha512crypt}" not in immutable.succeed("getent shadow greg"), "greg user password is not correct"
+ def assert_password_match(machine, username, password):
+ shadow_entry = machine.succeed(f"getent shadow {username}")
+ print(shadow_entry)
+ hash = shadow_entry.split(":")[1]
+ seed = "$".join(hash.split("$")[:-1])
+ assert crypt.crypt(password, seed) == hash, f"{username} user password does not match"
+ with subtest("alice user has correct password"):
for machine in machines:
- machine.wait_for_unit("multi-user.target")
- machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+ assert_password_match(machine, "alice", "${password1}")
+ assert "${hashed_sha512crypt}" not in machine.succeed("getent shadow alice"), f"{machine}: alice user password is not correct"
- def check_login(machine: Machine, tty_number: str, username: str, password: str):
- machine.send_key(f"alt-f{tty_number}")
- machine.wait_until_succeeds(f"[ $(fgconsole) = {tty_number} ]")
- machine.wait_for_unit(f"getty@tty{tty_number}.service")
- machine.wait_until_succeeds(f"pgrep -f 'agetty.*tty{tty_number}'")
- machine.wait_until_tty_matches(tty_number, "login: ")
- machine.send_chars(f"{username}\n")
- machine.wait_until_tty_matches(tty_number, f"login: {username}")
- machine.wait_until_succeeds("pgrep login")
- machine.wait_until_tty_matches(tty_number, "Password: ")
- machine.send_chars(f"{password}\n")
- machine.send_chars(f"whoami > /tmp/{tty_number}\n")
- machine.wait_for_file(f"/tmp/{tty_number}")
- assert username in machine.succeed(f"cat /tmp/{tty_number}"), f"{machine}: {username} password is not correct"
+ with subtest("bob user has correct password"):
+ for machine in machines:
+ print(machine.succeed("getent shadow bob"))
+ assert "${hashed_bcrypt}" in machine.succeed("getent shadow bob"), f"{machine}: bob user password is not correct"
- with subtest("Test initialPassword override"):
- for machine in machines:
- check_login(machine, "2", "egon", "${password1}")
+ with subtest("cat user has correct password"):
+ for machine in machines:
+ print(machine.succeed("getent shadow cat"))
+ assert "${hashed_bcrypt}" in machine.succeed("getent shadow cat"), f"{machine}: cat user password is not correct"
- with subtest("Test initialHashedPassword override"):
- for machine in machines:
- check_login(machine, "3", "fran", "meow")
- '';
- }
-)
+ with subtest("dan user has correct password"):
+ for machine in machines:
+ print(machine.succeed("getent shadow dan"))
+ assert "${hashed_bcrypt}" in machine.succeed("getent shadow dan"), f"{machine}: dan user password is not correct"
+
+ with subtest("greg user has correct password"):
+ print(mutable.succeed("getent shadow greg"))
+ assert "${hashed_sha512crypt}" in mutable.succeed("getent shadow greg"), "greg user password is not correct"
+
+ assert_password_match(immutable, "greg", "${password1}")
+ assert "${hashed_sha512crypt}" not in immutable.succeed("getent shadow greg"), "greg user password is not correct"
+
+ for machine in machines:
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+
+ def check_login(machine: Machine, tty_number: str, username: str, password: str):
+ machine.send_key(f"alt-f{tty_number}")
+ machine.wait_until_succeeds(f"[ $(fgconsole) = {tty_number} ]")
+ machine.wait_for_unit(f"getty@tty{tty_number}.service")
+ machine.wait_until_succeeds(f"pgrep -f 'agetty.*tty{tty_number}'")
+ machine.wait_until_tty_matches(tty_number, "login: ")
+ machine.send_chars(f"{username}\n")
+ machine.wait_until_tty_matches(tty_number, f"login: {username}")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches(tty_number, "Password: ")
+ machine.send_chars(f"{password}\n")
+ machine.send_chars(f"whoami > /tmp/{tty_number}\n")
+ machine.wait_for_file(f"/tmp/{tty_number}")
+ assert username in machine.succeed(f"cat /tmp/{tty_number}"), f"{machine}: {username} password is not correct"
+
+ with subtest("Test initialPassword override"):
+ for machine in machines:
+ check_login(machine, "2", "egon", "${password1}")
+
+ with subtest("Test initialHashedPassword override"):
+ for machine in machines:
+ check_login(machine, "3", "fran", "meow")
+ '';
+}
diff --git a/nixos/tests/pds.nix b/nixos/tests/pds.nix
index 4c4ab2a64326..a07a2c1fcf72 100644
--- a/nixos/tests/pds.nix
+++ b/nixos/tests/pds.nix
@@ -1,29 +1,27 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "PDS";
+{ lib, ... }:
+{
+ name = "PDS";
- nodes.machine = {
- services.pds = {
- enable = true;
- settings = {
- PDS_PORT = 3000;
- PDS_HOSTNAME = "example.com";
+ nodes.machine = {
+ services.pds = {
+ enable = true;
+ settings = {
+ PDS_PORT = 3000;
+ PDS_HOSTNAME = "example.com";
- # Snake oil testing credentials
- PDS_JWT_SECRET = "7b93fee53be046bf59c27a32a0fb2069";
- PDS_ADMIN_PASSWORD = "3a4077bc0d5f04eca945ef0509f7e809";
- PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX = "ae4f5028d04c833ba630f29debd5ff80b7700e43e9f4bf70f729a88cd6a6ce35";
- };
+ # Snake oil testing credentials
+ PDS_JWT_SECRET = "7b93fee53be046bf59c27a32a0fb2069";
+ PDS_ADMIN_PASSWORD = "3a4077bc0d5f04eca945ef0509f7e809";
+ PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX = "ae4f5028d04c833ba630f29debd5ff80b7700e43e9f4bf70f729a88cd6a6ce35";
};
};
+ };
- testScript = ''
- machine.wait_for_unit("pds.service")
- machine.wait_for_open_port(3000)
- machine.succeed("curl --fail http://localhost:3000")
- '';
+ testScript = ''
+ machine.wait_for_unit("pds.service")
+ machine.wait_for_open_port(3000)
+ machine.succeed("curl --fail http://localhost:3000")
+ '';
- meta.maintainers = with lib.maintainers; [ t4ccer ];
- }
-)
+ meta.maintainers = with lib.maintainers; [ t4ccer ];
+}
diff --git a/nixos/tests/peerflix.nix b/nixos/tests/peerflix.nix
index b53f1b114abe..92a03157f568 100644
--- a/nixos/tests/peerflix.nix
+++ b/nixos/tests/peerflix.nix
@@ -1,26 +1,24 @@
# This test runs peerflix and checks if peerflix starts
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "peerflix";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ offline ];
- };
+{ pkgs, ... }:
+{
+ name = "peerflix";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ offline ];
+ };
- nodes = {
- peerflix =
- { ... }:
- {
- services.peerflix.enable = true;
- };
- };
+ nodes = {
+ peerflix =
+ { ... }:
+ {
+ services.peerflix.enable = true;
+ };
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- peerflix.wait_for_unit("peerflix.service")
- peerflix.wait_until_succeeds("curl -f localhost:9000")
- '';
- }
-)
+ peerflix.wait_for_unit("peerflix.service")
+ peerflix.wait_until_succeeds("curl -f localhost:9000")
+ '';
+}
diff --git a/nixos/tests/peroxide.nix b/nixos/tests/peroxide.nix
index 3508942d2970..d5902a64ba2d 100644
--- a/nixos/tests/peroxide.nix
+++ b/nixos/tests/peroxide.nix
@@ -1,20 +1,18 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "peroxide";
- meta.maintainers = with lib.maintainers; [ aidalgol ];
+{ pkgs, lib, ... }:
+{
+ name = "peroxide";
+ meta.maintainers = with lib.maintainers; [ aidalgol ];
- nodes.machine =
- { config, pkgs, ... }:
- {
- networking.hostName = "nixos";
- services.peroxide.enable = true;
- };
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ networking.hostName = "nixos";
+ services.peroxide.enable = true;
+ };
- testScript = ''
- machine.wait_for_unit("peroxide.service")
- machine.wait_for_open_port(1143) # IMAP
- machine.wait_for_open_port(1025) # SMTP
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("peroxide.service")
+ machine.wait_for_open_port(1143) # IMAP
+ machine.wait_for_open_port(1025) # SMTP
+ '';
+}
diff --git a/nixos/tests/pgbouncer.nix b/nixos/tests/pgbouncer.nix
index 7951ad0fb084..ffe2c3c137bf 100644
--- a/nixos/tests/pgbouncer.nix
+++ b/nixos/tests/pgbouncer.nix
@@ -1,62 +1,60 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "pgbouncer";
+{ lib, pkgs, ... }:
+{
+ name = "pgbouncer";
- meta = with lib.maintainers; {
- maintainers = [ _1000101 ];
- };
+ meta = with lib.maintainers; {
+ maintainers = [ _1000101 ];
+ };
- nodes = {
- one =
- { pkgs, ... }:
- {
- systemd.services.postgresql = {
- postStart = ''
- ${pkgs.postgresql}/bin/psql -U postgres -c "ALTER ROLE testuser WITH LOGIN PASSWORD 'testpass'";
- ${pkgs.postgresql}/bin/psql -U postgres -c "ALTER DATABASE testdb OWNER TO testuser;";
+ nodes = {
+ one =
+ { pkgs, ... }:
+ {
+ systemd.services.postgresql = {
+ postStart = ''
+ ${pkgs.postgresql}/bin/psql -U postgres -c "ALTER ROLE testuser WITH LOGIN PASSWORD 'testpass'";
+ ${pkgs.postgresql}/bin/psql -U postgres -c "ALTER DATABASE testdb OWNER TO testuser;";
+ '';
+ };
+
+ services = {
+ postgresql = {
+ enable = true;
+ ensureDatabases = [ "testdb" ];
+ ensureUsers = [ { name = "testuser"; } ];
+ authentication = ''
+ local testdb testuser scram-sha-256
'';
};
- services = {
- postgresql = {
- enable = true;
- ensureDatabases = [ "testdb" ];
- ensureUsers = [ { name = "testuser"; } ];
- authentication = ''
- local testdb testuser scram-sha-256
- '';
- };
-
- pgbouncer = {
- enable = true;
- openFirewall = true;
- settings = {
- pgbouncer = {
- listen_addr = "localhost";
- auth_type = "scram-sha-256";
- auth_file = builtins.toFile "pgbouncer-users.txt" ''
- "testuser" "testpass"
- '';
- };
- databases = {
- test = "host=/run/postgresql port=5432 auth_user=testuser dbname=testdb";
- };
+ pgbouncer = {
+ enable = true;
+ openFirewall = true;
+ settings = {
+ pgbouncer = {
+ listen_addr = "localhost";
+ auth_type = "scram-sha-256";
+ auth_file = builtins.toFile "pgbouncer-users.txt" ''
+ "testuser" "testpass"
+ '';
+ };
+ databases = {
+ test = "host=/run/postgresql port=5432 auth_user=testuser dbname=testdb";
};
};
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
- one.wait_for_unit("default.target")
- one.require_unit_state("pgbouncer.service", "active")
+ testScript = ''
+ start_all()
+ one.wait_for_unit("default.target")
+ one.require_unit_state("pgbouncer.service", "active")
- # Test if we can make a query through PgBouncer
- one.wait_until_succeeds(
- "psql 'postgres://testuser:testpass@localhost:6432/test' -c 'SELECT 1;'"
- )
- '';
- }
-)
+ # Test if we can make a query through PgBouncer
+ one.wait_until_succeeds(
+ "psql 'postgres://testuser:testpass@localhost:6432/test' -c 'SELECT 1;'"
+ )
+ '';
+}
diff --git a/nixos/tests/pgmanage.nix b/nixos/tests/pgmanage.nix
index a28a3ce44766..157f46faec9f 100644
--- a/nixos/tests/pgmanage.nix
+++ b/nixos/tests/pgmanage.nix
@@ -1,46 +1,44 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- role = "test";
- password = "secret";
- conn = "local";
- in
- {
- name = "pgmanage";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ basvandijk ];
- };
- nodes = {
- one =
- { config, pkgs, ... }:
- {
- services = {
- postgresql = {
- enable = true;
- initialScript = pkgs.writeText "pg-init-script" ''
- CREATE ROLE ${role} SUPERUSER LOGIN PASSWORD '${password}';
- '';
- };
- pgmanage = {
- enable = true;
- connections = {
- ${conn} =
- "hostaddr=127.0.0.1 port=${toString config.services.postgresql.settings.port} dbname=postgres";
- };
+{ pkgs, ... }:
+let
+ role = "test";
+ password = "secret";
+ conn = "local";
+in
+{
+ name = "pgmanage";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ basvandijk ];
+ };
+ nodes = {
+ one =
+ { config, pkgs, ... }:
+ {
+ services = {
+ postgresql = {
+ enable = true;
+ initialScript = pkgs.writeText "pg-init-script" ''
+ CREATE ROLE ${role} SUPERUSER LOGIN PASSWORD '${password}';
+ '';
+ };
+ pgmanage = {
+ enable = true;
+ connections = {
+ ${conn} =
+ "hostaddr=127.0.0.1 port=${toString config.services.postgresql.settings.port} dbname=postgres";
};
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
- one.wait_for_unit("default.target")
- one.require_unit_state("pgmanage.service", "active")
+ testScript = ''
+ start_all()
+ one.wait_for_unit("default.target")
+ one.require_unit_state("pgmanage.service", "active")
- # Test if we can log in.
- one.wait_until_succeeds(
- "curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail"
- )
- '';
- }
-)
+ # Test if we can log in.
+ one.wait_until_succeeds(
+ "curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail"
+ )
+ '';
+}
diff --git a/nixos/tests/phosh.nix b/nixos/tests/phosh.nix
index 9a93f64b0ac4..a276e1f57653 100644
--- a/nixos/tests/phosh.nix
+++ b/nixos/tests/phosh.nix
@@ -1,88 +1,86 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- pin = "1234";
- in
- {
- name = "phosh";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ zhaofengli ];
- };
+{ pkgs, ... }:
+let
+ pin = "1234";
+in
+{
+ name = "phosh";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ zhaofengli ];
+ };
- nodes = {
- phone =
- { config, pkgs, ... }:
- {
- users.users.nixos = {
- isNormalUser = true;
- password = pin;
- };
-
- services.xserver.desktopManager.phosh = {
- enable = true;
- user = "nixos";
- group = "users";
-
- phocConfig = {
- outputs.Virtual-1 = {
- scale = 2;
- };
- };
- };
-
- environment.systemPackages = [
- pkgs.phosh-mobile-settings
- ];
-
- systemd.services.phosh = {
- environment = {
- # Accelerated graphics fail on phoc 0.20 (wlroots 0.15)
- "WLR_RENDERER" = "pixman";
- };
- };
-
- virtualisation.resolution = {
- x = 720;
- y = 1440;
- };
- virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci,xres=720,yres=1440" ];
+ nodes = {
+ phone =
+ { config, pkgs, ... }:
+ {
+ users.users.nixos = {
+ isNormalUser = true;
+ password = pin;
};
- };
- enableOCR = true;
+ services.xserver.desktopManager.phosh = {
+ enable = true;
+ user = "nixos";
+ group = "users";
- testScript = ''
- import time
+ phocConfig = {
+ outputs.Virtual-1 = {
+ scale = 2;
+ };
+ };
+ };
- start_all()
- phone.wait_for_unit("phosh.service")
+ environment.systemPackages = [
+ pkgs.phosh-mobile-settings
+ ];
- with subtest("Check that we can see the lock screen info page"):
- # Saturday, January 1
- phone.succeed("timedatectl set-time '2022-01-01 07:00'")
+ systemd.services.phosh = {
+ environment = {
+ # Accelerated graphics fail on phoc 0.20 (wlroots 0.15)
+ "WLR_RENDERER" = "pixman";
+ };
+ };
- phone.wait_for_text("Saturday")
- phone.screenshot("01lockinfo")
+ virtualisation.resolution = {
+ x = 720;
+ y = 1440;
+ };
+ virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci,xres=720,yres=1440" ];
+ };
+ };
- with subtest("Check that we can unlock the screen"):
- phone.send_chars("${pin}", delay=0.2)
- time.sleep(1)
- phone.screenshot("02unlock")
+ enableOCR = true;
- phone.send_chars("\n")
+ testScript = ''
+ import time
- phone.wait_for_text("All Apps")
- phone.screenshot("03launcher")
+ start_all()
+ phone.wait_for_unit("phosh.service")
- with subtest("Check the on-screen keyboard shows"):
- phone.send_chars("mobile setting", delay=0.2)
- phone.wait_for_text("123") # A button on the OSK
- phone.screenshot("04osk")
+ with subtest("Check that we can see the lock screen info page"):
+ # Saturday, January 1
+ phone.succeed("timedatectl set-time '2022-01-01 07:00'")
- with subtest("Check mobile-phosh-settings starts"):
- phone.send_chars("\n")
- phone.wait_for_text("Tweak advanced mobile settings");
- phone.screenshot("05settings")
- '';
- }
-)
+ phone.wait_for_text("Saturday")
+ phone.screenshot("01lockinfo")
+
+ with subtest("Check that we can unlock the screen"):
+ phone.send_chars("${pin}", delay=0.2)
+ time.sleep(1)
+ phone.screenshot("02unlock")
+
+ phone.send_chars("\n")
+
+ phone.wait_for_text("All Apps")
+ phone.screenshot("03launcher")
+
+ with subtest("Check the on-screen keyboard shows"):
+ phone.send_chars("mobile setting", delay=0.2)
+ phone.wait_for_text("123") # A button on the OSK
+ phone.screenshot("04osk")
+
+ with subtest("Check mobile-phosh-settings starts"):
+ phone.send_chars("\n")
+ phone.wait_for_text("Tweak advanced mobile settings");
+ phone.screenshot("05settings")
+ '';
+}
diff --git a/nixos/tests/photonvision.nix b/nixos/tests/photonvision.nix
index 6893e77d1554..6ad5ec8915ea 100644
--- a/nixos/tests/photonvision.nix
+++ b/nixos/tests/photonvision.nix
@@ -1,24 +1,22 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "photonvision";
+{ pkgs, lib, ... }:
+{
+ name = "photonvision";
- nodes = {
- machine =
- { pkgs, ... }:
- {
- services.photonvision = {
- enable = true;
- };
+ nodes = {
+ machine =
+ { pkgs, ... }:
+ {
+ services.photonvision = {
+ enable = true;
};
- };
+ };
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("photonvision.service")
- machine.wait_for_open_port(5800)
- '';
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("photonvision.service")
+ machine.wait_for_open_port(5800)
+ '';
- meta.maintainers = with lib.maintainers; [ max-niederman ];
- }
-)
+ meta.maintainers = with lib.maintainers; [ max-niederman ];
+}
diff --git a/nixos/tests/photoprism.nix b/nixos/tests/photoprism.nix
index b8c86c9ac20a..e4cdfeb43331 100644
--- a/nixos/tests/photoprism.nix
+++ b/nixos/tests/photoprism.nix
@@ -1,28 +1,26 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "photoprism";
- meta.maintainers = with lib.maintainers; [ stunkymonkey ];
+{ lib, pkgs, ... }:
+{
+ name = "photoprism";
+ meta.maintainers = with lib.maintainers; [ stunkymonkey ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.photoprism = {
- enable = true;
- port = 8080;
- originalsPath = "/media/photos/";
- passwordFile = pkgs.writeText "password" "secret";
- };
- environment.extraInit = ''
- mkdir -p /media/photos
- '';
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.photoprism = {
+ enable = true;
+ port = 8080;
+ originalsPath = "/media/photos/";
+ passwordFile = pkgs.writeText "password" "secret";
};
+ environment.extraInit = ''
+ mkdir -p /media/photos
+ '';
+ };
- testScript = ''
- machine.wait_for_unit("multi-user.target")
- machine.wait_for_open_port(8080)
- response = machine.succeed("curl -vvv -s -H 'Host: photoprism' http://127.0.0.1:8080/library/login")
- assert 'PhotoPrism' in response, "Login page didn't load successfully"
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_for_open_port(8080)
+ response = machine.succeed("curl -vvv -s -H 'Host: photoprism' http://127.0.0.1:8080/library/login")
+ assert 'PhotoPrism' in response, "Login page didn't load successfully"
+ '';
+}
diff --git a/nixos/tests/pict-rs.nix b/nixos/tests/pict-rs.nix
index 12109c74138d..7bd2c601f8a6 100644
--- a/nixos/tests/pict-rs.nix
+++ b/nixos/tests/pict-rs.nix
@@ -1,24 +1,22 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "pict-rs";
- meta.maintainers = with lib.maintainers; [ happysalada ];
+{ pkgs, lib, ... }:
+{
+ name = "pict-rs";
+ meta.maintainers = with lib.maintainers; [ happysalada ];
- nodes.machine =
- { ... }:
- {
- environment.systemPackages = with pkgs; [
- curl
- jq
- ];
- services.pict-rs.enable = true;
- };
+ nodes.machine =
+ { ... }:
+ {
+ environment.systemPackages = with pkgs; [
+ curl
+ jq
+ ];
+ services.pict-rs.enable = true;
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine.wait_for_unit("pict-rs")
- machine.wait_for_open_port(8080)
- '';
- }
-)
+ machine.wait_for_unit("pict-rs")
+ machine.wait_for_open_port(8080)
+ '';
+}
diff --git a/nixos/tests/pingvin-share.nix b/nixos/tests/pingvin-share.nix
index 5b1ec55add20..5cb5dcd2a3fc 100644
--- a/nixos/tests/pingvin-share.nix
+++ b/nixos/tests/pingvin-share.nix
@@ -1,26 +1,24 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "pingvin-share";
- meta.maintainers = with lib.maintainers; [ ratcornu ];
+{ lib, ... }:
+{
+ name = "pingvin-share";
+ meta.maintainers = with lib.maintainers; [ ratcornu ];
- nodes.machine =
- { ... }:
- {
- services.pingvin-share = {
- enable = true;
+ nodes.machine =
+ { ... }:
+ {
+ services.pingvin-share = {
+ enable = true;
- backend.port = 9010;
- frontend.port = 9011;
- };
+ backend.port = 9010;
+ frontend.port = 9011;
};
+ };
- testScript = ''
- machine.wait_for_unit("pingvin-share-frontend.service")
- machine.wait_for_open_port(9010)
- machine.wait_for_open_port(9011)
- machine.succeed("curl --fail http://127.0.0.1:9010/api/configs")
- machine.succeed("curl --fail http://127.0.0.1:9011/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("pingvin-share-frontend.service")
+ machine.wait_for_open_port(9010)
+ machine.wait_for_open_port(9011)
+ machine.succeed("curl --fail http://127.0.0.1:9010/api/configs")
+ machine.succeed("curl --fail http://127.0.0.1:9011/")
+ '';
+}
diff --git a/nixos/tests/plantuml-server.nix b/nixos/tests/plantuml-server.nix
index b0885ea2630d..e46461bc55ac 100644
--- a/nixos/tests/plantuml-server.nix
+++ b/nixos/tests/plantuml-server.nix
@@ -1,25 +1,23 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "plantuml-server";
- meta.maintainers = with lib.maintainers; [ anthonyroussel ];
+{ pkgs, lib, ... }:
+{
+ name = "plantuml-server";
+ meta.maintainers = with lib.maintainers; [ anthonyroussel ];
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.curl ];
- services.plantuml-server.enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.curl ];
+ services.plantuml-server.enable = true;
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- machine.wait_for_unit("plantuml-server.service")
- machine.wait_for_open_port(8080)
+ machine.wait_for_unit("plantuml-server.service")
+ machine.wait_for_open_port(8080)
- with subtest("Generate chart"):
- chart_id = machine.succeed("curl -sSf http://localhost:8080/plantuml/coder -d 'Alice -> Bob'")
- machine.succeed("curl -sSf http://localhost:8080/plantuml/txt/{}".format(chart_id))
- '';
- }
-)
+ with subtest("Generate chart"):
+ chart_id = machine.succeed("curl -sSf http://localhost:8080/plantuml/coder -d 'Alice -> Bob'")
+ machine.succeed("curl -sSf http://localhost:8080/plantuml/txt/{}".format(chart_id))
+ '';
+}
diff --git a/nixos/tests/plasma-bigscreen.nix b/nixos/tests/plasma-bigscreen.nix
index 4a14564364ac..b429117b3a44 100644
--- a/nixos/tests/plasma-bigscreen.nix
+++ b/nixos/tests/plasma-bigscreen.nix
@@ -1,43 +1,41 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "plasma-bigscreen";
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- ttuegel
- k900
- ];
- };
+{
+ name = "plasma-bigscreen";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ ttuegel
+ k900
+ ];
+ };
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.displayManager.sddm.enable = true;
- services.displayManager.defaultSession = "plasma-bigscreen-x11";
- services.xserver.desktopManager.plasma5.bigscreen.enable = true;
- services.displayManager.autoLogin = {
- enable = true;
- user = "alice";
- };
-
- users.users.alice.extraGroups = [ "uinput" ];
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.displayManager.sddm.enable = true;
+ services.displayManager.defaultSession = "plasma-bigscreen-x11";
+ services.xserver.desktopManager.plasma5.bigscreen.enable = true;
+ services.displayManager.autoLogin = {
+ enable = true;
+ user = "alice";
};
- testScript =
- { nodes, ... }:
- ''
- with subtest("Wait for login"):
- start_all()
- machine.wait_for_file("/tmp/xauth_*")
- machine.succeed("xauth merge /tmp/xauth_*")
+ users.users.alice.extraGroups = [ "uinput" ];
+ };
- with subtest("Check plasmashell started"):
- machine.wait_until_succeeds("pgrep plasmashell")
- machine.wait_for_window("Plasma Big Screen")
- '';
- }
-)
+ testScript =
+ { nodes, ... }:
+ ''
+ with subtest("Wait for login"):
+ start_all()
+ machine.wait_for_file("/tmp/xauth_*")
+ machine.succeed("xauth merge /tmp/xauth_*")
+
+ with subtest("Check plasmashell started"):
+ machine.wait_until_succeeds("pgrep plasmashell")
+ machine.wait_for_window("Plasma Big Screen")
+ '';
+}
diff --git a/nixos/tests/plasma5-systemd-start.nix b/nixos/tests/plasma5-systemd-start.nix
index 9f21c21714b0..6a62f356f839 100644
--- a/nixos/tests/plasma5-systemd-start.nix
+++ b/nixos/tests/plasma5-systemd-start.nix
@@ -1,48 +1,46 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "plasma5-systemd-start";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ oxalica ];
- };
+{
+ name = "plasma5-systemd-start";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ oxalica ];
+ };
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.xserver = {
- enable = true;
- desktopManager.plasma5.enable = true;
- desktopManager.plasma5.runUsingSystemd = true;
- };
-
- services.displayManager = {
- sddm.enable = true;
- defaultSession = "plasma";
- autoLogin = {
- enable = true;
- user = "alice";
- };
- };
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver = {
+ enable = true;
+ desktopManager.plasma5.enable = true;
+ desktopManager.plasma5.runUsingSystemd = true;
};
- testScript =
- { nodes, ... }:
- ''
- with subtest("Wait for login"):
- start_all()
- machine.wait_for_file("/tmp/xauth_*")
- machine.succeed("xauth merge /tmp/xauth_*")
+ services.displayManager = {
+ sddm.enable = true;
+ defaultSession = "plasma";
+ autoLogin = {
+ enable = true;
+ user = "alice";
+ };
+ };
+ };
- with subtest("Check plasmashell started"):
- machine.wait_until_succeeds("pgrep plasmashell")
- machine.wait_for_window("^Desktop ")
+ testScript =
+ { nodes, ... }:
+ ''
+ with subtest("Wait for login"):
+ start_all()
+ machine.wait_for_file("/tmp/xauth_*")
+ machine.succeed("xauth merge /tmp/xauth_*")
- status, result = machine.systemctl('--no-pager show plasma-plasmashell.service', user='alice')
- assert status == 0, 'Service not found'
- assert 'ActiveState=active' in result.split('\n'), 'Systemd service not active'
- '';
- }
-)
+ with subtest("Check plasmashell started"):
+ machine.wait_until_succeeds("pgrep plasmashell")
+ machine.wait_for_window("^Desktop ")
+
+ status, result = machine.systemctl('--no-pager show plasma-plasmashell.service', user='alice')
+ assert status == 0, 'Service not found'
+ assert 'ActiveState=active' in result.split('\n'), 'Systemd service not active'
+ '';
+}
diff --git a/nixos/tests/plasma5.nix b/nixos/tests/plasma5.nix
index d333df24eb8d..7fe677feae92 100644
--- a/nixos/tests/plasma5.nix
+++ b/nixos/tests/plasma5.nix
@@ -1,72 +1,70 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "plasma5";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ttuegel ];
+{
+ name = "plasma5";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ttuegel ];
+ };
+
+ nodes.machine =
+ { ... }:
+
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.displayManager.sddm.enable = true;
+ services.displayManager.defaultSession = "plasma";
+ services.xserver.desktopManager.plasma5.enable = true;
+ environment.plasma5.excludePackages = [ pkgs.plasma5Packages.elisa ];
+ services.displayManager.autoLogin = {
+ enable = true;
+ user = "alice";
+ };
};
- nodes.machine =
- { ... }:
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ xdo = "${pkgs.xdotool}/bin/xdotool";
+ in
+ ''
+ with subtest("Wait for login"):
+ start_all()
+ machine.wait_for_file("/tmp/xauth_*")
+ machine.succeed("xauth merge /tmp/xauth_*")
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.displayManager.sddm.enable = true;
- services.displayManager.defaultSession = "plasma";
- services.xserver.desktopManager.plasma5.enable = true;
- environment.plasma5.excludePackages = [ pkgs.plasma5Packages.elisa ];
- services.displayManager.autoLogin = {
- enable = true;
- user = "alice";
- };
- };
+ with subtest("Check plasmashell started"):
+ machine.wait_until_succeeds("pgrep plasmashell")
+ machine.wait_for_window("^Desktop ")
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- xdo = "${pkgs.xdotool}/bin/xdotool";
- in
- ''
- with subtest("Wait for login"):
- start_all()
- machine.wait_for_file("/tmp/xauth_*")
- machine.succeed("xauth merge /tmp/xauth_*")
+ with subtest("Check that KDED is running"):
+ machine.succeed("pgrep kded5")
- with subtest("Check plasmashell started"):
- machine.wait_until_succeeds("pgrep plasmashell")
- machine.wait_for_window("^Desktop ")
+ with subtest("Check that logging in has given the user ownership of devices"):
+ machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
- with subtest("Check that KDED is running"):
- machine.succeed("pgrep kded5")
+ with subtest("Ensure Elisa is not installed"):
+ machine.fail("which elisa")
- with subtest("Check that logging in has given the user ownership of devices"):
- machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
+ machine.succeed("su - ${user.name} -c 'xauth merge /tmp/xauth_*'")
- with subtest("Ensure Elisa is not installed"):
- machine.fail("which elisa")
+ with subtest("Run Dolphin"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 dolphin >&2 &'")
+ machine.wait_for_window(" Dolphin")
- machine.succeed("su - ${user.name} -c 'xauth merge /tmp/xauth_*'")
+ with subtest("Run Konsole"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 konsole >&2 &'")
+ machine.wait_for_window("Konsole")
- with subtest("Run Dolphin"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 dolphin >&2 &'")
- machine.wait_for_window(" Dolphin")
+ with subtest("Run systemsettings"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 systemsettings5 >&2 &'")
+ machine.wait_for_window("Settings")
- with subtest("Run Konsole"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 konsole >&2 &'")
- machine.wait_for_window("Konsole")
-
- with subtest("Run systemsettings"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 systemsettings5 >&2 &'")
- machine.wait_for_window("Settings")
-
- with subtest("Wait to get a screenshot"):
- machine.execute(
- "${xdo} key Alt+F1 sleep 10"
- )
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Wait to get a screenshot"):
+ machine.execute(
+ "${xdo} key Alt+F1 sleep 10"
+ )
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/plasma6.nix b/nixos/tests/plasma6.nix
index afdb965d5d89..b10d829102ad 100644
--- a/nixos/tests/plasma6.nix
+++ b/nixos/tests/plasma6.nix
@@ -1,70 +1,68 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "plasma6";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ k900 ];
+{
+ name = "plasma6";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ k900 ];
+ };
+
+ nodes.machine =
+ { ... }:
+
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.displayManager.sddm.enable = true;
+ # FIXME: this should be testing Wayland
+ services.displayManager.defaultSession = "plasmax11";
+ services.desktopManager.plasma6.enable = true;
+ environment.plasma6.excludePackages = [ pkgs.kdePackages.elisa ];
+ services.displayManager.autoLogin = {
+ enable = true;
+ user = "alice";
+ };
};
- nodes.machine =
- { ... }:
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.users.users.alice;
+ xdo = "${pkgs.xdotool}/bin/xdotool";
+ in
+ ''
+ with subtest("Wait for login"):
+ start_all()
+ machine.wait_for_file("/tmp/xauth_*")
+ machine.succeed("xauth merge /tmp/xauth_*")
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.displayManager.sddm.enable = true;
- # FIXME: this should be testing Wayland
- services.displayManager.defaultSession = "plasmax11";
- services.desktopManager.plasma6.enable = true;
- environment.plasma6.excludePackages = [ pkgs.kdePackages.elisa ];
- services.displayManager.autoLogin = {
- enable = true;
- user = "alice";
- };
- };
+ with subtest("Check plasmashell started"):
+ machine.wait_until_succeeds("pgrep plasmashell")
+ machine.wait_for_window("^Desktop ")
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.users.users.alice;
- xdo = "${pkgs.xdotool}/bin/xdotool";
- in
- ''
- with subtest("Wait for login"):
- start_all()
- machine.wait_for_file("/tmp/xauth_*")
- machine.succeed("xauth merge /tmp/xauth_*")
+ with subtest("Check that KDED is running"):
+ machine.succeed("pgrep kded6")
- with subtest("Check plasmashell started"):
- machine.wait_until_succeeds("pgrep plasmashell")
- machine.wait_for_window("^Desktop ")
+ with subtest("Ensure Elisa is not installed"):
+ machine.fail("which elisa")
- with subtest("Check that KDED is running"):
- machine.succeed("pgrep kded6")
+ machine.succeed("su - ${user.name} -c 'xauth merge /tmp/xauth_*'")
- with subtest("Ensure Elisa is not installed"):
- machine.fail("which elisa")
+ with subtest("Run Dolphin"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 dolphin >&2 &'")
+ machine.wait_for_window(" Dolphin")
- machine.succeed("su - ${user.name} -c 'xauth merge /tmp/xauth_*'")
+ with subtest("Run Konsole"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 konsole >&2 &'")
+ machine.wait_for_window("Konsole")
- with subtest("Run Dolphin"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 dolphin >&2 &'")
- machine.wait_for_window(" Dolphin")
+ with subtest("Run systemsettings"):
+ machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 systemsettings >&2 &'")
+ machine.wait_for_window("Settings")
- with subtest("Run Konsole"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 konsole >&2 &'")
- machine.wait_for_window("Konsole")
-
- with subtest("Run systemsettings"):
- machine.execute("su - ${user.name} -c 'DISPLAY=:0.0 systemsettings >&2 &'")
- machine.wait_for_window("Settings")
-
- with subtest("Wait to get a screenshot"):
- machine.execute(
- "${xdo} key Alt+F1 sleep 10"
- )
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Wait to get a screenshot"):
+ machine.execute(
+ "${xdo} key Alt+F1 sleep 10"
+ )
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/plausible.nix b/nixos/tests/plausible.nix
index 2076667797db..5253b521c99e 100644
--- a/nixos/tests/plausible.nix
+++ b/nixos/tests/plausible.nix
@@ -1,36 +1,34 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "plausible";
- meta = {
- maintainers = lib.teams.cyberus.members;
- };
+{ lib, ... }:
+{
+ name = "plausible";
+ meta = {
+ maintainers = lib.teams.cyberus.members;
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- virtualisation.memorySize = 4096;
- services.plausible = {
- enable = true;
- server = {
- baseUrl = "http://localhost:8000";
- secretKeybaseFile = "${pkgs.writeText "dont-try-this-at-home" "nannannannannannannannannannannannannannannannannannannan_batman!"}";
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ virtualisation.memorySize = 4096;
+ services.plausible = {
+ enable = true;
+ server = {
+ baseUrl = "http://localhost:8000";
+ secretKeybaseFile = "${pkgs.writeText "dont-try-this-at-home" "nannannannannannannannannannannannannannannannannannannan_batman!"}";
};
};
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("plausible.service")
- machine.wait_for_open_port(8000)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("plausible.service")
+ machine.wait_for_open_port(8000)
- # Ensure that the software does not make not make the machine
- # listen on any public interfaces by default.
- machine.fail("ss -tlpn 'src = 0.0.0.0 or src = [::]' | grep LISTEN")
+ # Ensure that the software does not make not make the machine
+ # listen on any public interfaces by default.
+ machine.fail("ss -tlpn 'src = 0.0.0.0 or src = [::]' | grep LISTEN")
- machine.succeed("curl -f localhost:8000 >&2")
+ machine.succeed("curl -f localhost:8000 >&2")
- machine.succeed("curl -f localhost:8000/js/script.js >&2")
- '';
- }
-)
+ machine.succeed("curl -f localhost:8000/js/script.js >&2")
+ '';
+}
diff --git a/nixos/tests/playwright-python.nix b/nixos/tests/playwright-python.nix
index e479f3a91517..7911dac1b428 100644
--- a/nixos/tests/playwright-python.nix
+++ b/nixos/tests/playwright-python.nix
@@ -1,61 +1,59 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "playwright-python";
+{ pkgs, ... }:
+{
+ name = "playwright-python";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ phaer ];
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ phaer ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.variables = {
+ NIX_MANUAL_DOCROOT = "file://${pkgs.nix.doc}/share/doc/nix/manual/index.html";
+ PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
+ };
+ environment.systemPackages = [
+ (pkgs.writers.writePython3Bin "test_playwright"
+ {
+ libraries = [ pkgs.python3Packages.playwright ];
+ }
+ ''
+ import sys
+ import re
+ from playwright.sync_api import sync_playwright
+ from playwright.sync_api import expect
+
+ browsers = {
+ "chromium": {'args': ["--headless", "--disable-gpu"], 'channel': 'chromium'},
+ "firefox": {},
+ "webkit": {}
+ }
+ needle = re.compile("Nix.*Reference Manual")
+ if len(sys.argv) != 3 or sys.argv[1] not in browsers.keys():
+ print(f"usage: {sys.argv[0]} [{'|'.join(browsers.keys())}] ")
+ sys.exit(1)
+ browser_name = sys.argv[1]
+ url = sys.argv[2]
+ browser_kwargs = browsers.get(browser_name)
+ args = ' '.join(browser_kwargs.get('args', []))
+ print(f"Running test on {browser_name} {args}")
+ with sync_playwright() as p:
+ browser = getattr(p, browser_name).launch(**browser_kwargs)
+ context = browser.new_context()
+ page = context.new_page()
+ page.goto(url)
+ expect(page.get_by_text(needle)).to_be_visible()
+ ''
+ )
+ ];
};
- nodes.machine =
- { pkgs, ... }:
- {
- environment.variables = {
- NIX_MANUAL_DOCROOT = "file://${pkgs.nix.doc}/share/doc/nix/manual/index.html";
- PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
- };
- environment.systemPackages = [
- (pkgs.writers.writePython3Bin "test_playwright"
- {
- libraries = [ pkgs.python3Packages.playwright ];
- }
- ''
- import sys
- import re
- from playwright.sync_api import sync_playwright
- from playwright.sync_api import expect
+ testScript = ''
+ # FIXME: Webkit segfaults
+ for browser in ["firefox", "chromium"]:
+ with subtest(f"Render Nix Manual in {browser}"):
+ machine.succeed(f"test_playwright {browser} $NIX_MANUAL_DOCROOT")
+ '';
- browsers = {
- "chromium": {'args': ["--headless", "--disable-gpu"], 'channel': 'chromium'},
- "firefox": {},
- "webkit": {}
- }
- needle = re.compile("Nix.*Reference Manual")
- if len(sys.argv) != 3 or sys.argv[1] not in browsers.keys():
- print(f"usage: {sys.argv[0]} [{'|'.join(browsers.keys())}] ")
- sys.exit(1)
- browser_name = sys.argv[1]
- url = sys.argv[2]
- browser_kwargs = browsers.get(browser_name)
- args = ' '.join(browser_kwargs.get('args', []))
- print(f"Running test on {browser_name} {args}")
- with sync_playwright() as p:
- browser = getattr(p, browser_name).launch(**browser_kwargs)
- context = browser.new_context()
- page = context.new_page()
- page.goto(url)
- expect(page.get_by_text(needle)).to_be_visible()
- ''
- )
- ];
- };
-
- testScript = ''
- # FIXME: Webkit segfaults
- for browser in ["firefox", "chromium"]:
- with subtest(f"Render Nix Manual in {browser}"):
- machine.succeed(f"test_playwright {browser} $NIX_MANUAL_DOCROOT")
- '';
-
- }
-)
+}
diff --git a/nixos/tests/please.nix b/nixos/tests/please.nix
index 6b461bff4938..7671266ac7e4 100644
--- a/nixos/tests/please.nix
+++ b/nixos/tests/please.nix
@@ -1,68 +1,66 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "please";
- meta.maintainers = [ ];
+{ lib, ... }:
+{
+ name = "please";
+ meta.maintainers = [ ];
- nodes.machine =
- { ... }:
- {
- users.users = lib.mkMerge [
- (lib.listToAttrs (
- map (n: lib.nameValuePair n { isNormalUser = true; }) (lib.genList (x: "user${toString x}") 6)
- ))
- {
- user0.extraGroups = [ "wheel" ];
- }
- ];
+ nodes.machine =
+ { ... }:
+ {
+ users.users = lib.mkMerge [
+ (lib.listToAttrs (
+ map (n: lib.nameValuePair n { isNormalUser = true; }) (lib.genList (x: "user${toString x}") 6)
+ ))
+ {
+ user0.extraGroups = [ "wheel" ];
+ }
+ ];
- security.please = {
- enable = true;
- wheelNeedsPassword = false;
- settings = {
- user2_run_true_as_root = {
- name = "user2";
- target = "root";
- rule = "/run/current-system/sw/bin/true";
- require_pass = false;
- };
- user4_edit_etc_hosts_as_root = {
- name = "user4";
- type = "edit";
- target = "root";
- rule = "/etc/hosts";
- editmode = 644;
- require_pass = false;
- };
+ security.please = {
+ enable = true;
+ wheelNeedsPassword = false;
+ settings = {
+ user2_run_true_as_root = {
+ name = "user2";
+ target = "root";
+ rule = "/run/current-system/sw/bin/true";
+ require_pass = false;
+ };
+ user4_edit_etc_hosts_as_root = {
+ name = "user4";
+ type = "edit";
+ target = "root";
+ rule = "/etc/hosts";
+ editmode = 644;
+ require_pass = false;
};
};
};
+ };
- testScript = ''
- with subtest("root: can run anything by default"):
- machine.succeed('please true')
- with subtest("root: can edit anything by default"):
- machine.succeed('EDITOR=cat pleaseedit /etc/hosts')
+ testScript = ''
+ with subtest("root: can run anything by default"):
+ machine.succeed('please true')
+ with subtest("root: can edit anything by default"):
+ machine.succeed('EDITOR=cat pleaseedit /etc/hosts')
- with subtest("user0: can run as root because it's in the wheel group"):
- machine.succeed('su - user0 -c "please -u root true"')
- with subtest("user1: cannot run as root because it's not in the wheel group"):
- machine.fail('su - user1 -c "please -u root true"')
+ with subtest("user0: can run as root because it's in the wheel group"):
+ machine.succeed('su - user0 -c "please -u root true"')
+ with subtest("user1: cannot run as root because it's not in the wheel group"):
+ machine.fail('su - user1 -c "please -u root true"')
- with subtest("user0: can edit as root"):
- machine.succeed('su - user0 -c "EDITOR=cat pleaseedit /etc/hosts"')
- with subtest("user1: cannot edit as root"):
- machine.fail('su - user1 -c "EDITOR=cat pleaseedit /etc/hosts"')
+ with subtest("user0: can edit as root"):
+ machine.succeed('su - user0 -c "EDITOR=cat pleaseedit /etc/hosts"')
+ with subtest("user1: cannot edit as root"):
+ machine.fail('su - user1 -c "EDITOR=cat pleaseedit /etc/hosts"')
- with subtest("user2: can run 'true' as root"):
- machine.succeed('su - user2 -c "please -u root true"')
- with subtest("user3: cannot run 'true' as root"):
- machine.fail('su - user3 -c "please -u root true"')
+ with subtest("user2: can run 'true' as root"):
+ machine.succeed('su - user2 -c "please -u root true"')
+ with subtest("user3: cannot run 'true' as root"):
+ machine.fail('su - user3 -c "please -u root true"')
- with subtest("user4: can edit /etc/hosts"):
- machine.succeed('su - user4 -c "EDITOR=cat pleaseedit /etc/hosts"')
- with subtest("user5: cannot edit /etc/hosts"):
- machine.fail('su - user5 -c "EDITOR=cat pleaseedit /etc/hosts"')
- '';
- }
-)
+ with subtest("user4: can edit /etc/hosts"):
+ machine.succeed('su - user4 -c "EDITOR=cat pleaseedit /etc/hosts"')
+ with subtest("user5: cannot edit /etc/hosts"):
+ machine.fail('su - user5 -c "EDITOR=cat pleaseedit /etc/hosts"')
+ '';
+}
diff --git a/nixos/tests/plikd.nix b/nixos/tests/plikd.nix
index 05a1c6017d2d..b22c26302081 100644
--- a/nixos/tests/plikd.nix
+++ b/nixos/tests/plikd.nix
@@ -1,33 +1,31 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "plikd";
- meta = with lib.maintainers; {
- maintainers = [ freezeboy ];
+{ lib, ... }:
+{
+ name = "plikd";
+ meta = with lib.maintainers; {
+ maintainers = [ freezeboy ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ let
+ in
+ {
+ services.plikd.enable = true;
+ environment.systemPackages = [ pkgs.plik ];
};
- nodes.machine =
- { pkgs, ... }:
- let
- in
- {
- services.plikd.enable = true;
- environment.systemPackages = [ pkgs.plik ];
- };
+ testScript = ''
+ # Service basic test
+ machine.wait_for_unit("plikd")
- testScript = ''
- # Service basic test
- machine.wait_for_unit("plikd")
+ # Network test
+ machine.wait_for_open_port(8080)
+ machine.succeed("curl --fail -v http://localhost:8080")
- # Network test
- machine.wait_for_open_port(8080)
- machine.succeed("curl --fail -v http://localhost:8080")
+ # Application test
+ machine.execute("echo test > /tmp/data.txt")
+ machine.succeed("plik --server http://localhost:8080 /tmp/data.txt | grep curl")
- # Application test
- machine.execute("echo test > /tmp/data.txt")
- machine.succeed("plik --server http://localhost:8080 /tmp/data.txt | grep curl")
-
- machine.succeed("diff data.txt /tmp/data.txt")
- '';
- }
-)
+ machine.succeed("diff data.txt /tmp/data.txt")
+ '';
+}
diff --git a/nixos/tests/plotinus.nix b/nixos/tests/plotinus.nix
index 97041012756a..f1ea049ff449 100644
--- a/nixos/tests/plotinus.nix
+++ b/nixos/tests/plotinus.nix
@@ -1,36 +1,34 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "plotinus";
- meta = {
- maintainers = pkgs.plotinus.meta.maintainers;
- timeout = 600;
+{ pkgs, ... }:
+{
+ name = "plotinus";
+ meta = {
+ maintainers = pkgs.plotinus.meta.maintainers;
+ timeout = 600;
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+
+ {
+ imports = [ ./common/x11.nix ];
+ programs.plotinus.enable = true;
+ environment.systemPackages = [
+ pkgs.gnome-pomodoro
+ pkgs.xdotool
+ ];
};
- nodes.machine =
- { pkgs, ... }:
-
- {
- imports = [ ./common/x11.nix ];
- programs.plotinus.enable = true;
- environment.systemPackages = [
- pkgs.gnome-pomodoro
- pkgs.xdotool
- ];
- };
-
- testScript = ''
- machine.wait_for_x()
- machine.succeed("gnome-pomodoro >&2 &")
- machine.wait_for_window("Pomodoro", timeout=120)
- machine.succeed(
- "xdotool search --sync --onlyvisible --class gnome-pomodoro "
- + "windowfocus --sync key --clearmodifiers --delay 1 'ctrl+shift+p'"
- )
- machine.sleep(5) # wait for the popup
- machine.screenshot("popup")
- machine.succeed("xdotool key --delay 100 p r e f e r e n c e s Return")
- machine.wait_for_window("Preferences", timeout=120)
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_x()
+ machine.succeed("gnome-pomodoro >&2 &")
+ machine.wait_for_window("Pomodoro", timeout=120)
+ machine.succeed(
+ "xdotool search --sync --onlyvisible --class gnome-pomodoro "
+ + "windowfocus --sync key --clearmodifiers --delay 1 'ctrl+shift+p'"
+ )
+ machine.sleep(5) # wait for the popup
+ machine.screenshot("popup")
+ machine.succeed("xdotool key --delay 100 p r e f e r e n c e s Return")
+ machine.wait_for_window("Preferences", timeout=120)
+ '';
+}
diff --git a/nixos/tests/pocket-id.nix b/nixos/tests/pocket-id.nix
index 753fa251473f..830ba3e8c760 100644
--- a/nixos/tests/pocket-id.nix
+++ b/nixos/tests/pocket-id.nix
@@ -1,47 +1,45 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "pocket-id";
- meta.maintainers = with lib.maintainers; [
- gepbird
- ymstnt
- ];
+{
+ name = "pocket-id";
+ meta.maintainers = with lib.maintainers; [
+ gepbird
+ ymstnt
+ ];
- nodes = {
- machine =
- { ... }:
- {
- services.pocket-id = {
- enable = true;
- settings = {
- PORT = 10001;
- INTERNAL_BACKEND_URL = "http://localhost:10002";
- BACKEND_PORT = 10002;
- };
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.pocket-id = {
+ enable = true;
+ settings = {
+ PORT = 10001;
+ INTERNAL_BACKEND_URL = "http://localhost:10002";
+ BACKEND_PORT = 10002;
};
};
- };
+ };
+ };
- testScript =
- { nodes, ... }:
- let
- inherit (nodes.machine.services.pocket-id) settings;
- inherit (builtins) toString;
- in
- ''
- machine.wait_for_unit("pocket-id-backend.service")
- machine.wait_for_open_port(${toString settings.BACKEND_PORT})
- machine.wait_for_unit("pocket-id-frontend.service")
- machine.wait_for_open_port(${toString settings.PORT})
+ testScript =
+ { nodes, ... }:
+ let
+ inherit (nodes.machine.services.pocket-id) settings;
+ inherit (builtins) toString;
+ in
+ ''
+ machine.wait_for_unit("pocket-id-backend.service")
+ machine.wait_for_open_port(${toString settings.BACKEND_PORT})
+ machine.wait_for_unit("pocket-id-frontend.service")
+ machine.wait_for_open_port(${toString settings.PORT})
- backend_status = machine.succeed("curl -L -o /tmp/backend-output -w '%{http_code}' http://localhost:${toString settings.BACKEND_PORT}/api/users/me")
- assert backend_status == "401"
- machine.succeed("grep 'You are not signed in' /tmp/backend-output")
+ backend_status = machine.succeed("curl -L -o /tmp/backend-output -w '%{http_code}' http://localhost:${toString settings.BACKEND_PORT}/api/users/me")
+ assert backend_status == "401"
+ machine.succeed("grep 'You are not signed in' /tmp/backend-output")
- frontend_status = machine.succeed("curl -L -o /tmp/frontend-output -w '%{http_code}' http://localhost:${toString settings.PORT}")
- assert frontend_status == "200"
- machine.succeed("grep 'Sign in to Pocket ID' /tmp/frontend-output")
- '';
- }
-)
+ frontend_status = machine.succeed("curl -L -o /tmp/frontend-output -w '%{http_code}' http://localhost:${toString settings.PORT}")
+ assert frontend_status == "200"
+ machine.succeed("grep 'Sign in to Pocket ID' /tmp/frontend-output")
+ '';
+}
diff --git a/nixos/tests/podgrab.nix b/nixos/tests/podgrab.nix
index 05c2fd726016..cefe5d373d99 100644
--- a/nixos/tests/podgrab.nix
+++ b/nixos/tests/podgrab.nix
@@ -2,40 +2,38 @@ let
defaultPort = 8080;
customPort = 4242;
in
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "podgrab";
+{ pkgs, ... }:
+{
+ name = "podgrab";
- nodes = {
- default =
- { ... }:
- {
- services.podgrab.enable = true;
+ nodes = {
+ default =
+ { ... }:
+ {
+ services.podgrab.enable = true;
+ };
+
+ customized =
+ { ... }:
+ {
+ services.podgrab = {
+ enable = true;
+ port = customPort;
};
+ };
+ };
- customized =
- { ... }:
- {
- services.podgrab = {
- enable = true;
- port = customPort;
- };
- };
- };
+ testScript = ''
+ start_all()
- testScript = ''
- start_all()
+ default.wait_for_unit("podgrab")
+ default.wait_for_open_port(${toString defaultPort})
+ default.succeed("curl --fail http://localhost:${toString defaultPort}")
- default.wait_for_unit("podgrab")
- default.wait_for_open_port(${toString defaultPort})
- default.succeed("curl --fail http://localhost:${toString defaultPort}")
+ customized.wait_for_unit("podgrab")
+ customized.wait_for_open_port(${toString customPort})
+ customized.succeed("curl --fail http://localhost:${toString customPort}")
+ '';
- customized.wait_for_unit("podgrab")
- customized.wait_for_open_port(${toString customPort})
- customized.succeed("curl --fail http://localhost:${toString customPort}")
- '';
-
- meta.maintainers = with pkgs.lib.maintainers; [ ambroisie ];
- }
-)
+ meta.maintainers = with pkgs.lib.maintainers; [ ambroisie ];
+}
diff --git a/nixos/tests/polaris.nix b/nixos/tests/polaris.nix
index 3a530996d63a..59e4b37337bf 100644
--- a/nixos/tests/polaris.nix
+++ b/nixos/tests/polaris.nix
@@ -1,32 +1,30 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "polaris";
- meta.maintainers = with lib.maintainers; [ pbsds ];
+{
+ name = "polaris";
+ meta.maintainers = with lib.maintainers; [ pbsds ];
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.jq ];
- services.polaris = {
- enable = true;
- port = 5050;
- settings.users = [
- {
- name = "test_user";
- password = "very_secret_password";
- admin = true;
- }
- ];
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.jq ];
+ services.polaris = {
+ enable = true;
+ port = 5050;
+ settings.users = [
+ {
+ name = "test_user";
+ password = "very_secret_password";
+ admin = true;
+ }
+ ];
};
+ };
- testScript = ''
- machine.wait_for_unit("polaris.service")
- machine.wait_for_open_port(5050)
- machine.succeed("curl http://localhost:5050/api/version")
- machine.succeed("curl -X GET http://localhost:5050/api/initial_setup -H 'accept: application/json' | jq -e '.has_any_users == true'")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("polaris.service")
+ machine.wait_for_open_port(5050)
+ machine.succeed("curl http://localhost:5050/api/version")
+ machine.succeed("curl -X GET http://localhost:5050/api/initial_setup -H 'accept: application/json' | jq -e '.has_any_users == true'")
+ '';
+}
diff --git a/nixos/tests/portunus.nix b/nixos/tests/portunus.nix
index 5bfe990943b5..5562c7f5ac8a 100644
--- a/nixos/tests/portunus.nix
+++ b/nixos/tests/portunus.nix
@@ -1,20 +1,18 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "portunus";
- meta.maintainers = with lib.maintainers; [ SuperSandro2000 ];
+{
+ name = "portunus";
+ meta.maintainers = with lib.maintainers; [ SuperSandro2000 ];
- nodes.machine = _: {
- services.portunus = {
- enable = true;
- ldap.suffix = "dc=example,dc=org";
- };
+ nodes.machine = _: {
+ services.portunus = {
+ enable = true;
+ ldap.suffix = "dc=example,dc=org";
};
+ };
- testScript = ''
- machine.wait_for_unit("portunus.service")
- machine.succeed("curl --fail -vvv http://localhost:8080/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("portunus.service")
+ machine.succeed("curl --fail -vvv http://localhost:8080/")
+ '';
+}
diff --git a/nixos/tests/postfixadmin.nix b/nixos/tests/postfixadmin.nix
index 9162de429482..2994efcfca47 100644
--- a/nixos/tests/postfixadmin.nix
+++ b/nixos/tests/postfixadmin.nix
@@ -1,36 +1,34 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "postfixadmin";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ globin ];
- };
+{ pkgs, ... }:
+{
+ name = "postfixadmin";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ globin ];
+ };
- nodes = {
- postfixadmin =
- { config, pkgs, ... }:
- {
- services.postfixadmin = {
- enable = true;
- hostName = "postfixadmin";
- setupPasswordFile = pkgs.writeText "insecure-test-setup-pw-file" "$2y$10$r0p63YCjd9rb9nHrV9UtVuFgGTmPDLKu.0UIJoQTkWCZZze2iuB1m";
- };
- services.nginx.virtualHosts.postfixadmin = {
- forceSSL = false;
- enableACME = false;
- };
+ nodes = {
+ postfixadmin =
+ { config, pkgs, ... }:
+ {
+ services.postfixadmin = {
+ enable = true;
+ hostName = "postfixadmin";
+ setupPasswordFile = pkgs.writeText "insecure-test-setup-pw-file" "$2y$10$r0p63YCjd9rb9nHrV9UtVuFgGTmPDLKu.0UIJoQTkWCZZze2iuB1m";
};
- };
+ services.nginx.virtualHosts.postfixadmin = {
+ forceSSL = false;
+ enableACME = false;
+ };
+ };
+ };
- testScript = ''
- postfixadmin.start
- postfixadmin.wait_for_unit("postgresql.service")
- postfixadmin.wait_for_unit("phpfpm-postfixadmin.service")
- postfixadmin.wait_for_unit("nginx.service")
- postfixadmin.succeed(
- "curl -sSfL http://postfixadmin/setup.php -X POST -F 'setup_password=not production'"
- )
- postfixadmin.succeed("curl -sSfL http://postfixadmin/ | grep 'Mail admins login here'")
- '';
- }
-)
+ testScript = ''
+ postfixadmin.start
+ postfixadmin.wait_for_unit("postgresql.service")
+ postfixadmin.wait_for_unit("phpfpm-postfixadmin.service")
+ postfixadmin.wait_for_unit("nginx.service")
+ postfixadmin.succeed(
+ "curl -sSfL http://postfixadmin/setup.php -X POST -F 'setup_password=not production'"
+ )
+ postfixadmin.succeed("curl -sSfL http://postfixadmin/ | grep 'Mail admins login here'")
+ '';
+}
diff --git a/nixos/tests/power-profiles-daemon.nix b/nixos/tests/power-profiles-daemon.nix
index a1f10afda9e6..75a45c437f63 100644
--- a/nixos/tests/power-profiles-daemon.nix
+++ b/nixos/tests/power-profiles-daemon.nix
@@ -1,64 +1,62 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "power-profiles-daemon";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ mvnetbiz ];
+{
+ name = "power-profiles-daemon";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ mvnetbiz ];
+ };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ security.polkit.enable = true;
+ services.power-profiles-daemon.enable = true;
+ environment.systemPackages = [
+ pkgs.glib
+ pkgs.power-profiles-daemon
+ ];
};
- nodes.machine =
- { pkgs, ... }:
- {
- security.polkit.enable = true;
- services.power-profiles-daemon.enable = true;
- environment.systemPackages = [
- pkgs.glib
- pkgs.power-profiles-daemon
- ];
- };
- testScript = ''
- def get_profile():
- return machine.succeed(
- """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
- --method org.freedesktop.DBus.Properties.Get 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile'
- """
- )
+ testScript = ''
+ def get_profile():
+ return machine.succeed(
+ """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
+ --method org.freedesktop.DBus.Properties.Get 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile'
+ """
+ )
- def set_profile(profile):
- return machine.succeed(
- """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
- --method org.freedesktop.DBus.Properties.Set 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
- """.format(
- profile=profile
- )
- )
+ def set_profile(profile):
+ return machine.succeed(
+ """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
+ --method org.freedesktop.DBus.Properties.Set 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
+ """.format(
+ profile=profile
+ )
+ )
- machine.wait_for_unit("multi-user.target")
+ machine.wait_for_unit("multi-user.target")
- set_profile("power-saver")
- profile = get_profile()
- if not "power-saver" in profile:
- raise Exception("Unable to set power-saver profile")
+ set_profile("power-saver")
+ profile = get_profile()
+ if not "power-saver" in profile:
+ raise Exception("Unable to set power-saver profile")
- set_profile("balanced")
- profile = get_profile()
- if not "balanced" in profile:
- raise Exception("Unable to set balanced profile")
+ set_profile("balanced")
+ profile = get_profile()
+ if not "balanced" in profile:
+ raise Exception("Unable to set balanced profile")
- # test powerprofilectl CLI
- machine.succeed("powerprofilesctl set power-saver")
- profile = get_profile()
- if not "power-saver" in profile:
- raise Exception("Unable to set power-saver profile with powerprofilectl")
+ # test powerprofilectl CLI
+ machine.succeed("powerprofilesctl set power-saver")
+ profile = get_profile()
+ if not "power-saver" in profile:
+ raise Exception("Unable to set power-saver profile with powerprofilectl")
- machine.succeed("powerprofilesctl set balanced")
- profile = get_profile()
- if not "balanced" in profile:
- raise Exception("Unable to set balanced profile with powerprofilectl")
- '';
- }
-)
+ machine.succeed("powerprofilesctl set balanced")
+ profile = get_profile()
+ if not "balanced" in profile:
+ raise Exception("Unable to set balanced profile with powerprofilectl")
+ '';
+}
diff --git a/nixos/tests/powerdns.nix b/nixos/tests/powerdns.nix
index 9ca6e597b6be..2813fa89bee5 100644
--- a/nixos/tests/powerdns.nix
+++ b/nixos/tests/powerdns.nix
@@ -2,71 +2,69 @@
# generic MySQL backend (gmysql) to connect to a
# MariaDB server using UNIX sockets authentication.
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "powerdns";
+{ pkgs, lib, ... }:
+{
+ name = "powerdns";
- nodes.server =
- { ... }:
- {
- services.powerdns.enable = true;
- services.powerdns.extraConfig = ''
- launch=gmysql
- gmysql-user=pdns
- zone-cache-refresh-interval=0
- '';
+ nodes.server =
+ { ... }:
+ {
+ services.powerdns.enable = true;
+ services.powerdns.extraConfig = ''
+ launch=gmysql
+ gmysql-user=pdns
+ zone-cache-refresh-interval=0
+ '';
- services.mysql = {
- enable = true;
- package = pkgs.mariadb;
- ensureDatabases = [ "powerdns" ];
- ensureUsers = lib.singleton {
- name = "pdns";
- ensurePermissions = {
- "powerdns.*" = "ALL PRIVILEGES";
- };
+ services.mysql = {
+ enable = true;
+ package = pkgs.mariadb;
+ ensureDatabases = [ "powerdns" ];
+ ensureUsers = lib.singleton {
+ name = "pdns";
+ ensurePermissions = {
+ "powerdns.*" = "ALL PRIVILEGES";
};
};
-
- environment.systemPackages = with pkgs; [
- dnsutils
- powerdns
- mariadb
- ];
};
- testScript = ''
- with subtest("PowerDNS database exists"):
- server.wait_for_unit("mysql")
- server.succeed("echo 'SHOW DATABASES;' | sudo -u pdns mysql -u pdns >&2")
+ environment.systemPackages = with pkgs; [
+ dnsutils
+ powerdns
+ mariadb
+ ];
+ };
- with subtest("Loading the MySQL schema works"):
- server.succeed(
- "sudo -u pdns mysql -u pdns -D powerdns <"
- "${pkgs.powerdns}/share/doc/pdns/schema.mysql.sql"
- )
+ testScript = ''
+ with subtest("PowerDNS database exists"):
+ server.wait_for_unit("mysql")
+ server.succeed("echo 'SHOW DATABASES;' | sudo -u pdns mysql -u pdns >&2")
- with subtest("PowerDNS server starts"):
- server.wait_for_unit("pdns")
- server.succeed("dig version.bind txt chaos @127.0.0.1 >&2")
+ with subtest("Loading the MySQL schema works"):
+ server.succeed(
+ "sudo -u pdns mysql -u pdns -D powerdns <"
+ "${pkgs.powerdns}/share/doc/pdns/schema.mysql.sql"
+ )
- with subtest("Adding an example zone works"):
- # Extract configuration file needed by pdnsutil
- pdnsutil = "sudo -u pdns pdnsutil "
- server.succeed(f"{pdnsutil} create-zone example.com ns1.example.com")
- server.succeed(f"{pdnsutil} add-record example.com ns1 A 192.168.1.2")
+ with subtest("PowerDNS server starts"):
+ server.wait_for_unit("pdns")
+ server.succeed("dig version.bind txt chaos @127.0.0.1 >&2")
- with subtest("Querying the example zone works"):
- reply = server.succeed("dig +noall +answer ns1.example.com @127.0.0.1")
- assert (
- "192.168.1.2" in reply
- ), f""""
- The reply does not contain the expected IP address:
- Expected:
- ns1.example.com. 3600 IN A 192.168.1.2
- Reply:
- {reply}"""
- '';
- }
-)
+ with subtest("Adding an example zone works"):
+ # Extract configuration file needed by pdnsutil
+ pdnsutil = "sudo -u pdns pdnsutil "
+ server.succeed(f"{pdnsutil} create-zone example.com ns1.example.com")
+ server.succeed(f"{pdnsutil} add-record example.com ns1 A 192.168.1.2")
+
+ with subtest("Querying the example zone works"):
+ reply = server.succeed("dig +noall +answer ns1.example.com @127.0.0.1")
+ assert (
+ "192.168.1.2" in reply
+ ), f""""
+ The reply does not contain the expected IP address:
+ Expected:
+ ns1.example.com. 3600 IN A 192.168.1.2
+ Reply:
+ {reply}"""
+ '';
+}
diff --git a/nixos/tests/pppd.nix b/nixos/tests/pppd.nix
index ad4927e9e67b..20cc03bfc7e7 100644
--- a/nixos/tests/pppd.nix
+++ b/nixos/tests/pppd.nix
@@ -1,75 +1,73 @@
-import ./make-test-python.nix (
- let
- chap-secrets = {
- text = ''"flynn" * "reindeerflotilla" *'';
- mode = "0640";
- };
- in
- { pkgs, ... }:
- {
- name = "pppd";
+let
+ chap-secrets = {
+ text = ''"flynn" * "reindeerflotilla" *'';
+ mode = "0640";
+ };
+in
+{ pkgs, ... }:
+{
+ name = "pppd";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ stv0g ];
- };
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ stv0g ];
+ };
- nodes = {
- server =
- { config, pkgs, ... }:
- {
- config = {
- # Run a PPPoE access concentrator server. It will spawn an
- # appropriate PPP server process when a PPPoE client sets up a
- # PPPoE session.
- systemd.services.pppoe-server = {
- restartTriggers = [
- config.environment.etc."ppp/pppoe-server-options".source
- config.environment.etc."ppp/chap-secrets".source
- ];
- after = [ "network.target" ];
- serviceConfig = {
- ExecStart = "${pkgs.rpPPPoE}/sbin/pppoe-server -F -O /etc/ppp/pppoe-server-options -q ${pkgs.ppp}/sbin/pppd -I eth1 -L 192.0.2.1 -R 192.0.2.2";
- };
- wantedBy = [ "multi-user.target" ];
- };
- environment.etc = {
- "ppp/pppoe-server-options".text = ''
- lcp-echo-interval 10
- lcp-echo-failure 2
- plugin pppoe.so
- require-chap
- nobsdcomp
- noccp
- novj
- '';
- "ppp/chap-secrets" = chap-secrets;
+ nodes = {
+ server =
+ { config, pkgs, ... }:
+ {
+ config = {
+ # Run a PPPoE access concentrator server. It will spawn an
+ # appropriate PPP server process when a PPPoE client sets up a
+ # PPPoE session.
+ systemd.services.pppoe-server = {
+ restartTriggers = [
+ config.environment.etc."ppp/pppoe-server-options".source
+ config.environment.etc."ppp/chap-secrets".source
+ ];
+ after = [ "network.target" ];
+ serviceConfig = {
+ ExecStart = "${pkgs.rpPPPoE}/sbin/pppoe-server -F -O /etc/ppp/pppoe-server-options -q ${pkgs.ppp}/sbin/pppd -I eth1 -L 192.0.2.1 -R 192.0.2.2";
};
+ wantedBy = [ "multi-user.target" ];
+ };
+ environment.etc = {
+ "ppp/pppoe-server-options".text = ''
+ lcp-echo-interval 10
+ lcp-echo-failure 2
+ plugin pppoe.so
+ require-chap
+ nobsdcomp
+ noccp
+ novj
+ '';
+ "ppp/chap-secrets" = chap-secrets;
};
};
- client =
- { config, pkgs, ... }:
- {
- services.pppd = {
- enable = true;
- peers.test = {
- config = ''
- plugin pppoe.so eth1
- name "flynn"
- noipdefault
- persist
- noauth
- debug
- '';
- };
+ };
+ client =
+ { config, pkgs, ... }:
+ {
+ services.pppd = {
+ enable = true;
+ peers.test = {
+ config = ''
+ plugin pppoe.so eth1
+ name "flynn"
+ noipdefault
+ persist
+ noauth
+ debug
+ '';
};
- environment.etc."ppp/chap-secrets" = chap-secrets;
};
- };
+ environment.etc."ppp/chap-secrets" = chap-secrets;
+ };
+ };
- testScript = ''
- start_all()
- client.wait_until_succeeds("ping -c1 -W1 192.0.2.1")
- server.wait_until_succeeds("ping -c1 -W1 192.0.2.2")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ client.wait_until_succeeds("ping -c1 -W1 192.0.2.1")
+ server.wait_until_succeeds("ping -c1 -W1 192.0.2.2")
+ '';
+}
diff --git a/nixos/tests/private-gpt.nix b/nixos/tests/private-gpt.nix
index f6bfda38aabf..f5c005165ab1 100644
--- a/nixos/tests/private-gpt.nix
+++ b/nixos/tests/private-gpt.nix
@@ -1,31 +1,29 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- mainPort = "8001";
- in
- {
- name = "private-gpt";
- meta = with lib.maintainers; {
- maintainers = [ ];
- };
+{ pkgs, lib, ... }:
+let
+ mainPort = "8001";
+in
+{
+ name = "private-gpt";
+ meta = with lib.maintainers; {
+ maintainers = [ ];
+ };
- nodes = {
- machine =
- { ... }:
- {
- services.private-gpt = {
- enable = true;
- };
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.private-gpt = {
+ enable = true;
};
- };
+ };
+ };
- testScript = ''
- machine.start()
+ testScript = ''
+ machine.start()
- machine.wait_for_unit("private-gpt.service")
- machine.wait_for_open_port(${mainPort})
+ machine.wait_for_unit("private-gpt.service")
+ machine.wait_for_open_port(${mainPort})
- machine.succeed("curl http://127.0.0.1:${mainPort}")
- '';
- }
-)
+ machine.succeed("curl http://127.0.0.1:${mainPort}")
+ '';
+}
diff --git a/nixos/tests/privoxy.nix b/nixos/tests/privoxy.nix
index 0c0cb6ab2e31..acbd1f81e878 100644
--- a/nixos/tests/privoxy.nix
+++ b/nixos/tests/privoxy.nix
@@ -1,155 +1,153 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- let
- # Note: For some reason Privoxy can't issue valid
- # certificates if the CA is generated using gnutls :(
- certs = pkgs.runCommand "example-certs" { buildInputs = [ pkgs.openssl ]; } ''
- mkdir $out
+let
+ # Note: For some reason Privoxy can't issue valid
+ # certificates if the CA is generated using gnutls :(
+ certs = pkgs.runCommand "example-certs" { buildInputs = [ pkgs.openssl ]; } ''
+ mkdir $out
- # generate CA keypair
- openssl req -new -nodes -x509 \
- -extensions v3_ca -keyout $out/ca.key \
- -out $out/ca.crt -days 365 \
- -subj "/O=Privoxy CA/CN=Privoxy CA"
+ # generate CA keypair
+ openssl req -new -nodes -x509 \
+ -extensions v3_ca -keyout $out/ca.key \
+ -out $out/ca.crt -days 365 \
+ -subj "/O=Privoxy CA/CN=Privoxy CA"
- # generate server key/signing request
- openssl genrsa -out $out/server.key 3072
- openssl req -new -key $out/server.key \
- -out server.csr -sha256 \
- -subj "/O=An unhappy server./CN=example.com"
+ # generate server key/signing request
+ openssl genrsa -out $out/server.key 3072
+ openssl req -new -key $out/server.key \
+ -out server.csr -sha256 \
+ -subj "/O=An unhappy server./CN=example.com"
- # sign the request/generate the certificate
- openssl x509 -req -in server.csr -CA $out/ca.crt \
- -CAkey $out/ca.key -CAcreateserial -out $out/server.crt \
- -days 500 -sha256
- '';
- in
+ # sign the request/generate the certificate
+ openssl x509 -req -in server.csr -CA $out/ca.crt \
+ -CAkey $out/ca.key -CAcreateserial -out $out/server.crt \
+ -days 500 -sha256
+ '';
+in
- {
- name = "privoxy";
- meta = with lib.maintainers; {
- maintainers = [ rnhmjoj ];
+{
+ name = "privoxy";
+ meta = with lib.maintainers; {
+ maintainers = [ rnhmjoj ];
+ };
+
+ nodes.machine =
+ { ... }:
+ {
+ services.nginx.enable = true;
+ services.nginx.virtualHosts."example.com" = {
+ addSSL = true;
+ sslCertificate = "${certs}/server.crt";
+ sslCertificateKey = "${certs}/server.key";
+ locations."/".root = pkgs.writeTextFile {
+ name = "bad-day";
+ destination = "/how-are-you/index.html";
+ text = "I've had a bad day!\n";
+ };
+ locations."/ads".extraConfig = ''
+ return 200 "Hot Nixpkgs PRs in your area. Click here!\n";
+ '';
+ };
+
+ services.privoxy = {
+ enable = true;
+ inspectHttps = true;
+ settings = {
+ ca-cert-file = "${certs}/ca.crt";
+ ca-key-file = "${certs}/ca.key";
+ debug = 65536;
+ };
+ userActions = ''
+ {+filter{positive}}
+ example.com
+
+ {+block{Fake ads}}
+ example.com/ads
+ '';
+ userFilters = ''
+ FILTER: positive This is a filter example.
+ s/bad/great/ig
+ '';
+ };
+
+ security.pki.certificateFiles = [ "${certs}/ca.crt" ];
+
+ networking.hosts."::1" = [ "example.com" ];
+ networking.proxy.httpProxy = "http://localhost:8118";
+ networking.proxy.httpsProxy = "http://localhost:8118";
};
- nodes.machine =
- { ... }:
- {
- services.nginx.enable = true;
- services.nginx.virtualHosts."example.com" = {
- addSSL = true;
- sslCertificate = "${certs}/server.crt";
- sslCertificateKey = "${certs}/server.key";
- locations."/".root = pkgs.writeTextFile {
- name = "bad-day";
- destination = "/how-are-you/index.html";
- text = "I've had a bad day!\n";
- };
- locations."/ads".extraConfig = ''
- return 200 "Hot Nixpkgs PRs in your area. Click here!\n";
- '';
- };
-
- services.privoxy = {
- enable = true;
- inspectHttps = true;
- settings = {
- ca-cert-file = "${certs}/ca.crt";
- ca-key-file = "${certs}/ca.key";
- debug = 65536;
- };
- userActions = ''
- {+filter{positive}}
- example.com
-
- {+block{Fake ads}}
- example.com/ads
- '';
- userFilters = ''
- FILTER: positive This is a filter example.
- s/bad/great/ig
- '';
- };
-
- security.pki.certificateFiles = [ "${certs}/ca.crt" ];
-
- networking.hosts."::1" = [ "example.com" ];
- networking.proxy.httpProxy = "http://localhost:8118";
- networking.proxy.httpsProxy = "http://localhost:8118";
+ nodes.machine_socks4 =
+ { ... }:
+ {
+ services.privoxy = {
+ enable = true;
+ settings.forward-socks4 = "/ 127.0.0.1:9050 .";
};
-
- nodes.machine_socks4 =
- { ... }:
- {
- services.privoxy = {
- enable = true;
- settings.forward-socks4 = "/ 127.0.0.1:9050 .";
- };
+ };
+ nodes.machine_socks4a =
+ { ... }:
+ {
+ services.privoxy = {
+ enable = true;
+ settings.forward-socks4a = "/ 127.0.0.1:9050 .";
};
- nodes.machine_socks4a =
- { ... }:
- {
- services.privoxy = {
- enable = true;
- settings.forward-socks4a = "/ 127.0.0.1:9050 .";
- };
+ };
+ nodes.machine_socks5 =
+ { ... }:
+ {
+ services.privoxy = {
+ enable = true;
+ settings.forward-socks5 = "/ 127.0.0.1:9050 .";
};
- nodes.machine_socks5 =
- { ... }:
- {
- services.privoxy = {
- enable = true;
- settings.forward-socks5 = "/ 127.0.0.1:9050 .";
- };
- };
- nodes.machine_socks5t =
- { ... }:
- {
- services.privoxy = {
- enable = true;
- settings.forward-socks5t = "/ 127.0.0.1:9050 .";
- };
+ };
+ nodes.machine_socks5t =
+ { ... }:
+ {
+ services.privoxy = {
+ enable = true;
+ settings.forward-socks5t = "/ 127.0.0.1:9050 .";
};
+ };
- testScript = ''
- with subtest("Privoxy is running"):
- machine.wait_for_unit("privoxy")
- machine.wait_for_open_port(8118)
- machine.succeed("curl -f http://config.privoxy.org")
+ testScript = ''
+ with subtest("Privoxy is running"):
+ machine.wait_for_unit("privoxy")
+ machine.wait_for_open_port(8118)
+ machine.succeed("curl -f http://config.privoxy.org")
- with subtest("Privoxy can filter http requests"):
- machine.wait_for_open_port(80)
- assert "great day" in machine.succeed(
- "curl -sfL http://example.com/how-are-you? | tee /dev/stderr"
- )
+ with subtest("Privoxy can filter http requests"):
+ machine.wait_for_open_port(80)
+ assert "great day" in machine.succeed(
+ "curl -sfL http://example.com/how-are-you? | tee /dev/stderr"
+ )
- with subtest("Privoxy can filter https requests"):
- machine.wait_for_open_port(443)
- assert "great day" in machine.succeed(
- "curl -sfL https://example.com/how-are-you? | tee /dev/stderr"
- )
+ with subtest("Privoxy can filter https requests"):
+ machine.wait_for_open_port(443)
+ assert "great day" in machine.succeed(
+ "curl -sfL https://example.com/how-are-you? | tee /dev/stderr"
+ )
- with subtest("Blocks are working"):
- machine.wait_for_open_port(443)
- machine.fail("curl -f https://example.com/ads 1>&2")
- machine.succeed("curl -f https://example.com/PRIVOXY-FORCE/ads 1>&2")
+ with subtest("Blocks are working"):
+ machine.wait_for_open_port(443)
+ machine.fail("curl -f https://example.com/ads 1>&2")
+ machine.succeed("curl -f https://example.com/PRIVOXY-FORCE/ads 1>&2")
- with subtest("Temporary certificates are cleaned"):
- # Count current certificates
- machine.succeed("test $(ls /run/privoxy/certs | wc -l) -gt 0")
- # Forward in time 12 days, trigger the timer..
- machine.succeed("date -s \"$(date --date '12 days')\"")
- machine.systemctl("start systemd-tmpfiles-clean")
- # ...and count again
- machine.succeed("test $(ls /run/privoxy/certs | wc -l) -eq 0")
+ with subtest("Temporary certificates are cleaned"):
+ # Count current certificates
+ machine.succeed("test $(ls /run/privoxy/certs | wc -l) -gt 0")
+ # Forward in time 12 days, trigger the timer..
+ machine.succeed("date -s \"$(date --date '12 days')\"")
+ machine.systemctl("start systemd-tmpfiles-clean")
+ # ...and count again
+ machine.succeed("test $(ls /run/privoxy/certs | wc -l) -eq 0")
- with subtest("Privoxy supports socks upstream proxies"):
- for m in [machine_socks4, machine_socks4a, machine_socks5, machine_socks5t]:
- m.wait_for_unit("privoxy")
- m.wait_for_open_port(8118)
- # We expect a 503 error because the dummy upstream proxy is not reachable.
- # In issue #265654, instead privoxy segfaulted causing curl to exit with "Empty reply from server".
- m.succeed("http_proxy=http://localhost:8118 curl -v http://does-not-exist/ 2>&1 | grep 'HTTP/1.1 503'")
- '';
- }
-)
+ with subtest("Privoxy supports socks upstream proxies"):
+ for m in [machine_socks4, machine_socks4a, machine_socks5, machine_socks5t]:
+ m.wait_for_unit("privoxy")
+ m.wait_for_open_port(8118)
+ # We expect a 503 error because the dummy upstream proxy is not reachable.
+ # In issue #265654, instead privoxy segfaulted causing curl to exit with "Empty reply from server".
+ m.succeed("http_proxy=http://localhost:8118 curl -v http://does-not-exist/ 2>&1 | grep 'HTTP/1.1 503'")
+ '';
+}
diff --git a/nixos/tests/proxy.nix b/nixos/tests/proxy.nix
index beba1d843592..2526ce954c5b 100644
--- a/nixos/tests/proxy.nix
+++ b/nixos/tests/proxy.nix
@@ -1,100 +1,98 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- backend =
- { pkgs, ... }:
+let
+ backend =
+ { pkgs, ... }:
+ {
+ services.httpd = {
+ enable = true;
+ adminAddr = "foo@example.org";
+ virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
+ };
+ networking.firewall.allowedTCPPorts = [ 80 ];
+ };
+in
+{
+ name = "proxy";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ ];
+ };
+
+ nodes = {
+ proxy =
+ { nodes, ... }:
{
services.httpd = {
enable = true;
- adminAddr = "foo@example.org";
- virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
+ adminAddr = "bar@example.org";
+ extraModules = [
+ "proxy_balancer"
+ "lbmethod_byrequests"
+ ];
+ extraConfig = ''
+ ExtendedStatus on
+ '';
+ virtualHosts.localhost = {
+ extraConfig = ''
+
+ Require all granted
+ SetHandler server-status
+
+
+
+ Require all granted
+ BalancerMember http://${nodes.backend1.config.networking.hostName} retry=0
+ BalancerMember http://${nodes.backend2.config.networking.hostName} retry=0
+
+
+ ProxyStatus full
+ ProxyPass /server-status !
+ ProxyPass / balancer://cluster/
+ ProxyPassReverse / balancer://cluster/
+
+ # For testing; don't want to wait forever for dead backend servers.
+ ProxyTimeout 5
+ '';
+ };
};
networking.firewall.allowedTCPPorts = [ 80 ];
};
- in
- {
- name = "proxy";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ ];
- };
- nodes = {
- proxy =
- { nodes, ... }:
- {
- services.httpd = {
- enable = true;
- adminAddr = "bar@example.org";
- extraModules = [
- "proxy_balancer"
- "lbmethod_byrequests"
- ];
- extraConfig = ''
- ExtendedStatus on
- '';
- virtualHosts.localhost = {
- extraConfig = ''
-
- Require all granted
- SetHandler server-status
-
+ backend1 = backend;
+ backend2 = backend;
-
- Require all granted
- BalancerMember http://${nodes.backend1.config.networking.hostName} retry=0
- BalancerMember http://${nodes.backend2.config.networking.hostName} retry=0
-
+ client = { ... }: { };
+ };
- ProxyStatus full
- ProxyPass /server-status !
- ProxyPass / balancer://cluster/
- ProxyPassReverse / balancer://cluster/
+ testScript = ''
+ start_all()
- # For testing; don't want to wait forever for dead backend servers.
- ProxyTimeout 5
- '';
- };
- };
- networking.firewall.allowedTCPPorts = [ 80 ];
- };
+ proxy.wait_for_unit("httpd")
+ backend1.wait_for_unit("httpd")
+ backend2.wait_for_unit("httpd")
+ client.wait_for_unit("network.target")
- backend1 = backend;
- backend2 = backend;
+ # With the back-ends up, the proxy should work.
+ client.succeed("curl --fail http://proxy/")
- client = { ... }: { };
- };
+ client.succeed("curl --fail http://proxy/server-status")
- testScript = ''
- start_all()
+ # Block the first back-end.
+ backend1.block()
- proxy.wait_for_unit("httpd")
- backend1.wait_for_unit("httpd")
- backend2.wait_for_unit("httpd")
- client.wait_for_unit("network.target")
+ # The proxy should still work.
+ client.succeed("curl --fail http://proxy/")
+ client.succeed("curl --fail http://proxy/")
- # With the back-ends up, the proxy should work.
- client.succeed("curl --fail http://proxy/")
+ # Block the second back-end.
+ backend2.block()
- client.succeed("curl --fail http://proxy/server-status")
+ # Now the proxy should fail as well.
+ client.fail("curl --fail http://proxy/")
- # Block the first back-end.
- backend1.block()
-
- # The proxy should still work.
- client.succeed("curl --fail http://proxy/")
- client.succeed("curl --fail http://proxy/")
-
- # Block the second back-end.
- backend2.block()
-
- # Now the proxy should fail as well.
- client.fail("curl --fail http://proxy/")
-
- # But if the second back-end comes back, the proxy should start
- # working again.
- backend2.unblock()
- client.succeed("curl --fail http://proxy/")
- '';
- }
-)
+ # But if the second back-end comes back, the proxy should start
+ # working again.
+ backend2.unblock()
+ client.succeed("curl --fail http://proxy/")
+ '';
+}
diff --git a/nixos/tests/pt2-clone.nix b/nixos/tests/pt2-clone.nix
index 98df2e8cbac3..160431175f8d 100644
--- a/nixos/tests/pt2-clone.nix
+++ b/nixos/tests/pt2-clone.nix
@@ -1,37 +1,35 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "pt2-clone";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ fgaz ];
+{ pkgs, ... }:
+{
+ name = "pt2-clone";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fgaz ];
+ };
+
+ nodes.machine =
+ { config, pkgs, ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ];
+
+ services.xserver.enable = true;
+ environment.systemPackages = [ pkgs.pt2-clone ];
};
- nodes.machine =
- { config, pkgs, ... }:
- {
- imports = [
- ./common/x11.nix
- ];
+ enableOCR = true;
- services.xserver.enable = true;
- environment.systemPackages = [ pkgs.pt2-clone ];
- };
+ testScript = ''
+ machine.wait_for_x()
+ # Add a dummy sound card, or the program won't start
+ machine.execute("modprobe snd-dummy")
- enableOCR = true;
+ machine.execute("pt2-clone >&2 &")
- testScript = ''
- machine.wait_for_x()
- # Add a dummy sound card, or the program won't start
- machine.execute("modprobe snd-dummy")
-
- machine.execute("pt2-clone >&2 &")
-
- machine.wait_for_window(r"ProTracker")
- machine.sleep(5)
- # One of the few words that actually get recognized
- if "LENGTH" not in machine.get_screen_text():
- raise Exception("Program did not start successfully")
- machine.screenshot("screen")
- '';
- }
-)
+ machine.wait_for_window(r"ProTracker")
+ machine.sleep(5)
+ # One of the few words that actually get recognized
+ if "LENGTH" not in machine.get_screen_text():
+ raise Exception("Program did not start successfully")
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/public-inbox.nix b/nixos/tests/public-inbox.nix
index 698dbf2eb799..23163f0bc982 100644
--- a/nixos/tests/public-inbox.nix
+++ b/nixos/tests/public-inbox.nix
@@ -1,244 +1,242 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- orga = "example";
- domain = "${orga}.localdomain";
+{ pkgs, lib, ... }:
+let
+ orga = "example";
+ domain = "${orga}.localdomain";
- tls-cert = pkgs.runCommand "selfSignedCert" { buildInputs = [ pkgs.openssl ]; } ''
- openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 36500 \
- -subj '/CN=machine.${domain}'
- install -D -t $out key.pem cert.pem
- '';
+ tls-cert = pkgs.runCommand "selfSignedCert" { buildInputs = [ pkgs.openssl ]; } ''
+ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 36500 \
+ -subj '/CN=machine.${domain}'
+ install -D -t $out key.pem cert.pem
+ '';
- gitRepositories = [
- "repo1"
- "repo2"
- ];
- in
- {
- name = "public-inbox";
+ gitRepositories = [
+ "repo1"
+ "repo2"
+ ];
+in
+{
+ name = "public-inbox";
- meta.maintainers = with pkgs.lib.maintainers; [ julm ];
+ meta.maintainers = with pkgs.lib.maintainers; [ julm ];
- nodes.machine =
- {
- config,
- pkgs,
- nodes,
- ...
- }:
- let
- inherit (config.services) public-inbox;
- in
- {
- virtualisation.diskSize = 1 * 1024;
- virtualisation.memorySize = 1 * 1024;
- networking.domain = domain;
+ nodes.machine =
+ {
+ config,
+ pkgs,
+ nodes,
+ ...
+ }:
+ let
+ inherit (config.services) public-inbox;
+ in
+ {
+ virtualisation.diskSize = 1 * 1024;
+ virtualisation.memorySize = 1 * 1024;
+ networking.domain = domain;
- security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
- # If using security.acme:
- #security.acme.certs."${domain}".postRun = ''
- # systemctl try-restart public-inbox-nntpd public-inbox-imapd
- #'';
+ security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
+ # If using security.acme:
+ #security.acme.certs."${domain}".postRun = ''
+ # systemctl try-restart public-inbox-nntpd public-inbox-imapd
+ #'';
- services.public-inbox = {
+ services.public-inbox = {
+ enable = true;
+ postfix.enable = true;
+ openFirewall = true;
+ settings.publicinbox = {
+ css = [ "href=https://machine.${domain}/style/light.css" ];
+ nntpserver = [ "nntps://machine.${domain}" ];
+ wwwlisting = "match=domain";
+ };
+ mda = {
enable = true;
- postfix.enable = true;
- openFirewall = true;
- settings.publicinbox = {
- css = [ "href=https://machine.${domain}/style/light.css" ];
- nntpserver = [ "nntps://machine.${domain}" ];
- wwwlisting = "match=domain";
- };
- mda = {
- enable = true;
- args = [ "--no-precheck" ]; # Allow Bcc:
- };
- http = {
- enable = true;
- port = "/run/public-inbox-http.sock";
- #port = 8080;
- args = [ "-W0" ];
- mounts = [
- "https://machine.${domain}/inbox"
- ];
- };
- nntp = {
- enable = true;
- #port = 563;
- args = [ "-W0" ];
- cert = "${tls-cert}/cert.pem";
- key = "${tls-cert}/key.pem";
- };
- imap = {
- enable = true;
- #port = 993;
- args = [ "-W0" ];
- cert = "${tls-cert}/cert.pem";
- key = "${tls-cert}/key.pem";
- };
- inboxes =
- lib.recursiveUpdate
- (lib.genAttrs gitRepositories (repo: {
- address = [
- # Routed to the "public-inbox:" transport in services.postfix.transport
- "${repo}@${domain}"
+ args = [ "--no-precheck" ]; # Allow Bcc:
+ };
+ http = {
+ enable = true;
+ port = "/run/public-inbox-http.sock";
+ #port = 8080;
+ args = [ "-W0" ];
+ mounts = [
+ "https://machine.${domain}/inbox"
+ ];
+ };
+ nntp = {
+ enable = true;
+ #port = 563;
+ args = [ "-W0" ];
+ cert = "${tls-cert}/cert.pem";
+ key = "${tls-cert}/key.pem";
+ };
+ imap = {
+ enable = true;
+ #port = 993;
+ args = [ "-W0" ];
+ cert = "${tls-cert}/cert.pem";
+ key = "${tls-cert}/key.pem";
+ };
+ inboxes =
+ lib.recursiveUpdate
+ (lib.genAttrs gitRepositories (repo: {
+ address = [
+ # Routed to the "public-inbox:" transport in services.postfix.transport
+ "${repo}@${domain}"
+ ];
+ description = ''
+ ${repo}@${domain} :
+ discussions about ${repo}.
+ '';
+ url = "https://machine.${domain}/inbox/${repo}";
+ newsgroup = "inbox.comp.${orga}.${repo}";
+ coderepo = [ repo ];
+ }))
+ {
+ repo2 = {
+ hide = [
+ "imap" # FIXME: doesn't work for IMAP as of public-inbox 1.6.1
+ "manifest"
+ "www"
];
- description = ''
- ${repo}@${domain} :
- discussions about ${repo}.
- '';
- url = "https://machine.${domain}/inbox/${repo}";
- newsgroup = "inbox.comp.${orga}.${repo}";
- coderepo = [ repo ];
- }))
- {
- repo2 = {
- hide = [
- "imap" # FIXME: doesn't work for IMAP as of public-inbox 1.6.1
- "manifest"
- "www"
- ];
- };
};
- settings.coderepo = lib.listToAttrs (
- map (
- repositoryName:
- lib.nameValuePair repositoryName {
- dir = "/var/lib/public-inbox/repositories/${repositoryName}.git";
- cgitUrl = "https://git.${domain}/${repositoryName}.git";
- }
- ) gitRepositories
- );
- };
-
- # Use nginx as a reverse proxy for public-inbox-httpd
- services.nginx = {
- enable = true;
- recommendedGzipSettings = true;
- recommendedOptimisation = true;
- recommendedTlsSettings = true;
- recommendedProxySettings = true;
- virtualHosts."machine.${domain}" = {
- forceSSL = true;
- sslCertificate = "${tls-cert}/cert.pem";
- sslCertificateKey = "${tls-cert}/key.pem";
- locations."/".return = "302 /inbox";
- locations."= /inbox".return = "302 /inbox/";
- locations."/inbox".proxyPass = "http://unix:${public-inbox.http.port}:/inbox";
- # If using TCP instead of a Unix socket:
- #locations."/inbox".proxyPass = "http://127.0.0.1:${toString public-inbox.http.port}/inbox";
- # Referred to by settings.publicinbox.css
- # See http://public-inbox.org/meta/_/text/color/
- locations."= /style/light.css".alias = pkgs.writeText "light.css" ''
- * { background:#fff; color:#000 }
-
- a { color:#00f; text-decoration:none }
- a:visited { color:#808 }
-
- *.q { color:#008 }
-
- *.add { color:#060 }
- *.del {color:#900 }
- *.head { color:#000 }
- *.hunk { color:#960 }
-
- .hl.num { color:#f30 } /* number */
- .hl.esc { color:#f0f } /* escape character */
- .hl.str { color:#f30 } /* string */
- .hl.ppc { color:#c3c } /* preprocessor */
- .hl.pps { color:#f30 } /* preprocessor string */
- .hl.slc { color:#099 } /* single-line comment */
- .hl.com { color:#099 } /* multi-line comment */
- /* .hl.opt { color:#ccc } */ /* operator */
- /* .hl.ipl { color:#ccc } */ /* interpolation */
-
- /* keyword groups kw[a-z] */
- .hl.kwa { color:#f90 }
- .hl.kwb { color:#060 }
- .hl.kwc { color:#f90 }
- /* .hl.kwd { color:#ccc } */
- '';
- };
- };
-
- services.postfix = {
- enable = true;
- setSendmail = true;
- #sslCert = "${tls-cert}/cert.pem";
- #sslKey = "${tls-cert}/key.pem";
- recipientDelimiter = "+";
- };
-
- environment.systemPackages = [
- pkgs.gitMinimal
- pkgs.mailutils
- pkgs.openssl
- ];
-
+ };
+ settings.coderepo = lib.listToAttrs (
+ map (
+ repositoryName:
+ lib.nameValuePair repositoryName {
+ dir = "/var/lib/public-inbox/repositories/${repositoryName}.git";
+ cgitUrl = "https://git.${domain}/${repositoryName}.git";
+ }
+ ) gitRepositories
+ );
};
- testScript = ''
- start_all()
+ # Use nginx as a reverse proxy for public-inbox-httpd
+ services.nginx = {
+ enable = true;
+ recommendedGzipSettings = true;
+ recommendedOptimisation = true;
+ recommendedTlsSettings = true;
+ recommendedProxySettings = true;
+ virtualHosts."machine.${domain}" = {
+ forceSSL = true;
+ sslCertificate = "${tls-cert}/cert.pem";
+ sslCertificateKey = "${tls-cert}/key.pem";
+ locations."/".return = "302 /inbox";
+ locations."= /inbox".return = "302 /inbox/";
+ locations."/inbox".proxyPass = "http://unix:${public-inbox.http.port}:/inbox";
+ # If using TCP instead of a Unix socket:
+ #locations."/inbox".proxyPass = "http://127.0.0.1:${toString public-inbox.http.port}/inbox";
+ # Referred to by settings.publicinbox.css
+ # See http://public-inbox.org/meta/_/text/color/
+ locations."= /style/light.css".alias = pkgs.writeText "light.css" ''
+ * { background:#fff; color:#000 }
- # The threshold and/or hardening may have to be changed with new features/checks
- with subtest("systemd hardening thresholds"):
- print(machine.succeed("systemd-analyze security public-inbox-httpd.service --threshold=5 --no-pager"))
- print(machine.succeed("systemd-analyze security public-inbox-imapd.service --threshold=5 --no-pager"))
- print(machine.succeed("systemd-analyze security public-inbox-nntpd.service --threshold=4 --no-pager"))
+ a { color:#00f; text-decoration:none }
+ a:visited { color:#808 }
- machine.wait_for_unit("multi-user.target")
- machine.wait_for_unit("public-inbox-init.service")
+ *.q { color:#008 }
- machine.succeed(
- ${lib.concatMapStrings (repositoryName: ''
- "sudo -u public-inbox git init --bare -b main /var/lib/public-inbox/repositories/${repositoryName}.git",
- '') gitRepositories}
- )
+ *.add { color:#060 }
+ *.del {color:#900 }
+ *.head { color:#000 }
+ *.hunk { color:#960 }
- # List inboxes through public-inbox-httpd
- machine.wait_for_unit("public-inbox-httpd.socket")
- machine.wait_for_unit("nginx.service")
- machine.succeed("curl -L https://machine.${domain} | grep repo1@${domain}")
- # The repo2 inbox is hidden
- machine.fail("curl -L https://machine.${domain} | grep repo2@${domain}")
+ .hl.num { color:#f30 } /* number */
+ .hl.esc { color:#f0f } /* escape character */
+ .hl.str { color:#f30 } /* string */
+ .hl.ppc { color:#c3c } /* preprocessor */
+ .hl.pps { color:#f30 } /* preprocessor string */
+ .hl.slc { color:#099 } /* single-line comment */
+ .hl.com { color:#099 } /* multi-line comment */
+ /* .hl.opt { color:#ccc } */ /* operator */
+ /* .hl.ipl { color:#ccc } */ /* interpolation */
- # Send a mail and read it through public-inbox-httpd
- # Must work too when using a recipientDelimiter.
- machine.wait_for_unit("postfix.service")
- machine.succeed("mail -t <${pkgs.writeText "mail" ''
- Subject: Testing mail
- From: root@localhost
- To: repo1+extension@${domain}
- Message-ID:
- Content-Type: text/plain; charset=utf-8
- Content-Disposition: inline
+ /* keyword groups kw[a-z] */
+ .hl.kwa { color:#f90 }
+ .hl.kwb { color:#060 }
+ .hl.kwc { color:#f90 }
+ /* .hl.kwd { color:#ccc } */
+ '';
+ };
+ };
- This is a testing mail.
- ''}")
- machine.sleep(10)
- machine.succeed("curl -L 'https://machine.${domain}/inbox/repo1/repo1@root-1/T/#u' | grep 'This is a testing mail.'")
+ services.postfix = {
+ enable = true;
+ setSendmail = true;
+ #sslCert = "${tls-cert}/cert.pem";
+ #sslKey = "${tls-cert}/key.pem";
+ recipientDelimiter = "+";
+ };
- # Read a mail through public-inbox-imapd
- machine.wait_for_unit("public-inbox-imapd.socket")
- machine.succeed("openssl s_client -ign_eof -crlf -connect machine.${domain}:993 <${pkgs.writeText "imap-commands" ''
- tag login anonymous@${domain} anonymous
- tag SELECT INBOX.comp.${orga}.repo1.0
- tag FETCH 1 (BODY[HEADER])
- tag LOGOUT
- ''} | grep '^Message-ID: '")
+ environment.systemPackages = [
+ pkgs.gitMinimal
+ pkgs.mailutils
+ pkgs.openssl
+ ];
- # TODO: Read a mail through public-inbox-nntpd
- #machine.wait_for_unit("public-inbox-nntpd.socket")
+ };
- # Delete a mail.
- # Note that the use of an extension not listed in the addresses
- # require to use --all
- machine.succeed("curl -L https://machine.${domain}/inbox/repo1/repo1@root-1/raw | sudo -u public-inbox public-inbox-learn rm --all")
- machine.fail("curl -L https://machine.${domain}/inbox/repo1/repo1@root-1/T/#u | grep 'This is a testing mail.'")
+ testScript = ''
+ start_all()
- # Compact the database
- machine.succeed("sudo -u public-inbox public-inbox-compact --all")
- '';
- }
-)
+ # The threshold and/or hardening may have to be changed with new features/checks
+ with subtest("systemd hardening thresholds"):
+ print(machine.succeed("systemd-analyze security public-inbox-httpd.service --threshold=5 --no-pager"))
+ print(machine.succeed("systemd-analyze security public-inbox-imapd.service --threshold=5 --no-pager"))
+ print(machine.succeed("systemd-analyze security public-inbox-nntpd.service --threshold=4 --no-pager"))
+
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_for_unit("public-inbox-init.service")
+
+ machine.succeed(
+ ${lib.concatMapStrings (repositoryName: ''
+ "sudo -u public-inbox git init --bare -b main /var/lib/public-inbox/repositories/${repositoryName}.git",
+ '') gitRepositories}
+ )
+
+ # List inboxes through public-inbox-httpd
+ machine.wait_for_unit("public-inbox-httpd.socket")
+ machine.wait_for_unit("nginx.service")
+ machine.succeed("curl -L https://machine.${domain} | grep repo1@${domain}")
+ # The repo2 inbox is hidden
+ machine.fail("curl -L https://machine.${domain} | grep repo2@${domain}")
+
+ # Send a mail and read it through public-inbox-httpd
+ # Must work too when using a recipientDelimiter.
+ machine.wait_for_unit("postfix.service")
+ machine.succeed("mail -t <${pkgs.writeText "mail" ''
+ Subject: Testing mail
+ From: root@localhost
+ To: repo1+extension@${domain}
+ Message-ID:
+ Content-Type: text/plain; charset=utf-8
+ Content-Disposition: inline
+
+ This is a testing mail.
+ ''}")
+ machine.sleep(10)
+ machine.succeed("curl -L 'https://machine.${domain}/inbox/repo1/repo1@root-1/T/#u' | grep 'This is a testing mail.'")
+
+ # Read a mail through public-inbox-imapd
+ machine.wait_for_unit("public-inbox-imapd.socket")
+ machine.succeed("openssl s_client -ign_eof -crlf -connect machine.${domain}:993 <${pkgs.writeText "imap-commands" ''
+ tag login anonymous@${domain} anonymous
+ tag SELECT INBOX.comp.${orga}.repo1.0
+ tag FETCH 1 (BODY[HEADER])
+ tag LOGOUT
+ ''} | grep '^Message-ID: '")
+
+ # TODO: Read a mail through public-inbox-nntpd
+ #machine.wait_for_unit("public-inbox-nntpd.socket")
+
+ # Delete a mail.
+ # Note that the use of an extension not listed in the addresses
+ # require to use --all
+ machine.succeed("curl -L https://machine.${domain}/inbox/repo1/repo1@root-1/raw | sudo -u public-inbox public-inbox-learn rm --all")
+ machine.fail("curl -L https://machine.${domain}/inbox/repo1/repo1@root-1/T/#u | grep 'This is a testing mail.'")
+
+ # Compact the database
+ machine.succeed("sudo -u public-inbox public-inbox-compact --all")
+ '';
+}
diff --git a/nixos/tests/pufferpanel.nix b/nixos/tests/pufferpanel.nix
index e0613b43b7de..0b695a57d266 100644
--- a/nixos/tests/pufferpanel.nix
+++ b/nixos/tests/pufferpanel.nix
@@ -1,79 +1,77 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "pufferpanel";
- meta.maintainers = [ lib.maintainers.tie ];
+{ lib, ... }:
+{
+ name = "pufferpanel";
+ meta.maintainers = [ lib.maintainers.tie ];
- nodes.machine =
- { pkgs, ... }:
- {
- environment.systemPackages = [ pkgs.pufferpanel ];
- services.pufferpanel = {
- enable = true;
- extraPackages = [ pkgs.netcat ];
- environment = {
- PUFFER_PANEL_REGISTRATIONENABLED = "false";
- PUFFER_PANEL_SETTINGS_COMPANYNAME = "NixOS";
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.pufferpanel ];
+ services.pufferpanel = {
+ enable = true;
+ extraPackages = [ pkgs.netcat ];
+ environment = {
+ PUFFER_PANEL_REGISTRATIONENABLED = "false";
+ PUFFER_PANEL_SETTINGS_COMPANYNAME = "NixOS";
};
};
+ };
- testScript = ''
- import shlex
- import json
+ testScript = ''
+ import shlex
+ import json
- curl = "curl --fail-with-body --silent"
- baseURL = "http://localhost:8080"
- adminName = "admin"
- adminEmail = "admin@nixos.org"
- adminPass = "admin"
- adminCreds = json.dumps({
- "email": adminEmail,
- "password": adminPass,
- })
- stopCode = 9 # SIGKILL
- serverPort = 1337
- serverDefinition = json.dumps({
- "name": "netcat",
- "node": 0,
- "users": [
- adminName,
- ],
- "type": "netcat",
- "run": {
- "stopCode": stopCode,
- "command": f"nc -l {serverPort}",
- },
- "environment": {
- "type": "standard",
- },
- })
+ curl = "curl --fail-with-body --silent"
+ baseURL = "http://localhost:8080"
+ adminName = "admin"
+ adminEmail = "admin@nixos.org"
+ adminPass = "admin"
+ adminCreds = json.dumps({
+ "email": adminEmail,
+ "password": adminPass,
+ })
+ stopCode = 9 # SIGKILL
+ serverPort = 1337
+ serverDefinition = json.dumps({
+ "name": "netcat",
+ "node": 0,
+ "users": [
+ adminName,
+ ],
+ "type": "netcat",
+ "run": {
+ "stopCode": stopCode,
+ "command": f"nc -l {serverPort}",
+ },
+ "environment": {
+ "type": "standard",
+ },
+ })
- start_all()
+ start_all()
- machine.wait_for_unit("pufferpanel.service")
- machine.wait_for_open_port(5657) # SFTP
- machine.wait_for_open_port(8080) # HTTP
+ machine.wait_for_unit("pufferpanel.service")
+ machine.wait_for_open_port(5657) # SFTP
+ machine.wait_for_open_port(8080) # HTTP
- # Note that PufferPanel does not initialize database unless necessary.
- # /api/config endpoint creates database file and triggers migrations.
- # On success, we run a command to create administrator user that we use to
- # interact with HTTP API.
- resp = json.loads(machine.succeed(f"{curl} {baseURL}/api/config"))
- assert resp["branding"]["name"] == "NixOS", "Invalid company name in configuration"
- assert resp["registrationEnabled"] == False, "Expected registration to be disabled"
+ # Note that PufferPanel does not initialize database unless necessary.
+ # /api/config endpoint creates database file and triggers migrations.
+ # On success, we run a command to create administrator user that we use to
+ # interact with HTTP API.
+ resp = json.loads(machine.succeed(f"{curl} {baseURL}/api/config"))
+ assert resp["branding"]["name"] == "NixOS", "Invalid company name in configuration"
+ assert resp["registrationEnabled"] == False, "Expected registration to be disabled"
- machine.succeed(f"pufferpanel --workDir /var/lib/pufferpanel user add --admin --name {adminName} --email {adminEmail} --password {adminPass}")
+ machine.succeed(f"pufferpanel --workDir /var/lib/pufferpanel user add --admin --name {adminName} --email {adminEmail} --password {adminPass}")
- resp = json.loads(machine.succeed(f"{curl} -d '{adminCreds}' {baseURL}/auth/login"))
- assert "servers.admin" in resp["scopes"], "User is not administrator"
- token = resp["session"]
- authHeader = shlex.quote(f"Authorization: Bearer {token}")
+ resp = json.loads(machine.succeed(f"{curl} -d '{adminCreds}' {baseURL}/auth/login"))
+ assert "servers.admin" in resp["scopes"], "User is not administrator"
+ token = resp["session"]
+ authHeader = shlex.quote(f"Authorization: Bearer {token}")
- resp = json.loads(machine.succeed(f"{curl} -H {authHeader} -H 'Content-Type: application/json' -d '{serverDefinition}' {baseURL}/api/servers"))
- serverID = resp["id"]
- machine.succeed(f"{curl} -X POST -H {authHeader} {baseURL}/proxy/daemon/server/{serverID}/start")
- machine.wait_for_open_port(serverPort)
- '';
- }
-)
+ resp = json.loads(machine.succeed(f"{curl} -H {authHeader} -H 'Content-Type: application/json' -d '{serverDefinition}' {baseURL}/api/servers"))
+ serverID = resp["id"]
+ machine.succeed(f"{curl} -X POST -H {authHeader} {baseURL}/proxy/daemon/server/{serverID}/start")
+ machine.wait_for_open_port(serverPort)
+ '';
+}
diff --git a/nixos/tests/pykms.nix b/nixos/tests/pykms.nix
index e7df338a9fc2..035b9f314e67 100644
--- a/nixos/tests/pykms.nix
+++ b/nixos/tests/pykms.nix
@@ -1,23 +1,21 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "pykms-test";
- meta.maintainers = with pkgs.lib.maintainers; [ zopieux ];
+{ pkgs, ... }:
+{
+ name = "pykms-test";
+ meta.maintainers = with pkgs.lib.maintainers; [ zopieux ];
- nodes.machine =
- {
- config,
- lib,
- pkgs,
- ...
- }:
- {
- services.pykms.enable = true;
- };
+ nodes.machine =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ services.pykms.enable = true;
+ };
- testScript = ''
- machine.wait_for_unit("pykms.service")
- machine.succeed("${pkgs.pykms}/bin/client")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("pykms.service")
+ machine.succeed("${pkgs.pykms}/bin/client")
+ '';
+}
diff --git a/nixos/tests/pyload.nix b/nixos/tests/pyload.nix
index 9f87faec2b2c..317f1c43a53d 100644
--- a/nixos/tests/pyload.nix
+++ b/nixos/tests/pyload.nix
@@ -1,38 +1,36 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "pyload";
- meta.maintainers = with lib.maintainers; [ ambroisie ];
+{ lib, ... }:
+{
+ name = "pyload";
+ meta.maintainers = with lib.maintainers; [ ambroisie ];
- nodes = {
- machine =
- { ... }:
- {
- services.pyload = {
- enable = true;
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.pyload = {
+ enable = true;
- listenAddress = "0.0.0.0";
- port = 9876;
- };
-
- networking.firewall.allowedTCPPorts = [ 9876 ];
+ listenAddress = "0.0.0.0";
+ port = 9876;
};
- client = { };
- };
+ networking.firewall.allowedTCPPorts = [ 9876 ];
+ };
- testScript = ''
- start_all()
+ client = { };
+ };
- machine.wait_for_unit("pyload.service")
+ testScript = ''
+ start_all()
- with subtest("Web interface accessible locally"):
- machine.wait_until_succeeds("curl -fs localhost:9876")
+ machine.wait_for_unit("pyload.service")
- client.wait_for_unit("network.target")
+ with subtest("Web interface accessible locally"):
+ machine.wait_until_succeeds("curl -fs localhost:9876")
- with subtest("Web interface accessible from a different machine"):
- client.wait_until_succeeds("curl -fs machine:9876")
- '';
- }
-)
+ client.wait_for_unit("network.target")
+
+ with subtest("Web interface accessible from a different machine"):
+ client.wait_until_succeeds("curl -fs machine:9876")
+ '';
+}
diff --git a/nixos/tests/qownnotes.nix b/nixos/tests/qownnotes.nix
index 710492f59bf5..3c5de65e5cfc 100644
--- a/nixos/tests/qownnotes.nix
+++ b/nixos/tests/qownnotes.nix
@@ -1,88 +1,86 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- {
- name = "qownnotes";
- meta.maintainers = [ lib.maintainers.pbek ];
+{
+ name = "qownnotes";
+ meta.maintainers = [ lib.maintainers.pbek ];
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [
- ./common/user-account.nix
- ./common/x11.nix
- ];
+ {
+ imports = [
+ ./common/user-account.nix
+ ./common/x11.nix
+ ];
- test-support.displayManager.auto.user = "alice";
- environment.systemPackages = [
- pkgs.qownnotes
- pkgs.xdotool
- ];
- };
+ test-support.displayManager.auto.user = "alice";
+ environment.systemPackages = [
+ pkgs.qownnotes
+ pkgs.xdotool
+ ];
+ };
- enableOCR = true;
+ enableOCR = true;
- # https://nixos.org/manual/nixos/stable/#ssec-machine-objects
- testScript =
- { nodes, ... }:
- let
- aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");'';
- in
- ''
- with subtest("Ensure X starts"):
- start_all()
- machine.wait_for_x()
+ # https://nixos.org/manual/nixos/stable/#ssec-machine-objects
+ testScript =
+ { nodes, ... }:
+ let
+ aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");'';
+ in
+ ''
+ with subtest("Ensure X starts"):
+ start_all()
+ machine.wait_for_x()
- with subtest("Check QOwnNotes version on CLI"):
- ${aliceDo "qownnotes --version"}
+ with subtest("Check QOwnNotes version on CLI"):
+ ${aliceDo "qownnotes --version"}
- machine.wait_for_console_text("QOwnNotes ${pkgs.qownnotes.version}")
+ machine.wait_for_console_text("QOwnNotes ${pkgs.qownnotes.version}")
- with subtest("Ensure QOwnNotes starts"):
- # start QOwnNotes window
- ${aliceDo "qownnotes"}
+ with subtest("Ensure QOwnNotes starts"):
+ # start QOwnNotes window
+ ${aliceDo "qownnotes"}
- machine.wait_for_text("Welcome to QOwnNotes")
- machine.screenshot("QOwnNotes-Welcome")
+ machine.wait_for_text("Welcome to QOwnNotes")
+ machine.screenshot("QOwnNotes-Welcome")
- with subtest("Finish first-run wizard"):
- # The wizard should show up now
- machine.wait_for_text("Note folder")
- machine.send_key("ret")
- machine.wait_for_console_text("Note path '/home/alice/Notes' was now created.")
- machine.wait_for_text("Panel layout")
- machine.send_key("ret")
- machine.wait_for_text("Nextcloud")
- machine.send_key("ret")
- machine.wait_for_text("App metric")
- machine.send_key("ret")
+ with subtest("Finish first-run wizard"):
+ # The wizard should show up now
+ machine.wait_for_text("Note folder")
+ machine.send_key("ret")
+ machine.wait_for_console_text("Note path '/home/alice/Notes' was now created.")
+ machine.wait_for_text("Panel layout")
+ machine.send_key("ret")
+ machine.wait_for_text("Nextcloud")
+ machine.send_key("ret")
+ machine.wait_for_text("App metric")
+ machine.send_key("ret")
- # Doesn't work for non-root
- #machine.wait_for_window("QOwnNotes - ${pkgs.qownnotes.version}")
+ # Doesn't work for non-root
+ #machine.wait_for_window("QOwnNotes - ${pkgs.qownnotes.version}")
- # OCR doesn't seem to be able any more to handle the main window
- #machine.wait_for_text("QOwnNotes - ${pkgs.qownnotes.version}")
+ # OCR doesn't seem to be able any more to handle the main window
+ #machine.wait_for_text("QOwnNotes - ${pkgs.qownnotes.version}")
- # The main window should now show up
- machine.wait_for_open_port(22222)
- machine.wait_for_console_text("QOwnNotes server listening on port 22222")
+ # The main window should now show up
+ machine.wait_for_open_port(22222)
+ machine.wait_for_console_text("QOwnNotes server listening on port 22222")
- machine.screenshot("QOwnNotes-DemoNote")
+ machine.screenshot("QOwnNotes-DemoNote")
- with subtest("Create a new note"):
- machine.send_key("ctrl-n")
- machine.sleep(1)
- machine.send_chars("This is a NixOS test!\n")
- machine.wait_until_succeeds("find /home/alice/Notes -type f | grep -qi 'Note 2'")
+ with subtest("Create a new note"):
+ machine.send_key("ctrl-n")
+ machine.sleep(1)
+ machine.send_chars("This is a NixOS test!\n")
+ machine.wait_until_succeeds("find /home/alice/Notes -type f | grep -qi 'Note 2'")
- # OCR doesn't seem to be able any more to handle the main window
- #machine.wait_for_text("This is a NixOS test!")
+ # OCR doesn't seem to be able any more to handle the main window
+ #machine.wait_for_text("This is a NixOS test!")
- # Doesn't work for non-root
- #machine.wait_for_window("- QOwnNotes - ${pkgs.qownnotes.version}")
+ # Doesn't work for non-root
+ #machine.wait_for_window("- QOwnNotes - ${pkgs.qownnotes.version}")
- machine.screenshot("QOwnNotes-NewNote")
- '';
- }
-)
+ machine.screenshot("QOwnNotes-NewNote")
+ '';
+}
diff --git a/nixos/tests/quake3.nix b/nixos/tests/quake3.nix
index cade2991de61..d56be93890a9 100644
--- a/nixos/tests/quake3.nix
+++ b/nixos/tests/quake3.nix
@@ -1,102 +1,100 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
+{ pkgs, lib, ... }:
- let
+let
- # Build Quake with coverage instrumentation.
- overrides = pkgs: {
- quake3game = pkgs.quake3game.override (args: {
- stdenv = pkgs.stdenvAdapters.addCoverageInstrumentation args.stdenv;
- });
+ # Build Quake with coverage instrumentation.
+ overrides = pkgs: {
+ quake3game = pkgs.quake3game.override (args: {
+ stdenv = pkgs.stdenvAdapters.addCoverageInstrumentation args.stdenv;
+ });
+ };
+
+ # Only allow the demo data to be used (only if it's unfreeRedistributable).
+ unfreePredicate =
+ pkg:
+ let
+ allowPackageNames = [
+ "quake3-demodata"
+ "quake3-pointrelease"
+ ];
+ allowLicenses = [ lib.licenses.unfreeRedistributable ];
+ in
+ lib.elem pkg.pname allowPackageNames && lib.elem (pkg.meta.license or null) allowLicenses;
+
+ client =
+ { pkgs, ... }:
+
+ {
+ imports = [ ./common/x11.nix ];
+ hardware.graphics.enable = true;
+ environment.systemPackages = [ pkgs.quake3demo ];
+ nixpkgs.config.packageOverrides = overrides;
+ nixpkgs.config.allowUnfreePredicate = unfreePredicate;
};
- # Only allow the demo data to be used (only if it's unfreeRedistributable).
- unfreePredicate =
- pkg:
- let
- allowPackageNames = [
- "quake3-demodata"
- "quake3-pointrelease"
- ];
- allowLicenses = [ lib.licenses.unfreeRedistributable ];
- in
- lib.elem pkg.pname allowPackageNames && lib.elem (pkg.meta.license or null) allowLicenses;
+in
- client =
+rec {
+ name = "quake3";
+ meta = with lib.maintainers; {
+ maintainers = [ domenkozar ];
+ };
+
+ # TODO: lcov doesn't work atm
+ #makeCoverageReport = true;
+
+ nodes = {
+ server =
{ pkgs, ... }:
{
- imports = [ ./common/x11.nix ];
- hardware.graphics.enable = true;
- environment.systemPackages = [ pkgs.quake3demo ];
+ systemd.services.quake3-server = {
+ wantedBy = [ "multi-user.target" ];
+ script =
+ "${pkgs.quake3demo}/bin/quake3-server +set g_gametype 0 "
+ + "+map q3dm7 +addbot grunt +addbot daemia 2> /tmp/log";
+ };
nixpkgs.config.packageOverrides = overrides;
nixpkgs.config.allowUnfreePredicate = unfreePredicate;
+ networking.firewall.allowedUDPPorts = [ 27960 ];
};
- in
+ client1 = client;
+ client2 = client;
+ };
- rec {
- name = "quake3";
- meta = with lib.maintainers; {
- maintainers = [ domenkozar ];
- };
+ testScript = ''
+ start_all()
- # TODO: lcov doesn't work atm
- #makeCoverageReport = true;
+ server.wait_for_unit("quake3-server")
+ client1.wait_for_x()
+ client2.wait_for_x()
- nodes = {
- server =
- { pkgs, ... }:
+ client1.execute("quake3 +set r_fullscreen 0 +set name Foo +connect server >&2 &", check_return = False)
+ client2.execute("quake3 +set r_fullscreen 0 +set name Bar +connect server >&2 &", check_return = False)
- {
- systemd.services.quake3-server = {
- wantedBy = [ "multi-user.target" ];
- script =
- "${pkgs.quake3demo}/bin/quake3-server +set g_gametype 0 "
- + "+map q3dm7 +addbot grunt +addbot daemia 2> /tmp/log";
- };
- nixpkgs.config.packageOverrides = overrides;
- nixpkgs.config.allowUnfreePredicate = unfreePredicate;
- networking.firewall.allowedUDPPorts = [ 27960 ];
- };
+ server.wait_until_succeeds("grep -q 'Foo.*entered the game' /tmp/log")
+ server.wait_until_succeeds("grep -q 'Bar.*entered the game' /tmp/log")
- client1 = client;
- client2 = client;
- };
+ server.sleep(10) # wait for a while to get a nice screenshot
- testScript = ''
- start_all()
+ client1.block()
- server.wait_for_unit("quake3-server")
- client1.wait_for_x()
- client2.wait_for_x()
+ server.sleep(20)
- client1.execute("quake3 +set r_fullscreen 0 +set name Foo +connect server >&2 &", check_return = False)
- client2.execute("quake3 +set r_fullscreen 0 +set name Bar +connect server >&2 &", check_return = False)
+ client1.screenshot("screen1")
+ client2.screenshot("screen2")
- server.wait_until_succeeds("grep -q 'Foo.*entered the game' /tmp/log")
- server.wait_until_succeeds("grep -q 'Bar.*entered the game' /tmp/log")
+ client1.unblock()
- server.sleep(10) # wait for a while to get a nice screenshot
+ server.sleep(10)
- client1.block()
+ client1.screenshot("screen3")
+ client2.screenshot("screen4")
- server.sleep(20)
+ client1.shutdown()
+ client2.shutdown()
+ server.stop_job("quake3-server")
+ '';
- client1.screenshot("screen1")
- client2.screenshot("screen2")
-
- client1.unblock()
-
- server.sleep(10)
-
- client1.screenshot("screen3")
- client2.screenshot("screen4")
-
- client1.shutdown()
- client2.shutdown()
- server.stop_job("quake3-server")
- '';
-
- }
-)
+}
diff --git a/nixos/tests/quicktun.nix b/nixos/tests/quicktun.nix
index 62b441f3fd78..22bd0dbdf52a 100644
--- a/nixos/tests/quicktun.nix
+++ b/nixos/tests/quicktun.nix
@@ -1,22 +1,20 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- {
- name = "quicktun";
- meta.maintainers = with lib.maintainers; [ h7x4 ];
+{ pkgs, lib, ... }:
+{
+ name = "quicktun";
+ meta.maintainers = with lib.maintainers; [ h7x4 ];
- nodes = {
- machine =
- { ... }:
- {
- services.quicktun."test-tunnel" = {
- protocol = "raw";
- };
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.quicktun."test-tunnel" = {
+ protocol = "raw";
};
- };
+ };
+ };
- testScript = ''
- start_all()
- machine.wait_for_unit("quicktun-test-tunnel.service")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("quicktun-test-tunnel.service")
+ '';
+}
diff --git a/nixos/tests/quickwit.nix b/nixos/tests/quickwit.nix
index 0dddd547fd06..f080285ca345 100644
--- a/nixos/tests/quickwit.nix
+++ b/nixos/tests/quickwit.nix
@@ -1,106 +1,104 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- let
- # Define an example Quickwit index schema,
- # and some `exampleDocs` below, to test if ingesting
- # and querying works as expected.
- index_yaml = ''
- version: 0.7
- index_id: example_server_logs
- doc_mapping:
- mode: dynamic
- field_mappings:
- - name: datetime
- type: datetime
- fast: true
- input_formats:
- - iso8601
- output_format: iso8601
- fast_precision: seconds
- fast: true
- - name: git
- type: text
- tokenizer: raw
- - name: hostname
- type: text
- tokenizer: raw
- - name: level
- type: text
- tokenizer: raw
- - name: message
- type: text
- - name: location
- type: text
- - name: source
- type: text
- timestamp_field: datetime
+let
+ # Define an example Quickwit index schema,
+ # and some `exampleDocs` below, to test if ingesting
+ # and querying works as expected.
+ index_yaml = ''
+ version: 0.7
+ index_id: example_server_logs
+ doc_mapping:
+ mode: dynamic
+ field_mappings:
+ - name: datetime
+ type: datetime
+ fast: true
+ input_formats:
+ - iso8601
+ output_format: iso8601
+ fast_precision: seconds
+ fast: true
+ - name: git
+ type: text
+ tokenizer: raw
+ - name: hostname
+ type: text
+ tokenizer: raw
+ - name: level
+ type: text
+ tokenizer: raw
+ - name: message
+ type: text
+ - name: location
+ type: text
+ - name: source
+ type: text
+ timestamp_field: datetime
- search_settings:
- default_search_fields: [message]
+ search_settings:
+ default_search_fields: [message]
- indexing_settings:
- commit_timeout_secs: 10
- '';
+ indexing_settings:
+ commit_timeout_secs: 10
+ '';
- exampleDocs = ''
- {"datetime":"2024-05-03T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Processing request done","location":"path/to/server.c:6442:32","source":""}
- {"datetime":"2024-05-04T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
- {"datetime":"2024-05-05T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
- {"datetime":"2024-05-06T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-2","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
- '';
- in
- {
- name = "quickwit";
- meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
+ exampleDocs = ''
+ {"datetime":"2024-05-03T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Processing request done","location":"path/to/server.c:6442:32","source":""}
+ {"datetime":"2024-05-04T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
+ {"datetime":"2024-05-05T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
+ {"datetime":"2024-05-06T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-2","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
+ '';
+in
+{
+ name = "quickwit";
+ meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
- nodes = {
- quickwit =
- { config, pkgs, ... }:
- {
- services.quickwit.enable = true;
- };
- };
+ nodes = {
+ quickwit =
+ { config, pkgs, ... }:
+ {
+ services.quickwit.enable = true;
+ };
+ };
- testScript = ''
- quickwit.wait_for_unit("quickwit")
- quickwit.wait_for_open_port(7280)
- quickwit.wait_for_open_port(7281)
+ testScript = ''
+ quickwit.wait_for_unit("quickwit")
+ quickwit.wait_for_open_port(7280)
+ quickwit.wait_for_open_port(7281)
- quickwit.wait_until_succeeds(
- "journalctl -o cat -u quickwit.service | grep 'version: ${pkgs.quickwit.version}'"
- )
+ quickwit.wait_until_succeeds(
+ "journalctl -o cat -u quickwit.service | grep 'version: ${pkgs.quickwit.version}'"
+ )
- quickwit.wait_until_succeeds(
- "journalctl -o cat -u quickwit.service | grep 'transitioned to ready state'"
- )
+ quickwit.wait_until_succeeds(
+ "journalctl -o cat -u quickwit.service | grep 'transitioned to ready state'"
+ )
- with subtest("verify UI installed"):
- machine.succeed("curl -sSf http://127.0.0.1:7280/ui/")
+ with subtest("verify UI installed"):
+ machine.succeed("curl -sSf http://127.0.0.1:7280/ui/")
- with subtest("injest and query data"):
- import json
+ with subtest("injest and query data"):
+ import json
- # Test CLI ingestion
- print(machine.succeed('${pkgs.quickwit}/bin/quickwit index create --index-config ${pkgs.writeText "index.yaml" index_yaml}'))
- # Important to use `--wait`, otherwise the queries below race with index processing.
- print(machine.succeed('${pkgs.quickwit}/bin/quickwit index ingest --index example_server_logs --input-path ${pkgs.writeText "exampleDocs.json" exampleDocs} --wait'))
+ # Test CLI ingestion
+ print(machine.succeed('${pkgs.quickwit}/bin/quickwit index create --index-config ${pkgs.writeText "index.yaml" index_yaml}'))
+ # Important to use `--wait`, otherwise the queries below race with index processing.
+ print(machine.succeed('${pkgs.quickwit}/bin/quickwit index ingest --index example_server_logs --input-path ${pkgs.writeText "exampleDocs.json" exampleDocs} --wait'))
- # Test CLI query
- cli_query_output = machine.succeed('${pkgs.quickwit}/bin/quickwit index search --index example_server_logs --query "exception"')
- print(cli_query_output)
+ # Test CLI query
+ cli_query_output = machine.succeed('${pkgs.quickwit}/bin/quickwit index search --index example_server_logs --query "exception"')
+ print(cli_query_output)
- # Assert query result is as expected.
- num_hits = len(json.loads(cli_query_output)["hits"])
- assert num_hits == 3, f"cli_query_output contains unexpected number of results: {num_hits}"
+ # Assert query result is as expected.
+ num_hits = len(json.loads(cli_query_output)["hits"])
+ assert num_hits == 3, f"cli_query_output contains unexpected number of results: {num_hits}"
- # Test API query
- api_query_output = machine.succeed('curl --fail http://127.0.0.1:7280/api/v1/example_server_logs/search?query=exception')
- print(api_query_output)
+ # Test API query
+ api_query_output = machine.succeed('curl --fail http://127.0.0.1:7280/api/v1/example_server_logs/search?query=exception')
+ print(api_query_output)
- quickwit.log(quickwit.succeed(
- "systemd-analyze security quickwit.service | grep -v '✓'"
- ))
- '';
- }
-)
+ quickwit.log(quickwit.succeed(
+ "systemd-analyze security quickwit.service | grep -v '✓'"
+ ))
+ '';
+}
diff --git a/nixos/tests/quorum.nix b/nixos/tests/quorum.nix
index 1a38ad434658..0e67f3564070 100644
--- a/nixos/tests/quorum.nix
+++ b/nixos/tests/quorum.nix
@@ -1,105 +1,103 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- keystore = {
- address = "9377bc3936de934c497e22917b81aa8774ac3bb0";
- crypto = {
- cipher = "aes-128-ctr";
- ciphertext = "ad8341d8ef225650403fd366c955f41095e438dd966a3c84b3d406818c1e366c";
- cipherparams = {
- iv = "2a09f7a72fd6dff7c43150ff437e6ac2";
- };
- kdf = "scrypt";
- kdfparams = {
- dklen = 32;
- n = 262144;
- p = 1;
- r = 8;
- salt = "d1a153845bb80cd6274c87c5bac8ac09fdfac5ff131a6f41b5ed319667f12027";
- };
- mac = "a9621ad88fa1d042acca6fc2fcd711f7e05bfbadea3f30f379235570c8e270d3";
+{ pkgs, ... }:
+let
+ keystore = {
+ address = "9377bc3936de934c497e22917b81aa8774ac3bb0";
+ crypto = {
+ cipher = "aes-128-ctr";
+ ciphertext = "ad8341d8ef225650403fd366c955f41095e438dd966a3c84b3d406818c1e366c";
+ cipherparams = {
+ iv = "2a09f7a72fd6dff7c43150ff437e6ac2";
};
- id = "89e847a3-1527-42f6-a321-77de0a14ce02";
- version = 3;
- };
- keystore-file = pkgs.writeText "keystore-file" (builtins.toJSON keystore);
- in
- {
- name = "quorum";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ mmahut ];
+ kdf = "scrypt";
+ kdfparams = {
+ dklen = 32;
+ n = 262144;
+ p = 1;
+ r = 8;
+ salt = "d1a153845bb80cd6274c87c5bac8ac09fdfac5ff131a6f41b5ed319667f12027";
+ };
+ mac = "a9621ad88fa1d042acca6fc2fcd711f7e05bfbadea3f30f379235570c8e270d3";
};
+ id = "89e847a3-1527-42f6-a321-77de0a14ce02";
+ version = 3;
+ };
+ keystore-file = pkgs.writeText "keystore-file" (builtins.toJSON keystore);
+in
+{
+ name = "quorum";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ mmahut ];
+ };
- nodes = {
- machine =
- { ... }:
- {
- services.quorum = {
- enable = true;
- permissioned = false;
- staticNodes = [
- "enode://dd333ec28f0a8910c92eb4d336461eea1c20803eed9cf2c056557f986e720f8e693605bba2f4e8f289b1162e5ac7c80c914c7178130711e393ca76abc1d92f57@0.0.0.0:30303?discport=0"
- ];
- genesis = {
- alloc = {
- "189d23d201b03ae1cf9113672df29a5d672aefa3" = {
- balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
- };
- "44b07d2c28b8ed8f02b45bd84ac7d9051b3349e6" = {
- balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
- };
- "4c1ccd426833b9782729a212c857f2f03b7b4c0d" = {
- balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
- };
- "7ae555d0f6faad7930434abdaac2274fd86ab516" = {
- balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
- };
- c1056df7c02b6f1a353052eaf0533cc7cb743b52 = {
- balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
- };
+ nodes = {
+ machine =
+ { ... }:
+ {
+ services.quorum = {
+ enable = true;
+ permissioned = false;
+ staticNodes = [
+ "enode://dd333ec28f0a8910c92eb4d336461eea1c20803eed9cf2c056557f986e720f8e693605bba2f4e8f289b1162e5ac7c80c914c7178130711e393ca76abc1d92f57@0.0.0.0:30303?discport=0"
+ ];
+ genesis = {
+ alloc = {
+ "189d23d201b03ae1cf9113672df29a5d672aefa3" = {
+ balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
};
- coinbase = "0x0000000000000000000000000000000000000000";
- config = {
- byzantiumBlock = 1;
- chainId = 10;
- eip150Block = 1;
- eip150Hash = "0x0000000000000000000000000000000000000000000000000000000000000000";
- eip155Block = 1;
- eip158Block = 1;
- homesteadBlock = 1;
- isQuorum = true;
- istanbul = {
- epoch = 30000;
- policy = 0;
- };
+ "44b07d2c28b8ed8f02b45bd84ac7d9051b3349e6" = {
+ balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
+ };
+ "4c1ccd426833b9782729a212c857f2f03b7b4c0d" = {
+ balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
+ };
+ "7ae555d0f6faad7930434abdaac2274fd86ab516" = {
+ balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
+ };
+ c1056df7c02b6f1a353052eaf0533cc7cb743b52 = {
+ balance = "0x446c3b15f9926687d2c40534fdb564000000000000";
};
- difficulty = "0x1";
- extraData = "0x0000000000000000000000000000000000000000000000000000000000000000f8aff869944c1ccd426833b9782729a212c857f2f03b7b4c0d94189d23d201b03ae1cf9113672df29a5d672aefa39444b07d2c28b8ed8f02b45bd84ac7d9051b3349e694c1056df7c02b6f1a353052eaf0533cc7cb743b52947ae555d0f6faad7930434abdaac2274fd86ab516b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0";
- gasLimit = "0xe0000000";
- gasUsed = "0x0";
- mixHash = "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365";
- nonce = "0x0";
- number = "0x0";
- parentHash = "0x0000000000000000000000000000000000000000000000000000000000000000";
- timestamp = "0x5cffc201";
};
+ coinbase = "0x0000000000000000000000000000000000000000";
+ config = {
+ byzantiumBlock = 1;
+ chainId = 10;
+ eip150Block = 1;
+ eip150Hash = "0x0000000000000000000000000000000000000000000000000000000000000000";
+ eip155Block = 1;
+ eip158Block = 1;
+ homesteadBlock = 1;
+ isQuorum = true;
+ istanbul = {
+ epoch = 30000;
+ policy = 0;
+ };
+ };
+ difficulty = "0x1";
+ extraData = "0x0000000000000000000000000000000000000000000000000000000000000000f8aff869944c1ccd426833b9782729a212c857f2f03b7b4c0d94189d23d201b03ae1cf9113672df29a5d672aefa39444b07d2c28b8ed8f02b45bd84ac7d9051b3349e694c1056df7c02b6f1a353052eaf0533cc7cb743b52947ae555d0f6faad7930434abdaac2274fd86ab516b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0";
+ gasLimit = "0xe0000000";
+ gasUsed = "0x0";
+ mixHash = "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365";
+ nonce = "0x0";
+ number = "0x0";
+ parentHash = "0x0000000000000000000000000000000000000000000000000000000000000000";
+ timestamp = "0x5cffc201";
};
};
- };
+ };
+ };
- testScript = ''
- start_all()
- machine.succeed("mkdir -p /var/lib/quorum/keystore")
- machine.succeed(
- 'cp ${keystore-file} /var/lib/quorum/keystore/UTC--2020-03-23T11-08-34.144812212Z--${keystore.address}'
- )
- machine.succeed(
- "echo fe2725c4e8f7617764b845e8d939a65c664e7956eb47ed7d934573f16488efc1 > /var/lib/quorum/nodekey"
- )
- machine.succeed("systemctl restart quorum")
- machine.wait_for_unit("quorum.service")
- machine.sleep(15)
- machine.succeed('geth attach /var/lib/quorum/geth.ipc --exec "eth.accounts" | grep ${keystore.address}')
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.succeed("mkdir -p /var/lib/quorum/keystore")
+ machine.succeed(
+ 'cp ${keystore-file} /var/lib/quorum/keystore/UTC--2020-03-23T11-08-34.144812212Z--${keystore.address}'
+ )
+ machine.succeed(
+ "echo fe2725c4e8f7617764b845e8d939a65c664e7956eb47ed7d934573f16488efc1 > /var/lib/quorum/nodekey"
+ )
+ machine.succeed("systemctl restart quorum")
+ machine.wait_for_unit("quorum.service")
+ machine.sleep(15)
+ machine.succeed('geth attach /var/lib/quorum/geth.ipc --exec "eth.accounts" | grep ${keystore.address}')
+ '';
+}
diff --git a/nixos/tests/rabbitmq.nix b/nixos/tests/rabbitmq.nix
index cb6dba27a64c..94c7bdf49ba5 100644
--- a/nixos/tests/rabbitmq.nix
+++ b/nixos/tests/rabbitmq.nix
@@ -1,63 +1,61 @@
# This test runs rabbitmq and checks if rabbitmq is up and running.
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- # in real life, you would keep this out of your repo and deploy it to a safe
- # location using safe means.
- configKeyPath = pkgs.writeText "fake-config-key" "hOjWzSEn2Z7cHzKOcf6i183O2NdjurSuoMDIIv01";
- in
- {
- name = "rabbitmq";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ offline ];
+{ pkgs, ... }:
+let
+ # in real life, you would keep this out of your repo and deploy it to a safe
+ # location using safe means.
+ configKeyPath = pkgs.writeText "fake-config-key" "hOjWzSEn2Z7cHzKOcf6i183O2NdjurSuoMDIIv01";
+in
+{
+ name = "rabbitmq";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ offline ];
+ };
+
+ nodes.machine = {
+ services.rabbitmq = {
+ enable = true;
+ managementPlugin.enable = true;
+
+ # To encrypt:
+ # rabbitmqctl --quiet encode --cipher blowfish_cfb64 --hash sha256 \
+ # --iterations 10000 '<<"dJT8isYu6t0Xb6u56rPglSj1vK51SlNVlXfwsRxw">>' \
+ # "hOjWzSEn2Z7cHzKOcf6i183O2NdjurSuoMDIIv01" ;
+ config = ''
+ [ { rabbit
+ , [ {default_user, <<"alice">>}
+ , { default_pass
+ , {encrypted,<<"oKKxyTze9PYmsEfl6FG1MxIUhxY7WPQL7HBoMPRC/1ZOdOZbtr9+DxjWW3e1D5SL48n3D9QOsGD0cOgYG7Qdvb7Txrepw8w=">>}
+ }
+ , {config_entry_decoder
+ , [ {passphrase, {file, <<"${configKeyPath}">>}}
+ , {cipher, blowfish_cfb64}
+ , {hash, sha256}
+ , {iterations, 10000}
+ ]
+ }
+ % , {rabbitmq_management, [{path_prefix, "/_queues"}]}
+ ]
+ }
+ ].
+ '';
};
+ # Ensure there is sufficient extra disk space for rabbitmq to be happy
+ virtualisation.diskSize = 1024;
+ };
- nodes.machine = {
- services.rabbitmq = {
- enable = true;
- managementPlugin.enable = true;
+ testScript = ''
+ machine.start()
- # To encrypt:
- # rabbitmqctl --quiet encode --cipher blowfish_cfb64 --hash sha256 \
- # --iterations 10000 '<<"dJT8isYu6t0Xb6u56rPglSj1vK51SlNVlXfwsRxw">>' \
- # "hOjWzSEn2Z7cHzKOcf6i183O2NdjurSuoMDIIv01" ;
- config = ''
- [ { rabbit
- , [ {default_user, <<"alice">>}
- , { default_pass
- , {encrypted,<<"oKKxyTze9PYmsEfl6FG1MxIUhxY7WPQL7HBoMPRC/1ZOdOZbtr9+DxjWW3e1D5SL48n3D9QOsGD0cOgYG7Qdvb7Txrepw8w=">>}
- }
- , {config_entry_decoder
- , [ {passphrase, {file, <<"${configKeyPath}">>}}
- , {cipher, blowfish_cfb64}
- , {hash, sha256}
- , {iterations, 10000}
- ]
- }
- % , {rabbitmq_management, [{path_prefix, "/_queues"}]}
- ]
- }
- ].
- '';
- };
- # Ensure there is sufficient extra disk space for rabbitmq to be happy
- virtualisation.diskSize = 1024;
- };
+ machine.wait_for_unit("rabbitmq.service")
+ machine.wait_until_succeeds(
+ 'su -s ${pkgs.runtimeShell} rabbitmq -c "rabbitmqctl status"'
+ )
+ machine.wait_for_open_port(15672)
- testScript = ''
- machine.start()
-
- machine.wait_for_unit("rabbitmq.service")
- machine.wait_until_succeeds(
- 'su -s ${pkgs.runtimeShell} rabbitmq -c "rabbitmqctl status"'
- )
- machine.wait_for_open_port(15672)
-
- # The password is the plaintext that was encrypted with rabbitmqctl encode above.
- machine.wait_until_succeeds(
- 'echo Hello World | ${pkgs.lib.getExe pkgs.amqpcat} --producer --uri=amqp://alice:dJT8isYu6t0Xb6u56rPglSj1vK51SlNVlXfwsRxw@localhost --queue test'
- )
- '';
- }
-)
+ # The password is the plaintext that was encrypted with rabbitmqctl encode above.
+ machine.wait_until_succeeds(
+ 'echo Hello World | ${pkgs.lib.getExe pkgs.amqpcat} --producer --uri=amqp://alice:dJT8isYu6t0Xb6u56rPglSj1vK51SlNVlXfwsRxw@localhost --queue test'
+ )
+ '';
+}
diff --git a/nixos/tests/radarr.nix b/nixos/tests/radarr.nix
index ac093beeb790..00949dcc7695 100644
--- a/nixos/tests/radarr.nix
+++ b/nixos/tests/radarr.nix
@@ -1,20 +1,18 @@
-import ./make-test-python.nix (
- { lib, ... }:
+{ lib, ... }:
- {
- name = "radarr";
- meta.maintainers = with lib.maintainers; [ etu ];
+{
+ name = "radarr";
+ meta.maintainers = with lib.maintainers; [ etu ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.radarr.enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.radarr.enable = true;
+ };
- testScript = ''
- machine.wait_for_unit("radarr.service")
- machine.wait_for_open_port(7878)
- machine.succeed("curl --fail http://localhost:7878/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("radarr.service")
+ machine.wait_for_open_port(7878)
+ machine.succeed("curl --fail http://localhost:7878/")
+ '';
+}
diff --git a/nixos/tests/radicale.nix b/nixos/tests/radicale.nix
index 96c17a657b3a..210be285c988 100644
--- a/nixos/tests/radicale.nix
+++ b/nixos/tests/radicale.nix
@@ -1,100 +1,98 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
+{ lib, pkgs, ... }:
- let
- user = "someuser";
- password = "some_password";
- port = "5232";
- filesystem_folder = "/data/radicale";
+let
+ user = "someuser";
+ password = "some_password";
+ port = "5232";
+ filesystem_folder = "/data/radicale";
- cli = "${lib.getExe pkgs.calendar-cli} --caldav-user ${user} --caldav-pass ${password}";
- in
- {
- name = "radicale3";
- meta.maintainers = with lib.maintainers; [ dotlambda ];
+ cli = "${lib.getExe pkgs.calendar-cli} --caldav-user ${user} --caldav-pass ${password}";
+in
+{
+ name = "radicale3";
+ meta.maintainers = with lib.maintainers; [ dotlambda ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.radicale = {
- enable = true;
- settings = {
- auth = {
- type = "htpasswd";
- htpasswd_filename = "/etc/radicale/users";
- htpasswd_encryption = "bcrypt";
- };
- storage = {
- inherit filesystem_folder;
- hook = "git add -A && (git diff --cached --quiet || git commit -m 'Changes by '%(user)s)";
- };
- logging.level = "info";
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.radicale = {
+ enable = true;
+ settings = {
+ auth = {
+ type = "htpasswd";
+ htpasswd_filename = "/etc/radicale/users";
+ htpasswd_encryption = "bcrypt";
};
- rights = {
- principal = {
- user = ".+";
- collection = "{user}";
- permissions = "RW";
- };
- calendars = {
- user = ".+";
- collection = "{user}/[^/]+";
- permissions = "rw";
- };
+ storage = {
+ inherit filesystem_folder;
+ hook = "git add -A && (git diff --cached --quiet || git commit -m 'Changes by '%(user)s)";
+ };
+ logging.level = "info";
+ };
+ rights = {
+ principal = {
+ user = ".+";
+ collection = "{user}";
+ permissions = "RW";
+ };
+ calendars = {
+ user = ".+";
+ collection = "{user}/[^/]+";
+ permissions = "rw";
};
};
- systemd.services.radicale.path = [ pkgs.git ];
- environment.systemPackages = [ pkgs.git ];
- systemd.tmpfiles.rules = [ "d ${filesystem_folder} 0750 radicale radicale -" ];
- # WARNING: DON'T DO THIS IN PRODUCTION!
- # This puts unhashed secrets directly into the Nix store for ease of testing.
- environment.etc."radicale/users".source = pkgs.runCommand "htpasswd" { } ''
- ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password}
- '';
};
- testScript = ''
- machine.wait_for_unit("radicale.service")
- machine.wait_for_open_port(${port})
+ systemd.services.radicale.path = [ pkgs.git ];
+ environment.systemPackages = [ pkgs.git ];
+ systemd.tmpfiles.rules = [ "d ${filesystem_folder} 0750 radicale radicale -" ];
+ # WARNING: DON'T DO THIS IN PRODUCTION!
+ # This puts unhashed secrets directly into the Nix store for ease of testing.
+ environment.etc."radicale/users".source = pkgs.runCommand "htpasswd" { } ''
+ ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password}
+ '';
+ };
+ testScript = ''
+ machine.wait_for_unit("radicale.service")
+ machine.wait_for_open_port(${port})
- machine.succeed("sudo -u radicale git -C ${filesystem_folder} init")
- machine.succeed(
- "sudo -u radicale git -C ${filesystem_folder} config --local user.email radicale@example.com"
- )
- machine.succeed(
- "sudo -u radicale git -C ${filesystem_folder} config --local user.name radicale"
- )
+ machine.succeed("sudo -u radicale git -C ${filesystem_folder} init")
+ machine.succeed(
+ "sudo -u radicale git -C ${filesystem_folder} config --local user.email radicale@example.com"
+ )
+ machine.succeed(
+ "sudo -u radicale git -C ${filesystem_folder} config --local user.name radicale"
+ )
- with subtest("Test calendar and event creation"):
- machine.succeed(
- "${cli} --caldav-url http://localhost:${port}/${user} calendar create cal"
- )
- machine.succeed("test -d ${filesystem_folder}/collection-root/${user}/cal")
- machine.succeed('test -z "$(ls ${filesystem_folder}/collection-root/${user}/cal)"')
- machine.succeed(
- "${cli} --caldav-url http://localhost:${port}/${user}/cal calendar add 2021-04-23 testevent"
- )
- machine.succeed('test -n "$(ls ${filesystem_folder}/collection-root/${user}/cal)"')
- (status, stdout) = machine.execute(
- "sudo -u radicale git -C ${filesystem_folder} log --format=oneline | wc -l"
- )
- assert status == 0, "git log failed"
- assert stdout == "3\n", "there should be exactly 3 commits"
+ with subtest("Test calendar and event creation"):
+ machine.succeed(
+ "${cli} --caldav-url http://localhost:${port}/${user} calendar create cal"
+ )
+ machine.succeed("test -d ${filesystem_folder}/collection-root/${user}/cal")
+ machine.succeed('test -z "$(ls ${filesystem_folder}/collection-root/${user}/cal)"')
+ machine.succeed(
+ "${cli} --caldav-url http://localhost:${port}/${user}/cal calendar add 2021-04-23 testevent"
+ )
+ machine.succeed('test -n "$(ls ${filesystem_folder}/collection-root/${user}/cal)"')
+ (status, stdout) = machine.execute(
+ "sudo -u radicale git -C ${filesystem_folder} log --format=oneline | wc -l"
+ )
+ assert status == 0, "git log failed"
+ assert stdout == "3\n", "there should be exactly 3 commits"
- with subtest("Test rights file"):
- machine.fail(
- "${cli} --caldav-url http://localhost:${port}/${user} calendar create sub/cal"
- )
- machine.fail(
- "${cli} --caldav-url http://localhost:${port}/otheruser calendar create cal"
- )
+ with subtest("Test rights file"):
+ machine.fail(
+ "${cli} --caldav-url http://localhost:${port}/${user} calendar create sub/cal"
+ )
+ machine.fail(
+ "${cli} --caldav-url http://localhost:${port}/otheruser calendar create cal"
+ )
- with subtest("Test web interface"):
- machine.succeed("curl --fail http://${user}:${password}@localhost:${port}/.web/")
+ with subtest("Test web interface"):
+ machine.succeed("curl --fail http://${user}:${password}@localhost:${port}/.web/")
- with subtest("Test security"):
- output = machine.succeed("systemd-analyze security radicale.service")
- machine.log(output)
- assert output[-9:-1] == "SAFE :-}"
- '';
- }
-)
+ with subtest("Test security"):
+ output = machine.succeed("systemd-analyze security radicale.service")
+ machine.log(output)
+ assert output[-9:-1] == "SAFE :-}"
+ '';
+}
diff --git a/nixos/tests/rasdaemon.nix b/nixos/tests/rasdaemon.nix
index c7b147a1ca52..cc7b3fc3c670 100644
--- a/nixos/tests/rasdaemon.nix
+++ b/nixos/tests/rasdaemon.nix
@@ -1,38 +1,36 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "rasdaemon";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ evils ];
+{ pkgs, ... }:
+{
+ name = "rasdaemon";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ evils ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
+ hardware.rasdaemon = {
+ enable = true;
+ # should be enabled by default, just making sure
+ record = true;
+ # nonsense label
+ labels = ''
+ vendor: none
+ product: none
+ model: none
+ DIMM_0: 0.0.0;
+ '';
+ };
};
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
- hardware.rasdaemon = {
- enable = true;
- # should be enabled by default, just making sure
- record = true;
- # nonsense label
- labels = ''
- vendor: none
- product: none
- model: none
- DIMM_0: 0.0.0;
- '';
- };
- };
-
- testScript = ''
- start_all()
- machine.wait_for_unit("multi-user.target")
- # confirm rasdaemon is running and has a valid database
- # some disk errors detected in qemu for some reason ¯\_(ツ)_/¯
- machine.wait_until_succeeds("ras-mc-ctl --errors | tee /dev/stderr | grep -q 'No .* errors.'")
- # confirm the supplied labels text made it into the system
- machine.succeed("grep -q 'vendor: none' /etc/ras/dimm_labels.d/labels >&2")
- machine.shutdown()
- '';
- }
-)
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ # confirm rasdaemon is running and has a valid database
+ # some disk errors detected in qemu for some reason ¯\_(ツ)_/¯
+ machine.wait_until_succeeds("ras-mc-ctl --errors | tee /dev/stderr | grep -q 'No .* errors.'")
+ # confirm the supplied labels text made it into the system
+ machine.succeed("grep -q 'vendor: none' /etc/ras/dimm_labels.d/labels >&2")
+ machine.shutdown()
+ '';
+}
diff --git a/nixos/tests/readarr.nix b/nixos/tests/readarr.nix
index d6d5fdd586b5..6a0e25742632 100644
--- a/nixos/tests/readarr.nix
+++ b/nixos/tests/readarr.nix
@@ -1,19 +1,17 @@
-import ./make-test-python.nix (
- { lib, ... }:
- {
- name = "readarr";
- meta.maintainers = with lib.maintainers; [ jocelynthode ];
+{ lib, ... }:
+{
+ name = "readarr";
+ meta.maintainers = with lib.maintainers; [ jocelynthode ];
- nodes.machine =
- { pkgs, ... }:
- {
- services.readarr.enable = true;
- };
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.readarr.enable = true;
+ };
- testScript = ''
- machine.wait_for_unit("readarr.service")
- machine.wait_for_open_port(8787)
- machine.succeed("curl --fail http://localhost:8787/")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("readarr.service")
+ machine.wait_for_open_port(8787)
+ machine.succeed("curl --fail http://localhost:8787/")
+ '';
+}
diff --git a/nixos/tests/realm.nix b/nixos/tests/realm.nix
index 826dab61dbf2..353e595fbd3d 100644
--- a/nixos/tests/realm.nix
+++ b/nixos/tests/realm.nix
@@ -1,44 +1,42 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "realm";
+{ lib, pkgs, ... }:
+{
+ name = "realm";
- meta = {
- maintainers = with lib.maintainers; [ ocfox ];
- };
+ meta = {
+ maintainers = with lib.maintainers; [ ocfox ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- services.nginx = {
- enable = true;
- statusPage = true;
- };
- # realm need DNS resolv server to run or use config.dns.nameserver
- services.resolved.enable = true;
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.nginx = {
+ enable = true;
+ statusPage = true;
+ };
+ # realm need DNS resolv server to run or use config.dns.nameserver
+ services.resolved.enable = true;
- services.realm = {
- enable = true;
- config = {
- endpoints = [
- {
- listen = "0.0.0.0:1000";
- remote = "127.0.0.1:80";
- }
- ];
- };
+ services.realm = {
+ enable = true;
+ config = {
+ endpoints = [
+ {
+ listen = "0.0.0.0:1000";
+ remote = "127.0.0.1:80";
+ }
+ ];
};
};
+ };
- testScript = ''
- machine.wait_for_unit("nginx.service")
- machine.wait_for_unit("realm.service")
+ testScript = ''
+ machine.wait_for_unit("nginx.service")
+ machine.wait_for_unit("realm.service")
- machine.wait_for_open_port(80)
- machine.wait_for_open_port(1000)
+ machine.wait_for_open_port(80)
+ machine.wait_for_open_port(1000)
- machine.succeed("curl --fail http://localhost:1000/")
- '';
+ machine.succeed("curl --fail http://localhost:1000/")
+ '';
- }
-)
+}
diff --git a/nixos/tests/redlib.nix b/nixos/tests/redlib.nix
index 55bfd6be4720..e03df475fe3d 100644
--- a/nixos/tests/redlib.nix
+++ b/nixos/tests/redlib.nix
@@ -1,31 +1,29 @@
-import ./make-test-python.nix (
- { lib, pkgs, ... }:
- {
- name = "redlib";
- meta.maintainers = with lib.maintainers; [
- bpeetz
- Guanran928
- ];
+{ lib, pkgs, ... }:
+{
+ name = "redlib";
+ meta.maintainers = with lib.maintainers; [
+ bpeetz
+ Guanran928
+ ];
- nodes.machine = {
- services.redlib = {
- package = pkgs.redlib;
- enable = true;
- # Test CAP_NET_BIND_SERVICE
- port = 80;
+ nodes.machine = {
+ services.redlib = {
+ package = pkgs.redlib;
+ enable = true;
+ # Test CAP_NET_BIND_SERVICE
+ port = 80;
- settings = {
- REDLIB_DEFAULT_USE_HLS = true;
- };
+ settings = {
+ REDLIB_DEFAULT_USE_HLS = true;
};
};
+ };
- testScript = ''
- machine.wait_for_unit("redlib.service")
- machine.wait_for_open_port(80)
- # Query a page that does not require Internet access
- machine.succeed("curl --fail http://localhost:80/settings")
- machine.succeed("curl --fail http://localhost:80/info | grep 'Use HLS | on |
'")
- '';
- }
-)
+ testScript = ''
+ machine.wait_for_unit("redlib.service")
+ machine.wait_for_open_port(80)
+ # Query a page that does not require Internet access
+ machine.succeed("curl --fail http://localhost:80/settings")
+ machine.succeed("curl --fail http://localhost:80/info | grep 'Use HLS | on |
'")
+ '';
+}
diff --git a/nixos/tests/renovate.nix b/nixos/tests/renovate.nix
index 52bcc867173c..d6adb3f76801 100644
--- a/nixos/tests/renovate.nix
+++ b/nixos/tests/renovate.nix
@@ -1,74 +1,72 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "renovate";
- meta.maintainers = with pkgs.lib.maintainers; [
- marie
- natsukium
- ];
+{ pkgs, ... }:
+{
+ name = "renovate";
+ meta.maintainers = with pkgs.lib.maintainers; [
+ marie
+ natsukium
+ ];
- nodes.machine =
- { config, ... }:
- {
- services.renovate = {
- enable = true;
- settings = {
- platform = "gitea";
- endpoint = "http://localhost:3000";
- autodiscover = true;
- gitAuthor = "Renovate ";
- };
- credentials = {
- RENOVATE_TOKEN = "/etc/renovate-token";
- };
+ nodes.machine =
+ { config, ... }:
+ {
+ services.renovate = {
+ enable = true;
+ settings = {
+ platform = "gitea";
+ endpoint = "http://localhost:3000";
+ autodiscover = true;
+ gitAuthor = "Renovate ";
};
- environment.systemPackages = [
- config.services.forgejo.package
- pkgs.tea
- pkgs.git
- ];
- services.forgejo = {
- enable = true;
- settings.server.HTTP_PORT = 3000;
+ credentials = {
+ RENOVATE_TOKEN = "/etc/renovate-token";
};
- # Uncomment the next line to lint service scripts (Note: breaks VM startup; see #373166)
- #systemd.enableStrictShellChecks = true;
};
+ environment.systemPackages = [
+ config.services.forgejo.package
+ pkgs.tea
+ pkgs.git
+ ];
+ services.forgejo = {
+ enable = true;
+ settings.server.HTTP_PORT = 3000;
+ };
+ # Uncomment the next line to lint service scripts (Note: breaks VM startup; see #373166)
+ #systemd.enableStrictShellChecks = true;
+ };
- testScript = ''
- def gitea(command):
- return machine.succeed(f"cd /var/lib/forgejo && sudo --user=forgejo GITEA_WORK_DIR=/var/lib/forgejo GITEA_CUSTOM=/var/lib/forgejo/custom gitea {command}")
+ testScript = ''
+ def gitea(command):
+ return machine.succeed(f"cd /var/lib/forgejo && sudo --user=forgejo GITEA_WORK_DIR=/var/lib/forgejo GITEA_CUSTOM=/var/lib/forgejo/custom gitea {command}")
- machine.wait_for_unit("forgejo.service")
- machine.wait_for_open_port(3000)
+ machine.wait_for_unit("forgejo.service")
+ machine.wait_for_open_port(3000)
- machine.systemctl("stop forgejo.service")
+ machine.systemctl("stop forgejo.service")
- gitea("admin user create --username meow --email meow@example.com --password meow")
+ gitea("admin user create --username meow --email meow@example.com --password meow")
- machine.systemctl("start forgejo.service")
- machine.wait_for_unit("forgejo.service")
- machine.wait_for_open_port(3000)
+ machine.systemctl("start forgejo.service")
+ machine.wait_for_unit("forgejo.service")
+ machine.wait_for_open_port(3000)
- accessToken = gitea("admin user generate-access-token --raw --username meow --scopes all | tr -d '\n'")
+ accessToken = gitea("admin user generate-access-token --raw --username meow --scopes all | tr -d '\n'")
- machine.succeed(f"tea login add --name default --user meow --token '{accessToken}' --password meow --url http://localhost:3000")
- machine.succeed("tea repo create --name kitty --init")
- machine.succeed("git config --global user.name Meow")
- machine.succeed("git config --global user.email meow@example.com")
- machine.succeed(f"git clone http://meow:{accessToken}@localhost:3000/meow/kitty.git /tmp/kitty")
- machine.succeed("echo '{ \"name\": \"meow\", \"version\": \"0.1.0\" }' > /tmp/kitty/package.json")
- machine.succeed("git -C /tmp/kitty add /tmp/kitty/package.json")
- machine.succeed("git -C /tmp/kitty commit -m 'add package.json'")
- machine.succeed("git -C /tmp/kitty push origin")
+ machine.succeed(f"tea login add --name default --user meow --token '{accessToken}' --password meow --url http://localhost:3000")
+ machine.succeed("tea repo create --name kitty --init")
+ machine.succeed("git config --global user.name Meow")
+ machine.succeed("git config --global user.email meow@example.com")
+ machine.succeed(f"git clone http://meow:{accessToken}@localhost:3000/meow/kitty.git /tmp/kitty")
+ machine.succeed("echo '{ \"name\": \"meow\", \"version\": \"0.1.0\" }' > /tmp/kitty/package.json")
+ machine.succeed("git -C /tmp/kitty add /tmp/kitty/package.json")
+ machine.succeed("git -C /tmp/kitty commit -m 'add package.json'")
+ machine.succeed("git -C /tmp/kitty push origin")
- machine.succeed(f"echo '{accessToken}' > /etc/renovate-token")
- machine.systemctl("start --wait renovate.service")
+ machine.succeed(f"echo '{accessToken}' > /etc/renovate-token")
+ machine.systemctl("start --wait renovate.service")
- machine.succeed("tea pulls list --repo meow/kitty | grep 'Configure Renovate'")
- machine.succeed("tea pulls merge --repo meow/kitty 1")
+ machine.succeed("tea pulls list --repo meow/kitty | grep 'Configure Renovate'")
+ machine.succeed("tea pulls merge --repo meow/kitty 1")
- machine.systemctl("start --wait renovate.service")
- '';
- }
-)
+ machine.systemctl("start --wait renovate.service")
+ '';
+}
diff --git a/nixos/tests/restart-by-activation-script.nix b/nixos/tests/restart-by-activation-script.nix
index cf89aa341ada..6d26d9843aff 100644
--- a/nixos/tests/restart-by-activation-script.nix
+++ b/nixos/tests/restart-by-activation-script.nix
@@ -1,81 +1,79 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "restart-by-activation-script";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ das_j ];
- };
+{ pkgs, ... }:
+{
+ name = "restart-by-activation-script";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ das_j ];
+ };
- nodes.machine =
- { pkgs, ... }:
- {
- imports = [ ../modules/profiles/minimal.nix ];
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ imports = [ ../modules/profiles/minimal.nix ];
- system.switch.enable = true;
+ system.switch.enable = true;
- systemd.services.restart-me = {
- wantedBy = [ "multi-user.target" ];
- serviceConfig = {
- Type = "oneshot";
- RemainAfterExit = true;
- ExecStart = "${pkgs.coreutils}/bin/true";
- };
- };
-
- systemd.services.reload-me = {
- wantedBy = [ "multi-user.target" ];
- serviceConfig = rec {
- Type = "oneshot";
- RemainAfterExit = true;
- ExecStart = "${pkgs.coreutils}/bin/true";
- ExecReload = ExecStart;
- };
- };
-
- system.activationScripts.test = {
- supportsDryActivation = true;
- text = ''
- if [ -e /test-the-activation-script ]; then
- if [ "$NIXOS_ACTION" != dry-activate ]; then
- touch /activation-was-run
- echo restart-me.service > /run/nixos/activation-restart-list
- echo reload-me.service > /run/nixos/activation-reload-list
- else
- echo restart-me.service > /run/nixos/dry-activation-restart-list
- echo reload-me.service > /run/nixos/dry-activation-reload-list
- fi
- fi
- '';
+ systemd.services.restart-me = {
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = true;
+ ExecStart = "${pkgs.coreutils}/bin/true";
};
};
- testScript = # python
- ''
- machine.wait_for_unit("multi-user.target")
+ systemd.services.reload-me = {
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = rec {
+ Type = "oneshot";
+ RemainAfterExit = true;
+ ExecStart = "${pkgs.coreutils}/bin/true";
+ ExecReload = ExecStart;
+ };
+ };
- with subtest("nothing happens when the activation script does nothing"):
- out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
- assert 'restart' not in out
- assert 'reload' not in out
- out = machine.succeed("/run/current-system/bin/switch-to-configuration test")
- assert 'restart' not in out
- assert 'reload' not in out
+ system.activationScripts.test = {
+ supportsDryActivation = true;
+ text = ''
+ if [ -e /test-the-activation-script ]; then
+ if [ "$NIXOS_ACTION" != dry-activate ]; then
+ touch /activation-was-run
+ echo restart-me.service > /run/nixos/activation-restart-list
+ echo reload-me.service > /run/nixos/activation-reload-list
+ else
+ echo restart-me.service > /run/nixos/dry-activation-restart-list
+ echo reload-me.service > /run/nixos/dry-activation-reload-list
+ fi
+ fi
+ '';
+ };
+ };
- machine.succeed("touch /test-the-activation-script")
+ testScript = # python
+ ''
+ machine.wait_for_unit("multi-user.target")
- with subtest("dry activation"):
- out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
- assert 'would restart the following units: restart-me.service' in out
- assert 'would reload the following units: reload-me.service' in out
- machine.fail("test -f /run/nixos/dry-activation-restart-list")
- machine.fail("test -f /run/nixos/dry-activation-reload-list")
+ with subtest("nothing happens when the activation script does nothing"):
+ out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
+ assert 'restart' not in out
+ assert 'reload' not in out
+ out = machine.succeed("/run/current-system/bin/switch-to-configuration test")
+ assert 'restart' not in out
+ assert 'reload' not in out
- with subtest("real activation"):
- out = machine.succeed("/run/current-system/bin/switch-to-configuration test 2>&1")
- assert 'restarting the following units: restart-me.service' in out
- assert 'reloading the following units: reload-me.service' in out
- machine.fail("test -f /run/nixos/activation-restart-list")
- machine.fail("test -f /run/nixos/activation-reload-list")
- '';
- }
-)
+ machine.succeed("touch /test-the-activation-script")
+
+ with subtest("dry activation"):
+ out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
+ assert 'would restart the following units: restart-me.service' in out
+ assert 'would reload the following units: reload-me.service' in out
+ machine.fail("test -f /run/nixos/dry-activation-restart-list")
+ machine.fail("test -f /run/nixos/dry-activation-reload-list")
+
+ with subtest("real activation"):
+ out = machine.succeed("/run/current-system/bin/switch-to-configuration test 2>&1")
+ assert 'restarting the following units: restart-me.service' in out
+ assert 'reloading the following units: reload-me.service' in out
+ machine.fail("test -f /run/nixos/activation-restart-list")
+ machine.fail("test -f /run/nixos/activation-reload-list")
+ '';
+}
diff --git a/nixos/tests/restic-rest-server.nix b/nixos/tests/restic-rest-server.nix
index ecca1bf83af3..9e6753d91b2a 100644
--- a/nixos/tests/restic-rest-server.nix
+++ b/nixos/tests/restic-rest-server.nix
@@ -1,129 +1,127 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- remoteRepository = "rest:http://restic_rest_server:8001/";
+let
+ remoteRepository = "rest:http://restic_rest_server:8001/";
- backupPrepareCommand = ''
- touch /root/backupPrepareCommand
- test ! -e /root/backupCleanupCommand
+ backupPrepareCommand = ''
+ touch /root/backupPrepareCommand
+ test ! -e /root/backupCleanupCommand
+ '';
+
+ backupCleanupCommand = ''
+ rm /root/backupPrepareCommand
+ touch /root/backupCleanupCommand
+ '';
+
+ testDir = pkgs.stdenvNoCC.mkDerivation {
+ name = "test-files-to-backup";
+ unpackPhase = "true";
+ installPhase = ''
+ mkdir $out
+ echo some_file > $out/some_file
+ echo some_other_file > $out/some_other_file
+ mkdir $out/a_dir
+ echo a_file > $out/a_dir/a_file
'';
+ };
- backupCleanupCommand = ''
- rm /root/backupPrepareCommand
- touch /root/backupCleanupCommand
- '';
+ passwordFile = "${pkgs.writeText "password" "correcthorsebatterystaple"}";
+ paths = [ "/opt" ];
+ exclude = [ "/opt/excluded_file_*" ];
+ pruneOpts = [
+ "--keep-daily 2"
+ "--keep-weekly 1"
+ "--keep-monthly 1"
+ "--keep-yearly 99"
+ ];
+in
+{
+ name = "restic-rest-server";
- testDir = pkgs.stdenvNoCC.mkDerivation {
- name = "test-files-to-backup";
- unpackPhase = "true";
- installPhase = ''
- mkdir $out
- echo some_file > $out/some_file
- echo some_other_file > $out/some_other_file
- mkdir $out/a_dir
- echo a_file > $out/a_dir/a_file
- '';
- };
-
- passwordFile = "${pkgs.writeText "password" "correcthorsebatterystaple"}";
- paths = [ "/opt" ];
- exclude = [ "/opt/excluded_file_*" ];
- pruneOpts = [
- "--keep-daily 2"
- "--keep-weekly 1"
- "--keep-monthly 1"
- "--keep-yearly 99"
- ];
- in
- {
- name = "restic-rest-server";
-
- nodes = {
- restic_rest_server = {
- services.restic.server = {
- enable = true;
- extraFlags = [ "--no-auth" ];
- listenAddress = "8001";
- };
- networking.firewall.allowedTCPPorts = [ 8001 ];
+ nodes = {
+ restic_rest_server = {
+ services.restic.server = {
+ enable = true;
+ extraFlags = [ "--no-auth" ];
+ listenAddress = "8001";
};
- server = {
- services.restic.backups = {
- remotebackup = {
- inherit
- passwordFile
- paths
- exclude
- pruneOpts
- backupPrepareCommand
- backupCleanupCommand
- ;
- repository = remoteRepository;
- initialize = true;
- timerConfig = null; # has no effect here, just checking that it doesn't break the service
- };
- remoteprune = {
- inherit passwordFile;
- repository = remoteRepository;
- pruneOpts = [ "--keep-last 1" ];
- };
+ networking.firewall.allowedTCPPorts = [ 8001 ];
+ };
+ server = {
+ services.restic.backups = {
+ remotebackup = {
+ inherit
+ passwordFile
+ paths
+ exclude
+ pruneOpts
+ backupPrepareCommand
+ backupCleanupCommand
+ ;
+ repository = remoteRepository;
+ initialize = true;
+ timerConfig = null; # has no effect here, just checking that it doesn't break the service
+ };
+ remoteprune = {
+ inherit passwordFile;
+ repository = remoteRepository;
+ pruneOpts = [ "--keep-last 1" ];
};
};
};
+ };
- testScript = ''
- restic_rest_server.start()
- server.start()
- restic_rest_server.wait_for_unit("restic-rest-server.socket")
- restic_rest_server.wait_for_open_port(8001)
- server.wait_for_unit("dbus.socket")
- server.fail(
- "restic-remotebackup snapshots",
- )
- server.succeed(
- # set up
- "cp -rT ${testDir} /opt",
- "touch /opt/excluded_file_1 /opt/excluded_file_2",
+ testScript = ''
+ restic_rest_server.start()
+ server.start()
+ restic_rest_server.wait_for_unit("restic-rest-server.socket")
+ restic_rest_server.wait_for_open_port(8001)
+ server.wait_for_unit("dbus.socket")
+ server.fail(
+ "restic-remotebackup snapshots",
+ )
+ server.succeed(
+ # set up
+ "cp -rT ${testDir} /opt",
+ "touch /opt/excluded_file_1 /opt/excluded_file_2",
- # test that remotebackup runs custom commands and produces a snapshot
- "timedatectl set-time '2016-12-13 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
- 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+ # test that remotebackup runs custom commands and produces a snapshot
+ "timedatectl set-time '2016-12-13 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
+ 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
- # test that restoring that snapshot produces the same directory
- "mkdir /tmp/restore-1",
- "restic-remotebackup restore latest -t /tmp/restore-1",
- "diff -ru ${testDir} /tmp/restore-1/opt",
+ # test that restoring that snapshot produces the same directory
+ "mkdir /tmp/restore-1",
+ "restic-remotebackup restore latest -t /tmp/restore-1",
+ "diff -ru ${testDir} /tmp/restore-1/opt",
- # test that we can create four snapshots in remotebackup and rclonebackup
- "timedatectl set-time '2017-12-13 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
+ # test that we can create four snapshots in remotebackup and rclonebackup
+ "timedatectl set-time '2017-12-13 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
- "timedatectl set-time '2018-12-13 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
+ "timedatectl set-time '2018-12-13 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
- "timedatectl set-time '2018-12-14 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
+ "timedatectl set-time '2018-12-14 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
- "timedatectl set-time '2018-12-15 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
+ "timedatectl set-time '2018-12-15 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
- "timedatectl set-time '2018-12-16 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
+ "timedatectl set-time '2018-12-16 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
- 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
+ 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
- # test that remoteprune brings us back to 1 snapshot in remotebackup
- "systemctl start restic-backups-remoteprune.service",
- 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
- )
- '';
- }
-)
+ # test that remoteprune brings us back to 1 snapshot in remotebackup
+ "systemctl start restic-backups-remoteprune.service",
+ 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+ )
+ '';
+}
diff --git a/nixos/tests/restic.nix b/nixos/tests/restic.nix
index 54d2a88c4545..44e405fe4852 100644
--- a/nixos/tests/restic.nix
+++ b/nixos/tests/restic.nix
@@ -1,249 +1,247 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- let
- remoteRepository = "/root/restic-backup";
- remoteFromFileRepository = "/root/restic-backup-from-file";
- remoteInhibitTestRepository = "/root/restic-backup-inhibit-test";
- remoteNoInitRepository = "/root/restic-backup-no-init";
- rcloneRepository = "rclone:local:/root/restic-rclone-backup";
+let
+ remoteRepository = "/root/restic-backup";
+ remoteFromFileRepository = "/root/restic-backup-from-file";
+ remoteInhibitTestRepository = "/root/restic-backup-inhibit-test";
+ remoteNoInitRepository = "/root/restic-backup-no-init";
+ rcloneRepository = "rclone:local:/root/restic-rclone-backup";
- backupPrepareCommand = ''
- touch /root/backupPrepareCommand
- test ! -e /root/backupCleanupCommand
+ backupPrepareCommand = ''
+ touch /root/backupPrepareCommand
+ test ! -e /root/backupCleanupCommand
+ '';
+
+ backupCleanupCommand = ''
+ rm /root/backupPrepareCommand
+ touch /root/backupCleanupCommand
+ '';
+
+ testDir = pkgs.stdenvNoCC.mkDerivation {
+ name = "test-files-to-backup";
+ unpackPhase = "true";
+ installPhase = ''
+ mkdir $out
+ echo some_file > $out/some_file
+ echo some_other_file > $out/some_other_file
+ mkdir $out/a_dir
+ echo a_file > $out/a_dir/a_file
+ echo a_file_2 > $out/a_dir/a_file_2
'';
+ };
- backupCleanupCommand = ''
- rm /root/backupPrepareCommand
- touch /root/backupCleanupCommand
- '';
+ passwordFile = "${pkgs.writeText "password" "correcthorsebatterystaple"}";
+ paths = [ "/opt" ];
+ exclude = [ "/opt/excluded_file_*" ];
+ pruneOpts = [
+ "--keep-daily 2"
+ "--keep-weekly 1"
+ "--keep-monthly 1"
+ "--keep-yearly 99"
+ ];
+in
+{
+ name = "restic";
- testDir = pkgs.stdenvNoCC.mkDerivation {
- name = "test-files-to-backup";
- unpackPhase = "true";
- installPhase = ''
- mkdir $out
- echo some_file > $out/some_file
- echo some_other_file > $out/some_other_file
- mkdir $out/a_dir
- echo a_file > $out/a_dir/a_file
- echo a_file_2 > $out/a_dir/a_file_2
- '';
- };
-
- passwordFile = "${pkgs.writeText "password" "correcthorsebatterystaple"}";
- paths = [ "/opt" ];
- exclude = [ "/opt/excluded_file_*" ];
- pruneOpts = [
- "--keep-daily 2"
- "--keep-weekly 1"
- "--keep-monthly 1"
- "--keep-yearly 99"
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [
+ bbigras
+ i077
];
- in
- {
- name = "restic";
+ };
- meta = with pkgs.lib.maintainers; {
- maintainers = [
- bbigras
- i077
- ];
- };
-
- nodes = {
- server =
- { pkgs, ... }:
- {
- services.restic.backups = {
- remotebackup = {
- inherit
- passwordFile
- paths
- exclude
- pruneOpts
- backupPrepareCommand
- backupCleanupCommand
- ;
- repository = remoteRepository;
- initialize = true;
- timerConfig = null; # has no effect here, just checking that it doesn't break the service
- };
- remote-from-file-backup = {
- inherit passwordFile exclude pruneOpts;
- initialize = true;
- repositoryFile = pkgs.writeText "repositoryFile" remoteFromFileRepository;
- paths = [
- "/opt/a_dir/a_file"
- "/opt/a_dir/a_file_2"
- ];
- dynamicFilesFrom = ''
- find /opt -mindepth 1 -maxdepth 1 ! -name a_dir # all files in /opt except for a_dir
- '';
- };
- inhibit-test = {
- inherit
- passwordFile
- paths
- exclude
- pruneOpts
- ;
- repository = remoteInhibitTestRepository;
- initialize = true;
- inhibitsSleep = true;
- };
- remote-noinit-backup = {
- inherit
- passwordFile
- exclude
- pruneOpts
- paths
- ;
- initialize = false;
- repository = remoteNoInitRepository;
- };
- rclonebackup = {
- inherit
- passwordFile
- paths
- exclude
- pruneOpts
- ;
- initialize = true;
- repository = rcloneRepository;
- rcloneConfig = {
- type = "local";
- one_file_system = true;
- };
-
- # This gets overridden by rcloneConfig.type
- rcloneConfigFile = pkgs.writeText "rclone.conf" ''
- [local]
- type=ftp
- '';
- };
- remoteprune = {
- inherit passwordFile;
- repository = remoteRepository;
- pruneOpts = [ "--keep-last 1" ];
- };
- custompackage = {
- inherit passwordFile paths;
- repository = "some-fake-repository";
- package = pkgs.writeShellScriptBin "restic" ''
- echo "$@" >> /root/fake-restic.log;
- '';
-
- pruneOpts = [ "--keep-last 1" ];
- checkOpts = [ "--some-check-option" ];
- };
+ nodes = {
+ server =
+ { pkgs, ... }:
+ {
+ services.restic.backups = {
+ remotebackup = {
+ inherit
+ passwordFile
+ paths
+ exclude
+ pruneOpts
+ backupPrepareCommand
+ backupCleanupCommand
+ ;
+ repository = remoteRepository;
+ initialize = true;
+ timerConfig = null; # has no effect here, just checking that it doesn't break the service
};
+ remote-from-file-backup = {
+ inherit passwordFile exclude pruneOpts;
+ initialize = true;
+ repositoryFile = pkgs.writeText "repositoryFile" remoteFromFileRepository;
+ paths = [
+ "/opt/a_dir/a_file"
+ "/opt/a_dir/a_file_2"
+ ];
+ dynamicFilesFrom = ''
+ find /opt -mindepth 1 -maxdepth 1 ! -name a_dir # all files in /opt except for a_dir
+ '';
+ };
+ inhibit-test = {
+ inherit
+ passwordFile
+ paths
+ exclude
+ pruneOpts
+ ;
+ repository = remoteInhibitTestRepository;
+ initialize = true;
+ inhibitsSleep = true;
+ };
+ remote-noinit-backup = {
+ inherit
+ passwordFile
+ exclude
+ pruneOpts
+ paths
+ ;
+ initialize = false;
+ repository = remoteNoInitRepository;
+ };
+ rclonebackup = {
+ inherit
+ passwordFile
+ paths
+ exclude
+ pruneOpts
+ ;
+ initialize = true;
+ repository = rcloneRepository;
+ rcloneConfig = {
+ type = "local";
+ one_file_system = true;
+ };
- environment.sessionVariables.RCLONE_CONFIG_LOCAL_TYPE = "local";
+ # This gets overridden by rcloneConfig.type
+ rcloneConfigFile = pkgs.writeText "rclone.conf" ''
+ [local]
+ type=ftp
+ '';
+ };
+ remoteprune = {
+ inherit passwordFile;
+ repository = remoteRepository;
+ pruneOpts = [ "--keep-last 1" ];
+ };
+ custompackage = {
+ inherit passwordFile paths;
+ repository = "some-fake-repository";
+ package = pkgs.writeShellScriptBin "restic" ''
+ echo "$@" >> /root/fake-restic.log;
+ '';
+
+ pruneOpts = [ "--keep-last 1" ];
+ checkOpts = [ "--some-check-option" ];
+ };
};
- };
- testScript = ''
- server.start()
- server.wait_for_unit("dbus.socket")
- server.fail(
- "restic-remotebackup snapshots",
- 'restic-remote-from-file-backup snapshots"',
- "restic-rclonebackup snapshots",
- "grep 'backup.* /opt' /root/fake-restic.log",
- )
- server.succeed(
- # set up
- "cp -rT ${testDir} /opt",
- "touch /opt/excluded_file_1 /opt/excluded_file_2",
- "mkdir -p /root/restic-rclone-backup",
- )
+ environment.sessionVariables.RCLONE_CONFIG_LOCAL_TYPE = "local";
+ };
+ };
- server.fail(
- # test that noinit backup in fact does not initialize the repository
- # and thus fails without a pre-initialized repository
- "systemctl start restic-backups-remote-noinit-backup.service",
- )
+ testScript = ''
+ server.start()
+ server.wait_for_unit("dbus.socket")
+ server.fail(
+ "restic-remotebackup snapshots",
+ 'restic-remote-from-file-backup snapshots"',
+ "restic-rclonebackup snapshots",
+ "grep 'backup.* /opt' /root/fake-restic.log",
+ )
+ server.succeed(
+ # set up
+ "cp -rT ${testDir} /opt",
+ "touch /opt/excluded_file_1 /opt/excluded_file_2",
+ "mkdir -p /root/restic-rclone-backup",
+ )
- server.succeed(
- # test that remotebackup runs custom commands and produces a snapshot
- "timedatectl set-time '2016-12-13 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
- 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+ server.fail(
+ # test that noinit backup in fact does not initialize the repository
+ # and thus fails without a pre-initialized repository
+ "systemctl start restic-backups-remote-noinit-backup.service",
+ )
- # test that restoring that snapshot produces the same directory
- "mkdir /tmp/restore-1",
- "restic-remotebackup restore latest -t /tmp/restore-1",
- "diff -ru ${testDir} /tmp/restore-1/opt",
+ server.succeed(
+ # test that remotebackup runs custom commands and produces a snapshot
+ "timedatectl set-time '2016-12-13 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
+ 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
- # test that remote-from-file-backup produces a snapshot
- "systemctl start restic-backups-remote-from-file-backup.service",
- 'restic-remote-from-file-backup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
- "mkdir /tmp/restore-2",
- "restic-remote-from-file-backup restore latest -t /tmp/restore-2",
- "diff -ru ${testDir} /tmp/restore-2/opt",
+ # test that restoring that snapshot produces the same directory
+ "mkdir /tmp/restore-1",
+ "restic-remotebackup restore latest -t /tmp/restore-1",
+ "diff -ru ${testDir} /tmp/restore-1/opt",
- # test that remote-noinit-backup produces a snapshot once initialized
- "restic-remote-noinit-backup init",
- "systemctl start restic-backups-remote-noinit-backup.service",
- 'restic-remote-noinit-backup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+ # test that remote-from-file-backup produces a snapshot
+ "systemctl start restic-backups-remote-from-file-backup.service",
+ 'restic-remote-from-file-backup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+ "mkdir /tmp/restore-2",
+ "restic-remote-from-file-backup restore latest -t /tmp/restore-2",
+ "diff -ru ${testDir} /tmp/restore-2/opt",
- # test that restoring that snapshot produces the same directory
- "mkdir /tmp/restore-3",
- "${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} restore latest -t /tmp/restore-3",
- "diff -ru ${testDir} /tmp/restore-3/opt",
+ # test that remote-noinit-backup produces a snapshot once initialized
+ "restic-remote-noinit-backup init",
+ "systemctl start restic-backups-remote-noinit-backup.service",
+ 'restic-remote-noinit-backup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
- # test that rclonebackup produces a snapshot
- "systemctl start restic-backups-rclonebackup.service",
- 'restic-rclonebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+ # test that restoring that snapshot produces the same directory
+ "mkdir /tmp/restore-3",
+ "${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} restore latest -t /tmp/restore-3",
+ "diff -ru ${testDir} /tmp/restore-3/opt",
- # test that custompackage runs both `restic backup` and `restic check` with reasonable commandlines
- "systemctl start restic-backups-custompackage.service",
- "grep 'backup' /root/fake-restic.log",
- "grep 'check.* --some-check-option' /root/fake-restic.log",
+ # test that rclonebackup produces a snapshot
+ "systemctl start restic-backups-rclonebackup.service",
+ 'restic-rclonebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
- # test that we can create four snapshots in remotebackup and rclonebackup
- "timedatectl set-time '2017-12-13 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
- "systemctl start restic-backups-rclonebackup.service",
+ # test that custompackage runs both `restic backup` and `restic check` with reasonable commandlines
+ "systemctl start restic-backups-custompackage.service",
+ "grep 'backup' /root/fake-restic.log",
+ "grep 'check.* --some-check-option' /root/fake-restic.log",
- "timedatectl set-time '2018-12-13 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
- "systemctl start restic-backups-rclonebackup.service",
+ # test that we can create four snapshots in remotebackup and rclonebackup
+ "timedatectl set-time '2017-12-13 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
+ "systemctl start restic-backups-rclonebackup.service",
- "timedatectl set-time '2018-12-14 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
- "systemctl start restic-backups-rclonebackup.service",
+ "timedatectl set-time '2018-12-13 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
+ "systemctl start restic-backups-rclonebackup.service",
- "timedatectl set-time '2018-12-15 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
- "systemctl start restic-backups-rclonebackup.service",
+ "timedatectl set-time '2018-12-14 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
+ "systemctl start restic-backups-rclonebackup.service",
- "timedatectl set-time '2018-12-16 13:45'",
- "systemctl start restic-backups-remotebackup.service",
- "rm /root/backupCleanupCommand",
- "systemctl start restic-backups-rclonebackup.service",
+ "timedatectl set-time '2018-12-15 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
+ "systemctl start restic-backups-rclonebackup.service",
- 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
- 'restic-rclonebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
+ "timedatectl set-time '2018-12-16 13:45'",
+ "systemctl start restic-backups-remotebackup.service",
+ "rm /root/backupCleanupCommand",
+ "systemctl start restic-backups-rclonebackup.service",
- # test that remoteprune brings us back to 1 snapshot in remotebackup
- "systemctl start restic-backups-remoteprune.service",
- 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+ 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
+ 'restic-rclonebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
- )
+ # test that remoteprune brings us back to 1 snapshot in remotebackup
+ "systemctl start restic-backups-remoteprune.service",
+ 'restic-remotebackup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
- # test that the inhibit option is working
- server.systemctl("start --no-block restic-backups-inhibit-test.service")
- server.wait_until_succeeds(
- "systemd-inhibit --no-legend --no-pager | grep -q restic",
- 5
- )
- '';
- }
-)
+ )
+
+ # test that the inhibit option is working
+ server.systemctl("start --no-block restic-backups-inhibit-test.service")
+ server.wait_until_succeeds(
+ "systemd-inhibit --no-legend --no-pager | grep -q restic",
+ 5
+ )
+ '';
+}
diff --git a/nixos/tests/retroarch.nix b/nixos/tests/retroarch.nix
index ac03cbffefea..9f700ed290ef 100644
--- a/nixos/tests/retroarch.nix
+++ b/nixos/tests/retroarch.nix
@@ -1,56 +1,54 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "retroarch";
- meta = with pkgs.lib; {
- maintainers = teams.libretro.members ++ [ maintainers.j0hax ];
- };
+{
+ name = "retroarch";
+ meta = with pkgs.lib; {
+ maintainers = teams.libretro.members ++ [ maintainers.j0hax ];
+ };
- nodes.machine =
- { ... }:
+ nodes.machine =
+ { ... }:
- {
- imports = [ ./common/user-account.nix ];
- services.xserver.enable = true;
- services.xserver.desktopManager.retroarch = {
+ {
+ imports = [ ./common/user-account.nix ];
+ services.xserver.enable = true;
+ services.xserver.desktopManager.retroarch = {
+ enable = true;
+ package = pkgs.retroarch-bare;
+ };
+ services.xserver.displayManager = {
+ sddm.enable = true;
+ defaultSession = "RetroArch";
+ autoLogin = {
enable = true;
- package = pkgs.retroarch-bare;
- };
- services.xserver.displayManager = {
- sddm.enable = true;
- defaultSession = "RetroArch";
- autoLogin = {
- enable = true;
- user = "alice";
- };
+ user = "alice";
};
};
+ };
- testScript =
- { nodes, ... }:
- let
- user = nodes.machine.config.users.users.alice;
- xdo = "${pkgs.xdotool}/bin/xdotool";
- in
- ''
- with subtest("Wait for login"):
- start_all()
- machine.wait_for_file("/tmp/xauth_*")
- machine.succeed("xauth merge /tmp/xauth_*")
+ testScript =
+ { nodes, ... }:
+ let
+ user = nodes.machine.config.users.users.alice;
+ xdo = "${pkgs.xdotool}/bin/xdotool";
+ in
+ ''
+ with subtest("Wait for login"):
+ start_all()
+ machine.wait_for_file("/tmp/xauth_*")
+ machine.succeed("xauth merge /tmp/xauth_*")
- with subtest("Check RetroArch started"):
- machine.wait_until_succeeds("pgrep retroarch")
- machine.wait_for_window("^RetroArch")
+ with subtest("Check RetroArch started"):
+ machine.wait_until_succeeds("pgrep retroarch")
+ machine.wait_for_window("^RetroArch")
- with subtest("Check configuration created"):
- machine.wait_for_file("${user.home}/.config/retroarch/retroarch.cfg")
+ with subtest("Check configuration created"):
+ machine.wait_for_file("${user.home}/.config/retroarch/retroarch.cfg")
- with subtest("Wait to get a screenshot"):
- machine.execute(
- "${xdo} key Alt+F1 sleep 10"
- )
- machine.screenshot("screen")
- '';
- }
-)
+ with subtest("Wait to get a screenshot"):
+ machine.execute(
+ "${xdo} key Alt+F1 sleep 10"
+ )
+ machine.screenshot("screen")
+ '';
+}
diff --git a/nixos/tests/robustirc-bridge.nix b/nixos/tests/robustirc-bridge.nix
index 31b4240f9836..2f6f48df757c 100644
--- a/nixos/tests/robustirc-bridge.nix
+++ b/nixos/tests/robustirc-bridge.nix
@@ -1,30 +1,28 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
+{ pkgs, ... }:
- {
- name = "robustirc-bridge";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ hax404 ];
- };
+{
+ name = "robustirc-bridge";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ hax404 ];
+ };
- nodes = {
- bridge = {
- services.robustirc-bridge = {
- enable = true;
- extraFlags = [
- "-listen localhost:6667"
- "-network example.com"
- ];
- };
+ nodes = {
+ bridge = {
+ services.robustirc-bridge = {
+ enable = true;
+ extraFlags = [
+ "-listen localhost:6667"
+ "-network example.com"
+ ];
};
};
+ };
- testScript = ''
- start_all()
+ testScript = ''
+ start_all()
- bridge.wait_for_unit("robustirc-bridge.service")
- bridge.wait_for_open_port(1080)
- bridge.wait_for_open_port(6667)
- '';
- }
-)
+ bridge.wait_for_unit("robustirc-bridge.service")
+ bridge.wait_for_open_port(1080)
+ bridge.wait_for_open_port(6667)
+ '';
+}
diff --git a/nixos/tests/rosenpass.nix b/nixos/tests/rosenpass.nix
index cb0937b58971..9af5ef608bfc 100644
--- a/nixos/tests/rosenpass.nix
+++ b/nixos/tests/rosenpass.nix
@@ -1,223 +1,221 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- deviceName = "rp0";
+{ pkgs, ... }:
+let
+ deviceName = "rp0";
- server = {
- ip = "fe80::1";
- wg = {
- public = "mQufmDFeQQuU/fIaB2hHgluhjjm1ypK4hJr1cW3WqAw=";
- secret = "4N5Y1dldqrpsbaEiY8O0XBUGUFf8vkvtBtm8AoOX7Eo=";
- listen = 10000;
- };
+ server = {
+ ip = "fe80::1";
+ wg = {
+ public = "mQufmDFeQQuU/fIaB2hHgluhjjm1ypK4hJr1cW3WqAw=";
+ secret = "4N5Y1dldqrpsbaEiY8O0XBUGUFf8vkvtBtm8AoOX7Eo=";
+ listen = 10000;
};
- client = {
- ip = "fe80::2";
- wg = {
- public = "Mb3GOlT7oS+F3JntVKiaD7SpHxLxNdtEmWz/9FMnRFU=";
- secret = "uC5dfGMv7Oxf5UDfdPkj6rZiRZT2dRWp5x8IQxrNcUE=";
- };
+ };
+ client = {
+ ip = "fe80::2";
+ wg = {
+ public = "Mb3GOlT7oS+F3JntVKiaD7SpHxLxNdtEmWz/9FMnRFU=";
+ secret = "uC5dfGMv7Oxf5UDfdPkj6rZiRZT2dRWp5x8IQxrNcUE=";
};
- in
- {
- name = "rosenpass";
+ };
+in
+{
+ name = "rosenpass";
- nodes =
- let
- shared =
- peer:
- { config, modulesPath, ... }:
- {
- imports = [ "${modulesPath}/services/networking/rosenpass.nix" ];
+ nodes =
+ let
+ shared =
+ peer:
+ { config, modulesPath, ... }:
+ {
+ imports = [ "${modulesPath}/services/networking/rosenpass.nix" ];
- boot.kernelModules = [ "wireguard" ];
+ boot.kernelModules = [ "wireguard" ];
- services.rosenpass = {
- enable = true;
- defaultDevice = deviceName;
- settings = {
- verbosity = "Verbose";
- public_key = "/etc/rosenpass/pqpk";
- secret_key = "/etc/rosenpass/pqsk";
- };
- };
-
- networking.firewall.allowedUDPPorts = [ 9999 ];
-
- systemd.network = {
- enable = true;
- networks."rosenpass" = {
- matchConfig.Name = deviceName;
- networkConfig.IPv4Forwarding = true;
- networkConfig.IPv6Forwarding = true;
- address = [ "${peer.ip}/64" ];
- };
-
- netdevs."10-rp0" = {
- netdevConfig = {
- Kind = "wireguard";
- Name = deviceName;
- };
- wireguardConfig.PrivateKeyFile = "/etc/wireguard/wgsk";
- };
- };
-
- environment.etc."wireguard/wgsk" = {
- text = peer.wg.secret;
- user = "systemd-network";
- group = "systemd-network";
+ services.rosenpass = {
+ enable = true;
+ defaultDevice = deviceName;
+ settings = {
+ verbosity = "Verbose";
+ public_key = "/etc/rosenpass/pqpk";
+ secret_key = "/etc/rosenpass/pqsk";
};
};
- in
- {
- server = {
- imports = [ (shared server) ];
- networking.firewall.allowedUDPPorts = [ server.wg.listen ];
+ networking.firewall.allowedUDPPorts = [ 9999 ];
- systemd.network.netdevs."10-${deviceName}" = {
- wireguardConfig.ListenPort = server.wg.listen;
- wireguardPeers = [
- {
- AllowedIPs = [ "::/0" ];
- PublicKey = client.wg.public;
- }
- ];
+ systemd.network = {
+ enable = true;
+ networks."rosenpass" = {
+ matchConfig.Name = deviceName;
+ networkConfig.IPv4Forwarding = true;
+ networkConfig.IPv6Forwarding = true;
+ address = [ "${peer.ip}/64" ];
+ };
+
+ netdevs."10-rp0" = {
+ netdevConfig = {
+ Kind = "wireguard";
+ Name = deviceName;
+ };
+ wireguardConfig.PrivateKeyFile = "/etc/wireguard/wgsk";
+ };
};
- services.rosenpass.settings = {
- listen = [ "0.0.0.0:9999" ];
- peers = [
- {
- public_key = "/etc/rosenpass/peers/client/pqpk";
- peer = client.wg.public;
- }
- ];
+ environment.etc."wireguard/wgsk" = {
+ text = peer.wg.secret;
+ user = "systemd-network";
+ group = "systemd-network";
};
};
- client = {
- imports = [ (shared client) ];
+ in
+ {
+ server = {
+ imports = [ (shared server) ];
- systemd.network.netdevs."10-${deviceName}".wireguardPeers = [
+ networking.firewall.allowedUDPPorts = [ server.wg.listen ];
+
+ systemd.network.netdevs."10-${deviceName}" = {
+ wireguardConfig.ListenPort = server.wg.listen;
+ wireguardPeers = [
{
AllowedIPs = [ "::/0" ];
- PublicKey = server.wg.public;
- Endpoint = "server:${builtins.toString server.wg.listen}";
+ PublicKey = client.wg.public;
}
];
+ };
- services.rosenpass.settings.peers = [
+ services.rosenpass.settings = {
+ listen = [ "0.0.0.0:9999" ];
+ peers = [
{
- public_key = "/etc/rosenpass/peers/server/pqpk";
- endpoint = "server:9999";
- peer = server.wg.public;
+ public_key = "/etc/rosenpass/peers/client/pqpk";
+ peer = client.wg.public;
}
];
};
};
+ client = {
+ imports = [ (shared client) ];
- testScript =
- { ... }:
- ''
- from os import system
+ systemd.network.netdevs."10-${deviceName}".wireguardPeers = [
+ {
+ AllowedIPs = [ "::/0" ];
+ PublicKey = server.wg.public;
+ Endpoint = "server:${builtins.toString server.wg.listen}";
+ }
+ ];
- # Full path to rosenpass in the store, to avoid fiddling with `$PATH`.
- rosenpass = "${pkgs.rosenpass}/bin/rosenpass"
-
- # Path in `/etc` where keys will be placed.
- etc = "/etc/rosenpass"
-
- start_all()
-
- for machine in [server, client]:
- machine.wait_for_unit("multi-user.target")
-
- # Gently stop Rosenpass to avoid crashes during key generation/distribution.
- for machine in [server, client]:
- machine.execute("systemctl stop rosenpass.service")
-
- for (name, machine, remote) in [("server", server, client), ("client", client, server)]:
- pk, sk = f"{name}.pqpk", f"{name}.pqsk"
- system(f"{rosenpass} gen-keys --force --secret-key {sk} --public-key {pk}")
- machine.copy_from_host(sk, f"{etc}/pqsk")
- machine.copy_from_host(pk, f"{etc}/pqpk")
- remote.copy_from_host(pk, f"{etc}/peers/{name}/pqpk")
-
- for machine in [server, client]:
- machine.execute("systemctl start rosenpass.service")
-
- for machine in [server, client]:
- machine.wait_for_unit("rosenpass.service")
-
- with subtest("ping"):
- client.succeed("ping -c 2 -i 0.5 ${server.ip}%${deviceName}")
-
- with subtest("preshared-keys"):
- # Rosenpass works by setting the WireGuard preshared key at regular intervals.
- # Thus, if it is not active, then no key will be set, and the output of `wg show` will contain "none".
- # Otherwise, if it is active, then the key will be set and "none" will not be found in the output of `wg show`.
- for machine in [server, client]:
- machine.wait_until_succeeds("wg show all preshared-keys | grep --invert-match none", timeout=5)
- '';
-
- # NOTE: Below configuration is for "interactive" (=developing/debugging) only.
- interactive.nodes =
- let
- inherit (import ./ssh-keys.nix pkgs) snakeOilPublicKey snakeOilPrivateKey;
-
- sshAndKeyGeneration = {
- services.openssh.enable = true;
- users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
- environment.systemPackages = [
- (pkgs.writeShellApplication {
- name = "gen-keys";
- runtimeInputs = [ pkgs.rosenpass ];
- text = ''
- HOST="$(hostname)"
- if [ "$HOST" == "server" ]
- then
- PEER="client"
- else
- PEER="server"
- fi
-
- # Generate keypair.
- mkdir -vp /etc/rosenpass/peers/$PEER
- rosenpass gen-keys --force --secret-key /etc/rosenpass/pqsk --public-key /etc/rosenpass/pqpk
-
- # Set up SSH key.
- mkdir -p /root/.ssh
- cp ${snakeOilPrivateKey} /root/.ssh/id_ecdsa
- chmod 0400 /root/.ssh/id_ecdsa
-
- # Copy public key to other peer.
- # shellcheck disable=SC2029
- ssh -o StrictHostKeyChecking=no $PEER "mkdir -pv /etc/rosenpass/peers/$HOST"
- scp /etc/rosenpass/pqpk "$PEER:/etc/rosenpass/peers/$HOST/pqpk"
- '';
- })
- ];
- };
-
- # Use kmscon
- # to provide a slightly nicer console, and while we're at it,
- # also use a nice font.
- # With kmscon, we can for example zoom in/out using [Ctrl] + [+]
- # and [Ctrl] + [-]
- niceConsoleAndAutologin.services.kmscon = {
- enable = true;
- autologinUser = "root";
- fonts = [
- {
- name = "Fira Code";
- package = pkgs.fira-code;
- }
- ];
- };
- in
- {
- server = sshAndKeyGeneration // niceConsoleAndAutologin;
- client = sshAndKeyGeneration // niceConsoleAndAutologin;
+ services.rosenpass.settings.peers = [
+ {
+ public_key = "/etc/rosenpass/peers/server/pqpk";
+ endpoint = "server:9999";
+ peer = server.wg.public;
+ }
+ ];
};
- }
-)
+ };
+
+ testScript =
+ { ... }:
+ ''
+ from os import system
+
+ # Full path to rosenpass in the store, to avoid fiddling with `$PATH`.
+ rosenpass = "${pkgs.rosenpass}/bin/rosenpass"
+
+ # Path in `/etc` where keys will be placed.
+ etc = "/etc/rosenpass"
+
+ start_all()
+
+ for machine in [server, client]:
+ machine.wait_for_unit("multi-user.target")
+
+ # Gently stop Rosenpass to avoid crashes during key generation/distribution.
+ for machine in [server, client]:
+ machine.execute("systemctl stop rosenpass.service")
+
+ for (name, machine, remote) in [("server", server, client), ("client", client, server)]:
+ pk, sk = f"{name}.pqpk", f"{name}.pqsk"
+ system(f"{rosenpass} gen-keys --force --secret-key {sk} --public-key {pk}")
+ machine.copy_from_host(sk, f"{etc}/pqsk")
+ machine.copy_from_host(pk, f"{etc}/pqpk")
+ remote.copy_from_host(pk, f"{etc}/peers/{name}/pqpk")
+
+ for machine in [server, client]:
+ machine.execute("systemctl start rosenpass.service")
+
+ for machine in [server, client]:
+ machine.wait_for_unit("rosenpass.service")
+
+ with subtest("ping"):
+ client.succeed("ping -c 2 -i 0.5 ${server.ip}%${deviceName}")
+
+ with subtest("preshared-keys"):
+ # Rosenpass works by setting the WireGuard preshared key at regular intervals.
+ # Thus, if it is not active, then no key will be set, and the output of `wg show` will contain "none".
+ # Otherwise, if it is active, then the key will be set and "none" will not be found in the output of `wg show`.
+ for machine in [server, client]:
+ machine.wait_until_succeeds("wg show all preshared-keys | grep --invert-match none", timeout=5)
+ '';
+
+ # NOTE: Below configuration is for "interactive" (=developing/debugging) only.
+ interactive.nodes =
+ let
+ inherit (import ./ssh-keys.nix pkgs) snakeOilPublicKey snakeOilPrivateKey;
+
+ sshAndKeyGeneration = {
+ services.openssh.enable = true;
+ users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
+ environment.systemPackages = [
+ (pkgs.writeShellApplication {
+ name = "gen-keys";
+ runtimeInputs = [ pkgs.rosenpass ];
+ text = ''
+ HOST="$(hostname)"
+ if [ "$HOST" == "server" ]
+ then
+ PEER="client"
+ else
+ PEER="server"
+ fi
+
+ # Generate keypair.
+ mkdir -vp /etc/rosenpass/peers/$PEER
+ rosenpass gen-keys --force --secret-key /etc/rosenpass/pqsk --public-key /etc/rosenpass/pqpk
+
+ # Set up SSH key.
+ mkdir -p /root/.ssh
+ cp ${snakeOilPrivateKey} /root/.ssh/id_ecdsa
+ chmod 0400 /root/.ssh/id_ecdsa
+
+ # Copy public key to other peer.
+ # shellcheck disable=SC2029
+ ssh -o StrictHostKeyChecking=no $PEER "mkdir -pv /etc/rosenpass/peers/$HOST"
+ scp /etc/rosenpass/pqpk "$PEER:/etc/rosenpass/peers/$HOST/pqpk"
+ '';
+ })
+ ];
+ };
+
+ # Use kmscon
+ # to provide a slightly nicer console, and while we're at it,
+ # also use a nice font.
+ # With kmscon, we can for example zoom in/out using [Ctrl] + [+]
+ # and [Ctrl] + [-]
+ niceConsoleAndAutologin.services.kmscon = {
+ enable = true;
+ autologinUser = "root";
+ fonts = [
+ {
+ name = "Fira Code";
+ package = pkgs.fira-code;
+ }
+ ];
+ };
+ in
+ {
+ server = sshAndKeyGeneration // niceConsoleAndAutologin;
+ client = sshAndKeyGeneration // niceConsoleAndAutologin;
+ };
+}
diff --git a/nixos/tests/roundcube.nix b/nixos/tests/roundcube.nix
index 1f82e9c7a902..c631c97d6827 100644
--- a/nixos/tests/roundcube.nix
+++ b/nixos/tests/roundcube.nix
@@ -1,40 +1,38 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "roundcube";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ globin ];
- };
+{ pkgs, ... }:
+{
+ name = "roundcube";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ globin ];
+ };
- nodes = {
- roundcube =
- { config, pkgs, ... }:
- {
- services.roundcube = {
- enable = true;
- hostName = "roundcube";
- database.password = "not production";
- package = pkgs.roundcube.withPlugins (plugins: [ plugins.persistent_login ]);
- plugins = [ "persistent_login" ];
- dicts = with pkgs.aspellDicts; [
- en
- fr
- de
- ];
- };
- services.nginx.virtualHosts.roundcube = {
- forceSSL = false;
- enableACME = false;
- };
+ nodes = {
+ roundcube =
+ { config, pkgs, ... }:
+ {
+ services.roundcube = {
+ enable = true;
+ hostName = "roundcube";
+ database.password = "not production";
+ package = pkgs.roundcube.withPlugins (plugins: [ plugins.persistent_login ]);
+ plugins = [ "persistent_login" ];
+ dicts = with pkgs.aspellDicts; [
+ en
+ fr
+ de
+ ];
};
- };
+ services.nginx.virtualHosts.roundcube = {
+ forceSSL = false;
+ enableACME = false;
+ };
+ };
+ };
- testScript = ''
- roundcube.start
- roundcube.wait_for_unit("postgresql.service")
- roundcube.wait_for_unit("phpfpm-roundcube.service")
- roundcube.wait_for_unit("nginx.service")
- roundcube.succeed("curl -sSfL http://roundcube/ | grep 'Keep me logged in'")
- '';
- }
-)
+ testScript = ''
+ roundcube.start
+ roundcube.wait_for_unit("postgresql.service")
+ roundcube.wait_for_unit("phpfpm-roundcube.service")
+ roundcube.wait_for_unit("nginx.service")
+ roundcube.succeed("curl -sSfL http://roundcube/ | grep 'Keep me logged in'")
+ '';
+}
diff --git a/nixos/tests/rspamd-trainer.nix b/nixos/tests/rspamd-trainer.nix
index fdb05bb8b00d..2f58ab73dd4f 100644
--- a/nixos/tests/rspamd-trainer.nix
+++ b/nixos/tests/rspamd-trainer.nix
@@ -1,168 +1,166 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- certs = import ./common/acme/server/snakeoil-certs.nix;
- domain = certs.domain;
- in
- {
- name = "rspamd-trainer";
- meta = with pkgs.lib.maintainers; {
- maintainers = [ onny ];
- };
+{ pkgs, ... }:
+let
+ certs = import ./common/acme/server/snakeoil-certs.nix;
+ domain = certs.domain;
+in
+{
+ name = "rspamd-trainer";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ onny ];
+ };
- nodes = {
- machine =
- { options, config, ... }:
- {
+ nodes = {
+ machine =
+ { options, config, ... }:
+ {
- security.pki.certificateFiles = [
- certs.ca.cert
+ security.pki.certificateFiles = [
+ certs.ca.cert
+ ];
+
+ networking.extraHosts = ''
+ 127.0.0.1 ${domain}
+ '';
+
+ services.rspamd-trainer = {
+ enable = true;
+ settings = {
+ HOST = domain;
+ USERNAME = "spam@${domain}";
+ INBOXPREFIX = "INBOX/";
+ };
+ secrets = [
+ # Do not use this in production. This will make passwords
+ # world-readable in the Nix store
+ "${pkgs.writeText "secrets" ''
+ PASSWORD = test123
+ ''}"
];
-
- networking.extraHosts = ''
- 127.0.0.1 ${domain}
- '';
-
- services.rspamd-trainer = {
- enable = true;
- settings = {
- HOST = domain;
- USERNAME = "spam@${domain}";
- INBOXPREFIX = "INBOX/";
- };
- secrets = [
- # Do not use this in production. This will make passwords
- # world-readable in the Nix store
- "${pkgs.writeText "secrets" ''
- PASSWORD = test123
- ''}"
- ];
- };
-
- services.maddy = {
- enable = true;
- hostname = domain;
- primaryDomain = domain;
- ensureAccounts = [ "spam@${domain}" ];
- ensureCredentials = {
- # Do not use this in production. This will make passwords world-readable
- # in the Nix store
- "spam@${domain}".passwordFile = "${pkgs.writeText "postmaster" "test123"}";
- };
- tls = {
- loader = "file";
- certificates = [
- {
- certPath = "${certs.${domain}.cert}";
- keyPath = "${certs.${domain}.key}";
- }
- ];
- };
- config =
- builtins.replaceStrings
- [
- "imap tcp://0.0.0.0:143"
- "submission tcp://0.0.0.0:587"
- ]
- [
- "imap tls://0.0.0.0:993 tcp://0.0.0.0:143"
- "submission tls://0.0.0.0:465 tcp://0.0.0.0:587"
- ]
- options.services.maddy.config.default;
- };
-
- services.rspamd = {
- enable = true;
- locals = {
- "redis.conf".text = ''
- servers = "${config.services.redis.servers.rspamd.unixSocket}";
- '';
- "classifier-bayes.conf".text = ''
- backend = "redis";
- autolearn = true;
- '';
- };
- };
-
- services.redis.servers.rspamd = {
- enable = true;
- port = 0;
- unixSocket = "/run/redis-rspamd/redis.sock";
- user = config.services.rspamd.user;
- };
-
- environment.systemPackages = [
- (pkgs.writers.writePython3Bin "send-testmail" { } ''
- import smtplib
- import ssl
- from email.mime.text import MIMEText
- context = ssl.create_default_context()
- msg = MIMEText("Hello World")
- msg['Subject'] = 'Test'
- msg['From'] = "spam@${domain}"
- msg['To'] = "spam@${domain}"
- with smtplib.SMTP_SSL(host='${domain}', port=465, context=context) as smtp:
- smtp.login('spam@${domain}', 'test123')
- smtp.sendmail(
- 'spam@${domain}', 'spam@${domain}', msg.as_string()
- )
- '')
- (pkgs.writers.writePython3Bin "create-mail-dirs" { } ''
- import imaplib
- with imaplib.IMAP4_SSL('${domain}') as imap:
- imap.login('spam@${domain}', 'test123')
- imap.create("\"INBOX/report_spam\"")
- imap.create("\"INBOX/report_ham\"")
- imap.create("\"INBOX/report_spam_reply\"")
- imap.select("INBOX")
- imap.copy("1", "\"INBOX/report_ham\"")
- imap.logout()
- '')
- (pkgs.writers.writePython3Bin "test-imap" { } ''
- import imaplib
- with imaplib.IMAP4_SSL('${domain}') as imap:
- imap.login('spam@${domain}', 'test123')
- imap.select("INBOX/learned_ham")
- status, refs = imap.search(None, 'ALL')
- assert status == 'OK'
- assert len(refs) == 1
- status, msg = imap.fetch(refs[0], 'BODY[TEXT]')
- assert status == 'OK'
- assert msg[0][1].strip() == b"Hello World"
- imap.logout()
- '')
- ];
-
};
- };
+ services.maddy = {
+ enable = true;
+ hostname = domain;
+ primaryDomain = domain;
+ ensureAccounts = [ "spam@${domain}" ];
+ ensureCredentials = {
+ # Do not use this in production. This will make passwords world-readable
+ # in the Nix store
+ "spam@${domain}".passwordFile = "${pkgs.writeText "postmaster" "test123"}";
+ };
+ tls = {
+ loader = "file";
+ certificates = [
+ {
+ certPath = "${certs.${domain}.cert}";
+ keyPath = "${certs.${domain}.key}";
+ }
+ ];
+ };
+ config =
+ builtins.replaceStrings
+ [
+ "imap tcp://0.0.0.0:143"
+ "submission tcp://0.0.0.0:587"
+ ]
+ [
+ "imap tls://0.0.0.0:993 tcp://0.0.0.0:143"
+ "submission tls://0.0.0.0:465 tcp://0.0.0.0:587"
+ ]
+ options.services.maddy.config.default;
+ };
- testScript =
- { nodes }:
- ''
- start_all()
- machine.wait_for_unit("maddy.service")
- machine.wait_for_open_port(143)
- machine.wait_for_open_port(993)
- machine.wait_for_open_port(587)
- machine.wait_for_open_port(465)
+ services.rspamd = {
+ enable = true;
+ locals = {
+ "redis.conf".text = ''
+ servers = "${config.services.redis.servers.rspamd.unixSocket}";
+ '';
+ "classifier-bayes.conf".text = ''
+ backend = "redis";
+ autolearn = true;
+ '';
+ };
+ };
- # Send test mail to spam@domain
- machine.succeed("send-testmail")
+ services.redis.servers.rspamd = {
+ enable = true;
+ port = 0;
+ unixSocket = "/run/redis-rspamd/redis.sock";
+ user = config.services.rspamd.user;
+ };
- # Create mail directories required for rspamd-trainer and copy mail from
- # INBOX into INBOX/report_ham
- machine.succeed("create-mail-dirs")
+ environment.systemPackages = [
+ (pkgs.writers.writePython3Bin "send-testmail" { } ''
+ import smtplib
+ import ssl
+ from email.mime.text import MIMEText
+ context = ssl.create_default_context()
+ msg = MIMEText("Hello World")
+ msg['Subject'] = 'Test'
+ msg['From'] = "spam@${domain}"
+ msg['To'] = "spam@${domain}"
+ with smtplib.SMTP_SSL(host='${domain}', port=465, context=context) as smtp:
+ smtp.login('spam@${domain}', 'test123')
+ smtp.sendmail(
+ 'spam@${domain}', 'spam@${domain}', msg.as_string()
+ )
+ '')
+ (pkgs.writers.writePython3Bin "create-mail-dirs" { } ''
+ import imaplib
+ with imaplib.IMAP4_SSL('${domain}') as imap:
+ imap.login('spam@${domain}', 'test123')
+ imap.create("\"INBOX/report_spam\"")
+ imap.create("\"INBOX/report_ham\"")
+ imap.create("\"INBOX/report_spam_reply\"")
+ imap.select("INBOX")
+ imap.copy("1", "\"INBOX/report_ham\"")
+ imap.logout()
+ '')
+ (pkgs.writers.writePython3Bin "test-imap" { } ''
+ import imaplib
+ with imaplib.IMAP4_SSL('${domain}') as imap:
+ imap.login('spam@${domain}', 'test123')
+ imap.select("INBOX/learned_ham")
+ status, refs = imap.search(None, 'ALL')
+ assert status == 'OK'
+ assert len(refs) == 1
+ status, msg = imap.fetch(refs[0], 'BODY[TEXT]')
+ assert status == 'OK'
+ assert msg[0][1].strip() == b"Hello World"
+ imap.logout()
+ '')
+ ];
- # Start rspamd-trainer. It should read mail from INBOX/report_ham
- machine.wait_for_unit("rspamd.service")
- machine.wait_for_unit("redis-rspamd.service")
- machine.wait_for_file("/run/rspamd/rspamd.sock")
- machine.succeed("systemctl start rspamd-trainer.service")
+ };
- # Check if mail got processed by rspamd-trainer successfully and check for
- # it in INBOX/learned_ham
- machine.succeed("test-imap")
- '';
- }
-)
+ };
+
+ testScript =
+ { nodes }:
+ ''
+ start_all()
+ machine.wait_for_unit("maddy.service")
+ machine.wait_for_open_port(143)
+ machine.wait_for_open_port(993)
+ machine.wait_for_open_port(587)
+ machine.wait_for_open_port(465)
+
+ # Send test mail to spam@domain
+ machine.succeed("send-testmail")
+
+ # Create mail directories required for rspamd-trainer and copy mail from
+ # INBOX into INBOX/report_ham
+ machine.succeed("create-mail-dirs")
+
+ # Start rspamd-trainer. It should read mail from INBOX/report_ham
+ machine.wait_for_unit("rspamd.service")
+ machine.wait_for_unit("redis-rspamd.service")
+ machine.wait_for_file("/run/rspamd/rspamd.sock")
+ machine.succeed("systemctl start rspamd-trainer.service")
+
+ # Check if mail got processed by rspamd-trainer successfully and check for
+ # it in INBOX/learned_ham
+ machine.succeed("test-imap")
+ '';
+}
diff --git a/nixos/tests/rstudio-server.nix b/nixos/tests/rstudio-server.nix
index 03a173fe32f2..e561bd309d40 100644
--- a/nixos/tests/rstudio-server.nix
+++ b/nixos/tests/rstudio-server.nix
@@ -1,43 +1,41 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "rstudio-server-test";
- meta.maintainers = with pkgs.lib.maintainers; [
- jbedo
- cfhammill
- ];
+{ pkgs, ... }:
+{
+ name = "rstudio-server-test";
+ meta.maintainers = with pkgs.lib.maintainers; [
+ jbedo
+ cfhammill
+ ];
- nodes.machine =
- {
- config,
- lib,
- pkgs,
- ...
- }:
- {
- services.rstudio-server.enable = true;
+ nodes.machine =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ services.rstudio-server.enable = true;
+ };
+
+ nodes.customPackageMachine =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ services.rstudio-server = {
+ enable = true;
+ package = pkgs.rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; };
};
+ };
- nodes.customPackageMachine =
- {
- config,
- lib,
- pkgs,
- ...
- }:
- {
- services.rstudio-server = {
- enable = true;
- package = pkgs.rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; };
- };
- };
+ testScript = ''
+ machine.wait_for_unit("rstudio-server.service")
+ machine.succeed("curl -f -vvv -s http://127.0.0.1:8787")
- testScript = ''
- machine.wait_for_unit("rstudio-server.service")
- machine.succeed("curl -f -vvv -s http://127.0.0.1:8787")
-
- customPackageMachine.wait_for_unit("rstudio-server.service")
- customPackageMachine.succeed("curl -f -vvv -s http://127.0.0.1:8787")
- '';
- }
-)
+ customPackageMachine.wait_for_unit("rstudio-server.service")
+ customPackageMachine.succeed("curl -f -vvv -s http://127.0.0.1:8787")
+ '';
+}
diff --git a/nixos/tests/rsyncd.nix b/nixos/tests/rsyncd.nix
index 9935c0e6c6bf..3ccf22c2132b 100644
--- a/nixos/tests/rsyncd.nix
+++ b/nixos/tests/rsyncd.nix
@@ -1,45 +1,43 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- {
- name = "rsyncd";
- meta.maintainers = with pkgs.lib.maintainers; [ ehmry ];
+{ pkgs, ... }:
+{
+ name = "rsyncd";
+ meta.maintainers = with pkgs.lib.maintainers; [ ehmry ];
- nodes =
- let
- mkNode =
- socketActivated:
- { config, ... }:
- {
- networking.firewall.allowedTCPPorts = [ config.services.rsyncd.port ];
- services.rsyncd = {
- enable = true;
- inherit socketActivated;
- settings = {
- globalSection = {
- "reverse lookup" = false;
- "forward lookup" = false;
- };
- sections = {
- tmp = {
- path = "/nix/store";
- comment = "test module";
- };
+ nodes =
+ let
+ mkNode =
+ socketActivated:
+ { config, ... }:
+ {
+ networking.firewall.allowedTCPPorts = [ config.services.rsyncd.port ];
+ services.rsyncd = {
+ enable = true;
+ inherit socketActivated;
+ settings = {
+ globalSection = {
+ "reverse lookup" = false;
+ "forward lookup" = false;
+ };
+ sections = {
+ tmp = {
+ path = "/nix/store";
+ comment = "test module";
};
};
};
};
- in
- {
- a = mkNode false;
- b = mkNode true;
- };
+ };
+ in
+ {
+ a = mkNode false;
+ b = mkNode true;
+ };
- testScript = ''
- start_all()
- a.wait_for_unit("rsync")
- b.wait_for_unit("sockets.target")
- b.succeed("rsync a::")
- a.succeed("rsync b::")
- '';
- }
-)
+ testScript = ''
+ start_all()
+ a.wait_for_unit("rsync")
+ b.wait_for_unit("sockets.target")
+ b.succeed("rsync a::")
+ a.succeed("rsync b::")
+ '';
+}
diff --git a/nixos/tests/rtorrent.nix b/nixos/tests/rtorrent.nix
index ca680380374a..b34f1cb5cec6 100644
--- a/nixos/tests/rtorrent.nix
+++ b/nixos/tests/rtorrent.nix
@@ -1,30 +1,28 @@
-import ./make-test-python.nix (
- { pkgs, ... }:
- let
- port = 50001;
- in
- {
- name = "rtorrent";
- meta = {
- maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
+{ pkgs, ... }:
+let
+ port = 50001;
+in
+{
+ name = "rtorrent";
+ meta = {
+ maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
+ };
+
+ nodes.machine =
+ { pkgs, ... }:
+ {
+ services.rtorrent = {
+ inherit port;
+ enable = true;
+ };
};
- nodes.machine =
- { pkgs, ... }:
- {
- services.rtorrent = {
- inherit port;
- enable = true;
- };
- };
+ testScript = # python
+ ''
+ machine.start()
+ machine.wait_for_unit("rtorrent.service")
+ machine.wait_for_open_port(${toString port})
- testScript = # python
- ''
- machine.start()
- machine.wait_for_unit("rtorrent.service")
- machine.wait_for_open_port(${toString port})
-
- machine.succeed("nc -z localhost ${toString port}")
- '';
- }
-)
+ machine.succeed("nc -z localhost ${toString port}")
+ '';
+}
diff --git a/nixos/tests/rustls-libssl.nix b/nixos/tests/rustls-libssl.nix
index 079fa52435bc..165edb76a5d4 100644
--- a/nixos/tests/rustls-libssl.nix
+++ b/nixos/tests/rustls-libssl.nix
@@ -1,92 +1,90 @@
-import ./make-test-python.nix (
- { pkgs, lib, ... }:
- let
- caCert = builtins.readFile ./common/acme/server/ca.cert.pem;
- certPath = ./common/acme/server/acme.test.cert.pem;
- keyPath = ./common/acme/server/acme.test.key.pem;
- hosts = ''
- 192.168.2.101 acme.test
- '';
- in
- {
- name = "rustls-libssl";
- meta.maintainers = with pkgs.lib.maintainers; [
- stephank
- cpu
- ];
+{ pkgs, lib, ... }:
+let
+ caCert = builtins.readFile ./common/acme/server/ca.cert.pem;
+ certPath = ./common/acme/server/acme.test.cert.pem;
+ keyPath = ./common/acme/server/acme.test.key.pem;
+ hosts = ''
+ 192.168.2.101 acme.test
+ '';
+in
+{
+ name = "rustls-libssl";
+ meta.maintainers = with pkgs.lib.maintainers; [
+ stephank
+ cpu
+ ];
- nodes = {
- server =
- { lib, pkgs, ... }:
- {
- networking = {
- interfaces.eth1 = {
- ipv4.addresses = [
- {
- address = "192.168.2.101";
- prefixLength = 24;
- }
- ];
- };
- extraHosts = hosts;
- firewall.allowedTCPPorts = [ 443 ];
- };
-
- security.pki.certificates = [ caCert ];
-
- services.nginx = {
- enable = true;
- package = pkgs.nginxMainline.override {
- openssl = pkgs.rustls-libssl;
- modules = [ ]; # slightly reduces the size of the build
- };
-
- # Hardcoded sole input accepted by rustls-libssl.
- sslCiphers = "HIGH:!aNULL:!MD5";
-
- virtualHosts."acme.test" = {
- onlySSL = true;
- sslCertificate = certPath;
- sslCertificateKey = keyPath;
- http2 = true;
- reuseport = true;
- root = lib.mkForce (
- pkgs.runCommandLocal "testdir" { } ''
- mkdir "$out"
- cat > "$out/index.html" <Hello World!