Skip to content

Instantly share code, notes, and snippets.

🌮

Profpatsch

🌮
Block or report user

Report or block Profpatsch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Profpatsch
Profpatsch / spaccetthi.nix
Created Nov 18, 2019
Build purescript packages from spacchetthi definitions
View spaccetthi.nix
{ pkgs ? import ./nixpkgs.nix {} }:
with pkgs.lib;
let
dhallFiles = ../src;
# convert dhall packages set to a nix file
spacchettiNix = pkgs.runCommand "spacchetti.nix" {} ''
${pkgs.dhall-nix}/bin/dhall-to-nix \
View execline-table.dhall
-- TODO: loops, parameter handling, heredocs, string-munging
λ(markdownToHtml : Text Text)
let Prelude =
./imports/Prelude/package.dhall
let el =
λ(bash : Text)
λ(execline : Text)
{ bash = bash, execline = execline, note = None Text }
View readDirRecursive.nix
let
# traverse an item of type T topologically.
# returns a List T
topoTraverse =
# T -> List T -- unfold an item into its next layer
unfoldList:
# T -> Bool -- whether to recurse further on an item
pred:
# T -- the start item
tree:
View sandbox.nix
let
# lightweight sandbox; execute any command in an unshared
# namespace that only has access to /nix and the specified
# directories.
sandbox = { extraMounts ? [] }:
let
pathsToMount = [ "/nix" "/dev" "/proc" "/sys" ];
# chain execlines and exit immediately if one fails
all = builtins.concatMap (c: [ "if" c ]);
mount = "${pkgs.utillinux}/bin/mount";
@Profpatsch
Profpatsch / document-stdlib.sh
Last active Oct 6, 2019
Generate html documentation for the dhall prelude.
View document-stdlib.sh
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p lr -p pandoc
set -euo pipefail
preludeDir="${1:?dir please}"
# each file (except package.dhall) starts with a multiline-comment with markdown docstrings.
# {- maybe docstring
# docstring
View gist:edc4aed14a2df12a633cf6aee4f5536f
bash execline note
a; b foreground { a } b
if a; then; b if { a } b
a && b if { a } b
a || b ifelse { a } { } b {} is wrong, { } is right
a && b || c ifelse { a } { b } c This is if/then/else; ifthenelse is for continuing
after the branches finish
if a; then b else c fi ifelse { a } { b } c
a && b || c; d ifthenelse { a } { b } { c } d
View execlineb.nix
let
execlineb-with-builtins =
let eldir = "${pkgs.execline}/bin";
in pkgs.writeScriptBin "execlineb" ''
#!${eldir}/execlineb -s0
# appends the execlineb bin dir to PATH if not yet in PATH
${eldir}/define eldir ${eldir}
''${eldir}/ifelse
{
# since this is nix, we can grep for the execline drv hash in PATH
View complete.dhall
let BaseCommand = List Text
let Command = λ(arg : Type) { cmd : Text, args : List arg }
let Option = < Long : Text | Short : Text >
let Argument =
< Plain : Text | Flag : Option | Option : { opt : Option, arg : Text } >
let OptionPrinter = (o : Option) Text
@Profpatsch
Profpatsch / sysdeps.nix
Created Aug 15, 2019
Code to generate a sysdeps.h header file from a structured sysdeps file
View sysdeps.nix
{ lib }:
let
example =
{
target = "aarch64-linux-gnu";
endianness = "little";
has = {
clockrt = true;
View nix-realize-in-build.nix
with import <nixpkgs> {};
let nixBin = "${pkgs.nix}/bin"; in
runCommand "foo" {}
''
set -e
datadir="${pkgs.nix}/share"
export TEST_ROOT=$(pwd)/test-tmp
export NIX_BUILD_HOOK=
export NIX_CONF_DIR=$TEST_ROOT/etc
export NIX_DB_DIR=$TEST_ROOT/db
You can’t perform that action at this time.