function nixeval { eval echo -en "$(nix-instantiate --eval --strict "$@" | sed 's/${/\\${/g')"; }
Evaluate Nix expression and remove quotes from resulting expresssion:
$ nixeval -E 'builtins.toJSON __nixPath' | jq
[
{
{ pkgs, config, ...}: { | |
boot.kernel.sysctl."net.core.rps_sock_flow_entries" = "32768"; | |
networking.usePredictableInterfaceNames = false; # we want eth0 | |
system.activationScripts.network_debloat = { | |
text = '' | |
interface=eth0 | |
${pkgs.iproute}/bin/tc qdisc replace dev "$interface" root fq_codel |
{ pkgs }: | |
let | |
old_iproute = { fetchurl, stdenv, flex, bison, db4, iptables, pkgconfig }: | |
stdenv.mkDerivation rec { | |
name = "iproute2-3.6.0"; | |
src = fetchurl { | |
url = http://kernel.org/pub/linux/utils/net/iproute2/iproute2-3.6.0.tar.xz; | |
sha256 = "0d05av2s7p552yszgj6glz6d74jlmg392s7n74hicgqfl16m85rd"; | |
}; |
# based on https://gist.github.com/thoughtpolice/1faff37f0a17e1ab291d | |
# updated for nixos-16.09 | |
/* | |
Example usage (in configuration.nix): | |
services.phabricator = { | |
enable = true; | |
baseURI = "https://phabricator.example.org"; | |
baseFilesURI = config.services.phabricator.baseURI; | |
rootDir = "/var/phabricator"; |
{ pkgs, lib, config, ...}: | |
let | |
cfg = config.services.postgresql; | |
initConfigScript = '' | |
ln -sf ${pkgs.writeText "pg_hba.conf" cfg.authentication} ${cfg.dataDir}/pg_hba.conf | |
ln -sf ${pkgs.writeText "pg_ident.conf" cfg.identMap} ${cfg.dataDir}/pg_ident.conf | |
ln -sf ${configFile} ${cfg.dataDir}/postgresql.conf |
Munin service ver 2.999.5 | |
Use like | |
``` | |
services.mm.munin-cron.enable = true; | |
services.mm.munin-cron.hosts = '' | |
[server1] | |
address server1 | |
[server2] | |
address server2 |
with import <nixpkgs> {}; | |
with import (stdenv.mkDerivation { | |
name = "trick-to-make-binary-channels-go-away"; | |
buildCommand = '' | |
grep -iq nixos /proc/sys/kernel/version || (echo "Can be built only on NixOS!" && exit 1) | |
echo '{}' > $out | |
''; | |
}); | |
stdenv.mkDerivation { | |
name = "build-only-on-nixos"; |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
function nixeval { eval echo -en "$(nix-instantiate --eval --strict "$@" | sed 's/${/\\${/g')"; }
Evaluate Nix expression and remove quotes from resulting expresssion:
$ nixeval -E 'builtins.toJSON __nixPath' | jq
[
{
#################################################################################### | |
# Nix shell for nix-powered environments | |
# This is like `virtualenv`, but with fine-defined system dependencies | |
#################################################################################### | |
rec { | |
nanomsg-py = pythonPackages.buildPythonPackage { | |
name = "nanomsg-1.0"; | |
src = pkgs.fetchurl { url = "https://pypi.python.org/packages/0b/b1/3037e0e380d5fab2824e69a59bd374da402c0cef264ccb3fe5d71c230c4b/nanomsg-1.0.tar.gz"; sha256 = "843be41258219d9d319cf434a68cac7669834ab9c993ea4bab5b3d87f62a7a13"; }; | |
doCheck = false; | |
buildInputs = [ pkgs.nanomsg ]; |
#!/usr/bin/env nix-shell | |
#!nix-shell -i bash -p gitMinimal nix-prefetch-git jq | |
set -e | |
project="$1" | |
branch="${2:-master}" | |
owner=$(echo "$project" | cut -d/ -f1) | |
repo=$(echo "$project" | cut -d/ -f2) | |
rev=$(git ls-remote "git://github.com/$project.git" "$branch" | head -n1 | awk '{print $1}') | |
rev=${rev:-$2} |