From da35923df94a788edd74184f4718350f147196a4 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:13:16 +0200 Subject: [PATCH 01/17] feat: package winapps & the winapps launcher using nix doc: document installation using Nix fix: explicitely specify path to inquirer fix: libvirt group is called libvirtd on nix fix: set libvirturl for winapps-launcher fix: refine group change sed expr feat: add desktop file fix: do not use source derivation fix: use install instead of cp fix: ensure exists --- README.md | 64 ++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++ flake.nix | 24 +++++++++ packages/winapps-launcher/default.nix | 66 ++++++++++++++++++++++++ packages/winapps/default.nix | 72 +++++++++++++++++++++++++++ 5 files changed, 287 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 packages/winapps-launcher/default.nix create mode 100644 packages/winapps/default.nix diff --git a/README.md b/README.md index da62a1f..ae985ac 100644 --- a/README.md +++ b/README.md @@ -471,6 +471,70 @@ The installer can be run multiple times. To update your installation of WinApps: 2. Pull the latest changes from the WinApps GitHub repository. 3. Re-install WinApps using the WinApps installer. +## Installation using Nix + +First, follow Step 1 of the normal installation guide to create your VM. +Then, install WinApps according to the following instructions. + +After installation, it will be available under `winapps`, with the installer being available under `winapps-setup` +and the optional launcher being available under `winapps-launcher.` + +### Using standalone Nix + +First, make sure Flakes and the `nix` command are enabled. +In your `~/.config/nix/nix.conf`: +``` +experimental-features = nix-command flakes +``` + +```bash +nix profile install github:winapps-org/winapps#winapps +nix profile install github:winapps-org/winapps#winapps-launcher # optional +``` + +### On NixOS using Flakes + +```nix +{ + description = "My configuration"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + winapps = { + url = ""github:winapps-org/winapps; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + nixpkgs, + winapps, + ... + }: { + nixosConfigurations.hostname = nixpkgs.lib.nixosSystem rec { + system = "x86_64-linux"; + + modules = [ + ./configuration.nix + ({pkgs, ...}: { + environment.systemPackages = [ + winapps.packages.${system}.winapps + winapps.packages.${system}.winapps-launcher # optional + ]; + }) + ]; + }; + }; +} +``` + +### On NixOS without Flakes + +[Flakes aren't real and they can't hurt you.](https://jade.fyi/blog/flakes-arent-real/). +See https://wiki.nixos.org/wiki/Flakes#Using_nix_flakes_with_NixOS on how to enable Flakes on your system. + + ## Star History diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b07995a --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1724819573, + "narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "71e91c409d1e654808b2621f28a327acfdad8dc2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..596e431 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "WinApps Nix packages & NixOS module"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: let + pkgs = import nixpkgs {inherit system;}; + in { + formatter = pkgs.alejandra; + + packages.winapps = pkgs.callPackage ./packages/winapps {}; + packages.winapps-launcher = pkgs.callPackage ./packages/winapps-launcher {}; + } + ); +} diff --git a/packages/winapps-launcher/default.nix b/packages/winapps-launcher/default.nix new file mode 100644 index 0000000..0b1cece --- /dev/null +++ b/packages/winapps-launcher/default.nix @@ -0,0 +1,66 @@ +{ + stdenv, + lib, + fetchFromGitHub, + makeWrapper, + makeDesktopItem, + callPackage, + yad, + ... +}: let + rev = "eaa660d39bf3f49b136c98c87c35e3e12f118f8f"; + hash = "sha256-7lkx/O4dOdVqAPX6s2IkkM6Ggbzmz9sm++20BBeoUQ4="; +in + stdenv.mkDerivation rec { + pname = "winapps-launcher"; + version = "git+${rev}"; + + src = fetchFromGitHub { + owner = "winapps-org"; + repo = "WinApps-Launcher"; + + inherit rev hash; + }; + + nativeBuildInputs = [makeWrapper]; + buildInputs = [yad (callPackage ../winapps {})]; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r ./Icons $out/Icons + + sed -E -i \ + -e "$(printf "%s$out%s" 's|^declare -rx ICONS_PATH="./Icons"|declare -rx ICONS_PATH="' '/Icons"|')" \ + WinAppsLauncher.sh + + install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher + install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg + + wrapProgram $out/bin/winapps-launcher \ + --set LIBVIRT_DEFAULT_URI "qemu:///system" \ + --prefix PATH : "${lib.makeBinPath buildInputs}" + + runHook postInstall + ''; + + desktopItems = [ + (makeDesktopItem { + name = "winapps"; + exec = "winapps-launcher"; + icon = "winapps"; + comment = meta.description; + desktopName = "WinApps"; + categories = ["Utility"]; + }) + ]; + + meta = with lib; { + homepage = "https://github.com/winapps-org/WinApps-Launcher"; + description = "Graphical launcher for WinApps. Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; + mainProgram = "winapps-launcher"; + platforms = platforms.linux; + license = licenses.gpl3; + }; + } diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix new file mode 100644 index 0000000..3f47542 --- /dev/null +++ b/packages/winapps/default.nix @@ -0,0 +1,72 @@ +{ + stdenv, + lib, + fetchFromGitHub, + makeWrapper, + freerdp3, + dialog, + libnotify, + netcat-gnu, + iproute2, + ... +}: let + rev = "feat-install-script"; # "9417382ae73d2ae5ad69d1c5c407e8b1e5f001dc"; + hash = "sha256-iasuufBu+DhulH/hj2uUaM/KzGO7241+PZXuujsT/qI="; +in + stdenv.mkDerivation rec { + pname = "winapps"; + version = "git+${rev}"; + + src = fetchFromGitHub { + owner = "winapps-org"; + repo = "winapps"; + + inherit rev hash; + }; + + nativeBuildInputs = [makeWrapper]; + buildInputs = [freerdp3 libnotify dialog netcat-gnu iproute2]; + + installPhase = '' + runHook preInstall + + patchShebangs install/inquirer.sh + + mkdir -p $out + mkdir -p $out/src + + cp -r ./ $out/src/ + + install -m755 -D bin/winapps $out/bin/winapps + install -m755 -D setup.sh $out/bin/winapps-setup + + sed -E -i \ + -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ + $out/bin/winapps + + sed -E -i \ + -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ + -e "$(printf "%s$out%s" 's|^readonly INQUIRER_PATH="./install/inquirer.sh"|readonly INQUIRER_PATH="' '/src/install/inquirer.sh"|')" \ + -e "$(printf "%s$out%s" 's|^readonly SYS_SOURCE_PATH="(.*?)"|readonly SYS_SOURCE_PATH="' '/src"|')" \ + -e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \ + -e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \ + -e 's|./setup.sh|winapps-setup|g' \ + $out/bin/winapps-setup + + for f in winapps-setup winapps; do + wrapProgram $out/bin/$f \ + --set LIBVIRT_DEFAULT_URI "qemu:///system" \ + --prefix PATH : "${lib.makeBinPath buildInputs}" + done + + runHook postInstall + ''; + + meta = with lib; { + homepage = "https://github.com/winapps-org/winapps"; + description = "Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; + mainProgram = "winapps"; + platforms = platforms.linux; + license = licenses.gpl3; + }; + } From 00141f1d54e9b7d206eb2bf45dc56f7cec7d3284 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Sat, 7 Sep 2024 13:05:09 +0200 Subject: [PATCH 02/17] fix: do not symlink binaries on nix --- packages/winapps/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 3f47542..46b869d 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -42,6 +42,8 @@ in sed -E -i \ -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ + -e 's|$SUDO ln -s "./bin/winapps"(.*)||' \ + -e 's|$SUDO ln -s "./setup.sh"(.*)||' \ $out/bin/winapps sed -E -i \ From 26a2f13815b555752b5f2cae6007a85e46d98880 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Sat, 7 Sep 2024 13:30:35 +0200 Subject: [PATCH 03/17] feat: bump version --- packages/winapps/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 46b869d..e2d4f44 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -10,8 +10,8 @@ iproute2, ... }: let - rev = "feat-install-script"; # "9417382ae73d2ae5ad69d1c5c407e8b1e5f001dc"; - hash = "sha256-iasuufBu+DhulH/hj2uUaM/KzGO7241+PZXuujsT/qI="; + rev = "4e3d5bd4581250a49974a19b37f55fc76165051a"; + hash = "sha256-meM9U6MLVqN0SjzorL8TeYKEkFXykCJI7BTady5CWMA="; in stdenv.mkDerivation rec { pname = "winapps"; @@ -42,8 +42,8 @@ in sed -E -i \ -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - -e 's|$SUDO ln -s "./bin/winapps"(.*)||' \ - -e 's|$SUDO ln -s "./setup.sh"(.*)||' \ + -e 's|\$SUDO ln -s "./bin/winapps"(.*)||' \ + -e 's|\$SUDO ln -s "./setup.sh"(.*)||' \ $out/bin/winapps sed -E -i \ From f4c0a454b7757a03ff59eefe39e7ca11f22a0b9d Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Sun, 8 Sep 2024 11:46:48 +0200 Subject: [PATCH 04/17] fix: properly escape ${} --- packages/winapps/default.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index e2d4f44..c3a8300 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -10,8 +10,8 @@ iproute2, ... }: let - rev = "4e3d5bd4581250a49974a19b37f55fc76165051a"; - hash = "sha256-meM9U6MLVqN0SjzorL8TeYKEkFXykCJI7BTady5CWMA="; + rev = "350f003d817765ed9e6f4791e86c3d69019f230a"; + hash = "sha256-MqQ9KFyo6bZDxfWCe62z1zDSvHJJjvWqZLO4UxwELow="; in stdenv.mkDerivation rec { pname = "winapps"; @@ -42,8 +42,6 @@ in sed -E -i \ -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - -e 's|\$SUDO ln -s "./bin/winapps"(.*)||' \ - -e 's|\$SUDO ln -s "./setup.sh"(.*)||' \ $out/bin/winapps sed -E -i \ @@ -53,6 +51,9 @@ in -e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \ -e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \ -e 's|./setup.sh|winapps-setup|g' \ + -e 's|\$SUDO ln -s "./bin/winapps" "\$\{BIN_PATH\}/winapps"||' \ + -e 's|\$SUDO ln -s "./setup.sh" "\$\{BIN_PATH\}/winapps-setup"||' \ + -e "s|\$\{BIN_PATH\}/winapps|$out/bin/winapps|" \ $out/bin/winapps-setup for f in winapps-setup winapps; do From b0f2830224003a0a368e1a36b25ba65848b642f1 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:27:36 +0200 Subject: [PATCH 05/17] feat: bump version --- packages/winapps/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index c3a8300..986c6dc 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -10,8 +10,8 @@ iproute2, ... }: let - rev = "350f003d817765ed9e6f4791e86c3d69019f230a"; - hash = "sha256-MqQ9KFyo6bZDxfWCe62z1zDSvHJJjvWqZLO4UxwELow="; + rev = "7bae17e3a3607e6b93c7cfc4155dfbdca7bba005"; + hash = "sha256-PP4POMwHCsAdiCxZkjXlON84F0Mg3Pd5bHEI6tC+Sds="; in stdenv.mkDerivation rec { pname = "winapps"; From 7d5cce374c3402b6bcc8169d325fd342c2f8d506 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:31:41 +0200 Subject: [PATCH 06/17] feat: use nixfmt --- .pre-commit-config.yaml | 6 ++ flake.nix | 25 ++++--- packages/winapps-launcher/default.nix | 90 +++++++++++----------- packages/winapps/default.nix | 103 ++++++++++++++------------ 4 files changed, 122 insertions(+), 102 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5f2edb..76a6cd0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,6 @@ ci: autoupdate_branch: "rewrite" + skip: [nixfmt] repos: - repo: https://github.com/Lucas-C/pre-commit-hooks @@ -48,3 +49,8 @@ repos: rev: v0.10.0.1 hooks: - id: shellcheck + + - repo: https://github.com/NixOS/nixfmt + rev: d0c0cda4fe6b7ae2b9aa37f3ee15e6412573eb01 + hooks: + - id: nixfmt diff --git a/flake.nix b/flake.nix index 596e431..5bf6d8f 100644 --- a/flake.nix +++ b/flake.nix @@ -6,19 +6,22 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { - nixpkgs, - flake-utils, - ... - }: + outputs = + { + nixpkgs, + flake-utils, + ... + }: flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = import nixpkgs {inherit system;}; - in { - formatter = pkgs.alejandra; + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + formatter = pkgs.nixfmt-rfc-style; - packages.winapps = pkgs.callPackage ./packages/winapps {}; - packages.winapps-launcher = pkgs.callPackage ./packages/winapps-launcher {}; + packages.winapps = pkgs.callPackage ./packages/winapps { }; + packages.winapps-launcher = pkgs.callPackage ./packages/winapps-launcher { }; } ); } diff --git a/packages/winapps-launcher/default.nix b/packages/winapps-launcher/default.nix index 0b1cece..362f428 100644 --- a/packages/winapps-launcher/default.nix +++ b/packages/winapps-launcher/default.nix @@ -7,60 +7,64 @@ callPackage, yad, ... -}: let +}: +let rev = "eaa660d39bf3f49b136c98c87c35e3e12f118f8f"; hash = "sha256-7lkx/O4dOdVqAPX6s2IkkM6Ggbzmz9sm++20BBeoUQ4="; in - stdenv.mkDerivation rec { - pname = "winapps-launcher"; - version = "git+${rev}"; +stdenv.mkDerivation rec { + pname = "winapps-launcher"; + version = "git+${rev}"; - src = fetchFromGitHub { - owner = "winapps-org"; - repo = "WinApps-Launcher"; + src = fetchFromGitHub { + owner = "winapps-org"; + repo = "WinApps-Launcher"; - inherit rev hash; - }; + inherit rev hash; + }; - nativeBuildInputs = [makeWrapper]; - buildInputs = [yad (callPackage ../winapps {})]; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ + yad + (callPackage ../winapps { }) + ]; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - mkdir -p $out - cp -r ./Icons $out/Icons + mkdir -p $out + cp -r ./Icons $out/Icons - sed -E -i \ - -e "$(printf "%s$out%s" 's|^declare -rx ICONS_PATH="./Icons"|declare -rx ICONS_PATH="' '/Icons"|')" \ - WinAppsLauncher.sh + sed -E -i \ + -e "$(printf "%s$out%s" 's|^declare -rx ICONS_PATH="./Icons"|declare -rx ICONS_PATH="' '/Icons"|')" \ + WinAppsLauncher.sh - install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher - install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg + install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher + install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg - wrapProgram $out/bin/winapps-launcher \ - --set LIBVIRT_DEFAULT_URI "qemu:///system" \ - --prefix PATH : "${lib.makeBinPath buildInputs}" + wrapProgram $out/bin/winapps-launcher \ + --set LIBVIRT_DEFAULT_URI "qemu:///system" \ + --prefix PATH : "${lib.makeBinPath buildInputs}" - runHook postInstall - ''; + runHook postInstall + ''; - desktopItems = [ - (makeDesktopItem { - name = "winapps"; - exec = "winapps-launcher"; - icon = "winapps"; - comment = meta.description; - desktopName = "WinApps"; - categories = ["Utility"]; - }) - ]; + desktopItems = [ + (makeDesktopItem { + name = "winapps"; + exec = "winapps-launcher"; + icon = "winapps"; + comment = meta.description; + desktopName = "WinApps"; + categories = [ "Utility" ]; + }) + ]; - meta = with lib; { - homepage = "https://github.com/winapps-org/WinApps-Launcher"; - description = "Graphical launcher for WinApps. Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; - mainProgram = "winapps-launcher"; - platforms = platforms.linux; - license = licenses.gpl3; - }; - } + meta = with lib; { + homepage = "https://github.com/winapps-org/WinApps-Launcher"; + description = "Graphical launcher for WinApps. Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; + mainProgram = "winapps-launcher"; + platforms = platforms.linux; + license = licenses.gpl3; + }; +} diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 986c6dc..9730c67 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -9,67 +9,74 @@ netcat-gnu, iproute2, ... -}: let +}: +let rev = "7bae17e3a3607e6b93c7cfc4155dfbdca7bba005"; hash = "sha256-PP4POMwHCsAdiCxZkjXlON84F0Mg3Pd5bHEI6tC+Sds="; in - stdenv.mkDerivation rec { - pname = "winapps"; - version = "git+${rev}"; +stdenv.mkDerivation rec { + pname = "winapps"; + version = "git+${rev}"; - src = fetchFromGitHub { - owner = "winapps-org"; - repo = "winapps"; + src = fetchFromGitHub { + owner = "winapps-org"; + repo = "winapps"; - inherit rev hash; - }; + inherit rev hash; + }; - nativeBuildInputs = [makeWrapper]; - buildInputs = [freerdp3 libnotify dialog netcat-gnu iproute2]; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ + freerdp3 + libnotify + dialog + netcat-gnu + iproute2 + ]; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - patchShebangs install/inquirer.sh + mkdir -p $out + mkdir -p $out/src - mkdir -p $out - mkdir -p $out/src + patchShebangs install/inquirer.sh - cp -r ./ $out/src/ + sed -E -i \ + -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ + bin/winapps - install -m755 -D bin/winapps $out/bin/winapps - install -m755 -D setup.sh $out/bin/winapps-setup + sed -E -i \ + -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ + -e "$(printf "%s$out%s" 's|^readonly INQUIRER_PATH="./install/inquirer.sh"|readonly INQUIRER_PATH="' '/src/install/inquirer.sh"|')" \ + -e "$(printf "%s$out%s" 's|^readonly SYS_SOURCE_PATH="(.*?)"|readonly SYS_SOURCE_PATH="' '/src"|')" \ + -e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \ + -e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \ + -e 's|./setup.sh|winapps-setup|g' \ + -e 's|\$SUDO ln -s "./bin/winapps" "\$\{BIN_PATH\}/winapps"||' \ + -e 's|\$SUDO ln -s "./setup.sh" "\$\{BIN_PATH\}/winapps-setup"||' \ + -e "s|\$\{BIN_PATH\}/winapps|$out/bin/winapps|" \ + ./setup.sh - sed -E -i \ - -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - $out/bin/winapps + cp -r ./ $out/src/ - sed -E -i \ - -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - -e "$(printf "%s$out%s" 's|^readonly INQUIRER_PATH="./install/inquirer.sh"|readonly INQUIRER_PATH="' '/src/install/inquirer.sh"|')" \ - -e "$(printf "%s$out%s" 's|^readonly SYS_SOURCE_PATH="(.*?)"|readonly SYS_SOURCE_PATH="' '/src"|')" \ - -e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \ - -e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \ - -e 's|./setup.sh|winapps-setup|g' \ - -e 's|\$SUDO ln -s "./bin/winapps" "\$\{BIN_PATH\}/winapps"||' \ - -e 's|\$SUDO ln -s "./setup.sh" "\$\{BIN_PATH\}/winapps-setup"||' \ - -e "s|\$\{BIN_PATH\}/winapps|$out/bin/winapps|" \ - $out/bin/winapps-setup + install -m755 -D bin/winapps $out/bin/winapps + install -m755 -D setup.sh $out/bin/winapps-setup - for f in winapps-setup winapps; do - wrapProgram $out/bin/$f \ - --set LIBVIRT_DEFAULT_URI "qemu:///system" \ - --prefix PATH : "${lib.makeBinPath buildInputs}" - done + for f in winapps-setup winapps; do + wrapProgram $out/bin/$f \ + --set LIBVIRT_DEFAULT_URI "qemu:///system" \ + --prefix PATH : "${lib.makeBinPath buildInputs}" + done - runHook postInstall - ''; + runHook postInstall + ''; - meta = with lib; { - homepage = "https://github.com/winapps-org/winapps"; - description = "Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; - mainProgram = "winapps"; - platforms = platforms.linux; - license = licenses.gpl3; - }; - } + meta = with lib; { + homepage = "https://github.com/winapps-org/winapps"; + description = "Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; + mainProgram = "winapps"; + platforms = platforms.linux; + license = licenses.agpl3Plus; + }; +} From 28e958e60006df1a1a10f0b8946ad7f8b6c8627c Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:09:42 +0200 Subject: [PATCH 07/17] feat: use patches --- .../winapps-launcher/WinAppsLauncher.diff | 11 +++ packages/winapps-launcher/default.nix | 10 ++- packages/winapps/default.nix | 29 +++--- packages/winapps/setup.diff | 88 +++++++++++++++++++ packages/winapps/winapps.patch | 11 +++ 5 files changed, 127 insertions(+), 22 deletions(-) create mode 100644 packages/winapps-launcher/WinAppsLauncher.diff create mode 100644 packages/winapps/setup.diff create mode 100644 packages/winapps/winapps.patch diff --git a/packages/winapps-launcher/WinAppsLauncher.diff b/packages/winapps-launcher/WinAppsLauncher.diff new file mode 100644 index 0000000..962b1bf --- /dev/null +++ b/packages/winapps-launcher/WinAppsLauncher.diff @@ -0,0 +1,11 @@ +--- a/WinAppsLauncher.sh ++++ b/WinAppsLauncher.sh +@@ -19,7 +19,7 @@ declare -rx EC_WIN_NOT_SPEC=6 + declare -rx EC_NO_WIN_FOUND=7 + + # Paths +-declare -rx ICONS_PATH="./Icons" ++declare -rx ICONS_PATH="@out@/Icons" + declare -rx APPDATA_PATH="${HOME}/.local/share/winapps" + declare -rx CONFIG_PATH="${HOME}/.config/winapps" + declare -rx CONFIG_FILE="${CONFIG_PATH}/winapps.conf" diff --git a/packages/winapps-launcher/default.nix b/packages/winapps-launcher/default.nix index 362f428..cbe0b76 100644 --- a/packages/winapps-launcher/default.nix +++ b/packages/winapps-launcher/default.nix @@ -29,16 +29,18 @@ stdenv.mkDerivation rec { (callPackage ../winapps { }) ]; + patches = [ ./WinAppsLauncher.diff ]; + + postPatch = '' + substituteAllInPlace WinAppsLauncher.sh + ''; + installPhase = '' runHook preInstall mkdir -p $out cp -r ./Icons $out/Icons - sed -E -i \ - -e "$(printf "%s$out%s" 's|^declare -rx ICONS_PATH="./Icons"|declare -rx ICONS_PATH="' '/Icons"|')" \ - WinAppsLauncher.sh - install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 9730c67..ea8ea8b 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -34,30 +34,23 @@ stdenv.mkDerivation rec { iproute2 ]; + patches = [ + ./winapps.patch + ./setup.patch + ]; + + postPatch = '' + substituteAllInPlace bin/winapps + substituteAllInPlace setup.sh + patchShebangs install/inquirer.sh + ''; + installPhase = '' runHook preInstall mkdir -p $out mkdir -p $out/src - patchShebangs install/inquirer.sh - - sed -E -i \ - -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - bin/winapps - - sed -E -i \ - -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - -e "$(printf "%s$out%s" 's|^readonly INQUIRER_PATH="./install/inquirer.sh"|readonly INQUIRER_PATH="' '/src/install/inquirer.sh"|')" \ - -e "$(printf "%s$out%s" 's|^readonly SYS_SOURCE_PATH="(.*?)"|readonly SYS_SOURCE_PATH="' '/src"|')" \ - -e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \ - -e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \ - -e 's|./setup.sh|winapps-setup|g' \ - -e 's|\$SUDO ln -s "./bin/winapps" "\$\{BIN_PATH\}/winapps"||' \ - -e 's|\$SUDO ln -s "./setup.sh" "\$\{BIN_PATH\}/winapps-setup"||' \ - -e "s|\$\{BIN_PATH\}/winapps|$out/bin/winapps|" \ - ./setup.sh - cp -r ./ $out/src/ install -m755 -D bin/winapps $out/bin/winapps diff --git a/packages/winapps/setup.diff b/packages/winapps/setup.diff new file mode 100644 index 0000000..98aaece --- /dev/null +++ b/packages/winapps/setup.diff @@ -0,0 +1,88 @@ +--- a/setup.sh ++++ b/setup.sh +@@ -38,8 +38,8 @@ readonly SYS_BIN_PATH="/usr/local/bin" # UNIX path to 'bin' dir + readonly USER_BIN_PATH="${HOME}/.local/bin" # UNIX path to 'bin' directory for a '--user' WinApps installation. + readonly USER_BIN_PATH_WIN='\\tsclient\home\.local\bin' # WINDOWS path to 'bin' directory for a '--user' WinApps installation. + # 'SOURCE' +-readonly SYS_SOURCE_PATH="${SYS_BIN_PATH}/winapps" # UNIX path to WinApps source directory for a '--system' WinApps installation. +-readonly USER_SOURCE_PATH="${USER_BIN_PATH}/winapps" # UNIX path to WinApps source directory for a '--system' WinApps installation. ++readonly SYS_SOURCE_PATH="@out@/src" # UNIX path to WinApps source directory for a '--system' WinApps installation. ++readonly USER_SOURCE_PATH="@out@/src" # UNIX path to WinApps source directory for a '--system' WinApps installation. + # 'APP' + readonly SYS_APP_PATH="/usr/share/applications" # UNIX path to 'applications' directory for a '--system' WinApps installation. + readonly USER_APP_PATH="${HOME}/.local/share/applications" # UNIX path to 'applications' directory for a '--user' WinApps installation. +@@ -69,7 +69,7 @@ readonly TEST_PATH_WIN="${USER_APPDATA_PATH_WIN}\\FreeRDP_Connection_Test" # WIN + # 'WinApps Configuration File' + readonly CONFIG_PATH="${HOME}/.config/winapps/winapps.conf" # UNIX path to the WinApps configuration file. + # 'Inquirer Bash Script' +-readonly INQUIRER_PATH="./install/inquirer.sh" # UNIX path to the 'inquirer' script, which is used to produce selection menus. ++readonly INQUIRER_PATH="@out@/src/install/inquirer.sh" # UNIX path to the 'inquirer' script, which is used to produce selection menus. + + # REMOTE DESKTOP CONFIGURATION + readonly VM_NAME="RDPWindows" # Name of the Windows VM (FOR 'libvirt' ONLY). +@@ -129,13 +129,13 @@ function waTerminateScript() { + # Role: Displays usage information for the script. + function waUsage() { + echo -e "Usage: +- ${COMMAND_TEXT}./setup.sh --user${CLEAR_TEXT} # Install WinApps and selected applications in ${HOME} +- ${COMMAND_TEXT}./setup.sh --system${CLEAR_TEXT} # Install WinApps and selected applications in /usr +- ${COMMAND_TEXT}./setup.sh --user --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in ${HOME} +- ${COMMAND_TEXT}./setup.sh --system --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in /usr +- ${COMMAND_TEXT}./setup.sh --user --uninstall${CLEAR_TEXT} # Uninstall everything in ${HOME} +- ${COMMAND_TEXT}./setup.sh --system --uninstall${CLEAR_TEXT} # Uninstall everything in /usr +- ${COMMAND_TEXT}./setup.sh --help${CLEAR_TEXT} # Display this usage message." ++ ${COMMAND_TEXT}winapps-setup --user${CLEAR_TEXT} # Install WinApps and selected applications in ${HOME} ++ ${COMMAND_TEXT}winapps-setup --system${CLEAR_TEXT} # Install WinApps and selected applications in /usr ++ ${COMMAND_TEXT}winapps-setup --user --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in ${HOME} ++ ${COMMAND_TEXT}winapps-setup --system --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in /usr ++ ${COMMAND_TEXT}winapps-setup --user --uninstall${CLEAR_TEXT} # Uninstall everything in ${HOME} ++ ${COMMAND_TEXT}winapps-setup --system --uninstall${CLEAR_TEXT} # Uninstall everything in /usr ++ ${COMMAND_TEXT}winapps-setup --help${CLEAR_TEXT} # Display this usage message." + } + + # Name: 'waGetSourceCode' +@@ -158,7 +158,7 @@ function waGetSourceCode() { + $SUDO git clone --recurse-submodules --remote-submodules https://github.com/winapps-org/winapps.git "$SOURCE_PATH" + else + echo -e "${INFO_TEXT}WinApps installation already present at ${CLEAR_TEXT}${COMMAND_TEXT}${SOURCE_PATH}${CLEAR_TEXT}${INFO_TEXT}. Updating...${CLEAR_TEXT}" +- $SUDO git -C "$SOURCE_PATH" pull --no-rebase ++ + fi + + # Silently change the working directory. +@@ -385,7 +385,7 @@ function waCheckExistingInstall() { + + # Display the suggested action(s). + echo "--------------------------------------------------------------------------------" +- echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}./setup.sh --user --uninstall${CLEAR_TEXT}." ++ echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}winapps-setup --user --uninstall${CLEAR_TEXT}." + echo "--------------------------------------------------------------------------------" + + # Terminate the script. +@@ -405,7 +405,7 @@ function waCheckExistingInstall() { + + # Display the suggested action(s). + echo "--------------------------------------------------------------------------------" +- echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}./setup.sh --system --uninstall${CLEAR_TEXT}." ++ echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}winapps-setup --system --uninstall${CLEAR_TEXT}." + echo "--------------------------------------------------------------------------------" + + # Terminate the script. +@@ -800,7 +800,7 @@ function waCheckGroupMembership() { + # Identify groups the current user belongs to. + USER_GROUPS=$(groups "$(whoami)") + +- if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirt\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then ++ if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirtd\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then + # Complete the previous line. + echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n" + +@@ -1621,8 +1621,8 @@ function waInstall() { + waFindInstalled + + # Install the WinApps bash scripts. +- $SUDO ln -s "./bin/winapps" "${BIN_PATH}/winapps" +- $SUDO ln -s "./setup.sh" "${BIN_PATH}/winapps-setup" + + # Configure the Windows RDP session application launcher. + waConfigureWindows diff --git a/packages/winapps/winapps.patch b/packages/winapps/winapps.patch new file mode 100644 index 0000000..478d0ac --- /dev/null +++ b/packages/winapps/winapps.patch @@ -0,0 +1,11 @@ +--- a/bin/winapps ++++ b/bin/winapps +@@ -295,7 +295,7 @@ function waCheckGroupMembership() { + # shellcheck disable=SC2155 # Silence warnings regarding masking return values through simultaneous declaration and assignment. + local USER_GROUPS=$(groups "$(whoami)") + +- if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirt\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then ++ if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirtd\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then + waThrowExit "$EC_NOT_IN_GROUP" + fi + } From b044cb41c7eb1b6d6240d00007eee9acb82cf57f Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:12:22 +0200 Subject: [PATCH 08/17] fix: properly name patches & remove nixfmt pre-commit hook since it requires GHC & hackage --- .pre-commit-config.yaml | 6 ------ .../{WinAppsLauncher.diff => WinAppsLauncher.patch} | 0 packages/winapps-launcher/default.nix | 2 +- packages/winapps/{setup.diff => setup.patch} | 0 4 files changed, 1 insertion(+), 7 deletions(-) rename packages/winapps-launcher/{WinAppsLauncher.diff => WinAppsLauncher.patch} (100%) rename packages/winapps/{setup.diff => setup.patch} (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76a6cd0..b5f2edb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,5 @@ ci: autoupdate_branch: "rewrite" - skip: [nixfmt] repos: - repo: https://github.com/Lucas-C/pre-commit-hooks @@ -49,8 +48,3 @@ repos: rev: v0.10.0.1 hooks: - id: shellcheck - - - repo: https://github.com/NixOS/nixfmt - rev: d0c0cda4fe6b7ae2b9aa37f3ee15e6412573eb01 - hooks: - - id: nixfmt diff --git a/packages/winapps-launcher/WinAppsLauncher.diff b/packages/winapps-launcher/WinAppsLauncher.patch similarity index 100% rename from packages/winapps-launcher/WinAppsLauncher.diff rename to packages/winapps-launcher/WinAppsLauncher.patch diff --git a/packages/winapps-launcher/default.nix b/packages/winapps-launcher/default.nix index cbe0b76..6e1b263 100644 --- a/packages/winapps-launcher/default.nix +++ b/packages/winapps-launcher/default.nix @@ -29,7 +29,7 @@ stdenv.mkDerivation rec { (callPackage ../winapps { }) ]; - patches = [ ./WinAppsLauncher.diff ]; + patches = [ ./WinAppsLauncher.patch ]; postPatch = '' substituteAllInPlace WinAppsLauncher.sh diff --git a/packages/winapps/setup.diff b/packages/winapps/setup.patch similarity index 100% rename from packages/winapps/setup.diff rename to packages/winapps/setup.patch From 7f3cdcee4d209e2187d006fa6846f3d332f6fc77 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:50:55 +0200 Subject: [PATCH 09/17] fix: fix malformed patch --- .pre-commit-config.yaml | 2 ++ packages/winapps/default.nix | 4 ++-- packages/winapps/setup.patch | 34 ++++++++++++++++++---------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5f2edb..04d95f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,8 @@ ci: autoupdate_branch: "rewrite" +exclude: ^(.+)\.patch$ + repos: - repo: https://github.com/Lucas-C/pre-commit-hooks rev: v1.5.5 diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index ea8ea8b..3f50ce9 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -11,8 +11,8 @@ ... }: let - rev = "7bae17e3a3607e6b93c7cfc4155dfbdca7bba005"; - hash = "sha256-PP4POMwHCsAdiCxZkjXlON84F0Mg3Pd5bHEI6tC+Sds="; + rev = "07817afe0c2cad15c4eb90b5c94261a2b4d365d4"; + hash = "sha256-4KxssnSw1Xk6huKRpbRFw6NXIhjCoZYBzu/HYA1ngDM="; in stdenv.mkDerivation rec { pname = "winapps"; diff --git a/packages/winapps/setup.patch b/packages/winapps/setup.patch index 98aaece..cb2c22b 100644 --- a/packages/winapps/setup.patch +++ b/packages/winapps/setup.patch @@ -4,8 +4,8 @@ readonly USER_BIN_PATH="${HOME}/.local/bin" # UNIX path to 'bin' directory for a '--user' WinApps installation. readonly USER_BIN_PATH_WIN='\\tsclient\home\.local\bin' # WINDOWS path to 'bin' directory for a '--user' WinApps installation. # 'SOURCE' --readonly SYS_SOURCE_PATH="${SYS_BIN_PATH}/winapps" # UNIX path to WinApps source directory for a '--system' WinApps installation. --readonly USER_SOURCE_PATH="${USER_BIN_PATH}/winapps" # UNIX path to WinApps source directory for a '--system' WinApps installation. +-readonly SYS_SOURCE_PATH="${SYS_BIN_PATH}/winapps-src" # UNIX path to WinApps source directory for a '--system' WinApps installation. +-readonly USER_SOURCE_PATH="${USER_BIN_PATH}/winapps-src" # UNIX path to WinApps source directory for a '--system' WinApps installation. +readonly SYS_SOURCE_PATH="@out@/src" # UNIX path to WinApps source directory for a '--system' WinApps installation. +readonly USER_SOURCE_PATH="@out@/src" # UNIX path to WinApps source directory for a '--system' WinApps installation. # 'APP' @@ -17,7 +17,7 @@ # 'Inquirer Bash Script' -readonly INQUIRER_PATH="./install/inquirer.sh" # UNIX path to the 'inquirer' script, which is used to produce selection menus. +readonly INQUIRER_PATH="@out@/src/install/inquirer.sh" # UNIX path to the 'inquirer' script, which is used to produce selection menus. - + # REMOTE DESKTOP CONFIGURATION readonly VM_NAME="RDPWindows" # Name of the Windows VM (FOR 'libvirt' ONLY). @@ -129,13 +129,13 @@ function waTerminateScript() { @@ -39,50 +39,52 @@ + ${COMMAND_TEXT}winapps-setup --system --uninstall${CLEAR_TEXT} # Uninstall everything in /usr + ${COMMAND_TEXT}winapps-setup --help${CLEAR_TEXT} # Display this usage message." } - + # Name: 'waGetSourceCode' @@ -158,7 +158,7 @@ function waGetSourceCode() { $SUDO git clone --recurse-submodules --remote-submodules https://github.com/winapps-org/winapps.git "$SOURCE_PATH" else echo -e "${INFO_TEXT}WinApps installation already present at ${CLEAR_TEXT}${COMMAND_TEXT}${SOURCE_PATH}${CLEAR_TEXT}${INFO_TEXT}. Updating...${CLEAR_TEXT}" - $SUDO git -C "$SOURCE_PATH" pull --no-rebase -+ ++ fi - + # Silently change the working directory. @@ -385,7 +385,7 @@ function waCheckExistingInstall() { - + # Display the suggested action(s). echo "--------------------------------------------------------------------------------" - echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}./setup.sh --user --uninstall${CLEAR_TEXT}." + echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}winapps-setup --user --uninstall${CLEAR_TEXT}." echo "--------------------------------------------------------------------------------" - + # Terminate the script. @@ -405,7 +405,7 @@ function waCheckExistingInstall() { - + # Display the suggested action(s). echo "--------------------------------------------------------------------------------" - echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}./setup.sh --system --uninstall${CLEAR_TEXT}." + echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}winapps-setup --system --uninstall${CLEAR_TEXT}." echo "--------------------------------------------------------------------------------" - + # Terminate the script. @@ -800,7 +800,7 @@ function waCheckGroupMembership() { # Identify groups the current user belongs to. USER_GROUPS=$(groups "$(whoami)") - + - if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirt\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then + if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirtd\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then # Complete the previous line. echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n" - + @@ -1621,8 +1621,8 @@ function waInstall() { waFindInstalled - + # Install the WinApps bash scripts. -- $SUDO ln -s "./bin/winapps" "${BIN_PATH}/winapps" -- $SUDO ln -s "./setup.sh" "${BIN_PATH}/winapps-setup" - +- $SUDO ln -sf "${SOURCE_PATH}/bin/winapps" "${BIN_PATH}/winapps" +- $SUDO ln -sf "${SOURCE_PATH}/setup.sh" "${BIN_PATH}/winapps-setup" ++ ++ + # Configure the Windows RDP session application launcher. waConfigureWindows From 64478a87a49d6093f4d4f3a281bf0eecd2e6f977 Mon Sep 17 00:00:00 2001 From: chn Date: Sat, 5 Oct 2024 14:08:39 +0800 Subject: [PATCH 10/17] use netcat instead of netcat-gnu --- packages/winapps/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 3f50ce9..17a5435 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -6,7 +6,7 @@ freerdp3, dialog, libnotify, - netcat-gnu, + netcat, iproute2, ... }: @@ -30,7 +30,7 @@ stdenv.mkDerivation rec { freerdp3 libnotify dialog - netcat-gnu + netcat iproute2 ]; From e8dc55a83abd3eb6b275990fb19bdb589b6ce13d Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Sat, 5 Oct 2024 09:55:56 +0200 Subject: [PATCH 11/17] fix: typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7cf336b..1c98086 100644 --- a/README.md +++ b/README.md @@ -494,7 +494,7 @@ nix profile install github:winapps-org/winapps#winapps-launcher # optional nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; winapps = { - url = ""github:winapps-org/winapps; + url = "github:winapps-org/winapps"; inputs.nixpkgs.follows = "nixpkgs"; }; }; From 9d455ba753806fb3c42835dd5632306ad81ddbbd Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:49:32 +0200 Subject: [PATCH 12/17] feat: flake-compat --- .license-tools-config.json | 2 ++ README.md | 61 ++++++++++++++++++++++++++------------ default.nix | 16 ++++++++++ flake.lock | 15 ++++++++++ flake.nix | 7 +++++ 5 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 default.nix diff --git a/.license-tools-config.json b/.license-tools-config.json index c361afa..a7c368a 100644 --- a/.license-tools-config.json +++ b/.license-tools-config.json @@ -7,10 +7,12 @@ "style_override_for_suffix": { ".yaml": "POUND_STYLE", ".ps1": "POUND_STYLE", + ".nix": "POUND_STYLE", ".bat": "BATCH_STYLE", "": "POUND_STYLE" }, "exclude": [ + "flake.lock", "^\\.[^/]+", "/\\.[^/]+", "^(.+)\\.(md|svg|png|reg|gif)", diff --git a/README.md b/README.md index bc2a160..6783278 100644 --- a/README.md +++ b/README.md @@ -487,6 +487,7 @@ nix profile install github:winapps-org/winapps#winapps-launcher # optional ### On NixOS using Flakes ```nix +# flake.nix { description = "My configuration"; @@ -494,38 +495,60 @@ nix profile install github:winapps-org/winapps#winapps-launcher # optional nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; winapps = { - url = ""github:winapps-org/winapps; + url = "" "github:winapps-org/winapps"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { - nixpkgs, - winapps, - ... - }: { - nixosConfigurations.hostname = nixpkgs.lib.nixosSystem rec { - system = "x86_64-linux"; + outputs = + { + nixpkgs, + winapps, + ... + }: + { + nixosConfigurations.hostname = nixpkgs.lib.nixosSystem rec { + system = "x86_64-linux"; - modules = [ - ./configuration.nix - ({pkgs, ...}: { - environment.systemPackages = [ - winapps.packages.${system}.winapps - winapps.packages.${system}.winapps-launcher # optional - ]; - }) - ]; + modules = [ + ./configuration.nix + ( + { pkgs, ... }: + { + environment.systemPackages = [ + winapps.packages.${system}.winapps + winapps.packages.${system}.winapps-launcher # optional + ]; + } + ) + ]; + }; }; - }; } ``` ### On NixOS without Flakes [Flakes aren't real and they can't hurt you.](https://jade.fyi/blog/flakes-arent-real/). -See https://wiki.nixos.org/wiki/Flakes#Using_nix_flakes_with_NixOS on how to enable Flakes on your system. +However, if you still don't want to use flakes, you can use WinApps with flake-compat like: +```nix +# configuration.nix +{ ... }: +{ + + environment.systemPackages = + let + winapps = + (import (builtins.fetchTarball "https://github.com/winapps-org/winapps/archive/main.tar.gz")) + .packages."${system}"; + in + [ + winapps.winapps + winapps.winapps-launcher # optional + ]; +} +``` ## Star History diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..0cd5241 --- /dev/null +++ b/default.nix @@ -0,0 +1,16 @@ +# Copyright (c) 2024 Oskar Manhart +# All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = + lock.nodes.flake-compat.locked.url + or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).defaultNix diff --git a/flake.lock b/flake.lock index b07995a..dc621f0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,19 @@ { "nodes": { + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -36,6 +50,7 @@ }, "root": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 5bf6d8f..22c8b5c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,15 @@ +# Copyright (c) 2024 Oskar Manhart +# All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0-or-later + { description = "WinApps Nix packages & NixOS module"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; flake-utils.url = "github:numtide/flake-utils"; }; From e630b5a89843a0fdae4beee6b694888e4f890bc4 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:03:55 +0200 Subject: [PATCH 13/17] feat: update packages --- packages/winapps-launcher/default.nix | 11 ++++++++--- packages/winapps/default.nix | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/winapps-launcher/default.nix b/packages/winapps-launcher/default.nix index 6e1b263..30982ff 100644 --- a/packages/winapps-launcher/default.nix +++ b/packages/winapps-launcher/default.nix @@ -1,3 +1,8 @@ +# Copyright (c) 2024 Oskar Manhart +# All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0-or-later + { stdenv, lib, @@ -9,12 +14,12 @@ ... }: let - rev = "eaa660d39bf3f49b136c98c87c35e3e12f118f8f"; - hash = "sha256-7lkx/O4dOdVqAPX6s2IkkM6Ggbzmz9sm++20BBeoUQ4="; + rev = "9f5fbcb57f2932b260202fb582f9adcf28df5f1c"; + hash = "sha256-cShXlcFHTryxKLKxdoqZSge2oyGgeuFPW9Nxg+gSjB4="; in stdenv.mkDerivation rec { pname = "winapps-launcher"; - version = "git+${rev}"; + version = "0-unstable-${rev}"; src = fetchFromGitHub { owner = "winapps-org"; diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 17a5435..4f769b9 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -1,3 +1,8 @@ +# Copyright (c) 2024 Oskar Manhart +# All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0-or-later + { stdenv, lib, @@ -11,12 +16,12 @@ ... }: let - rev = "07817afe0c2cad15c4eb90b5c94261a2b4d365d4"; - hash = "sha256-4KxssnSw1Xk6huKRpbRFw6NXIhjCoZYBzu/HYA1ngDM="; + rev = "c8dcccad08b3e5489d78f2aad034189d8654745c"; + hash = "sha256-RM9jv8oS8wKcSJpvkFFG9uyiRv9EaLQWANymGTXdl4o="; in stdenv.mkDerivation rec { pname = "winapps"; - version = "git+${rev}"; + version = "0-unstable-${rev}"; src = fetchFromGitHub { owner = "winapps-org"; From 7277f71b9c3806a4aee3b9ad65815a7ea619c0b1 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:04:17 +0200 Subject: [PATCH 14/17] feat: auto-update flake weekly --- .github/workflows/update-nix.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/update-nix.yaml diff --git a/.github/workflows/update-nix.yaml b/.github/workflows/update-nix.yaml new file mode 100644 index 0000000..8203da5 --- /dev/null +++ b/.github/workflows/update-nix.yaml @@ -0,0 +1,19 @@ +name: "Update Flake Packages" + +on: + workflow_dispatch: + schedule: + - cron: "0 10 * * 0" # https://crontab.guru/#0_10_*_*_0 + +jobs: + updateFlakePackages: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Nix + uses: cachix/install-nix-action@v20 + + - name: Update flake packages + uses: selfuryon/nix-update-action@v1 From df54d0895542ee480218fb27b32b3bb094b62525 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:07:29 +0200 Subject: [PATCH 15/17] feat: properly set versions --- packages/winapps-launcher/default.nix | 2 +- packages/winapps/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/winapps-launcher/default.nix b/packages/winapps-launcher/default.nix index 30982ff..2af26ac 100644 --- a/packages/winapps-launcher/default.nix +++ b/packages/winapps-launcher/default.nix @@ -19,7 +19,7 @@ let in stdenv.mkDerivation rec { pname = "winapps-launcher"; - version = "0-unstable-${rev}"; + version = "0-unstable-2024-10-01"; src = fetchFromGitHub { owner = "winapps-org"; diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 4f769b9..27bc193 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -21,7 +21,7 @@ let in stdenv.mkDerivation rec { pname = "winapps"; - version = "0-unstable-${rev}"; + version = "0-unstable-2024-10-09"; src = fetchFromGitHub { owner = "winapps-org"; From 2dafe2d7a1b3ebdaf44db411f50bf33ce07c77fb Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:22:18 +0100 Subject: [PATCH 16/17] fix: iron out some more issues This addresses the issues in https://github.com/winapps-org/winapps/pull/234#discussion_r1813582112 and closes #299. --- packages/winapps/setup.patch | 56 ++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/packages/winapps/setup.patch b/packages/winapps/setup.patch index cb2c22b..b4c90e8 100644 --- a/packages/winapps/setup.patch +++ b/packages/winapps/setup.patch @@ -1,6 +1,8 @@ +diff --git a/setup.sh b/setup.sh +index 6aa9b574..66b2e920 100755 --- a/setup.sh +++ b/setup.sh -@@ -38,8 +38,8 @@ readonly SYS_BIN_PATH="/usr/local/bin" # UNIX path to 'bin' dir +@@ -48,8 +48,8 @@ readonly SYS_BIN_PATH="/usr/local/bin" # UNIX path to 'bin' dir readonly USER_BIN_PATH="${HOME}/.local/bin" # UNIX path to 'bin' directory for a '--user' WinApps installation. readonly USER_BIN_PATH_WIN='\\tsclient\home\.local\bin' # WINDOWS path to 'bin' directory for a '--user' WinApps installation. # 'SOURCE' @@ -11,7 +13,7 @@ # 'APP' readonly SYS_APP_PATH="/usr/share/applications" # UNIX path to 'applications' directory for a '--system' WinApps installation. readonly USER_APP_PATH="${HOME}/.local/share/applications" # UNIX path to 'applications' directory for a '--user' WinApps installation. -@@ -69,7 +69,7 @@ readonly TEST_PATH_WIN="${USER_APPDATA_PATH_WIN}\\FreeRDP_Connection_Test" # WIN +@@ -79,7 +79,7 @@ readonly TEST_PATH_WIN="${USER_APPDATA_PATH_WIN}\\FreeRDP_Connection_Test" # WIN # 'WinApps Configuration File' readonly CONFIG_PATH="${HOME}/.config/winapps/winapps.conf" # UNIX path to the WinApps configuration file. # 'Inquirer Bash Script' @@ -20,7 +22,7 @@ # REMOTE DESKTOP CONFIGURATION readonly VM_NAME="RDPWindows" # Name of the Windows VM (FOR 'libvirt' ONLY). -@@ -129,13 +129,13 @@ function waTerminateScript() { +@@ -139,13 +139,13 @@ function waTerminateScript() { # Role: Displays usage information for the script. function waUsage() { echo -e "Usage: @@ -41,7 +43,7 @@ } # Name: 'waGetSourceCode' -@@ -158,7 +158,7 @@ function waGetSourceCode() { +@@ -168,7 +168,7 @@ function waGetSourceCode() { $SUDO git clone --recurse-submodules --remote-submodules https://github.com/winapps-org/winapps.git "$SOURCE_PATH" else echo -e "${INFO_TEXT}WinApps installation already present at ${CLEAR_TEXT}${COMMAND_TEXT}${SOURCE_PATH}${CLEAR_TEXT}${INFO_TEXT}. Updating...${CLEAR_TEXT}" @@ -50,7 +52,7 @@ fi # Silently change the working directory. -@@ -385,7 +385,7 @@ function waCheckExistingInstall() { +@@ -395,7 +395,7 @@ function waCheckExistingInstall() { # Display the suggested action(s). echo "--------------------------------------------------------------------------------" @@ -59,7 +61,7 @@ echo "--------------------------------------------------------------------------------" # Terminate the script. -@@ -405,7 +405,7 @@ function waCheckExistingInstall() { +@@ -415,7 +415,7 @@ function waCheckExistingInstall() { # Display the suggested action(s). echo "--------------------------------------------------------------------------------" @@ -68,7 +70,7 @@ echo "--------------------------------------------------------------------------------" # Terminate the script. -@@ -800,7 +800,7 @@ function waCheckGroupMembership() { +@@ -810,7 +810,7 @@ function waCheckGroupMembership() { # Identify groups the current user belongs to. USER_GROUPS=$(groups "$(whoami)") @@ -77,7 +79,37 @@ # Complete the previous line. echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n" -@@ -1621,8 +1621,8 @@ function waInstall() { +@@ -1244,11 +1244,11 @@ function waConfigureWindows() { + # Populate variables. + WIN_BASH="\ + #!/usr/bin/env bash +-${BIN_PATH}/winapps windows" ++@out@/bin/winapps windows" + WIN_DESKTOP="\ + [Desktop Entry] + Name=Windows +-Exec=${BIN_PATH}/winapps windows %F ++Exec=@out/bin/winapps windows %F + Terminal=false + Type=Application + Icon=${APPDATA_PATH}/icons/windows.svg +@@ -1295,13 +1295,13 @@ function waConfigureApp() { + # Determine the content of the bash script for the application. + APP_BASH="\ + #!/usr/bin/env bash +-${BIN_PATH}/winapps ${1}" ++@out@/bin/winapps ${1}" + + # Determine the content of the '.desktop' file for the application. + APP_DESKTOP_FILE="\ + [Desktop Entry] + Name=${NAME} +-Exec=${BIN_PATH}/winapps ${1} %F ++Exec=@out@/bin/winapps ${1} %F + Terminal=false + Type=Application + Icon=${APP_ICON} +@@ -1631,8 +1631,8 @@ function waInstall() { waFindInstalled # Install the WinApps bash scripts. @@ -88,3 +120,11 @@ # Configure the Windows RDP session application launcher. waConfigureWindows +@@ -1687,6 +1687,7 @@ function waUninstall() { + $SUDO rm -f "${BIN_PATH}/winapps-setup" + + # Remove WinApps configuration data, temporary files and logs. ++ chmod -R o+rw "$USER_APPDATA_PATH" + rm -rf "$USER_APPDATA_PATH" + + # Remove application icons and shortcuts. From b18efc4497c0994182bbe482808583c11cc51a2e Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:23:11 +0100 Subject: [PATCH 17/17] fix: don't change mode for owner but for current user --- packages/winapps/setup.patch | 43 ++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/packages/winapps/setup.patch b/packages/winapps/setup.patch index b4c90e8..18124b6 100644 --- a/packages/winapps/setup.patch +++ b/packages/winapps/setup.patch @@ -1,5 +1,5 @@ diff --git a/setup.sh b/setup.sh -index 6aa9b574..66b2e920 100755 +index 6aa9b574..9fbefe65 100755 --- a/setup.sh +++ b/setup.sh @@ -48,8 +48,8 @@ readonly SYS_BIN_PATH="/usr/local/bin" # UNIX path to 'bin' dir @@ -120,11 +120,46 @@ index 6aa9b574..66b2e920 100755 # Configure the Windows RDP session application launcher. waConfigureWindows -@@ -1687,6 +1687,7 @@ function waUninstall() { - $SUDO rm -f "${BIN_PATH}/winapps-setup" +@@ -1682,18 +1682,15 @@ function waUninstall() { + local DESKTOP_FILE_NAME="" # Stores the name of the '.desktop' file for the application. + local BASH_SCRIPT_NAME="" # Stores the name of the application. +- # Remove the 'WinApps' bash scripts. +- $SUDO rm -f "${BIN_PATH}/winapps" +- $SUDO rm -f "${BIN_PATH}/winapps-setup" +- # Remove WinApps configuration data, temporary files and logs. -+ chmod -R o+rw "$USER_APPDATA_PATH" ++ chmod -R +rw "$USER_APPDATA_PATH" rm -rf "$USER_APPDATA_PATH" # Remove application icons and shortcuts. + $SUDO rm -rf "$APPDATA_PATH" + + # Store '.desktop' files containing "${BIN_PATH}/winapps" in an array, returning an empty array if no such files exist. +- readarray -t WINAPPS_DESKTOP_FILES < <(grep -l -d skip "${BIN_PATH}/winapps" "${APP_PATH}/"* 2>/dev/null || true) ++ readarray -t WINAPPS_DESKTOP_FILES < <(grep -l -d skip "@out@/bin/winapps" "${APP_PATH}/"* 2>/dev/null || true) + + # Remove each '.desktop' file. + for DESKTOP_FILE_PATH in "${WINAPPS_DESKTOP_FILES[@]}"; do +@@ -1714,7 +1711,7 @@ function waUninstall() { + done + + # Store the paths of bash scripts calling 'WinApps' to launch specific applications in an array, returning an empty array if no such files exist. +- readarray -t WINAPPS_APP_BASH_SCRIPTS < <(grep -l -d skip "${BIN_PATH}/winapps" "${BIN_PATH}/"* 2>/dev/null || true) ++ readarray -t WINAPPS_APP_BASH_SCRIPTS < <(grep -l -d skip "@out@/bin/winapps" "${BIN_PATH}/"* 2>/dev/null || true) + + # Remove each bash script. + for BASH_SCRIPT_PATH in "${WINAPPS_APP_BASH_SCRIPTS[@]}"; do +@@ -1735,10 +1732,9 @@ function waUninstall() { + done + + # Print caveats. +- echo -e "\n${INFO_TEXT}Please note that your WinApps configuration and the WinApps source code were not removed.${CLEAR_TEXT}" +- echo -e "${INFO_TEXT}You can remove these manually by running:${CLEAR_TEXT}" ++ echo -e "\n${INFO_TEXT}Please note that your WinApps configuration and the WinApps package were not removed.${CLEAR_TEXT}" ++ echo -e "${INFO_TEXT}You can remove your config manually by running:${CLEAR_TEXT}" + echo -e "${COMMAND_TEXT}rm -r $(dirname "$CONFIG_PATH")${CLEAR_TEXT}" +- echo -e "${COMMAND_TEXT}rm -r ${SOURCE_PATH}${CLEAR_TEXT}\n" + + # Print feedback. + echo -e "${SUCCESS_TEXT}UNINSTALLATION COMPLETE.${CLEAR_TEXT}"