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

fix cardano-wallet nixos module #4869

Merged

Conversation

clemenscodes
Copy link
Contributor

This fixes #4522.

The option self.defaultPackage.${pkgs.system} does not contain a cardano-node package, it only contains a cardano-wallet package.

Currently users are required to override the services.cardano-node.package option manually by pointing to a compatible cardano-node package.

So we point to the correct cardano-node compatible with cardano-wallet by using self.packages.${pkgs.system}.cardano-node instead.

The option `self.defaultPackage.${pkgs.system}` does not contain a
`cardano-node` package, it only contains a `cardano-wallet` package.

So we point to the correct `cardano-node` compatible with
`cardano-wallet` by using `self.packages.${pkgs.system}.cardano-node`
instead. This fixes cardano-foundation#4522.
@abailly
Copy link
Collaborator

abailly commented Dec 9, 2024

Thanks a lot for the PR @clemenscodes
I am not a nix expert, could you tell me how I can verify this PR indeed fixes the issue?

@clemenscodes
Copy link
Contributor Author

Thanks a lot for the PR @clemenscodes I am not a nix expert, could you tell me how I can verify this PR indeed fixes the issue?

The fastest way to verify would be using NixOS and running the cardano-node and cardano-wallet services at the same time successfully, without having to specify the services.cardano-node.package option. However it is not required to use NixOS. We can first understand the core issue, where in last two lines it reports

line 26: /nix/store/vxwqzhjp4wfj42cm3ff42z3cgr7244vp-cardano-wallet-2024.3.27/bin/cardano-node: No such file or directory

So the script that runs the cardano-node refers to the cardano-node binary via the cardano-wallet-2024.3.27 derivation from the nix store, and it can't find it there. All that is required for this to work again is telling the cardano-node script to look for the cardano-node binary where it actually exists.

The cardano-wallet-2024.3.27 derivation is used because the cardano-wallet module declares

services.cardano-node.package = lib.mkDefault self.defaultPackage.${pkgs.system};

in flake.nix.

You can verify that this referenced cardano-node binary does not exist by building the package and verifying that the result does not contain the binary. This can be done by building self.defaultPackage.${pkgs.system} from the root directory of the master branch of the cardano-wallet repository. After completion this will place a result symlink in the same directory, which contains a bin directory. This should contain a cardano-node binary but it only contains a cardano-wallet binary.

nix --extra-experimental-features "nix-command flakes"  build .#defaultPackage.x86_64-linux
ls result/bin | grep cardano-node # fails

After confirming this, you can then build self.packages.${pkgs.system}.cardano-node and verify that now it indeed exists.

nix --extra-experimental-features "nix-command flakes"  build .#packages.x86_64-linux.cardano-node
ls result/bin | grep cardano-node # succeeds

If you have any more questions or issues with verifying this, feel free to reach out.

@abailly
Copy link
Collaborator

abailly commented Dec 9, 2024

currently trying to test this change, nix takes ages to download and build 12GB of data

@abailly
Copy link
Collaborator

abailly commented Dec 9, 2024

What I don't understand is that running nix build .#packages.x86_64-linux.cardano-node at the HEAD of master just works and gives the same result than doing it in your branch. What's the point?

@clemenscodes
Copy link
Contributor Author

Yeah, it takes a lot of data, but fortunately you can garbage collect the data afterwards. The point is that the derivation you built with nix build .#packages.x86_64-linux.cardano-node differs from the derivation built with nix build .#defaultPackage.x86_64-linux. The latter is what is currently used in the cardano-wallet nixos module, but since the latter does not produce the cardano-node binary, it breaks the cardano-node nixos module. Note that defaultPackage.x86_64-linux is not the same derivation as packages.x86_64-linux.cardano-node. All I did was update the cardano-wallet nixos module to use the proper derivation that actually has the required cardano-node for the cardano-node nixos service.

@abailly
Copy link
Collaborator

abailly commented Dec 9, 2024

Integration tests rely on Nix, I will need to create an internal PR to ensure this is validated by the CI.

@abailly abailly added this pull request to the merge queue Dec 9, 2024
Merged via the queue into cardano-foundation:master with commit 3905529 Dec 9, 2024
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cardano-wallet NixOS module not working with cardano-node NixOS module
2 participants