mirror of
https://github.com/elwrcl/heliux.git
synced 2026-11-01 06:38:03 +03:00
first commit
This commit is contained in:
15 files changed
+1017
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{ self, ... }:
|
||||
{
|
||||
flake = {
|
||||
homeModules.helium = import ./home-manager.nix { inherit self; };
|
||||
nixosModules.helium = import ./nixos.nix;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
{ self }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.helium;
|
||||
|
||||
fetchExtension =
|
||||
{ id, hash }:
|
||||
let
|
||||
os = if pkgs.stdenv.isDarwin then "mac" else "linux";
|
||||
arch = if pkgs.stdenv.isAarch64 then "arm64" else "x64";
|
||||
os_arch = if pkgs.stdenv.isDarwin then "arm64" else "x86_64";
|
||||
in
|
||||
pkgs.fetchurl {
|
||||
name = "${id}.crx";
|
||||
url = "https://clients2.google.com/service/update2/crx?response=redirect&os=${os}&arch=${arch}&os_arch=${os_arch}&nacl_arch=x86-64&prod=chromiumcrx&prodchannel=stable&prodversion=120.0.0.0&acceptformat=crx3&x=id%3D${id}%26installsource%3Dondemand%26uc";
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
unpackExtension =
|
||||
{ id, hash }:
|
||||
pkgs.runCommand "helium-ext-${id}"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.unzip ];
|
||||
src = fetchExtension { inherit id hash; };
|
||||
}
|
||||
''
|
||||
mkdir -p $out
|
||||
unzip -q $src -d $out || true
|
||||
|
||||
# Remove the system-reserved metadata folder that causes the load error
|
||||
rm -rf $out/_metadata
|
||||
'';
|
||||
|
||||
resolvedExtensions = map (spec: {
|
||||
inherit (spec) id;
|
||||
unpacked = unpackExtension { inherit (spec) id hash; };
|
||||
}) cfg.extensions;
|
||||
|
||||
# We add the IDs to the Allowlist policy so Helium doesn't disable them for being "unverified"
|
||||
policyAttrs = {
|
||||
ExtensionInstallAllowlist = map (ext: ext.id) cfg.extensions;
|
||||
}
|
||||
// cfg.extraPolicies;
|
||||
|
||||
loadExtensionFlag =
|
||||
if resolvedExtensions != [ ] then
|
||||
[ "--load-extension=${lib.concatStringsSep "," (map (ext: "${ext.unpacked}") resolvedExtensions)}" ]
|
||||
else
|
||||
[ ];
|
||||
|
||||
heliumWithFlags = pkgs.symlinkJoin {
|
||||
name = "helium-configured";
|
||||
paths = [ cfg.package ];
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/helium \
|
||||
${lib.concatMapStringsSep " \\\n " (f: "--add-flags ${lib.escapeShellArg f}") (
|
||||
[
|
||||
"--disable-component-update"
|
||||
"--allow-file-access-from-files"
|
||||
]
|
||||
++ loadExtensionFlag
|
||||
++ lib.optionals pkgs.stdenv.isLinux [
|
||||
"--ozone-platform-hint=auto"
|
||||
"--enable-features=WaylandWindowDecorations,NativeNotifications,SystemNotifications"
|
||||
]
|
||||
++ cfg.extraFlags
|
||||
)}
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
options.programs.helium = {
|
||||
enable = lib.mkEnableOption "Helium browser";
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.${pkgs.stdenv.hostPlatform.system}.helium;
|
||||
};
|
||||
extensions = lib.mkOption {
|
||||
type = lib.types.listOf (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
id = lib.mkOption { type = lib.types.str; };
|
||||
hash = lib.mkOption { type = lib.types.str; };
|
||||
};
|
||||
}
|
||||
);
|
||||
default = [ ];
|
||||
};
|
||||
extraFlags = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
};
|
||||
extraPolicies = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.anything;
|
||||
default = { };
|
||||
};
|
||||
defaultBrowser = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
|
||||
finalPolicyJson = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
internal = true;
|
||||
default = builtins.toJSON policyAttrs;
|
||||
};
|
||||
|
||||
preferences = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.anything;
|
||||
default = { };
|
||||
description = ''
|
||||
Chromium preferences to set in the Default profile.
|
||||
These are merged into ~/.config/net.imput.helium/Default/Preferences.
|
||||
Type: 'helium://prefs-internals/' to search for the json keys and values
|
||||
'';
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
"browser"."show_home_button" = true;
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home = {
|
||||
packages = [
|
||||
heliumWithFlags
|
||||
pkgs.jq
|
||||
pkgs.coreutils
|
||||
];
|
||||
|
||||
activation = lib.mkIf (cfg.preferences != { }) {
|
||||
heliumPreferences = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
prefs_dir="$HOME/.config/net.imput.helium/Default"
|
||||
prefs_file="$prefs_dir/Preferences"
|
||||
nix_prefs='${builtins.toJSON cfg.preferences}'
|
||||
|
||||
run mkdir -p "$prefs_dir"
|
||||
|
||||
if [ -f "$prefs_file" ]; then
|
||||
merged=$(${pkgs.jq}/bin/jq -s '.[0] * .[1]' "$prefs_file" - <<< "$nix_prefs")
|
||||
if [ -n "$merged" ]; then
|
||||
printf '%s\n' "$merged" > "$prefs_file"
|
||||
fi
|
||||
else
|
||||
printf '%s\n' "$nix_prefs" > "$prefs_file"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
xdg.mimeApps = lib.mkIf cfg.defaultBrowser {
|
||||
enable = true;
|
||||
defaultApplications = {
|
||||
"text/html" = "helium.desktop";
|
||||
"x-scheme-handler/http" = "helium.desktop";
|
||||
"x-scheme-handler/https" = "helium.desktop";
|
||||
};
|
||||
};
|
||||
xdg.desktopEntries.helium = lib.mkIf cfg.defaultBrowser {
|
||||
name = "Helium";
|
||||
exec = "${heliumWithFlags}/bin/helium %U";
|
||||
icon = "helium";
|
||||
terminal = false;
|
||||
categories = [
|
||||
"Network"
|
||||
"WebBrowser"
|
||||
];
|
||||
mimeType = [
|
||||
"text/html"
|
||||
"x-scheme-handler/http"
|
||||
"x-scheme-handler/https"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
# finding all home-manager users that have helium enabled
|
||||
enabledUsers = lib.filterAttrs (_: user: user.programs.helium.enable or false) (
|
||||
config.home-manager.users or { }
|
||||
);
|
||||
|
||||
# generate etc files per user to support multi-user systems
|
||||
policyFiles = lib.mapAttrs' (
|
||||
name: user:
|
||||
lib.nameValuePair "chromium/policies/managed/helium-${name}.json" {
|
||||
text = user.programs.helium.finalPolicyJson;
|
||||
mode = "0644";
|
||||
}
|
||||
) enabledUsers;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf (enabledUsers != { }) {
|
||||
environment.etc = policyFiles;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
perSystem =
|
||||
{ system, ... }:
|
||||
{
|
||||
_module.args.pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
{ ... }:
|
||||
{
|
||||
perSystem =
|
||||
{ pkgs, system, ... }:
|
||||
let
|
||||
sources = import ./sources.nix;
|
||||
|
||||
version = if pkgs.stdenv.isDarwin then sources.versions.darwin else sources.versions.linux;
|
||||
|
||||
src = pkgs.fetchurl (
|
||||
(sources.srcs.${system} or (throw "Unsupported system: ${system}")) sources.versions
|
||||
);
|
||||
|
||||
helium = pkgs.callPackage ./package.nix { inherit version src; };
|
||||
|
||||
# same build with the proprietary Widevine CDM bundled, so DRM-protected
|
||||
# streaming works out of the box. Kept as a separate output rather than a
|
||||
# default so the plain `helium` package stays free-software only.
|
||||
helium-widevine = helium.override { enableWidevine = true; };
|
||||
|
||||
app = {
|
||||
type = "app";
|
||||
program = "${helium}/bin/helium";
|
||||
meta = {
|
||||
inherit (helium.meta)
|
||||
description
|
||||
homepage
|
||||
license
|
||||
platforms
|
||||
;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
default = helium;
|
||||
inherit helium;
|
||||
}
|
||||
// pkgs.lib.optionalAttrs pkgs.stdenv.isLinux { inherit helium-widevine; };
|
||||
|
||||
apps = {
|
||||
default = app;
|
||||
helium = app;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [
|
||||
helium
|
||||
pkgs.nix-update
|
||||
];
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-tree;
|
||||
|
||||
checks = {
|
||||
build = helium;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
makeWrapper,
|
||||
autoPatchelfHook,
|
||||
copyDesktopItems,
|
||||
makeDesktopItem,
|
||||
_7zz,
|
||||
# runtime/build deps
|
||||
alsa-lib,
|
||||
at-spi2-atk,
|
||||
at-spi2-core,
|
||||
atk,
|
||||
cairo,
|
||||
cups,
|
||||
dbus,
|
||||
expat,
|
||||
fontconfig,
|
||||
freetype,
|
||||
gdk-pixbuf,
|
||||
glib,
|
||||
gtk3,
|
||||
kdePackages,
|
||||
libdrm,
|
||||
libgbm,
|
||||
libGL,
|
||||
libpulseaudio,
|
||||
libva,
|
||||
libvdpau,
|
||||
libx11,
|
||||
libxcb,
|
||||
libxcomposite,
|
||||
libxcursor,
|
||||
libxdamage,
|
||||
libxext,
|
||||
libxfixes,
|
||||
libxi,
|
||||
libxkbcommon,
|
||||
libxrandr,
|
||||
libxrender,
|
||||
libxscrnsaver,
|
||||
libxshmfence,
|
||||
libxtst,
|
||||
libuuid,
|
||||
mesa,
|
||||
nspr,
|
||||
nss,
|
||||
pango,
|
||||
pipewire,
|
||||
systemd,
|
||||
vulkan-loader,
|
||||
wayland,
|
||||
widevine-cdm,
|
||||
# bundle the "proprietary" Widevine CDM so DRM streaming ( Netflix, HBO, ..)
|
||||
# Requires `nixpkgs.config.allowUnfree = true` in the consuming config.
|
||||
enableWidevine ? false,
|
||||
version,
|
||||
src,
|
||||
}:
|
||||
let
|
||||
# Chromium flags applied on all platforms to disable update machinery.
|
||||
commonFlags = [
|
||||
"--disable-component-update"
|
||||
"--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT'"
|
||||
"--check-for-update-interval=0"
|
||||
"--no-first-run"
|
||||
"--enable-features=StorageAccessAPI"
|
||||
"--restore-last-session"
|
||||
];
|
||||
|
||||
addFlags = lib.concatMapStringsSep " \\\n " (f: "--add-flags \"${f}\"");
|
||||
|
||||
# Libraries that must appear on LD_LIBRARY_PATH at runtime on Linux.
|
||||
linuxRuntimeLibs = [
|
||||
libGL
|
||||
libvdpau
|
||||
libva
|
||||
pipewire
|
||||
alsa-lib
|
||||
libpulseaudio
|
||||
];
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "helium";
|
||||
inherit version src;
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
]
|
||||
++ lib.optionals stdenv.isLinux [
|
||||
autoPatchelfHook
|
||||
copyDesktopItems
|
||||
]
|
||||
++ lib.optionals stdenv.isDarwin [ _7zz ];
|
||||
|
||||
buildInputs = lib.optionals stdenv.isLinux [
|
||||
alsa-lib
|
||||
at-spi2-atk
|
||||
at-spi2-core
|
||||
atk
|
||||
cairo
|
||||
cups
|
||||
dbus
|
||||
expat
|
||||
fontconfig
|
||||
freetype
|
||||
gdk-pixbuf
|
||||
glib
|
||||
gtk3
|
||||
libdrm
|
||||
libgbm
|
||||
libGL
|
||||
libpulseaudio
|
||||
libx11
|
||||
libxcb
|
||||
libxcomposite
|
||||
libxcursor
|
||||
libxdamage
|
||||
libxext
|
||||
libxfixes
|
||||
libxi
|
||||
libxkbcommon
|
||||
libxrandr
|
||||
libxrender
|
||||
libxscrnsaver
|
||||
libxshmfence
|
||||
libxtst
|
||||
libuuid
|
||||
mesa
|
||||
nspr
|
||||
nss
|
||||
pango
|
||||
pipewire
|
||||
systemd
|
||||
vulkan-loader
|
||||
wayland
|
||||
kdePackages.qtbase
|
||||
];
|
||||
|
||||
# QT libraries are bundled; suppress autoPatchelf warnings for them.
|
||||
autoPatchelfIgnoreMissingDeps = lib.optionals stdenv.isLinux [
|
||||
"libQt6Core.so.6"
|
||||
"libQt6Gui.so.6"
|
||||
"libQt6Widgets.so.6"
|
||||
"libQt5Core.so.5"
|
||||
"libQt5Gui.so.5"
|
||||
"libQt5Widgets.so.5"
|
||||
];
|
||||
|
||||
dontWrapQtApps = stdenv.isLinux;
|
||||
|
||||
unpackCmd = lib.optionalString stdenv.isDarwin "7zz x $src";
|
||||
|
||||
installPhase =
|
||||
if stdenv.isDarwin then
|
||||
''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/Applications/Helium.app
|
||||
cp -r . $out/Applications/Helium.app
|
||||
|
||||
mkdir -p $out/bin
|
||||
makeWrapper $out/Applications/Helium.app/Contents/MacOS/Helium $out/bin/helium \
|
||||
${addFlags commonFlags}
|
||||
|
||||
runHook postInstall
|
||||
''
|
||||
else
|
||||
''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin $out/opt/helium
|
||||
cp -r * $out/opt/helium
|
||||
${lib.optionalString enableWidevine ''
|
||||
cp -r ${widevine-cdm}/share/google/chrome/WidevineCdm $out/opt/helium/WidevineCdm
|
||||
''}
|
||||
|
||||
makeWrapper $out/opt/helium/helium $out/bin/helium \
|
||||
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath linuxRuntimeLibs}" \
|
||||
--add-flags "--ozone-platform-hint=auto" \
|
||||
--add-flags "--enable-features=WaylandWindowDecorations" \
|
||||
${addFlags commonFlags}
|
||||
|
||||
mkdir -p $out/share/icons/hicolor/256x256/apps
|
||||
cp $out/opt/helium/product_logo_256.png \
|
||||
$out/share/icons/hicolor/256x256/apps/helium.png
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# helper utility for getting extensions
|
||||
postInstall = ''
|
||||
mkdir -p $out/bin
|
||||
cp ${../scripts/prefetch-nix-extension.sh} $out/bin/prefetch-nix
|
||||
chmod +x $out/bin/prefetch-nix
|
||||
'';
|
||||
|
||||
desktopItems = lib.optionals stdenv.isLinux [
|
||||
(makeDesktopItem {
|
||||
name = "helium";
|
||||
exec = "helium %U";
|
||||
icon = "helium";
|
||||
desktopName = "Helium";
|
||||
genericName = "Web Browser";
|
||||
categories = [
|
||||
"Network"
|
||||
"WebBrowser"
|
||||
];
|
||||
terminal = false;
|
||||
mimeTypes = [
|
||||
"text/html"
|
||||
"text/xml"
|
||||
"application/xhtml+xml"
|
||||
"x-scheme-handler/http"
|
||||
"x-scheme-handler/https"
|
||||
];
|
||||
})
|
||||
];
|
||||
|
||||
meta = {
|
||||
description = "Private, fast, and honest web browser based on ungoogled-chromium";
|
||||
homepage = "https://helium.computer/";
|
||||
license = lib.licenses.gpl3Only;
|
||||
platforms = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
mainProgram = "helium";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
versions = {
|
||||
linux = "0.15.7.1";
|
||||
darwin = "0.15.7.1";
|
||||
};
|
||||
|
||||
srcs = {
|
||||
x86_64-linux = versions: {
|
||||
url = "https://github.com/imputnet/helium-linux/releases/download/${versions.linux}/helium-${versions.linux}-x86_64_linux.tar.xz";
|
||||
hash = "sha256-MQKJLN69/g1R46Y44ADo1UvKAXxS2vKsq/XlAwBO+58=";
|
||||
};
|
||||
aarch64-linux = versions: {
|
||||
url = "https://github.com/imputnet/helium-linux/releases/download/${versions.linux}/helium-${versions.linux}-arm64_linux.tar.xz";
|
||||
hash = "sha256-CYHUDYEMwe+2//4cDPMS2VqcRfbRJD0USDxDJ7kKu6Q=";
|
||||
};
|
||||
x86_64-darwin = versions: {
|
||||
url = "https://github.com/imputnet/helium-macos/releases/download/${versions.darwin}/helium_${versions.darwin}_x86_64-macos.dmg";
|
||||
hash = "sha256-vQ3CkgEQHCPDvlxW24zNVkFM42OkfHIHHgmvcehU0ic=";
|
||||
};
|
||||
aarch64-darwin = versions: {
|
||||
url = "https://github.com/imputnet/helium-macos/releases/download/${versions.darwin}/helium_${versions.darwin}_arm64-macos.dmg";
|
||||
hash = "sha256-QQT3dtBKQvnGi3ySsgaVeXGqKIJ/iys5fDApZnDlt5E=";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user