Skip to content

Commit

Permalink
add new chrome kiosk mode and fix bluetooth for good
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyEamigh committed Nov 16, 2024
1 parent 227c63d commit e44a618
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 72 deletions.
14 changes: 7 additions & 7 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
build config="cog-example":
build config="chrome-example":
nix build '.#nixosConfigurations.{{config}}.config.system.build.toplevel' -j$(nproc) --show-trace

initrd config="cog-example":
initrd config="chrome-example":
nix build '.#nixosConfigurations.{{config}}.config.system.build.initrd' -j$(nproc) --show-trace
echo "initrd is $(stat -Lc%s -- result/initrd | numfmt --to=iec)"

fs config="cog-example":
fs config="chrome-example":
nix build '.#nixosConfigurations.{{config}}.config.system.build.btrfs' -j$(nproc) --show-trace
echo "rootfs is $(stat -Lc%s -- result | numfmt --to=iec)"

installer config="cog-example":
installer config="chrome-example":
#!/usr/bin/env bash
set -euo pipefail
Expand All @@ -28,7 +28,7 @@ installer config="cog-example":
echo "rootfs (compact) is $(stat -Lc%s -- ./linux/rootfs.img | numfmt --to=iec)"


run-installer config="cog-example":
run-installer config="chrome-example":
just installer {{config}}
cd out && ./install.sh

Expand All @@ -41,7 +41,7 @@ zip-installer:

