Skip to content

Commit

Permalink
fix(nix/modules/launcher): add wrapGAppsHook (#1976)
Browse files Browse the repository at this point in the history
* fix(nix/modules/launcher): add and make proper use of wrappGAppsHook

this fixes an issue where the filechooser doesn't work. there's also a fix for DevTools on non-NixOS environments

* add container and scripts for  hc-launch testing

* fix(nix/modules/hc-launch): add missing deps for devtools
  • Loading branch information
steveej authored Mar 25, 2023
1 parent f75c30c commit 003039a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
24 changes: 24 additions & 0 deletions containers/ubuntu-podman/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ubuntu:22.10

ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo git \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************

# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME

WORKDIR /home/$USERNAME
26 changes: 26 additions & 0 deletions containers/ubuntu-podman/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -xeu

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

podman build --build-arg USERNAME="$USER" --tag ubuntu-nix "${SCRIPT_DIR}"
xhost +si:localuser:"$USER"
podman run -it --rm \
--userns keep-id \
--security-opt label=type:container_runtime_t \
-v "$XAUTHORITY":"$XAUTHORITY":ro \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
--env XAUTHORITY \
--env DISPLAY \
--env NIX_REMOTE="daemon" \
--env NIX_CONFIG="experimental-features = nix-command flakes" \
-v /nix/store:/nix/store:ro \
-v /nix/var/nix/db:/nix/var/nix/db:ro \
-v /nix/var/nix/daemon-socket:/nix/var/nix/daemon-socket:ro \
-v "$(readlink "$(which nix)")":/usr/bin/nix:ro \
-v "${SCRIPT_DIR}"/../..:/home/"$USER"/project \
--workdir /home/"$USER"/project \
localhost/ubuntu-nix \
bash

17 changes: 13 additions & 4 deletions nix/modules/launcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
perl
pkg-config
])
++ (lib.optionals pkgs.stdenv.isLinux
(with pkgs; [
wrapGAppsHook
]))
++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
xcbuild
libiconv
Expand All @@ -66,10 +70,14 @@
];

preFixup = ''
wrapProgram $out/bin/hc-launch \
--set WEBKIT_DISABLE_COMPOSITING_MODE 1 \
--set GIO_MODULE_DIR ${pkgs.glib-networking}/lib/gio/modules \
--prefix GIO_EXTRA_MODULES : ${pkgs.glib-networking}/lib/gio/modules
gappsWrapperArgs+=(
--set WEBKIT_DISABLE_COMPOSITING_MODE 1
)
# without this the DevTools will just display an unparsed HTML file (see https://github.com/tauri-apps/tauri/issues/5711#issuecomment-1336409601)
gappsWrapperArgs+=(
--prefix XDG_DATA_DIRS : "${pkgs.shared-mime-info}/share"
)
'';
});

Expand All @@ -81,3 +89,4 @@
};
};
}

4 changes: 4 additions & 0 deletions scripts/test-hc-launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

# TODO: build the hc-launch-test.webhapp file from source
echo pass | nix develop .#holonix --command hc-launch --piped -n1 ./hc-launch-test.webhapp network mdns

0 comments on commit 003039a

Please sign in to comment.