Skip to content

Instantly share code, notes, and snippets.

View adisbladis's full-sized avatar
:shipit:
^ This guy

adisbladis

:shipit:
^ This guy
View GitHub Profile
@adisbladis
adisbladis / .direnvrc
Created June 6, 2018 09:44
direnvrc nix cache
use_nix() {
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix)
local cache_key=$(nix-instantiate "$shell_file" 2> /dev/null | shasum -a 1 | cut -d ' ' -f 1)
# Use ram as virtualenv storage
local tmpdir
case $(uname -s) in
Linux*) tmpdir=$XDG_RUNTIME_DIR;;
Darwin*) tmpdir_SDK=$TMPDIR;;
*) tmpdir=/tmp
@adisbladis
adisbladis / default.nix
Created September 22, 2018 15:50
An example of how to set up a custom emacs with packages from nixpkgs
with import <nixpkgs> {};
let
# An example of how to get xwidgets rather than gtk
# overridenEmacs = emacs26.override { withXwidgets = true; };
overridenEmacs = emacs26;
emacsPkgs = pkgs.emacsPackagesNgGen overridenEmacs;
emacsWithPackages = emacsPkgs.emacsWithPackages;
in emacsWithPackages(epkgs: with epkgs; [
with import <nixpkgs> { };
let
cutPoints = builtins.map (drv: drv.outPath) [
nodejs
python2
python3
coreutils
openssl.out
glibc
@adisbladis
adisbladis / shell.nix
Created October 28, 2018 21:52
Dirty nixpkgs python
with import <nixpkgs> {};
mkShell {
buildInputs = [
(python3.withPackages(ps: [
ps.nixpkgs
]))
];
}
@adisbladis
adisbladis / nix-path.py
Created April 10, 2019 19:52
Add derivations to PATH at runtime from python
#!/usr/bin/env python
#
# Add binaries to PATH at runtime
import subprocess
import nix
import os
def realise_path(store_path: str):
@adisbladis
adisbladis / defer.py
Last active May 13, 2019 16:46
Go-style defer from python
#!/usr/bin/env python
# The MIT License
# Copyright (c) 2018 Adam Hose (adisbladis)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
{ stdenv, fetchFromGitHub, automake, zlib, libpng, libjpeg
, freetype, libX11, libXext, yacc, flex }:
stdenv.mkDerivation rec {
version = "unstable-2019-05-20";
pname = "microwindows";
src = fetchFromGitHub {
owner = "ghaerr";
repo = "microwindows";
@adisbladis
adisbladis / duplicates.org
Created July 5, 2019 13:57
Find duplicate dependencies in buildGoModule packages in nixpkgs
PackageTimes duplicated
github.com/pmezard/go-difflib23
github.com/davecgh/go-spew21
golang.org/x/text20
github.com/stretchr/testify18
gopkg.in/yaml.v215
github.com/fsnotify/fsnotify12
github.com/inconshreveable/mousetrap12
github.com/pkg/errors12
{ pkgs, ...}:
let
scope = pkgs.newScope {
openssl = pkgs.openssl_1_1;
pkgs = pkgs // { openssl = pkgs.openssl_1_1; };
};
beam = pkgs.beam.override { callPackage = scope; };
in beam.interpreters.erlangR22
@adisbladis
adisbladis / table.org
Last active July 23, 2019 12:27
gemset.nix duplicates
PackageCount
multi_json-1rl0qy4inf1mp8mybfk56dfga0mvx97zwpmq5xmiwl5r770171nv19
thread_safe-0nmhcgq6cgz44srylra07bmaw99f5271l0dpsvl5f75m44l0gmwy17
mini_portile2-15zplpfw3knqifj9bpf604rb3wc1vhq6363pd6lvhayng8wql5vy15
addressable-0bcm2hchn897xjhqj9zzsxf3n9xhddymj4lsclz508f4vw3av46l14
concurrent-ruby-1x07r23s7836cpp5z9yrlbpljcxpax14yw4fy4bnp6crhr6x24an13
tzinfo-1fjx9j327xpkkdlxwmkl3a8wqj7i4l4jwlrv3z13mg95z9wl253z13
nokogiri-02bjydih0j515szfv9mls195cvpyidh6ixm7dwbl3s2sbaxxk5s413