Error installing 1Password on aarch64-linux

I’m trying to install 1Password CLI by adding the _1password package in my configuration.nix. However, I’m getting the following error on nixos-rebuild:

building '/nix/store/1lv7y8mrxvxrhp9d4idvniv8wx06cix4-1password-1.12.2.drv'...
unpacking sources
unpacking source archive /nix/store/qivalwkfb633adys6d4z7rpy6i8i91wp-source
source root is source
patching sources
updateAutotoolsGnuConfigScriptsPhase
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2
shrinking /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2/bin/op
patchelf: cannot find section '.dynamic'. The input file is most likely statically linked
strip is /nix/store/545df3ksp8k6qf2gcyn29a7qsxm4b4cw-binutils-wrapper-2.35.2/bin/strip
stripping (with command strip and flags -S) in /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2/bin 
patching script interpreter paths in /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2
checking for references to /build/ in /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2...
patchelf: cannot find section '.dynamic'. The input file is most likely statically linked
automatically fixing dependencies for ELF files
running install tests
/nix/store/mhhmdpy3iz679c1apiq1r3g7sm1bfyas-stdenv-linux/setup: line 1341: /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2/bin/op: cannot execute binary file: Exec format error
builder for '/nix/store/1lv7y8mrxvxrhp9d4idvniv8wx06cix4-1password-1.12.2.drv' failed with exit code 126
cannot build derivation '/nix/store/f0zki144ys4l3jxghk1mh8cpirl6jqi8-home-manager-path.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/i7xi5yd3vcr2l2m3gzs1gmd5mdcayr3a-home-manager-generation.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/fc9n4fzc17fgzw5wnbvr772kvb2cr3mm-unit-home-manager-dylan.service.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/mmnr288qhkwbk2qq5y5sqgaziiszlk6x-system-units.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/0lyy9j4qbd2h4k42vjqbj5ylbpqp1ric-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/wjrbrqx2y03a18v808yix995hybflcz2-nixos-system-tisdall-nixos-dev-21.11.335481.604c44137d9.drv': 1 dependencies couldn't be built
error: build of '/nix/store/wjrbrqx2y03a18v808yix995hybflcz2-nixos-system-tisdall-nixos-dev-21.11.335481.604c44137d9.drv' failed

I’m new to NixOS, and this is the first time I’ve had a package throw errors like this, so I’m not sure how to proceed. Any advice greatly appreciated.

Thanks,
Dylan

My guess is just that that package is broken on the Nix channel you’re using. My usual process for this is check for any relevant issues or pull requests on nixpkgs. A surprisingly high amount of the time there’s already a merged PR that fixes the issue, and if so I just pull that in using an overlay. If there is no PR that fixes it and I want to not block updating I will try to find an old nixpkgs Git hash where the package was previously working and add that in an overlay.

If there’s no luck with existing issues or PRs I either try to fix it locally and create a PR or open an issue.

Oh also if you’re on the unstable channel maybe try the stable channel or vice-versa for this package.

1 Like

Thanks, I didn’t see an existing PR or issue. However, after looking more closely at the default.nix file, I suspect the error is just that it’s downloading the 32-bit ARM binary instead of the 64-bit ARM binary (i.e., it’s got the wrong URL for fetchzip). Can you point me to documentation or an example of how to create an overlay if I make a local version of 1password/default.nix to repair the error?

Thanks again,
Dylan

Is this a VM inside an M1 mac? Because you shouldn’t get a binary execution error on most aarch64 machines because they can also run armv7l binaries.

This should obviously still be fixed up but that might be the reason it’s broken.

What does file /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2/bin/op say?

Best would be to fix the error upstream. If it’s just the URL and hash are wrong, simply fix those and open a PR.

You do not need an overlay for this. I personally use local checkouts as my system nixpkgs where I can simply cherry-pick the changes before they make it into a channel but you can also do something like this:

_1password.overrideAttrs (old: { src = fetchzip { ... }; } )

That whole thing evaluates to a 1password derivation where the source is different. Just add it to your environment instead of the regular 1password and you’re gtg. Obviously you’d want to revert back once the upstream fix is in your channel since you’d also be pinning the source.

You can also turn this thing into an overlay like this:

{
  nixpkgs.overlays = [
    (final: prev: {
      _1password = prev._1password.overrideAttrs (old: { src = fetchzip { ... }; } );
    })
  ];
}

which makes any reference to _1password have its source overridden.

See Overlays - NixOS Wiki for more info.

1 Like

Thanks for the clarification. I’ve still got a couple more questions, but to answer your questions first:

  • Yes this is a VM running on an M1 mac, so that’s assuredly why it’s unhappy with the 32-bit ARM binary.

  • The output of file is:

[nix-shell:~/nixos-config]$ file /nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2/bin/op
/nix/store/xgbwg323w558yyjgp68jzasy9zdcf7db-1password-1.12.2/bin/op: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=BQb4xC_cd0MJtcKN5YdS/90ZLZ7dVAzt2X04TFjro/1KaAQsv8EqZP4DZWNqHo/p489UY6k2tV197wsX5MP, stripped

Which I think shows, as we expect, it’s got a 32-bit ARM binary.

My challenge, though, is that I can’t get my overlay fixing this to take effect. When I do nixos-rebuild switch (I’ve got home-manager installed as a NixOS module), I see it still tries to build the old derivation. I suspect this is because I’m just not fully understanding the order of function application used to generate the final package set to be installed. Any help here greatly appreciated. The relevant parts of my configuration are probably:

configuration.nix:

imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      <home-manager/nixos>
    ];
...
home-manager.users.dylan = import ./home-manager.nix { pkgs = pkgs; };

home-manager.nix:

  home.packages = with pkgs; [
    ...
    _1password
  ];
  
  nixpkgs.overlays = [
    (import overlays/1password.nix)
  ];

overlays/1password.nix:

self: super: {
  _1password = super._1password.overrideAttrs( old: {
    version = "1.12.4";
    src = super.fetchzip {
      url="https://cache.agilebits.com/dist/1P/op/pkg/v1.12.4/op_linux_arm64_v1.12.4.zip";
      sha256="1gxas3n552cxz7ppdrk8q1yarq74p6da9v72d75jbj36karb8n0j";
    };
  });
}

I’ll just add, I’m also happy to do the fix upstream and contribute back, but would need a little direction for how to use a local checkout of nixpkgs, and the various steps that are normally done to ensure a change like this is submitted properly.

I don’t know what’s wrong with your setup as it looks right to me. I’d ask about that problem in a separate thread.

I’d honestly just skip overlays entirely and just put the expression in home.packages. If you’re planning on upstreaming this, it’s temporary anyways.

For hacking on Nixpkgs, all non-flake nix- commands take the -I argument which can be used like this:

nixos-rebuild test -I nixpkgs=/path/to/nixpkgs/checkout

Then simply follow the contribution guide.

1 Like

Great, I’ve tried to follow the guide and I’ve filed a PR. Thanks again for your help!

1 Like