Skip to content

Instantly share code, notes, and snippets.

{ config, lib, pkgs, ... }:
with lib;
let
cfg = attrByPath [ "services" "local-modules" "nix-darwin" "keyboard" ] { } config;
globalKeyMappings = { }
// (if cfg.remapCapsLockToControl then { "Keyboard Caps Lock" = "Keyboard Left Control"; } else { })
// (if cfg.remapCapsLockToEscape then { "Keyboard Caps Lock" = "Keyboard Escape"; } else { })
// (if cfg.nonUS.remapTilde then { "Keyboard Non-US # and ~" = "Keyboard Grave Accent and Tilde"; } else { });
@eqyiel
eqyiel / nixos-encrypted-zfs.sh
Created May 4, 2020 01:15 — forked from dysinger/nixos-encrypted-zfs.sh
How I installed Encrypted ZFS root on NixOS
#!/bin/sh
# FIRST STOP THE zfs-zed SERVICE
systemctl stop zfs-zed
# FORCE UNLOAD ZFS KERNEL MODULES
lsmod | grep zfs | cut -d' ' -f1 | xargs rmmod -f
# NOW ADD THE FOLLOWING TO /etc/nixos/configuration.nix
#
@eqyiel
eqyiel / nix-serve.md
Last active October 8, 2021 00:28
How to use nix-serve with an alternative store location

This is something you might want to do if you have an existing store directory on another dataset but don't want to overlay mount it onto /nix/store.

~/shell.nix is

{
  pkgs ? import <nixpkgs> {
    overlays = [
      (self: super: {
        nix = super.nix.override {
@eqyiel
eqyiel / Use Yubikey (GPG key) for SSH.md
Created August 2, 2020 11:49 — forked from jacquesbh/Use Yubikey (GPG key) for SSH.md
Use my Yubikey with GPG keys to SSH with a guest computer (OSX or Windows)
@eqyiel
eqyiel / apache-json-log-format
Created May 4, 2020 03:26 — forked from vmadman/apache-json-log-format
An apache log format that allow access logs (but not error logs) to be output in JSON format. I found this here: http://untergeek.com/2012/10/11/getting-apache-to-output-json-for-logstash/ -- but modified it for my purposes a good bit.
# Access Logs
LogFormat "{ \
\"@vips\":[\"%v\"], \
\"@source\":\"%v%U%q\", \
\"@source_host\": \"%v\", \
\"@source_path\": \"%f\", \
\"@tags\":[\"Apache\",\"Access\"], \
\"@message\": \"%h %l %u %t \\\"%r\\\" %>s %b\", \
\"@fields\": { \
\"timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \
#!/usr/bin/env jq --raw-output --from-file --stream
. as $in
| select(length > 1)
| (
.[0] | map(
if type == "number"
then "[" + @json + "]"
else "." + .
end
@eqyiel
eqyiel / configure.sh
Created February 22, 2018 23:20 — forked from LnL7/configure.sh
darwin nix-daemon distributed builds
#!/usr/bin/env bash
sudo mkdir -p /run/nix/current-load
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo curl -fsSL -o /Library/LaunchDaemons/org.nixos.nix-daemon.plist https://gist.github.com/LnL7/ba2eac19e77cd6b4bb02c8de03bf5f4e/raw/69722c2b13c4eb022a1312cd6891838b413e1f96/org.nixos.nix-daemon.plist
sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
# Configure /etc/nix/machines
# Make sure root can ssh to the builder (known_hosts etc.)
@eqyiel
eqyiel / readme.md
Created December 11, 2017 04:58 — forked from IOAyman/readme.md
Use yarn with Greenkeeper

Use yarn with Greenkeeper

When using yarn, it will create a yarn.lock lockfile which holds data on your used dependencies. This file also includes hard-typed versions, so should you update your dependencies, the yarn.lock file is basically outdated and needs to be regenerated. While yarn does this automatically, Greenkeeper pull requests that update dependencies as of right now do not do this regeneration, which means you would have to do it manually.

This gist shows you a way how to automatise this step using a Travis CI script.

Prerequisites

  • You use Travis CI and have it build Pull Requests (default behaviour)
  • You have a yarn.lock file in your repository for Travis CI to automatically install yarn (yarn will be added to their default images soon)

Getting started

@eqyiel
eqyiel / webpack.config.js
Last active November 3, 2017 02:21
How to monkeypatch webpack-dev-server ^2.9.3 for use with react-devtools
/**
* webpack.config.js
*/
const webpack = require('webpack');
const path = require('path');
const { stripIndent } = require('common-tags');
module.exports = (env, { p: production }) => ({
...{
nix-repl> mkVal = with lib; let mkIndent = depth: concatStrings (builtins.genList (_: " ") (2 * depth)); in { value, depth ? 0 }: if (value == true) then "true"
else if (value == false) then "false"
else if (isInt value) then (toString value)
else if (isList value) then concatMapStringsSep " " mkVal { inherit value depth; }
else if (isAttrs value) then
(concatStringsSep "\n${mkIndent (depth + 1)}"
([ "{" ] ++ (mapAttrsToList
(attrName: attrValue: "${attrName} = ${mkVal { value = attrValue; depth = depth + 1; }}")
value) ++ [ "\n${mkIndent depth}}\n" ]))