Skip to content

Instantly share code, notes, and snippets.

View danbst's full-sized avatar

Danylo Hlynskyi danbst

  • Ivano-Frankivsk, Ukraine
View GitHub Profile
@danbst
danbst / onsub.py
Created May 24, 2016 13:17
Mercurial 3.8+ compatible onsub extension
# onsub.py - execute commands recursively on subrepositories
#
# Copyright 2010, 2011 aragost Trifork
#
# This software may be used and distributed according to the terms of
# the GNU General Public License version 2 or any later version.
import os
from mercurial.i18n import _
from mercurial import extensions, subrepo, util, cmdutil
@danbst
danbst / 4ct-proof.nix
Created August 1, 2016 06:11
WIP reproduce the Four Color Theorem proof by Gonthier
#! /usr/bin/env nix-build
{ pkgs ? import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/2fa9bd50597c3089cc00abb3f20d7510fcc8ad6a.tar.gz) { }
}:
let
inherit (pkgs) stdenv lib;
theoremDistrib = pkgs.fetchurl {
url = https://download.microsoft.com/download/D/1/D/D1D6FCF9-4D04-49FE-9952-0D295B180CF4/4ct.msi;
sha256 = null;
};
theoremSrc = stdenv.mkDerivation {
{ 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 / example.nix
Created April 8, 2017 07:07
Extending NixOS submodules
# this example adds an option `.tomcatProxy` in namespace
# services.nginx.virtualHosts.*.locations.*
# that acts as alternative to specifying actual nginx config in .extraConfig
#
# execute with
/*
cat $(grep -o "/nix/store/[a-z0-9]*-nginx.conf" \
$(NIX_PATH=nixos-config=./example.nix:$NIX_PATH \
nix-build --no-out-link -E '
with import <nixpkgs/nixos> {};
@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";

Switching NixOS architecture (32bit -> 64bit)

There are rumors, that you can switch from system architecture just adding 1 configuration option:

nixpkgs.system = "x86_64-linux"

and running nixos-rebuild boot && reboot.