Skip to content

Instantly share code, notes, and snippets.

View bennofs's full-sized avatar
🎯
Focusing

Benno Fünfstück bennofs

🎯
Focusing
View GitHub Profile
@bennofs
bennofs / default.nix
Created August 26, 2014 10:04
create file in nix store in builder
with (import <nixpkgs> {});
derivation {
name = "b";
builder = "${bash}/bin/bash";
args = ["-c" "echo 3 > /nix/store/foo; read foo < /nix/store/foo; echo $foo > $out"];
system = "${builtins.currentSystem}";
}
{-# LANGUAGE OverloadedStrings #-}
module Downloader where
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C8
import Data.Conduit
import qualified Data.Conduit.Binary as CB
@bennofs
bennofs / default.nix
Last active August 29, 2015 14:10 — forked from JLimperg/default.nix
# This file was auto-generated by cabal2nix. Please do NOT edit manually!
{ cabal, convertible, exceptions, HDBC, HDBCSqlite3, monadHdbc, mtl
, options, text, time, transformers
}:
cabal.mkDerivation (self: {
pname = "scrumgr";
version = "0.1.0.0";
src = ./.;
@bennofs
bennofs / Compiling
Last active August 29, 2015 14:15
Concurrency and the FFI
$ gcc -c -o cbit.o cbit.c
$ ghc -threaded --make ffi.hs cbit.o -rtsopts
@bennofs
bennofs / ghc-mod-github.nix
Created April 26, 2015 12:45
Overriding with haskell-ng
{}: # nix-env expects a function
let
# Get nixpkgs (in configuration.nix, use pkgs for this, but this file is standalone
# to test it easier so we have to manually import nixpkgs)
pkgs = import <nixpkgs> {};
# First, get the haskell packages from nixpkgs. In configuration.nix, you
# can use pkgs.haskellngPackages for this of course.
haskellngPackages = pkgs.haskellngPackages;
@bennofs
bennofs / shell.nix
Last active August 29, 2015 14:20
HaskellNG: override hakyll without patch
let
nixpkgs = import <nixpkgs> {};
haskellNg = nixpkgs.pkgs.haskell-ng;
# hopefully temporary, but ghc 7.8 fails because of non-deterministic builds (of GHC)
ghc710 = haskellNg.packages.ghc7101;
fixedHakyll = ghc710.hakyll.override { inherit (ghc710) mkDerivation; };
pkg = ghc710.callPackage ./. {
hakyll = fixedHakyll;
};
in nixpkgs.lib.overrideDerivation pkg.env (old:{
@bennofs
bennofs / example.cpp
Created August 6, 2015 17:33
Extract template from type
struct SampleData {
Container<float> totalradiance;
Container<int> lightcutSize;
template <class T>
struct decl_sampledata_from_container {};
template <template <class, class...> class C, class T>
struct decl_sampledata_from_container<C<T>> {
typedef SampleData<C> type;
@bennofs
bennofs / main.cpp
Created August 12, 2015 10:46
Qt QML context object garbage collected
#include <QQmlEngine>
#include <QObject>
#include <QGuiApplication>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQuickWindow>
#include <QDebug>
class App : public QObject
{
$ nix-instantiate haskell-rethinkdb.nix --indirect --add-root $PWD/shell.drv --show-trace
@bennofs
bennofs / default.nix
Created August 19, 2015 17:23
Use this as a default.nix in the root servant folder to aggregate all dependencies
# This is a function: we take `haskellPackages` as an argument so that it can be overriden,
# but supply `nixpkgs.haskellPackages` as a default value if no value is explictly given.
{ haskellPackages ? (import <nixpkgs> {}).haskellPackages }:
let
# Build our own haskell package set with all the packages added that we want
myHaskellPackages = haskellPackages.override {
# super refers to the "previous" haskell package set (the one we extend)
# self refers to the final haskell package set, after our customizations have been