diff --git a/Justfile b/Justfile index 08340b6..bb0caaf 100644 --- a/Justfile +++ b/Justfile @@ -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 @@ -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 @@ -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) @@ -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 diff --git a/README.md b/README.md index 0a03eed..53f420d 100644 --- a/README.md +++ b/README.md @@ -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 = @@ -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"; + } + ) ]; }; }; @@ -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 }; } ``` diff --git a/examples/chrome.nix b/examples/chrome.nix new file mode 100644 index 0000000..b13ba68 --- /dev/null +++ b/examples/chrome.nix @@ -0,0 +1,5 @@ +{ ... }: +{ + superbird.gui.kiosk = "https://github.com/JoeyEamigh/nixos-superbird"; + system.stateVersion = "24.11"; +} diff --git a/examples/cog.nix b/examples/cog.nix deleted file mode 100644 index aa0f600..0000000 --- a/examples/cog.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ pkgs, ... }: -{ - superbird.gui.app = "${pkgs.cog}/bin/cog https://github.com/JoeyEamigh/nixos-superbird"; - system.stateVersion = "24.11"; -} diff --git a/examples/experiments/Justfile b/examples/experiments/Justfile index 9709c2e..fc84fa6 100644 --- a/examples/experiments/Justfile +++ b/examples/experiments/Justfile @@ -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)" @@ -32,4 +33,4 @@ zip-installer: zip -r nixos-superbird-installer.zip . push: - nix run github:serokell/deploy-rs \ No newline at end of file + nix flake update && nix run github:serokell/deploy-rs \ No newline at end of file diff --git a/examples/experiments/flake.lock b/examples/experiments/flake.lock index b6429c9..7e53240 100644 --- a/examples/experiments/flake.lock +++ b/examples/experiments/flake.lock @@ -42,7 +42,7 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-Mvlu2XenmY6Khk2VruZjLAIU67O2uUMOxAmair50S9I=", + "narHash": "sha256-ul8xr+Rme4gvoizL9hwzWMvTJ7c/D73BuaQmxRdi64c=", "path": "../../", "type": "path" }, @@ -83,27 +83,14 @@ "type": "github" } }, - "nixpkgs_3": { - "locked": { - "lastModified": 1731139594, - "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "deploy-rs": "deploy-rs", "nixos-superbird": "nixos-superbird", - "nixpkgs": "nixpkgs_3" + "nixpkgs": [ + "nixos-superbird", + "nixpkgs" + ] } }, "systems": { diff --git a/examples/experiments/flake.nix b/examples/experiments/flake.nix index 9fcb73b..b2aa66c 100644 --- a/examples/experiments/flake.nix +++ b/examples/experiments/flake.nix @@ -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"; }; @@ -25,7 +25,6 @@ ( { pkgs, ... }: { - # superbird.gui.app = "${pkgs.firefox}/bin/firefox"; superbird.gui.app = '' ${pkgs.ungoogled-chromium}/bin/chromium \ --ozone-platform-hint=auto \ @@ -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"; } ) diff --git a/examples/flake/flake.nix b/examples/flake/flake.nix index 957e6ee..928f06e 100644 --- a/examples/flake/flake.nix +++ b/examples/flake/flake.nix @@ -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"; }; @@ -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"; } ) diff --git a/flake.nix b/flake.nix index 7fc0e27..9fbc0d9 100644 --- a/flake.nix +++ b/flake.nix @@ -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 ]; }; @@ -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; }; diff --git a/modules/default.nix b/modules/default.nix index 4521c01..336d5d2 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -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 = { diff --git a/modules/fs/boot.nix b/modules/fs/boot.nix index 779f042..6d3ee48 100644 --- a/modules/fs/boot.nix +++ b/modules/fs/boot.nix @@ -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 + '''' + } ''; }; } diff --git a/modules/gui/default.nix b/modules/gui/default.nix index 6117874..a06bb39 100644 --- a/modules/gui/default.nix +++ b/modules/gui/default.nix @@ -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 @@ -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."; } ]; }; diff --git a/modules/net/bluetooth.nix b/modules/net/bluetooth.nix index 146acb0..c8768a1 100644 --- a/modules/net/bluetooth.nix +++ b/modules/net/bluetooth.nix @@ -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; }; }; }; diff --git a/template b/template index 72eec74..dc724bd 160000 --- a/template +++ b/template @@ -1 +1 @@ -Subproject commit 72eec74ef790ec6ac1a182bc7972a12822ec37c1 +Subproject commit dc724bd03179b728ca622474bc7135fa3c528eb7