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

Namecoin Core flake #1

Open
wants to merge 19 commits into
base: flake
Choose a base branch
from
Open

Namecoin Core flake #1

wants to merge 19 commits into from

Conversation

jurraca
Copy link

@jurraca jurraca commented Aug 27, 2021

Adds a Nix flake for Namecoin-Core.

TODO:

  • core packages build
  • GUI builds
  • devShell
  • module for namecoind
  • figure out versioning

Notes:

  • I used the bitcoin nix expression to figure out the qt stuff but haven't managed to build it.
  • the versioning more or less matches bitcoin, might have to just hardcode it.
  • the core packages built fine until I added some of this qt stuff, but the error is that it can't find core cpp libraries. Stuck on this.

@jurraca jurraca marked this pull request as draft August 27, 2021 22:50
@jurraca
Copy link
Author

jurraca commented Sep 6, 2021

so I'm kinda dead in the water with the Qt part of this @jonringer . Could we pair at some point?

@jonringer
Copy link
Collaborator

Yea, we can. Unfortunately I'm visiting family until the weekend. Sunday or monday?

the env vars should be conditional on the withGui value, but I couldn't figure it out so they are loaded globally.
@jurraca
Copy link
Author

jurraca commented Sep 9, 2021

Yea, we can. Unfortunately I'm visiting family until the weekend. Sunday or monday?

I think I'm good actually! This last commit builds Qt successfully. Moving on to cleanup / container / module stuff.

@jurraca jurraca marked this pull request as ready for review September 10, 2021 17:15
flake.nix Outdated Show resolved Hide resolved
./configure --enable-cxx --without-bdb --disable-shared --prefix=${db48}/bin --with-boost=${boost} --with-boost-libdir=${boost}/lib --prefix=$out
'';

QT_PLUGIN_PATH = "${qtbase}/${qtbase.qtPluginPrefix}";
Copy link
Author

Choose a reason for hiding this comment

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

Couldn't figure out a way to get these evaluated correctly as optionals with withGui

Copy link
Collaborator

Choose a reason for hiding this comment

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

null values get filtered out

Suggested change
QT_PLUGIN_PATH = "${qtbase}/${qtbase.qtPluginPrefix}";
QT_PLUGIN_PATH = if withGui then "${qtbase}/${qtbase.qtPluginPrefix}" else null;

Copy link
Author

Choose a reason for hiding this comment

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

nice. I was trying to get those four env vars declared as part of a phase where i could do
optionals withGui [ '' QT_PLUGIN_PATH = ... ;'', '' LRELEASE = ... '' ]
Is that an anti pattern or ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably do something like

} // lib.optionalAttrs withGui {
   QT_PLUGIN_PATH = "${qtbase}/${qtbase.qtPluginPrefix}";
   ....
}

nix/namecoin-core.nix Outdated Show resolved Hide resolved
Copy link
Collaborator

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

I would also probably factor out the nixos module to a separate file

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated
@@ -25,6 +29,24 @@
apps.namecoin-core = utils.lib.mkApp { drv = packages.namecoin-core; };
hydraJobs = { inherit (legacyPackages) namecoin-core; };
checks = { inherit (legacyPackages) namecoin-core; };
nixosModules.namecoin-core =
{ ... }:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{ ... }:
{ lib, config, ... }:

