at 22.05-pre 1.1 kB view raw
1import ./make-test-python.nix ({ pkgs, ... }: 2 3let 4 exampleScript = pkgs.writeTextFile { 5 name = "example.sh"; 6 text = '' 7 #! ${pkgs.runtimeShell} -e 8 9 while true; do 10 echo "Example script running" >&2 11 ${pkgs.coreutils}/bin/sleep 1 12 done 13 ''; 14 executable = true; 15 }; 16 17 unitFile = pkgs.writeTextFile { 18 name = "example.service"; 19 text = '' 20 [Unit] 21 Description=Example systemd service unit file 22 23 [Service] 24 ExecStart=${exampleScript} 25 26 [Install] 27 WantedBy=multi-user.target 28 ''; 29 }; 30in 31{ 32 name = "systemd-unit-path"; 33 34 machine = { pkgs, lib, ... }: { 35 boot.extraSystemdUnitPaths = [ "/etc/systemd-rw/system" ]; 36 }; 37 38 testScript = '' 39 machine.wait_for_unit("multi-user.target") 40 machine.succeed("mkdir -p /etc/systemd-rw/system") 41 machine.succeed( 42 "cp ${unitFile} /etc/systemd-rw/system/example.service" 43 ) 44 machine.succeed("systemctl start example.service") 45 machine.succeed("systemctl status example.service | grep 'Active: active'") 46 ''; 47})