Skip to content

Instantly share code, notes, and snippets.

;; Copyright (c) 2019 Vertiv, Inc.
(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]))
(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]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
<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>
;; 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
(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) [])
(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]
{ 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";
{ 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";
(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?
{ 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";