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.
This commit is contained in:
Geir Okkenhaug Jerstad 2025-06-04 16:10:13 +02:00
commit f30013723e
43 changed files with 4220 additions and 0 deletions

145
packages/README.md Normal file
View file

@ -0,0 +1,145 @@
# 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`

16
packages/default.nix Normal file
View file

@ -0,0 +1,16 @@
{ pkgs ? import <nixpkgs> { } }:
{
# Custom packages for Home-lab infrastructure
# Home-lab specific tools and utilities
home-lab-tools = pkgs.callPackage ./home-lab-tools.nix { };
# Re-export commonly used packages with custom configurations
inherit (pkgs)
# Core utilities that might be customized
git
curl
wget
;
}

View file

@ -0,0 +1,38 @@
{ lib, stdenv, writeShellScriptBin, ... }:
writeShellScriptBin "home-lab-tools" ''
#!/usr/bin/env bash
# Home-lab administration tools
# Placeholder for custom utilities and scripts
case "$1" in
"status")
echo "Home-lab infrastructure status:"
echo " congenital-optimist: $(systemctl is-active tailscale || echo 'unknown')"
echo " sleeper-service: Checking connectivity..."
;;
"backup")
echo "Initiating backup procedures..."
echo "This would trigger backup scripts across the infrastructure"
;;
"monitor")
echo "System monitoring overview:"
echo "Use this space for custom monitoring commands"
;;
"deploy")
echo "Deploying configurations..."
echo "This would handle nixos-rebuild across machines"
;;
*)
echo "Home-lab Tools"
echo "Usage: $0 {status|backup|monitor|deploy}"
echo ""
echo "Available commands:"
echo " status - Check infrastructure status"
echo " backup - Run backup procedures"
echo " monitor - Show monitoring overview"
echo " deploy - Deploy configurations"
;;
esac
''