{ pkgs, lib, ... }: let # 1) Native‐messaging host: reads and clears the queued JSON command containerControllerHost = pkgs.writeScriptBin "firefox-containercontroller-host" '' #!/usr/bin/env bash CMD_FILE="$HOME/.cache/firefox-container-command.json" if [ -f "$CMD_FILE" ]; then cat "$CMD_FILE" rm "$CMD_FILE" else echo '{}' fi ''; # 2) CLI helper to enqueue a “hide” command hideContainer = pkgs.writeScriptBin "hide-container" '' #!/usr/bin/env bash if [ -z "$1" ]; then echo "Usage: $0 " >&2 exit 1 fi ID="$1" mkdir -p "$HOME/.cache" printf '{"userContextId": %s, "action": "hide"}' "$ID" \ > "$HOME/.cache/firefox-container-command.json" ''; # 3) CLI helper to enqueue a “show” command showContainer = pkgs.writeScriptBin "show-container" '' #!/usr/bin/env bash if [ -z "$1" ]; then echo "Usage: $0 " >&2 exit 1 fi ID="$1" mkdir -p "$HOME/.cache" printf '{"userContextId": %s, "action": "show"}' "$ID" \ > "$HOME/.cache/firefox-container-command.json" ''; in { # Install host + helpers environment.systemPackages = [ containerControllerHost hideContainer showContainer ]; # Register the native‐messaging host for our extension environment.etc."mozilla/native-messaging-hosts/com.firefox.containercontroller.json".text = builtins.toJSON { name = "com.firefox.containercontroller"; description = "Native messaging host for Container Controller"; path = containerControllerHost; type = "stdio"; allowed_extensions = [ "containercontroller@cloonar.com" ]; }; }