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
nh2 / ghc-error-verbose.txt
Last active Nov 12, 2019
GHC build error trying to add fields to InstalledPackageInfo
View ghc-error-verbose.txt
% ./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 Nov 10, 2019
Nix odp-dpdk problem investigation for flokli
View nix-ldd.txt
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 Oct 31, 2019
TemplateHaskell: The [TH] Recompilation Problem
View TemplateHaskell-recompilation-problem.md

"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 Jul 13, 2019
Check whether a port is open in Haskell
View SocketUtils.hs
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 Jul 12, 2019
Cachix systemd service for static-haskell-nix CI builder
View static-haskell-nix-cachix-push-daemon.nix
{
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";
@nh2
nh2 / hetzner-dedicated-wipe-and-install-nixos.sh
Last active Sep 22, 2019
Example script to install NixOS on a Hetzner dedicated server via the Hetzner rescue mode
View hetzner-dedicated-wipe-and-install-nixos.sh
#!/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:
@nh2
nh2 / ovh-dedicated-wipe-and-install-nixos.sh
Created Jun 3, 2019
Example script to install NixOS on an OVH dedicated server via the OVH rescue mode
View ovh-dedicated-wipe-and-install-nixos.sh
#!/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
nh2 / install-grub-errors.txt
Last active Jun 1, 2019
install-grub.pl 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
nh2 / Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8.conf
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-2.4.1.0-9MZFDeNrcJI10bcroa6pq8.conf
name: Cabal
version: 2.4.1.0
id: Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8
key: Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8
license: BSD-3-Clause
copyright: 2003-2018, Cabal Development Team (see AUTHORS file)
maintainer: cabal-devel@haskell.org
author: Cabal Development Team <cabal-devel@haskell.org>
homepage: http://www.haskell.org/cabal/
synopsis: A framework for packaging Haskell software
@nh2
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, (.|))
You can’t perform that action at this time.