Add interactive session launch option
This commit is contained in:
parent
b296bf670e
commit
b5cf3140f8
88
flake.nix
88
flake.nix
@ -11,7 +11,9 @@
|
||||
citrixDownloadPageUrl = "https://www.citrix.com/downloads/workspace-app/legacy-workspace-app-for-linux/workspace-app-for-linux-250810.html";
|
||||
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
|
||||
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
|
||||
@ -38,6 +40,10 @@
|
||||
citrix_workspace = super.citrix_workspace.overrideAttrs (_: {
|
||||
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
|
||||
echo "No .ica files found in $download_dir or $PWD" >&2
|
||||
return 1
|
||||
echo "No .ica files found in $download_dir or $PWD." >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "${constants.icaDisclaimer}" >&2
|
||||
|
||||
echo "Available .ica files:" >&2
|
||||
for i in "''${!files[@]}"; do
|
||||
echo " $((i+1))) ''${files[$i]}" >&2
|
||||
@ -89,27 +97,40 @@
|
||||
|
||||
local selection
|
||||
while true; do
|
||||
read -rp "Select file [1-''${#files[@]}] (default: 1): " selection >&2
|
||||
selection="''${selection:-1}"
|
||||
if [[ "$selection" =~ ^[0-9]+$ ]] && \
|
||||
(( selection >= 1 && selection <= ''${#files[@]} )); then
|
||||
read -rp "Select file [1-''${#files[@]}] (leave blank to start interactive session): " \
|
||||
selection >&2
|
||||
if [[ -z "$selection" ]] || \
|
||||
([[ "$selection" =~ ^[0-9]+$ ]] && \
|
||||
(( selection >= 1 && selection <= ''${#files[@]} ))); then
|
||||
break
|
||||
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
|
||||
|
||||
if [[ -n "$selection" ]]; then
|
||||
echo "''${files[$((selection-1))]}"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "${constants.disclaimer}"
|
||||
|
||||
ica_file=$(select_ica_file)
|
||||
|
||||
mkdir -p /tmp/dtcc-onboarding
|
||||
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
|
||||
'';
|
||||
|
||||
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 {
|
||||
nixosConfigurations.dtcc-onboarding = nixpkgs.lib.nixosSystem {
|
||||
inherit pkgs;
|
||||
@ -117,6 +138,12 @@
|
||||
modules = [
|
||||
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
|
||||
({ pkgs, ... }: {
|
||||
environment.systemPackages = with pkgs; [
|
||||
citrix_workspace
|
||||
ungoogled-chromium
|
||||
gnomeExtensions.no-overview
|
||||
];
|
||||
|
||||
services = {
|
||||
displayManager.gdm = {
|
||||
enable = true;
|
||||
@ -141,11 +168,6 @@
|
||||
}];
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
citrix_workspace
|
||||
gnomeExtensions.no-overview
|
||||
];
|
||||
|
||||
users.users.nixos = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
@ -154,12 +176,39 @@
|
||||
|
||||
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";
|
||||
wantedBy = [ "graphical-session.target" ];
|
||||
after = [ "graphical-session.target" ];
|
||||
environment.PATH = pkgs.lib.mkForce "/run/current-system/sw/bin:/run/wrappers/bin";
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.citrix_workspace}/bin/wfica /mnt/ica/dtcc-ica.ica'";
|
||||
ExecStart = "${scripts.autolaunch}/bin/autolaunch";
|
||||
Restart = "no";
|
||||
Type = "oneshot";
|
||||
};
|
||||
@ -173,7 +222,8 @@
|
||||
msize = 128 * 1024;
|
||||
diskSize = 12 * 1024;
|
||||
qemu.options = [
|
||||
"-vga virtio"
|
||||
"-vga none"
|
||||
"-device virtio-vga"
|
||||
];
|
||||
sharedDirectories = {
|
||||
default = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user