home-lab/packages/README.md
Geir Okkenhaug Jerstad f30013723e feat: initial NixOS home lab infrastructure setup
- Add modular flake-based NixOS configuration
- Implement GitOps foundation with CI/CD pipeline
- Create comprehensive documentation and branching strategy
- Add modular desktop environments (GNOME, Cosmic, Sway)
- Configure virtualization stack (Incus, Libvirt, Podman)
- Set up development tools and hardware-specific modules
- Establish user configuration with literate programming support

This commit represents the completion of Phase 1: Flakes Migration
with modular configuration, virtualization, and GitOps foundation.
2025-06-04 16:10:13 +02:00

145 lines
No EOL
3.3 KiB
Markdown

# Packages Directory
This directory contains custom package definitions and overlays for the Home-lab NixOS infrastructure.
## Directory Purpose
The `packages/` directory is used for:
- Custom package derivations not available in nixpkgs
- Modified versions of existing packages
- Home-lab specific applications and utilities
- Package overlays and customizations
## Structure
### Custom Packages
- `my-package/` - Individual package directories
- `default.nix` - Package collection and exports
- `flake-module.nix` - Flake integration for packages
### Package Categories
- `applications/` - Custom applications and GUIs
- `scripts/` - Shell scripts and automation tools
- `configs/` - Configuration packages and templates
- `overlays/` - Package overlays and modifications
## Usage
### In Flake Configuration
```nix
# flake.nix
{
outputs = { self, nixpkgs, ... }: {
packages.x86_64-linux = import ./packages {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
};
overlays.default = import ./packages/overlays;
};
}
```
### In Machine Configuration
```nix
# machine configuration
{
nixpkgs.overlays = [ inputs.self.overlays.default ];
environment.systemPackages = with pkgs; [
# Custom packages from this directory
my-custom-tool
home-lab-scripts
];
}
```
## Package Development
### Creating New Package
1. Create package directory: `packages/my-package/`
2. Write `default.nix` with package derivation
3. Add to `packages/default.nix` exports
4. Test with `nix build .#my-package`
### Package Template
```nix
{ lib, stdenv, fetchFromGitHub, ... }:
stdenv.mkDerivation rec {
pname = "my-package";
version = "1.0.0";
src = fetchFromGitHub {
owner = "user";
repo = "repo";
rev = "v${version}";
sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
meta = with lib; {
description = "Description of my package";
homepage = "https://github.com/user/repo";
license = licenses.mit;
maintainers = [ "geir" ];
platforms = platforms.linux;
};
}
```
## Overlay Examples
### Package Modification
```nix
# overlays/default.nix
final: prev: {
# Modify existing package
vim = prev.vim.override {
features = "huge";
};
# Add custom package
home-lab-tools = final.callPackage ../tools { };
}
```
## Home-lab Specific Packages
### CongenitalOptimist Packages
- Development environment customizations
- Workstation-specific tools
- Desktop application modifications
### sleeper-service Packages
- File server utilities
- Monitoring tools
- Backup scripts
- Network service tools
## Best Practices
- **Versioning**: Pin package versions for reproducibility
- **Documentation**: Include clear descriptions and usage
- **Testing**: Test packages across target machines
- **Licensing**: Respect upstream licenses and attributions
- **Maintenance**: Keep packages updated and functional
## Integration with Modules
Packages can be integrated with NixOS modules:
```nix
# modules/development/tools.nix
{ config, pkgs, ... }: {
environment.systemPackages = with pkgs; [
# Reference custom packages
home-lab-dev-tools
custom-editor-config
];
}
```
## Flake Outputs
Custom packages are exported as flake outputs:
- `packages.x86_64-linux.package-name`
- `overlays.default`
- `apps.x86_64-linux.script-name`