flake.nix: run tests against pinned nixpkgs

and migrate to the new runTest, which evaluates much faster.
This commit is contained in:
Martin Weinelt 2025-05-10 02:36:21 +02:00
parent 1feca02008
commit ef1e02e555
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
7 changed files with 80 additions and 56 deletions

View file

@ -14,12 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
{ pkgs ? import <nixpkgs> {}, blobs}:
{
lib,
blobs,
...
}:
pkgs.nixosTest {
{
name = "clamav";
nodes = {
server = { config, pkgs, lib, ... }:
server = { pkgs, ... }:
{
imports = [
../default.nix
@ -28,6 +33,8 @@ pkgs.nixosTest {
virtualisation.memorySize = 1500;
environment.systemPackages = with pkgs; [ netcat ];
services.rsyslogd = {
enable = true;
defaultConfig = ''
@ -83,7 +90,7 @@ pkgs.nixosTest {
"root/eicar.com.txt".text = "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*";
};
};
client = { nodes, config, pkgs, ... }: let
client = { nodes, pkgs, ... }: let
serverIP = nodes.server.networking.primaryIPAddress;
clientIP = nodes.client.networking.primaryIPAddress;
grep-ip = pkgs.writeScriptBin "grep-ip" ''
@ -180,8 +187,7 @@ pkgs.nixosTest {
};
};
testScript = { nodes, ... }:
''
testScript = ''
start_all()
server.wait_for_unit("multi-user.target")
@ -189,10 +195,10 @@ pkgs.nixosTest {
# TODO put this blocking into the systemd units? I am not sure if rspamd already waits for the clamd socket.
server.wait_until_succeeds(
"set +e; timeout 1 ${nodes.server.nixpkgs.pkgs.netcat}/bin/nc -U /run/rspamd/rspamd-milter.sock < /dev/null; [ $? -eq 124 ]"
"set +e; timeout 1 nc -U /run/rspamd/rspamd-milter.sock < /dev/null; [ $? -eq 124 ]"
)
server.wait_until_succeeds(
"set +e; timeout 1 ${nodes.server.nixpkgs.pkgs.netcat}/bin/nc -U /run/clamav/clamd.ctl < /dev/null; [ $? -eq 124 ]"
"set +e; timeout 1 nc -U /run/clamav/clamd.ctl < /dev/null; [ $? -eq 124 ]"
)
client.execute("cp -p /etc/root/.* ~/")