XXLPitu
November 10, 2020, 9:28pm
1
I’m trying to create some overlays to patch resilio-sync
(adding arm64
support) and some other packages but whatever I try I always get infinite recursion. I have no idea why that would happen, in my overlay I can’t think of a way this would create a cyclic dependency or would try to resolve a variable infinitly.
My current setup
Version: 20.09
configuration.nix
# importing a list is intentional so that I can stack several overlays once this works
nixpkgs.overlays = import ./pkgs;
pkgs/default.nix
[
(self: super: {
resilio-sync = super.callPackage ./resilio-sync.nix { };
})
]
pkgs/resilio-sync.nix
{ pkgs, stdenv, fetchurl }:
let
arch = {
x86_64-linux = "x64";
i686-linux = "i386";
aarch64-linux = "arm64";
}.${stdenv.hostPlatform.system} or (throw
"Unsupported system: ${stdenv.hostPlatform.system}");
in pkgs.resilio-sync.overrideAttrs (oldAttrs: {
src = fetchurl {
url =
"https://download-cdn.resilio.com/${oldAttrs.version}/linux-${arch}/resilio-sync_${arch}.tar.gz";
sha256 = {
x86_64-linux = "0gar5lzv1v4yqmypwqsjnfb64vffzn8mw9vnjr733fgf1pmr57hf";
i686-linux = "1bws7r86h1vysjkhyvp2zk8yvxazmlczvhjlcayldskwq48iyv6w";
aarch64-linux = "0j8wk5cf8bcaaqxi8gnqf1mpv8nyfjyr4ibls7jnn2biqq767af2";
}.${stdenv.hostPlatform.system};
};
})
XXLPitu
November 10, 2020, 9:57pm
3
This makes so much sense. Thank you.
Sadly this does not fix the issue but now I get an error message that makes this clear. It now points to that exact line 9 .
error: attribute 'resilio-sync' missing, at /etc/nixos/pkgs/resilio-sync.nix:9:4
XXLPitu
November 10, 2020, 10:01pm
4
I found a solution that works thanks to your help @earvstedt but not sure that is the best way to do it.
pkgs/default.nix
[
(self: super: {
resilio-sync = super.callPackage ./resilio-sync.nix { pkgs = super; };
})
]
Sorry, I was wrong. callPackage
always uses the final pkgs
attrset for default function args.
Here’s a working solution:
nix-build --no-out-link - <<'EOF'
let
rs = { resilio-sync, stdenv, fetchurl }:
let
arch = {
x86_64-linux = "x64";
i686-linux = "i386";
aarch64-linux = "arm64";
}.${stdenv.hostPlatform.system} or (throw
"Unsupported system: ${stdenv.hostPlatform.system}");
in resilio-sync.overrideAttrs (oldAttrs: {
src = fetchurl {
url = "https://download-cdn.resilio.com/${oldAttrs.version}/linux-${arch}/resilio-sync_${arch}.tar.gz";
sha256 = {
x86_64-linux = "0gar5lzv1v4yqmypwqsjnfb64vffzn8mw9vnjr733fgf1pmr57hf";
i686-linux = "1bws7r86h1vysjkhyvp2zk8yvxazmlczvhjlcayldskwq48iyv6w";
aarch64-linux = "0j8wk5cf8bcaaqxi8gnqf1mpv8nyfjyr4ibls7jnn2biqq767af2";
}.${stdenv.hostPlatform.system};
};
});
overlays = [
(self: super: {
resilio-sync = self.callPackage rs { inherit (super) resilio-sync; };
})
];
in
(import <nixpkgs> { inherit overlays; }).resilio-sync
EOF