1
Fork 0
mirror of https://github.com/thegeneralist01/config.git synced 2026-05-30 08:37:01 +02:00

Compare commits

..

No commits in common. "802a38f61b86abffe08b6dc38d323a9a9c925db4" and "6014ad7d7a7167333cb0249c1dffd9edbf0bddc1" have entirely different histories.

18 changed files with 310 additions and 725 deletions

194
AGENTS.md
View file

@ -1,194 +0,0 @@
# AGENTS.md - AI Assistant Context
This file provides context for AI assistants working with thegeneralist's Nix configuration.
## Quick Commands
### Build & Deploy Commands
```bash
# Build specific host
nixos-rebuild switch --flake .#<hostname> # Linux
darwin-rebuild switch --flake .#<hostname> # macOS
# Update flake dependencies
nix flake update
# Check configuration validity
nix flake check
# Format Nix files
nixpkgs-fmt **/*.nix
# Clean up old generations
nh clean all --keep 3 --keep-since 4d
```
### Development Commands
```bash
# Enter dev shell with tools
nix develop
# Edit secrets
agenix -e <secret-name>.age
# Re-encrypt all secrets
agenix -r
```
## Architecture Overview
### File Structure Conventions
- **`flake.nix`** - Main entry point, defines inputs/outputs
- **`hosts/`** - Host-specific configurations
- Each host has `default.nix` that calls `lib.mkSystem`
- `configuration.nix` contains host-specific settings
- **`modules/`** - Reusable system modules
- `common/` - Cross-platform modules (always loaded)
- `darwin/` - macOS-specific modules
- `linux/` - Linux-specific modules
- **`lib/`** - Custom library functions
- `mkSystem` - Main system builder function
### Host Naming & Categorization
- Hosts ending in `mbp` or containing `central-mbp` → Darwin
- All others → NixOS
- Current hosts:
- `thegeneralist` (NixOS)
- `thegeneralist-central` (NixOS)
- `thegeneralist-mbp` (Darwin)
- `thegeneralist-central-mbp` (Darwin)
## Code Conventions
### Nix Style Guidelines
- Use `nixpkgs-fmt` for formatting
- Prefer explicit attribute sets over `with` statements
- Use meaningful variable names
- Add comments for complex logic
### Module Organization
```nix
# Standard module structure
{ config, lib, pkgs, ... }:
{
# Module configuration here
}
```
### Host Configuration Pattern
```nix
# hosts/<hostname>/default.nix
lib: inputs: self: lib.mkSystem "<os>" ./configuration.nix
# hosts/<hostname>/configuration.nix
{ config, pkgs, ... }: {
# Host-specific settings
}
```
## Common Modification Patterns
### Adding a New Package
1. **System-wide**: Add to appropriate `modules/*/packages.nix`
2. **User-specific**: Add to home-manager config in host's `configuration.nix`
### Adding a New Module
1. Create `.nix` file in appropriate `modules/` subdirectory
2. Module is auto-discovered and loaded
### Adding a New Host
1. Create `hosts/<hostname>/` directory
2. Add `default.nix` with system type
3. Add `configuration.nix` with host settings
4. Optionally add `hardware-configuration.nix`
### Managing Secrets
1. Define in `secrets.nix` with proper recipients
2. Reference as `config.age.secrets.<name>.path`
3. Edit with `agenix -e <secret>.age`
## Key Features to Remember
### Distributed Builds
- `thegeneralist-central` is the main build machine
- Other hosts offload builds via SSH
- SSH keys and build users configured automatically
### Binary Caches
- Personal: `cache.thegeneralist01.com`
- Community: `cache.garnix.io`
- Official: `cache.nixos.org`
### Home Manager Integration
- Configured via `modules/common/home-manager.nix`
- Per-host customization in host's `configuration.nix`
- Includes `nh` tool for optimized rebuilds
### Development Tools
- Development shell includes: `nil`, `nixpkgs-fmt`, `agenix`
- Custom options available via `lib.mkOption`
- Flake inputs follow nixpkgs for consistency
## Debugging Tips
### Build Issues
1. Check syntax: `nix flake check`
2. Update dependencies: `nix flake update`
3. Clear cache: `nix-collect-garbage -d`
4. Verify module imports and paths
### Secret Issues
1. Check `keys.nix` has correct public keys
2. Verify secret recipient list in `secrets.nix`
3. Re-encrypt if needed: `agenix -r`
### Module Not Loading
1. Verify file is in correct `modules/` subdirectory
2. Check file extension is `.nix`
3. Ensure valid Nix syntax
## Performance Optimizations
### Recommended Practices
- Use distributed builds when available
- Leverage binary caches
- Regular garbage collection via `nh clean`
- Keep flake inputs updated but stable
### Avoiding Rebuilds
- Prefer adding packages to existing modules over creating new ones
- Use overlays for package modifications
- Consider impact on all hosts when modifying common modules
## Testing Strategy
### Before Major Changes
1. Test on single host first
2. Verify flake builds: `nix flake check`
3. Check that all hosts can still build
4. Consider impact on secrets/distributed builds
### Rollback Strategy
```bash
# System level rollback
nixos-rebuild switch --rollback
darwin-rebuild switch --rollback
# Or boot into previous generation from bootloader
```
## User Preferences
### Code Style
- Clean, readable Nix code
- Proper indentation and formatting
- Meaningful comments for complex logic
- Consistent naming conventions
### Organization Preferences
- Modular approach over monolithic configs
- Platform-specific separation (darwin/linux/common)
- Host-specific customization in host directories
- Secrets properly encrypted and organized
This configuration emphasizes maintainability, security, and cross-platform consistency.

