README: drop example

people don't find the quickstart guide until they are already finished with this one. Also we than have to maintain everything twice
This commit is contained in:
Jörg Thalheim 2023-09-11 16:51:27 +02:00 committed by mergify[bot]
parent 50e1df362e
commit 3686956935

121
README.md
View File

@ -83,127 +83,6 @@ data has been migrated.
## How to use nixos-anywhere
Heres  a quick summary of how to use **nixos-anywhere**. You can find more
information in the [documentation](./docs).
The tool doesn't need to be installed, since it can be run directly from this
repository.
First create a repo that includes the disk configuration and a
[flake](https://nixos.wiki/wiki/Flakes) to configure your options. This example
assumes that flakes have been enabled on your source machine.
Heres an example of a simple disk configuration:
```nix
{ disks ? [ "/dev/vda" ], ... }:
{
disk = {
main = {
type = "disk";
device = builtins.elemAt disks 0;
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for grub MBR
};
ESP = {
size = "512M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
}
```
The
[disko repository](https://github.com/nix-community/disko/tree/master/example)
has several examples of disk configurations. You can adapt them to our own
needs.
A simple flake may look like this:
```nix
{
inputs.nixpkgs.url = github:NixOS/nixpkgs;
inputs.disko.url = github:nix-community/disko;
inputs.disko.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, disko, ... }@attrs: {
#-----------------------------------------------------------
# The following line names the configuration as hetzner-cloud
# This name will be referenced when nixos-remote is run
#-----------------------------------------------------------
nixosConfigurations.hetzner-cloud = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = attrs;
modules = [
({modulesPath, ... }: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/profiles/qemu-guest.nix")
disko.nixosModules.disko
];
disko.devices = import ./disk-config.nix {
lib = nixpkgs.lib;
};
boot.loader.grub = {
devices = [ "/dev/sda" ];
efiSupport = true;
efiInstallAsRemovable = true;
};
services.openssh.enable = true;
#-------------------------------------------------------
# Change the line below replacing <insert your key here>
# with your own ssh public key
#-------------------------------------------------------
users.users.root.openssh.authorizedKeys.keys = [ "<insert your key here>" ];
})
];
};
};
}
```
Once youve created the disk configuration and the flake, you can run the tool
with a single nix command, which may look like this:
```
nix run github:numtide/nixos-anywhere -- --flake <flake URL> <SSH destination>
# Example:
# nix run github:numtide/nixos-anywhere -- --flake .#hetzner-cloud root@135.181.254.201
```
Note that this command references the URL of your flake, in this case `.#`,
together with the name of the system `hetzner-cloud`, as highlighted by the
comment in the sample flake.
This will configure and build the new NixOS server. Since the configurations are
defined in the flake, it will not create `/etc/nixos/configuration.nix`. If you
need to make changes to the configuration in future, you should make the changes
in the flake, and rebuild using the --flake option as shown below:
```
nixos-rebuild --flake <flake URL> --target-host <SSH destination> switch
# Example:
# nixos-rebuild --flake .#hetzner-cloud --target-host root@135.181.254.201 switch
```
The [Quickstart Guide](./docs/quickstart.md) gives more information on how to
run **nixos-anywhere** in its simplest form. For more specific instructions to
suit individual requirements, see the [How To Guide](./docs/howtos.md).