> ## Documentation Index
> Fetch the complete documentation index at: https://nicos.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Start your first machine

<RequestExample>
  ```bash Installation theme={null}
  nix run github:plmercereau/nicos -- init
  ```
</RequestExample>

<ResponseExample>
  ```nix flake.nix theme={null}
  {
    inputs = {
      nicos.url = "github:plmercereau/nicos";
    };

    outputs = {nicos, ...}:
      nicos.lib.configure {
        projectRoot = ./.;
        adminKeys = ["ssh-ed25519 ..."];
        nixos = {
          enable = true;
          path = "./hosts-nixos";
        };
      }
      {
        # Your additional flake outputs go here
      };
  }
  ```

  ```nix shared.nix theme={null}
  # Settings common to all the machines
  {cluster, ...}: {
    settings = {
      users.users.bob = {
        enable = true;
        admin = true;
        publicKeys = cluster.adminKeys;
      };
    };
  }
  ```

  ```nix hosts-nixos/my-machine.nix theme={null}
  {hardware, ...}: {
    imports = [hardware.hetzner-x86];
    settings = {
      sshPublicKey = "ssh-ed25519 ...";
    };
  }
  ```
</ResponseExample>

<Steps>
  <Step title="Prerequisites">
    <AccordionGroup>
      <Accordion title="Nix">
        Make sure you installed Nix before using Nicos. Please have a look at the [official installation instructions](https://nixos.org/download#download-nix).
      </Accordion>

      <Accordion title="Enable Flake support">
        In your NixOS configuration, add the following line:

        ```nix theme={null}
        nix.extraOptions = ''
          experimental-features = nix-command flakes
        '';
        ```
      </Accordion>

      <Accordion title="Recommended: direnv and nix-direnv">
        You can add the following lines in your home-manager configuration:

        ```nix theme={null}
        programs.direnv.enable = true;
        programs.direnv.nix-direnv.enable = true;
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Installation">
    ```bash theme={null}
    nix run github:plmercereau/nicos -- init
    ```

    It will guide you in the configuration of your project. For now, you can only enable the NixOS feature and skip the other ones.
  </Step>

  <Step title="Prepare a Hetzner Cloud instance">
    Add your current user's SSH public key on Hetzner Cloud to this machine. See [Hetzner Cloud documentation](https://community.hetzner.com/tutorials/add-ssh-key-to-your-hetzner-cloud) for more information.
  </Step>

  <Step title="Create a machine configuration">
    ```bash theme={null}
    nix run github:plmercereau/nicos -- create my-machine
    ```
  </Step>

  <Step title="Install the machine">
    Now that the machine configuration is ready, you can install it on your Hetzner Cloud server:

    ```bash theme={null}
    nix run github:plmercereau/nicos -- create \
      my-machine [machine-ip]
    ```

    It will install and configure the machine using [nixos-anywhere](https://github.com/nix-community/nixos-anywhere), kexec, and [cloud-init](https://cloud-init.io).
  </Step>
</Steps>
