Skip to content

Instantly share code, notes, and snippets.

View alexpeits's full-sized avatar

Alex Peitsinis alexpeits

View GitHub Profile
@alexpeits
alexpeits / default.nix
Created February 29, 2020 02:56
nix derivation to build the source for the programming language miranda (http://miranda.org.uk/)
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "miranda";
buildInputs = [ gcc ];
src = ./.;
configurePhase = ''
make cleanup
patchShebangs quotehostinfo
'';
@alexpeits
alexpeits / default.nix
Created January 19, 2020 16:26
generic haskell + nix configuration (here copied from `harg`)
# to see ghc versions:
# nix-instantiate --eval -E "with import ./nix/nixpkgs.nix {}; lib.attrNames haskell.compiler"
{ pkgs ? null, compiler ? null, withHoogle ? true }:
let
nixpkgs = if isNull pkgs then
import (import ./nix/sources.nix).nixos-stable { }
else if builtins.typeOf pkgs == "set" then
pkgs
docker run -p 8080:80 mendhak/http-https-echo
curl http://localhost/whatever # works
# in another terminal
export hostmachine="$(docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge)"
docker run --add-host hostmachine:$hostmachine --net=host -it debian bash
apt-get update && apt-get install -y curl
curl http://hostmachine:8080/whatever # I expect this to work
@alexpeits
alexpeits / xmonad.nix
Created November 20, 2019 14:20
XMonad nix derivation
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:
let
inherit (nixpkgs) pkgs;
f = { mkDerivation, base, containers, data-default, directory
, extensible-exceptions, filepath, mtl, process, QuickCheck
, setlocale, stdenv, unix, utf8-string, X11
}:

Keybase proof

I hereby claim:

  • I am alexpeits on github.
  • I am alexpeits (https://keybase.io/alexpeits) on keybase.
  • I have a public key ASAtZxx1hUjLBX9w9TNQcTLX-8Xq1gd6n4YqXtQZ1PKDHAo

To claim this, I am signing this object:

@alexpeits
alexpeits / .envrc
Created October 22, 2019 13:00
direnv + nix + caching + only exporting useful things (https://github.com/direnv/direnv/wiki/Nix)
# Usage: use_nix [...]
#
# Load environment variables from `nix-shell`.
# If you have a `default.nix` or `shell.nix` one of these will be used and
# the derived environment will be stored at ./.direnv/env-<hash>
# and symlink to it will be created at ./.direnv/default.
# Dependencies are added to the GC roots, such that the environment remains persistent.
#
# The resulting environment is cached for better performance.
#
@alexpeits
alexpeits / Makefile.haskell
Created September 8, 2019 19:20
Makefiles
ghcid:
ghcid -a --command="stack ghci -- src/**/*.hs"
ghcid-doctest:
ghcid -a --command='stack ghci -- src/**/*.hs' --test ':!stack exec doctest -- --verbose -XOverloadedStrings src/'
@alexpeits
alexpeits / LensError.hs
Created June 30, 2019 23:18
Testing error handling with classy prisms
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module LensError where
import Control.Lens
import Control.Monad.Error.Lens
data User
= User
@alexpeits
alexpeits / Configuration.hs
Last active June 11, 2019 17:58
No, I'm not crazy
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
@alexpeits
alexpeits / ArgsToHList.hs
Last active July 1, 2019 08:44
Function arguments to HList (i-am-tom's work)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module ArgsToHList where