This commit introduces two new custom script packages: tb-scripts for all systems and tb-dev-scripts for development machines. These packages provide a maintainable way to distribute utility scripts across the infrastructure with proper dependency management. Created pkgs/ directory with two script collections: 1. **tb-scripts** - General utilities available on all systems: - ,jq_reformat: Reformat JSON files in-place with atomic file operations - ,rename_lower: Convert filenames to lowercase with validation 2. **tb-dev-scripts** - Development-specific tools: - ,cmake_update_fetchcontent: Update CMake FetchContent dependencies All scripts have been significantly enhanced from their original versions: - Proper quoting to handle filenames with spaces - Secure temporary file creation using mktemp - Atomic file replacement to prevent data loss - Input validation and comprehensive error handling - Usage help with -h/--help flag - Extensive inline comments explaining each section - Cleanup traps on error - Complete rewrite in Python for consistency - Validates files exist before attempting rename - Checks if target lowercase filename already exists - Skips files already lowercase (no-op) - Descriptive error messages for each failure case - Usage documentation with examples - Proper exit codes - Interactive CMake FetchContent dependency updater - Recursively finds all CMakeLists.txt files via add_subdirectory() - Queries GitHub API for latest releases/tags - Compares semantic versions and commit hashes - Shows available updates in formatted table - Prompts for confirmation before applying updates - Atomic file updates with validation Scripts are packaged using writeShellApplication with proper dependency injection via runtimeInputs: - tb-scripts requires: jq, python3 - tb-dev-scripts requires: python3, git Dependencies are automatically available in PATH when scripts run, eliminating manual dependency checks. Created system module files to import the script packages: - system/default/scripts.nix: Adds tb-scripts to nixosModules.default - system/develop/scripts.nix: Adds tb-dev-scripts to nixosModules.develop Updated flake.nix to import these modules in the appropriate contexts. - Scripts have proper Nix-managed dependencies - No manual installation or PATH configuration needed - Easy to extend with additional scripts - Scripts are validated with shellcheck during build - Clear separation between all-systems and dev-only utilities - Comprehensive error handling and user documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
93 lines
2.1 KiB
Nix
93 lines
2.1 KiB
Nix
{
|
|
description = "Timo's Shared Nix Modules";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, ... }: {
|
|
# Set up formatter.
|
|
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
|
|
|
|
# Global all-hosts configuration
|
|
nixosModules.default = { ... }: {
|
|
imports = [
|
|
./system/default/editor.nix
|
|
./system/default/nix.nix
|
|
./system/default/packages.nix
|
|
./system/default/prompt.nix
|
|
./system/default/scripts.nix
|
|
./system/default/ssh-authorized-keys.nix
|
|
];
|
|
};
|
|
|
|
# Linux specific system configuration
|
|
nixosModules.linux = { ... }: {
|
|
imports = [
|
|
./system/linux/i18n.nix
|
|
./system/linux/openssh.nix
|
|
./system/linux/system.nix
|
|
./system/linux/user-tb.nix
|
|
];
|
|
};
|
|
|
|
# MacOS specific system configuration
|
|
nixosModules.macos = { ... }: {
|
|
imports = [
|
|
./system/macos/environment.nix
|
|
./system/macos/fonts.nix
|
|
./system/macos/hotkeys.nix
|
|
./system/macos/nix.nix
|
|
./system/macos/system.nix
|
|
./system/macos/yabai.nix
|
|
];
|
|
};
|
|
|
|
# Tools on all development machines
|
|
nixosModules.develop = { ... }: {
|
|
imports = [
|
|
./system/develop/packages.nix
|
|
./system/develop/scripts.nix
|
|
];
|
|
};
|
|
|
|
# Home Manager Modules
|
|
homeManagerModules.default = { ... }: {
|
|
imports = [
|
|
./home/default/bash.nix
|
|
./home/default/basic.nix
|
|
./home/default/direnv.nix
|
|
./home/default/git.nix
|
|
];
|
|
};
|
|
|
|
# Add private homelab and cloud host aliases
|
|
homeManagerModules.private = { ... }: {
|
|
imports = [
|
|
./home/private/ssh-hosts.nix
|
|
];
|
|
};
|
|
|
|
# MacOS specific home configuration
|
|
homeManagerModules.macos = { ... }: {
|
|
imports = [
|
|
./home/macos/home.nix
|
|
];
|
|
};
|
|
|
|
# Emacs Configuration
|
|
homeManagerModules.develop = { ... }: {
|
|
imports = [
|
|
./home/develop/emacs.nix
|
|
];
|
|
};
|
|
|
|
# Claude Code configuration
|
|
homeManagerModules.claude = { ... }: {
|
|
imports = [
|
|
./home/claude/config.nix
|
|
];
|
|
};
|
|
};
|
|
}
|