Skip to content

Commit

Permalink
Adding google chrome program to ghaf
Browse files Browse the repository at this point in the history
Signed-off-by: Enes Öztürk <[email protected]>
  • Loading branch information
enesoztrk authored and brianmcgillion committed Nov 15, 2024
1 parent 7b58d8a commit 942a9ef
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 46 deletions.
2 changes: 1 addition & 1 deletion modules/common/networking/hosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let
}
{
ip = 100;
name = "chromium-vm";
name = "chrome-vm";
}
{
ip = 101;
Expand Down
34 changes: 22 additions & 12 deletions modules/common/services/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,34 @@ in
'';
in
[
{
# The SPKI fingerprint is calculated like this:
# $ openssl x509 -noout -in mitmproxy-ca-cert.pem -pubkey | openssl asn1parse -noout -inform pem -out public.key
# $ openssl dgst -sha256 -binary public.key | openssl enc -base64
name = "Chromium";
description = "Isolated General Browsing";
vm = "Chromium";
path = "${pkgs.givc-cli}/bin/givc-cli ${cliArgs} start chromium";
icon = "${pkgs.icon-pack}/chromium.svg";
}
# {
# # The SPKI fingerprint is calculated like this:
# # $ openssl x509 -noout -in mitmproxy-ca-cert.pem -pubkey | openssl asn1parse -noout -inform pem -out public.key
# # $ openssl dgst -sha256 -binary public.key | openssl enc -base64
# name = "Chromium";
# description = "Isolated General Browsing";
# vm = "Chromium";
# path = "${pkgs.givc-cli}/bin/givc-cli ${cliArgs} start chromium";
# icon = "${pkgs.icon-pack}/chromium.svg";
# }

{
name = "Trusted Browser";
description = "Isolated Trusted Browsing";
vm = "Business";
path = "${pkgs.givc-cli}/bin/givc-cli ${cliArgs} start --vm business-vm chromium";
path = "${pkgs.givc-cli}/bin/givc-cli ${cliArgs} start --vm business-vm google-chrome";
icon = "${pkgs.icon-pack}/thorium-browser.svg";
}
{
# The SPKI fingerprint is calculated like this:
# $ openssl x509 -noout -in mitmproxy-ca-cert.pem -pubkey | openssl asn1parse -noout -inform pem -out public.key
# $ openssl dgst -sha256 -binary public.key | openssl enc -base64
name = "Google Chrome";
description = "Isolated General Browsing";
vm = "Chrome";
path = "${pkgs.givc-cli}/bin/givc-cli ${cliArgs} start --vm chrome-vm google-chrome";
icon = "${pkgs.icon-pack}/google-chrome.svg";
}

{
name = "VPN";
Expand Down Expand Up @@ -127,7 +137,7 @@ in
name = "PDF Viewer";
description = "Isolated PDF Viewer";
vm = "Zathura";
path = "${pkgs.givc-cli}/bin/givc-cli ${cliArgs} start zathura";
path = "${pkgs.givc-cli}/bin/givc-cli ${cliArgs} start --vm zathura-vm zathura";
icon = "${pkgs.icon-pack}/document-viewer.svg";
}

Expand Down
9 changes: 8 additions & 1 deletion modules/desktop/graphics/demo-apps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ in
{
options.ghaf.graphics.demo-apps = {
chromium = mkProgramOption "Chromium browser" false;
google-chrome = mkProgramOption "Google Chrome browser" false;
firefox = mkProgramOption "Firefox browser" config.ghaf.graphics.enableDemoApplications;
gala-app = mkProgramOption "Gala App" false;
element-desktop = mkProgramOption "Element desktop" config.ghaf.graphics.enableDemoApplications;
Expand All @@ -33,7 +34,13 @@ in

config = lib.mkIf config.ghaf.profiles.graphics.enable {
ghaf.graphics.launchers =
lib.optional cfg.chromium {
lib.optional cfg.google-chrome {
name = "Google Chrome";
description = "Web Browser";
path = "${pkgs.google-chrome}/bin/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland";
icon = "${pkgs.icon-pack}/google-chrome.svg";
}
++ lib.optional cfg.chromium {
name = "Chromium";
description = "Web Browser";
path = "${pkgs.chromium}/bin/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland";
Expand Down
2 changes: 1 addition & 1 deletion modules/givc/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let
mitmEnabled =
config.ghaf.virtualization.microvm.idsvm.enable
&& config.ghaf.virtualization.microvm.idsvm.mitmproxy.enable;
mitmExtraArgs = lib.optionalString mitmEnabled "--user-data-dir=/home/${config.ghaf.users.accounts.user}/.config/chromium/Default --test-type --ignore-certificate-errors-spki-list=Bq49YmAq1CG6FuBzp8nsyRXumW7Dmkp7QQ/F82azxGU=";
mitmExtraArgs = lib.optionalString mitmEnabled "--user-data-dir=/home/${config.ghaf.users.accounts.user}/.config/google-chrome/Default --test-type --ignore-certificate-errors-spki-list=Bq49YmAq1CG6FuBzp8nsyRXumW7Dmkp7QQ/F82azxGU=";
in
{
options.ghaf.givc = {
Expand Down
5 changes: 3 additions & 2 deletions modules/hardware/common/usb/vhotplug.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ let
}
];
}

{
name = "ChromiumVM";
qmpSocket = "/var/lib/microvms/chromium-vm/chromium-vm.sock";
name = "ChromeVM";
qmpSocket = "/var/lib/microvms/chrome-vm/chrome-vm.sock";
usbPassthrough = [
{
class = 14;
Expand Down
27 changes: 17 additions & 10 deletions modules/reference/appvms/business.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ in
name = "${name}";
packages =
[
pkgs.chromium
pkgs.google-chrome
pkgs.globalprotect-openconnect
pkgs.losslesscut-bin
pkgs.openconnect
gnomeTextEditor
pkgs.xarchiver

]
++ lib.optionals config.ghaf.profiles.debug.enable [ pkgs.tcpdump ]
++ lib.optionals config.ghaf.givc.enable [ pkgs.open-normal-extension ];
Expand All @@ -49,7 +50,8 @@ in
{ pkgs, ... }:
{
imports = [
../programs/chromium.nix
# ../programs/chromium.nix
../programs/google-chrome.nix
../services/globalprotect-vpn/default.nix
];
time.timeZone = config.time.timeZone;
Expand All @@ -68,21 +70,21 @@ in
name = lib.mkForce "business-vm";
applications = [
{
name = "chromium";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
name = "google-chrome";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
args = [ "url" ];
}
{
name = "outlook";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://outlook.office.com/mail/ ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://outlook.office.com/mail/ ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
}
{
name = "office";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://microsoft365.com ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://microsoft365.com ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
}
{
name = "teams";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://teams.microsoft.com ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://teams.microsoft.com ${config.ghaf.givc.idsExtraArgs} --load-extension=${pkgs.open-normal-extension}";
}
{
name = "gpclient";
Expand All @@ -104,7 +106,7 @@ in
};

reference = {
programs.chromium.enable = true;
programs.google-chrome.enable = true;

services.globalprotect = {
enable = true;
Expand All @@ -114,12 +116,17 @@ in

services.xdghandlers.enable = true;
};

environment.etc."chromium/native-messaging-hosts/fi.ssrc.open_normal.json" =
environment.etc."opt/chrome/native-messaging-hosts/fi.ssrc.open_normal.json" =
mkIf config.ghaf.givc.enable
{
source = "${pkgs.open-normal-extension}/fi.ssrc.open_normal.json";
};

# environment.etc."chromium/native-messaging-hosts/fi.ssrc.open_normal.json" =
# mkIf config.ghaf.givc.enable
# {
# source = "${pkgs.open-normal-extension}/fi.ssrc.open_normal.json";
# };
environment.etc."open-normal-extension.cfg" = mkIf config.ghaf.givc.enable {
text =
let
Expand Down
14 changes: 9 additions & 5 deletions modules/reference/appvms/comms.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in
name = "${name}";

packages = [
pkgs.chromium
pkgs.google-chrome
pkgs.element-desktop
pkgs.element-gps
pkgs.gpsd
Expand All @@ -32,7 +32,11 @@ in
cores = 4;
extraModules = [
{
imports = [ ../programs/chromium.nix ];
imports = [
# ../programs/chromium.nix
../programs/google-chrome.nix

];

systemd = {
services = {
Expand Down Expand Up @@ -93,15 +97,15 @@ in
}
{
name = "slack";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://app.slack.com/client ${config.ghaf.givc.idsExtraArgs}";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://app.slack.com/client ${config.ghaf.givc.idsExtraArgs}";
}
{
name = "zoom";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://app.zoom.us/wc/home ${config.ghaf.givc.idsExtraArgs}";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland --app=https://app.zoom.us/wc/home ${config.ghaf.givc.idsExtraArgs}";
}
];
};
ghaf.reference.programs.chromium.enable = true;
ghaf.reference.programs.google-chrome.enable = true;
ghaf.services.xdghandlers.enable = true;
}
];
Expand Down
2 changes: 2 additions & 0 deletions modules/reference/appvms/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ in
options.ghaf.reference.appvms = {
enable = lib.mkEnableOption "Enable the Ghaf reference appvms module";
chromium-vm = lib.mkEnableOption "Enable the Chromium appvm";
chrome-vm = lib.mkEnableOption "Enable the Google Chrome appvm";
gala-vm = lib.mkEnableOption "Enable the Gala appvm";
zathura-vm = lib.mkEnableOption "Enable the Zathura appvm";
comms-vm = lib.mkEnableOption ''
Expand All @@ -37,6 +38,7 @@ in
ghaf.reference.appvms = {
enabled-app-vms =
(lib.optionals cfg.chromium-vm [ (import ./chromium.nix { inherit pkgs lib config; }) ])
++ (lib.optionals cfg.chrome-vm [ (import ./google-chrome.nix { inherit pkgs lib config; }) ])
++ (lib.optionals cfg.gala-vm [ (import ./gala.nix { inherit pkgs lib config; }) ])
++ (lib.optionals cfg.zathura-vm [ (import ./zathura.nix { inherit pkgs lib config; }) ])
++ (lib.optionals cfg.comms-vm [ (import ./comms.nix { inherit pkgs lib config; }) ])
Expand Down
56 changes: 56 additions & 0 deletions modules/reference/appvms/google-chrome.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
#
{
pkgs,
lib,
config,
...
}:
let
name = "chrome";
in
{
name = "${name}";
packages = [
pkgs.google-chrome
] ++ lib.optional config.ghaf.development.debug.tools.enable pkgs.alsa-utils;
# TODO create a repository of mac addresses to avoid conflicts
macAddress = "02:00:00:03:11:01";
ramMb = 6144;
cores = 4;
extraModules = [
{
imports = [ ../programs/google-chrome.nix ];

time.timeZone = config.time.timeZone;

# Disable camera for now, because, due to the bug, the camera is not accessable in BusinessVM
# microvm.qemu.extraArgs = optionals (
# config.ghaf.hardware.usb.internal.enable
# && (hasAttr "cam0" config.ghaf.hardware.usb.internal.qemuExtraArgs)
# ) config.ghaf.hardware.usb.internal.qemuExtraArgs.cam0;
microvm.devices = [ ];

ghaf.givc.appvm = {
enable = true;
name = lib.mkForce "chrome-vm";
applications = [
{
name = "google-chrome";
command = "${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland ${config.ghaf.givc.idsExtraArgs}";
args = [
"url"
"flag"
];
}
];
};
ghaf.reference.programs.google-chrome.enable = true;
ghaf.services.xdghandlers.enable = true;
}
];
borderColor = "#630505";
ghafAudio.enable = true;
vtpm.enable = true;
}
2 changes: 1 addition & 1 deletion modules/reference/profiles/laptop-x86.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ in
enable = true;
vms = [
"business-vm"
"chromium-vm"
"comms-vm"
"chrome-vm"
];
};
};
Expand Down
3 changes: 2 additions & 1 deletion modules/reference/profiles/mvp-user-trial.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ in
reference = {
appvms = {
enable = true;
chromium-vm = true;
chrome-vm = true;
gala-vm = true;
zathura-vm = true;
comms-vm = true;
business-vm = true;

};

services = {
Expand Down
3 changes: 2 additions & 1 deletion modules/reference/programs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
imports = [
./zathura.nix
./chromium.nix
# ./chromium.nix
./google-chrome.nix
./windows-launcher.nix
];
}
Loading

0 comments on commit 942a9ef

Please sign in to comment.