### Setting Up a Dendritic Flake with flake-parts and import-tree Source: https://context7.com/vic/dendritic/llms.txt The entry point for a Dendritic project is a `flake.nix` that uses `import-tree` to automatically import all module files from a directory. This setup leverages `flake-parts` for module management and `import-tree` for automatic module discovery. ```nix # flake.nix { inputs = { flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; import-tree.url = "github:vic/import-tree"; nixpkgs.url = "github:nixos/nixpkgs/25.11"; }; # All .nix files in ./modules are automatically imported as flake-parts modules outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); } ``` -------------------------------- ### Cross-Cutting Concern Module for Shell Configuration Source: https://context7.com/vic/dendritic/llms.txt This Nix module defines a single concern, shell configuration, that applies across multiple configuration classes like NixOS, Darwin, and nix-on-droid. Each class gets its own submodule for specific settings. ```nix # modules/shell.nix { flake.modules = { nixos.shell = { pkgs, ... }: { programs.fish.enable = true; users.users.${config.meta.username}.shell = pkgs.fish; }; darwin.shell = { pkgs, ... }: { programs.fish.enable = true; }; nixOnDroid.shell = { pkgs, ... }: { user.shell = lib.getExe pkgs.zsh; }; }; } ``` -------------------------------- ### Cross-Cutting Concern Module for Admin User Configuration Source: https://context7.com/vic/dendritic/llms.txt This Nix module abstracts platform-specific differences for configuring administrator users across NixOS and Darwin systems. It ensures consistent admin user setup while accommodating OS variations. ```nix # modules/admin.nix { flake.modules = { nixos.admin = { users.users.${config.meta.username} = { isNormalUser = true; extraGroups = [ "wheel" ]; }; }; darwin.admin.system.primaryUser = config.meta.username; }; } ``` -------------------------------- ### Utility Module for Specific Configuration Aspects Source: https://context7.com/vic/dendritic/llms.txt This Nix code defines a small utility module for specific configuration aspects, such as bootloader settings. It can be easily imported by host configurations to manage particular settings like disabling the GRUB bootloader. ```nix # modules/no-boot.nix { flake.modules.nixos.no-boot = { boot.loader.grub.enable = false; fileSystems."/".device = "/dev/no-boot"; }; } ``` -------------------------------- ### Setting Top-Level Option Values in Nix Source: https://context7.com/vic/dendritic/llms.txt This Nix code snippet demonstrates how to set values for custom top-level options. These values can then be read by any module via `config.meta.*`, providing a centralized way to manage global configuration parameters. ```nix # modules/meta.nix { meta.username = "iam"; } ``` -------------------------------- ### Exposing NixOS Configurations with flake-parts Source: https://context7.com/vic/dendritic/llms.txt This Nix code uses `flake-parts` to expose configurations as flake outputs. Each configuration imports a single top-level module, adhering to the recommendation of modularity and simplifying NixOS system definitions. ```nix # modules/configurations.nix { flake.nixosConfigurations.my-laptop = lib.nixosSystem { # recommendation is for nixos to include only a single module # and make that module import others as needed. modules = [ self.modules.nixos.my-laptop ]; }; # instantiate other kinds of configurations like darwinConfigurations, nixDroid, etc. } ``` -------------------------------- ### Host-Specific Configuration Module in Nix Source: https://context7.com/vic/dendritic/llms.txt This Nix module defines a host-specific configuration. It imports relevant concern modules (like admin and shell) and sets host-specific options, allowing for tailored configurations per machine. ```nix # modules/my-laptop.nix { flake.modules.nixos.my-laptop = { imports = with self.modules.nixos; [ admin shell no-boot # any other usability concerns for my-laptop ]; nixpkgs.hostPlatform = "x86_64-linux"; }; } ``` -------------------------------- ### Defining Supported Systems in Nix Flake Source: https://context7.com/vic/dendritic/llms.txt This Nix code snippet specifies the systems supported by the flake. This is crucial for generating per-system outputs and ensuring compatibility across different architectures and operating systems. ```nix # modules/systems.nix { systems = [ "x86_64-linux" "aarch64-linux" ]; } ``` -------------------------------- ### Defining Custom Top-Level Options in Nix Source: https://context7.com/vic/dendritic/llms.txt This Nix code defines custom options at the top level of a configuration. These options can be accessed by any module through `config`, effectively replacing the `specialArgs` anti-pattern and promoting cleaner configuration management. ```nix # modules/options/meta.nix { options.meta.username = lib.mkOption { description = "Principal User's username"; type = lib.types.str; }; } ``` -------------------------------- ### Enabling flake-parts Modules System Source: https://context7.com/vic/dendritic/llms.txt This Nix code snippet enables the flake-parts modules system, which is used to store and manage lower-level NixOS, Darwin, and other configuration modules within a Dendritic project. ```nix # modules/options/flakeparts-modules.nix { imports = [ inputs.flake-parts.flakeModules.modules ]; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.