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

plex: use buildFHSUserEnv #38767

Closed
wants to merge 2 commits into from
Closed

Conversation

lukateras
Copy link
Member

@lukateras lukateras commented Apr 11, 2018

Fixes #25502. NixOS module is not tested yet.

/cc @mkaito @izuk @thanegill

@mkaito
Copy link
Contributor

mkaito commented May 2, 2018

Haven't been able to get this to run. Something about chdir path not found in the logs. Would be nice if it said what path that is. Guess I'll have to strace this thing to find out.

@colemickens
Copy link
Member

Sorry, I had failed to cherry-pick both commits properly. When I do so, I'm back to basically getting zero useful output from the journal. This is literally all I get now:

May 30 14:35:03 chimera systemd[1]: Starting Plex Media Server...
May 30 14:35:03 chimera plex-pre-start[28065]: Preparing plugin directory.
May 30 14:35:03 chimera plex-pre-start[28065]: Removing old symlinks.
May 30 14:35:03 chimera plex-pre-start[28065]: Symlinking plugins.
May 30 14:35:03 chimera systemd[1]: Started Plex Media Server.
May 30 14:35:04 chimera systemd[1]: plex.service: Main process exited, code=exited, status=255/n/a
May 30 14:35:04 chimera systemd[1]: plex.service: Failed with result 'exit-code'.
May 30 14:35:04 chimera systemd[1]: plex.service: Service hold-off time over, scheduling restart.
May 30 14:35:04 chimera systemd[1]: plex.service: Scheduled restart job, restart counter is at 5.
May 30 14:35:04 chimera systemd[1]: Stopped Plex Media Server.
May 30 14:35:04 chimera systemd[1]: plex.service: Start request repeated too quickly.
May 30 14:35:04 chimera systemd[1]: plex.service: Failed with result 'exit-code'.

@colemickens
Copy link
Member

With this PR applied, if I run ExecStartPre and then ExecStart, the server seems to startup, but it doesn't have access to the existing data, as its running me through a first time install. Maybe this is due to me executing the commands one after another in a regular shell, rather than how systemd runs them.

Either way, I'm not sure how to proceed debugging the systemd unit that is emitted for plex to get it to start properly.

@lukateras lukateras closed this Jun 12, 2018
@lukateras lukateras reopened this Jun 12, 2018
@lukateras lukateras force-pushed the 20180411.101856/plex branch 4 times, most recently from 1ccca68 to 654f3bf Compare June 18, 2018 02:08
@lukateras lukateras changed the title [WIP] plex: use buildFHSUserEnv plex: use buildFHSUserEnv Jun 18, 2018
@colemickens
Copy link
Member

This is now working great for me. Thank you very much!

vsnHash = plexpkg.vsnHash;
sha256 = plexpkg.sha256;
name = "plexmediaserver-${version}";
version = "1.9.6.4429-23901a099";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only thing I noticed, this is a major step back in terms of version.

The latest publicly available release works fine.

diff --git a/pkgs/servers/plex/default.nix b/pkgs/servers/plex/default.nix
index 4ce1410e46a..247eb7ad737 100644
--- a/pkgs/servers/plex/default.nix
+++ b/pkgs/servers/plex/default.nix
@@ -2,11 +2,11 @@

let
  name = "plexmediaserver-${version}";
-  version = "1.9.6.4429-23901a099";
+  version = "1.13.2.5154-fd05be322";                                                                                                                                                       

  src = fetchurl {                                                                                                                                                                              url = "https://downloads.plex.tv/plex-media-server/${version}/${name}.x86_64.rpm";
-    sha256 = "0bmqf8b2d9h2h5q3n4ahs8y6a9aihj63rch7wd82rcr1l9xnqk9d";
+    sha256 = "09hy9xhhv17jbzplyls13xrzaxndlc278amp6k3w8q4j6wpsi6np";
  };                                                                                                                    

@mkaito
Copy link
Contributor

mkaito commented Jun 19, 2018

Updated package.

Rebased from nixos-unstable-small and squashed commits for cherry picking.

Tested on my local setup and works for me.

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: plex

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: plex

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: plex

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


Copy link
Contributor

@mkaito mkaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been using for a few days. Have encountered no issues.

@lukateras
Copy link
Member Author

Will merge when I address reverse compatibility issues (this works much better, but not reverse compatible).

