### Initialize Flake with Dendrix Template Source: https://vic.github.io/dendrix/print This command initializes a new Nix flake project using a template provided by the dendrix repository. It's a quick way to start a new system configuration with Dendrix. ```Shell nix flake init github:vic/dendrix#template ``` -------------------------------- ### Import Dendrix Trees/Layers in Flake-Parts Source: https://vic.github.io/dendrix/Getting-Started This code shows how to import Dendrix configurations (trees or layers) into your flake-parts setup. By adding the Dendrix input, you can then reference its modules, such as example aspects like 'macos-keys' or general layers, within your system's configuration. ```Nix { imports = [ # inputs.dendrix.vic-vix.macos-keys # example aspect. # inputs.dendrix.vix # example layer, see https://github.com/vic/dendrix/tree/main/dev/layers ]; } ``` -------------------------------- ### Initialize New System Flake with Dendrix Template Source: https://vic.github.io/dendrix/Getting-Started This command-line instruction initializes a new system flake using a template provided by the Dendrix project. It's a quick way to start a new project with Dendrix's pre-configured structure and settings. ```Shell nix flake init github:vic/dendrix#template ``` -------------------------------- ### Minimal Flake Configuration with import-tree Source: https://vic.github.io/dendrix/print This example shows a minimal `flake.nix` file that uses `flake-parts` and `import-tree` to load all Nix modules from the `./modules` directory recursively. This approach keeps the main flake file clean and focused on inputs. ```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); } ``` -------------------------------- ### Run Ephemeral NixOS with Dendrix Source: https://vic.github.io/dendrix/Getting-Started This command allows you to run an ephemeral NixOS environment directly from your flake, using the 'os-switch' template provided by Dendrix. This is useful for testing configurations or trying out NixOS without a full installation. ```Shell nix run .#os-switch template ``` -------------------------------- ### Import Dendrix Trees/Layers in Flake-Parts Source: https://vic.github.io/dendrix/print Demonstrates how to import Dendrix trees or layers into your flake-parts configuration. This allows you to leverage community-provided aspects for your Nix setup. ```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 ]; } ``` -------------------------------- ### Defining a Community AI Layer Source: https://vic.github.io/dendrix/print An example of how an AI Layer might be defined within the Dendrix community repository. It imports AI aspects from different repositories, defines flake-level options, and sets up system-specific configurations and extensions. ```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 = { }; } ``` -------------------------------- ### Configure Formatter with Flake-Parts Source: https://vic.github.io/dendrix/print This Nix snippet configures the system's formatter to be 'alejandra' using flake-parts. It's an example of how individual features can be defined in separate files within the modules directory. ```Nix # modules/flake/formatter.nix { perSystem = {pkgs, ...}: { formatter = pkgs.alejandra; }; } ``` -------------------------------- ### Set System Formatter in Nix Configuration Source: https://vic.github.io/dendrix/Dendritic This Nix module configures the system's formatter to 'alejandra'. It's an example of how individual modules within the `./modules` directory can contribute to system-wide settings, keeping the main `flake.nix` clean. ```Nix # modules/flake/formatter.nix { perSystem = {pkgs, ...}: { formatter = pkgs.alejandra; }; } ``` -------------------------------- ### Share User Configuration Across Nix Environments Source: https://vic.github.io/dendrix/Dendritic This example illustrates sharing a username configuration across NixOS, macOS, and Home Manager using the Dendritic pattern. It defines user-specific settings for each environment within a single module file, avoiding the use of `specialArgs` by utilizing let bindings for shared values. ```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; # 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"; }; } ``` -------------------------------- ### Define a Dendrix AI Layer in Nix Source: https://vic.github.io/dendrix/Dendrix-Layers Provides an example of how a Dendrix Layer for an 'ai' aspect might be defined within the community repository. It shows importing multiple community AI aspects, defining flake-level options, and configuring packages and extensions. ```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 Source: https://vic.github.io/dendrix/print Illustrates the dendritic pattern for configuring a cross-cutting concern, like SSH, across different Nix configuration classes (NixOS, macOS, Home Manager). Each class gets its specific configuration within the same aspect file. ```Nix # modules/ssh.nix -- like every other file inside modules, this is a flake-parts module. { config, ... }: { flake.modules.nixos.ssh = { # Linux config: server, firewall-ports, etc. }; flake.modules.darwin.ssh = { # MacOS config: enable builtin ssh server, etc. }; flake.modules.homeManager.ssh = { # setup ~/.ssh/config or keys. }; perSystem = {pkgs, ...}: { # expose custom package/checks/devshells by this aspect. }; } ``` -------------------------------- ### Initialize Flake with Dendritic Configuration using import-tree Source: https://vic.github.io/dendrix/Dendritic This `flake.nix` sets up a project using flake-parts and the `vic/import-tree` utility to recursively load all Nix modules from the `./modules` directory. This centralizes configuration loading, making the `flake.nix` file minimal and focused on inputs. ```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); } ``` -------------------------------- ### Run Ephemeral NixOS with Dendrix Source: https://vic.github.io/dendrix/print This command allows you to run an ephemeral NixOS environment on the web, likely for testing or demonstration purposes. It uses a template provided by Dendrix. ```Shell nix run .#os-switch template ``` -------------------------------- ### Enter Dendrix Development Shell Source: https://vic.github.io/dendrix/Development This command enters the Dendrix development shell, providing access to a menu of predefined commands for managing the project. It's recommended to use `direnv` or run this command directly. ```Nix nix develop ./dev ``` -------------------------------- ### Add Dendrix Input to Nix Flake Source: https://vic.github.io/dendrix/Getting-Started This snippet demonstrates how to add the Dendrix project as an input to your Nix flake configuration. It specifies the URL for the Dendrix repository and includes commented-out lines for flattening dependencies, which might be useful for managing transitive dependencies. ```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"; } ``` -------------------------------- ### Using a Dendrix AI Layer Source: https://vic.github.io/dendrix/print Shows how to import a community-managed AI layer into your own Nix flake module. This allows you to utilize pre-configured AI facilities shared by the community. ```Nix # your ./modules/ai.nix { inputs, ...}: { imports = [ inputs.dendrix.ai ]; } ``` -------------------------------- ### Importing Dendrix Repositories and Aspects Source: https://vic.github.io/dendrix/print Demonstrates how to import all shared files from a repository or specific aspect files within a repository using Dendrix. This is intended for use with filtering mechanisms. ```Nix # your ./modules/something.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 ]; } ``` -------------------------------- ### Add Dendrix Input to Flake Source: https://vic.github.io/dendrix/print This snippet shows how to add the dendrix GitHub repository as an input to your Nix flake configuration. It also includes commented-out lines for potentially following specific dependency versions. ```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"; } ``` -------------------------------- ### Importing Dendrix Configurations in Nix Source: https://vic.github.io/dendrix/Dendrix-Trees This snippet demonstrates how to import shared files and specific aspects from a repository using Dendrix. It shows the structure for accessing all shared files within a repository and files defining specific classes within aspects. ```Nix { 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 ]; } ``` -------------------------------- ### Nix Configuration with Flake-Parts Source: https://vic.github.io/dendrix/Dendritic This snippet illustrates how to structure Nix configurations using the dendritic pattern with flake-parts. It shows how features are organized by aspect and how modules can be extended by adding new files that contribute to the same aspect. ```Nix flake.modules..feature-x ``` -------------------------------- ### Import Dendrix AI Layer in Nix Source: https://vic.github.io/dendrix/Dendrix-Layers Demonstrates how to import a community-managed AI layer from Dendrix into your own Nix flake configuration. This involves specifying the Dendrix input and importing the 'ai' module. ```Nix # your ./modules/ai.nix { inputs, ...}: { imports = [ inputs.dendrix.ai ]; } ``` -------------------------------- ### Community Shared vs. Private Nix Configurations Source: https://vic.github.io/dendrix/print Illustrates the separation between files shared with the community via Dendrix and those kept private for host or user-specific configurations. Only community-shared files are intended for reuse by others. ```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 SSH Aspect Across NixOS, macOS, and Home Manager Source: https://vic.github.io/dendrix/Dendritic This Nix module demonstrates the Dendritic pattern by configuring the 'ssh' aspect for NixOS, macOS, and Home Manager. It shows how to define system-specific configurations within a single file, leveraging flake-parts' `flake.modules..` option. ```Nix # modules/ssh.nix -- like every other file inside modules, this is a flake-parts module. { config, ...}: { flake.modules.nixos.ssh = { # Linux config: server, firewall-ports, etc. }; flake.modules.darwin.ssh = { # MacOS config: enable builtin ssh server, etc. }; flake.modules.homeManager.ssh = { # setup ~/.ssh/config or keys. }; perSystem = {pkgs, ...}: { # expose custom package/checks/devshells by this aspect. }; } ``` -------------------------------- ### Configure NixOS User with Flake-Parts Source: https://vic.github.io/dendrix/print This snippet demonstrates how to configure a NixOS user named 'vic' using flake-parts. It sets the user as a normal user and adds them to the 'wheel' group. ```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; # 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"; }; } ``` -------------------------------- ### Filtering with Dendrix Flags Source: https://vic.github.io/dendrix/print This Nix code snippet demonstrates how to use Dendrix flags to include or exclude files based on path patterns. It shows how to import all files 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") ]; } ``` -------------------------------- ### Filter Modules with Flags in Nix Source: https://vic.github.io/dendrix/Dendrix-Conventions This Nix code snippet demonstrates how to use Dendrix flags to include or exclude modules based on their paths. It utilizes the `flagged` function to apply filtering logic, allowing consumers to customize which capabilities are included or excluded. ```Nix { imports = [ # Include anything with +vim on their path. # Exclude anything with +emacs on their path. (inputs.dendrix.your-repo.flagged "-emacs +vim") ]; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.