Skip to content

mrshmllow/affinity-nix

Repository files navigation

affinity-nix

image

About

Affinity v3 & v2 packaged with Nix!

Based on https://github.com/lf-/affinity-crimes and https://affinity.liz.pet/, and uses ElementalWarrior's wine.

We also install https://github.com/noahc3/AffinityPluginLoader for a far more pleasant experience.

There is a sister project which allows you to run these packages on any Linux distro through AppImages, affinity-everywhere.

Recent Breaking Changes

With the release of v3, there has been some changes:

  • Packages {wine,wineboot,wineserver,winetricks} have been removed. There are instructions below to access these binaries.
  • Packages {update,direct}* have been removed. There are instructions below to update the apps.
  • Since v3 was unified into a single application, {photo,designer,publisher} remain the way to access v2 affinity, with v3 becoming the package to access the v3 application.
  • Additionally, the default package now points to v3.

Preamble

Tip

Add garnix as a substituter to avoid compiling yourself.

Note

This repo does not attempt to redistribute affinity archives. Any instance of caching Canva IP should be reported as a bug.

User preferences are located in $XDG_DATA_HOME/affinity/ or $XDG_DATA_HOME/affinity-v3/ falling back to $HOME/.local/share/affinity/ or $HOME/.local/share/affinity-v3/.

How it works

A wine prefix containing all the necessary dependencies and the affinity installation is built in nix and mounted at runtime. Overlayfs is used to keep your user preferences intact. fuse-overlayfs will be fallen back on if your kernel rejects unprivileged user namespaces, common on hardened systems. This can reduce performance.

graph LR;
    A([Winetricks])-.->B[Nix Store];
    C([Affinity])-.->B;
    D([Wine])-.->B;

    B e1@-->E[Overlayfs];
    F[User Data] e2@<-->E;

    E<-- Mounted @ Runtime -->G[Affinity Application];
Loading

Usage Instructions

Running Ad-hoc

$ nix run github:mrshmllow/affinity-nix#v3

-- v2 versions:

$ nix run github:mrshmllow/affinity-nix#photo
$ nix run github:mrshmllow/affinity-nix#designer
$ nix run github:mrshmllow/affinity-nix#publisher

Installing the applications on your system (Optional)

Install with nix-profile

$ nix profile install github:mrshmllow/affinity-nix#v3

-- v2 versions:

$ nix profile install github:mrshmllow/affinity-nix#photo
$ nix profile install github:mrshmllow/affinity-nix#designer
$ nix profile install github:mrshmllow/affinity-nix#publisher

Install on NixOS / Home Manager

Install on NixOS

The following is an example. Installing this package does not differ to installing a package from any other flake.

{
  inputs = {
    affinity-nix.url = "github:mrshmllow/affinity-nix";
    # ...
  };

  outputs = inputs @ {
    affinity-nix,
    ...
  }: {
    nixosConfigurations.my-system = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = {inherit inputs;};
      modules = [
        # ...
        {
          environment.systemPackages = [affinity-nix.packages.x86_64-linux.v3];
        }
      ];
    };
  }
}
Install with Home Manager

The following is an example. Installing this package does not differ to installing a package from any other flake.

{
  inputs = {
    affinity-nix.url = "github:mrshmllow/affinity-nix";
    # ...
  };

  outputs = inputs @ {
    affinity-nix,
    ...
  }: {
    homeConfigurations.my-user = home-manager.lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages."x86_64-linux";
      extraSpecialArgs = {inherit inputs;};
      modules = [
        # ...
        {
          home.packages = [affinity-nix.packages.x86_64-linux.v3];
        }
      ];
    };
  }
}

Troubleshooting, winetricks, wineboot, and more

Each package (v3|photo|designer|publisher) has the following usage:

$ affinity-v3 --help
Usage: affinity-v3 [COMMAND] [OPTIONS]

Commands:
  wine
  winetricks
  wineboot
  wineserver
  help                    Show this
  (nothing)               Launch Affinity v3

Tip

Armed with these you should be able to follow https://affinity.liz.pet/v2/misc-troubleshooting/ for troubleshooting steps.

For example, accessing wine:

$ affinity-v3 wine
Usage: wine PROGRAM [ARGUMENTS...]   Run the specified program
       wine --help                   Display this help and exit
       wine --version                Output version information and exit

Or winecfg:

$ affinity-v3 wine winecfg

Driver Support

I (the maintainer of this repo) currently only have an AMD GPU to test OpenCL support for Affinity. On AMD, I can attest that

hardware.amdgpu.opencl.enable = true;

appears to be all that is required to get OpenCL to work with affinity-nix.

Sponsor this project

 

Contributors