diff --git a/modules/aspects/provides/tty-autologin.nix b/modules/aspects/provides/tty-autologin.nix new file mode 100644 index 0000000..9411527 --- /dev/null +++ b/modules/aspects/provides/tty-autologin.nix @@ -0,0 +1,32 @@ +let + description = '' + Enables automatic tty login given a username. + + This battery must be included in a Host aspect. + + den.aspects.my-laptop.includes = [ (den._.tty-autologin "root") ]; + ''; + + # From https://discourse.nixos.org/t/autologin-for-single-tty/49427/2 + tty-autologin-module = + username: + { pkgs, config, ... }: + { + systemd.services."getty@tty1" = { + overrideStrategy = "asDropin"; + serviceConfig.ExecStart = [ + "" + "@${pkgs.util-linux}/sbin/agetty agetty --login-program ${config.services.getty.loginProgram} --autologin ${username} --noclear --keep-baud %I 115200,38400,9600 $TERM" + ]; + }; + }; + + __functor = _self: username: { + nixos = tty-autologin-module username; + }; +in +{ + den.provides.tty-autologin = { + inherit description __functor; + }; +} diff --git a/templates/default/README.md b/templates/default/README.md index 09f3561..edf3d18 100644 --- a/templates/default/README.md +++ b/templates/default/README.md @@ -10,10 +10,14 @@ Steps you can follow after cloning this template: nix flake update den ``` -- Run checks to test everything works. +- Edit [modules/hosts.nix](modules/hosts.nix) + +- Run the VM + +We recommend to use a VM develop cycle so you can play with the system before applying to your hardware. + +See [modules/vm.nix](modules/vm.nix) ```console -nix flake check +nix run .#vm ``` - -- Edit [modules/hosts.nix](modules/hosts.nix) diff --git a/templates/default/modules/vm.nix b/templates/default/modules/vm.nix index 1337f64..9db2fbd 100644 --- a/templates/default/modules/vm.nix +++ b/templates/default/modules/vm.nix @@ -1,16 +1,24 @@ # enables `nix run .#vm`. it is very useful to have a VM # you can edit your config and launch the VM to test stuff # instead of having to reboot each time. -{ inputs, ... }: +{ inputs, den, ... }: { + + # USER TODO: remove this tty-autologin used for the VM + den.aspects.igloo.includes = [ (den.provides.tty-autologin "tux") ]; + perSystem = { pkgs, ... }: { packages.vm = pkgs.writeShellApplication { name = "vm"; - text = '' - ${inputs.self.nixosConfigurations.igloo.config.system.build.vm}/bin/run-igloo-vm "$@" - ''; + text = + let + host = inputs.self.nixosConfigurations.igloo.config; + in + '' + ${host.system.build.vm}/bin/run-${host.networking.hostName}-vm "$@" + ''; }; }; }