+devshell structure

This commit is contained in:
m3tam3re
2025-10-12 16:21:40 +02:00
parent 27d92a238b
commit 11755d832f
5 changed files with 375 additions and 19 deletions

113
README.md
View File

@@ -6,6 +6,7 @@ My personal Nix repository containing custom packages, overlays, NixOS modules,
- 🎁 **Custom Packages**: Collection of personal Nix packages
- 🔄 **Overlays**: Package modifications and enhancements
- 🐚 **Development Shells**: Pre-configured environments for Python and DevOps
- ⚙️ **NixOS Modules**: System-level configuration modules
- 🏠 **Home Manager Modules**: User-level configuration modules
- 📚 **Library Functions**: Helper utilities for configuration management
@@ -25,6 +26,10 @@ m3ta-nixpkgs/
│ ├── pomodoro-timer/
│ ├── tuxedo-backlight/
│ └── zellij-ps/
├── shells/ # Development shells
│ ├── default.nix # Shell registry (default, python, devops)
│ ├── python.nix # Python development environment
│ └── devops.nix # DevOps/infrastructure tools
├── overlays/ # Overlays
│ ├── default.nix
│ └── mods/ # Package modifications
@@ -43,7 +48,7 @@ m3ta-nixpkgs/
│ └── ports.nix # Port management utilities
├── examples/ # Usage examples
│ ├── home-manager-standalone.nix
── nixos-configuration.nix
── nixos-configuration.nix
└── templates/ # Templates for new packages/modules
```
@@ -160,6 +165,112 @@ nix profile install git+https://code.m3ta.dev/m3tam3re/nixpkgs#msty-studio
nix flake show git+https://code.m3ta.dev/m3tam3re/nixpkgs
```
## Development Shells
This repository provides pre-configured development environments. All shells are accessible via `nix develop`.
### Available Shells
| Shell | Description | Usage |
| --------- | ---------------------------------------------- | ---------------------- |
| `default` | Nix development tools for working on this repo | `nix develop` |
| `python` | Python with common libraries and tools | `nix develop .#python` |
| `devops` | Docker, Kubernetes, Terraform, cloud CLIs | `nix develop .#devops` |
### Quick Start
```bash
# Enter a development environment
nix develop git+https://code.m3ta.dev/m3tam3re/nixpkgs#python
nix develop git+https://code.m3ta.dev/m3tam3re/nixpkgs#devops
# Run a command in a shell without entering it
nix develop git+https://code.m3ta.dev/m3tam3re/nixpkgs#python --command python --version
```
### Using Shells in Home Manager
Add shells to your home-manager configuration for persistent access:
```nix
{
inputs.m3ta-nixpkgs.url = "git+https://code.m3ta.dev/m3tam3re/nixpkgs";
# Make tools globally available
home.packages = with inputs.m3ta-nixpkgs.devShells.${pkgs.system};
python.buildInputs ++ devops.buildInputs;
# Or create aliases
programs.zsh.shellAliases = {
dev-python = "nix develop ${inputs.m3ta-nixpkgs}#python";
dev-devops = "nix develop ${inputs.m3ta-nixpkgs}#devops";
};
}
```
### Using Shells in NixOS
Add shells system-wide:
```nix
{
inputs.m3ta-nixpkgs.url = "git+https://code.m3ta.dev/m3tam3re/nixpkgs";
# Make tools available to all users
environment.systemPackages =
inputs.m3ta-nixpkgs.devShells.${pkgs.system}.python.buildInputs;
# System-wide aliases
environment.shellAliases = {
dev-python = "nix develop ${inputs.m3ta-nixpkgs}#python";
};
}
```
### Project-Specific Usage with direnv
Create `.envrc` in your project directory:
```bash
use flake git+https://code.m3ta.dev/m3tam3re/nixpkgs#python
```
Then run `direnv allow`. The environment activates automatically when you enter the directory!
### Extending Shells for Your Project
Create a `flake.nix` in your project that extends a base shell:
```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
m3ta-nixpkgs.url = "git+https://code.m3ta.dev/m3tam3re/nixpkgs";
};
outputs = { nixpkgs, m3ta-nixpkgs, ... }: {
devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
# Inherit all packages from base Python shell
inputsFrom = [ m3ta-nixpkgs.devShells.x86_64-linux.python ];
# Add project-specific packages
buildInputs = [ nixpkgs.legacyPackages.x86_64-linux.postgresql ];
# Project-specific environment variables
DATABASE_URL = "postgresql://localhost/mydb";
};
};
}
```
### Shell Details
See individual shell files for detailed package lists and configuration:
- **Default Shell**: `shells/default.nix` - Nix development tools
- **Python Shell**: `shells/python.nix` - Python development environment
- **DevOps Shell**: `shells/devops.nix` - Infrastructure and cloud tools
## Development
### Setting Up Development Environment