diff --git a/src/local/flake.lock b/src/local/flake.lock index 5d0214c3..cc6262e1 100644 --- a/src/local/flake.lock +++ b/src/local/flake.lock @@ -363,12 +363,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-3jw+c8xu0ia5ZD7QaZGqWKdUXRJ5fDZrYUpiKdPEOzs=", - "path": "/nix/store/kabv0zhhn0b00fvw4xrr9i1q7g8bz298-source", + "narHash": "sha256-UIgHO0Th/bdamo5H3eamvjczpbnyglRbk4/xZ54g3+c=", + "path": "/nix/store/nmp7kyh862rsc7ghasyk660gkh536w1m-source", "type": "path" }, "original": { - "path": "/nix/store/kabv0zhhn0b00fvw4xrr9i1q7g8bz298-source", + "path": "/nix/store/nmp7kyh862rsc7ghasyk660gkh536w1m-source", "type": "path" } }, diff --git a/src/std/fwlib/blockTypes/nixostests.nix b/src/std/fwlib/blockTypes/nixostests.nix new file mode 100644 index 00000000..1951e977 --- /dev/null +++ b/src/std/fwlib/blockTypes/nixostests.nix @@ -0,0 +1,75 @@ +{ + root, + super, +}: +/* +Use the NixosTests Blocktype in order to instrucement nixos +vm-based test inside your reporisory. + +Available actions: + - run + - run-vm + - audit-script + - run-vm-+ +*/ +let + inherit (root) mkCommand actions; + inherit (super) addSelectorFunctor; +in + name: { + __functor = addSelectorFunctor; + inherit name; + type = "nixostests"; + actions = { + currentSystem, + fragment, + fragmentRelPath, + target, + inputs, + }: let + pkgs = inputs.nixpkgs.${currentSystem}; + in [ + (mkCommand currentSystem "run" "run tests in headless vm" [] '' + # ${target.driver} + ${target.driver}/bin/nixos-test-driver + '' {}) + (mkCommand currentSystem "audit-script" "audit the test script" [pkgs.bat] '' + # ${target.driver} + bat --language py ${target.driver}/test-script + '' {}) + (mkCommand currentSystem "run-vm" "run tests interactively in vm" [] '' + # ${target.driverInteractive} + ${target.driverInteractive}/bin/nixos-test-driver + '' {}) + (mkCommand currentSystem "run-vm+" "run tests with state from last run" [] '' + # ${target.driverInteractive} + ${target.driverInteractive}/bin/nixos-test-driver --keep-vm-state + '' {}) + (mkCommand currentSystem "iptables+" "setup nat redirect 80->8080 & 443->4433" [pkgs.iptables] '' + sudo iptables \ + --table nat \ + --insert OUTPUT \ + --proto tcp \ + --destination 127.0.0.1 \ + --dport 443 \ + --jump REDIRECT \ + --to-ports 4433 + sudo iptables \ + --table nat \ + --insert OUTPUT \ + --proto tcp \ + --destination 127.0.0.1 \ + --dport 80 \ + --jump REDIRECT \ + --to-ports 8080 + '' {}) + (mkCommand currentSystem "iptables-" "remove nat redirect 80->8080 & 443->4433" [pkgs.iptables] '' + sudo iptables \ + --table nat \ + --delete OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 4433 + sudo iptables \ + --table nat \ + --delete OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 + '' {}) + ]; + } diff --git a/src/tests/flake.lock b/src/tests/flake.lock index bd7c6954..f98cffbb 100644 --- a/src/tests/flake.lock +++ b/src/tests/flake.lock @@ -534,12 +534,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-XqH/66cLRYyiTlk2ob04WCeps5TFC0vyB4J+4foZBYw=", - "path": "/nix/store/056lk4aanlj3h831x4kj2hb1v9rgc98f-source", + "narHash": "sha256-c+krYSi/VpFJZao8RSLCZmC++/r6leLsr4JlCHsT6hY=", + "path": "/nix/store/jy7sjazvkrr0l3v7n7905g987rfk4bw2-source", "type": "path" }, "original": { - "path": "/nix/store/056lk4aanlj3h831x4kj2hb1v9rgc98f-source", + "path": "/nix/store/jy7sjazvkrr0l3v7n7905g987rfk4bw2-source", "type": "path" } },