Skip to content

Instantly share code, notes, and snippets.

Mic92 /
Last active December 15, 2023 19:35
Tvix (79246855d1a0fd9b81be113b16a56379c7641aa1) vs nix (2.19.2) evaluation of the hello package

Tvix is a new implementation of the Nix language and package manager. In this benchmark we test it's performance when instantiating the hello package from nix. Note that at the time tvix does not have its own store implementation yet and it has to execute nix-store whenever it needs to copy files to the store.

Mic92 /
Created October 22, 2023 05:57
Scrape all nixpkgs pull requests
#!/usr/bin/env python3
import http.client
import json
import os
import time
import urllib.parse
import urllib.request
from pathlib import Path
from typing import Any
Mic92 / kexec-installer.nix
Last active September 24, 2023 02:02
kexec-based installer for nixos to install nixos from every linux!
View kexec-installer.nix
# $ nix-build kexec-installer.nix
# can be deployed remote like this
# $ rsync -aL -e ssh result/ root@host:
# $ ssh root@host ./kexec-installer
## Customize it like this
# # custom-installer.nix
# import ./kexec-installer.nix {
# extraConfig = {pkgs, ... } {
# user.extraUsers.root.openssh.authorizedKeys.keys = [ "<your-key>" ];
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p sqlite -p bash
SQL=$(cat <<EOF
select * from DerivationOutputs do
inner join ValidPaths vp on = do.drv
inner join Refs r1 on r1.referrer =
inner join ValidPaths vp2 on r1.reference =
where do.path GLOB '/nix/store/$1-*'
Mic92 / shell.nix
Created March 25, 2018 09:03 — forked from abbradar/shell.nix
Nix FHS env for OpenWrt
View shell.nix
{ pkgs ? import <nixpkgs> {} }:
fixWrapper = pkgs.runCommand "fix-wrapper" {} ''
mkdir -p $out/bin
for i in ${}/bin/*-gnu-gcc*; do
ln -s ${pkgs.gcc}/bin/gcc $out/bin/$(basename "$i")
for i in ${}/bin/*-gnu-{g++,c++}*; do
ln -s ${pkgs.gcc}/bin/g++ $out/bin/$(basename "$i")
Mic92 / 00_eval.txt
Last active July 16, 2023 10:19
Evaluation benchmark for benchmark with different batchsizes
View 00_eval.txt
# Batch size: 1000
## Query all packages
elapsed: 24.68 s, heap size: 2610.18 MiB
## Evaluating packages in batches
elapsed: 15.04 s, heap size: 1217.18 MiB
elapsed: 18.31 s, heap size: 1377.18 MiB
elapsed: 9.13 s, heap size: 673.18 MiB
elapsed: 11.24 s, heap size: 769.18 MiB
elapsed: 16.69 s, heap size: 1169.18 MiB
elapsed: 3.50 s, heap size: 384.31 MiB
if ! command -v nix >/dev/null; then
echo "Installing Nix..."
if command -v curl; then
curl -L > /tmp/install
elif command -v wget; then
wget -O /tmp/install
echo "Please install curl or wget"
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p qemu_kvm -p iproute2
set -x -eu -o pipefail
Mic92 / default.nix
Last active March 11, 2023 17:59
Nix-shell environment to get all dependencies to build openwrt/LEDE (a more up-to-date version can be found here:
View default.nix
# Nix is a powerful package manager for Linux and other Unix systems that makes
# package management reliable and reproducible:
# This file is intended to be used with `nix-shell`
# ( to setup a fully-functional
# LEDE build environment by installing all required dependencies.
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "openwrt-dev-env";
buildInputs = [
# This list is more explicit then it have to be: it also includes utils
Mic92 / pushover-warning@.service
Last active February 25, 2023 14:21
Sent pushover warnings when a systemd service failed (useful for backups and systemd timers)
View pushover-warning@.service
Description=pushover warning
ExecStart=/usr/bin/curl -s \
--form-string "token=<PUSHOVER_APPLICATION_TOKEN>" \
--form-string "user=<PUSHOVER_USER_TOKEN>" \
--form-string "message=service %I at %H failed" \