From fe2df830a2659ed1fb5b4bbf5302e91d4817caca Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sun, 17 Jul 2022 10:33:22 +0200 Subject: [PATCH 1/3] flake: add system `armv7l-linux` There are some ARMv7 single board computers that are capable of running a bitcoin node (see https://nixos.wiki/wiki/NixOS_on_ARM). --- flake.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 6a4ad3d..116bdcc 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,12 @@ outputs = { self, nixpkgs, nixpkgsUnstable, flake-utils }: let - supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ]; + supportedSystems = [ + "x86_64-linux" + "i686-linux" + "aarch64-linux" + "armv7l-linux" + ]; in { lib = { mkNbPkgs = { From 2926fc27dc015613e3babd02e4687c319e7433d9 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sun, 17 Jul 2022 10:33:23 +0200 Subject: [PATCH 2/3] krops: enable evaluating nodes with non-native systems --- docs/install.md | 18 ++++++++++++++++++ helper/makeShell.nix | 20 +++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/docs/install.md b/docs/install.md index 4aa2ee8..fb69a43 100644 --- a/docs/install.md +++ b/docs/install.md @@ -238,6 +238,24 @@ You can also build Nix from source by following the instructions at https://nixo cp -r ../nix-bitcoin/examples/{nix-bitcoin-release.nix,configuration.nix,shell.nix,krops,.gitignore} . ``` +#### Optional: Specify the system of your node + This enables evaluating your node config on a machine that has a different system platform + than your node.\ + Examples: Deploying from macOS or deploying from a x86 desktop PC to a Raspberry Pi. + + ``` + # Run this when your node has a 64-Bit x86 CPU (e.g., an Intel or AMD CPU) + echo "x86_64-linux" > krops/system + + # Run this when your node has a 64-Bit ARM CPU (e.g., Raspberry Pi 4 B, Pine64) + echo "aarch64-linux" > krops/system + ``` + Other available systems: + - `i686-linux` (`x86`) + - `armv7l-linux` (`ARMv7`)\ + This platform is untested and has no binary caches. + [See here](https://nixos.wiki/wiki/NixOS_on_ARM) for details. + ## 4. Deploy with krops 1. Edit your ssh config diff --git a/helper/makeShell.nix b/helper/makeShell.nix index 456784d..50c7f87 100644 --- a/helper/makeShell.nix +++ b/helper/makeShell.nix @@ -109,11 +109,25 @@ pkgs.stdenv.mkDerivation { $(nix-build --no-out-link "${cfgDir}/krops/deploy.nix") )} - eval-config() { + eval-config() {( + set -euo pipefail + system=$(getNodeSystem) NIXOS_CONFIG="${cfgDir}/krops/krops-configuration.nix" \ - nix-instantiate --eval ${nixpkgs}/nixos -A system.outPath | tr -d '"' + nix-instantiate --eval ${nixpkgs}/nixos $system -A system.outPath | tr -d '"' echo - } + )} + + getNodeSystem() { + if [[ -e '${cfgDir}/krops/system' ]]; then + echo -n "--argstr system "; cat '${cfgDir}/krops/system' + elif [[ $OSTYPE == darwin* ]]; then + # On macOS, `builtins.currentSystem` (`*-darwin`) can never equal + # the node system (`*-linux`), so we can always provide a helpful error message: + >&2 echo "Error, node system not set. See here how to fix this:" + >&2 echo "https://github.com/fort-nix/nix-bitcoin/blob/master/docs/install.md#optional-specify-the-system-of-your-node" + return 1 + fi + }; pidClosure() { echo "$1" From dad9679647bf8ee9edfe43b84a92c73e80bed2d3 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sun, 17 Jul 2022 10:33:24 +0200 Subject: [PATCH 3/3] deployment shell: add command `build-config` --- helper/makeShell.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helper/makeShell.nix b/helper/makeShell.nix index 50c7f87..2ab42df 100644 --- a/helper/makeShell.nix +++ b/helper/makeShell.nix @@ -29,6 +29,9 @@ pkgs.stdenv.mkDerivation { eval-config Evaluate your node system configuration + build-config + Build your node system on your local machine + generate-secrets Create secrets required by your node configuration. Secrets are written to ./secrets/ @@ -117,6 +120,13 @@ pkgs.stdenv.mkDerivation { echo )} + build-config() {( + set -euo pipefail + system=$(getNodeSystem) + NIXOS_CONFIG="${cfgDir}/krops/krops-configuration.nix" \ + nix-build --no-out-link ${nixpkgs}/nixos $system -A system + )} + getNodeSystem() { if [[ -e '${cfgDir}/krops/system' ]]; then echo -n "--argstr system "; cat '${cfgDir}/krops/system'