commit 18dc2304c069b1d2b13615cf83b919a16d1edc69 Author: Jonas Nick Date: Tue Nov 13 23:44:54 2018 +0000 running bitcoin diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..8123b84 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,71 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./modules/default.nix + ]; + + networking.hostName = "nix-bitcoin"; # Define your hostname. + time.timeZone = "UTC"; + + environment.systemPackages = with pkgs; [ + wget vim tmux bitcoin git nginx + ]; + + services.openssh.enable = true; + +# users.users.root = { +# openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILacgZRwLsiICNHGHY2TG2APeuxFsrw6Cg13ZTMQpNqA nickler@rick" ]; +# }; + + + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + networking.firewall.enable = true; + + services.bitcoin.enable = true; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n = { + # consoleFont = "Lat2-Terminus16"; + # consoleKeyMap = "us"; + # defaultLocale = "en_US.UTF-8"; + # }; + + + # List packages installed in system profile. To search, run: + # $ nix search wget + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { enable = true; enableSSHSupport = true; }; + + # List services that you want to enable: + + + # Open ports in the firewall. + # Or disable the firewall altogether. + + # Define a user account. Don't forget to set a password with ‘passwd’. + # users.users.guest = { + # isNormalUser = true; + # uid = 1000; + # }; + + # This value determines the NixOS release with which your system is to be + # compatible, in order to avoid breaking some software such as database + # servers. You should change this only after NixOS release notes say you + # should. + system.stateVersion = "18.09"; # Did you read the comment? + +} diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..b17e551 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.bitcoin; + datadir = "/var/lib/bitcoin"; +in { + options.services.bitcoin = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + If enabled, the bitcoin service will be installed. + ''; + }; + }; + + config = mkIf cfg.enable { + users.users.bitcoin = + { + description = "Tor Daemon User"; + createHome = true; + home = datadir; + }; + systemd.services.bitcoind = + { description = "Run bitcoind"; + path = [ pkgs.bitcoin ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = + { ExecStart = "${pkgs.bitcoin}/bin/bitcoind -datadir=${datadir}"; + User = "bitcoin"; + }; + }; + }; +} diff --git a/network-vbox.nix b/network-vbox.nix new file mode 100644 index 0000000..262d70b --- /dev/null +++ b/network-vbox.nix @@ -0,0 +1,9 @@ +{ + bitcoin-node = + { config, pkgs, ... }: + { deployment.targetEnv = "virtualbox"; + deployment.virtualbox.memorySize = 2048; # megabytes + deployment.virtualbox.vcpu = 2; # number of cpus + deployment.virtualbox.headless = true; + }; +} diff --git a/network.nix b/network.nix new file mode 100644 index 0000000..2f44385 --- /dev/null +++ b/network.nix @@ -0,0 +1,5 @@ +{ + network.description = "Bitcoin Core node"; + + bitcoin-node = import ./configuration.nix; +}