Skip to content

Commit

Permalink
Merge pull request #234 from winapps-org/feat-nix-packaging
Browse files Browse the repository at this point in the history
Package WinApps (and the Launcher) with Nix
  • Loading branch information
oskardotglobal authored Nov 1, 2024
2 parents b49979e + b18efc4 commit e93cf9a
Show file tree
Hide file tree
Showing 12 changed files with 580 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/update-nix.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .license-tools-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ ci:
autoupdate_branch: "rewrite"
skip: [license-tools]

exclude: ^(.+)\.patch$

repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
Expand Down
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,93 @@ 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
# flake.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/).
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
<a href="https://star-history.com/#winapps-org/winapps&Date">
<picture>
Expand Down
16 changes: 16 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions flake.lock

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

34 changes: 34 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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";
};

outputs =
{
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
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 { };
}
);
}
11 changes: 11 additions & 0 deletions packages/winapps-launcher/WinAppsLauncher.patch
Original file line number Diff line number Diff line change
@@ -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"
77 changes: 77 additions & 0 deletions packages/winapps-launcher/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright (c) 2024 Oskar Manhart
# All rights reserved.
#
# SPDX-License-Identifier: AGPL-3.0-or-later

{
stdenv,
lib,
fetchFromGitHub,
makeWrapper,
makeDesktopItem,
callPackage,
yad,
...
}:
let
rev = "9f5fbcb57f2932b260202fb582f9adcf28df5f1c";
hash = "sha256-cShXlcFHTryxKLKxdoqZSge2oyGgeuFPW9Nxg+gSjB4=";
in
stdenv.mkDerivation rec {
pname = "winapps-launcher";
version = "0-unstable-2024-10-01";

src = fetchFromGitHub {
owner = "winapps-org";
repo = "WinApps-Launcher";

inherit rev hash;
};

nativeBuildInputs = [ makeWrapper ];
buildInputs = [
yad
(callPackage ../winapps { })
];

patches = [ ./WinAppsLauncher.patch ];

postPatch = ''
substituteAllInPlace WinAppsLauncher.sh
'';

installPhase = ''
runHook preInstall
mkdir -p $out
cp -r ./Icons $out/Icons
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;
};
}
Loading

0 comments on commit e93cf9a

Please sign in to comment.