Plex on aarch64

This PR makes the plex derivation leverage buildFHSUserEnv. As far as I can tell, buildFHSUserEnv is built to handle x86 and x86_64, but not other architectures. Trying to use Plex on aarch64 like this:

{ config, pkgs, lib, ... }:

let
  # ... other config elided ...
in {
  # ... other stanzas elided ...
  services.plex = {
    enable = true;
  };
}

… leads to this:

# nixos-rebuild switch
building Nix...
building the system configuration...
error: i686 Linux package set can only be used with the x86 family.
(use '--show-trace' to show detailed location information)

I’ve tried masking/overriding either pkgsi686Linux or buildFHSEnv like this:

{ config, pkgs, lib, ... }:

let
  # ...
  pkgsi686Linux = abort "fail on pkgsi686Linux";
  buildFHSEnv = abort "fail on buildFHSEnv";
in {
  # ... other stanzas elided ...
  services.plex = {
    enable = true;
  };
}

… in the hopes that I could actually define something like this (rather than just abort):

buildFHSEnv = args@{...}: buildFHSEnv (args // { multiPkgs = null; });

… to bypass the multi-arch logic, but it always seems to use the real/underlying implementation during the package installation (whether I just try to abort or actually define something that might do something useful). What am I doing wrong here? Should I be trying to redefine/wrap buildFHSEnv, or is there a better approach?

I ended up just using a Plex docker image instead:

  virtualisation.docker.enable = true;

  virtualisation.oci-containers.containers."plex" = {
    environment = {
      TZ = "America/Vancouver";
      PUID = toString config.users.users.plex.uid;
      PGID = toString config.users.groups.media.gid;
      PLEX_CLAIM = "claim-Sfksdf-U5_8_FSDfSDFy";
      VERSION = "latest";
    };
    extraOptions = [ "--network=host" ];
    image = "linuxserver/plex";
    volumes = [
      "/mnt/media/plex-config:/config"
      "/mnt/media:/media"
    ];
  };

This would probably be nice to sort out for other derivations that make use of buildFHSEnv; but alas, I haven’t hit any of those other cases on aarch64 yet.

Really, we should make it so that buildFHSUserEnv isn’t x86 specific, the underlying bubblewrap program and kernel features are usable outside of x86

2 Likes

Actually, I just made a PR to not bring in x86 only packages here: plex: allow use on non-x86 platforms by jonringer · Pull Request #132963 · NixOS/nixpkgs · GitHub

3 Likes

related as well? buildFHSUserEnvBubblewrap: generalize for non-x86_64 by ehmry · Pull Request #110303 · NixOS/nixpkgs · GitHub

Wow, that’s essentially what I wrote first, I guess I mis-typed is64bit as is64Bit

Can you tell me if any other solution besides docker is currently available?

services.plex.enable = true;

2 Likes

I’ve been trying to get services.plex.enable = true; to work, with the same error (error: i686 Linux package set can only be used with the x86 family.). Any pointers is appreciated.

I build with nixos-rebuild --flake '.#'

My flake.nix:

{
  outputs = { self, nixpkgs }: {
    nixosConfigurations.machine = nixpkgs.lib.nixosSystem {
      system = "aarch64-linux";
      modules = [ ./hosts/sombrero/configuration.nix ];
    };
  };
}

Pinning the nixpkgs in my flake.nix did not help

inputs = {
   nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
 };
nix-repl> stdenv.hostPlatform.system
"aarch64-linux"
> nix-info -m
 - system: `"aarch64-linux"`
 - host os: `Linux 5.15.74, NixOS, 23.05 (Stoat), 23.05.20230106.b3818a4`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.12.0`
 - channels(alex): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

@7NGmHwik I’m just pinning it to the last commit I found that isn’t broken e.g.

let 
  plex = fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/0874168639713f547c05947c76124f78441ea46c.tar.gz";
    sha256 = "0gw5l5bj3zcgxhp7ki1jafy6sl5nk4vr43hal94lhi15kg2vfmfy";
  };
in
{
  disabledModules = [
    "services/misc/plex.nix"
  ];

  imports = 
  [ 
    "${plex}/nixos/modules/services/misc/plex.nix"
  ];

  services.plex = {
    enable = true;
    package = (import plex {
      inherit system;
      config = { allowUnfree = true; };
    }).plex;
  };

}
1 Like