This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
pkgs.mkShell rec { | |
packages = with pkgs; [ delve go gopls go-outline go-tools libkrb5.dev ]; | |
WORKSPACE_ROOT = toString ./.; | |
# VSCode's Go plugin doesn't play well with nix shells, so we create a custom directory for all our tools and tell the plugin to use it. | |
shellHook = '' | |
initNixShell() { | |
echo Initializing Nix shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::str::FromStr; | |
#[derive(Debug, Clone, PartialEq, Eq)] | |
enum Error { | |
PositionalArgExpected(String), | |
FlagExpectedValue(String), | |
ConversionFailed(String), | |
} | |
/// A trait for types that can represent a command-line argument or flag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Various functions for working with containers of any kind. | |
#pragma once | |
#include <boost/optional.hpp> | |
#include <vector> | |
// -------- Advanced C++ Trickery ---------------- | |
// From https://stackoverflow.com/a/7943765/503377 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T, typename Container = std::vector<T>> | |
struct NonEmpty { | |
using iterator = typename Container::iterator; | |
using const_iterator = typename Container::const_iterator; | |
iterator begin() | |
{ | |
return c_.begin(); | |
} | |
iterator end() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <math.h> | |
struct RTK{}; | |
struct Barometer{}; | |
struct Meters{}; | |
template<typename Repr, typename Self> | |
struct UnitWrapped { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Install Windows 10 but leave a chunk of your drive unpartitioned | |
# 2. Within Windows create a new partition for your NixOS install | |
# 3. Create an installation disk/USB for NixOS | |
# 4. Boot into NixOS graphical installer | |
# 5. Open GParted so you can make sure you've selected the right drives (ls -lah /dev/disk/by-id/... will tell you what drive the path is symlinked to) | |
# 6. Run the following! | |
TARGET_DISK="/dev/disk/by-id/nvme-Force_MP600_20468229000128554A4B-part5" | |
sudo zpool create -o ashift=12 -O acltype=posixacl -O compression=lz4 -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa -O mountpoint=none zroot "$TARGET_DISK" | |
sudo zfs create -o encryption=aes-256-gcm -o keyformat=passphrase -o mountpoint=none zroot/crypt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.10 | |
RUN apt-get update && \ | |
apt-get install -y sudo curl xz-utils && apt-get clean && \ | |
useradd builder -d /home/builder && \ | |
mkdir /home/builder && chown builder /home/builder && \ | |
echo "builder ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \ | |
chmod 0440 /etc/sudoers.d/user && \ | |
(su builder --login -c 'curl -L https://nixos.org/nix/install | sh') && \ | |
apt-get remove -y curl xz-utils && apt-get autoremove -y && apt-get clean && \ | |
echo '. /home/builder/.nix-profile/etc/profile.d/nix.sh' >> /home/builder/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListView(): | |
def __init__(self, items, slice_=None): | |
start = (slice_.start if slice_ else None) or 0 | |
stop = (slice_.stop if slice_ else None) or float('inf') | |
step = (slice_.step if slice_ else None) or 1 | |
if isinstance(items, ListView): | |
self._items = items._items | |
self._start = max(items._start, items._start + start) | |
self._stop = min(items._stop, items._start + stop) | |
self._step = items._step * step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ lib }: rec { | |
isValidDrvNameChar = c: "a" <= c && c <= "z" || "A" <= c && c <= "Z" || "0" <= c && c <= "9" || c == "+" || c == "-" || c == "_" || c == "?" || c == "=" || c == "."; | |
makeValidDrvName = { str, replacement ? "?" }: | |
let | |
newName = lib.stringAsChars (c: if isValidDrvNameChar c then c else replacement) str; | |
in if builtins.substring 0 1 newName == "." then "_" + newName else newName; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import (builtins.fetchTarball { | |
url = https://releases.nixos.org/nixpkgs/nixpkgs-20.09pre229671.9d0c3ffe678/nixexprs.tar.xz; | |
sha256 = "0apkg6kamf15v32j2kddrl8mf0l79frczrn5nlbab76dv9gdq008"; | |
}) {} | |
}: | |
let | |
githubData = { | |
owner = "MaterializeInc"; | |
repo = "materialize"; | |
rev = "39faa05714a6e78e8d9e8b518cd39f94e9201e5a"; |
NewerOlder