Skip to content

Instantly share code, notes, and snippets.

View moretea's full-sized avatar

Maarten Hoogendoorn moretea

View GitHub Profile
module Fin
-- Defined Vect and Fin datastructures as described in
-- "idris, a general purpose dependently typed programming language:
-- design and implementation"
data Vect: Nat -> Type -> Type where
Nil : Vect Z a
(::) : a -> Vect k a -> Vect (S k) a
data Fin : Nat -> Type where
fZ : Fin (S k)
@moretea
moretea / _readme.md
Last active March 28, 2017 12:11
Habitat demo

How to demo hab on k8s.

  1. Start the ui (see script), open UI window
  2. Download the reset.sh and run it
  3. get the url for the guestbook, open UI window
  4. Show off resiliance by killing pods in the UI, after 5 kills the quorum is lost See this gist for details why
  5. When it inevitably loses quorum, run reset.sh again.
@moretea
moretea / shell.nix
Created January 31, 2017 23:10
Rust development environment
with import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/a211c1752ce3f6b017edefda49c1c8102a7ce812.tar.gz") {};
{
env = stdenv.mkDerivation {
name = "env";
buildInputs = with pkgs; [rustcNightlyBin.rustc cargo];
};
}
#!/usr/bin/env ruby
# (C) 2017 Maarten Hoogendoorn <[email protected]>
# Released under the GPL3.0
#
# This script finds the runtime closure of programs, and tries to find the correct license for it.
# Given that the mapping of store paths -> nix expressions does not exist, it guesses the package
# name and aborts if this guess is wrong.
require "json"
with (import <nixpkgs> {});
with pkgs.lib;
let
getLicense = meta:
if !(meta ? license) then
"not specified"
else
if (meta.license ? fullName)
then meta.license.fullName
else
with (import <nixpkgs> {});
let
v_old_1 = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/archive/${sha1}.tar.gz) {}.;
v_old_2 = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/archive/${sha1}.tar.gz) {}.;
v_old_3 = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/archive/${sha1}.tar.gz) {}.;
in
{
myPackage = stdenv.mkDerivation rec {
name = "different-editor-versions";
buildInputs = [v_old1.emacs v_old2.vi];
let
myGenerator = stdenv.mkDerivation {
name ="yadda";
phases ="meh";
meh = ''
mkdir $out
generateSomeNix > $out/generated.nix
'';
};
in
@moretea
moretea / all-packages-of-a-maintainer.nix
Last active February 23, 2017 09:17
List all packages filtered by some maintainer
#usage:
# nix-instantiate --arg maintainer "\"Matthias Beyer <[email protected]>\"" --strict --json --eval ./all-packages-of-a-maintainer.nix | $(nix-build '<nixpkgs>' -A jq)/bin/jq
with (import <nixpkgs> {});
with lib;
{ maintainer }:
let
filter = k: v:
let
{ stdenv, callPackage, which, lessc, nodejs}:
let
jsPackage = (callPackage ./js {}).package;
desktopPackage = (callPackage ./desktop {}).package;
in rec {
# turtle = stdenv.mkDerivation {
# name = "turtle-desktop";
# buildInputs = [ nodejs which lessc jsPackage];
# src = "${jsPackage}/lib/node_modules/turtl-js";
[maarten@maarten-laptop:~]$ nix-repl
Welcome to Nix version 1.11.4. Type :? for help.
nix-repl> hostname = "aaa"
nix-repl> hostname == "aaa"
true
nix-repl>