Skip to content

Instantly share code, notes, and snippets.

View Lillecarl's full-sized avatar
πŸ¦•
Dinosaurs are a lie!

Carl Lillecarl

πŸ¦•
Dinosaurs are a lie!
View GitHub Profile
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: nix-csi
namespace: nix-csi
rules:
- apiGroups:
- ""
resources:
- nodes
apiVersion: v1
items:
- apiVersion: cilium.io/v2
kind: CiliumClusterwideNetworkPolicy
metadata:
annotations:
kluctl.io/deployment-item-dir: default
creationTimestamp: "2025-11-17T22:24:53Z"
generation: 3
labels:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2025-11-02T21:23:43Z"
generateName: ctest-656cddf679-
generation: 1
labels:
app: ctest
pod-template-hash: 656cddf679
name: ctest-656cddf679-dj8pt
@Lillecarl
Lillecarl / nix-timegc.py
Created October 27, 2025 14:01
A smarter way to collect garbage(?)
#!/usr/bin/env python3
import argparse
import sqlite3
import subprocess
import os
import sys
from sqlite3 import Connection
from datetime import datetime, timedelta
from pathlib import Path
[lillecarl@shitbox] in ~/C/easykubenix [πŸŽ‹ main][🐚fish]
[18:03:51]❯ cat $(nix build --file . eval.config.kluctl.projectDir)/**/** 2>/dev/null
[bat error]: '/nix/store/smm9fd70zsvn4nfrsd25dwxv5cxx6hxp-kluctlProject/CustomResourceDefinition' is a directory.
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
β”‚ File: /nix/store/smm9fd70zsvn4nfrsd25dwxv5cxx6hxp-kluctlProject/CustomResourceDefinition/easykubenix.yaml
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 β”‚ {"apiVersion":"v1","items":[],"kind":"List"}
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[bat error]: '/nix/store/smm9fd70zsvn4nfrsd25dwxv5cxx6hxp-kluctlProject/def
From b39df2392ba95b50d6a4864188063ee354313170 Mon Sep 17 00:00:00 2001
From: Carl Andersson <[email protected]>
Date: Mon, 13 Oct 2025 13:08:24 +0200
Subject: [PATCH] Add namespacing to kubernetes.resources
This way we can't collide when rendering manifests and such.
I took too much inspiration from kubenix when putting the original API together!
---
cluster-config/cilium.nix | 2 +-
cluster-config/cnpg.nix | 2 +-
{
pkgs ? import <nixpkgs> { },
}:
let
manifest = pkgs.writeTextFile {
name = "test-manifest.yaml";
text = ''
apiVersion: v1
kind: ConfigMap
metadata:
@Lillecarl
Lillecarl / kluapply.fish
Last active October 7, 2025 12:13
Use kluctl deploy --prune
#! /usr/bin/env fish
# Defined via `source`
function kluapply --description 'Deploy YAML with kluctl'
argparse --ignore-unknown 'd/discriminator=' 'f/file=' -- $argv
or return 1
set discriminator $_flag_discriminator
set filepath $_flag_file
if test -z "$discriminator"
#!/usr/bin/env python3
"""
nix-touch: Update Nix store path registration times for LRU garbage collection
This tool updates the registrationTime field in the Nix database for a store path
and its dependencies, effectively marking them as "recently used" for GC purposes.
"""
import argparse
import sqlite3
apiVersion: v1
kind: Pod
metadata:
annotations:
cknix-expr: hello
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{"cknix-expr":"hello","kubenix/k8s-version":"1.33","kubenix/project-name":"kubenix"},"name":"testpod","namespace":"default"},"spec":{"containers":[{"command":["/nix/var/result/bin/sleep","infinity"],"env":[{"name":"PATH","value":"/nix/var/result/bin"}],"image":"dramforever/scratch:latest","name":"this","volumeMounts":[{"mountPath":"/etc/nix","name":"nix-config","readOnly":true},{"mountPath":"/nix","name":"cknix-volume","readOnly":false}]}],"hostNetwork":true,"volumes":[{"configMap":{"name":"nix-config"},"name":"nix-config"},{"csi":{"driver":"cknix.csi.store","volumeAttributes":{"expr":"let\n pkgs = (import (builtins.fetchTree {\n type = \"github\";\n repo = \"nixpkgs\";\n owner = \"NixOS\";\n ref = \"nixos-unstable\";\n }) {});\nin\n pkgs.buildEnv {\n name = \"testEnv\";\n paths = [\n pkgs.uutil