Skip to content

Commit

Permalink
README: drop example
Browse files Browse the repository at this point in the history
people don't find the quickstart guide until they are already finished with this one. Also we than have to maintain everything twice
  • Loading branch information
Mic92 authored and mergify[bot] committed Sep 11, 2023
1 parent 50e1df3 commit 3686956
Showing 1 changed file with 0 additions and 121 deletions.
121 changes: 0 additions & 121 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,127 +83,6 @@ data has been migrated.

## How to use nixos-anywhere

Here’s  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.

Here’s 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 you’ve 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).
Expand Down

0 comments on commit 3686956

Please sign in to comment.