Skip to content

Instantly share code, notes, and snippets.

View flokli's full-sized avatar
🐑
Määh!

Florian Klink flokli

🐑
Määh!
View GitHub Profile
@flokli
flokli / mitm_nixbld.sh
Created January 8, 2025 19:25
mitmproxy for nix builds
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p minica -p mitmproxy
set -e
echo "Creating CA key and certificate, as well as wildcard cert"
minica -domains '*' || true
echo "Assembling chain.pem"
(openssl x509 -text <./_/cert.pem && openssl x509 -text <./minica.pem && cat ./_/key.pem) > chain.pem
@flokli
flokli / devenv-eval-only.md
Created November 11, 2024 21:02
Sketch on how devenv could use tvix-eval

This document sketches out how devenv could be using Tvix, instead of Nix for Evaluation.

Currently building with Tvix as well is out of scope, but we're fine with Tvix ingesting things in its own (in-memory or semi-ephemeral in a cache directory) store, and copying from there into the "real" Nix store.

Ultimately, devenv evaluates a few attrpaths in a Nix file. As internally fetchTree is used, it being supported in Tvix is a requirement.

Assuming there is fetchTree support, we can evaluate these files with Tvix too.

@flokli
flokli / gist:de8fd87833cea49fba11bd63b67d587e
Created June 6, 2024 05:56
Estonian i-voting application
{ stdenv
, lib
, fetchurl
, makeWrapper
, fontconfig
, libXft
, opensc
, xorg

Keybase proof

I hereby claim:

  • I am flokli on github.
  • I am flokli (https://keybase.io/flokli) on keybase.
  • I have a public key whose fingerprint is D581 720C FA3E 9BC3 610C D996 89F2 59B8 FA0D 181F

To claim this, I am signing this object:

@flokli
flokli / oci.go
Last active December 24, 2023 14:05
tvix-build oci docstr
// Builds a OCI bundle from a BuildRequest and a path, which points to an
// existing (and empty) path to a directory (usually a temporary).
//
// This function emits an OCI bundle that will run the build specifed in the
// buildRequest.
//
// After running this function, the directory contains the following:
//
// - `config.json`, the OCI runtime spec itself
// - `scratch`, a directory containing other directories which will be
@flokli
flokli / gist:0fa74eb334a3c388df0f2cd85f281316
Last active May 24, 2023 09:02
tvix-cli eval without shelling out to `nix-store --add`
tvix-cli from https://cl.tvl.fyi/c/depot/+/8572/33:
❯ /nix/store/fi3j1sbpd2fzwbjnak924z58zhpd07j0-hyperfine-1.16.1/bin/hyperfine --warmup 10 './target/release/tvix -E "with import <nixpkgs>{}; toString stdenv"' 'nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString stdenv"'
Benchmark 1: ./target/release/tvix -E "with import <nixpkgs>{}; toString stdenv"
Time (mean ± σ): 1.235 s ± 0.013 s [User: 1.161 s, System: 0.074 s]
Range (min … max): 1.218 s … 1.254 s 10 runs
Benchmark 2: nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString stdenv"
Time (mean ± σ): 193.7 ms ± 3.4 ms [User: 161.7 ms, System: 32.0 ms]
Range (min … max): 190.3 ms … 203.1 ms 14 runs
@flokli
flokli / gist:b147c4b9cab81535b306ba21cc5a14ce
Created March 27, 2023 21:13
gscan2pdf build failure
running tests
PERL_DL_NONLAZY=1 "/nix/store/rgw6wzny8rqpri516srzvjv2gqsg1niv-perl-5.36.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_NetPBM.t ................................. ok
t/02_Scanner_Options_brother.t ................ ok
t/02_Scanner_Options_Brother_DCP-7025.t ....... ok
t/02_Scanner_Options_Brother_MFC_5100c.t ...... ok
t/02_Scanner_Options_Brother_MFC_8860DN.t ..... ok
t/02_Scanner_Options_canonLiDE25.t ............ ok
t/02_Scanner_Options_canoscan_FB_630P.t ....... ok
t/02_Scanner_Options_epson1.t ................. ok
❯ nix-build -A nixosTests.systemd-cryptenroll
this derivation will be built:
/nix/store/wrrx8d9splrkd484p6cjrrwpn1n81f98-vm-test-run-systemd-cryptenroll.drv
building '/nix/store/wrrx8d9splrkd484p6cjrrwpn1n81f98-vm-test-run-systemd-cryptenroll.drv'...
Machine state will be reset. To keep it, pass --keep-vm-state
start all VLans
start vlan
running vlan (pid 7; ctl /build/vde1.ctl)
(finished: start all VLans, in 0.00 seconds)
run the VM test script
@flokli
flokli / fod_calculations.go
Created November 27, 2022 23:25
Some bit twiddling to realize FOD output path calculation uses the NAR representation of the contents, at least when not interacting with directories.
package main
import (
"encoding/hex"
"fmt"
nixhash "github.com/nix-community/go-nix/pkg/hash"
"github.com/nix-community/go-nix/pkg/nixbase32"
)
@flokli
flokli / nsncd.nix
Last active October 13, 2022 20:19
Snippet to include into your nixos configuration to run a nsncd (non-caching NSS daemon, written in Rust)
{ pkgs, lib, ... }:
let
nsncdPackage = pkgs.rustPlatform.buildRustPackage rec {
pname = "nsncd";
version = "unstable-2021-10-13";
src = pkgs.fetchFromGitHub {
owner = "flokli";
repo = "nsncd";