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 / 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";
@flokli
flokli / qnap-ec.nix
Created August 21, 2022 20:17
qnap-ec kernel module. Set `boot.extraModulePackages = [ (config.boot.kernelPackages.callPackage ./path-to-qnap-ec.nix {}) ];` to use
{ stdenv
, lib
, fetchFromGitHub
, kernel
, kmod
}:
stdenv.mkDerivation {
pname = "qnap-ec";
version = "unstable-2021-11-22";
@flokli
flokli / talos_nocloud_cidata.bash
Created March 25, 2022 16:31
Install talos nocloud and add CIDATA with config
#!/usr/bin/env bash
# This assumes a booted rescue system, copies the installation media to the destination disk
# it'll then add a CIDATA partition to the end of the disk, and prepare it with user-data
# used in a terraform ssh provisioner, but extracted to here for now.
destination_disk=/dev/nvme0n1
talos_version=v0.14.3
wipefs -af $destination_disk
wget https://github.com/talos-systems/talos/releases/download/${talos_version}/nocloud-amd64.raw.xz
@flokli
flokli / foobar.yml
Last active August 21, 2020 09:40
ansible-playbook -i inventory.ini foobar.yml
- name: This doesn't work
hosts: localhost
connection: local
gather_facts: no
become: no
tasks:
- local_action: >
shell
echo hey
@flokli
flokli / build-qcow2.nix
Created August 17, 2020 07:58
build NixOS qcow image for serial testing
# stolen from https://gist.github.com/tarnacious/f9674436fff0efeb4bb6585c79a3b9ff
{ config, lib, pkgs, ... }:
with lib;
{
imports =
[
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
./configuration.nix