diff --git a/services-agnostic/agetty/default.nix b/services-agnostic/agetty/default.nix new file mode 100644 index 0000000..56903ae --- /dev/null +++ b/services-agnostic/agetty/default.nix @@ -0,0 +1,14 @@ +{createManagedProcess, util-linux}: +{port, instanceName ? "agetty-${port}", baudrate ? 9600, extraOptions ? []}: + +createManagedProcess { + inherit instanceName; + foregroundProcess = "${util-linux}/bin/agetty"; + args = extraOptions ++ [ port baudrate ]; + + overrides = { + sysvinit = { + runlevels = [ 2 3 4 5 ]; + }; + }; +} diff --git a/services-agnostic/constructors.nix b/services-agnostic/constructors.nix index a74ec9d..1081e6e 100644 --- a/services-agnostic/constructors.nix +++ b/services-agnostic/constructors.nix @@ -207,4 +207,9 @@ in inherit createManagedProcess forceDisableUserChange logDir libDir callingUser callingGroup; inherit (pkgs) stdenv vsftpd writeTextFile lib; }; + + agetty = import ./agetty { + inherit createManagedProcess; + inherit (pkgs) util-linux; + }; } diff --git a/tests/agetty/note.md b/tests/agetty/note.md new file mode 100644 index 0000000..ee5cf11 --- /dev/null +++ b/tests/agetty/note.md @@ -0,0 +1,9 @@ +This test is for setting up a connection with a null modem cable that works +to link up my PC with my Commodore Amiga 500. + +It cannot be automated with the NixOS test driver, but you can manually deploy +it by running the following command as root user: + +```bash +nixproc-supervisord-deploy-stateless processes.nix +``` diff --git a/tests/agetty/processes.nix b/tests/agetty/processes.nix new file mode 100644 index 0000000..74154f7 --- /dev/null +++ b/tests/agetty/processes.nix @@ -0,0 +1,28 @@ +{ pkgs ? import { inherit system; } +, system ? builtins.currentSystem +, stateDir ? "/var" +, runtimeDir ? "${stateDir}/run" +, logDir ? "${stateDir}/log" +, spoolDir ? "${stateDir}/spool" +, cacheDir ? "${stateDir}/cache" +, libDir ? "${stateDir}/lib" +, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp") +, forceDisableUserChange ? false +, processManager +, nix-processmgmt ? ../../../nix-processmgmt +}: + +let + constructors = import ../../services-agnostic/constructors.nix { + inherit pkgs stateDir runtimeDir logDir tmpDir cacheDir libDir spoolDir forceDisableUserChange processManager nix-processmgmt; + }; +in +{ + agetty-nullmodem = { + pkg = constructors.agetty { + baudrate = 19200; + port = "ttyUSB0"; + extraOptions = [ "--flow-control" ]; + }; + }; +}