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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,57 @@

outputs = { self, nixpkgs, utils }:
let
localOverlay = import ./nix/overlay.nix;
localOverlay = final: prev: {
namecoin-core = prev.callPackage ./nix/namecoin-core.nix { };

pkgsForSystem = system: import nixpkgs {
overlays = [
localOverlay
];
inherit system;
devShell = final.namecoin-core;
};
in utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ] (system: rec {

pkgsForSystem = system:
import nixpkgs {
overlays = [ localOverlay ];
inherit system;
};
in utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]
(system: rec {
legacyPackages = pkgsForSystem system;
packages = utils.lib.flattenTree {
inherit (legacyPackages) devShell namecoin-core;
default = legacyPackages.namecoin-core;
};
defaultPackage = packages.namecoin-core;
apps.namecoin-core = utils.lib.mkApp { drv = packages.namecoin-core; };
hydraJobs = { inherit (legacyPackages) namecoin-core; };
checks = { inherit (legacyPackages) namecoin-core; };
}) // {
overlay = localOverlay;
overlays = {};
};
}) // {
nixosModules.namecoin-core = { pkgs, lib, config, ... }:
with lib;
let cfg = config.services.namecoin-core;
in {
options = {
services.namecoin-core = {
enable = mkOption {
type = types.bool;
default = false;
};
};
};
config = mkIf cfg.enable {
nixpkgs.overlays = [ localOverlay ];

systemd.packages = [ pkgs.namecoin-core ];

systemd.services.namecoin-core = {
path = [ pkgs.namecoin-core ];
description = "Namecoin Core daemon.";

serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.namecoin-core}/bin/namecoind";
wantedBy = [ "default.target" ];
};
};
};
};
overlays.default = localOverlay;
};
}
95 changes: 88 additions & 7 deletions nix/namecoin-core.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,97 @@
{ lib, stdenv, fetchFromGitHub, nix-gitignore, pkg-config, autoreconfHook }:
{
lib,
stdenv,
fetchFromGitHub,
nix-gitignore,
pkg-config,
autoreconfHook,
boost,
python3,
libtool,
libevent,
zeromq,
hexdump,
db48,
sqlite,
libupnp,
libnatpmp,
libsForQt5,
withWallet ? false,
withGui ? true,
withUpnp ? false,
withNatpmp ? false,
withHardening ? true
}:

with lib;
let
additionalFilters = [ "*.nix" "nix/" "build/" ];
filterSource = nix-gitignore.gitignoreSource additionalFilters;
cleanedSource = filterSource ../.;
in stdenv.mkDerivation {
pname = "namecoin-core";
# TODO: find a better way to determine version, but it doesn't seem to be version controlled
version = "0.21.1";
desktop = builtins.fetchurl {
url = "https://raw.githubusercontent.com/bitcoin-core/packaging/${version}/debian/bitcoin-qt.desktop";
sha256 = "0a46bbadda140599e807be38999e6848c89f9c3523d26fede02d34d62d50f632";
};
inherit (libsForQt5.qt5) qtbase qttools qmake wrapQtAppsHook;

in stdenv.mkDerivation rec {
pname = "namecoin-core";
version = "23.0";
src = cleanedSource;

nativeBuildInputs = [ pkg-config autoreconfHook ];
buildInputs = [ ];
nativeBuildInputs = [ pkg-config autoreconfHook boost wrapQtAppsHook ]
++ optionals (withGui) [ wrapQtAppsHook qmake ];

buildInputs = [ python3 libtool libevent zeromq hexdump qtbase qttools ]
++ optionals (withWallet) [ db48 sqlite ]
++ optionals (withUpnp) [ libupnp ]
++ optionals (withNatpmp) [ libnatpmp];

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"
];

preConfigure = ''
./autogen.sh
'';

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

QT_PLUGIN_PATH = if withGui then "${qtbase}/${qtbase.qtPluginPrefix}" else null;
LRELEASE = "${qttools.dev}/bin/lrelease";
LUPDATE = "${qttools.dev}/bin/lupdate";
LCONVERT = "${qttools.dev}/bin/lconvert";

postConfigure = "make qmake_all";

buildPhase = ''
make -j $NIX_BUILD_CORES
'';

postInstall = optionalString withGui ''
install -Dm644 ${desktop} $out/share/applications/namecoin-qt.desktop
'';

qtWrapperArgs = [ ''--prefix PATH : ${placeholder "out"}/bin/namecoin-qt '' ];

checkFlags =
[ "LC_ALL=C.UTF-8" ]
# QT_PLUGIN_PATH needs to be set when executing QT, which is needed when testing Bitcoin's GUI.
# See also https://github.com/NixOS/nixpkgs/issues/24256
++ optional withGui "QT_PLUGIN_PATH=${qtbase}/${qtbase.qtPluginPrefix}";

meta = {
homepage = "https://namecoin.org";
downloadPage = "https://namecoin.org/download";
description = "a decentralized open source information registration and transfer system based on the Bitcoin cryptocurrency.";
};
}
5 changes: 0 additions & 5 deletions nix/overlay.nix

This file was deleted.