View file

@ -1,246 +1,2 @@
# thegeneralist's Nix Configuration # config
My Nix flake and dotfiles
A comprehensive Nix flake configuration supporting both NixOS (Linux) and nix-darwin (macOS) systems with home-manager integration.
## Overview
This configuration provides a unified way to manage multiple machines across different platforms:
- **NixOS hosts**: `thegeneralist`, `thegeneralist-central`
- **Darwin hosts**: `thegeneralist-mbp`, `thegeneralist-central-mbp`
## Quick Start
### Prerequisites
- Nix package manager with flakes enabled
- Git for cloning the repository
### Installation
1. Clone the repository:
```bash
git clone https://github.com/thegeneralist01/config.git ~/config
cd ~/config
```
2. For NixOS systems:
```bash
sudo nixos-rebuild switch --flake .#<hostname>
```
3. For Darwin systems:
```bash
darwin-rebuild switch --flake .#<hostname>
```
### Development Environment
Enter the development shell for configuration management:
```bash
nix develop
```
This provides:
- `nil` - Nix language server
- `nixpkgs-fmt` - Nix formatter
- `agenix` - Secret management
## Architecture
### Directory Structure
```
├── docs/ # Documentation
├── flake.nix # Main flake configuration
├── flake.lock # Locked dependency versions
├── hosts/ # Host-specific configurations
│ ├── default.nix # Host discovery and categorization
│ └── <hostname>/ # Individual host configurations
├── lib/ # Custom library functions
│ ├── default.nix # Library entry point
│ ├── option.nix # Option utilities
│ └── system.nix # System building functions
├── modules/ # Reusable system modules
│ ├── common/ # Cross-platform modules
│ ├── darwin/ # macOS-specific modules
│ └── linux/ # Linux-specific modules
├── keys.nix # Age public keys for secrets
└── secrets.nix # Encrypted secrets
```
### Key Components
#### Flake Inputs
- **nixpkgs**: Main package repository (nixos-unstable)
- **home-manager**: Dotfiles and user environment management
- **nix-darwin**: macOS system configuration
- **agenix**: Age-based secret management
- **ghostty**: Modern terminal emulator
- **fenix**: Rust toolchain provider
#### Library Functions
- `mkSystem`: Core system builder for both Linux and Darwin
- `mkOption`: Custom option utilities
- Host auto-discovery and categorization
## Host Configuration
### Adding a New Host
1. Create a new directory under `hosts/`:
```bash
mkdir hosts/new-hostname
```
2. Create the host's `default.nix`:
```nix
lib: inputs: self: lib.mkSystem "linux" ./configuration.nix
# or for macOS:
lib: inputs: self: lib.mkSystem "darwin" ./configuration.nix
```
3. Create `configuration.nix` with your host-specific settings:
```nix
{ config, pkgs, ... }: {
# Host-specific configuration here
}
```
4. Rebuild your flake:
```bash
nix flake lock # Update lock file if needed
nixos-rebuild switch --flake .#new-hostname
```
### Host Categorization
Hosts are automatically categorized based on naming conventions:
- Names ending with `mbp` or containing `central-mbp` → Darwin
- All others → NixOS
## Module System
### Common Modules
Located in `modules/common/`, these are loaded on all systems:
- `nix.nix` - Nix configuration, caches, and distributed builds
- `home-manager.nix` - User environment management
- `packages.nix` - Common packages
- `git.nix`, `neovim.nix`, `zsh.nix` - Development tools
- `agenix.nix` - Secret management
### Platform-Specific Modules
- `modules/darwin/` - macOS-specific (SSH, Karabiner, packages)
- `modules/linux/` - Linux-specific (boot, networking, X11, NVIDIA)
### Creating Custom Modules
1. Add your module to the appropriate directory:
```nix
# modules/common/mymodule.nix
{ config, pkgs, ... }: {
# Module configuration
}
```
2. The module is automatically discovered and loaded
## Secret Management
Uses `agenix` for encrypted secrets management:
1. Add recipient public keys to [`keys.nix`](file:///Users/thegeneralist/misc/config-copy/keys.nix)
2. Define secrets in [`secrets.nix`](file:///Users/thegeneralist/misc/config-copy/secrets.nix)
3. Edit secrets: `agenix -e secret-name.age`
4. Reference in configuration: `config.age.secrets.secret-name.path`
## Distributed Builds
The configuration includes distributed build support:
- `thegeneralist-central` serves as the build machine
- Other hosts can offload builds via SSH
- Shared binary caches for faster builds
## Binary Caches
Configured caches for improved build performance:
- `cache.thegeneralist01.com` - Personal cache
- `cache.garnix.io` - Community cache
- `cache.nixos.org` - Official cache
## Development Workflow
### Updating Dependencies
```bash
nix flake update
```
### Formatting Code
```bash
nixpkgs-fmt **/*.nix
```
### Checking Configuration
```bash
nix flake check
```
### Cleaning Up
```bash
# Via nh (configured in home-manager)
nh clean all --keep 3 --keep-since 4d
# Manual cleanup
nix-collect-garbage -d
```
## Common Tasks
### Installing Packages System-wide
Add to the appropriate `modules/*/packages.nix` file.
### Installing User Packages
Modify the home-manager configuration in your host's `configuration.nix`.
### Updating a Single Host
```bash
nixos-rebuild switch --flake .#hostname
# or
darwin-rebuild switch --flake .#hostname
```
### Rolling Back Changes
```bash
nixos-rebuild switch --rollback
# or
darwin-rebuild switch --rollback
```
## Troubleshooting
### Build Failures
1. Check flake lock compatibility: `nix flake update`
2. Clear build cache: `nix-collect-garbage -d`
3. Verify module syntax: `nix flake check`
### Secret Access Issues
1. Verify keys are properly configured in `keys.nix`
2. Re-encrypt secrets: `agenix -r`
3. Check file permissions on age keys
### Performance Issues
1. Enable distributed builds to `thegeneralist-central`
2. Verify binary cache access
3. Use `nh` for optimized rebuilds
## Contributing
1. Follow existing code style and organization
2. Test changes on a single host before applying broadly
3. Update documentation for significant changes
4. Use meaningful commit messages
## References
- [NixOS Manual](https://nixos.org/manual/nixos/stable/)
- [Nix-Darwin](https://github.com/nix-darwin/nix-darwin)
- [Home Manager](https://nix-community.github.io/home-manager/)
- [Agenix](https://github.com/ryantm/agenix)

147
flake.lock generated
View file

@ -64,6 +64,43 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1733312601,
"narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems_2" "systems": "systems_2"
@ -105,6 +142,37 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks-nix": {
"inputs": {
"flake-compat": [
"nix"
],
"gitignore": [
"nix"
],
"nixpkgs": [
"nix",
"nixpkgs"
],
"nixpkgs-stable": [
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1734279981,
"narHash": "sha256-NdaCraHPp8iYMWzdXAt5Nv6sA3MUzlCiGiR586TCwo0=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "aa9f40c906904ebd83da78e7f328cd8aeaeae785",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -125,6 +193,28 @@
"type": "github" "type": "github"
} }
}, },
"nix": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-parts": "flake-parts",
"git-hooks-nix": "git-hooks-nix",
"nixpkgs": "nixpkgs",
"nixpkgs-23-11": "nixpkgs-23-11",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1748188105,
"narHash": "sha256-skPu7lTZrTr6gShsN47IGPUX4+Y0CbI2gl8tG3Dh7hM=",
"owner": "NixOS",
"repo": "nix",
"rev": "543cee1c9272238f9402e5643402b99f952415c3",
"type": "github"
},
"original": {
"id": "nix",
"type": "indirect"
}
},
"nix-darwin": { "nix-darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -148,11 +238,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1755186698, "lastModified": 1747179050,
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=", "narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c", "rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -162,6 +252,38 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-23-11": {
"locked": {
"lastModified": 1717159533,
"narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
}
},
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1741992157, "lastModified": 1741992157,
@ -194,14 +316,31 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1755186698,
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"fenix": "fenix", "fenix": "fenix",
"ghostty": "ghostty", "ghostty": "ghostty",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix": "nix",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs_2"
} }
}, },
"rust-analyzer-src": { "rust-analyzer-src": {

View file

@ -1,65 +1,48 @@
{ {
description = "thegeneralist's config flake"; description = "thegeneralist's config flake";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nix-darwin = { nix-darwin = {
url = "github:nix-darwin/nix-darwin/master"; url = "github:nix-darwin/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
agenix = { agenix = {
url = "github:ryantm/agenix"; url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager"; inputs.home-manager.follows = "home-manager";
inputs.darwin.follows = "nix-darwin"; inputs.darwin.follows = "nix-darwin";
}; };
ghostty = { ghostty = {
url = "github:ghostty-org/ghostty"; url = "github:ghostty-org/ghostty";
}; };
fenix = { fenix = {
url = "github:nix-community/fenix"; url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
#nix.url = "github:DeterminateSystems/nix-src";
}; };
outputs = inputs@{ self, nixpkgs, nix-darwin, ... }: outputs = inputs@{ self, nixpkgs, nix-darwin, nix, ... }: let
let inherit (builtins) readDir;
# Extend nixpkgs lib with darwin and custom functions inherit (nixpkgs.lib) attrsToList const groupBy listToAttrs mapAttrs;
lib = nixpkgs.lib.extend ( #nix.enable = false;
_: _: nix-darwin.lib // (import ./lib inputs)
);
# Import host configurations lib' = nixpkgs.lib.extend (_: _: nix-darwin.lib);
hostConfigs = import ./hosts { inherit lib inputs self; }; lib = lib'.extend <| import ./lib inputs;
in
{
# NixOS configurations for Linux hosts
nixosConfigurations = hostConfigs.nixos or {};
# Darwin configurations for macOS hosts targetHost = readDir ./hosts
darwinConfigurations = hostConfigs.darwin or {}; |> mapAttrs (name: const <| import ./hosts/${name} lib inputs self)
|> attrsToList
# Development shells |> groupBy (host:
devShells = lib.genAttrs [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ] (system: if host.name == "thegeneralist" || host.name == "thegeneralist-central" then
let pkgs = nixpkgs.legacyPackages.${system}; "nixosConfigurations"
in { else
default = pkgs.mkShell { "darwinConfigurations")
buildInputs = with pkgs; [ |> mapAttrs (const listToAttrs);
nil in targetHost;
nixpkgs-fmt
inputs.agenix.packages.${system}.default
];
};
}
);
};
} }

View file

@ -1,33 +0,0 @@
{ lib, inputs, self }:
let
inherit (lib)
mapAttrs filterAttrs hasPrefix hasSuffix;
# Read host directories
hostDirs = builtins.readDir ./.;
# Build a single host configuration
mkHostConfig = name: _type:
let
hostPath = ./${name};
hostModule = import hostPath;
in
hostModule lib inputs self;
# Determine if host is Darwin or NixOS based on naming
isDarwin = name:
hasPrefix "thegeneralist" name &&
(hasSuffix "mbp" name || hasSuffix "central-mbp" name);
# Build all host configurations
allHosts = mapAttrs mkHostConfig
(filterAttrs (_: type: type == "directory") hostDirs);
# Separate Darwin and NixOS configurations
darwinHosts = filterAttrs (name: _: isDarwin name) allHosts;
nixosHosts = filterAttrs (name: _: !isDarwin name) allHosts;
in
{
darwin = darwinHosts;
nixos = nixosHosts;
}

View file

@ -1 +1 @@
lib: inputs: self: lib.mkSystem "darwin" ./configuration.nix lib: inputs: self: lib.system "darwin" ./configuration.nix

View file

@ -1 +1 @@
lib: inputs: self: lib.mkSystem "linux" ./configuration.nix lib: inputs: self: lib.system "linux" ./configuration.nix

View file

@ -1 +1 @@
lib: inputs: self: lib.mkSystem "darwin" ./configuration.nix lib: inputs: self: lib.system "darwin" ./configuration.nix

View file

@ -1 +1 @@
lib: inputs: self: lib.mkSystem "linux" ./configuration.nix lib: inputs: self: lib.system "linux" ./configuration.nix

View file

@ -1,21 +1,6 @@
inputs: inputs: self: super:
let let
inherit (inputs.nixpkgs.lib) makeExtensible; system = import ./system.nix inputs self super;
option = import ./option.nix inputs self super;
in in
makeExtensible (self: system // option
let
callLib = file: import file inputs self;
optionUtils = callLib ./option.nix;
in
{
# Core system building functions
mkSystem = (callLib ./system.nix).mkSystem;
# Custom option utilities
mkConst = optionUtils.mkConst;
mkValue = optionUtils.mkValue;
# Host detection and configuration
mkHosts = callLib ./hosts.nix;
}
)

View file

@ -1,64 +1,66 @@
inputs: self: inputs: self: super:
let let
inherit (inputs.nixpkgs.lib) inherit (self)
hasSuffix filesystem attrValues filter getAttrFromPath hasSuffix
hasAttrByPath mapAttrsToList concatMap; filesystem
attrValues
filter
getAttrFromPath
hasAttrByPath
;
# Helper to collect all .nix files recursively in a directory collectModules = path: filesystem.listFilesRecursive path |> filter (hasSuffix ".nix");
collectModules = path:
if builtins.pathExists path
then filter (hasSuffix ".nix") (filesystem.listFilesRecursive path)
else [];
# Collect modules from flake inputs with fallback handling collectInputModules =
collectInputModules = packagePath: packagePath:
let (attrValues inputs) |> filter (hasAttrByPath packagePath) |> map (getAttrFromPath packagePath);
getModule = input:
if hasAttrByPath packagePath input
then [ (getAttrFromPath packagePath input) ]
else [];
in
concatMap getModule (attrValues inputs);
# Shared arguments for all configurations
specialArgs = inputs // { specialArgs = inputs // {
inherit inputs self; inherit inputs;
inherit self;
}; };
# Collect platform-specific modules # All modules
modulesCommon = collectModules ../modules/common; modulesCommon = collectModules ../modules/common;
modulesLinux = collectModules ../modules/linux; modulesLinux = collectModules ../modules/linux;
modulesDarwin = collectModules ../modules/darwin; modulesDarwin = collectModules ../modules/darwin;
# Collect input modules by platform inputModulesNixos = collectInputModules [
inputModulesNixos = collectInputModules [ "nixosModules" "default" ]; "nixosModules"
inputModulesDarwin = collectInputModules [ "darwinModules" "default" ]; "default"
];
inputModulesDarwin = collectInputModules [
"darwinModules"
"default"
];
# Collect overlays from inputs # Overlays
overlays = collectInputModules [ "overlays" "default" ]; overlays = collectInputModules [
"overlays"
"default"
];
overlayModule = { overlayModules = {
nixpkgs.overlays = overlays; nixpkgs.overlays = overlays;
}; };
in in
{ {
# Main system builder function system =
mkSystem = os: configFile: os: configFile:
let (if os == "darwin" then
systemBuilder = if os == "darwin" super.darwinSystem
then inputs.nix-darwin.lib.darwinSystem else
else inputs.nixpkgs.lib.nixosSystem; super.nixosSystem) {
inherit specialArgs;
platformModules = if os == "darwin" modules =
then modulesDarwin ++ inputModulesDarwin [
else modulesLinux ++ inputModulesNixos; overlayModules
in configFile
systemBuilder { ]
inherit specialArgs; ++ modulesCommon
++ (
modules = [ if os == "darwin" then modulesDarwin ++ inputModulesDarwin else modulesLinux ++ inputModulesNixos
overlayModule );
configFile };
] ++ modulesCommon ++ platformModules;
};
} }

