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 / 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;
nh2 / chromebook-samsung-linux-boot-discussion.txt
Created Apr 13, 2019
IRC discussion on #chromium-os on picked kernel bug and how to put newer kernels on the Samsung 500C like ChrUbuntu
View chromebook-samsung-linux-boot-discussion.txt
→ nh2 joined • Channel mode: +cgnrt
02:41 <nh2> I think I found a bug in ChromiumOS's custom Linux kernel patches. How do I find the exact git commit of the kernel that my Chromebook is running?
03:30 <nh2> also, why is the `Version Lookup` box on returning (in red bold text):
03:30 <nh2> <html> <head> <title>500 Internal Server Error</title> </head> <body> <h1>500 Internal Server Error</h1> The server has either erred or is incapable of performing the requested operation.<br /><br /> </body> </html>
05:50 → CEnnis91 joined ⇐ flyback quit ↔ seventh popped in ↔ bashfulshell, sibis and phh nipped out
Tuesday, March 19th, 2019
<+amstan> nh2: hey
00:20 <nh2> amstan: hey
nh2 / ffunction-sections-xmonad.diff
Created Apr 4, 2019
Effect of -ffunction-sections on xmonad
View ffunction-sections-xmonad.diff
% diff <(nm /nix/store/nz921f60s8bgjwfkd9h2g0dilj16yz4q-xmonad-0.14.2/bin/xmonad | cut '-d ' -f3) <(nm /nix/store/qk5v882jg6s8jzzbnir4mbyh10mqjqrc-xmonad-0.14.2/bin/xmonad | cut '-d ' -f3)
< AppendLEntry
< AppendLooseLEntry.isra.1
< been_here.7889
< been_here.7898
< been_here.7906
< been_here.7918
nh2 / filterSourceConvenience.nix
Created Mar 6, 2019
A convenient function for filtering nix src input
View filterSourceConvenience.nix
# Example usage:
# src = filterSourceConvenience.filter ./. {
# srcDirs = [
# ./src
# ./app
# ./images
# ];
# srcFiles = [
# ./mypackage.cabal

Keybase proof

I hereby claim:

  • I am nh2 on github.
  • I am nh2 ( on keybase.
  • I have a public key ASDKBpC_rW52PREKyp33ebXJ9PYSfVhlvco2_3mZ2QiMOQo

To claim this, I am signing this object:

nh2 /
Created Dec 16, 2018
How autoconf does some feature detection on cross compilation

Originally from #ghc on freenode, 2018-12-16:

Most of the checks seem to actually be no-ops for cross-compilation. E.g. checking for working strnlen is just hardcoded to "yes" on all targets but AIX (in similar other cases, it just prints "guessing yes").

For checking size of int *, it does a binary search as you say, and NOT invoke the compiled programs. It does it by generating a static array with known size, like arr[1 - 2 * (sizeof(int*) <= BINARY_SEARCH_VAR)], so that the static size is either [1] or [-1]. C compilers happen to complain about arrays of negative static size, so that's how it figures that out. See ac_fn_c_compute_int().

To see this, I use for compilation of GNU hello, the following added to

nh2 / add-bluetoothd-flag.nix
Created Dec 9, 2018
Shows how to add `-P` to bluetoothd in NixOS
View add-bluetoothd-flag.nix
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "bluez-patched-systemd-unit";
buildCommand = let
in ''
set -eo pipefail
cp -rvs ${pkgs.bluez} --no-preserve=mode $out
sed --in-place 's:bluetooth/bluetoothd:bluetooth/bluetoothd -P:g' $out/etc/systemd/system/bluetooth.service
nh2 / dmesg.txt
Last active Dec 3, 2018
dmesg output showing failure of 2 devices in RAID1
View dmesg.txt
$ dmesg
[ 0.000000] microcode: CPU0 microcode updated early to revision 0x1f, date = 2018-02-07
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.4.0-131-generic (buildd@lgw01-amd64-015) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #157-Ubuntu SMP Thu Jul 12 15:51:36 UTC 2018 (Ubuntu 4.4.0-131.157-generic 4.4.134)
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-4.4.0-131-generic root=/dev/mapper/vg0-ubuntu1604 ro console=tty1 console=ttyS0,115200
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
You can’t perform that action at this time.