Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run in VM #31

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
77 changes: 9 additions & 68 deletions nix/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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";
}
3 changes: 2 additions & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -58,7 +59,7 @@ rec {
'';
};

inherit machine-generic machine-cm3;
inherit machine-generic machine-cm3 vm;

env = pkgs.buildEnv {
name = "dev-env";
Expand Down
40 changes: 40 additions & 0 deletions nix/profiles/kiosk.nix
Original file line number Diff line number Diff line change
@@ -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.
}
12 changes: 12 additions & 0 deletions nix/profiles/networking.nix
Original file line number Diff line number Diff line change
@@ -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;
}

20 changes: 20 additions & 0 deletions nix/profiles/ssh-server.nix
Original file line number Diff line number Diff line change
@@ -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 = "";
}
Loading