Merge pull request 'docs: misc clean up 2' (#3742) from push-wzkskzxyzkwt into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3742
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Clan supports integration with [flake.parts](https://flake.parts/) a tool which allows composing nixos modules in a modular way.
|
Clan supports integration with [flake-parts](https://flake.parts/), a framework for constructing your `flake.nix` using modules.
|
||||||
|
|
||||||
Here's how to set up Clan using `nix flakes` and `flake-parts`.
|
To construct your Clan using flake-parts, follow these steps:
|
||||||
|
|
||||||
## 1. Update Your Flake Inputs
|
## 1. Update Your Flake Inputs
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ To begin, you'll need to add `flake-parts` as a new dependency in your flake's i
|
|||||||
```nix
|
```nix
|
||||||
# flake.nix
|
# flake.nix
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
||||||
|
|
||||||
# New flake-parts input
|
# New flake-parts input
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
@@ -18,77 +18,76 @@ inputs = {
|
|||||||
|
|
||||||
clan-core = {
|
clan-core = {
|
||||||
url = "git+https://git.clan.lol/clan/clan-core";
|
url = "git+https://git.clan.lol/clan/clan-core";
|
||||||
inputs.nixpkgs.follows = "nixpkgs"; # Needed if your configuration uses nixpkgs unstable.
|
inputs.nixpkgs.follows = "nixpkgs"; # Necessary if you are using a stable NixOS channel
|
||||||
# New
|
# New
|
||||||
inputs.flake-parts.follows = "flake-parts";
|
inputs.flake-parts.follows = "flake-parts";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2. Import Clan-Core Flake Module
|
## 2. Import the Clan flake-parts Module
|
||||||
|
|
||||||
After updating your flake inputs, the next step is to import the `clan-core` flake module. This will make the [clan options](../reference/nix-api/buildclan.md) available within `mkFlake`.
|
After updating your flake inputs, the next step is to import the Clan flake-parts module. This will make the [Clan options](../reference/nix-api/buildclan.md) available within `mkFlake`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
|
{
|
||||||
outputs =
|
outputs =
|
||||||
inputs@{ flake-parts, ... }:
|
inputs@{ flake-parts, ... }:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } (
|
flake-parts.lib.mkFlake { inherit inputs; } (
|
||||||
{
|
{
|
||||||
#
|
|
||||||
imports = [
|
imports = [
|
||||||
inputs.clan-core.flakeModules.default
|
inputs.clan-core.flakeModules.default
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Configure Clan Settings and Define Machines
|
### 3. Configure Clan Settings and Define Machines
|
||||||
|
|
||||||
Configure your clan settings and define machine configurations.
|
Next you'll need to configure Clan wide settings and define machines, here's an example of how `flake.nix` should look:
|
||||||
|
|
||||||
Below is a guide on how to structure this in your flake.nix:
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
|
{
|
||||||
outputs = inputs@{ flake-parts, clan-core, ... }:
|
outputs = inputs@{ flake-parts, clan-core, ... }:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } ({self, pkgs, ...}: {
|
flake-parts.lib.mkFlake { inherit inputs; } ({self, pkgs, ...}: {
|
||||||
# We define our own systems below. you can still use this to add system specific outputs to your flake.
|
|
||||||
# See: https://flake.parts/getting-started
|
# See: https://flake.parts/getting-started
|
||||||
systems = [];
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
# import clan-core modules
|
# Import the Clan flake-parts module
|
||||||
imports = [
|
imports = [
|
||||||
clan-core.flakeModules.default
|
clan-core.flakeModules.default
|
||||||
];
|
];
|
||||||
# Define your clan
|
|
||||||
|
# Define your Clan
|
||||||
# See: https://docs.clan.lol/reference/nix-api/buildclan/
|
# See: https://docs.clan.lol/reference/nix-api/buildclan/
|
||||||
clan = {
|
clan = {
|
||||||
# Clan wide settings. (Required)
|
# Clan wide settings
|
||||||
meta.name = ""; # Ensure to choose a unique name.
|
meta.name = ""; # This is required and must be unique
|
||||||
|
|
||||||
machines = {
|
machines = {
|
||||||
jon = {
|
jon = {
|
||||||
imports = [
|
imports = [
|
||||||
./machines/jon/configuration.nix
|
./modules/firefox.nix
|
||||||
./modules/disko.nix
|
|
||||||
# ... more modules
|
# ... more modules
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.hostPlatform = "x86_64-linux";
|
nixpkgs.hostPlatform = "x86_64-linux";
|
||||||
|
|
||||||
# Set this for clan commands use ssh i.e. `clan machines update`
|
# Set this for Clan commands to work remotely over SSH like `clan machines update`
|
||||||
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon";
|
clan.core.networking.targetHost = "root@jon";
|
||||||
|
|
||||||
# remote> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
|
# remote> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
|
||||||
disko.devices.disk.main = {
|
disko.devices.disk.main = {
|
||||||
device = "/dev/disk/by-id/nvme-eui.e8238fa6bf530001001b448b4aec2929";
|
device = "/dev/disk/by-id/nvme-eui.e8238fa6bf530001001b448b4aec2929";
|
||||||
};
|
};
|
||||||
|
|
||||||
# There needs to be exactly one controller per clan
|
|
||||||
clan.core.networking.zerotier.controller.enable = true;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
For detailed information about configuring `flake-parts` and the available options within Clan,
|
For detailed information about configuring `flake-parts` and the available options within Clan,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# Migrate existing NixOS configurations
|
# Migrate existing NixOS configurations
|
||||||
|
|
||||||
This guide will help you migrate your existing Nix configurations into Clan.
|
This guide will help you migrate your existing NixOS configurations into Clan.
|
||||||
|
|
||||||
!!! Warning
|
!!! Warning
|
||||||
Migrating instead of starting new can be trickier and might lead to bugs or
|
Migrating instead of starting new can be trickier and might lead to bugs or
|
||||||
unexpected issues. We recommend following the [Getting Started](../getting-started/index.md) guide first. Once you have a working setup, you can easily transfer your Nix configurations over.
|
unexpected issues. We recommend following the [Getting Started](../getting-started/index.md) guide first. Once you have a working setup, you can easily transfer your NixOS configurations over.
|
||||||
|
|
||||||
## Back up your existing configuration!
|
## Back up your existing configuration!
|
||||||
Before you start, it is strongly recommended to back up your existing
|
Before you start, it is strongly recommended to back up your existing
|
||||||
@@ -31,12 +31,12 @@ have have two hosts: **berlin** and **cologne**.
|
|||||||
|
|
||||||
berlin = nixpkgs.lib.nixosSystem {
|
berlin = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [./machines/berlin/configuration.nix];
|
modules = [ ./machines/berlin/configuration.nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
cologne = nixpkgs.lib.nixosSystem {
|
cologne = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [./machines/cologne/configuration.nix];
|
modules = [ ./machines/cologne/configuration.nix ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -53,7 +53,7 @@ inputs.clan-core = {
|
|||||||
url = "git+https://git.clan.lol/clan/clan-core";
|
url = "git+https://git.clan.lol/clan/clan-core";
|
||||||
# Don't do this if your machines are on nixpkgs stable.
|
# Don't do this if your machines are on nixpkgs stable.
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Update Outputs
|
## Update Outputs
|
||||||
@@ -86,20 +86,20 @@ For the provide flake example, your flake should now look like this:
|
|||||||
outputs = { self, nixpkgs, clan-core, ... }:
|
outputs = { self, nixpkgs, clan-core, ... }:
|
||||||
let
|
let
|
||||||
clan = clan-core.lib.buildClan {
|
clan = clan-core.lib.buildClan {
|
||||||
self = self; # this needs to point at the repository root
|
self = self; # this needs to point at the repository root
|
||||||
specialArgs = {};
|
specialArgs = {};
|
||||||
meta.name = throw "Change me to something unique";
|
meta.name = throw "Change me to something unique";
|
||||||
|
|
||||||
machines = {
|
machines = {
|
||||||
berlin = {
|
berlin = {
|
||||||
nixpkgs.hostPlatform = "x86_64-linux";
|
nixpkgs.hostPlatform = "x86_64-linux";
|
||||||
imports = [ ./machines/berlin/configuration.nix ];
|
imports = [ ./machines/berlin/configuration.nix ];
|
||||||
};
|
|
||||||
cologne = {
|
|
||||||
nixpkgs.hostPlatform = "x86_64-linux";
|
|
||||||
imports = [ ./machines/cologne/configuration.nix ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
cologne = {
|
||||||
|
nixpkgs.hostPlatform = "x86_64-linux";
|
||||||
|
imports = [ ./machines/cologne/configuration.nix ];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -144,7 +144,7 @@ A minimal example is provided below, add it to your flake outputs.
|
|||||||
```nix
|
```nix
|
||||||
devShells."x86_64-linux".default = nixpkgs.legacyPackages."x86_64-linux".mkShell {
|
devShells."x86_64-linux".default = nixpkgs.legacyPackages."x86_64-linux".mkShell {
|
||||||
packages = [ clan-core.packages."x86_64-linux".clan-cli ];
|
packages = [ clan-core.packages."x86_64-linux".clan-cli ];
|
||||||
};
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
To use the CLI, execute `nix develop` in the directory of your flake. The
|
To use the CLI, execute `nix develop` in the directory of your flake. The
|
||||||
@@ -178,4 +178,3 @@ Clan needs to know where it can reach your hosts. For each of your hosts, set
|
|||||||
You are now fully set up. Use the CLI to manage your hosts or proceed to
|
You are now fully set up. Use the CLI to manage your hosts or proceed to
|
||||||
configure further services. At this point you should be able to run commands
|
configure further services. At this point you should be able to run commands
|
||||||
like `clan machines update berlin` to deploy a host.
|
like `clan machines update berlin` to deploy a host.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user