Compare commits
5 Commits
ke-facts-c
...
update-tem
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c456ac1334 | ||
|
|
f7c48d560d | ||
|
|
bb9b535f20 | ||
|
|
f0c5a8c84a | ||
|
|
a27321a826 |
@@ -394,6 +394,7 @@ in
|
||||
options = {
|
||||
# ModuleSpec
|
||||
module = lib.mkOption {
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options.input = lib.mkOption {
|
||||
type = types.nullOr types.str;
|
||||
|
||||
@@ -91,13 +91,19 @@ def test_clan_core_templates(
|
||||
clan_core_templates = nix_attrset["inputs"][InputName("clan-core")]["templates"][
|
||||
"clan"
|
||||
]
|
||||
clan_core_template_keys = list(clan_core_templates.keys())
|
||||
clan_core_template_keys = set(clan_core_templates.keys())
|
||||
|
||||
expected_templates = ["default", "flake-parts", "minimal", "minimal-flake-parts"]
|
||||
expected_templates = set(
|
||||
{
|
||||
"default",
|
||||
"minimal",
|
||||
"flake-parts",
|
||||
}
|
||||
)
|
||||
assert clan_core_template_keys == expected_templates
|
||||
|
||||
vlist_temps = list_templates("clan", clan_dir)
|
||||
list_template_keys = list(vlist_temps.inputs[InputName("clan-core")].keys())
|
||||
list_template_keys = set(vlist_temps.inputs[InputName("clan-core")].keys())
|
||||
assert list_template_keys == expected_templates
|
||||
|
||||
default_template = get_template(
|
||||
@@ -112,14 +118,11 @@ def test_clan_core_templates(
|
||||
Path(default_template.src["path"]),
|
||||
new_clan,
|
||||
)
|
||||
assert (new_clan / "flake.nix").exists()
|
||||
assert (new_clan / "machines").is_dir()
|
||||
assert (new_clan / "machines" / "jon").is_dir()
|
||||
config_nix_p = new_clan / "machines" / "jon" / "configuration.nix"
|
||||
assert (config_nix_p).is_file()
|
||||
flake_file = new_clan / "flake.nix"
|
||||
|
||||
# Test if we can write to the configuration.nix file
|
||||
with config_nix_p.open("r+") as f:
|
||||
assert (flake_file).exists()
|
||||
# Test if we can read + write files after the template was copied
|
||||
with flake_file.open("r+") as f:
|
||||
data = f.read()
|
||||
f.write(data)
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ def test_create_flake(
|
||||
|
||||
cli.run(["flakes", "create", str(flake_dir), "--template=default", "--no-update"])
|
||||
|
||||
assert (flake_dir / ".clan-flake").exists()
|
||||
# Replace the inputs.clan.url in the template flake.nix
|
||||
# Replace the inputs.clan-core.url in the template flake.nix
|
||||
substitute(
|
||||
flake_dir / "flake.nix",
|
||||
clan_core,
|
||||
@@ -35,13 +34,6 @@ def test_create_flake(
|
||||
|
||||
cli.run(["machines", "create", "machine1"])
|
||||
|
||||
# create a hardware-configuration.nix that doesn't throw an eval error
|
||||
|
||||
for patch_machine in ["jon", "sara"]:
|
||||
(
|
||||
flake_dir / "machines" / f"{patch_machine}/hardware-configuration.nix"
|
||||
).write_text("{}")
|
||||
|
||||
with capture_output as output:
|
||||
cli.run(["machines", "list"])
|
||||
assert "machine1" in output.out
|
||||
@@ -68,8 +60,7 @@ def test_create_flake_existing_git(
|
||||
|
||||
cli.run(["flakes", "create", str(flake_dir), "--template=default", "--no-update"])
|
||||
|
||||
assert (flake_dir / ".clan-flake").exists()
|
||||
# Replace the inputs.clan.url in the template flake.nix
|
||||
# Replace the inputs.clan-core.url in the template flake.nix
|
||||
substitute(
|
||||
flake_dir / "flake.nix",
|
||||
clan_core,
|
||||
@@ -79,13 +70,6 @@ def test_create_flake_existing_git(
|
||||
monkeypatch.chdir(flake_dir)
|
||||
cli.run(["machines", "create", "machine1"])
|
||||
|
||||
# create a hardware-configuration.nix that doesn't throw an eval error
|
||||
|
||||
for patch_machine in ["jon", "sara"]:
|
||||
(
|
||||
flake_dir / "machines" / f"{patch_machine}/hardware-configuration.nix"
|
||||
).write_text("{}")
|
||||
|
||||
with capture_output as output:
|
||||
cli.run(["machines", "list"])
|
||||
assert "machine1" in output.out
|
||||
@@ -111,7 +95,7 @@ def test_ui_template(
|
||||
|
||||
cli.run(["flakes", "create", str(flake_dir), "--template=minimal", "--no-update"])
|
||||
|
||||
# Replace the inputs.clan.url in the template flake.nix
|
||||
# Replace the inputs.clan-core.url in the template flake.nix
|
||||
substitute(
|
||||
flake_dir / "flake.nix",
|
||||
clan_core,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
result
|
||||
result*
|
||||
.direnv/
|
||||
77
templates/clan/default/flake.nix
Normal file
77
templates/clan/default/flake.nix
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
|
||||
inputs.nixpkgs.follows = "clan-core/nixpkgs";
|
||||
|
||||
outputs =
|
||||
{ self, clan-core, ... }:
|
||||
let
|
||||
# Usage see: https://docs.clan.lol
|
||||
clan = clan-core.clanLib.buildClan {
|
||||
inherit self;
|
||||
|
||||
# Ensure this is unique among all clans you want to use.
|
||||
meta.name = "__CHANGE_ME__";
|
||||
|
||||
# Clan services to use. See https://docs.clan.lol/reference/clanServices
|
||||
inventory.instances = {
|
||||
admin = {
|
||||
roles.default.tags.all = { };
|
||||
roles.default.settings.allowedKeys = {
|
||||
# Insert the public key of all your admin machines
|
||||
# All these 'admin machines' will have ssh access to "tags.all" (all machines)
|
||||
# Alternatively set 'users.users.root.openssh.authorizedKeys.keys' in each machine
|
||||
"admin-machine-1" = "__YOUR_PUBLIC_KEY__";
|
||||
};
|
||||
};
|
||||
|
||||
zerotier = {
|
||||
# Replace with the name of your machine that you will use as zerotier-controller
|
||||
# See: https://docs.zerotier.com/controller/
|
||||
# Deploy this machine first to create the network secrets
|
||||
roles.controller.machines."__YOUR_CONTROLLER__" = { };
|
||||
# Peers of the network
|
||||
# tags.all means 'all machines' will joined
|
||||
roles.peer.tags.all = { };
|
||||
};
|
||||
};
|
||||
|
||||
# A mapping of machine names to their nixos configuration.
|
||||
# Allows specifying additional nixos configuration.
|
||||
machines = {
|
||||
somemachine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = with pkgs; [ asciinema ];
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
# Expose clan structures as flake outputs. clanInternals is needed for
|
||||
# the clan-cli. Exposing nixosConfigurations allows using `nixos-rebuild` as before.
|
||||
inherit (clan)
|
||||
nixosConfigurations
|
||||
nixosModules
|
||||
clanInternals
|
||||
darwinConfigurations
|
||||
darwinModules
|
||||
;
|
||||
|
||||
# Add the Clan cli tool to the dev shell.
|
||||
# Use "nix develop" to enter the dev shell.
|
||||
devShells =
|
||||
clan-core.inputs.nixpkgs.lib.genAttrs
|
||||
[
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
]
|
||||
(system: {
|
||||
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
|
||||
packages = [ clan-core.packages.${system}.clan-cli ];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
2
templates/clan/flake-parts/.gitignore
vendored
Normal file
2
templates/clan/flake-parts/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
result*
|
||||
.direnv/
|
||||
@@ -1,15 +1,11 @@
|
||||
{
|
||||
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
|
||||
inputs.nixpkgs.follows = "clan-core/nixpkgs";
|
||||
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
inputs.flake-parts.follows = "clan-core/flake-parts";
|
||||
inputs.flake-parts.inputs.nixpkgs-lib.follows = "clan-core/nixpkgs";
|
||||
|
||||
outputs =
|
||||
inputs@{
|
||||
self,
|
||||
flake-parts,
|
||||
...
|
||||
}:
|
||||
inputs@{ flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
@@ -18,84 +14,41 @@
|
||||
"aarch64-darwin"
|
||||
];
|
||||
imports = [ inputs.clan-core.flakeModules.default ];
|
||||
# https://docs.clan.lol/guides/getting-started/flake-parts/
|
||||
# https://docs.clan.lol/guides/flake-parts/
|
||||
clan = {
|
||||
meta.name = "__CHANGE_ME__"; # Ensure this is unique among all clans you want to use.
|
||||
# Ensure this is unique among all clans you want to use.
|
||||
meta.name = "__CHANGE_ME__";
|
||||
|
||||
inherit self;
|
||||
machines = {
|
||||
# "jon" will be the hostname of the machine
|
||||
jon =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./modules/shared.nix
|
||||
./modules/disko.nix
|
||||
./machines/jon/configuration.nix
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
|
||||
# Set this for clan commands use ssh i.e. `clan machines update`
|
||||
# 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
|
||||
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon";
|
||||
|
||||
# You can get your disk id by running the following command on the installer:
|
||||
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
|
||||
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
|
||||
disko.devices.disk.main = {
|
||||
device = "/dev/disk/by-id/__CHANGE_ME__";
|
||||
};
|
||||
|
||||
# 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.
|
||||
clan.core.networking.zerotier.controller.enable = true;
|
||||
# Clan services to use. See https://docs.clan.lol/reference/clanServices
|
||||
inventory.instances = {
|
||||
admin = {
|
||||
roles.default.tags.all = { };
|
||||
roles.default.settings.allowedKeys = {
|
||||
# Insert the public key of all your admin machines
|
||||
# All these 'admin machines' will have ssh access to "tags.all" (all machines)
|
||||
# Alternatively set 'users.users.root.openssh.authorizedKeys.keys' in each machine
|
||||
"admin-machine-1" = "__YOUR_PUBLIC_KEY__";
|
||||
};
|
||||
# "sara" will be the hostname of the machine
|
||||
sara =
|
||||
};
|
||||
|
||||
zerotier = {
|
||||
# Replace with the name of your machine that you will use as zerotier-controller
|
||||
# See: https://docs.zerotier.com/controller/
|
||||
# Deploy this machine first to create the network secrets
|
||||
roles.controller.machines."__YOUR_CONTROLLER__" = { };
|
||||
# Peers of the network
|
||||
# tags.all means 'all machines' will joined
|
||||
roles.peer.tags.all = { };
|
||||
};
|
||||
};
|
||||
|
||||
# A mapping of machine names to their nixos configuration.
|
||||
# Allows specifying additional nixos configuration.
|
||||
machines = {
|
||||
somemachine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./modules/shared.nix
|
||||
./modules/disko.nix
|
||||
./machines/sara/configuration.nix
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
|
||||
# Set this for clan commands use ssh i.e. `clan machines update`
|
||||
# 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
|
||||
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@sara";
|
||||
|
||||
# You can get your disk id by running the following command on the installer:
|
||||
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
|
||||
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
|
||||
disko.devices.disk.main = {
|
||||
device = "/dev/disk/by-id/__CHANGE_ME__";
|
||||
};
|
||||
|
||||
# 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>" ]
|
||||
'';
|
||||
|
||||
/*
|
||||
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
|
||||
*/
|
||||
# clan.core.networking.zerotier.networkId = builtins.readFile ../../vars/per-machine/jon/zerotier/zerotier-network-id/value;
|
||||
environment.systemPackages = with pkgs; [ asciinema ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
{ config, ... }:
|
||||
let
|
||||
username = config.networking.hostName;
|
||||
in
|
||||
{
|
||||
imports = [ ./hardware-configuration.nix ];
|
||||
|
||||
# Locale service discovery and mDNS
|
||||
services.avahi.enable = true;
|
||||
|
||||
services.xserver.enable = true;
|
||||
services.xserver.desktopManager.gnome.enable = true;
|
||||
services.xserver.displayManager.gdm.enable = true;
|
||||
# Disable the default gnome apps to speed up deployment
|
||||
services.gnome.core-utilities.enable = false;
|
||||
|
||||
# Enable automatic login for the user.
|
||||
services.displayManager.autoLogin = {
|
||||
enable = true;
|
||||
user = username;
|
||||
};
|
||||
|
||||
users.users.${username} = {
|
||||
initialPassword = username;
|
||||
isNormalUser = true;
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"networkmanager"
|
||||
"video"
|
||||
"audio"
|
||||
"input"
|
||||
"dialout"
|
||||
"disk"
|
||||
];
|
||||
uid = 1000;
|
||||
openssh.authorizedKeys.keys = config.users.users.root.openssh.authorizedKeys.keys;
|
||||
};
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
{ config, ... }:
|
||||
|
||||
let
|
||||
username = config.networking.hostName;
|
||||
in
|
||||
{
|
||||
imports = [ ./hardware-configuration.nix ];
|
||||
|
||||
# Locale service discovery and mDNS
|
||||
services.avahi.enable = true;
|
||||
|
||||
services.xserver.enable = true;
|
||||
services.xserver.desktopManager.gnome.enable = true;
|
||||
services.xserver.displayManager.gdm.enable = true;
|
||||
# Disable the default gnome apps to speed up deployment
|
||||
services.gnome.core-utilities.enable = false;
|
||||
|
||||
# Enable automatic login for the user.
|
||||
services.displayManager.autoLogin = {
|
||||
enable = true;
|
||||
user = username;
|
||||
};
|
||||
|
||||
users.users.${username} = {
|
||||
initialPassword = username;
|
||||
isNormalUser = true;
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"networkmanager"
|
||||
"video"
|
||||
"audio"
|
||||
"input"
|
||||
"dialout"
|
||||
"disk"
|
||||
];
|
||||
uid = 1000;
|
||||
openssh.authorizedKeys.keys = config.users.users.root.openssh.authorizedKeys.keys;
|
||||
};
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
{ lib, clan-core, ... }:
|
||||
|
||||
let
|
||||
suffix = config.clan.core.vars.generators.disk-id.files.diskId.value;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
clan-core.clanModules.disk-id
|
||||
];
|
||||
|
||||
boot.loader.grub.efiSupport = lib.mkDefault true;
|
||||
boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true;
|
||||
disko.devices = {
|
||||
disk = {
|
||||
"main" = {
|
||||
# suffix is to prevent disk name collisions
|
||||
name = "main-" + suffix;
|
||||
type = "disk";
|
||||
# Set the following in flake.nix for each maschine:
|
||||
# device = <uuid>;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
"boot" = {
|
||||
size = "1M";
|
||||
type = "EF02"; # for grub MBR
|
||||
priority = 1;
|
||||
};
|
||||
"ESP" = {
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
"root" = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
clan-core,
|
||||
# Optional, if you want to access other flakes:
|
||||
# self,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
clan-core.clanModules.sshd
|
||||
clan-core.clanModules.root-password
|
||||
# You can access other flakes imported in your flake via `self` like this:
|
||||
# self.inputs.nix-index-database.nixosModules.nix-index
|
||||
];
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{ self, ... }:
|
||||
{
|
||||
perSystem =
|
||||
{
|
||||
self',
|
||||
lib,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
{
|
||||
checks =
|
||||
let
|
||||
nixosMachines = lib.mapAttrs' (
|
||||
name: config: lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel
|
||||
) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations);
|
||||
|
||||
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
|
||||
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
|
||||
in
|
||||
nixosMachines // packages // devShells;
|
||||
};
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{ self, inputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
inputs.clan.flakeModules.default
|
||||
];
|
||||
clan = {
|
||||
meta.name = "__CHANGE_ME__";
|
||||
inherit self;
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
_: {
|
||||
perSystem =
|
||||
{
|
||||
pkgs,
|
||||
inputs',
|
||||
...
|
||||
}:
|
||||
{
|
||||
devShells = {
|
||||
default = pkgs.mkShellNoCC {
|
||||
packages = [
|
||||
inputs'.clan.packages.default
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
|
||||
inputs = {
|
||||
clan.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
|
||||
nixpkgs.follows = "clan/nixpkgs";
|
||||
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts.inputs.nixpkgs-lib.follows = "clan/nixpkgs";
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{ flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } (
|
||||
{ ... }:
|
||||
{
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
imports = [
|
||||
./checks.nix
|
||||
./clan.nix
|
||||
./devshells.nix
|
||||
./formatter.nix
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
_: {
|
||||
perSystem =
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
formatter = pkgs.nixfmt;
|
||||
};
|
||||
}
|
||||
2
templates/clan/minimal/.gitignore
vendored
Normal file
2
templates/clan/minimal/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
result*
|
||||
.direnv/
|
||||
@@ -1,12 +1,22 @@
|
||||
{
|
||||
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
|
||||
inputs.nixpkgs.follows = "clan-core/nixpkgs";
|
||||
inputs = {
|
||||
clan-core.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
|
||||
nixpkgs.follows = "clan-core/nixpkgs";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, clan-core, ... }:
|
||||
{
|
||||
self,
|
||||
clan-core,
|
||||
nixpkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# Usage see: https://docs.clan.lol
|
||||
clan = clan-core.lib.clan { inherit self; };
|
||||
clan = clan-core.lib.clan {
|
||||
inherit self;
|
||||
meta.name = nixpkgs.lib.mkDefault "new-clan";
|
||||
};
|
||||
in
|
||||
{
|
||||
# all machines managed by Clan
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"meta": { "name": "__CHANGE_ME__" },
|
||||
"machines": {},
|
||||
"services": {}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
# DO NOT DELETE
|
||||
# This file is used by the clan cli to discover a clan flake
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
|
||||
inputs.nixpkgs.follows = "clan-core/nixpkgs";
|
||||
|
||||
outputs =
|
||||
{ self, clan-core, ... }:
|
||||
let
|
||||
# Usage see: https://docs.clan.lol
|
||||
clan = clan-core.lib.clan {
|
||||
inherit self;
|
||||
# Ensure this is unique among all clans you want to use.
|
||||
meta.name = "__CHANGE_ME__";
|
||||
|
||||
# All machines in ./machines will be imported.
|
||||
|
||||
# Prerequisite: boot into the installer.
|
||||
# See: https://docs.clan.lol/guides/getting-started/installer
|
||||
# local> mkdir -p ./machines/machine1
|
||||
# local> Edit ./machines/<machine>/configuration.nix to your liking.
|
||||
machines = {
|
||||
# You can also specify additional machines here.
|
||||
# somemachine = {
|
||||
# imports = [ ./some-machine/configuration.nix ];
|
||||
# }
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit (clan.config) nixosConfigurations nixosModules clanInternals;
|
||||
# Add the Clan cli tool to the dev shell.
|
||||
# Use "nix develop" to enter the dev shell.
|
||||
devShells =
|
||||
clan-core.inputs.nixpkgs.lib.genAttrs
|
||||
[
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
]
|
||||
(system: {
|
||||
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
|
||||
packages = [ clan-core.packages.${system}.clan-cli ];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
# contains your disk format and partitioning configuration.
|
||||
../../modules/disko.nix
|
||||
# this file is shared among all machines
|
||||
../../modules/shared.nix
|
||||
# enables GNOME desktop (optional)
|
||||
../../modules/gnome.nix
|
||||
];
|
||||
|
||||
# This is your user login name.
|
||||
users.users.user.name = "<your-username>";
|
||||
|
||||
# Set this for clan commands use ssh i.e. `clan machines update`
|
||||
# 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
|
||||
clan.core.networking.targetHost = "root@<IP>";
|
||||
|
||||
# You can get your disk id by running the following command on the installer:
|
||||
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
|
||||
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
|
||||
disko.devices.disk.main.device = "/dev/disk/by-id/__CHANGE_ME__";
|
||||
|
||||
# IMPORTANT! Add your SSH key here
|
||||
# e.g. > cat ~/.ssh/id_ed25519.pub
|
||||
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.
|
||||
clan.core.networking.zerotier.controller.enable = true;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
../../modules/disko.nix
|
||||
../../modules/shared.nix
|
||||
# enables GNOME desktop (optional)
|
||||
../../modules/gnome.nix
|
||||
];
|
||||
# Put your username here for login
|
||||
users.users.user.name = "<your-username>";
|
||||
|
||||
# Set this for clan commands use ssh i.e. `clan machines update`
|
||||
# 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
|
||||
clan.core.networking.targetHost = "root@<IP>";
|
||||
|
||||
# You can get your disk id by running the following command on the installer:
|
||||
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
|
||||
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
|
||||
disko.devices.disk.main.device = "/dev/disk/by-id/__CHANGE_ME__";
|
||||
|
||||
# IMPORTANT! Add your SSH key here
|
||||
# e.g. > cat ~/.ssh/id_ed25519.pub
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
''
|
||||
__YOUR_SSH_KEY__
|
||||
''
|
||||
];
|
||||
/*
|
||||
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
|
||||
*/
|
||||
# clan.core.networking.zerotier.networkId = builtins.readFile ../../vars/per-machine/jon/zerotier/zerotier-network-id/value;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
clan-core,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
suffix = config.clan.core.vars.generators.disk-id.files.diskId.value;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
clan-core.clanModules.disk-id
|
||||
];
|
||||
|
||||
# DO NOT EDIT THIS FILE AFTER INSTALLATION of a machine
|
||||
# Otherwise your system might not boot because of missing partitions / filesystems
|
||||
boot.loader.grub.efiSupport = lib.mkDefault true;
|
||||
boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true;
|
||||
disko.devices = {
|
||||
disk = {
|
||||
"main" = {
|
||||
# suffix is to prevent disk name collisions
|
||||
name = "main-" + suffix;
|
||||
type = "disk";
|
||||
# Set the following in flake.nix for each maschine:
|
||||
# device = <uuid>;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
"boot" = {
|
||||
size = "1M";
|
||||
type = "EF02"; # for grub MBR
|
||||
priority = 1;
|
||||
};
|
||||
"ESP" = {
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "nofail" ];
|
||||
};
|
||||
};
|
||||
"root" = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
# format = "btrfs";
|
||||
# format = "bcachefs";
|
||||
mountpoint = "/";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
services.xserver.enable = true;
|
||||
services.xserver.desktopManager.gnome.enable = true;
|
||||
services.xserver.displayManager.gdm.enable = true;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
config,
|
||||
clan-core,
|
||||
# Optional, if you want to access other flakes:
|
||||
# self,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
# Enables the OpenSSH server for remote access
|
||||
clan-core.clanModules.sshd
|
||||
# Set a root password
|
||||
clan-core.clanModules.root-password
|
||||
clan-core.clanModules.user-password
|
||||
clan-core.clanModules.state-version
|
||||
|
||||
# You can access other flakes imported in your flake via `self` like this:
|
||||
# self.inputs.nix-index-database.nixosModules.nix-index
|
||||
];
|
||||
|
||||
# Locale service discovery and mDNS
|
||||
services.avahi.enable = true;
|
||||
|
||||
# generate a random password for our user below
|
||||
# can be read using `clan secrets get <machine-name>-user-password` command
|
||||
clan.user-password.user = "user";
|
||||
users.users.user = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"networkmanager"
|
||||
"video"
|
||||
"input"
|
||||
];
|
||||
uid = 1000;
|
||||
openssh.authorizedKeys.keys = config.users.users.root.openssh.authorizedKeys.keys;
|
||||
};
|
||||
}
|
||||
@@ -26,9 +26,11 @@
|
||||
EOF
|
||||
'';
|
||||
evaled = (import "${initialized}/flake.nix").outputs {
|
||||
flake-parts = inputs.flake-parts;
|
||||
self = evaled // {
|
||||
outPath = initialized;
|
||||
};
|
||||
nixpkgs = self.inputs.nixpkgs;
|
||||
clan-core = self;
|
||||
};
|
||||
in
|
||||
|
||||
@@ -24,20 +24,18 @@
|
||||
|
||||
clan = {
|
||||
default = {
|
||||
description = "Initialize a new clan flake";
|
||||
path = ./clan/new-clan;
|
||||
};
|
||||
minimal = {
|
||||
description = "for clans managed via (G)UI";
|
||||
path = ./clan/minimal;
|
||||
description = "Initialize a new clan";
|
||||
path = ./clan/default;
|
||||
};
|
||||
|
||||
flake-parts = {
|
||||
description = "Flake-parts";
|
||||
description = "Initialize a new clan (flake-parts)";
|
||||
path = ./clan/flake-parts;
|
||||
};
|
||||
minimal-flake-parts = {
|
||||
description = "Minimal flake-parts clan template";
|
||||
path = ./clan/minimal-flake-parts;
|
||||
|
||||
minimal = {
|
||||
description = "Minimal Clan";
|
||||
path = ./clan/minimal;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user