initial config
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
result
|
||||||
|
result-*
|
||||||
|
.direnv/
|
||||||
183
README.md
Normal file
183
README.md
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
# User Configuration Template
|
||||||
|
|
||||||
|
This directory contains templates for creating external user configuration modules that can be referenced from the main `nixos-systems/users.nix` file.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
External user modules allow users to maintain their personal configurations (dotfiles, packages, settings) in separate Git repositories and reference them from the main `nixos-systems` repository using `builtins.fetchGit`.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
user-dotfiles-repo/
|
||||||
|
├── home.nix # Required: Home-manager configuration
|
||||||
|
├── nixos.nix # Optional: System-level NixOS configuration
|
||||||
|
├── README.md # Documentation
|
||||||
|
└── dotfiles/ # Optional: Dotfiles to symlink
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### 1. Create Your User Configuration Repository
|
||||||
|
|
||||||
|
Copy the templates from this directory to your own Git repository:
|
||||||
|
- `home.nix` - Required for home-manager configuration
|
||||||
|
- `nixos.nix` - Optional for system-level configuration
|
||||||
|
|
||||||
|
### 2. Reference It in users.nix
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
ugaif.users = {
|
||||||
|
myusername = {
|
||||||
|
description = "My Name";
|
||||||
|
extraGroups = [ "wheel" "networkmanager" ];
|
||||||
|
shell = pkgs.zsh;
|
||||||
|
|
||||||
|
# Option 1: External module from Git
|
||||||
|
home = builtins.fetchGit {
|
||||||
|
url = "https://github.com/username/dotfiles";
|
||||||
|
rev = "abc123def456..."; # Full commit hash for reproducibility
|
||||||
|
ref = "main"; # Optional: branch/tag name
|
||||||
|
};
|
||||||
|
|
||||||
|
# Option 2: Local path for testing
|
||||||
|
# home = /path/to/local/dotfiles;
|
||||||
|
|
||||||
|
# Option 3: Inline configuration
|
||||||
|
# home = {
|
||||||
|
# home.packages = [ pkgs.vim ];
|
||||||
|
# programs.git.enable = true;
|
||||||
|
# };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Enable on Systems
|
||||||
|
|
||||||
|
Enable the user in `inventory.nix`:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
"my-system" = {
|
||||||
|
devices = {
|
||||||
|
"hostname" = {
|
||||||
|
extraUsers = [ "myusername" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## File Descriptions
|
||||||
|
|
||||||
|
### home.nix (Required)
|
||||||
|
|
||||||
|
This file contains your home-manager configuration. It must be a valid NixOS module that accepts `{ inputs, ... }` and returns a home-manager configuration.
|
||||||
|
|
||||||
|
**Must export:**
|
||||||
|
- Home-manager options (programs.*, home.packages, etc.)
|
||||||
|
|
||||||
|
**Receives:**
|
||||||
|
- `inputs` - Flake inputs (nixpkgs, home-manager, etc.)
|
||||||
|
- `config` - Home-manager config
|
||||||
|
- `pkgs` - Nixpkgs package set
|
||||||
|
- `osConfig` - Access to OS-level configuration
|
||||||
|
|
||||||
|
### nixos.nix (Optional)
|
||||||
|
|
||||||
|
This file contains system-level NixOS configuration. Only needed for:
|
||||||
|
- System services related to the user
|
||||||
|
- System packages requiring root
|
||||||
|
- Special permissions or system settings
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Minimal home.nix
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ inputs, ... }:
|
||||||
|
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
vim
|
||||||
|
git
|
||||||
|
htop
|
||||||
|
];
|
||||||
|
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
userName = "My Name";
|
||||||
|
userEmail = "me@example.com";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### With Dotfiles
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ inputs, ... }:
|
||||||
|
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
home.packages = with pkgs; [ ripgrep fd bat ];
|
||||||
|
|
||||||
|
# Symlink dotfiles
|
||||||
|
home.file.".bashrc".source = ./dotfiles/bashrc;
|
||||||
|
home.file.".vimrc".source = ./dotfiles/vimrc;
|
||||||
|
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
userName = "My Name";
|
||||||
|
userEmail = "me@example.com";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### With System Configuration (nixos.nix)
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ inputs, ... }:
|
||||||
|
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
# Add user to docker group
|
||||||
|
users.users.myusername.extraGroups = [ "docker" ];
|
||||||
|
|
||||||
|
# Install system package
|
||||||
|
environment.systemPackages = [ pkgs.docker ];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Integration Features
|
||||||
|
|
||||||
|
External user modules:
|
||||||
|
- Receive the same flake inputs as nixos-systems
|
||||||
|
- Can use all home-manager options
|
||||||
|
- Optionally provide system-level configuration (nixos.nix)
|
||||||
|
- System zsh theme applied if `useZshTheme = true` (default)
|
||||||
|
- System nvim config applied if `useNvimPlugins = true` (default)
|
||||||
|
- Merged with inventory.nix user settings (groups, shell, etc.)
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
|
||||||
|
1. Create your user config repository with `home.nix`
|
||||||
|
2. Test locally: `home = /path/to/local/repo;`
|
||||||
|
3. Build: `nix build .#nixosConfigurations.hostname.config.system.build.toplevel`
|
||||||
|
4. Commit and push changes
|
||||||
|
5. Update users.nix with commit hash
|
||||||
|
6. Deploy to systems
|
||||||
|
|
||||||
|
## Benefits
|
||||||
|
|
||||||
|
- **Personal Ownership**: Users maintain their own configs
|
||||||
|
- **Version Control**: Track dotfile changes over time
|
||||||
|
- **Portability**: Use same config across multiple machines
|
||||||
|
- **Reproducibility**: Pin to specific commits
|
||||||
|
- **Privacy**: Use private repositories for personal settings
|
||||||
|
- **Separation**: Keep personal configs separate from system configs
|
||||||
108
home.nix
Normal file
108
home.nix
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
{ inputs, ... }:
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# User Home Manager Configuration Template
|
||||||
|
# ============================================================================
|
||||||
|
# This file provides home-manager configuration for a user.
|
||||||
|
# It will be imported into the NixOS system's home-manager configuration.
|
||||||
|
#
|
||||||
|
# Usage in users.nix:
|
||||||
|
# myusername = {
|
||||||
|
# description = "My Name";
|
||||||
|
# home = builtins.fetchGit {
|
||||||
|
# url = "https://github.com/username/dotfiles";
|
||||||
|
# rev = "commit-hash";
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
#
|
||||||
|
# This module receives the same `inputs` flake inputs as the main
|
||||||
|
# nixos-systems configuration (nixpkgs, home-manager, etc.).
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
osConfig, # Access to the OS-level config
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
# ========== Home Manager Configuration ==========
|
||||||
|
|
||||||
|
# User identity (required)
|
||||||
|
home.username = lib.mkDefault config.home.username; # Set by system
|
||||||
|
home.homeDirectory = lib.mkDefault config.home.homeDirectory; # Set by system
|
||||||
|
home.stateVersion = lib.mkDefault "25.11";
|
||||||
|
|
||||||
|
# ========== Packages ==========
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
htop
|
||||||
|
ripgrep
|
||||||
|
ghostty
|
||||||
|
fd
|
||||||
|
bat
|
||||||
|
];
|
||||||
|
|
||||||
|
# ========== Programs ==========
|
||||||
|
|
||||||
|
# Git configuration
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
init.defaultBranch = "main";
|
||||||
|
user = {
|
||||||
|
name = "Hunter Halloran";
|
||||||
|
email = "hdh20267@uga.edu";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Zsh configuration
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
# System theme is applied automatically if useZshTheme = true in users.nix
|
||||||
|
# Add your custom zsh config here
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.vscode = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.vscode.fhs;
|
||||||
|
profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||||
|
vscodevim.vim
|
||||||
|
jnoortheen.nix-ide
|
||||||
|
ms-vscode-remote.vscode-remote-extensionpack
|
||||||
|
ms-vscode-remote.remote-ssh
|
||||||
|
ms-python.python
|
||||||
|
ms-python.vscode-pylance
|
||||||
|
ms-python.debugpy
|
||||||
|
github.copilot
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Neovim configuration
|
||||||
|
# programs.neovim = {
|
||||||
|
# enable = true;
|
||||||
|
# # System nvim config is applied automatically if useNvimPlugins = true
|
||||||
|
# # Add your custom neovim config here
|
||||||
|
# };
|
||||||
|
|
||||||
|
# ========== Shell Environment ==========
|
||||||
|
|
||||||
|
home.sessionVariables = {
|
||||||
|
EDITOR = "nvim";
|
||||||
|
# Add your custom environment variables
|
||||||
|
};
|
||||||
|
|
||||||
|
# ========== Dotfiles ==========
|
||||||
|
|
||||||
|
# You can manage dotfiles with home.file
|
||||||
|
# home.file.".bashrc".source = ./dotfiles/bashrc;
|
||||||
|
# home.file.".vimrc".source = ./dotfiles/vimrc;
|
||||||
|
|
||||||
|
# Or use programs.* options for better integration
|
||||||
|
|
||||||
|
# ========== XDG Configuration ==========
|
||||||
|
|
||||||
|
xdg.enable = true;
|
||||||
|
# xdg.configFile."app/config.conf".source = ./config/app.conf;
|
||||||
|
}
|
||||||
49
nixos.nix
Normal file
49
nixos.nix
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{ inputs, ... }:
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# User NixOS System Configuration (Optional)
|
||||||
|
# ============================================================================
|
||||||
|
# This file provides system-level NixOS configuration for a user.
|
||||||
|
# It's optional - most user configuration should go in home.nix.
|
||||||
|
#
|
||||||
|
# Use this for:
|
||||||
|
# - System-level services that depend on the user (e.g., user systemd services)
|
||||||
|
# - Special system permissions or configurations
|
||||||
|
# - Installing system packages that require root
|
||||||
|
#
|
||||||
|
# This module receives the same `inputs` flake inputs as the main
|
||||||
|
# nixos-systems configuration.
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
# ========== System Configuration ==========
|
||||||
|
|
||||||
|
# Example: Enable a system service for this user
|
||||||
|
# systemd.services.my-user-service = {
|
||||||
|
# description = "My User Service";
|
||||||
|
# wantedBy = [ "multi-user.target" ];
|
||||||
|
# serviceConfig = {
|
||||||
|
# Type = "oneshot";
|
||||||
|
# User = "myusername";
|
||||||
|
# ExecStart = "${pkgs.bash}/bin/bash -c 'echo Hello'";
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
|
||||||
|
# Example: Install system-wide packages needed by this user
|
||||||
|
# environment.systemPackages = with pkgs; [
|
||||||
|
# docker
|
||||||
|
# ];
|
||||||
|
|
||||||
|
# Example: Add user to additional groups
|
||||||
|
# users.users.myusername.extraGroups = [ "docker" ];
|
||||||
|
|
||||||
|
# Most configuration should be in home.nix instead of here
|
||||||
|
|
||||||
|
services.tailscale.enable = true;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user