Skip to content

Instantly share code, notes, and snippets.

View ryantrinkle's full-sized avatar

Ryan Trinkle ryantrinkle

View GitHub Profile
let # invert is O(n^2); it's not obvious to me that we can do much better without a lot of work
# invert :: Map a [b] -> Map b [a]
invert = m:
let allBs = builtins.concatLists (builtins.attrValues m);
exploded = builtins.concatMap (a: map (b: { ${b} = a; }) m.${a}) (builtins.attrNames m);
in builtins.listToAttrs (map (b: { name = b; value = builtins.catAttrs b exploded; }) allBs);
# Given a package that installs .desktop files in the usual location,
# return a mapping from mime types to lists of desktop file names.
# This is suitable for use in home-manager's
# xdg.mimeApps.defaultApplications.
{ runCommand, patchelf, coreutils, binutils-unwrapped, find-libs }:
targetPrefix: inputPackage:
runCommand (inputPackage.pname + "-portable") {
inherit inputPackage targetPrefix;
} ''
set -euo pipefail
cp -a "$inputPackage" "$out"
$ gcc acltest.c && sudo strace -f ./a.out
execve("./a.out", ["./a.out"], 0x7ffe03614de8 /* 17 vars */) = 0
brk(NULL) = 0x1189000
access("/etc/ld-nix.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/n0axl4pks91d841aivjqm3m0gmdj3f2h-shell/lib64/tls/x86_64/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/nix/store/n0axl4pks91d841aivjqm3m0gmdj3f2h-shell/lib64/tls/x86_64/x86_64", 0x7fffea8d7150) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/n0axl4pks91d841aivjqm3m0gmdj3f2h-shell/lib64/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/nix/store/n0axl4pks91d841aivjqm3m0gmdj3f2h-shell/lib64/tls/x86_64", 0x7fffea8d7150) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/n0axl4pks91d841aivjqm3m0gmdj3f2h-shell/lib64/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/nix/store/n0axl4pks91d841aivjq
unpacking sources
unpacking source archive /nix/store/c36x4l6a4raqxc9krkf3nbrv4kwfxk3h-source
source root is source
patching sources
applying patch /nix/store/bn2glwzfc4dwdqzbdsyd9jawn9f694vr-1230afb211f85e0cdf5fb10c9becf318cd626d88...nixos-zfs-2018-08-13.patch
patching file .github/PULL_REQUEST_TEMPLATE.md
patching file cmd/zdb/zdb.c
patching file cmd/zed/agents/zfs_mod.c
patching file cmd/zpool/zpool_main.c
patching file cmd/ztest/ztest.c
{ config, lib, pkgs, ... }:
#TODO: Hairpinning
#TODO: WiFi AP
# - NAT
# - DHCP
with lib;
let externalInterface = "enp1s0";
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecursiveDo #-}
import Control.Monad (ap)
import Control.Monad.Trans (lift)
import Data.Semigroup (First (..))
import Data.Text (Text)
import qualified Data.Text as T
import Reflex.Dom
newtype MonoidalWidget t m e = MonoidalWidget { unMonoidalWidget :: EventWriterT t (First e) m () }
{ stdenv, fetchurl, cups, dpkg, ghostscript, patchelf, a2ps, coreutils, gnused, gawk, file }:
let version = "1.1.2-1";
printerName = "hl3170cdw";
lprDownloadId = "007056";
cupswrapperDownloadId = "007058";
in stdenv.mkDerivation rec {
name = "${printerName}-cupswrapper-${version}";
inherit version;
srcs =
networking.nat = {
enable = true;
internalInterfaces = ["ve-+"];
externalInterface = "enp6s0";
forwardPorts = [
{ sourcePort = 3000; destination = "192.168.100.2:3000"; }
];
};
containers = {
import Reflex.Dom
main = mainWidget $ do
bChangeWidget <- button "changeWidget"
el "div" $ widgetHold (text "placeholder") $ fmap (\_ -> text "changed") bChangeWidget
return ()
@ryantrinkle
ryantrinkle / Sample.hs
Last active October 7, 2015 21:37 — forked from et4te/Sample.hs
Here the updated baseImgD in templateRenderCanvas will not fire
templateRenderCanvas qrcInfoD cnvInfo newBaseImage initialBaseImage = do
cnvRef <- liftIO $ mkCanvas' cnvInfo
qrcInfo <- sample $ current qrcInfoD
imgRef <- liftIO $ canvasDisplay cnvRef imgInfo
qrcRef <- liftIO $ canvasDisplay cnvRef qrcInfo
liftIO $ canvasAddChild cnvRef imgRef
liftIO $ imageAddChild imgRef qrcRef
return ()