Nixpkgs: mutagen doesn't install mutagen agents

Created on 28 Feb 2020  路  9Comments  路  Source: NixOS/nixpkgs

Describe the bug
Trying to run mutagen results in an error:

$ mutagen sync resume bedc2b69-b8ef-42c3-98bc-993059c84d7b
Started Mutagen daemon in background (terminate with "mutagen daemon stop")     
Extracting agent...                                                             
Error: resume failed: unable to resume session: unable to connect to beta: unable to connect to endpoint: unable to dial agent endpoint: unable to install agent: unable to get agent for platform: unable to open agent bundle: open /nix/store/n5nx3n2wkxbpm7nfdl7w7rbllafxamqy-mutagen-0.11.0/bin/mutagen-agents.tar.gz: no such file or directory

The mutagen-agents.tar.gz which is supposed to have binaries for different platforms is missing.

To Reproduce

  1. Install mutagen
  2. Activate a mutagen session

Metadata

  • system: "x86_64-linux"

    • host os: Linux 5.4.20, NixOS, 20.09pre213994.e2b4abe3c8f (Nightingale)

    • multi-user?: yes

    • sandbox: yes

    • version: nix-env (Nix) 2.3.3

    • channels(alex): "home-manager"

    • channels(root): "nixos-20.09pre213994.e2b4abe3c8f, home-manager"

    • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:mutagen
# a list of nixos modules affected by the problem
module:
bug

All 9 comments

Hey, author of Mutagen here, super excited to see a Nix package for it!

I just thought I'd mention that the mutagen-agents.tar.gz bundle currently needs to be placed in the same directory as the mutagen executable itself. This is something I've been meaning to improve for a while now (by allowing it to be put in a libexec directory), but I haven't had a chance to implement it yet, mostly because it's a little tricky to get right with package managers like Homebrew that symlink binaries into a different target location.

I'm not very familiar with Nix, but I'm sure that it would prefer to avoid having this tarball in the bin directory. So I'm happy to push ahead on trying to support the libexec-based layout if that's helpful here (or perhaps something more general if NixOS prefers a different layout).

cc @marsam

A quick update: Mutagen v0.11.2 and later support looking for the mutagen-agents.tar.gz bundle in a libexec directory (assuming a Filesystem Hierarchy Standard layout), so a layout of the form:

bin/
    mutagen
libexec/
    mutagen-agents.tar.gz

should now work (in addition to the option of installing the bundle directly alongside the executable).

This also works in a Homebrew-style setup where the mutagen binary is symlinked into a larger bin directory.

@havoc-io Thanks! Is the mutagen-agents.tar.gz available for direct download?

@alexvorobiev The mutagen-agents.tar.gz bundle ships as part of the official releases (e.g. in the mutagen_linux_amd64_v0.11.5.tar.gz bundle available here). It needs to be kept in sync with the version of the mutagen binary being installed, but it should work just fine with a mutagen binary built locally, so long as the versions are the same (to the patch level).

The mutagen-agents.tar.gz bundle can also be built locally, but doing so requires running a custom script inside the Mutagen source tree that performs the necessary cross-compilation (this bundle is a collection of cross-compiled binaries that get injected to remote systems to facilitate file synchronization and network forwarding). I'm not sure the best way of handling that in the context of the NixOS packaging system. Perhaps there are some custom hooks available? At the moment, this script doesn't have a flag for building just this bundle (it will only be built as part of a full set of release bundles for all platforms), though I suppose such a flag could be added.

One of the downsides of doing the cross-compilation locally on Linux (or any non-macOS system) is that the C FFI bindings needed for efficient filesystem watching on macOS won't be available, so file synchronization between NixOS systems and macOS systems will suffer. That might not be a huge loss, though.

This is why the Homebrew packages just use the official pre-built release bundles as their "source code." It's a bit non-idiomatic, but it saves on local build times and allows for cross-compiled binaries with C FFI support. Of course, I totally understand if that doesn't work with the NixOS package philosophy, in which case just building the bundle locally is probably the best bet.

As a reference point, here's what the Mutagen Homebrew formula looks like: https://github.com/mutagen-io/homebrew-mutagen/blob/master/Formula/mutagen.rb

I agree, setting up the cross-compilation would not be trivial so the nix derivation must download the prebuilt agents binaries from somewhere while still being able to build the agent on the platform it is running on. I see three possibilities:

  1. (No changes on the mutagen side). Nix derivation downloads the full mutagen release and extracts mutagen-agents.tar.gz.
  2. Add the version number to the mutagen-agents.tar.gz and add it to the downloads. The nix derivation would just download it.
  3. Provide the individual downloads for the agents similarly to agent_linux_amd64_v0.12.0-alpha1.tar.gz for all the platforms and have the nix derivation create the mutagen-agents.tar.gz itself. That way it would be very easy to even parametrize it to only download the agents the user wants and the nix derivation would supply the binary for the platform it is running on.

All three options are reasonable ideas, though I would prefer to avoid (3) since it would significantly increase the number of assets attached to each GitHub release (which is probably already too high). The individual agent binaries for linux/amd64 that you mentioned are sort of a special case for some experimental container integration features, so I'd prefer to avoid expanding them to every platform. I also don't know if many users want to go through the trouble of filtering the remote platform support that they want, though if that's something users are interested in then I'm certainly willing to try to support that.1

Option (2) is possible without too much effort, though I don't think it adds much value over option (1).

Additionally, if option (1) is already going to be used to download the release bundle, it might as well just pull the mutagen binary out of the release bundle as well and save the complexity of a local build.

In any case, the current package should have the build of cmd/mutagen-agent removed since it won't really be of any use.

Let me know if option (1) will work and if there's anything I can do to help.


1 I think a better long-term solution is to provide two download variants: a "full" agent bundle that includes all platforms and a "slim" agent bundle that just includes commonly used platforms.


P.S. Thanks for helping to support this!

Given the usual problems with pre-compiled binaries, reading the discussion above I thought we might have another problem : nixos needing its own agent in mutagen-agents.tar.gz. But to my surprise, the amd64 binaries work on nixos without the need to patch the ELF聽interpreter or anything else, it seems that everything is self-contained with no external dependencies. So why not make a binary installation directly?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thoughtpolice picture thoughtpolice  路  71Comments

timokau picture timokau  路  66Comments

joepie91 picture joepie91  路  102Comments

ttuegel picture ttuegel  路  98Comments

worldofpeace picture worldofpeace  路  103Comments