summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2019-02-26 08:58:51 +0100
committermakefu <github@syntax-fehler.de>2019-02-26 08:58:51 +0100
commite437c7d17b4accf9c18d2aa17a0ec98a171d8f3f (patch)
treebbb65961d3eaaa7f14461383290db99f391bb6cb /krebs
parent6da32a5952faf38c92c7b289cc6ae0881ec4aa36 (diff)
parent2db5d56cf2e252822f38900ef9436d7b118476a9 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'krebs')
-rw-r--r--krebs/3modules/default.nix2
-rw-r--r--krebs/3modules/hosts.nix61
-rw-r--r--krebs/3modules/retiolum-hosts.nix28
-rw-r--r--krebs/5pkgs/haskell/blessings.nix9
-rw-r--r--krebs/5pkgs/haskell/flameshot-once.nix21
-rw-r--r--krebs/5pkgs/simple/flameshot-once/default.nix27
-rw-r--r--krebs/5pkgs/simple/flameshot-once/profile.nix129
-rw-r--r--krebs/nixpkgs.json6
8 files changed, 246 insertions, 37 deletions
diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix
index 9303a81f..9c2f53cb 100644
--- a/krebs/3modules/default.nix
+++ b/krebs/3modules/default.nix
@@ -45,7 +45,6 @@ let
./reaktor2.nix
./realwallpaper.nix
./retiolum-bootstrap.nix
- ./retiolum-hosts.nix
./rtorrent.nix
./secret.nix
./setuid.nix
@@ -101,6 +100,7 @@ let
{ krebs = import ./krebs { inherit config; }; }
{ krebs = import ./lass { inherit config; }; }
{ krebs = import ./makefu { inherit config; }; }
+ { krebs = import ./external/palo.nix { inherit config; }; }
{ krebs = import ./tv { inherit config; }; }
{
krebs.dns.providers = {
diff --git a/krebs/3modules/hosts.nix b/krebs/3modules/hosts.nix
index 0985bb53..7fe01a76 100644
--- a/krebs/3modules/hosts.nix
+++ b/krebs/3modules/hosts.nix
@@ -1,6 +1,5 @@
with import <stockholm/lib>;
{ config, ... }: let
- # TODO dedup functions with ./retiolum-hosts.nix
check = hostname: any (domain: hasSuffix ".${domain}" hostname) domains;
domains = attrNames (filterAttrs (_: eq "hosts") config.krebs.dns.providers);
in {
@@ -30,6 +29,66 @@ in {
map (addr: { ${addr} = aliases; }) net.addrs)
(attrValues host.nets))
(attrValues config.krebs.hosts)));
+
+ nixpkgs.config.packageOverrides = super: let
+ # nameValuePair name value : { "name" : name, "value" : value }
+
+ # addr : str
+ # aliase : str
+ # hostname : str
+ # netname : str
+
+ # addrAliases : nameValuePair addr [alias]
+
+ # hostNetAliases : host -> { ${netname} : [addrAliases] }
+ hostNetAliases = host:
+ mapAttrs (_: net: filter (x: x.name != null && x.value != []) [
+ { name = net.ip4.addr or null; value = net.aliases; }
+ { name = net.ip6.addr or null; value = net.aliases; }
+ ]) host.nets;
+
+ # netAliases : { ${netname} : [addrAliases] }
+ netAliases =
+ foldl'
+ (result: host:
+ foldl'
+ # λ netAliases -> [addrAliases] -> netAliases
+ (result: { name, value }: result // {
+ ${name} = result.${name} or [] ++ value;
+ })
+ result
+ (mapAttrsToList nameValuePair (hostNetAliases host))
+ )
+ {}
+ (attrValues config.krebs.hosts);
+
+ # writeHosts : str -> [addrAliases] -> package
+ writeHosts = name: addrAliases: super.writeText name ''
+ ${concatMapStringsSep
+ "\n"
+ ({ name, value }: "${name} ${toString value}")
+ addrAliases}
+ '';
+ in
+ {
+ # hosts file for all krebs networks
+ krebs-hosts =
+ writeHosts "krebs-hosts" (concatLists [
+ netAliases.internet
+ netAliases.retiolum
+ netAliases.wiregrill
+ ]);
+
+ # combined hosts file for all networks (even custom ones)
+ krebs-hosts_combined =
+ writeHosts "krebs-hosts_combined"
+ (concatLists (attrValues netAliases));
+ }
+ //
+ genAttrs' (attrNames netAliases) (netname: rec {
+ name = "krebs-hosts-${netname}";
+ value = writeHosts name netAliases.${netname};
+ });
};
}
diff --git a/krebs/3modules/retiolum-hosts.nix b/krebs/3modules/retiolum-hosts.nix
deleted file mode 100644
index ddf85ead..00000000
--- a/krebs/3modules/retiolum-hosts.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-with import <stockholm/lib>;
-{ config, ... }: let
- # TODO dedup functions with ./hosts.nix
- check = hostname: any (domain: hasSuffix ".${domain}" hostname) domains;
- domains = attrNames (filterAttrs (_: eq "hosts") config.krebs.dns.providers);
-in {
- nixpkgs.config.packageOverrides = super: {
- retiolum-hosts =
- super.writeText "retiolum-hosts" ''
- ${
- concatStringsSep
- "\n"
- (flatten
- (map
- (host: let
- net = host.nets.retiolum;
- aliases = longs;
- longs = filter check net.aliases;
- in
- optionals
- (aliases != [])
- (map (addr: "${addr} ${toString aliases}") net.addrs))
- (filter (host: hasAttr "retiolum" host.nets)
- (attrValues config.krebs.hosts))))
- }
- '';
- };
-}
diff --git a/krebs/5pkgs/haskell/blessings.nix b/krebs/5pkgs/haskell/blessings.nix
index 97e4a717..f730cc72 100644
--- a/krebs/5pkgs/haskell/blessings.nix
+++ b/krebs/5pkgs/haskell/blessings.nix
@@ -1,5 +1,5 @@
with import <stockholm/lib>;
-{ mkDerivation, base, fetchgit, stdenv }: let
+{ mkDerivation, base, fetchgit, hspec, QuickCheck, stdenv, text }: let
cfg = {
"18.03" = {
@@ -7,8 +7,8 @@ with import <stockholm/lib>;
sha256 = "1k908zap3694fcxdk4bb29s54b0lhdh557y10ybjskfwnym7szn1";
};
"18.09" = {
- version = "2.1.0";
- sha256 = "0wc8v48bb0bkvypc0j6imvnf8xc8572hykk9sgjhzf2w0ggqxv5d";
+ version = "2.2.0";
+ sha256 = "1pb56dgf3jj2kq3cbbppwzyg3ccgqy9xara62hkjwyxzdx20clk1";
};
}.${versions.majorMinor nixpkgsVersion};
@@ -20,7 +20,8 @@ in mkDerivation {
rev = "refs/tags/v${cfg.version}";
sha256 = cfg.sha256;
};
- libraryHaskellDepends = [ base ];
+ libraryHaskellDepends = [ base text ];
+ testHaskellDepends = [ base hspec QuickCheck ];
doHaddock = false;
# WTFPL is the true license, which is unknown to cabal.
license = stdenv.lib.licenses.wtfpl;
diff --git a/krebs/5pkgs/haskell/flameshot-once.nix b/krebs/5pkgs/haskell/flameshot-once.nix
new file mode 100644
index 00000000..89b95ca0
--- /dev/null
+++ b/krebs/5pkgs/haskell/flameshot-once.nix
@@ -0,0 +1,21 @@
+{ mkDerivation, async, base, blessings, bytestring, dbus, fetchgit
+, iso8601-time, process, random, stdenv, text, time, unagi-chan
+, unix
+}:
+mkDerivation {
+ pname = "flameshot-once";
+ version = "1.1.0";
+ src = fetchgit {
+ url = "https://cgit.krebsco.de/flameshot-once";
+ sha256 = "158ha1yyj3p3mdjjga62j91ml83nhrsg34xbg3dir5cb399j8pxx";
+ rev = "9d688b6ffad14912bd1afe42555747cb3d213d95";
+ fetchSubmodules = true;
+ };
+ isLibrary = false;
+ isExecutable = true;
+ executableHaskellDepends = [
+ async base blessings bytestring dbus iso8601-time process random
+ text time unagi-chan unix
+ ];
+ license = stdenv.lib.licenses.mit;
+}
diff --git a/krebs/5pkgs/simple/flameshot-once/default.nix b/krebs/5pkgs/simple/flameshot-once/default.nix
new file mode 100644
index 00000000..c442a2e9
--- /dev/null
+++ b/krebs/5pkgs/simple/flameshot-once/default.nix
@@ -0,0 +1,27 @@
+with import <stockholm/lib>;
+{ pkgs, ... }@args:
+
+let
+ # config cannot be declared in the input attribute set because that would
+ # cause callPackage to inject the wrong config. Instead, get it from ...
+ # via args.
+ config = args.config or {};
+in
+
+ pkgs.symlinkJoin {
+ name = "flameshot-once-wrapper";
+ paths = [
+ (pkgs.writeDashBin "flameshot-once" ''
+ export PATH=${makeBinPath [
+ pkgs.flameshot
+ pkgs.qt5.qtbase
+ pkgs.xclip
+ ]}
+ ${optionalString (config != null) /* sh */ ''
+ . ${import ./profile.nix { inherit config pkgs; }}
+ ''}
+ exec ${pkgs.haskellPackages.flameshot-once}/bin/flameshot-once "$@"
+ '')
+ pkgs.haskellPackages.flameshot-once
+ ];
+ }
diff --git a/krebs/5pkgs/simple/flameshot-once/profile.nix b/krebs/5pkgs/simple/flameshot-once/profile.nix
new file mode 100644
index 00000000..4fcbd62c
--- /dev/null
+++ b/krebs/5pkgs/simple/flameshot-once/profile.nix
@@ -0,0 +1,129 @@
+with import <stockholm/lib>;
+{ config, pkgs }:
+let
+
+ # Refs https://github.com/lupoDharkael/flameshot/blob/master/src/widgets/capture/capturebutton.h
+ ButtonType = {
+ PENCIL = 0;
+ DRAWER = 1;
+ ARROW = 2;
+ SELECTION = 3;
+ RECTANGLE = 4;
+ CIRCLE = 5;
+ MARKER = 6;
+ SELECTIONINDICATOR = 7;
+ MOVESELECTION = 8;
+ UNDO = 9;
+ COPY = 10;
+ SAVE = 11;
+ EXIT = 12;
+ IMAGEUPLOADER = 13;
+ OPEN_APP = 14;
+ BLUR = 15;
+ REDO = 16;
+ PIN = 17;
+ TEXT = 18;
+ };
+
+ cfg = eval.config;
+
+ eval = evalModules {
+ modules = singleton {
+ _file = toString ./config.nix;
+ imports = singleton config;
+ options = {
+ buttons = mkOption {
+ apply = map (name: ButtonType.${name});
+ default = [
+ "PENCIL"
+ "DRAWER"
+ "ARROW"
+ "SELECTION"
+ "RECTANGLE"
+ "CIRCLE"
+ "MARKER"
+ "SELECTIONINDICATOR"
+ "MOVESELECTION"
+ "UNDO"
+ "SAVE"
+ "EXIT"
+ "BLUR"
+ ];
+ type = types.listOf (types.enum (attrNames ButtonType));
+ };
+ disabledTrayIcon = mkOption {
+ default = true;
+ type = types.bool;
+ };
+ drawThickness = mkOption {
+ default = 8;
+ type = types.positive;
+ };
+ filenamePattern = mkOption {
+ default = "%FT%T%z_flameshot.png";
+ type =
+ # This is types.filename extended by [%:][%:+]*
+ types.addCheck types.str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*");
+ };
+ savePath = mkOption {
+ default = "/tmp";
+ type = types.absolute-pathname;
+ };
+ showDesktopNotification = mkOption {
+ default = false;
+ type = types.bool;
+ };
+ showHelp = mkOption {
+ default = false;
+ type = types.bool;
+ };
+ };
+ };
+ };
+
+ hexchars = stringToCharacters "0123456789abcdef";
+
+ # Encode integer to C-escaped string of bytes, little endian / LSB 0
+ le = rec {
+ x1 = i: let
+ i0 = mod i 16;
+ i1 = i / 16;
+ in
+ "\\x${elemAt hexchars i1}${elemAt hexchars i0}";
+
+ x2 = i: let
+ i0 = mod i 256;
+ i1 = i / 256;
+ in
+ "${x1 i0}${x1 i1}";
+
+ x4 = i: let
+ i0 = mod i 65536;
+ i1 = i / 65536;
+ in
+ "${x2 i0}${x2 i1}";
+ };
+
+ toQList = t: xs:
+ assert t == "int";
+ "QList<${t}>${le.x4 0}${le.x4 (length xs)}${concatMapStrings le.x4 xs}";
+
+ XDG_CONFIG_HOME = pkgs.write "flameshot-config" {
+ "/Dharkael/flameshot.ini".text = ''
+ [General]
+ buttons=@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons})
+ disabledTrayIcon=${toJSON cfg.disabledTrayIcon}
+ drawThickness=${toJSON cfg.drawThickness}
+ filenamePattern=${toJSON cfg.filenamePattern}
+ savePath=${toJSON cfg.savePath}
+ showDesktopNotification=${toJSON cfg.showDesktopNotification}
+ showHelp=${toJSON cfg.showHelp}
+ '';
+ };
+
+in
+
+ pkgs.writeDash "flameshot.profile" ''
+ export FLAMESHOT_CAPTURE_PATH=${cfg.savePath}
+ export XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
+ ''
diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json
index 614d5bcc..b6124ad4 100644
--- a/krebs/nixpkgs.json
+++ b/krebs/nixpkgs.json
@@ -1,7 +1,7 @@
{
"url": "https://github.com/NixOS/nixpkgs-channels",
- "rev": "97e0d53d669cd07f0750a42fd535524b3cdd46d1",
- "date": "2019-01-15T00:11:44+01:00",
- "sha256": "111xa7qn9142dar29cil4br2mvn8f1rbiy310lkhwl73126fq8dw",
+ "rev": "9bd45dddf8171e2fd4288d684f4f70a2025ded19",
+ "date": "2019-02-15T12:11:24-05:00",
+ "sha256": "1idrxrymwqfsfysav3yl8lya1jhgg8xzgq9hy7dpdd63770vn8c1",
"fetchSubmodules": false
}