Skip to content

Instantly share code, notes, and snippets.

View corpix's full-sized avatar
👹
Fighting demons

corpix corpix

👹
Fighting demons
View GitHub Profile
@corpix
corpix / luastatic.nix
Created April 24, 2022 13:40
Luastatic nix derivation
{ lua, luaPackages, fetchurl, fetchgit }:
luaPackages.buildLuarocksPackage rec {
pname = "luastatic";
version = "0.0.12";
knownRockspec = (fetchurl {
url = "https://luarocks.org/manifests/ers35/luastatic-${version}-1.rockspec";
sha256 = "sha256-jNxq4gyO+7kN7+Vpvq1iGFrIQ15x+HAkcqa3VqIhUVU=";
}).outPath;
src = fetchgit {
url = "https://github.com/ers35/luastatic";
#lang racket/base
(require setup/dirs
setup/variant
setup/cross-system
racket/promise)
(define plain-variant
(delay/sync
(cond
[(cross-installation?)
@corpix
corpix / Makefile
Last active October 25, 2023 18:25
prepare host for nixos
latest-nixos-minimal-x86_64-linux.iso:
wget https://channels.nixos.org/nixos-20.03/latest-nixos-minimal-x86_64-linux.iso
curl -Ls https://channels.nixos.org/nixos-20.03/latest-nixos-minimal-x86_64-linux.iso.sha256 \
| grep -F .iso | head -n1 \
| sed 's|nixos-minimal-.\+|latest-nixos-minimal-x86_64-linux.iso|' \
| sha256sum -c -
root.img:
qemu-img create root.img 10G
@corpix
corpix / nix-deploy.md
Last active August 11, 2019 12:31
Scripts to deploy NixOS machines without nixops/nix-deploy/etc...

Requirements:

  • root directory is a git repository(for git rev-parse --show-toplevel)
  • github.com/nixos/nixpkgs at pkgs/nixpkgs

Tree:

.
├── .git
@corpix
corpix / cointop.nix
Last active May 4, 2018 19:25
cointop nix derivation
with import <nixpkgs>{};
{ pkgs ? import <nixpkgs> {} }:
buildGo19Package rec {
name = "cointop-unstable-${version}";
version = "development";
src = fetchFromGitHub {
owner = "miguelmota";
repo = "cointop";
#! /usr/bin/env racket
#lang racket
(require racket/cmdline)
(require csv-reading) ;; $ raco pkg install csv-reading
(define (will-loop executor)
(lambda ()
(let loop ()
(will-execute executor)
;; Disable flycheck when on battery
(defun toggle-flycheck ()
(when (fboundp 'battery-status-function)
(let
((battery-status (battery-format "%L" (funcall battery-status-function))))
(cond
((string-match-p "N/A" battery-status) (global-flycheck-mode +1))
((string-match-p "AC" battery-status) (global-flycheck-mode +1))
(t (global-flycheck-mode -1))))))
(run-with-idle-timer 5 1 'toggle-flycheck)
@corpix
corpix / numbers.nix
Last active August 6, 2024 02:02
pow, decimal to hex, hex to decimal in nix language
{ lib }:
with lib; rec {
pow =
let
pow' = base: exponent: value:
# FIXME: It will silently overflow on values > 2**62 :(
# The value will become negative or zero in this case
if exponent == 0
then 1
else if exponent <= 1
@corpix
corpix / ip6.nix
Last active January 28, 2018 01:33
My very naive implementation of IP6 address expansion in nix language
/*
$ nix-instantiate --eval --expr 'with (import <nixpkgs> {}); with lib; builtins.toJSON ((import ./ip6.nix { lib = pkgs.lib; }).expandIP6 "ea5f::")' | jq -r . | jq .
"ea5f:0000:0000:0000:0000:0000:0000:0000"
$ nix-instantiate --eval --expr 'with (import <nixpkgs> {}); with lib; builtins.toJSON ((import ./ip6.nix { lib = pkgs.lib; }).expandIP6 "::ea5f")' | jq -r . | jq .
"0000:0000:0000:0000:0000:0000:0000:ea5f"
$ nix-instantiate --eval --expr 'with (import <nixpkgs> {}); with lib; builtins.toJSON ((import ./ip6.nix { lib = pkgs.lib; }).expandIP6 "ea5f::ff")' | jq -r . | jq .
"ea5f:0000:0000:0000:0000:0000:0000:00ff"
*/
This file has been truncated, but you can view the full file.
Jan 21 21:18:09: ----- cjdns memory snapshot -----
Jan 21 21:18:09: Core.c:338 [157264] bytes
Jan 21 21:18:09: ASynchronizer.c:102 [480] bytes
Jan 21 21:18:09: | UDPAddrIface.c:199 [13000] bytes
Jan 21 21:18:09: | | ASynchronizer.c:104 [64] bytes at [0x55b2f716daf0]
Jan 21 21:18:09: | | ASynchronizer.c:104 [64] bytes at [0x55b2f716daa0]
Jan 21 21:18:09: | | Message.h:86 [88] bytes at [0x55b2f716da40]
Jan 21 21:18:09: | | Message.h:75 [4088] bytes at [0x55b2f716ca40]
Jan 21 21:18:09: | | ASynchronizer.c:104 [64] bytes at [0x55b2f716c9f0]
Jan 21 21:18:09: | | ASynchronizer.c:104 [64] bytes at [0x55b2f716c9a0]