flake.nix Outdated
@@ -25,6 +29,24 @@
apps.namecoin-core = utils.lib.mkApp { drv = packages.namecoin-core; };
hydraJobs = { inherit (legacyPackages) namecoin-core; };
checks = { inherit (legacyPackages) namecoin-core; };
nixosModules.namecoin-core =
{ ... }:
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{
with lib;
let
cfg = config.services.namecoin-core;
in {
options.services.namecoin-core = {
enable = lib.mkEnableOption "Namecoin-core";
withGui = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable gui";
};
};
config = mkIf cfg.enable {
# what you had before

@jurraca
Copy link
Author

jurraca commented Sep 15, 2021

Thanks 👍 . I'm trying to stay away from adding multiple files, just because I think it'll make it less likely for the upstream project to incorporate the flake. wdyt?

@nrdsp nrdsp self-assigned this Jul 28, 2022
@jonringer
Copy link
Collaborator

jonringer commented Jul 28, 2022

@nrdsp and I had a really good chat. I think moving forward we should

Must:

  • Update the flake conventions
  • Update the upstream to a more recent checkout?
  • Check the packages still build

Optionally:

  • Somehow test the module (nixosTest?)

@nrdsp
Copy link

nrdsp commented Jul 29, 2022

Following-up on @jonringer's comment above, I commited an update of flake conventions. More specifically, attributes defaultPackage and overlay were dropped in favour of packages.<system>.default and overlays.default. Nix flake check isn't throwing me any warning now.

@nrdsp
Copy link

nrdsp commented Jul 29, 2022

@jonringer @jurraca there are diverging changes with upstream. Should we attempt to force syncing and then try building? synced my local copy of jurraca/namecoin-core with ngi-nix/namecoin-core and the updated flake seems to build without issues nor warnings. Maybe someone else could double check if the current flake builds against the upstream repository (ngi-nix/namecoin-core)?

@nrdsp
Copy link

nrdsp commented Aug 1, 2022

@jonringer as to testing, should we implement any of the built-in integration tests?

nix/namecoin-core.nix Outdated Show resolved Hide resolved
nix/namecoin-core.nix Outdated Show resolved Hide resolved
Comment on lines 52 to 66
configureFlags = [ ]
++ optionals (!withGui) [ " --without-gui " ]
++ optionals (!withWallet) [ "--disable-wallet" "--without-bdb" ]
++ optionals (withUpnp) [ "--with-miniupnpc" "--enable-upnp-default" ]
++ optionals (withNatpmp) [ "--with-natpmp" "--enable-natpmp-default" ]
++ optionals (!withHardening) [ "--disable-hardening" ]
++ optionals withGui [
"--with-gui=qt5"
"--with-qt-bindir=${qtbase.dev}/bin:${qttools.dev}/bin"
];

configurePhase = ''
./autogen.sh
./configure --enable-cxx --without-bdb --disable-shared --prefix=${db48}/bin --with-boost=${boost} --with-boost-libdir=${boost}/lib --prefix=$out
'';
Copy link
Collaborator

Choose a reason for hiding this comment

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

odd that we use both configureFlags, and then overwrite the default configure phase and call ./configure with specific flags. We should probably unify the flags into configureFlags, and move ./autogen.sh into preConfigure

Copy link

@nrdsp nrdsp Sep 20, 2022

Choose a reason for hiding this comment

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

Moving these flags into configureFlags doesn't seem to have the desired effect. For instance:

  configureFlags = [  "--enable-cxx"  "--without-bdb" "--disable-shared" "--prefix=${db48}/bin" "--with-boost=${boost}" "--with-boost-libdir=${boost}/lib" "--prefix=$out" ]
      ++ optionals (!withGui) [ " --without-gui " ]
      ++ optionals (!withWallet) [ "--disable-wallet" "--without-bdb" ]
      ++ optionals (withUpnp) [ "--with-miniupnpc" "--enable-upnp-default" ]
      ++ optionals (withNatpmp) [ "--with-natpmp" "--enable-natpmp-default" ]
      ++ optionals (!withHardening) [ "--disable-hardening" ] 
      ++ optionals withGui [
        "--with-gui=qt5"
        "--with-qt-bindir=${qtbase.dev}/bin:${qttools.dev}/bin"
      ];

  configurePhase = ''
    ./configure
  '';

The above gives us:

> checking whether to build Namecoin Core GUI... yes (Qt5)
       > checking for Berkeley DB C++ headers... no
       > configure: error: libdb_cxx headers missing, Namecoin Core requires this library for BDB wallet support (--without-bdb to disable BDB wallet support)

Adding the flag "--without-bdb" to ++ optionals withGui doesn't do much either.

nrdsp and others added 2 commits September 18, 2022 19:03
Co-authored-by: Jonathan Ringer <[email protected]>
@portothree
Copy link
Member

Hey, I tried consuming this flake nixos module and encountered the following error:

error: attribute 'namecoin-core' missing

       at /nix/store/p0ivsgkf349snq28mba2viva6h3sny3v-source/flake.nix:100:13:

           99|             microvm.nixosModules.host
          100|             namecoin-core.nixosModules.namecoin-core
             |             ^
          101|           ];

After inspecting the flake with nix flake show, I can see that the output of namecoin-core.nixosModules does not have a namecoin-core value, it has a list of systems instead. My guess was that this was being caused because the nixosModules is being defined inside the flake-utils eachSystem function, causing each ouput value to have a list of system before the actual closure value.

➜  nix flake show github:jurraca/namecoin-core/flake
github:jurraca/namecoin-core/dfa1676ab3531b34667fc51540338cf538be0ea5
[...]
├───nixosModules
│   ├───aarch64-linux: NixOS module
│   ├───x86_64-darwin: NixOS module
│   └───x86_64-linux: NixOS module
[...]

I have paired with @nrdsp to explore this and we end up finding a solution.
We moved the nixosModules definition to outside of the eachSystem call and replace defaultPackage reference inside the module definition with pkgs.namecoin-core given that we are using a overlay for the nixpkgs to include namecoin-core in the store.

This worked fine and now I can do the following:

pkgs.lib.nixosSystem {
    modules = [ namecoin-core.nixosModules.namecoin-core ];

in my flake.nix.

@jonringer Could you have a look at this change and let me know if this is the best option to solve this, please? 🙏

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.

4 participants