Skip to content

Instantly share code, notes, and snippets.

let qemuBinfmtWrapperSource = pkgs.writeTextDir "qemu-binfmt-wrapper.c"
''
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/auxv.h>
int main(int argc,char ** argv) {
int fd = (int) getauxval(AT_EXECFD);
size_t sz = snprintf(NULL, 0, "/proc/self/fd/%d", fd) + 1;
lib: let inherit (lib) extrec; in
{ testSimpleExtrec =
{ expr =
let base = extrec."{"{ x = 123;
y = self: self.x;
}"}";
overrides = extrec."{"{ x = 456;
z = self: self.y;
}"}";
let pkgs = import ./. { system = "riscv64-linux"; }; in
builtins.toFile "ugh" ''
${builtins.unsafeDiscardOutputDependency pkgs.stdenv.drvPath}
''
@shlevy
shlevy / build log
Created February 25, 2018 13:08
miniperl gcc 7 segfault
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/qk6d52igqsnakwa8c8q5jmh16xfmdhpw-perl-5.24.3.tar.gz
source root is perl-5.24.3
unpacking source archive /nix/store/85jfz2bkpmnb1f0dh9zdjkw7lwanqpgr-perl-cross-1.1.8.tar.gz
setting SOURCE_DATE_EPOCH to timestamp 1506110117 of file perl-5.24.3/pod/perldelta.pod
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
applying patch /nix/store/2xihh65mm3hjwd3d6lfrh1r54pnbghzp-no-sys-dirs.patch
patching file Configure
@shlevy
shlevy / fstab
Created February 23, 2018 11:54
# This is a generated file. Do not edit!
#
# To make changes, edit the fileSystems and swapDevices NixOS options
# in your /etc/nixos/configuration.nix file.
# Filesystems.
tmpfs / tmpfs defaults,mode=755 0 0
/dev/disk/by-label/ESP /boot vfat defaults 0 2
/dev/disk/by-label/root /etc-persistent btrfs defaults,subvol=/etc-persistent 0 0
/dev/disk/by-label/root /home-persistent/shlevy btrfs defaults,subvol=/home-persistent/shlevy 0 0
@shlevy
shlevy / README.md
Last active February 21, 2018 19:16
qemu-user binfmt risc-v

Compile qemu-binfmt-wrapper.c with QEMU_RISCV_BINDIR set to the bin directory qemu-riscv is installed in, and name the binary /run/binfmt/riscv64. Then riscv.conf in /etc/binfmt.d on a systemd system will have qemu-user interpret all riscv64 binaries, including respecting setuid bit. On non-systemd you'll need to add the binfmt registration some other way.

#include <thread>
#include <mutex>
#include <iostream>
extern "C" {
#include <poll.h>
#include <unistd.h>
}
std::mutex stdio_mutex;
haskellPackages:
let overrideHaskellPackages = orig:
{ buildHaskellPackages =
orig.buildHaskellPackages.override overrideHaskellPackages;
ghc = orig.ghc.override { deterministicProfiling = true; };
};
in haskellPackages.override overrideHaskellPackages
Require Import Unicode.Utf8.
Require Import Arith.Compare_dec.
Require Vectors.Vector.
Set Implicit Arguments.
Fixpoint pow (n : nat) (e : nat) : nat :=
match e with
| 0 => 1
| S e' => n * pow n e'
@shlevy
shlevy / test.ledger
Created January 1, 2018 20:35
Rounding
;; -*- mode: Ledger; -*-
2018/01/01 Target
Expenses:Food ($2.95 * 19/20)
Expenses:Clothing ($0.40 * 19/20)
; With the following line commented, normal balance report rounds to
; cents and --unround shows 1/4 of a cent left over. With it uncommented,
; balance report rounds to 100ths of a cent
;Income:Red Card Rounding (-$0.0025)
Liabilities:Red Card -$3.18