diff --git a/README.md b/README.md index 949e539..2ed7641 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,16 @@ If you invoke the build from `x86_64-linux`, it'll cross-compile the sdcard image. If you build on an `aarch64-linux` box, it'll natively compile. Both works. +### VM Test +For a smaller feedback loop, it's possible to build a script running the +software stack in a local qemu (KVM). It might have another virtual screen +resolution, and obviously doesn't test the hardware bits. + +To run it, invoke: +``` +$(nix-build nix -A vm)/bin/run-fossbeamer-vm +``` + -- [wip.bar]: https://wip.bar [Nix]: https://nixos.org diff --git a/nix/configuration.nix b/nix/configuration.nix index 3371427..9c27933 100644 --- a/nix/configuration.nix +++ b/nix/configuration.nix @@ -7,6 +7,15 @@ }: { imports = [ (modulesPath + "/installer/sd-card/sd-image-aarch64.nix") + ./profiles/kiosk.nix + ./profiles/networking.nix + ./profiles/ssh-server.nix + ]; + # HACK: sd-image-aarch64.nix sets console=ttyS0,115200n8 (and some others), + # which breaks the device-tree provided serial config. + boot.kernelParams = lib.mkForce [ + "systemd.log_target=console" + "systemd.journald.forward_to_console=1" ]; # configure journald to not logs to disk @@ -20,12 +29,6 @@ lib.mkForce [ "vfat" ]; - # HACK: sd-image-aarch64.nix sets console=ttyS0,115200n8 (and some others), - # which breaks the device-tree provided serial config. - boot.kernelParams = lib.mkForce [ - "systemd.log_target=console" - "systemd.journald.forward_to_console=1" - ]; # Switch to systemd-initrd, which is the future (tm). # Also it has proven to be a bit more permissive with some boards where the @@ -34,72 +37,10 @@ nix.settings.max-jobs = 8; - # Configure networking - networking.hostName = "fossbeamer"; - networking.useDHCP = true; - networking.useNetworkd = true; - networking.wireless.iwd.enable = true; - networking.networkmanager.enable = false; - services.resolved.enable = true; - services.resolved.dnssec = "false"; - networking.nftables.enable = true; - - # Configure ssh - services.openssh = { - enable = true; - settings.PasswordAuthentication = false; - openFirewall = true; - }; - users.users.root.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTVTXOutUZZjXLB0lUSgeKcSY/8mxKkC0ingGK1whD2 flokli" - "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIA34k0FVKDGNdJ8uk0Ytbvh6J8v+H86F4t6BXAIoW/7xAAAABHNzaDo= flokli 20240704 14321691" - "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIP7rdJ1klzK8nx74QQA8jYdFwznM1klLS0C7M5lHiu+IAAAABHNzaDo= flokli 20240617 28772765" - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC02nCZ1XKOr7lalsEP4Cy5pfNE34RUOpdvS+UB4ozdpGTk+KybGhh1STs9HcJAmNcOitJ4JRlPtQTQVQK5A8XDnt9qxF5W3umIAkAibe9UIRMJK36/K0BXTtvErLmTUxMuSx/NxRJyTV4/3eJC+Lfzg7hy/M6HoZ41w/7L7WZKotElYgnCZcXMxBPVCX1HXGakcr+SHVZGDAgvQ+QL2kYhRyhAqKWp6U3GJ402selzE1OHOeBylqZP8kRUyt+MjehhLG6Lc3uuc5wiz9UxNc5x7JJXGI2ynta10OyHFOzgKtUzqedyb/5sz53nwdEe4gj/Uyrl84QCpYScLqGPGUOMwHTptBcocucvweOgCFXGwaCid6eAo5FhRLS6JOiCoh0jVvgvFjB+hPAX4cKprlXmpNsJcmn6PvCnIa0IylyT8Ki932KqtSzyEvp+U9Olci+fF0+EjghelSFbY6cEBNdKi/ZYiACtyOnA8hL4oApe7em4nFngkQPPbAh2DpUFxp8= Freya" - ]; - - programs.mosh.enable = true; - - - # Create a kiosk user - users.users.kiosk = { - isNormalUser = true; - uid = 1000; - }; - - # And configure cage to show fossbeamer on it. - services.cage = { - enable = true; - user = "kiosk"; - program = pkgs.writers.writeBash "run-cage-program" '' - ${pkgs.wlr-randr}/bin/wlr-randr --output HDMI-A-1 --transform 180 --scale 2 - ${pkgs.fossbeamer}/bin/fossbeamer --default-config=${../default-config.json} https://wip.bar - ''; - environment = { - GST_PLUGIN_SYSTEM_PATH_1_0 = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" (with pkgs.gst_all_1;[ - gstreamer - gst-plugins-base - gst-plugins-good - gst-plugins-bad - gst-libav - ]); - GIO_MODULE_DIR = "${pkgs.glib-networking}/lib/gio/modules/"; - LIBGL_DEBUG = "verbose"; - RUST_LOG = "debug"; - }; - extraArguments = [ - "-d" # don't draw client decorations when possible - ]; - }; - systemd.services."cage-tty1".restartIfChanged = lib.mkForce true; - environment.systemPackages = [ - pkgs.htop pkgs.kmsxx # kmsprint pkgs.i2c-tools ]; - documentation.enable = false; # Reduces closure size and build time. - - users.users."root".initialPassword = ""; system.stateVersion = "24.05"; } diff --git a/nix/default.nix b/nix/default.nix index 25562a0..f50bbdd 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -34,6 +34,7 @@ let machine-generic = (pkgsAArch64.nixos ./configuration.nix); machine-cm3 = (pkgsAArch64.nixos ./configuration-cm3.nix); + vm = (pkgs.nixos ./configuration.nix).vm; in rec { @@ -58,7 +59,7 @@ rec { ''; }; - inherit machine-generic machine-cm3; + inherit machine-generic machine-cm3 vm; env = pkgs.buildEnv { name = "dev-env"; diff --git a/nix/profiles/kiosk.nix b/nix/profiles/kiosk.nix new file mode 100644 index 0000000..fd1213e --- /dev/null +++ b/nix/profiles/kiosk.nix @@ -0,0 +1,40 @@ +{ lib, pkgs, ... }: { + # Create a kiosk user + users.users.kiosk = { + isNormalUser = true; + uid = 1000; + packages = [ pkgs.dconf ]; + }; + + # And configure cage to show fossbeamer on it. + services.cage = { + enable = true; + user = "kiosk"; + program = pkgs.writers.writeBash "run-cage-program" '' + ${pkgs.wlr-randr}/bin/wlr-randr --output HDMI-A-1 --transform 180 --scale 2 + ${pkgs.fossbeamer}/bin/fossbeamer --default-config=${../../default-config.json} https://wip.bar + ''; + environment = { + GST_PLUGIN_SYSTEM_PATH_1_0 = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" (with pkgs.gst_all_1;[ + gstreamer + gst-plugins-base + gst-plugins-good + gst-plugins-bad + gst-libav + ]); + GIO_MODULE_DIR = "${pkgs.glib-networking}/lib/gio/modules/"; + LIBGL_DEBUG = "verbose"; + RUST_LOG = "debug"; + }; + extraArguments = [ + "-d" # don't draw client decorations when possible + ]; + }; + systemd.services."cage-tty1".restartIfChanged = lib.mkForce true; + + environment.systemPackages = [ + pkgs.htop + ]; + + documentation.enable = false; # Reduces closure size and build time. +} diff --git a/nix/profiles/networking.nix b/nix/profiles/networking.nix new file mode 100644 index 0000000..3a43626 --- /dev/null +++ b/nix/profiles/networking.nix @@ -0,0 +1,12 @@ +{ ... }: { + # Configure networking + networking.hostName = "fossbeamer"; + networking.useDHCP = true; + networking.useNetworkd = true; + networking.wireless.iwd.enable = true; + networking.networkmanager.enable = false; + services.resolved.enable = true; + services.resolved.dnssec = "false"; + networking.nftables.enable = true; +} + diff --git a/nix/profiles/ssh-server.nix b/nix/profiles/ssh-server.nix new file mode 100644 index 0000000..9e663d8 --- /dev/null +++ b/nix/profiles/ssh-server.nix @@ -0,0 +1,20 @@ +{ ... }: { + + # Configure ssh + services.openssh = { + enable = true; + settings.PasswordAuthentication = false; + openFirewall = true; + }; + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTVTXOutUZZjXLB0lUSgeKcSY/8mxKkC0ingGK1whD2 flokli" + "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIA34k0FVKDGNdJ8uk0Ytbvh6J8v+H86F4t6BXAIoW/7xAAAABHNzaDo= flokli 20240704 14321691" + "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIP7rdJ1klzK8nx74QQA8jYdFwznM1klLS0C7M5lHiu+IAAAABHNzaDo= flokli 20240617 28772765" + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC02nCZ1XKOr7lalsEP4Cy5pfNE34RUOpdvS+UB4ozdpGTk+KybGhh1STs9HcJAmNcOitJ4JRlPtQTQVQK5A8XDnt9qxF5W3umIAkAibe9UIRMJK36/K0BXTtvErLmTUxMuSx/NxRJyTV4/3eJC+Lfzg7hy/M6HoZ41w/7L7WZKotElYgnCZcXMxBPVCX1HXGakcr+SHVZGDAgvQ+QL2kYhRyhAqKWp6U3GJ402selzE1OHOeBylqZP8kRUyt+MjehhLG6Lc3uuc5wiz9UxNc5x7JJXGI2ynta10OyHFOzgKtUzqedyb/5sz53nwdEe4gj/Uyrl84QCpYScLqGPGUOMwHTptBcocucvweOgCFXGwaCid6eAo5FhRLS6JOiCoh0jVvgvFjB+hPAX4cKprlXmpNsJcmn6PvCnIa0IylyT8Ki932KqtSzyEvp+U9Olci+fF0+EjghelSFbY6cEBNdKi/ZYiACtyOnA8hL4oApe7em4nFngkQPPbAh2DpUFxp8= Freya" + ]; + + programs.mosh.enable = true; + + # Allow logging in via serial without password. + users.users."root".initialPassword = ""; +}