From 95b42b62a853970317c3f1012574ba1f6e3b5d1e Mon Sep 17 00:00:00 2001 From: Clemens Fruhwirth Date: Tue, 26 Mar 2019 14:57:17 +0100 Subject: [PATCH 1/2] Give pkgs their own directory and convert everything to callPackage. --- modules/nix-bitcoin-pkgs.nix | 8 ++++---- pkgs/{ => banlist}/banlist.sh | 0 pkgs/{banlist.nix => banlist/default.nix} | 0 pkgs/{electrs.nix => electrs/default.nix} | 0 pkgs/{liquidd.nix => liquidd/default.nix} | 0 pkgs/{nodeinfo.nix => nodeinfo/default.nix} | 0 pkgs/{ => nodeinfo}/nodeinfo.sh | 0 7 files changed, 4 insertions(+), 4 deletions(-) rename pkgs/{ => banlist}/banlist.sh (100%) rename pkgs/{banlist.nix => banlist/default.nix} (100%) rename pkgs/{electrs.nix => electrs/default.nix} (100%) rename pkgs/{liquidd.nix => liquidd/default.nix} (100%) rename pkgs/{nodeinfo.nix => nodeinfo/default.nix} (100%) rename pkgs/{ => nodeinfo}/nodeinfo.sh (100%) diff --git a/modules/nix-bitcoin-pkgs.nix b/modules/nix-bitcoin-pkgs.nix index 740fe6b..10036dd 100644 --- a/modules/nix-bitcoin-pkgs.nix +++ b/modules/nix-bitcoin-pkgs.nix @@ -4,13 +4,13 @@ nixpkgs-unstable = import nixpkgs-pinned.nixpkgs-unstable { }; # Custom packages - nodeinfo = (import ../pkgs/nodeinfo.nix) { inherit pkgs; }; - banlist = (import ../pkgs/banlist.nix) { inherit pkgs; }; + nodeinfo = pkgs.callPackage ../pkgs/nodeinfo { }; + banlist = pkgs.callPackage ../pkgs/banlist { }; lightning-charge = pkgs.callPackage ../pkgs/lightning-charge { }; nanopos = pkgs.callPackage ../pkgs/nanopos { }; spark-wallet = pkgs.callPackage ../pkgs/spark-wallet { }; - electrs = pkgs.callPackage (import ../pkgs/electrs.nix) { }; - liquidd = pkgs.callPackage (import ../pkgs/liquidd.nix) { }; + electrs = pkgs.callPackage ../pkgs/electrs { }; + liquidd = pkgs.callPackage ../pkgs/liquidd { }; in { disabledModules = [ "services/security/tor.nix" ]; imports = [ diff --git a/pkgs/banlist.sh b/pkgs/banlist/banlist.sh similarity index 100% rename from pkgs/banlist.sh rename to pkgs/banlist/banlist.sh diff --git a/pkgs/banlist.nix b/pkgs/banlist/default.nix similarity index 100% rename from pkgs/banlist.nix rename to pkgs/banlist/default.nix diff --git a/pkgs/electrs.nix b/pkgs/electrs/default.nix similarity index 100% rename from pkgs/electrs.nix rename to pkgs/electrs/default.nix diff --git a/pkgs/liquidd.nix b/pkgs/liquidd/default.nix similarity index 100% rename from pkgs/liquidd.nix rename to pkgs/liquidd/default.nix diff --git a/pkgs/nodeinfo.nix b/pkgs/nodeinfo/default.nix similarity index 100% rename from pkgs/nodeinfo.nix rename to pkgs/nodeinfo/default.nix diff --git a/pkgs/nodeinfo.sh b/pkgs/nodeinfo/nodeinfo.sh similarity index 100% rename from pkgs/nodeinfo.sh rename to pkgs/nodeinfo/nodeinfo.sh From 687bf8017d69096315fef77c068ebbb6c48a0ff8 Mon Sep 17 00:00:00 2001 From: Clemens Fruhwirth Date: Thu, 28 Mar 2019 09:13:04 +0100 Subject: [PATCH 2/2] Make repository importable as NUR (including an overlay) https://github.com/nix-community/NUR is a Nix community project that aims to make out of tree derivations more easily discoverable and accessible to Nix users. Converting the nix-bitcoin repo to conform to that style is a minor change and enhances reusability of its components. For instance, I could slap on the clightning module more easily onto my existing bitcoin node without having to redeploy the whole as nixops driven installation. Having the repo in NUR style would make that easier. --- default.nix | 14 ++++++++++++++ modules/default.nix | 13 +++++++++++++ modules/nix-bitcoin-pkgs.nix | 26 +++++--------------------- non-broken.nix | 27 +++++++++++++++++++++++++++ overlay.nix | 21 +++++++++++++++++++++ 5 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 default.nix create mode 100644 modules/default.nix create mode 100644 non-broken.nix create mode 100644 overlay.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..518bd34 --- /dev/null +++ b/default.nix @@ -0,0 +1,14 @@ +{ pkgs ? import {} }: +{ + # 'lib', 'modules' and 'overlays' are special, see + # https://github.com/nix-community/NUR for more. + modules = import ./modules; # NixOS modules + + nodeinfo = pkgs.callPackage ./pkgs/nodeinfo { }; + banlist = pkgs.callPackage ./pkgs/banlist { }; + lightning-charge = pkgs.callPackage ./pkgs/lightning-charge { }; + nanopos = pkgs.callPackage ./pkgs/nanopos { }; + spark-wallet = pkgs.callPackage ./pkgs/spark-wallet { }; + electrs = pkgs.callPackage ./pkgs/electrs { }; + liquidd = pkgs.callPackage ./pkgs/liquidd { }; +} diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..ad57e84 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,13 @@ +{ + bitcoind = ./bitcoind.nix; + clightning = ./clightning.nix; + default = ./default.nix; + electrs = ./electrs.nix; + lightning-charge = ./lightning-charge.nix; + liquid = ./liquid.nix; + nanopos = ./nanopos.nix; + nix-bitcoin = ./nix-bitcoin.nix; + nix-bitcoin-pkgs = ./nix-bitcoin-pkgs.nix; + nix-bitcoin-webindex = ./nix-bitcoin-webindex.nix; + spark-wallet = ./spark-wallet.nix; +} diff --git a/modules/nix-bitcoin-pkgs.nix b/modules/nix-bitcoin-pkgs.nix index 10036dd..8ca0d1b 100644 --- a/modules/nix-bitcoin-pkgs.nix +++ b/modules/nix-bitcoin-pkgs.nix @@ -1,35 +1,19 @@ { config, pkgs, ... }: - let - nixpkgs-pinned = import ../pkgs/nixpkgs-pinned.nix; - nixpkgs-unstable = import nixpkgs-pinned.nixpkgs-unstable { }; - - # Custom packages - nodeinfo = pkgs.callPackage ../pkgs/nodeinfo { }; - banlist = pkgs.callPackage ../pkgs/banlist { }; - lightning-charge = pkgs.callPackage ../pkgs/lightning-charge { }; - nanopos = pkgs.callPackage ../pkgs/nanopos { }; - spark-wallet = pkgs.callPackage ../pkgs/spark-wallet { }; - electrs = pkgs.callPackage ../pkgs/electrs { }; - liquidd = pkgs.callPackage ../pkgs/liquidd { }; +let + nixpkgs-pinned = import ../pkgs/nixpkgs-pinned.nix; + nixpkgs-unstable = import nixpkgs-pinned.nixpkgs-unstable { }; in { disabledModules = [ "services/security/tor.nix" ]; imports = [ (nixpkgs-pinned.nixpkgs-unstable + "/nixos/modules/services/security/tor.nix") ]; + nixpkgs.overlays = [ (import ../overlay.nix) ]; + nixpkgs.config.packageOverrides = pkgs: { # Use bitcoin and clightning from unstable bitcoin = nixpkgs-unstable.bitcoin.override { }; altcoins.bitcoind = nixpkgs-unstable.altcoins.bitcoind.override { }; clightning = nixpkgs-unstable.clightning.override { }; - - # Add custom packages - inherit nodeinfo; - inherit banlist; - inherit lightning-charge; - inherit nanopos; - inherit spark-wallet; - inherit electrs; - inherit liquidd; }; } diff --git a/non-broken.nix b/non-broken.nix new file mode 100644 index 0000000..b9a2cf9 --- /dev/null +++ b/non-broken.nix @@ -0,0 +1,27 @@ +# This file filters out all the broken packages from your package set. +# It's what gets built by CI, so if you correctly mark broken packages as +# broken your CI will not try to build them and the non-broken packages will +# be added to the cache. +{ pkgs ? import {} }: + +let filterSet = + (f: g: s: builtins.listToAttrs + (map + (n: { name = n; value = builtins.getAttr n s; }) + (builtins.filter + (n: f n && g (builtins.getAttr n s)) + (builtins.attrNames s) + ) + ) + ); +in filterSet + (n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages + (p: (builtins.isAttrs p) + && !( + (builtins.hasAttr "meta" p) + && (builtins.hasAttr "broken" p.meta) + && (p.meta.broken) + ) + ) + (import ./default.nix { inherit pkgs; }) + diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 0000000..082b038 --- /dev/null +++ b/overlay.nix @@ -0,0 +1,21 @@ +# You can use this file as a nixpkgs overlay. +# It's useful in the case where you don't want to add the whole NUR namespace +# to your configuration. + +self: super: + +let filterSet = + (f: g: s: builtins.listToAttrs + (map + (n: { name = n; value = builtins.getAttr n s; }) + (builtins.filter + (n: f n && g (builtins.getAttr n s)) + (builtins.attrNames s) + ) + ) + ); +in filterSet + (n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages + (p: true) # all packages are ok + (import ./default.nix { pkgs = super; }) +