User Templates Guide

This NixOS template includes several pre-configured user templates for different use cases. Each template provides a complete Home Manager configuration optimized for specific workflows.

Available User Templates

Basic User (user.nix)

Developer User (developer.nix)

Gaming User (gamer.nix)

Minimal User (minimal.nix)

Server Admin (server.nix)

Quick Start

1. Choose a Template

# List available user templates
just list-users

# Show template details
just show-user developer

2. Initialize User Configuration

# Initialize a new user configuration from template
just init-user myhost developer

# Or copy manually
cp home/users/developer.nix hosts/myhost/home.nix

3. Customize Configuration

Edit the created home.nix file to customize:

4. Apply Configuration

# Test the configuration
just test myhost

# Apply the configuration
just switch myhost

Template Details

Basic User Template

Applications included:

Configuration highlights:

Customization points:

Developer Template

Applications included:

Configuration highlights:

Customization points:

Gaming Template

Applications included:

Configuration highlights:

Customization points:

Minimal Template

Applications included:

Configuration highlights:

Customization points:

Server Admin Template

Applications included:

Configuration highlights:

Customization points:

Customization Guide

Changing Desktop Environment

Each template imports a desktop profile. To change desktop environments:

imports = [
  # Change this line to your preferred desktop
  ../profiles/niri.nix       # For niri
  # ../profiles/gnome.nix    # For GNOME
  # ../profiles/hyprland.nix # For Hyprland
  # ../profiles/niri.nix     # For Niri
];

Adding Custom Applications

Add applications to the home.packages section:

home.packages = with pkgs; [
  # Existing packages...

  # Add your custom applications
  thunderbird    # Email client
  gimp          # Image editor
  libreoffice   # Office suite
];

Customizing Shell Configuration

Modify the bash configuration:

programs.bash = {
  enable = true;

  shellAliases = {
    # Add your custom aliases
    myalias = "my command";
  };

  bashrcExtra = ''
    # Add custom bash configuration
    export MY_VARIABLE="value"
  '';
};

Environment Variables

Set custom environment variables:

home.sessionVariables = {
  # Add your environment variables
  MY_APP_CONFIG = "${config.home.homeDirectory}/.config/myapp";
  CUSTOM_PATH = "/usr/local/custom/bin";
};

Multiple Users

You can configure different users with different templates:

# In your NixOS configuration
home-manager.users = {
  alice = import ./hosts/desktop/alice-home.nix;
  bob = import ./hosts/desktop/bob-home.nix;
};

Where each user file is based on a different template.

Template Comparison

Feature Basic Developer Gaming Minimal Server
Resource Usage Low Medium High Very Low Low
Applications Essential Development Gaming Minimal Admin Tools
Desktop GNOME Any GNOME None None
Complexity Simple Advanced Medium Very Simple Advanced
Use Case General Coding Gaming Embedded Administration

Creating Custom Templates

To create your own user template:

  1. Copy existing template:

    cp home/users/user.nix home/users/mytemplate.nix
    
  2. Customize the configuration:
    • Modify applications in home.packages
    • Adjust shell configuration
    • Add specific environment variables
    • Configure programs as needed
  3. Test the template:

    just init-user testhost mytemplate
    just test testhost
    
  4. Document your template:
    • Add comments explaining the purpose
    • Document customization points
    • Include usage examples

Troubleshooting

Common Issues

Template not found:

ERROR: Template 'mytemplate' not found

Configuration conflicts:

ERROR: The option 'programs.git.userName' is defined multiple times

Desktop environment conflicts:

ERROR: Multiple desktop environments enabled

Getting Help

  1. Check template documentation in comments
  2. Validate configuration: just validate
  3. Test before switching: just test hostname
  4. Check Home Manager documentation
  5. Review NixOS options search

Best Practices

Template Selection

  1. Start simple: Begin with basic template, add features as needed
  2. Match use case: Choose template that fits your primary usage
  3. Consider resources: Ensure system can handle template requirements
  4. Plan for growth: Choose template that can grow with your needs

Customization

  1. Document changes: Add comments for custom modifications
  2. Test thoroughly: Always test before applying to main system
  3. Backup configurations: Keep working configurations safe
  4. Version control: Use git to track configuration changes

Maintenance

  1. Regular updates: Keep templates updated with system
  2. Clean unused: Remove packages and configurations not needed
  3. Monitor resources: Check system performance regularly
  4. Security updates: Keep security-sensitive applications current

Advanced Usage

Template Inheritance

Create templates that inherit from others:

# custom-developer.nix
{ config, lib, pkgs, inputs, outputs, ... }:

{
  imports = [
    ./developer.nix  # Inherit from developer template
  ];

  # Override or extend configurations
  home.packages = with pkgs; [
    # Additional packages beyond developer template
    postman
    insomnia
  ];

  # Override git configuration
  programs.git.userEmail = lib.mkForce "custom@example.com";
}

Conditional Configurations

Use conditions to customize based on system:

{ config, lib, pkgs, ... }:

{
  # Conditional gaming applications
  home.packages = with pkgs; [
    # Always include basics
    firefox
    git
  ] ++ lib.optionals (config.hardware.nvidia.enable) [
    # Only if NVIDIA GPU present
    cuda-tools
    nvidia-settings
  ] ++ lib.optionals (system == "x86_64-linux") [
    # Only on x86_64 systems
    steam
  ];
}

Modular Configurations

Split large templates into modules:

# home/modules/development/languages.nix
{ pkgs, ... }:

{
  home.packages = with pkgs; [
    nodejs_22
    python3
    rustc
    go
  ];
}

# Then import in template
imports = [
  ../modules/development/languages.nix
];

Contributing Templates

To contribute a new template:

  1. Create template following existing patterns
  2. Test thoroughly on multiple systems
  3. Document features and use cases
  4. Add to template list in this documentation
  5. Submit for review

Template naming convention: purpose.nix (e.g., scientist.nix, artist.nix)