@mkaito
Copy link
Contributor

mkaito commented Jun 20, 2018

What's not compatible? Did you move the database?

@colemickens
Copy link
Member

(My existing media database just worked with the commit I pulled, anyway.)

@mkaito
Copy link
Contributor

mkaito commented Jun 21, 2018

The only problem I've found is the preStart script of the version in master will screw with a library created with the PR version. So don't "downgrade", I guess.

patchelf --set-interpreter "${glibc.out}/lib/ld-linux-x86-64.so.2" "$out/usr/lib/plexmediaserver/$bin"
patchelf --set-rpath "$out/usr/lib/plexmediaserver" "$out/usr/lib/plexmediaserver/$bin"
done
buildFHSUserEnv {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use buildFHSUserEnv instead of patching a few binaries, doesn't this make accessing media way more complicated then it should be?

Copy link
Member Author

@lukateras lukateras Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes Plex plugins usable.

I believe that FHS containers are better for pre-built binaries than patchelf because that means original binary doesn't have to be refetched on every major rebuild. That's especially important when there are redistribution restrictions on the binary. Also, that allows programs to download additional executables at run time.

Also that doesn't break self-checksumming executables. Generally, this is less prone to break over time.

More importantly, though, is that it seems like a more proper separation of concerns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you can't patch binaries that Plex downloads at runtime.

@colemickens
Copy link
Member

Gentle ping. Is there anything I can do to help this along?

@colemickens
Copy link
Member

Ping again.

@colemickens
Copy link
Member

I'd be willing to jump in and either send a new PR or try to finish up whatever is remaining on this one. Any suggestions?

@mkaito
Copy link
Contributor

mkaito commented Oct 3, 2018

The main concern is preserving data and config when upgrading to the new derivation. You can either write a script to take care of it, or show that nothing is lost during an upgrade.

@colemickens
Copy link
Member

Are we concerned about downgrading as well? I didn't have to reconfigure when using this PR, so upgrading doesn't seem to damage the library. I can drop this and reconfirm locally, I just want to make sure we don't also need to worry about downgrade.

@mkaito
Copy link
Contributor

mkaito commented Oct 4, 2018 via email

@colemickens
Copy link
Member

I've just been flipping back and forth between channels/nixos-unstable and colemickens/nixpkgs@plex and Plex doesn't seem to miss a beat. I reloaded Firefox once but otherwise it just all seemed to work fine.

Note, I can't speak to every permutation. I've been running this module for a while. It's possible that a big version jump for older users might have different behaviors. But as far as I can tell, and from what I remember when I started using this PR... it's fine.

I confirmed by checking systemctl cat plex when flipping back and forth to ensure it was a different systemd unit (hence with and without the module rewrite).

@colemickens
Copy link
Member

If it sounds okay, maybe @yegortimoshenko can rebase, or I can send a rebase/plex-updated PR to succeed this. Let me know.

@colemickens
Copy link
Member

Here's a branch, rebased, with the latest Plex package. https://github.com/colemickens/nixpkgs/commits/plex

@mkaito
Copy link
Contributor

mkaito commented Oct 10, 2018

@colemickens diff between my branch and yours. Why?

--- a/nixos/modules/services/misc/plex.nix
+++ b/nixos/modules/services/misc/plex.nix
@@ -56,12 +56,12 @@ in
     };

     users.users.plex = {
+      createHome = true;
       group = "plex";
+      home = cfg.dataDir;
       uid = config.ids.uids.plex;
     };

-    users.groups.plex = {
-      gid = config.ids.gids.plex;
-    };
+    users.groups.plex.gid = config.ids.gids.plex;
   };
 }

@colemickens
Copy link
Member

@mkaito I don't know. That diff appears in the original PR form @yegortimoshenko. I'm not sure where your branch came from, etc.

As far as I know, my branch should be the same commits as the PR, just rebased, and then with one extra commit bumping up the version.

@colemickens
Copy link
Member

(I do know that Plex (particularly in NixOS) has had issues in the past when it's home directory didn't exist ahead of time. Also, the other change looks like a syntax-only change as well.)

@mkaito
Copy link
Contributor

mkaito commented Oct 13, 2018

I think it was probably a rebase gone bad at some point. 👍

@lukateras
Copy link
Member Author

Superseded by #48506.

@lukateras lukateras closed this Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants