Skip to content

Instantly share code, notes, and snippets.

{ coreutils, writeShellScript, lib, system, glibcLocales }:
rec {
inherit (builtins) derivation;
inherit (lib) concatMapStringsSep;
standardBuildInputs = [ coreutils ];
locale = { LC_ALL = "en_US.UTF-8"; LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; };
import Control.Exception.Safe
import Control.Concurrent
bracketFork
:: IO resource
-- ^ The first action; will run in the current thread
-> (resource -> IO a)
-- ^ A final action that runs in the forked thread, with async exceptions masked
-> (resource -> IO b)
-- ^ Action that runs in the forked thread, with async exceptions unmasked
#! /usr/bin/env bash
set -eufo pipefail
nix-shell --pure --run 'ghcide --lsp'
@chris-martin
chris-martin / default.nix
Last active April 15, 2019 18:45
LaTeX + Nix setup for "Finding Success and Failure in Haskell"
{
pkgs =
import (import ./nixpkgs.nix) {};
texlive =
import ./texlive.nix { inherit (pkgs) texlive; };
fontsForLatex =
[
{ name = "google-fonts";
https://twitter.com/Cshearer41/status/1103717536921800704
Let a, b, c be the triangles, smallest to largest.
Observations from the illustration about the relative triangle sizes:
side b = 2 * height a [observation ab]
side c = 2 * height b [observation bc]
Let w be the rectangle's width and let h be its height.
{-# LANGUAGE LambdaCase #-}
import Prelude (Bool (True, False), Monad, (>>=))
ifThenElseM :: Monad m => m Bool -> m a -> m a -> m a
ifThenElseM cond ifTrue ifFalse =
cond >>= \case { True -> ifTrue; False -> ifFalse }
ifThenElseM' :: Monad m => [(m Bool, m a)] -> m a -> m a
import Pipes
import Pipes.HTTP
import qualified Pipes.Prelude as P
import qualified Pipes.ByteString as PB
import qualified Data.ByteString as BS
url = "https://typeclasses.com"
fetch url action =
do
{ pkgs, ... }:
let
src = pkgs.fetchFromGitHub {
owner = "cachix";
repo = "cachix";
# Jun 23, 2018
rev = "6a65632a4b51488b5355377e5c292a6a01efee2e";
sha256 = "13l12xkqpx6l7pfqwysz6yrgpjk6ydj6w7c85h74mzz4fvzihxyl";
};

The problem:

chris@cubby ~ ❯❯❯ nix run -f '<nixpkgs>' zlib -c cabal install zlib
Resolving dependencies...
Configuring zlib-0.6.2...
Failed to install zlib-0.6.2
Build log ( /home/chris/.cabal/logs/ghc-8.2.2/zlib-0.6.2-L2Qec9Buml21zwTs2VzSGb.log ):
cabal: Entering directory '/tmp/cabal-tmp-31070/zlib-0.6.2'
Configuring zlib-0.6.2...
#! /usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error when substituting
# The .nix directory is where we put all our Nix output symlinks. Create it if it doesn't already exist.
mkdir --parents .nix
# Pin Nix to the exact version of nixpkgs we're using.
nix build -f nixpkgs.nix --out-link .nix/nixpkgs