From 1978aae39f07302d0a2fb5e48415b4435df754b5 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sat, 13 Apr 2024 15:53:12 +0200 Subject: [PATCH] docs: improve template --- docs/site/index.md | 35 +++++- templates/new-clan/flake.lock | 174 ++++++++++++++++++++++++++ templates/new-clan/flake.nix | 21 ++-- templates/new-clan/modules/disko.nix | 36 ------ templates/new-clan/modules/shared.nix | 9 ++ 5 files changed, 224 insertions(+), 51 deletions(-) create mode 100644 templates/new-clan/flake.lock delete mode 100644 templates/new-clan/modules/disko.nix create mode 100644 templates/new-clan/modules/shared.nix diff --git a/docs/site/index.md b/docs/site/index.md index 5253e3b7..e2c4ad83 100644 --- a/docs/site/index.md +++ b/docs/site/index.md @@ -60,17 +60,42 @@ This command creates the `flake.nix` and `.clan-flake` files for your project. ### Step 3: Verify the Project Structure -Ensure the creation of your project files with a quick directory listing +Ensure that all project files exist by running: -```shell -cd my-clan && ls -la +```bash +tree ``` -You should see `.clan-flake`, `flake.lock`, and `flake.nix` among the files listed, which means you're set up! +This should yield this: + +```bash +. +├── flake.nix +├── machines +│   ├── jon +│   │   ├── configuration.nix +│   │   └── hardware-configuration.nix +│   └── sara +│   ├── configuration.nix +│   └── hardware-configuration.nix +└── modules + └── shared.nix + +5 directories, 6 files +``` + +!!! success + + You just successfully bootstrapped your first clan directory. --- -### Next Steps +### What's Next? + +- [**Deploy Machines**](./getting-started/machines.md): Learn how to deploy to any remote machine. +- **Machine Configuration**: Declare behavior and configuration of machines. + +--- ### Edit Flake.nix diff --git a/templates/new-clan/flake.lock b/templates/new-clan/flake.lock new file mode 100644 index 00000000..22ccc041 --- /dev/null +++ b/templates/new-clan/flake.lock @@ -0,0 +1,174 @@ +{ + "nodes": { + "clan-core": { + "inputs": { + "disko": "disko", + "flake-parts": "flake-parts", + "nixos-generators": "nixos-generators", + "nixpkgs": "nixpkgs", + "sops-nix": "sops-nix", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1713013053, + "narHash": "sha256-ka9INCWd1jTPlK47gcuf1hrdPL7WcZ4UrN/bFHBCldU=", + "ref": "refs/heads/main", + "rev": "579994aea61b92d359d532a9cdc22fe4c4581c39", + "revCount": 2536, + "type": "git", + "url": "https://git.clan.lol/clan/clan-core" + }, + "original": { + "type": "git", + "url": "https://git.clan.lol/clan/clan-core" + } + }, + "disko": { + "inputs": { + "nixpkgs": [ + "clan-core", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712356478, + "narHash": "sha256-kTcEtrQIRnexu5lAbLsmUcfR2CrmsACF1s3ZFw1NEVA=", + "owner": "nix-community", + "repo": "disko", + "rev": "0a17298c0d96190ef3be729d594ba202b9c53beb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "clan-core", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1711846064, + "narHash": "sha256-cqfX0QJNEnge3a77VnytM0Q6QZZ0DziFXt6tSCV8ZSc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "90b1a963ff84dc532db92f678296ff2499a60a87", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "clan-core", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712191720, + "narHash": "sha256-xXtSSnVHURHsxLQO30dzCKW5NJVGV/umdQPmFjPFMVA=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "0c15e76bed5432d7775a22e8d22059511f59d23a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1712468661, + "narHash": "sha256-n2gVVBs+rV+HzPv/N3QQv5cdAXqSkjmaObvfeMqnw2c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "298edc8f1e0dfffce67f50375c9f5952e04a6d02", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "clan-core": "clan-core" + } + }, + "sops-nix": { + "inputs": { + "nixpkgs": [ + "clan-core", + "nixpkgs" + ], + "nixpkgs-stable": [ + "clan-core" + ] + }, + "locked": { + "lastModified": 1712458908, + "narHash": "sha256-DMgBS+jNHDg8z3g9GkwqL8xTKXCRQ/0FGsAyrniVonc=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "39191e8e6265b106c9a2ba0cfd3a4dafe98a31c6", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "clan-core", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711963903, + "narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/templates/new-clan/flake.nix b/templates/new-clan/flake.nix index 9c9effe8..36cb6f3f 100644 --- a/templates/new-clan/flake.nix +++ b/templates/new-clan/flake.nix @@ -19,14 +19,11 @@ machines = { jon = { imports = [ + ./modules/shared.nix ./machines/jon/configuration.nix ./machines/jon/hardware-configuration.nix - clan-core.clanModules.sshd - clan-core.clanModules.diskLayouts - clan-core.clanModules.root-password ]; - nixpkgs.hostPlatform = system; clanCore.machineIcon = null; # Optional, a path to an image file # Set this for clan commands use ssh i.e. `clan machines update` @@ -44,13 +41,11 @@ }; sara = { imports = [ + ./modules/shared.nix ./machines/sara/configuration.nix ./machines/jon/hardware-configuration.nix - clan-core.clanModules.sshd - clan-core.clanModules.diskLayouts - clan-core.clanModules.root-password ]; - nixpkgs.hostPlatform = system; + clanCore.machineIcon = null; # Optional, a path to an image file # Set this for clan commands use ssh i.e. `clan machines update` @@ -64,11 +59,17 @@ }; clan.networking.zerotier.networking.enable = true; - # After jon is deployed, uncomment the following line - # This will allow sara to share the VPN overlay network with jon + /* + After jon is deployed, uncomment the following line + This will allow sara to share the VPN overlay network with jon + */ # clan.networking.zerotier.networkId = builtins.readFile ../jon/facts/zerotier-network-id; }; }; + + specialArgs = { + inherit system; + }; }; in { diff --git a/templates/new-clan/modules/disko.nix b/templates/new-clan/modules/disko.nix deleted file mode 100644 index 18b84cd1..00000000 --- a/templates/new-clan/modules/disko.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - disko.devices = { - disk = { - main = { - type = "disk"; - device = throw "Change this to your disk device"; - content = { - type = "gpt"; - partitions = { - boot = { - size = "1M"; - type = "EF02"; # for grub MBR - }; - ESP = { - size = "512M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - }; - }; - root = { - size = "100%"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; - }; - }; - }; - }; - }; - }; -} diff --git a/templates/new-clan/modules/shared.nix b/templates/new-clan/modules/shared.nix new file mode 100644 index 00000000..cae7a65a --- /dev/null +++ b/templates/new-clan/modules/shared.nix @@ -0,0 +1,9 @@ +{clan-core, system, ...}: +{ + imports = [ + clan-core.clanModules.sshd + clan-core.clanModules.diskLayouts + clan-core.clanModules.root-password + ]; + nixpkgs.hostPlatform = system; +}