Skip to content

Instantly share code, notes, and snippets.

View nh2's full-sized avatar

Niklas Hambüchen nh2

View GitHub Profile
@nh2
nh2 / Squashing commits on a branch including merges while retaining some individual commits.md
Created January 8, 2020 00:04
git: Squashing commits on a branch including merges while retaining some individual commits

Initial state

We want to squash the v commits in

v1
v2
v3
k1
k2
@nh2
nh2 / nixpkgs-duplicity-test-gpg-errors.txt
Created December 16, 2019 04:04
duplicity tests gpg invocations fail with double free or corruption (out) on nix-review for https://github.com/NixOS/nixpkgs/pull/73315
% NIX_PATH=nixpkgs=. /usr/bin/time nix-build --no-link -A duplicity
these derivations will be built:
/nix/store/73in6wzsqzpsi6k4y4x2qqi3az9rnkff-duplicity-0.7.19.drv
building '/nix/store/73in6wzsqzpsi6k4y4x2qqi3az9rnkff-duplicity-0.7.19.drv' on 'ssh://static-haskell-nix-ci'...
copying path '/nix/store/75c1irykc5r095djhxhnxrj9r0s0gph7-1359.2.3' from 'https://cache.nixos.org'...
copying path '/nix/store/lcckqzhp6khmzb9833frnh47g7fsjgik-1359.2.2' from 'https://cache.nixos.org'...
copying path '/nix/store/srgh1frvgvz141rish0pyjn520rgff38-1359.2.1' from 'https://cache.nixos.org'...
copying path '/nix/store/q8mapr5b3z26h7hackmnsk3sirjxqcq8-duplicity-0.7.19.tar.gz' from 'https://cache.nixos.org'...
copying path '/nix/store/g2za9nam04lpb5h8s7dd0y51r3lg75x6-gnutar-in-test.patch' from 'https://cache.nixos.org'...
copying path '/nix/store/ijvka0qiq3c7sk19sgs1mvm49qwpzgpl-python2.7-pyOpenSSL-19.0.0' from 'https://cache.nixos.org'...
@nh2
nh2 / ghc-error-verbose.txt
Last active November 12, 2019 01:02
GHC build error trying to add fields to InstalledPackageInfo
% ./hadrian/build.stack.sh -j --flavour=quickest --verbose
| Building Stage1 libraries: binary, Cabal, ghc, ghc-boot, ghc-boot-th, ghc-heap, ghci, hpc, mtl, parsec, template-haskell, text, transformers, terminfo, array, base, bytestring, containers, deepseq, directory, filepath, ghc-compact, ghc-prim, haskeline, integer-gmp, pretty, process, rts, stm, time, xhtml, libiserv, unix
| Building Stage1 programs: ghc, ghc-pkg, hp2ps, hsc2hs, unlit, haddock, hpc, ghc-iserv, runghc
| Building Stage2 libraries: binary, Cabal, ghc, ghc-boot, ghc-boot-th, ghc-heap, ghci, hpc, mtl, parsec, template-haskell, text, transformers, terminfo, array, base, bytestring, containers, deepseq, directory, filepath, ghc-compact, ghc-prim, haskeline, integer-gmp, pretty, process, rts, stm, time, xhtml, libiserv, unix
| Building Stage2 programs: ghc, ghc-pkg, hp2ps, hsc2hs, unlit, haddock, hpc, ghc-iserv, runghc
| Building Stage3 libraries:
| Building Stage3 programs:
@nh2
nh2 / nix-ldd.txt
Last active November 10, 2019 17:24
Nix odp-dpdk problem investigation for flokli
unpacking source archive /nix/store/cqq2m229cpgms09gcf3a3z07774d36d0-odp-dpdk-1.22.0.0_DPDK_18.11.tar.gz
source root is odp-dpdk-1.22.0.0_DPDK_18.11
setting SOURCE_DATE_EPOCH to timestamp 1566561796 of file odp-dpdk-1.22.0.0_DPDK_18.11/test/validation/api/traffic_mngr/traffic_mngr.c
patching sources
autoreconfPhase
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
@nh2
nh2 / TemplateHaskell-recompilation-problem.md
Created October 31, 2019 11:12
TemplateHaskell: The [TH] Recompilation Problem

"The [TH] Recompilation Problem"

Usually, when you use ghci's :reload or ghc --make (with -O0 to disable unfoldings which are used for cross-module inlining), after changing implementation code of functions, GHC will incrementally recompile only the modules you changed, making for a fast development experience when iterating on implementation details.

(When you change API like functions types, export lists, etc.,

@nh2
nh2 / SocketUtils.hs
Created July 13, 2019 20:18
Check whether a port is open in Haskell
module SocketUtils
( isPortOpen
, simpleSockAddr
) where
import Data.Word (Word8)
import Foreign.C.Error (Errno(..), eCONNREFUSED)
import GHC.IO.Exception (IOException(..))
import Network.Socket (PortNumber, socket, connect, close', Family(AF_INET), SocketType(Stream), SockAddr(SockAddrInet), tupleToHostAddress)
import UnliftIO.Exception (try, bracket, throwIO)
@nh2
nh2 / static-haskell-nix-cachix-push-daemon.nix
Last active July 12, 2019 19:16
Cachix systemd service for static-haskell-nix CI builder
{
systemd.services.static-haskell-nix-cachix-push-daemon = {
requiredBy = [ "multi-user.target" ];
after = [
"network-online.target"
];
environment.HOME = "/root";
path = [ pkgs.nix ]; # cachix shells out to nix binaries
serviceConfig = {
ExecStart = "${pkgs.cachix}/bin/cachix push static-haskell-nix --watch-store";
#!/usr/bin/env bash
# Installs NixOS on a Hetzner server, wiping the server.
#
# This is for a specific server configuration; adjust where needed.
#
# Prerequisites:
# * Update the script to adjust SSH pubkeys, hostname, NixOS version etc.
#
# Usage:
#!/usr/bin/env bash
# Installs NixOS on an OVH server, 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/benacofs-luks-key
# e.g. by copying it up.
@nh2
nh2 / install-grub-errors.txt
Last active June 1, 2019 18:10
install-grub.pl errors with nixos-install when / is on an LVM LV on top of mdadm RA
# 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):