Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Whitt WhittlesJr

View GitHub Profile
@WhittlesJr
WhittlesJr / Readme.md
Last active Aug 24, 2018 — forked from techhazard/Readme.md
NixOS: PCI Passthrough
View Readme.md

PCI Passthrough

Warning: unfinished (but successfull!)

I did PCI passthrough on Archlinux and Debian with the old PCI-stub method (this was pre-4.0 era). And later I did PCI passthrough on the 4.1+ kernels on Arch and Ubuntu (16.10 I think?).

This is my attempt at doing the same on Nixos.

Requirements

View custom-alarm.nix
{ stdenv, fetchFromGitHub }:
with stdenv.lib;
stdenv.mkDerivation rec {
name = "hass-custom-alarm-${version}";
version = "1.3.1";
src = fetchFromGitHub {
owner = "gazoscalvertos";
repo = "Hass-Custom-Alarm";
View complex-rule-codec-example.clj
(def npdu
(util-b/complex-rule-codec
:version :ubyte
:control-octet (util-b/complex-bytes
:ubyte [{:bits 1
:name :layer
:enum-map {:network 1
:apdu 0}}
nil ;;reserved
:dest-present?
View custom-alarm.nix
{ stdenv, fetchFromGitHub }:
with stdenv.lib;
stdenv.mkDerivation rec {
name = "hass-custom-alarm-${version}";
version = "1.3.1";
src = fetchFromGitHub {
owner = "gazoscalvertos";
repo = "Hass-Custom-Alarm";
View custom-alarm.nix
{ stdenv, fetchFromGitHub }:
with stdenv.lib;
stdenv.mkDerivation rec {
name = "hass-custom-alarm-${version}";
version = "1.3.1";
src = fetchFromGitHub {
owner = "gazoscalvertos";
repo = "Hass-Custom-Alarm";
View hara.data.clj
(defn reduce-kvs [rf init kvs]
(reduce (fn [acc [k v]] (rf acc k v)) init (partition-all 2 kvs)))
(defn assoc-if
"Assoc each kv if (pred value) is true
(assoc-if odd? {:a 1} :b 2 :c 3)
=> {:a 1 :c 3}"
([pred m k v ] (if (pred v) (assoc m k v) (or m {})))
([pred m k v & kvs]
View binary_util.clj
(ns clj-bacnet.binary-util
(:require [org.clojars.smee.binary.core :as binary]
[com.rpl.specter :refer :all])
(:import org.clojars.smee.binary.core.BinaryIO))
(defn hexify "Convert byte sequence to hex string"
[coll-or-num]
(let [coll (cond (coll? coll-or-num) coll-or-num
(number? coll-or-num) [coll-or-num]
(nil? coll-or-num) [])
View build-hosts.clj
;; My IP address data is shaped like this:
(def data {"host-a" {:ip "1.1.1.1"}
"host-b" {:ip "2.2.2.2"}
"container" {"host-c" {:ip "3.3.3.3"}
"host-d" {:ip "4.4.4.4"}}})
;; This logic turns that data into a map ("set" in nix) that would work for `networking.hosts`:
(defn build-hosts [ip-data & [name-prefix]]
(reduce-kv (fn [result hostname {:keys [ip] :as info}]
(let [full-hostname (if name-prefix
View settings.xml
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>my-mirror</id>
<mirrorOf>*</mirrorOf>
<url>http://my-mirror/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
View header.clj
(ns clj-bacnet.application.prefix.header
(:require [clj-binary.codec.complex-bytes :as cb]
[clj-binary.core :as bin]
[clojure.spec.alpha :as s]
[orchestra.core :refer [defn-spec]]
[org.clojars.smee.binary.core :as sb]
[spec-coerce.core :as coerce]
[vertiv-common.spec :as vs]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
You can’t perform that action at this time.