rename nixos-remote to nixos-anywhere

This commit is contained in:
Jörg Thalheim 2023-02-01 19:49:46 +01:00
parent 6fdd010b51
commit c3326a417f
No known key found for this signature in database
15 changed files with 44 additions and 44 deletions

View File

@ -1,6 +1,6 @@
# nixos-remote - install nixos everywhere via ssh
# nixos-anywhere - install nixos everywhere via ssh
nixos-remote makes it possible to install nixos from Linux machines reachable via ssh.
nixos-anywhere (formally known as nixos-remote) makes it possible to install nixos from Linux machines reachable via ssh.
Under the hood uses a [kexec image](https://github.com/nix-community/nixos-images#kexec-tarballs) to boot
into a NixOS installer from a running Linux system.
It then uses [disko](https://github.com/nix-community/disko) to partition and
@ -15,23 +15,23 @@ configuration.
the whole nixos into memory.
## Usage
Needs a repo with your configurations with flakes. For a minimal example checkout https://github.com/numtide/nixos-remote-examples.
Needs a repo with your configurations with flakes. For a minimal example checkout https://github.com/numtide/nixos-anywhere-examples.
Your NixOS configuration will also need a [disko](https://github.com/nix-community/disko) configuration as we can see in
our [example](https://github.com/numtide/nixos-remote-examples/blob/9768e438b1467ec55d42e096860e7199bd1ef43d/flake.nix#L15-L19)
our [example](https://github.com/numtide/nixos-anywhere-examples/blob/9768e438b1467ec55d42e096860e7199bd1ef43d/flake.nix#L15-L19)
Afterwards you can just run:
```
nix run github:numtide/nixos-remote -- root@yourip --flake github:your-user/your-repo#your-system
nix run github:numtide/nixos-anywhere -- root@yourip --flake github:your-user/your-repo#your-system
```
The parameter passed to `--flake` should point to your nixos configuration
exposed in your flake (`nixosConfigurations.your-system` in the example above).
`nixos-remote --help`
`nixos-anywhere --help`
``` shell
Usage: nixos-remote [options] ssh-host
Usage: nixos-anywhere [options] ssh-host
Options:
@ -65,11 +65,11 @@ Options:
## Using your own kexec image
By default `nixos-remote` will download the kexec image from [here](https://github.com/nix-community/nixos-images#kexec-tarballs).
By default `nixos-anywhere` will download the kexec image from [here](https://github.com/nix-community/nixos-images#kexec-tarballs).
It is also possible to provide your own by providing a file to `--kexec`. The image will than uploaded prior to executing.
``` shell
nixos-remote \
nixos-anywhere \
--kexec "$(nix build --print-out-paths github:nix-community/nixos-images#packages.x86_64-linux.kexec-installer-nixos-unstable)/nixos-kexec-installer-x86_64-linux.tar.gz" \
--flake 'github:your-user/your-repo#your-system' \
root@yourip
@ -80,7 +80,7 @@ pre-build image. The following example assumes that your local machine can
build for aarch64-linux either natively or through a remote builder
``` shell
nixos-remote \
nixos-anywhere \
--kexec "$(nix build --print-out-paths github:nix-community/nixos-images#packages.aarch64-linux.kexec-installer-nixos-unstable)/nixos-kexec-installer-aarch64-linux.tar.gz" \
--flake 'your-flake#your-system' \
root@yourip
@ -88,7 +88,7 @@ nixos-remote \
## Developer guide
To run `nixos-remote` from the repo:
To run `nixos-anywhere` from the repo:
```console
nix run . -- --help

View File

@ -8,5 +8,5 @@ status = [
"devShell default [x86_64-linux]",
"package default [x86_64-linux]",
"package docs [x86_64-linux]",
"package nixos-remote [x86_64-linux]"
"package nixos-anywhere [x86_64-linux]"
]

View File

@ -1,7 +1,7 @@
# Table of Content
- [Introduction](./introduction.md)
- [What is nixos-remote?](#)
- [What is nixos-anywhere?](#)
- [Quickstart](#)
- [Getting Started](#)
- [System Requirements](#)

View File

@ -3,4 +3,4 @@ authors = [ ]
language = "en"
multilingual = false
src = "."
title = "nixos-remote - install NixOS everywhere"
title = "nixos-anywhere - install NixOS everywhere"

View File

@ -1,7 +1,7 @@
# CLI
```
Usage: nixos-remote [options] ssh-host
Usage: nixos-anywhere [options] ssh-host
Options:

View File

@ -1,6 +1,6 @@
{
perSystem = { pkgs, lib, ... }: {
packages.docs = pkgs.runCommand "nixos-remote-docs"
packages.docs = pkgs.runCommand "nixos-anywhere-docs"
{
passthru.serve = pkgs.writeShellScriptBin "serve" ''
cd docs

View File

@ -1,6 +1,6 @@
# Introduction
- [What is nixos-remote?](#)
- [What is nixos-anywhere?](#)
- [Quickstart](#)
- [Getting Started](#)
- [System Requirements](#)

View File

@ -23,8 +23,8 @@ let
];
in
(writeShellApplication {
name = "nixos-remote";
text = builtins.readFile ./nixos-remote.sh;
name = "nixos-anywhere";
text = builtins.readFile ./nixos-anywhere.sh;
inherit runtimeInputs;
}) // {
# also expose this attribute to other derivations

View File

@ -1,11 +1,11 @@
{
perSystem = { config, pkgs, ... }: {
packages = {
nixos-remote = pkgs.callPackage ./. { };
default = config.packages.nixos-remote;
nixos-anywhere = pkgs.callPackage ./. { };
default = config.packages.nixos-anywhere;
};
devShells.default = pkgs.mkShellNoCC {
packages = config.packages.nixos-remote.runtimeInputs;
packages = config.packages.nixos-anywhere.runtimeInputs;
};
};
}

View File

@ -1,6 +1,6 @@
showUsage() {
cat <<USAGE
Usage: nixos-remote [options] ssh-host
Usage: nixos-anywhere [options] ssh-host
Options:
@ -132,14 +132,14 @@ fi
# ssh wrapper
timeout_ssh_() {
timeout 10 ssh -i "$ssh_key_dir"/nixos-remote -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection" "$@"
timeout 10 ssh -i "$ssh_key_dir"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection" "$@"
}
ssh_() {
ssh -T -i "$ssh_key_dir"/nixos-remote -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection" "$@"
ssh -T -i "$ssh_key_dir"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection" "$@"
}
nix_copy() {
NIX_SSHOPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $ssh_key_dir/nixos-remote" nix copy \
NIX_SSHOPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $ssh_key_dir/nixos-anywhere" nix copy \
"${nix_options[@]}" \
"${nix_copy_options[@]}" \
"$@"
@ -156,11 +156,11 @@ if [[ -z ${ssh_connection-} ]]; then
abort "ssh-host must be set"
fi
# we generate a temporary ssh keypair that we can use during nixos-remote
# we generate a temporary ssh keypair that we can use during nixos-anywhere
ssh_key_dir=$(mktemp -d)
trap 'rm -rf "$ssh_key_dir"' EXIT
mkdir -p "$ssh_key_dir"
ssh-keygen -t ed25519 -f "$ssh_key_dir"/nixos-remote -P "" -C "nixos-remote" >/dev/null
ssh-keygen -t ed25519 -f "$ssh_key_dir"/nixos-anywhere -P "" -C "nixos-anywhere" >/dev/null
# parse flake nixos-install style syntax, get the system attr
if [[ -n ${flake-} ]]; then
@ -198,7 +198,7 @@ fi
until
ssh-copy-id \
-i "$ssh_key_dir"/nixos-remote.pub \
-i "$ssh_key_dir"/nixos-anywhere.pub \
-o ConnectTimeout=10 \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
@ -255,7 +255,7 @@ if [[ ${is_os-n} != "Linux" ]]; then
fi
if [[ ${is_arch-n} != "x86_64" ]] && [[ $kexec_url == "$default_kexec_url" ]]; then
abort "The default kexec image only support x86_64 cpus. Checkout https://github.com/numtide/nixos-remote/#using-your-own-kexec-image for more information."
abort "The default kexec image only support x86_64 cpus. Checkout https://github.com/numtide/nixos-anywhere/#using-your-own-kexec-image for more information."
fi
if [[ ${is_kexec-n} == "n" ]] && [[ ${is_installer-n} == "n" ]]; then
@ -298,7 +298,7 @@ ssh_ "$disko_script"
if [[ ${stop_after_disko-n} == "y" ]]; then
# Should we also do this for `--no-reboot`?
echo "WARNING: leaving temporary ssh key at '$ssh_key_dir/nixos-remote' to login to the machine" >&2
echo "WARNING: leaving temporary ssh key at '$ssh_key_dir/nixos-anywhere' to login to the machine" >&2
trap - EXIT
exit 0
fi

View File

@ -6,7 +6,7 @@
testInputs = {
inherit pkgs;
inherit (inputs.disko.nixosModules) disko;
nixos-remote = config.packages.nixos-remote;
nixos-anywhere = config.packages.nixos-anywhere;
kexec-installer = "${inputs'.nixos-images.packages.kexec-installer-nixos-unstable}/nixos-kexec-installer-${system}.tar.gz";
};
in

View File

@ -19,13 +19,13 @@
start_all()
installer.succeed("echo super-secret > /tmp/disk-1.key")
output = installer.succeed("""
nixos-remote \
nixos-anywhere \
--debug \
--kexec /etc/nixos-remote/kexec-installer \
--kexec /etc/nixos-anywhere/kexec-installer \
--stop-after-disko \
--disk-encryption-keys /tmp/disk-1.key /tmp/disk-1.key \
--disk-encryption-keys /tmp/disk-2.key <(echo another-secret) \
--store-paths /etc/nixos-remote/disko /etc/nixos-remote/system-to-install \
--store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \
nixos@installed >&2
echo "disk-1.key: '$(ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
root@installed cat /tmp/disk-1.key)'"

View File

@ -23,18 +23,18 @@
installer.succeed("mkdir -p /tmp/extra-files/var/lib/secrets")
installer.succeed("echo value > /tmp/extra-files/var/lib/secrets/key")
installer.succeed("""
nixos-remote \
nixos-anywhere \
--debug \
--kexec /etc/nixos-remote/kexec-installer \
--kexec /etc/nixos-anywhere/kexec-installer \
--extra-files /tmp/extra-files \
--store-paths /etc/nixos-remote/disko /etc/nixos-remote/system-to-install \
--store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \
root@installed >&2
""")
installed.shutdown()
new_machine = create_test_machine(oldmachine=installed, args={ "name": "after_install" })
new_machine.start()
hostname = new_machine.succeed("hostname").strip()
assert "nixos-remote" == hostname, f"'nixos-remote' != '{hostname}'"
assert "nixos-anywhere" == hostname, f"'nixos-anywhere' != '{hostname}'"
content = new_machine.succeed("cat /var/lib/secrets/key").strip()
assert "value" == content, f"secret does not have expected value: {content}"
'';

View File

@ -12,11 +12,11 @@ in
${pkgs.coreutils}/bin/install -D -m600 ${./ssh-keys/ssh} /root/.ssh/id_rsa
'';
environment.systemPackages = [ inputs.nixos-remote ];
environment.systemPackages = [ inputs.nixos-anywhere ];
environment.etc = {
"nixos-remote/disko".source = system-to-install.config.system.build.disko;
"nixos-remote/system-to-install".source = system-to-install.config.system.build.toplevel;
"nixos-remote/kexec-installer".source = kexec-installer;
"nixos-anywhere/disko".source = system-to-install.config.system.build.disko;
"nixos-anywhere/system-to-install".source = system-to-install.config.system.build.toplevel;
"nixos-anywhere/kexec-installer".source = kexec-installer;
};
}

View File

@ -4,7 +4,7 @@
(modulesPath + "/profiles/qemu-guest.nix")
(modulesPath + "/profiles/minimal.nix")
];
networking.hostName = "nixos-remote";
networking.hostName = "nixos-anywhere";
documentation.enable = false;
hardware.enableAllFirmware = false;
networking.hostId = "8425e349"; # from profiles/base.nix, needed for zfs