+devshell structure
This commit is contained in:
113
README.md
113
README.md
@@ -6,6 +6,7 @@ My personal Nix repository containing custom packages, overlays, NixOS modules,
|
|||||||
|
|
||||||
- 🎁 **Custom Packages**: Collection of personal Nix packages
|
- 🎁 **Custom Packages**: Collection of personal Nix packages
|
||||||
- 🔄 **Overlays**: Package modifications and enhancements
|
- 🔄 **Overlays**: Package modifications and enhancements
|
||||||
|
- 🐚 **Development Shells**: Pre-configured environments for Python and DevOps
|
||||||
- ⚙️ **NixOS Modules**: System-level configuration modules
|
- ⚙️ **NixOS Modules**: System-level configuration modules
|
||||||
- 🏠 **Home Manager Modules**: User-level configuration modules
|
- 🏠 **Home Manager Modules**: User-level configuration modules
|
||||||
- 📚 **Library Functions**: Helper utilities for configuration management
|
- 📚 **Library Functions**: Helper utilities for configuration management
|
||||||
@@ -25,6 +26,10 @@ m3ta-nixpkgs/
|
|||||||
│ ├── pomodoro-timer/
|
│ ├── pomodoro-timer/
|
||||||
│ ├── tuxedo-backlight/
|
│ ├── tuxedo-backlight/
|
||||||
│ └── zellij-ps/
|
│ └── zellij-ps/
|
||||||
|
├── shells/ # Development shells
|
||||||
|
│ ├── default.nix # Shell registry (default, python, devops)
|
||||||
|
│ ├── python.nix # Python development environment
|
||||||
|
│ └── devops.nix # DevOps/infrastructure tools
|
||||||
├── overlays/ # Overlays
|
├── overlays/ # Overlays
|
||||||
│ ├── default.nix
|
│ ├── default.nix
|
||||||
│ └── mods/ # Package modifications
|
│ └── mods/ # Package modifications
|
||||||
@@ -43,7 +48,7 @@ m3ta-nixpkgs/
|
|||||||
│ └── ports.nix # Port management utilities
|
│ └── ports.nix # Port management utilities
|
||||||
├── examples/ # Usage examples
|
├── examples/ # Usage examples
|
||||||
│ ├── home-manager-standalone.nix
|
│ ├── home-manager-standalone.nix
|
||||||
│ └── nixos-configuration.nix
|
│ ├── nixos-configuration.nix
|
||||||
└── templates/ # Templates for new packages/modules
|
└── 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
|
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
|
## Development
|
||||||
|
|
||||||
### Setting Up Development Environment
|
### Setting Up Development Environment
|
||||||
|
23
flake.nix
23
flake.nix
@@ -75,27 +75,14 @@
|
|||||||
import ./lib {lib = pkgs.lib;}
|
import ./lib {lib = pkgs.lib;}
|
||||||
);
|
);
|
||||||
|
|
||||||
# Development shell for working on this repository
|
# Development shells for various programming environments
|
||||||
|
# Usage: nix develop .#<shell-name>
|
||||||
|
# Available shells: default, rust, python, nodejs, go, cpp, web, devops, data-science
|
||||||
devShells = forAllSystems (
|
devShells = forAllSystems (
|
||||||
system: let
|
system: let
|
||||||
pkgs = pkgsFor system;
|
pkgs = pkgsFor system;
|
||||||
in {
|
in
|
||||||
default = pkgs.mkShell {
|
import ./shells {inherit pkgs;}
|
||||||
buildInputs = with pkgs; [
|
|
||||||
nil # Nix LSP
|
|
||||||
nixpkgs-fmt # Nix formatter
|
|
||||||
nix-tree # Explore dependency trees
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
echo "🚀 m3ta-nixpkgs development environment"
|
|
||||||
echo "Available commands:"
|
|
||||||
echo " nix flake check - Check flake validity"
|
|
||||||
echo " nix flake show - Show flake outputs"
|
|
||||||
echo " nix build .#<pkg> - Build a package"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
# Formatter for 'nix fmt'
|
# Formatter for 'nix fmt'
|
||||||
|
36
shells/default.nix
Normal file
36
shells/default.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Development shells for various programming environments
|
||||||
|
# Each shell can be accessed via: nix develop .#<shell-name>
|
||||||
|
# Or used in home-manager/system configs
|
||||||
|
{pkgs}: {
|
||||||
|
# Default shell for working on this repository
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
name = "m3ta-nixpkgs-dev";
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
nil # Nix LSP
|
||||||
|
nixpkgs-fmt # Nix formatter
|
||||||
|
nix-tree # Explore dependency trees
|
||||||
|
statix # Nix linter
|
||||||
|
deadnix # Find dead Nix code
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
echo "🚀 m3ta-nixpkgs development environment"
|
||||||
|
echo "Available commands:"
|
||||||
|
echo " nix flake check - Check flake validity"
|
||||||
|
echo " nix flake show - Show flake outputs"
|
||||||
|
echo " nix build .#<pkg> - Build a package"
|
||||||
|
echo " nixpkgs-fmt . - Format Nix files"
|
||||||
|
echo " statix check . - Lint Nix files"
|
||||||
|
echo " deadnix . - Find dead code"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# Import all individual shell environments
|
||||||
|
rust = import ./rust.nix {inherit pkgs;};
|
||||||
|
python = import ./python.nix {inherit pkgs;};
|
||||||
|
nodejs = import ./nodejs.nix {inherit pkgs;};
|
||||||
|
go = import ./go.nix {inherit pkgs;};
|
||||||
|
web = import ./web.nix {inherit pkgs;};
|
||||||
|
devops = import ./devops.nix {inherit pkgs;};
|
||||||
|
}
|
144
shells/devops.nix
Normal file
144
shells/devops.nix
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
# DevOps development environment
|
||||||
|
# Usage: nix develop .#devops
|
||||||
|
{pkgs}:
|
||||||
|
pkgs.mkShell {
|
||||||
|
name = "devops-dev";
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
# Container tools
|
||||||
|
docker
|
||||||
|
docker-compose
|
||||||
|
podman
|
||||||
|
buildah
|
||||||
|
skopeo
|
||||||
|
dive # Docker image explorer
|
||||||
|
|
||||||
|
# Kubernetes tools
|
||||||
|
kubectl
|
||||||
|
kubectx # Includes kubens
|
||||||
|
k9s # TUI for Kubernetes
|
||||||
|
kubernetes-helm
|
||||||
|
helmfile
|
||||||
|
kustomize
|
||||||
|
stern # Multi-pod log tailing
|
||||||
|
kubeseal # Sealed secrets
|
||||||
|
|
||||||
|
# Infrastructure as Code
|
||||||
|
terraform
|
||||||
|
opentofu # Open-source Terraform fork
|
||||||
|
terragrunt
|
||||||
|
terraform-docs
|
||||||
|
tflint
|
||||||
|
infracost # Cost estimates for Terraform
|
||||||
|
|
||||||
|
# Configuration management
|
||||||
|
ansible
|
||||||
|
ansible-lint
|
||||||
|
|
||||||
|
# CI/CD tools
|
||||||
|
github-cli
|
||||||
|
gitlab-runner
|
||||||
|
act # Run GitHub Actions locally
|
||||||
|
|
||||||
|
# Cloud CLIs
|
||||||
|
awscli2
|
||||||
|
google-cloud-sdk
|
||||||
|
azure-cli
|
||||||
|
doctl # DigitalOcean CLI
|
||||||
|
|
||||||
|
# Monitoring and observability
|
||||||
|
prometheus
|
||||||
|
grafana
|
||||||
|
# Note: promtool is included in prometheus package
|
||||||
|
|
||||||
|
# Service mesh
|
||||||
|
istioctl
|
||||||
|
linkerd
|
||||||
|
|
||||||
|
# Security and secrets
|
||||||
|
vault
|
||||||
|
sops
|
||||||
|
age # Encryption tool
|
||||||
|
trivy # Security scanner
|
||||||
|
|
||||||
|
# Scripting and automation
|
||||||
|
python3
|
||||||
|
jq
|
||||||
|
yq-go
|
||||||
|
jo # JSON output from shell
|
||||||
|
|
||||||
|
# Network tools
|
||||||
|
curl
|
||||||
|
wget
|
||||||
|
httpie
|
||||||
|
netcat
|
||||||
|
nmap
|
||||||
|
tcpdump
|
||||||
|
wireshark-cli
|
||||||
|
|
||||||
|
# System utilities
|
||||||
|
htop
|
||||||
|
btop
|
||||||
|
lsof
|
||||||
|
tmux
|
||||||
|
git
|
||||||
|
gnumake
|
||||||
|
|
||||||
|
# Linters and formatters
|
||||||
|
shellcheck
|
||||||
|
shfmt
|
||||||
|
yamllint
|
||||||
|
];
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
DOCKER_BUILDKIT = "1";
|
||||||
|
COMPOSE_DOCKER_CLI_BUILD = "1";
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
echo "🚀 DevOps Development Environment"
|
||||||
|
echo ""
|
||||||
|
echo "Container tools:"
|
||||||
|
echo " docker / podman - Container runtime"
|
||||||
|
echo " docker-compose - Multi-container applications"
|
||||||
|
echo " dive - Explore Docker images"
|
||||||
|
echo " buildah / skopeo - Build and manage containers"
|
||||||
|
echo ""
|
||||||
|
echo "Kubernetes:"
|
||||||
|
echo " kubectl - Kubernetes CLI"
|
||||||
|
echo " k9s - Kubernetes TUI"
|
||||||
|
echo " helm - Package manager"
|
||||||
|
echo " kubectx / kubens - Switch contexts/namespaces (kubens included in kubectx)"
|
||||||
|
echo " stern <pod> - Multi-pod logs"
|
||||||
|
echo ""
|
||||||
|
echo "Infrastructure as Code:"
|
||||||
|
echo " terraform / opentofu - Infrastructure provisioning"
|
||||||
|
echo " terragrunt - Terraform wrapper"
|
||||||
|
echo " ansible - Configuration management"
|
||||||
|
echo " tflint - Terraform linter"
|
||||||
|
echo ""
|
||||||
|
echo "Cloud CLIs:"
|
||||||
|
echo " aws - AWS CLI"
|
||||||
|
echo " gcloud - Google Cloud CLI"
|
||||||
|
echo " az - Azure CLI"
|
||||||
|
echo " doctl - DigitalOcean CLI"
|
||||||
|
echo ""
|
||||||
|
echo "Security & Secrets:"
|
||||||
|
echo " vault - HashiCorp Vault"
|
||||||
|
echo " sops - Secrets management"
|
||||||
|
echo " trivy - Security scanner"
|
||||||
|
echo " kubeseal - Sealed secrets"
|
||||||
|
echo ""
|
||||||
|
echo "CI/CD:"
|
||||||
|
echo " gh - GitHub CLI"
|
||||||
|
echo " act - Run GitHub Actions locally"
|
||||||
|
echo " gitlab-runner - GitLab CI runner"
|
||||||
|
echo ""
|
||||||
|
echo "Utilities:"
|
||||||
|
echo " jq / yq - JSON/YAML processors"
|
||||||
|
echo " httpie / curl - HTTP clients"
|
||||||
|
echo " shellcheck - Shell script linter"
|
||||||
|
echo ""
|
||||||
|
echo "💡 Tip: Use 'kubectx' and 'kubens' to quickly switch contexts"
|
||||||
|
echo ""
|
||||||
|
'';
|
||||||
|
}
|
78
shells/python.nix
Normal file
78
shells/python.nix
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Modern Python development environment with marimo and uv — Nushell version
|
||||||
|
# Usage: nix develop .#python (drops into Nushell)
|
||||||
|
{pkgs}: let
|
||||||
|
# Use the latest Python available in nixpkgs
|
||||||
|
python = pkgs.python314;
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
name = "python-marimo-dev";
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
# Python interpreter
|
||||||
|
python
|
||||||
|
|
||||||
|
# Modern package manager
|
||||||
|
uv
|
||||||
|
|
||||||
|
# Essential system dependencies for numpy and scientific packages
|
||||||
|
stdenv.cc.cc.lib
|
||||||
|
zlib
|
||||||
|
gfortran
|
||||||
|
openblas
|
||||||
|
lapack
|
||||||
|
|
||||||
|
# Nushell itself
|
||||||
|
nushell
|
||||||
|
];
|
||||||
|
|
||||||
|
# Environment variables for proper library linking
|
||||||
|
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath [
|
||||||
|
pkgs.stdenv.cc.cc.lib
|
||||||
|
pkgs.zlib
|
||||||
|
pkgs.gfortran.cc.lib
|
||||||
|
]}";
|
||||||
|
|
||||||
|
# Bash shellHook that sets up the environment and launches Nushell
|
||||||
|
shellHook = ''
|
||||||
|
echo "🐍 Python + Marimo Development Environment"
|
||||||
|
echo ""
|
||||||
|
echo "Python version: $(python --version)"
|
||||||
|
echo "uv version: $(uv --version)"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Create venv if it doesn't exist
|
||||||
|
if [ ! -d ".venv" ]; then
|
||||||
|
echo "Creating virtual environment..."
|
||||||
|
uv venv
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Activate the virtual environment
|
||||||
|
source .venv/bin/activate
|
||||||
|
|
||||||
|
# Install marimo if not present
|
||||||
|
if ! python -c "import marimo" 2>/dev/null; then
|
||||||
|
echo "Installing marimo..."
|
||||||
|
uv pip install marimo
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install numpy if not present
|
||||||
|
if ! python -c "import numpy" 2>/dev/null; then
|
||||||
|
echo "Installing numpy..."
|
||||||
|
uv pip install numpy
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✅ Environment ready!"
|
||||||
|
echo ""
|
||||||
|
echo "Quick start:"
|
||||||
|
echo " marimo edit - Start marimo notebook"
|
||||||
|
echo " uv pip install <package> - Install packages"
|
||||||
|
echo " python script.py - Run Python scripts"
|
||||||
|
echo ""
|
||||||
|
echo "💡 Popular packages: uv pip install pandas matplotlib scipy scikit-learn"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Launch Nushell
|
||||||
|
exec nu
|
||||||
|
'';
|
||||||
|
}
|
Reference in New Issue
Block a user