Nickel Package Repository for Amalgam-Generated Types
This repository contains type-safe Nickel configuration packages automatically generated using Amalgam from various schema sources including Kubernetes CRDs, OpenAPI specifications, and other type definitions. It serves as a centralized registry of strongly-typed Nickel definitions for infrastructure as code.
This repository provides pre-generated, versioned type definitions from major Kubernetes ecosystem projects. All packages are defined in .amalgam-manifest.toml and generated from specific version tags to ensure reproducibility.
Current packages include:
- Kubernetes Core Types - Complete k8s.io API definitions
- GitOps Tools - ArgoCD, FluxCD (Kustomize & Source controllers)
- Infrastructure - CrossPlane, cert-manager
- Scaling & Serverless - KEDA, Knative
- Observability - Prometheus Operator
- CI/CD - Tekton Pipelines
See .amalgam-manifest.toml for the complete list with specific versions.
Packages can be imported directly from GitHub using Nickel's import system:
# Import entire package modules
let k8s = import "github:seryl/nickel-pkgs/pkgs/k8s_io/mod.ncl" in
let crossplane = import "github:seryl/nickel-pkgs/pkgs/crossplane/mod.ncl" in
# Or import specific versions directly
let k8s_v1 = import "github:seryl/nickel-pkgs/pkgs/k8s_io/v1/mod.ncl" in
# Use type-safe configurations with full validation
let deployment = k8s_v1.Deployment & {
apiVersion = "apps/v1",
kind = "Deployment",
metadata = k8s_v1.ObjectMeta & {
name = "my-app",
namespace = "default",
labels = {
app = "my-app",
environment = "production"
}
},
spec = k8s_v1.DeploymentSpec & {
replicas = 3,
selector = {
matchLabels = {
app = "my-app"
}
},
template = k8s_v1.PodTemplateSpec & {
metadata = k8s_v1.ObjectMeta & {
labels = {
app = "my-app"
}
},
spec = k8s_v1.PodSpec & {
containers = [{
name = "app",
image = "nginx:latest",
ports = [{
containerPort = 80
}]
}]
}
}
}
} in
deploymentPackages automatically handle cross-package imports. For example, CrossPlane types reference Kubernetes ObjectMeta:
# CrossPlane Composition using Kubernetes types
let crossplane = import "github:seryl/nickel-pkgs/pkgs/crossplane/apiextensions.crossplane.io/v1/mod.ncl" in
let composition = crossplane.Composition & {
apiVersion = "apiextensions.crossplane.io/v1",
kind = "Composition",
metadata = { # This automatically uses k8s_io ObjectMeta
name = "my-composition",
labels = {
provider = "aws",
complexity = "simple"
}
},
spec = crossplane.CompositionSpec & {
compositeTypeRef = {
apiVersion = "example.io/v1",
kind = "XDatabase"
},
# Additional spec fields...
}
} in
compositionnickel-pkgs/
βββ .amalgam-manifest.toml # Package generation manifest
βββ flake.nix # Nix flake with dev environment
βββ nix/ # All Nix tooling
β βββ ci-runner.nix # CI orchestration
β βββ packages.nix # Package definitions
βββ pkgs/ # Generated Nickel packages
βββ k8s_io/ # Core Kubernetes types
β βββ mod.ncl # Main module
β βββ v1/ # Core v1 API types
β βββ v1beta1/ # Beta API types
βββ crossplane/ # CrossPlane CRDs
βββ argocd/ # ArgoCD CRDs
βββ ... # Other packages
This repository provides a complete development environment via Nix flakes:
# Enter development shell (or use direnv)
nix develop
# Then use built-in commands:
ci-runner ci # Run full CI pipeline (generate + validate)
ci-runner generate # Generate packages from manifest
ci-runner validate # Validate all packages
amalgam --help # Direct access to Amalgam
# Or use one-liners:
nix develop -c ci-runner ciTo add a new package, edit .amalgam-manifest.toml:
[[packages]]
name = "my-operator"
type = "url"
url = "https://github.com/example/operator/tree/v1.0.0/crds" # Use versioned URLs
git_ref = "v1.0.0" # Specify the git reference
version = "1.0.0" # Package version
output = "my-operator"
description = "My operator CRD type definitions"
keywords = ["operator", "kubernetes"]
dependencies = { k8s_io = "1.33.4" }Important: Always use versioned URLs (tags/releases) rather than main/master branches to ensure reproducible package generation.
Each generated package follows a consistent structure:
- mod.ncl - Main module file that exports all API versions
- Version directories (v1, v1beta1, v1alpha1, etc.) - API version-specific types
- Individual type files - One .ncl file per type with contracts and documentation
- Automatic imports - Cross-package dependencies resolved via relative paths
pkgs/k8s_io/
βββ mod.ncl # Main module exporting all versions
βββ Nickel-pkg.ncl # Package metadata
βββ v1/
β βββ mod.ncl # v1 API module
β βββ deployment.ncl # Individual type definitions
β βββ pod.ncl
β βββ ...
βββ v1beta1/
βββ mod.ncl
βββ ...
# deployment.ncl - Generated with full type safety and documentation
let deploymentstatus = import "./deploymentstatus.ncl" in
let objectmeta = import "./objectmeta.ncl" in
let deploymentspec = import "./deploymentspec.ncl" in
{
# Deployment enables declarative updates for Pods and ReplicaSets
Deployment = {
apiVersion | optional | String | doc "API version",
kind | optional | String | doc "Resource kind",
metadata | optional | objectmeta.ObjectMeta | doc "Standard object metadata",
spec | optional | deploymentspec.DeploymentSpec | doc "Deployment specification",
status | optional | deploymentstatus.DeploymentStatus | doc "Current status",
}
}To contribute new packages:
- Edit
.amalgam-manifest.tomlto add your package definition - Run
nix develop -c ci-runner cito generate and validate - Ensure all packages use versioned URLs for reproducibility
- Test that cross-package imports work correctly
- Submit a pull request with your changes
The repository uses GitHub Actions for CI/CD, which automatically validates all packages on every push.
This repository uses Amalgam (currently v0.6.1) which provides:
- Universal schema parsing (Kubernetes CRDs, OpenAPI specs, Go types)
- Automatic cross-package import resolution with dependency tracking
- Idempotent package generation - same input always produces same output
- Type registry for managing complex type hierarchies
- Support for all Kubernetes API conventions and CRD formats
All packages depend on the Kubernetes core types (k8s_io) for common types like ObjectMeta. The dependency graph is automatically managed by Amalgam during generation.
Other Nix projects can import this repository to access both the packages and tooling:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nickel-pkgs.url = "github:seryl/nickel-pkgs";
};
outputs = { self, nixpkgs, nickel-pkgs, ... }: {
devShells.default = pkgs.mkShell {
buildInputs = [
# Get Nickel with package support
nickel-pkgs.packages.${system}.nickel-with-packages
# Get Amalgam for generating new types
nickel-pkgs.packages.${system}.amalgam-bin
];
};
};
}The repository includes a comprehensive CI pipeline that:
- Generates all packages from
.amalgam-manifest.toml - Validates all generated Nickel files with type checking
- Ensures cross-package imports resolve correctly
- Runs on every push via GitHub Actions
This repository and its generated packages are available under the Apache License 2.0.
- Generated using Amalgam
- For use with Nickel configuration language
- Built with Nix flakes for reproducible environments