Merge fort-nix/nix-bitcoin#516: krops: Enable evaluating nodes with non-native systems

dad9679647 deployment shell: add command `build-config` (Erik Arvstedt)
2926fc27dc krops: enable evaluating nodes with non-native systems (Erik Arvstedt)
fe2df830a2 flake: add system `armv7l-linux` (Erik Arvstedt)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK dad9679647

Tree-SHA512: b87b6734d642ebf413d3e1c9f540ddab2145b35d1f8208a08f64db1ee79fe69056b29bf3e3f3bc70dc1a5d6be3ad0299c491486fdaf5106dc2a4331f61805d15
This commit is contained in:
Jonas Nick 2022-07-18 07:20:53 +00:00
commit 3f13cfd159
No known key found for this signature in database
GPG Key ID: 4861DBF262123605
3 changed files with 51 additions and 4 deletions

View File

@ -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

View File

@ -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 = {

View File

@ -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/
@ -109,11 +112,32 @@ 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
}
)}
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'
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"