Skip to content

Instantly share code, notes, and snippets.

@erikarvstedt
Created September 24, 2020 14:39
Show Gist options
  • Save erikarvstedt/fcd3b8298983298b4ddfc161f585db79 to your computer and use it in GitHub Desktop.
Save erikarvstedt/fcd3b8298983298b4ddfc161f585db79 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
set -euo pipefail
vm=$(nix-build --show-trace --no-out-link - <<'EOF'
let
# https://github.com/fort-nix/nix-bitcoin/issues/241
nbConfig = { config, pkgs, lib, ... }:
let
nix-bitcoin = builtins.fetchTarball {
# https://github.com/fort-nix/nix-bitcoin/pull/242
url = https://github.com/fort-nix/nix-bitcoin/archive/774da9d4e0071b0d5ed4018bebce9d8d6538695d.tar.gz;
sha256 = "0jr7larx4zckfq252f3d40a0c0v2rpl6d1wdwkvk8gn148qkrnhl";
};
containerName = "nix-bitcoin"; # container name length is limited to 11 chars
in {
imports = [ "${nix-bitcoin}/modules/modules.nix" ];
containers.${containerName} = {
autoStart = true;
config = { pkgs, config, lib, ... }: {
imports = [
"${nix-bitcoin}/modules/presets/secure-node.nix"
"${nix-bitcoin}/modules/secrets/generate-secrets.nix"
];
documentation.nixos.enable = false;
};
};
};
nixpkgs = builtins.fetchTarball {
url = https://github.com/NixOS/nixpkgs-channels/archive/1179840f9a88b8a548f4b11d1a03aa25a790c379.tar.gz;
sha256 = "00jy37wj04bvh299xgal2iik2my9l0nq6cw50r1b2kdfrji8d563";
};
in
(import "${nixpkgs}/nixos" {
configuration = { pkgs, lib, ... }: with lib; {
imports = [ nbConfig ];
virtualisation.graphics = false;
services.mingetty.autologinUser = "root";
};
}).vm
EOF
)
export NIX_DISK_IMAGE=/tmp/vmimg; rm -f $NIX_DISK_IMAGE; QEMU_OPTS='-m 1024 -smp 3' $vm/bin/run-*-vm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment