clan-core/templates/new-clan/flake.nix

96 lines
3.7 KiB
Nix
Raw Normal View History

{
description = "<Put your description here>";
2023-10-31 12:01:16 +00:00
inputs.clan-core.url = "git+https://git.clan.lol/clan/clan-core";
2024-03-17 18:48:49 +00:00
outputs =
{ self, clan-core, ... }:
2023-09-02 14:12:37 +00:00
let
system = "x86_64-linux";
pkgs = clan-core.inputs.nixpkgs.legacyPackages.${system};
# Usage see: https://docs.clan.lol
clan = clan-core.lib.buildClan {
directory = self;
2024-04-06 09:54:34 +00:00
clanName = "__CHANGE_ME__"; # Ensure this is internet wide unique.
2024-04-10 10:03:23 +00:00
# Prerequisite: boot into the installer
# See: https://docs.clan.lol/getting-started/installer
2024-04-07 13:59:33 +00:00
# local> mkdir -p ./machines/machine1
# local> Edit ./machines/machine1/configuration.nix to your liking
2024-04-05 11:08:32 +00:00
machines = {
2024-05-12 22:09:24 +00:00
# "jon" will be the hostname of the machine
2024-04-06 09:54:34 +00:00
jon = {
2024-04-05 11:08:32 +00:00
imports = [
2024-04-13 13:53:12 +00:00
./modules/shared.nix
2024-04-06 09:54:34 +00:00
./machines/jon/configuration.nix
2024-04-09 07:17:20 +00:00
];
2024-04-07 13:59:33 +00:00
2024-04-13 14:00:01 +00:00
nixpkgs.hostPlatform = system;
2024-04-10 10:03:23 +00:00
# Set this for clan commands use ssh i.e. `clan machines update`
2024-05-12 22:09:24 +00:00
# If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP
2024-04-10 10:03:23 +00:00
clan.networking.targetHost = pkgs.lib.mkDefault "root@jon";
2024-04-05 11:08:32 +00:00
# ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = {
2024-04-10 10:03:23 +00:00
device = "/dev/disk/by-id/__CHANGE_ME__";
2024-04-09 07:17:20 +00:00
};
2024-04-10 10:03:23 +00:00
# IMPORTANT! Add your SSH key here
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = throw ''
Don't forget to add your SSH key here!
users.users.root.openssh.authorizedKeys.keys = [ "<YOUR SSH_KEY>" ]
'';
# Zerotier needs one controller to accept new nodes. Once accepted
# the controller can be offline and routing still works.
2024-04-10 10:03:23 +00:00
clan.networking.zerotier.controller.enable = true;
2024-04-05 11:08:32 +00:00
};
2024-05-12 22:09:24 +00:00
# "sara" will be the hostname of the machine
2024-04-06 09:54:34 +00:00
sara = {
2024-04-05 11:08:32 +00:00
imports = [
2024-04-13 13:53:12 +00:00
./modules/shared.nix
2024-04-06 09:54:34 +00:00
./machines/sara/configuration.nix
2024-04-09 07:17:20 +00:00
];
2024-04-13 13:53:12 +00:00
2024-04-13 14:00:01 +00:00
nixpkgs.hostPlatform = system;
2024-04-10 10:03:23 +00:00
# Set this for clan commands use ssh i.e. `clan machines update`
2024-05-12 22:09:24 +00:00
# If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP
2024-04-10 10:03:23 +00:00
clan.networking.targetHost = pkgs.lib.mkDefault "root@sara";
2024-04-05 11:08:32 +00:00
# ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = {
2024-04-10 10:03:23 +00:00
device = "/dev/disk/by-id/__CHANGE_ME__";
2024-04-09 07:17:20 +00:00
};
# IMPORTANT! Add your SSH key here
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = throw ''
Don't forget to add your SSH key here!
users.users.root.openssh.authorizedKeys.keys = [ "<YOUR SSH_KEY>" ]
'';
2024-04-13 14:29:24 +00:00
/*
2024-04-13 13:53:12 +00:00
After jon is deployed, uncomment the following line
This will allow sara to share the VPN overlay network with jon
The networkId is generated by the first deployment of jon
2024-04-13 13:53:12 +00:00
*/
2024-04-10 10:03:23 +00:00
# clan.networking.zerotier.networkId = builtins.readFile ../jon/facts/zerotier-network-id;
2024-04-05 11:08:32 +00:00
};
};
};
2023-09-02 14:12:37 +00:00
in
{
2024-05-27 13:54:17 +00:00
# all machines managed by Clan
inherit (clan) nixosConfigurations clanInternals;
2024-05-27 13:54:17 +00:00
# add the Clan cli tool to the dev shell
2023-09-02 14:12:37 +00:00
devShells.${system}.default = pkgs.mkShell {
2024-03-17 18:48:49 +00:00
packages = [ clan-core.packages.${system}.clan-cli ];
2023-09-02 14:12:37 +00:00
};
};
}