cache:
attic push superbird \
$(nix build .#nixosConfigurations.cog-example.config.system.build.toplevel --no-link --print-out-paths) \
$(nix build .#nixosConfigurations.chrome-example.config.system.build.toplevel --no-link --print-out-paths) \
$(nix build .#nixosConfigurations.headless-example.config.system.build.toplevel --no-link --print-out-paths) \
$(nix build .#nixosConfigurations.qemu-example.config.system.build.toplevel --no-link --print-out-paths)

Expand All @@ -55,7 +55,7 @@ docker:
run-docker-example:
docker run --privileged --rm -it -v ./examples/flake/:/workdir ghcr.io/joeyeamigh/nixos-superbird/builder:latest

inspect-image config="cog-example":
inspect-image config="chrome-example":
#!/usr/bin/env bash
set -euo pipefail
Expand Down
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ The most basic form of using `nixos-superbird` is a single `flake.nix` file.
{
description = "NixOS Superbird configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-superbird.url = "github:joeyeamigh/nixos-superbird/main";
nixpkgs.follows = "nixos-superbird/nixpkgs"; # if you need newer versions of apps you can override or PR this repo
};
outputs =
Expand All @@ -56,10 +56,13 @@ The most basic form of using `nixos-superbird` is a single `flake.nix` file.
superbird = nixosSystem {
modules = [
nixos-superbird.nixosModules.superbird
{
superbird.gui.app = "${pkgs.cog}/bin/cog https://github.com/JoeyEamigh/nixos-superbird";
system.stateVersion = "24.11";
}
(
{ ... }:
{
superbird.gui.kiosk = "https://github.com/JoeyEamigh/nixos-superbird";
system.stateVersion = "24.11";
}
)
];
};
};
Expand All @@ -85,21 +88,23 @@ To make this flake as easy to use as possible, not many things are directly conf
{
superbird = {
bluetooth = {
enable = true;
name = "Superbird";
enable = true; # whether bluetooth is enabled
name = "Superbird"; # name of the device as it broadcasts over bluetooth
};
gui = {
enable = true;
app = null;
enable = true; # whether cage (kiosk-mode wayland compositor) is enabled
app = null; # full path to an app to run - i.e. "${pkgs.cog}/bin/cog"
kiosk = null; # url to send a chromium kiosk (with basic gpu acceleration) to - i.e. "https://github.com/JoeyEamigh/nixos-superbird"
};
# you cannot have both app and kiosk set at the same time - if you need more control use app or disable gui and diy
swap = {
enable = true;
size = 512;
enable = true; # whether to create a swapfile
size = 512; # size of said swapfile in MiB
};
qemu = false;
qemu = false; # whether you are building an image to run IN qemu
};
}
```
Expand Down
5 changes: 5 additions & 0 deletions examples/chrome.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ ... }:
{
superbird.gui.kiosk = "https://github.com/JoeyEamigh/nixos-superbird";
system.stateVersion = "24.11";
}
5 changes: 0 additions & 5 deletions examples/cog.nix

This file was deleted.

5 changes: 3 additions & 2 deletions examples/experiments/Justfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
build:
nix build '.#nixosConfigurations.superbird.config.system.build.installer' -j"$(nproc)" --show-trace
nix flake update && nix build '.#nixosConfigurations.superbird.config.system.build.installer' -j"$(nproc)" --show-trace

installer:
#!/usr/bin/env bash
set -euo pipefail
nix flake update
nix build '.#nixosConfigurations.superbird.config.system.build.installer' -j$(nproc) --show-trace
echo "kernel is $(stat -Lc%s -- result/linux/kernel | numfmt --to=iec)"
echo "initrd is $(stat -Lc%s -- result/linux/initrd.img | numfmt --to=iec)"
Expand Down Expand Up @@ -32,4 +33,4 @@ zip-installer:
zip -r nixos-superbird-installer.zip .

push:
nix run github:serokell/deploy-rs
nix flake update && nix run github:serokell/deploy-rs
23 changes: 5 additions & 18 deletions examples/experiments/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 3 additions & 14 deletions examples/experiments/flake.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
description = "NixOS Superbird configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-superbird.url = "path:../../";
nixpkgs.follows = "nixos-superbird/nixpkgs";
deploy-rs.url = "github:serokell/deploy-rs";
};

Expand All @@ -25,7 +25,6 @@
(
{ pkgs, ... }:
{
# superbird.gui.app = "${pkgs.firefox}/bin/firefox";
superbird.gui.app = ''
${pkgs.ungoogled-chromium}/bin/chromium \
--ozone-platform-hint=auto \
Expand Down Expand Up @@ -58,20 +57,10 @@
--touch-events=enabled \
--ignore-certificate-errors \
--kiosk \
--app=https://motherfuckingwebsite.com/
--app=https://github.com/JoeyEamigh/nixos-superbird
'';
# superbird.gui.app = "${pkgs.cog}/bin/cog https://github.com/JoeyEamigh/nixos-superbird";
superbird.packages.useful = true;

# environment.systemPackages = [
# # useful
# pkgs.btop
# pkgs.neovim

# # fun
# pkgs.neofetch
# ];

superbird.packages.useful = true;
system.stateVersion = "24.11";
}
)
Expand Down
7 changes: 3 additions & 4 deletions examples/flake/flake.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
description = "NixOS Superbird configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

nixos-superbird.url = "path:../../";
# nixos-superbird.url = "github:joeyeamigh/nixos-superbird/main";

nixpkgs.follows = "nixos-superbird/nixpkgs";
deploy-rs.url = "github:serokell/deploy-rs";
};

Expand All @@ -26,9 +25,9 @@
modules = [
nixos-superbird.nixosModules.superbird
(
{ pkgs, ... }:
{ ... }:
{
superbird.gui.app = "${pkgs.cog}/bin/cog https://github.com/JoeyEamigh/nixos-superbird";
superbird.gui.kiosk = "https://github.com/JoeyEamigh/nixos-superbird";
system.stateVersion = "24.11";
}
)
Expand Down
6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
nixosModules.superbird = import ./modules;

nixosConfigurations = {
cog-example = nixosSystem {
chrome-example = nixosSystem {
system = "aarch64-linux";
modules = [
self.nixosModules.superbird
./examples/cog.nix
./examples/chrome.nix
];
};

Expand Down Expand Up @@ -66,7 +66,7 @@

checks.aarch64-linux = self.packages.aarch64-linux;
packages.aarch64-linux = {
example-cog = self.nixosConfigurations.cog-example.config.system.build.installer;
example-chrome = self.nixosConfigurations.chrome-example.config.system.build.installer;
example-doom = self.nixosConfigurations.doom-example.config.system.build.installer;
example-headless = self.nixosConfigurations.headless-example.config.system.build.installer;
};
Expand Down
11 changes: 9 additions & 2 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@

app = mkOption {
default = null;
type = types.str;
example = "\${pkgs.cog}/bin/cog https://example.com";
type = types.nullOr types.str;
example = "\${pkgs.cog}/bin/cog https://github.com/JoeyEamigh/nixos-superbird";
description = "path to the application to run in cage";
};

kiosk = mkOption {
default = null;
type = types.nullOr types.str;
example = "https://github.com/JoeyEamigh/nixos-superbird";
description = "website to place into chromium kiosk mode";
};
};

swap = {
Expand Down
17 changes: 17 additions & 0 deletions modules/fs/boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ in
echo "boot >>> done!" > /dev/kmsg
fi
${
if cfg.bluetooth.enable then
''
if [ ! -f /lib/firmware/brcm/BCM.hcd ] || [ ! -f /lib/firmware/brcm/BCM20703A2.hcd ]; then
echo "firmware >>> bluetooth firmware not detected - setting up" > /dev/kmsg
mkdir -p /lib/firmware/brcm
cp ${../net/firmware/brcm/BCM.hcd} /lib/firmware/brcm/BCM.hcd
cp ${../net/firmware/brcm/BCM20703A2.hcd} /lib/firmware/brcm/BCM20703A2.hcd
echo "firmware >>> bluetooth firmware set up!" > /dev/kmsg
fi
''
else
''''
}
'';
};
}
46 changes: 42 additions & 4 deletions modules/gui/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,49 @@
let
cfg = config.superbird;

chromeKiosk = ''
${pkgs.ungoogled-chromium}/bin/chromium \
--ozone-platform-hint=auto \
--ozone-platform=wayland \
--no-sandbox \
--autoplay-policy=no-user-gesture-required \
--use-fake-ui-for-media-stream \
--use-fake-device-for-media-stream \
--disable-sync \
--remote-debugging-port=9222 \
--force-device-scale-factor=1.0 \
--pull-to-refresh=0 \
--disable-smooth-scrolling \
--disable-login-animations \
--disable-modal-animations \
--noerrdialogs \
--no-first-run \
--disable-infobars \
--fast \
--fast-start \
--disable-pinch \
--disable-translate \
--overscroll-history-navigation=0 \
--hide-scrollbars \
--disable-overlay-scrollbar \
--disable-features=OverlayScrollbar \
--disable-features=TranslateUI \
--disable-features=TouchpadOverscrollHistoryNavigation,OverscrollHistoryNavigation \
--password-store=basic \
--touch-events=enabled \
--ignore-certificate-errors \
--kiosk \
--app=${cfg.gui.kiosk}
'';

app = "${pkgs.writeScriptBin "start-cage-app" ''
#!/usr/bin/env bash
wlr-randr --output DSI-1 --transform 270
exec ${cfg.gui.app}
exec ${if cfg.gui.kiosk != null then chromeKiosk else cfg.gui.app}
''}/bin/start-cage-app";
in
{

config = lib.mkIf cfg.gui.enable {
environment.systemPackages = with pkgs; [
wlr-randr
Expand All @@ -41,8 +75,12 @@ in

assertions = [
{
assertion = cfg.gui.app != null;
message = "You must include an app when GUI is enabled.";
assertion = cfg.gui.app != null || cfg.gui.kiosk != null;
message = "You must include an app or a kiosk site when GUI is enabled.";
}
{
assertion = cfg.gui.app == null || cfg.gui.kiosk == null;
message = "You cannot use both an app and a kiosk site.";
}
];
};
Expand Down
3 changes: 3 additions & 0 deletions modules/net/bluetooth.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ let
in
{
config = lib.mkIf cfg.bluetooth.enable {
environment.etc."machine-info".text = "PRETTY_HOSTNAME=${cfg.bluetooth.name}";

hardware.bluetooth = {
enable = true;
powerOnBoot = false;
settings = {
General = {
Name = cfg.bluetooth.name;
FastConnectable = true;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion template
Submodule template updated 2 files
+2 −0 README.md
+17 −3 flake.nix

0 comments on commit e44a618

Please sign in to comment.