Add interactive session launch option

This commit is contained in:
Riuga 2026-04-01 10:11:41 -05:00
parent b296bf670e
commit b5cf3140f8

View File

@ -11,7 +11,9 @@
citrixDownloadPageUrl = "https://www.citrix.com/downloads/workspace-app/legacy-workspace-app-for-linux/workspace-app-for-linux-250810.html"; citrixDownloadPageUrl = "https://www.citrix.com/downloads/workspace-app/legacy-workspace-app-for-linux/workspace-app-for-linux-250810.html";
citrixTarballHash = "sha256-bd3ClxBRJgvjJW+waKBE31k9ePam+n2pHeSjlkvkDRo="; citrixTarballHash = "sha256-bd3ClxBRJgvjJW+waKBE31k9ePam+n2pHeSjlkvkDRo=";
disclaimer = '' dtccVdiUrl = "https://myvdi.dtcc.com";
icaDisclaimer = ''
WARNING: ICA files are only good to be used ONCE. If you've logged into the DTCC virtual WARNING: ICA files are only good to be used ONCE. If you've logged into the DTCC virtual
desktop using it before, you will get a connection error from Citrix upon trying to log in desktop using it before, you will get a connection error from Citrix upon trying to log in
with it again. To get a fresh ICA file, you need to _refresh_ your myvdi.dtcc.com page and with it again. To get a fresh ICA file, you need to _refresh_ your myvdi.dtcc.com page and
@ -38,6 +40,10 @@
citrix_workspace = super.citrix_workspace.overrideAttrs (_: { citrix_workspace = super.citrix_workspace.overrideAttrs (_: {
src = scripts.citrixTarballScraper; src = scripts.citrixTarballScraper;
}); });
ungoogled-chromium = super.ungoogled-chromium.override {
# Disables the prompt to create a default keyring on initial startup.
commandLineArgs = "--password-store=basic";
};
}) })
]; ];
}; };
@ -78,10 +84,12 @@
) )
if [[ ''${#files[@]} -eq 0 ]]; then if [[ ''${#files[@]} -eq 0 ]]; then
echo "No .ica files found in $download_dir or $PWD" >&2 echo "No .ica files found in $download_dir or $PWD." >&2
return 1 return 0
fi fi
echo "${constants.icaDisclaimer}" >&2
echo "Available .ica files:" >&2 echo "Available .ica files:" >&2
for i in "''${!files[@]}"; do for i in "''${!files[@]}"; do
echo " $((i+1))) ''${files[$i]}" >&2 echo " $((i+1))) ''${files[$i]}" >&2
@ -89,27 +97,40 @@
local selection local selection
while true; do while true; do
read -rp "Select file [1-''${#files[@]}] (default: 1): " selection >&2 read -rp "Select file [1-''${#files[@]}] (leave blank to start interactive session): " \
selection="''${selection:-1}" selection >&2
if [[ "$selection" =~ ^[0-9]+$ ]] && \ if [[ -z "$selection" ]] || \
(( selection >= 1 && selection <= ''${#files[@]} )); then ([[ "$selection" =~ ^[0-9]+$ ]] && \
(( selection >= 1 && selection <= ''${#files[@]} ))); then
break break
fi fi
echo "Invalid selection, please enter a number between 1 and ''${#files[@]}" >&2 echo "Invalid selection, please enter a number between 1 and ''${#files[@]}." >&2
echo "Or leave blank to start an interactive session."
done done
echo "''${files[$((selection-1))]}" if [[ -n "$selection" ]]; then
echo "''${files[$((selection-1))]}"
fi
} }
echo "${constants.disclaimer}"
ica_file=$(select_ica_file) ica_file=$(select_ica_file)
mkdir -p /tmp/dtcc-onboarding mkdir -p /tmp/dtcc-onboarding
cp "$ica_file" /tmp/dtcc-onboarding/dtcc-ica.ica if [[ -n "''${ica_file}" ]]; then
cp "$ica_file" /tmp/dtcc-onboarding/dtcc-ica.ica
else
echo "Launching interactive session..." >&2
fi
${self.nixosConfigurations.dtcc-onboarding.config.system.build.vm}/bin/run-nixos-vm ${self.nixosConfigurations.dtcc-onboarding.config.system.build.vm}/bin/run-nixos-vm
''; '';
scripts.autolaunch = pkgs.writeShellScriptBin "autolaunch" ''
if [[ -f /mnt/ica/dtcc-ica.ica ]]; then
${pkgs.citrix_workspace}/bin/wfica /mnt/ica/dtcc-ica.ica
else
${pkgs.ungoogled-chromium}/bin/chromium ${constants.dtccVdiUrl}
fi
'';
in { in {
nixosConfigurations.dtcc-onboarding = nixpkgs.lib.nixosSystem { nixosConfigurations.dtcc-onboarding = nixpkgs.lib.nixosSystem {
inherit pkgs; inherit pkgs;
@ -117,6 +138,12 @@
modules = [ modules = [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
({ pkgs, ... }: { ({ pkgs, ... }: {
environment.systemPackages = with pkgs; [
citrix_workspace
ungoogled-chromium
gnomeExtensions.no-overview
];
services = { services = {
displayManager.gdm = { displayManager.gdm = {
enable = true; enable = true;
@ -141,11 +168,6 @@
}]; }];
}; };
environment.systemPackages = with pkgs; [
citrix_workspace
gnomeExtensions.no-overview
];
users.users.nixos = { users.users.nixos = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
@ -154,12 +176,39 @@
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;
systemd.user.services.launch-citrix = { xdg.mime.enable = true;
environment.etc."share/applications/mimeapps.list".text = ''
[Default Applications]
application/x-ica=wfica.desktop
'';
environment.etc."share/applications/wfica.desktop".text = ''
[Desktop Entry]
Type=Application
Name=Citrix Workspace
Exec=wfica %f
MimeType=application/x-ica;
NoDisplay=true
'';
environment.etc."chromium/policies/managed/default-browser.json".text = builtins.toJSON {
DefaultBrowserSettingEnabled = false;
};
environment.etc."chromium/policies/managed/downloads.json".text = builtins.toJSON {
PromptForDownloadLocation = false;
AutoOpenFileTypes = [ "ica" ];
};
# Launches Citrix or Chromium depending on whether the user specified a file on init.
systemd.user.services.autolaunch = {
description = "Launch Citrix ICA session"; description = "Launch Citrix ICA session";
wantedBy = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ];
after = [ "graphical-session.target" ]; after = [ "graphical-session.target" ];
environment.PATH = pkgs.lib.mkForce "/run/current-system/sw/bin:/run/wrappers/bin";
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.citrix_workspace}/bin/wfica /mnt/ica/dtcc-ica.ica'"; ExecStart = "${scripts.autolaunch}/bin/autolaunch";
Restart = "no"; Restart = "no";
Type = "oneshot"; Type = "oneshot";
}; };
@ -173,7 +222,8 @@
msize = 128 * 1024; msize = 128 * 1024;
diskSize = 12 * 1024; diskSize = 12 * 1024;
qemu.options = [ qemu.options = [
"-vga virtio" "-vga none"
"-device virtio-vga"
]; ];
sharedDirectories = { sharedDirectories = {
default = { default = {