Skip to content

Instantly share code, notes, and snippets.

Niklas Hambüchen nh2

Block or report user

Report or block nh2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nh2 /
Created Jun 3, 2019
Example script to install NixOS on an OVH dedicated server via the OVH rescue mode
#!/usr/bin/env bash
# Installs NixOS on an OVH server in its rescue mode, wiping the server.
# This is for a specific server configuration; adjust where needed.
# Originally written for an OVH STOR-1 server.
# Prerequisites:
# * Create a LUKS key file at /root/datafs-luks-key
# e.g. by copying it up.
nh2 / install-grub-errors.txt
Last active Jun 1, 2019 errors with nixos-install when / is on an LVM LV on top of mdadm RA
View install-grub-errors.txt
# EDIT: Solution was that I had accidentally given grub a config where / is on LVM on LUKS, which can obviously not work.
# Still unclear why GRUB "memory leaks" in that case.
installing the GRUB 2 boot loader on /dev/sda...
Installing for i386-pc platform.
You have a memory leak (not released memory pool):
[0x56c1e0] dtree
[0x571e10] dtree
Internal error: Unreleased memory pool(s) found.
You have a memory leak (not released memory pool):
nh2 / Cabal-
Created May 29, 2019
Problem with GHC saying `<command line>: unknown package: integer-gmp` when Cabal built with an integer-gmp GHC is used in a build of a GHC with integer-simple
View Cabal-
name: Cabal
id: Cabal-
key: Cabal-
license: BSD-3-Clause
copyright: 2003-2018, Cabal Development Team (see AUTHORS file)
author: Cabal Development Team <>
synopsis: A framework for packaging Haskell software
nh2 / ProcessConduitGhciExample.hs
Created May 8, 2019
Example for controlling ghci interactively with conduit's process module
View ProcessConduitGhciExample.hs
-- Example for controlling ghci interactively with conduit's process module.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Conduit
import Control.Concurrent.Async
import Control.Concurrent.MVar
import Control.Monad
import Data.Conduit (runConduit, (.|))
nh2 / grep-darwin.txt
Last active May 3, 2019
Linux vs Darwin gst-plugins-good dev build outputs problem
View grep-darwin.txt
$ env | grep -i --color prop
nh2 / Makefile
Last active Apr 26, 2019
Another make horror example. Guess what this does. (Don't use Make, unless you really know how it works, by which time you probably decide against it.)
View Makefile
# Let's assume COMPILER was for some accidental reason not set.
CFLAGS = -O2 -Wall
$(COMPILER) $(CFLAGS) --version
View error-output.txt
[root@builder:~/kernel]# mkdir tmpdir
[root@builder:~/kernel]# cd tmpdir
[root@builder:~/kernel/tmpdir]# NIX_PATH=nixpkgs=$HOME/kernel/nixpkgs nix-shell -E 'with import <nixpkgs> {}; linux.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkgconfig ncurses ];})'
[nix-shell:~/kernel/tmpdir]# unpackPhase
unpacking source archive /nix/store/z7wzk01hjfgdcbnbzpkq040v7k9hw427-linux-4.19.36.tar.xz
source root is linux-4.19.36
setting SOURCE_DATE_EPOCH to timestamp 1555744565 of file linux-4.19.36/virt/lib/irqbypass.c
nh2 / chromiumos-kernel.config
Created Apr 19, 2019
Looking for kernel config options that make ChromiumOS's config boot and NixOS's not
View chromiumos-kernel.config
% ./extract-ikconfig $(NIX_PATH=nixpkgs=$HOME/src/nixpkgs nix-build '<nixpkgs/nixos>' -A -I nixos-config=nixos-rootfs.nix --option builders-use-substitutes true --builders @$HOME/nix-remote-builders)/bzImage
# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 4.4.178 Kernel Configuration
nh2 / nixops-custom-subsitutor-hack.diff
Created Apr 19, 2019
Shows my custom hack to ensure deployed NixOps machines use my custom substitutor already for the first `nixops deploy`
View nixops-custom-subsitutor-hack.diff
diff --git a/nixops/ b/nixops/
index 1341a27..6df2fd6 100644
--- a/nixops/
+++ b/nixops/
@@ -2,7 +2,7 @@
import sys
import os.path
-import subprocess
+import subprocess32 as subprocess
nh2 / nixos-rootfs.nix
Last active Apr 19, 2019
Example of how to build a NixOS root file system
View nixos-rootfs.nix
# Build with:
# NIX_PATH=nixpkgs=$HOME/src/nixpkgs nix-build --no-link '<nixpkgs/nixos>' -A -I nixos-config=thisfile.nix
# You can also use
# -A
# to build something you can browse locally (that uses symlinks into your nix store).
{config, pkgs, ...}:
# We need no bootloader, because the Chromebook can't use that anyway.
boot.loader.grub.enable = false;
You can’t perform that action at this time.