Skip to content

Instantly share code, notes, and snippets.

View danbst's full-sized avatar

Danylo Hlynskyi danbst

  • Ivano-Frankivsk, Ukraine
View GitHub Profile
{ 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";
};
@danbst
danbst / phabricator.nix
Last active January 19, 2017 14:02 — forked from thoughtpolice/phabricator.nix
Extensive Phabricator module for NixOS (with Nginx frontend support)
# 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";
@danbst
danbst / postgresql-reloadable.nix
Last active February 14, 2017 16:16
A NixOS module, that makes postgresql service reload on configuration change and restart on infrastructure change.
{ 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
@danbst
danbst / README.txt
Last active May 19, 2017 14:34
Munin service ver 2.999.5 (NixOS)
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
@danbst
danbst / silly.nix
Last active May 25, 2017 17:04
A trick to make a package nix-buildable only on NixOS
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";
@danbst
danbst / 0_reuse_code.js
Created August 2, 2017 09:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@danbst
danbst / nixeval.md
Last active November 8, 2017 04:09
Is there simpler way to extract string from Nix string?
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
[             
 {
@danbst
danbst / default.nix
Created March 27, 2018 13:36
Nix + Python + nanomsg
####################################################################################
# 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}