Skip to content

Instantly share code, notes, and snippets.

View Profpatsch's full-sized avatar
🌮

Profpatsch

🌮
View GitHub Profile
{ pkgs }:
{ service-dir }:
let sd = pkgs.lib.escapeShellArg service-dir;
in pkgs.writers.writeDash "service" ''
set -e
CMD=''${1:?please specify command as first argument}
@Profpatsch
Profpatsch / !nix-build-if-changed.py
Last active July 13, 2023 18:35
build a nix expression, but only if it isn’t already available in substituters; skip downloading the results if that is the case.
#!/usr/bin/env python3
# Small wrapper around nix-instantiate and `nix-store --realize`
# that checks whether the output path is already in a cache
# and if it isn’t, builds it.
#
# The arguments you pass will be given to nix-instantiate,
# not to nix-store --realize
# (This might be a TODO for the future).
@Profpatsch
Profpatsch / setup-nix-conf.sh
Created June 7, 2020 13:09
post-build-hooks in nix on circleci
#!/bin/sh
set -eu
# copy post-build-hook script to /etc/nix
cp ./upload-to-cache.sh /etc/nix/
chmod a+x /etc/nix/upload-to-cache.sh
# fetch the secret key used to access the S3 cache bucket from the
# environment, and write to disk (it is used to by the
#[derive(Clone, Debug, PartialEq, Eq,)]
struct Parsed<'a> {
protocol: Protocol,
domain: &'a str,
port: &'a str,
rest: &'a str,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum Protocol {
@Profpatsch
Profpatsch / el_substitute.rs
Last active May 15, 2020 22:46
el_subsitute wrapper
extern crate errno;
extern crate libc;
extern crate ascii;
use std::ffi::{CStr, CString};
use ascii::AsciiStr;
#[repr(C)]
pub struct Stralloc_C {
s: *mut libc::c_char,
{ pkgs }:
let
lib = pkgs.lib;
in
# list of additional packages to add to the packageset
additionalPackages:
# source path of the package (derivation or (filtered) nix path)
assert (lib.all (pkg: pkg ? src) additionalPackages);
# dhall file of that package
@Profpatsch
Profpatsch / release.nix
Last active May 28, 2020 18:37
haskell refactor hydra jobset
attrs:
let
nixpkgs = import "${attrs.nixpkgs}/pkgs/top-level/release.nix" attrs;
in {
inherit (nixpkgs) haskellPackages;
}
@Profpatsch
Profpatsch / pass-shell.nix
Created December 13, 2019 11:04
shell.nix for a pass passwordstore (plus pre-commit hook to prevent leaking unencrypted secrets)
# sets up the environment in a way that adapts pass and git
# to work with the files in this repository instead of
# the global pass store.
let
pkgs = import <nixpkgs> {};
repository-dir = toString ./.;
git-hook-dir =
let
@Profpatsch
Profpatsch / spaccetthi.nix
Created November 18, 2019 17:14
Build purescript packages from spacchetthi definitions
{ 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 \
-- 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 }