Skip to content

Instantly share code, notes, and snippets.

View zimbatm's full-sized avatar
🦙
nixified

Jonas Chevalier zimbatm

🦙
nixified
View GitHub Profile
@zimbatm
zimbatm / commit-msg
Last active March 31, 2020 14:43
gerrit commit-msg hook + "Jira: " trailer
#!/bin/sh
# From Gerrit Code Review 3.0.1
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#!/usr/bin/env bash
set -euo pipefail
target_host=root@35.236.126.176
target_port=10022
export NIX_PATH=nixpkgs=/home/zimbatm/go/src/github.com/NixOS/nixpkgs
export NIX_SSHOPTS="-p $target_port"
export TERM=xterm
#!/usr/bin/env bash
i=1
loop() {
echo "iteration $i"
((i++))
sleep 1
echo loop >> "$0"
}
loop
name = "etherbrowser"
packages = [
# generic tooling
"file",
"gitAndTools.git",
"gitAndTools.git-crypt",
"gnugrep",
"goreman",
"reflex",
nix-profile() {
local profile=$PWD/.direnv/nix-profile
mkdir -p .direnv
rm -f "$profile"
nix-build --out-link "$profile" profile.nix
watch_file profile.nix
#source "$profile/etc/profile.d/nix.sh"
load_prefix "$profile"
# Usage: use nix_shell
#
# Works like use_nix, except that it's only rebuilt if the shell.nix or
# default.nix file changes. This avoids scenarios where the nix-channel is
# being updated and all the projects now need to be re-built.
#
# To force the reload the derivation, run `touch shell.nix`
use_nix() {
local shellfile=shell.nix
local wd=$PWD/.direnv/nix
@zimbatm
zimbatm / sources.nix
Last active January 5, 2020 23:04
niv's source.nix but that's loading the flake.lock
# Flake-lock source reader
with builtins;
let
readJSON = f: fromJSON (readFile f);
flakeLock = readJSON ../flake.lock;
fetchers = {
"github" = xxx: narHash:
let
{ lib
, bashInteractive
, buildEnv
, writeText
}:
{ name ? "profile"
, packages ? {}
, env ? {}
, profile ? ""
{ pkgs }@orig:
{ pkgs ? orig.pkgs, rootDir }:
with builtins;
let
mapAttrsMerge = pred: set:
let
mapF = name:
let
v = pred name set.${name};
in
@zimbatm
zimbatm / default.nix
Last active December 20, 2019 21:05
$ alpacasay
{ cowsay, writeScriptBin }:
# When squinting, the alpaca looks a lot like a llama
writeScriptBin "alpacasay" ''
#!/bin/sh -e
${cowsay}/bin/cowsay -f ${./llama.cow} "$@"
''