diff --git a/configuration.nix b/configuration.nix index dc0981d..230f2e8 100644 --- a/configuration.nix +++ b/configuration.nix @@ -3,10 +3,9 @@ # and in the NixOS manual (accessible by running ‘nixos-help’). { config, pkgs, ... }: - -{ - - +let + nodeinfo = (import pkgs/nodeinfo.nix); +in { disabledModules = [ "services/security/tor.nix" ]; imports = @@ -14,15 +13,18 @@ ./modules/default.nix ./modules/tor.nix ./modules/onionnode.nix - + ./modules/nodeinfo.nix ]; networking.hostName = "nix-bitcoin"; # Define your hostname. time.timeZone = "UTC"; environment.systemPackages = with pkgs; [ - wget vim tmux bitcoin git nginx + wget vim tmux git nginx nodeinfo ]; + nixpkgs.config.packageOverrides = pkgs: { + inherit nodeinfo; + }; services.openssh.enable = true; diff --git a/modules/nodeinfo.nix b/modules/nodeinfo.nix new file mode 100644 index 0000000..6db0a39 --- /dev/null +++ b/modules/nodeinfo.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + systemd.services.nodeinfo = { + description = "Get node info"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${pkgs.bash}/bin/bash -c ${pkgs.nodeinfo}/bin/nodeinfo"; + user = "root"; + type = "oneshot"; + }; + }; + }; +} diff --git a/pkgs/nodeinfo.nix b/pkgs/nodeinfo.nix new file mode 100644 index 0000000..db0699f --- /dev/null +++ b/pkgs/nodeinfo.nix @@ -0,0 +1,14 @@ +with import {}; # bring all of Nixpkgs into scope + +stdenv.mkDerivation { + name = "nodeinfo"; + src = ./nodeinfo.sh; + + unpackPhase = "true"; + installPhase = '' + mkdir -p $out + mkdir -p $out/bin + chmod +wx $src + cp $src $out/bin/nodeinfo + ''; +} diff --git a/pkgs/nodeinfo.sh b/pkgs/nodeinfo.sh new file mode 100644 index 0000000..b404356 --- /dev/null +++ b/pkgs/nodeinfo.sh @@ -0,0 +1,8 @@ +sleep 5 +OUTFILE=/var/lib/nodeinfo.nix +rm -f $OUTFILE +{ + echo \{ + echo " bitcoind_onion = \"$(cat /var/lib/tor/onion/bitcoind/hostname)\";" + echo \} +} > $OUTFILE