Skip to content

Instantly share code, notes, and snippets.

@shlevy
shlevy / gist:4505293
Created January 10, 2013 20:00
filterSource with import-from-derivation
$ cat test.nix
builtins.filterSource (path: type:
import ((import <nixpkgs> {}).writeTextFile { name = "true.nix"; text = "true"; }).outPath
) ./.
$ nix-instantiate test.nix
error: bad archive: unknown field
(use `--show-trace' to show detailed location information)
@shlevy
shlevy / __init__.py
Created December 17, 2012 18:44
_multiprocess_can_split_, but doesn't
_multiprocess_can_split_ = True
val = 1
def setup():
global val
val = 2
def teardown():
global val
@shlevy
shlevy / dont set path
Created July 19, 2012 13:57
PYTHONPATH vs addsitedir
# /nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/bin/python webcharon.wsgi
['/root', '/nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/lib/python27.zip', '/nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/lib/python2.7', '/nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/lib/python2.7/plat-linux2', '/nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/lib/python2.7/lib-tk', '/nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/lib/python2.7/lib-old', '/nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/lib/python2.7/lib-dynload', '/nix/store/5qmz5wc596kl7rywx56phyl2gb0052w7-python-2.7.3/lib/python2.7/site-packages', '/nix/store/n67kdkin76lcswjfv267sig3rp5iyl1f-webcharon-0/lib/python-2.7/site-packages']
@shlevy
shlevy / gist:3104735
Created July 13, 2012 12:50
logstash config
services.logstash = {
enable = true;
inputConfig = config.lib.logstash.mkNameValuePairs [
{
file = {
type = "syslog";
path = "/var/log/messages";
};
}
@shlevy
shlevy / gist:3091479
Created July 11, 2012 16:11
logstash nixos example
services.logstash = {
enable = true;
inputConfig = {
__type = "repeated";
values = [
{ name = "file"; value = {
type = "syslog";
path = [
"/var/log/messages"
@shlevy
shlevy / gist:2644261
Created May 9, 2012 12:47 — forked from patrickt/gist:2644080
EVERYONE ON TWITTER ONLY LIVES ONCE #yolo
javascript:(function(){$(".twitter-hashtag").html("#yolo");$(".js-tweet-text").each(function(idx){ v = $(this).text(); v = v.replace('Thanks', 'Thanks, OBAMA!!!'); $(this).text(v);})}())
@shlevy
shlevy / gist:2393408
Created April 15, 2012 15:23
UEFI NixOS on P8H67-M PRO
1. Download the latest 64-bit EFI-compatible ISO from http://hydra.nixos.org/job/nixos/trunk/iso_efi
2. Boot the cd in EFI mode. Enter into your UEFI menu, go to the boot options menu, and select your CD drive (Make sure you select the one that says EFI or UEFI boot! If a grub menu shows up you have not succeeded).
3. Use the 'gdisk' program to partition your drive. The interface is very similar to fdisk. Make sure you create one partition of type ef00 (EFI System Partition). This will be your /boot.
4. Format your partitions. Make the EFI System Partition a vfat volume.
5. Mount your partitions per the manual. Mount the EFI System Partition on /mnt/boot.
6. Follow the manual up to the stage of filling out your configuration.nix. The EFI specific portions of your config should be very similar to lines 31-43 of https://bitbucket.org/shlevy/dotfiles/src/11376b30c57e/nixos/p8p67-configuration.nix#cl-31 . See man configuration.nix, particularly the efiBootStub options, for more. Note that it is important to disab
@shlevy
shlevy / expression
Created March 23, 2012 15:10
'with' infinite recursion
let
a = with b; { c = 2; d = c; };
b = a // { c = 3; };
in b.d
let
a = { c = 2; d = b.c; };
b = a // { c = 3; };
in b.d
@shlevy
shlevy / gist:1876692
Created February 21, 2012 13:58
Strangeness with packageOverrides

$ cat ~/.nixpkgs/config.nix

{
  packageOverrides = pkgs: {
    testEnv = pkgs.buildEnv {
      name = "test";
      paths = [];
    };
  };

}

@shlevy
shlevy / gist:1832527
Created February 15, 2012 02:07
Run init() at start
if (document.readyState === "complete") {
init();
} else {
document.addEventListener("load", { handleEvent: init });
}