From 0e3718ab220eaca3dbd6b638ccc6ecef8707867b Mon Sep 17 00:00:00 2001 From: voidarc Date: Sat, 17 Oct 2026 18:41:53 +0100 Subject: [PATCH] added readme and comments for part 1 --- README.md | 21 +++++++++++++++++++++ flake.nix | 10 ++++++++-- modules/hosts/host/default.nix | 3 +++ modules/hosts/host/system.nix | 2 ++ modules/hosts/newHost/newHost.nix | 5 ++++- modules/hosts/newHost/system.nix | 3 ++- modules/parts.nix | 3 +++ modules/system/bootloader.nix | 8 ++++++++ modules/system/default.nix | 16 +++++++++++++++- modules/system/imports.nix | 5 +++++ modules/system/networking.nix | 8 ++++++++ modules/system/user.nix | 6 ++++++ 12 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b02104b --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Dendritic Example Repo + +Videos can be found [on my channel](https://www.youtube.com/@Adumh00man). + +This is supposed to be a minimal dendritic nix configuration, some things may be +deliberately missing or broken for demonstrative purposes in some commits. + +This repo will most likely not work on bare metal, using a vm is reccomended for +tinkering and getting your head around things. This can be done with the following command: + +```bash +nixos-rebuild build-vm --flake .#host +``` + +Some commits will require impure evaluation, although I will keep this to a minimum. + +Comments have been placed outside of filming to explain what parts of the code do, +as this is a mostly "for reference" repo. + +Any issues or typos or whatever can be reported via [email](mailto://admin@voidarc.co.uk) +or [matrix](https://matrix.to/#/@admin:voidarc.co.uk). Lots of love <3 diff --git a/flake.nix b/flake.nix index e23478e..2bceac9 100644 --- a/flake.nix +++ b/flake.nix @@ -2,13 +2,19 @@ description = "some config"; inputs = { + # Latest stable nixpkgs nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05"; + # Flake parts utils flake-parts.url = "github:hercules-ci/flake-parts"; import-tree.url = "github:vic/import-tree"; }; + # Default import-tree output outputs = inputs: - inputs.flake-parts.lib.mkFlake {inherit inputs;} - (inputs.import-tree ./modules); + # Pass all inputs to outputs + inputs.flake-parts.lib.mkFlake { + # Call mkFlake from flake-parts module + inherit inputs; # Inherit inputs (required to get correct arch for self') + } (inputs.import-tree ./modules); # Pass in all modules using import-tree } diff --git a/modules/hosts/host/default.nix b/modules/hosts/host/default.nix index 695c6d1..1f0f1f0 100644 --- a/modules/hosts/host/default.nix +++ b/modules/hosts/host/default.nix @@ -1,9 +1,12 @@ { + # Import self and universal inputs (different to inputs') self, inputs, ... }: { + # Define nixosConfiguration with hostname "host" flake.nixosConfigurations.host = inputs.nixpkgs.lib.nixosSystem { + # Define modules to import modules = with self.nixosModules; [ hostConfiguration system diff --git a/modules/hosts/host/system.nix b/modules/hosts/host/system.nix index 77daa52..1de01d0 100644 --- a/modules/hosts/host/system.nix +++ b/modules/hosts/host/system.nix @@ -1,5 +1,7 @@ {...}: { + # Define flake part nixosModule "hostConfiguration" and pass in arch specific pkgs flake.nixosModules.hostConfiguration = {pkgs, ...}: { + # Normal nix code within module, add git to systemPackages environment.systemPackages = with pkgs; [ git ]; diff --git a/modules/hosts/newHost/newHost.nix b/modules/hosts/newHost/newHost.nix index 4e13660..fd057ae 100644 --- a/modules/hosts/newHost/newHost.nix +++ b/modules/hosts/newHost/newHost.nix @@ -1,11 +1,14 @@ { + # Import self and universal inputs (different to inputs') self, inputs, ... }: { + # Define nixosConfiguration with hostname "newHost" flake.nixosConfigurations.newHost = inputs.nixpkgs.lib.nixosSystem { + # Define modules to import modules = with self.nixosModules; [ - newHostConfiguration + newHostConfiguration system ]; }; diff --git a/modules/hosts/newHost/system.nix b/modules/hosts/newHost/system.nix index 2986395..d050b7e 100644 --- a/modules/hosts/newHost/system.nix +++ b/modules/hosts/newHost/system.nix @@ -1,8 +1,9 @@ {...}: { + # Define flake part nixosModule "newHostConfiguration" and pass in arch specific pkgs flake.nixosModules.newHostConfiguration = {pkgs, ...}: { + # Normal nix code within module, add git to systemPackages environment.systemPackages = with pkgs; [ fastfetch ]; - }; } diff --git a/modules/parts.nix b/modules/parts.nix index 657e3ca..af68b96 100644 --- a/modules/parts.nix +++ b/modules/parts.nix @@ -1,4 +1,7 @@ { + # Define what systems the modules are runnable on. + # Some pacakges may not have an aarch64 version, consult + # nixpkgs to check. config = { systems = [ "x86_64-linux" diff --git a/modules/system/bootloader.nix b/modules/system/bootloader.nix index 5872676..3cadb80 100644 --- a/modules/system/bootloader.nix +++ b/modules/system/bootloader.nix @@ -1,16 +1,24 @@ {...}: { + # Define flake part nixosModule "bootloader" and pass in pkgs flake.nixosModules.bootloader = {pkgs, ...}: { + # Normal nix code boot = { loader = { + # Set bootloader timeout timeout = 2; efi = { + # Enable efi var mutation canTouchEfiVariables = true; }; + # Enable grub grub = { efiSupport = true; + # Fix resolution issues device = "nodev"; }; }; + + # Set kernel to latest available version kernelPackages = pkgs.linuxPackages_latest; }; }; diff --git a/modules/system/default.nix b/modules/system/default.nix index 196f898..2f4cf66 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -1,10 +1,24 @@ {self, ...}: { + # This module acts as a collection of other modules, for ease + # of use. Adding another module to this list will import it + # for all other modules that import this one. + + # Keep in mind that you cannot import this module alongside + # any of its children. For example, importing this module and + # the user module in the same block is the same as importing + # the user module twice, leading to an error due to trying + # to define the same user twice. + + # Collections should be used for static lists of modules, like + # those that would make up a basic system, as seen here. + + # Define flake part nixosModule "system" flake.nixosModules.system = {...}: let modules = with self.nixosModules; [ user networking bootloader - imports + imports ]; in { imports = modules; diff --git a/modules/system/imports.nix b/modules/system/imports.nix index 2edf636..f7eb8ba 100644 --- a/modules/system/imports.nix +++ b/modules/system/imports.nix @@ -1,6 +1,11 @@ {...}: { + # Define flake part nixosModule "imports" flake.nixosModules.imports = {...}: { + # Import sibling file imports = [ + # Prefacing file names with underscores means that + # import-tree will ignore them. You do not need to + # preface files that don't have a ".nix" ending ./_hardware-configuration.nix ]; }; diff --git a/modules/system/networking.nix b/modules/system/networking.nix index 1c04fa7..519354f 100644 --- a/modules/system/networking.nix +++ b/modules/system/networking.nix @@ -1,17 +1,25 @@ {...}: { + # Define flake part nixosModule "networking" flake.nixosModules.networking = {...}: { + # Normal nix code networking = { + # Enable networkManager networkmanager = { enable = true; + # Disable router dns dns = "none"; }; + # cloudflare nameservers nameservers = [ "1.1.1.1" "8.8.8.8" ]; + # disable firewall firewall.enable = false; }; + # Disable "wait-online" target, makes connecting to network + # async on boot systemd.services.NetworkManager-wait-online.enable = false; }; } diff --git a/modules/system/user.nix b/modules/system/user.nix index d1b5b35..658cc5b 100644 --- a/modules/system/user.nix +++ b/modules/system/user.nix @@ -1,8 +1,14 @@ {...}: { + # Define flake part nixosModule "user" flake.nixosModules.user = {...}: { + # Normal nix code + # Define user called user01 users.users.user01 = { + # Make not root explicitly (prevents permission issues) isNormalUser = true; + # Password for vm initialPassword = "password"; + # Allow use of sudo with password extraGroups = [ "root" "wheel"