### Initialize Dendrix Template Source: https://dendrix.oeiuwq.com/Getting-Started This command initializes a new system flake using a Dendrix template. It's a quick way to start a new project with Dendrix pre-configured, allowing users to then edit their `layers.nix` file. ```bash nix flake init github:vic/dendrix#template ``` -------------------------------- ### Defining Flake Inputs and Modules with vic/flake-file Source: https://dendrix.oeiuwq.com/print This example demonstrates how a flake-parts module can define its own flake inputs and contribute to the main flake configuration using `flake-file`. The `./modules/home/vim.nix` file specifies `nixvim` as an input and configures Home Manager for Vim. ```nix # ./modules/home/vim.nix { inputs, ... }: { flake-file.inputs.nixvim.url = "github:nix-community/nixvim"; flake.modules.homeManager.vim = { # use inputs.nixvim }; } ``` -------------------------------- ### Load Development Environment with Nix Source: https://dendrix.oeiuwq.com/Development This command loads the development environment for Dendrix using Nix. It is the primary way to access the project's development tools and utilities. Ensure you have Nix installed and the project cloned locally. ```bash nix develop ./dev ``` -------------------------------- ### Organize Nix Logic with Flake-Parts Source: https://dendrix.oeiuwq.com/Dendritic This snippet demonstrates how to move Nix logic out of `flake.nix` into modular flake-parts. The `flake.nix` file acts as an entrypoint, while modules in `./modules` handle specific configurations like Home Manager's Vim setup. It shows how to declare inputs and contribute modules for different configuration classes. ```nix # ./modules/home/vim.nix { inputs, ... }: { flake-file.inputs.nixvim.url = "github:nix-community/nixvim"; flake.modules.homeManager.vim = { # use inputs.nixvim }; } ``` -------------------------------- ### Run Ephemeral NixOS on Distrosea Source: https://dendrix.oeiuwq.com/Getting-Started This command allows users to run an ephemeral NixOS environment on Distrosea, a web-based NixOS instance. It's useful for trying out NixOS or Dendrix without a local installation. Ensure you select the `minimal` release on Distrosea. ```bash nix run .#os-switch template ``` -------------------------------- ### Define Host Configurations Across OS with Aspects Source: https://dendrix.oeiuwq.com/Dendritic This example illustrates how to define system configurations for different operating systems (NixOS and macOS) using a feature-based approach (aspects). The `scrolling-desktop` aspect is applied to both, with OS-specific modules enabling different underlying tools (`niri` for Linux, `paneru` for macOS). This promotes cross-platform consistency for features. ```nix # ./modules/hosts.nix { inputs, ... }: { flake.nixosConfigurations.my-host = inputs.nixpkgs.lib.nixosSystem { system = "aarm64-linux"; modules = with inputs.self.modules.nixos; [ ai ssh vpn mac-like-keyboard scrolling-desktop ]; }; flake.darwinConfigurations.my-host = inputs.nix-darwin.lib.darwinSystem { system = "aarm64-darwin"; modules = with inputs.self.modules.darwin; [ ai ssh vpn scrolling-desktop ]; }; } ``` -------------------------------- ### Basic flake.nix Structure with flake-parts and import-tree Source: https://dendrix.oeiuwq.com/print This is a standard flake.nix file for a Dendritic setup. It defines inputs including flake-parts and import-tree, and uses import-tree to recursively load all modules from the './modules' directory. This approach centralizes module loading and keeps the flake.nix file clean. ```nix # flake.nix { inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; import-tree.url = "github:vic/import-tree"; # all other inputs your flake needs, like nixpkgs. }; outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); } ``` -------------------------------- ### Define a Dendrix AI Layer in Nix Source: https://dendrix.oeiuwq.com/Dendrix-Layers This example shows how an AI layer might be defined within the Dendrix community repository. It imports AI aspects from different repositories, defines community-level options, and sets up system-wide packages and extensions for AI features. ```nix # This is an example of how an AI Layer might be defined in our Dendrix community repository. # # ./dev/layers/ai/modules/default.nix { inputs, lib, ... }: let ai-one = inputs.dendrix.repo-one.ai; # import-tree for AI aspect from repo-one. ai-two = inputs.dendrix.repo-two.ai; # import-tree for AI aspect from repo-two. in { imports = [ ai-one ai-two ]; # flake-level community options. options.ai.something.enable = lib.mkEnableOption "Enable something for AI"; # packages,checks,devshells,etc for AI perSystem = {pkgs, ...}: { packages.ai-cli = {}; }; # extensions to the ai aspect. flake.modules.nixos.ai = {}; flake.modules.darwin.ai = {}; flake.modules.homeManager.ai = {}; } ``` -------------------------------- ### Dendritic SSH Aspect Configuration Example Source: https://dendrix.oeiuwq.com/print This Nix code illustrates the dendritic configuration pattern for managing SSH facilities across different Nix configuration classes (nixos, darwin, homeManager). It defines an 'ssh' aspect and shows how to configure it for each class, including custom ports and package-related configurations. ```nix # modules/ssh.nix -- like every other file inside modules, this is a flake-parts module. { inputs, config, ... }: let scpPort = 2277; # let-bindings or custom flake-parts options communicate values across classes in { flake.modules.nixos.ssh = { # Linux config: setup OpenSSH server, firewall-ports, etc. }; flake.modules.darwin.ssh = { # MacOS config: enable MacOS builtin ssh server, etc. }; flake.modules.homeManager.ssh = { # setup ~/.ssh/config, authorized_keys, private keys secrets, etc. }; perSystem = { pkgs, ... }: { # custom packages taking advantage of ssh facilities, eg deployment-scripts. }; } ``` -------------------------------- ### Dendrix Flagged Import Example (Nix) Source: https://dendrix.oeiuwq.com/Dendrix-Conventions This Nix code snippet demonstrates how to use Dendrix's `flagged` function to selectively include or exclude modules based on flags present in their paths. It shows how to import all modules with the '+vim' flag while excluding those with the '+emacs' flag. ```nix { imports = [ # Include anything with +vim on their path. # Exclude anything with +emacs on their path. (inputs.dendrix.your-repo.flagged "-emacs +vim") ]; } ``` -------------------------------- ### Import All Modules Recursively with import-tree Source: https://dendrix.oeiuwq.com/Dendritic This flake.nix file demonstrates how to use the 'import-tree' flake utility to recursively load all Nix modules from the './modules' directory. This centralizes module loading, eliminating the need for manual imports and simplifying project structure. ```nix # flake.nix { inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; import-tree.url = "github:vic/import-tree"; # all other inputs your flake needs, like nixpkgs. }; outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); } ``` -------------------------------- ### Feature-Based NixOS and macOS Configurations Source: https://dendrix.oeiuwq.com/print This snippet shows how to define NixOS and macOS system configurations based on features rather than hostnames. It uses `flake.nixosConfigurations` and `flake.darwinConfigurations` to assemble modules like 'ai', 'ssh', 'vpn', 'mac-like-keyboard', and 'scrolling-desktop', allowing for cross-platform feature composition. ```nix # ./modules/hosts.nix { inputs, ... }: { flake.nixosConfigurations.my-host = inputs.nixpkgs.lib.nixosSystem { system = "aarm64-linux"; modules = with inputs.self.modules.nixos; [ ai ssh vpn mac-like-keyboard scrolling-desktop ]; }; flake.darwinConfigurations.my-host = inputs.nix-darwin.lib.darwinSystem { system = "aarm64-darwin"; modules = with inputs.self.modules.darwin; [ ai ssh vpn scrolling-desktop ]; }; } ``` -------------------------------- ### Dendrix Development Environment Menu Source: https://dendrix.oeiuwq.com/Development This is the interactive menu displayed upon entering the Dendrix development shell. It lists various commands available for common development tasks such as building, testing, formatting, and dependency management. ```bash nix develop ./dev 🔨 Welcome to devshell [[general commands]] book - serve dev/book check - run flake checks discover - generate files with discovery-community-aspects enabled. elm-build - compile elm debug mode elm-check - run elm tests elm-registry - use elm2nix to regen dependencies registry for nix files - fmt / genfiles / fmt fmt - run code formatter genfiles - generate files from sources menu - prints this menu pins - run npins inside dev ``` -------------------------------- ### Shared vs. Private Nix Configuration Structure Source: https://dendrix.oeiuwq.com/Dendrix-Layers This illustrates how a repository can share specific parts of its Nix configuration with the community (e.g., for AI features) while keeping host-specific or user-specific configurations private. This allows for modularity and controlled contribution. ```nix # only this is shared to the community ./modules/community/ai.nix # these two are not community shared. ./modules/hosts/myhost/ai.nix # augmented for host specific gpu. ./modules/users/vic/ai.nix # with user specific credentials. ``` -------------------------------- ### Configure User Aspects with Flake-Parts Modules (NixOS, macOS, Home Manager) Source: https://dendrix.oeiuwq.com/print This snippet defines user configurations for NixOS, macOS, and Home Manager using flake-parts modules. It sets up a normal user with 'wheel' group on NixOS, designates a primary user on macOS, and configures username and home directory for Home Manager, adapting to the operating system. ```nix let userName = "vic"; # a shared value between classes in { flake.modules.nixos.${userName} = { users.users.${userName} = { isNormalUser = true; extraGroups = [ "wheel" ]; }; }; flake.modules.darwin.${userName} = { system.primaryUser = userName; # note that configuring a user is different on MacOS than on NixOS. }; flake.modules.homeManager.${userName} = { pkgs, lib, ... }: { home.username = lib.mkDefault userName; home.homeDirectory = lib.mkDefault (if pkgs.stdenvNoCC.isDarwin then "/Users/${userName}" else "/home/${userName}"); home.stateVersion = lib.mkDefault "25.05"; }; } ``` -------------------------------- ### Import Dendrix Trees/Layers in flake-parts Source: https://dendrix.oeiuwq.com/Getting-Started This code demonstrates how to import Dendrix trees or layers within a flake-parts module. It shows how to reference specific aspects provided by Dendrix, such as `macos-keys` or general layers found in the `dev/layers` directory. ```nix { inputs, ... }: { imports = [ # inputs.dendrix.vic-vix.macos-keys # example aspect. # inputs.dendrix.vix # example layer, see https://github.com/vic/dendrix/tree/main/dev/layers ]; } ``` -------------------------------- ### Add Dendrix Input to Nix Flake Source: https://dendrix.oeiuwq.com/Getting-Started This snippet shows how to add the Dendrix flake input to your Nix project's `flake.nix` file. It specifies the GitHub URL for the Dendrix repository. Uncommented lines show how to flatten dependencies if needed. ```nix { inputs.dendrix.url = "github:vic/dendrix"; # Flatten dependencies. #inputs.dendrix.inputs.import-tree.follows = "import-tree"; #inputs.dendrix.inputs.nixpkgs-lib.follows = "nixpkgs-lib"; } ``` -------------------------------- ### Import Dendrix Aspects and Shared Files in Nix Source: https://dendrix.oeiuwq.com/Dendrix-Trees This snippet demonstrates how to import all shared files from a repository and specific aspect files within a Nix configuration. It utilizes the `dendrix` input to access these configurations. ```nix { inputs, ...}: { imports = [ inputs.dendrix.some-repo # ALL shared files in a repository. intended to be used WITH `.filter`. inputs.dendrix.some-repo.some-aspect # Files that define flake.modules..some-aspect ]; } ``` -------------------------------- ### Import Dendrix AI Layer in Nix Configuration Source: https://dendrix.oeiuwq.com/Dendrix-Layers This snippet demonstrates how to import the Dendrix AI layer into your own Nix flake module. It assumes you have Dendrix configured as an input in your flake.nix. ```nix # your ./modules/ai.nix { inputs, ... }: { imports = [ inputs.dendrix.ai ]; } ``` -------------------------------- ### Configure User Aspect Across NixOS, Darwin, and Home Manager Source: https://dendrix.oeiuwq.com/Dendritic This Nix module configures the 'vic' user aspect for NixOS, Darwin, and Home Manager. It shows how to define user-specific configurations, adapting to differences between system classes, and uses a let-binding for the shared userName value. ```nix # modules/vic.nix -- a flake-parts module that configures the "vic" user aspect. let userName = "vic"; # a shared value between classes in { flake.modules.nixos.${userName} = { users.users.${userName} = { isNormalUser = true; extraGroups = [ "wheel" ]; }; }; flake.modules.darwin.${userName} = { system.primaryUser = userName; # note that configuring a user is different on MacOS than on NixOS. }; flake.modules.homeManager.${userName} = { pkgs, lib, ... }: { home.username = lib.mkDefault userName; home.homeDirectory = lib.mkDefault (if pkgs.stdenvNoCC.isDarwin then "/Users/${userName}" else "/home/${userName}"); home.stateVersion = lib.mkDefault "25.05"; }; } ``` -------------------------------- ### Configure SSH Aspect Across NixOS, Darwin, and Home Manager Source: https://dendrix.oeiuwq.com/Dendritic This Nix module configures the 'ssh' aspect for NixOS, Darwin, and Home Manager. It demonstrates how to define configurations for different system classes within a single module file, using let-bindings to share values like scpPort. ```nix # modules/ssh.nix -- like every other file inside modules, this is a flake-parts module. { inputs, config, ... }: let scpPort = 2277; # let-bindings or custom flake-parts options communicate values across classes in { flake.modules.nixos.ssh = { # Linux config: setup OpenSSH server, firewall-ports, etc. }; flake.modules.darwin.ssh = { # MacOS config: enable MacOS builtin ssh server, etc. }; flake.modules.homeManager.ssh = { # setup ~/.ssh/config, authorized_keys, private keys secrets, etc. }; perSystem = {pkgs, ...}: { # custom packages taking advantage of ssh facilities, eg deployment-scripts. }; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.