Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package WinApps (and the Launcher) with Nix #234

Merged
merged 22 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
da35923
feat: package winapps & the winapps launcher using nix
oskardotglobal Aug 30, 2024
00141f1
fix: do not symlink binaries on nix
oskardotglobal Sep 7, 2024
26a2f13
feat: bump version
oskardotglobal Sep 7, 2024
b7b5b34
Merge branch 'main' into feat-nix-packaging
oskardotglobal Sep 8, 2024
f4c0a45
fix: properly escape ${}
oskardotglobal Sep 8, 2024
b0f2830
feat: bump version
oskardotglobal Sep 8, 2024
7d5cce3
feat: use nixfmt
oskardotglobal Sep 9, 2024
28e958e
feat: use patches
oskardotglobal Sep 9, 2024
b044cb4
fix: properly name patches & remove nixfmt pre-commit hook since it r…
oskardotglobal Sep 9, 2024
60b3e80
Merge remote-tracking branch 'origin/main' into feat-nix-packaging
oskardotglobal Sep 9, 2024
7f3cdce
fix: fix malformed patch
oskardotglobal Sep 9, 2024
509a782
Merge branch 'main' into feat-nix-packaging
oskardotglobal Sep 14, 2024
64478a8
use netcat instead of netcat-gnu
CHN-beta Oct 5, 2024
d248abc
Merge pull request #281 from CHN-beta/feat-nix-packaging
oskardotglobal Oct 5, 2024
e8dc55a
fix: typo
oskardotglobal Oct 5, 2024
9d455ba
feat: flake-compat
oskardotglobal Oct 22, 2024
e8fbc95
Merge branch 'feat-nix-packaging' of github.com:winapps-org/winapps i…
oskardotglobal Oct 22, 2024
e630b5a
feat: update packages
oskardotglobal Oct 22, 2024
7277f71
feat: auto-update flake weekly
oskardotglobal Oct 22, 2024
df54d08
feat: properly set versions
oskardotglobal Oct 22, 2024
2dafe2d
fix: iron out some more issues
oskardotglobal Oct 30, 2024
b18efc4
fix: don't change mode for owner but for current user
oskardotglobal Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,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 by running `winapps-setup`.

## 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;
oskardotglobal marked this conversation as resolved.
Show resolved Hide resolved
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/).
oskardotglobal marked this conversation as resolved.
Show resolved Hide resolved
See https://wiki.nixos.org/wiki/Flakes#Using_nix_flakes_with_NixOS on how to enable Flakes on your system.


## Star History
<a href="https://star-history.com/#winapps-org/winapps&Date">
<picture>
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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 {};
}
);
}
66 changes: 66 additions & 0 deletions packages/winapps-launcher/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
75 changes: 75 additions & 0 deletions packages/winapps/default.nix
oskardotglobal marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
stdenv,
lib,
fetchFromGitHub,
makeWrapper,
freerdp3,
dialog,
libnotify,
netcat-gnu,
iproute2,
...
}: let
rev = "7bae17e3a3607e6b93c7cfc4155dfbdca7bba005";
hash = "sha256-PP4POMwHCsAdiCxZkjXlON84F0Mg3Pd5bHEI6tC+Sds=";
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
AkechiShiro marked this conversation as resolved.
Show resolved Hide resolved
install -m755 -D setup.sh $out/bin/winapps-setup

sed -E -i \
oskardotglobal marked this conversation as resolved.
Show resolved Hide resolved
-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' \
-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
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;
oskardotglobal marked this conversation as resolved.
Show resolved Hide resolved
};
}