2026-08-19 17:02:26 +01:00
|
|
|
#./apps/helium.nix
|
|
|
|
|
{ inputs, pkgs, lib, config, ... }:
|
2026-08-19 17:13:25 +01:00
|
|
|
let
|
|
|
|
|
upstream = inputs.helium-browser.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
|
|
|
|
|
|
|
|
|
# Helium is ungoogled-chromium, so there is no userChrome.css to render a
|
|
|
|
|
# template into the way zen does. Its one themeable surface is chromium's
|
|
|
|
|
# GTK mode: with extensions.theme.system_theme = 1 (ui::SystemTheme::kGtk)
|
|
|
|
|
# the frame, tabstrip and omnibox come from the GTK3 theme, and chromium
|
|
|
|
|
# subscribes to notify::gtk-theme-name — so the gsettings flip at the end of
|
|
|
|
|
# theme-apply recolours a RUNNING helium, the same as nemo. Nothing
|
|
|
|
|
# per-wallpaper has to be generated for it.
|
|
|
|
|
#
|
|
|
|
|
# browser.custom_chrome_frame = false is chromium's "Use system title bar and
|
|
|
|
|
# borders". Hyprland draws no titlebar, so this only drops chromium's own
|
|
|
|
|
# frame, rounded corners and shadow margin — the window fills its tile.
|
|
|
|
|
#
|
|
|
|
|
# Both are profile prefs and chromium rewrites Preferences from memory on
|
|
|
|
|
# exit; no enterprise policy covers either, so there is no declarative way
|
|
|
|
|
# in. Patch the file just before launch instead: helium is then either not
|
|
|
|
|
# running, and the write sticks, or already running with the prefs applied
|
|
|
|
|
# and this process only forwards its arguments to that instance.
|
|
|
|
|
seedPrefs = pkgs.writeShellScript "helium-seed-prefs" ''
|
|
|
|
|
prefs="$HOME/.config/net.imput.helium/Default/Preferences"
|
|
|
|
|
[ -f "$prefs" ] || exit 0
|
|
|
|
|
${pkgs.jq}/bin/jq -c '
|
|
|
|
|
.extensions.theme.system_theme = 1
|
|
|
|
|
| .browser.custom_chrome_frame = false
|
|
|
|
|
' "$prefs" > "$prefs.fred" && mv "$prefs.fred" "$prefs" || rm -f "$prefs.fred"
|
|
|
|
|
'';
|
|
|
|
|
in
|
2026-08-19 17:02:26 +01:00
|
|
|
{
|
|
|
|
|
config = lib.mkIf (lib.elem config.networking.hostName [ "FredOS-Gaming" "FredOS-Macbook" ]) {
|
|
|
|
|
environment.systemPackages = [
|
2026-08-19 17:13:25 +01:00
|
|
|
(pkgs.symlinkJoin {
|
|
|
|
|
name = "helium-themed";
|
|
|
|
|
paths = [ upstream ];
|
|
|
|
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
|
|
|
|
# `|| true` is load-bearing: wrapProgram's wrapper runs under `bash -e`,
|
|
|
|
|
# so an unreadable or half-written Preferences would stop the browser
|
|
|
|
|
# from starting at all rather than just skipping the theming.
|
|
|
|
|
postBuild = ''
|
|
|
|
|
wrapProgram $out/bin/helium --run '${seedPrefs} || true'
|
|
|
|
|
|
|
|
|
|
# A broken filter here is invisible until the browser quietly never
|
|
|
|
|
# follows the theme, so patch a stub profile at build time and assert.
|
|
|
|
|
(
|
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
|
mkdir -p "$HOME/.config/net.imput.helium/Default"
|
|
|
|
|
echo '{"browser":{"custom_chrome_frame":true}}' \
|
|
|
|
|
> "$HOME/.config/net.imput.helium/Default/Preferences"
|
|
|
|
|
${seedPrefs}
|
|
|
|
|
${pkgs.jq}/bin/jq -e '.extensions.theme.system_theme == 1
|
|
|
|
|
and .browser.custom_chrome_frame == false' \
|
|
|
|
|
"$HOME/.config/net.imput.helium/Default/Preferences" > /dev/null
|
|
|
|
|
)
|
|
|
|
|
'';
|
|
|
|
|
})
|
2026-08-19 17:02:26 +01:00
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
}
|