View file

@ -1,26 +0,0 @@
{ config, lib, pkgs, ... }:
let
enableAmp = (!config.onLinux) || (!config.isServer);
ampHomeModule = { lib, pkgs, ... }: {
home.sessionPath = [ "$HOME/.amp/bin" ];
home.activation.ampInstall = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
amp_bin="$HOME/.amp/bin/amp"
if [ -x "$amp_bin" ]; then
exit 0
fi
export PATH="${lib.makeBinPath [
pkgs.coreutils
pkgs.gnugrep
pkgs.curl
pkgs.bash
]}:$PATH"
# Prevent installer from trying to mutate shell rc files (Home Manager manages those).
SHELL="amp-installer" ${pkgs.curl}/bin/curl -fsSL https://ampcode.com/install.sh | ${pkgs.bash}/bin/bash
'';
};
in
lib.mkIf enableAmp {
home-manager.sharedModules = [ ampHomeModule ];
}

View file

@ -4,7 +4,6 @@ in {
options.dnsServers = mkOption { options.dnsServers = mkOption {
default = [ default = [
"100.100.100.100#shorthair-wall.ts.net" "100.100.100.100#shorthair-wall.ts.net"
"1.1.1.1#"
]; ];
}; };
} }

View file

@ -30,8 +30,6 @@ in {
builders-use-substitutes = true; builders-use-substitutes = true;
}; };
nix.package = pkgs.nixVersions.nix_2_30;
nix.distributedBuilds = true; nix.distributedBuilds = true;
nix.buildMachines = if (config.networking.hostName != "thegeneralist-central") then [{ nix.buildMachines = if (config.networking.hostName != "thegeneralist-central") then [{
hostName = "thegeneralist-central"; hostName = "thegeneralist-central";

View file

@ -46,26 +46,31 @@ alias g = glimpse --interactive -o both -f llm.md
def gg [] { def gg [] {
open llm.md | save -r /dev/stdout | ^xclip -sel c open llm.md | save -r /dev/stdout | ^xclip -sel c
} }
alias rn = yazi
# Zoxide init
#^zoxide init nushell | save --force ~/.config/nushell/zoxide.nu
#source ~/.config/nushell/zoxide.nu
alias c = clear alias c = clear
alias e = exa alias e = exa
alias ea = exa -a alias el = exa -la
alias ela = exa -la alias l = ls -a
alias l = ls alias ll = ls -la
alias la = ls -a alias cl = c; l
alias lal = ls -la
alias ap = cd ~/personal
alias ad = cd ~/Downloads
alias ab = cd ~/books
alias a = cd ~
alias ah = cd ~/dotfiles/hosts/thegeneralist
alias ai3 = nvim /home/thegeneralist/dotfiles/hosts/thegeneralist/dotfiles/i3/config
# alias rb = sudo nixos-rebuild switch --flake ~/dotfiles#thegeneralist
alias rb = nh os switch . -v -- --show-trace --verbose
def greeting [] { def greeting [] {
let quotes = [ let quotes = [
"What is impossible for you is not impossible for me." "What is impossible for you is not impossible for me."
"Why do we fall, Master Wayne? So that we can learn to pick ourselves up. - Alfred Pennyworth"
"Endure, Master Wayne. Take it. Theyll hate you for it, but thats the point of Batman. He can be the outcast. He can make the choice… that no one else can make. The right choice. - Alfred Pennyworth"
"— I never said thank you.\n— And you will never have to."
"A hero can be anyone, even a man doing something as simple and reassuring as putting a coat on a young boy's shoulders to let him know that the world hadn't ended. - Batman"
"— Come with me. Save yourself. You don't owe these ppl anymore, you've given them everything.\n— Not everything. Not yet."
"The night is always darkest before the dawn, but I promise you, the dawn is coming. - Harvey Dent"
"It's not who you are underneath, but what you do that defines you. - Batman"
"The idea was to be a symbol. Batman... could be anybody. That was the point. - Bruce Wayne"
] ]
echo ($quotes | get (random int 0..(($quotes | length) - 1))) echo ($quotes | get (random int 0..(($quotes | length) - 1)))
} }

View file

@ -1,105 +1,71 @@
{ { config, pkgs, lib, ... }: let
config, inherit (lib) readFile getExe mkIf optionalAttrs;
pkgs, in {
lib,
...
}:
let
inherit (lib)
readFile
getExe
mkIf
optionalAttrs
;
in
{
# TODO: starship + change the zoxide src # TODO: starship + change the zoxide src
# TODO: Rust tooling # TODO: Rust tooling
environment = environment = optionalAttrs config.onLinux {
optionalAttrs config.onLinux { sessionVariables.SHELLS = [ (getExe pkgs.nushell) (getExe pkgs.zsh) ];
sessionVariables.SHELLS = [ } // {
(getExe pkgs.nushell) shells = mkIf (!config.onLinux) [ pkgs.nushell pkgs.zsh ];
(getExe pkgs.zsh)
];
}
// {
shells = mkIf (!config.onLinux) [
pkgs.nushell
pkgs.zsh
];
systemPackages = with pkgs; [ systemPackages = with pkgs; [
nushell nushell
fish fish
zoxide zoxide
vivid vivid
ripgrep ripgrep
yazi yazi
jq jq
yq-go yq-go
eza eza
fzf fzf
gh gh
fastfetch fastfetch
carapace carapace
bat ];
bat-extras.core
];
shellAliases = { shellAliases = {
v = "nvim ."; v = "nvim .";
vi = "vim"; ff = "fastfetch --load-config examples/10.jsonc";
vim = "nvim"; g = "glimpse --interactive -o both -f llm.md";
gg = "open llm.md | save -r /dev/stdout | ^xclip -sel c";
ff = "fastfetch --load-config examples/10.jsonc"; rn = "yazi";
c = "clear";
g = "glimpse --interactive -o both -f llm.md"; e = "exa";
gg = "open llm.md | save -r /dev/stdout | ^xclip -sel c"; el = "exa -la";
rn = "yazi"; l = "ls -a";
cat = "bat"; ll = "ls -la";
c = "clear"; cl = "c; l";
e = "exa"; ap = "cd ~/personal";
ea = "exa -a"; ad = "cd ~/Downloads";
el = "exa -la"; ab = "cd ~/books";
l = "ls -a"; a = "cd ~";
la = "ls -a"; ah = "cd ~/dotfiles/hosts/thegeneralist";
ll = "ls -la"; ai3 = "nvim /home/thegeneralist/dotfiles/hosts/thegeneralist/dotfiles/i3/config";
cl = "c; l"; rb = "nh os switch . -v -- --show-trace --verbose";
ap = "cd ~/personal";
ad = "cd ~/Downloads";
ab = "cd ~/books";
a = "cd ~";
ah = "cd ~/dotfiles/hosts/thegeneralist";
ai3 = "nvim /home/thegeneralist/dotfiles/hosts/thegeneralist/dotfiles/i3/config";
rb = "nh os switch . -v -- --show-trace --verbose";
};
}; };
};
home-manager.sharedModules = [ home-manager.sharedModules = [
{ ({
home = { home.file = {
sessionPath = [ "$HOME/.amp/bin" "$HOME/.npm-packages/bin" "/opt/homebrew/bin" ]; ".zshrc" = let
file = { configFile = ./config.nu;
".zshrc" = envFile = ./env.nu;
let in {
configFile = ./config.nu; text = "exec nu --env-config ${envFile} --config ${configFile}";
envFile = ./env.nu; force = true;
in
{
text = "exec nu --env-config ${envFile} --config ${configFile}";
force = true;
};
".config/nushell/zoxide.nu".source = pkgs.runCommand "zoxide.nu" { } ''
${getExe pkgs.zoxide} init nushell --cmd cd > $out
'';
".config/nushell/ls_colors.txt".source = pkgs.runCommand "ls_colors.txt" { } ''
${getExe pkgs.vivid} generate gruvbox-dark-hard > $out
'';
}; };
".config/nushell/zoxide.nu".source = pkgs.runCommand "zoxide.nu" {} ''
${getExe pkgs.zoxide} init nushell --cmd cd > $out
'';
".config/nushell/ls_colors.txt".source = pkgs.runCommand "ls_colors.txt" {} ''
${getExe pkgs.vivid} generate gruvbox-dark-hard > $out
'';
}; };
} })
(homeArgs: { (homeArgs: {
programs.nushell = { programs.nushell = {
enable = true; enable = true;

View file

@ -10,10 +10,14 @@ $env.ENV_CONVERSIONS.PATH = {
$env.LS_COLORS = (open ~/.config/nushell/ls_colors.txt) $env.LS_COLORS = (open ~/.config/nushell/ls_colors.txt)
source ~/.config/nushell/zoxide.nu source ~/.config/nushell/zoxide.nu
# NVM
# source ("/Users/thegeneralist/.nvm/" | path join "nvm.sh")
# GPG TTY
# $env.GPG_TTY = (tty)
# Extra PATHs # Extra PATHs
# $env.PATH = [ # $env.PATH = [
# # ($env.HOME | path join ".amp/bin")
# # "/home/thegeneralist/AppImages" # # "/home/thegeneralist/AppImages"
# # ($env.HOME | path join "personal/zen") # # ($env.HOME | path join "personal/zen")
# # ($env.HOME | path join ".local/scripts") # # ($env.HOME | path join ".local/scripts")
@ -32,4 +36,6 @@ source ~/.config/nushell/zoxide.nu
# # "/usr/local/go/bin" # # "/usr/local/go/bin"
# # ($env.HOME | path join "go/bin") # # ($env.HOME | path join "go/bin")
# # ($env.HOME | path join ".npm-packages/bin") # # ($env.HOME | path join ".npm-packages/bin")
# # ($env.HOME | path join ".Android/Sdk/platform-tools")
# # ($env.HOME | path join ".Android/Sdk/emulator")
# ] ++ $env.PATH # ] ++ $env.PATH

View file

@ -1,14 +1,12 @@
# stolen from https://github.com/RGBCube/ncc/blob/94c349aa767f04f40ff4165c70c15ed3c3996f82/modules/postgresql.nix # stolen from https://github.com/RGBCube/ncc/blob/94c349aa767f04f40ff4165c70c15ed3c3996f82/modules/postgresql.nix
{ config, lib, pkgs, ... }: let { config, lib, pkgs, ... }: let
inherit (lib) flip mkForce mkOverride mkOption; inherit (lib) flip mkForce mkOverride mkValue;
in { in {
config.environment.systemPackages = [ config.environment.systemPackages = [
config.services.postgresql.package config.services.postgresql.package
]; ];
options.services.postgresql.ensure = mkOption { options.services.postgresql.ensure = mkValue [];
default = [];
};
config.services.postgresql = { config.services.postgresql = {
enable = true; enable = true;
@ -43,3 +41,4 @@ in {
}); });
}; };
} }