diff --git a/overlays/default.nix b/overlays/default.nix index c0308009..21a917ea 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -6,12 +6,13 @@ let (import ./nur { inherit sources; }) (import sources.emacs-overlay) (import ./rustfmt) + (import ./katlib) + (import ./katpkgs) /* # TODO: implement these (import ./vimrc) */ ] ++ (map (path: import "${path}/overlay.nix") [ sources.arcexprs - sources.katexprs sources.anicca ]); config = { diff --git a/overlays/katlib/color-helpers.nix b/overlays/katlib/color-helpers.nix new file mode 100644 index 00000000..76ee77a7 --- /dev/null +++ b/overlays/katlib/color-helpers.nix @@ -0,0 +1,25 @@ +{ lib }: rec { + hexChars = + [ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" ]; + hexCharToInt = char: + let + pairs = lib.imap0 (lib.flip lib.nameValuePair) hexChars; + idx = builtins.listToAttrs pairs; + in + idx.${lib.toLower char}; + hexToInt = str: + lib.foldl (value: chr: value * 16 + hexCharToInt chr) 0 + (lib.stringToCharacters str); + hextorgba = hex: alpha: + ( + let + r_hex = lib.substring 1 2 hex; + g_hex = lib.substring 3 2 hex; + b_hex = lib.substring 5 2 hex; + r_dec = hexToInt r_hex; + g_dec = hexToInt g_hex; + b_dec = hexToInt b_hex; + in + "rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, ${toString alpha})" + ); +} diff --git a/overlays/katlib/default.nix b/overlays/katlib/default.nix new file mode 100644 index 00000000..beb64f69 --- /dev/null +++ b/overlays/katlib/default.nix @@ -0,0 +1,8 @@ +self: super: { + lib = super.lib.extend (self: super: import ./import.nix { + inherit super; + lib = self; + isOverlayLib = true; + }); +} + diff --git a/overlays/katlib/domain-merge.nix b/overlays/katlib/domain-merge.nix new file mode 100644 index 00000000..21bb1dfa --- /dev/null +++ b/overlays/katlib/domain-merge.nix @@ -0,0 +1,13 @@ +{ lib }: { folder, defaultFile ? "default.nix", folderPaths ? [ ] }: with lib; let + defaultFileFinal = + if (defaultFile == "default.nix" && folder == "hosts") then + "nixos.nix" + else defaultFile; + folderModLists = map + (folderPath: modList { + modulesDir = folderPath; + defaultFile = defaultFileFinal; + }) + (filter builtins.pathExists folderPaths); +in +foldl modListMerge { } folderModLists diff --git a/overlays/katlib/folder-list.nix b/overlays/katlib/folder-list.nix new file mode 100644 index 00000000..110ffd52 --- /dev/null +++ b/overlays/katlib/folder-list.nix @@ -0,0 +1,7 @@ +{ lib }: path: excludes: +let + filterAttrNamesToList = filter: set: + lib.foldl' (a: b: a ++ b) [ ] + (map (e: if (filter e set.${e}) then [ e ] else [ ]) (lib.attrNames set)); +in +(filterAttrNamesToList (name: type: ! (builtins.elem name excludes) && type == "directory") (builtins.readDir path)) diff --git a/overlays/katlib/import.nix b/overlays/katlib/import.nix new file mode 100644 index 00000000..0158ad4d --- /dev/null +++ b/overlays/katlib/import.nix @@ -0,0 +1,23 @@ +{ pkgs ? import { } +, lib ? pkgs.lib + # for internal use... +, super ? if !isOverlayLib then lib else { } +, self ? if isOverlayLib then lib else { } +, before ? if !isOverlayLib then lib else { } +, isOverlayLib ? false +}@args: +let + colorHelpers = import ./color-helpers.nix { inherit lib; }; + lib = before // katlib // self; + katlib = with before; with katlib; with self; + { + inherit (colorHelpers) hextorgba; + nodeImport = import ./node-import.nix { inherit lib; }; + virtualHostGen = import ./virtual-host-gen.nix { inherit lib; }; + domainMerge = import ./domain-merge.nix { inherit lib; }; + modListMerge = import ./intersect-merge.nix { inherit lib; }; + modList = import ./module-list.nix { inherit lib; }; + folderList = import ./folder-list.nix { inherit lib; }; + }; +in +katlib diff --git a/overlays/katlib/intersect-merge.nix b/overlays/katlib/intersect-merge.nix new file mode 100644 index 00000000..ed198e08 --- /dev/null +++ b/overlays/katlib/intersect-merge.nix @@ -0,0 +1,5 @@ +{ lib }: pathsA: pathsB: with lib; let + pathIntersection = intersectLists (attrNames pathsA) (attrNames pathsB); + pathMerger = pathA: pathB: { imports = [ pathA pathB ]; }; +in +pathsA // pathsB // genAttrs pathIntersection (key: (pathMerger pathsA.${key} pathsB.${key})) diff --git a/overlays/katlib/module-list.nix b/overlays/katlib/module-list.nix new file mode 100644 index 00000000..5bf1d029 --- /dev/null +++ b/overlays/katlib/module-list.nix @@ -0,0 +1,29 @@ +{ lib }: { modulesDir, defaultFile ? "default.nix", importAll ? false }: + +with builtins; + +let + isModule = m: lib.isFunction m && (m.isModule or true); + filterAttrNamesToList = filter: set: + foldl' (a: b: a ++ b) [ ] + (map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set)); + nameValuePair = name: value: { inherit name value; }; + listToAttrs = foldl' (acc: val: acc // { ${val.name} = val.value; }) { }; + directories = + filterAttrNamesToList (_: type: type == "directory") (readDir modulesDir); + files = map (dir: nameValuePair dir (modulesDir + "/${dir}/${defaultFile}")) + (filter (f: builtins.pathExists (modulesDir + "/${f}/${defaultFile}")) directories); + modules = map + ({ name, value }: + # if the file contains a function, assume it to be a module and pass the path + # (for dedup and such). if it contains anything else, pass that. + let m = import value; + in + { + inherit name; + value = if lib.isFunction m && ! isModule m then m { inherit lib; } else if isModule m && !importAll then value else m; + }) + files; + modList = (listToAttrs modules); +in +modList diff --git a/overlays/katlib/node-import.nix b/overlays/katlib/node-import.nix new file mode 100644 index 00000000..27e49913 --- /dev/null +++ b/overlays/katlib/node-import.nix @@ -0,0 +1,21 @@ +{ lib }: { nixosImports, homeImports, users, hostName, profiles }: with lib; + +let + importLists = { + nixos = nixosImports; + home = homeImports; + }; + replacedLists = mapAttrs + (_: fileList: + map (builtins.replaceStrings [ "HN" ] [ "${hostName}" ]) fileList + ) + importLists; + homeScaffold = user: { + home-manager.users.${user} = { + imports = filter builtins.pathExists replacedLists.home; + }; + }; + scaffoldedUsers = map homeScaffold users; + baseProfile = if builtins.isAttrs profiles.base then profiles.base.imports else singleton profiles.base; +in +filter builtins.pathExists replacedLists.nixos ++ baseProfile ++ scaffoldedUsers diff --git a/overlays/katlib/virtual-host-gen.nix b/overlays/katlib/virtual-host-gen.nix new file mode 100644 index 00000000..ae1e3a89 --- /dev/null +++ b/overlays/katlib/virtual-host-gen.nix @@ -0,0 +1,11 @@ +{ lib }: { config, networkFilter ? [ ], addresses ? [ ], block }: with lib; + +let + networks = config.network.addresses; + filteredNetworks = filterAttrs (n: v: elem n networkFilter) networks; + networkValues = attrValues filteredNetworks; + addressList'= concatMap (n: n.out.identifierList) networkValues; + addressList = map(n: builtins.unsafeDiscardStringContext n) addressList'; + hostBlocks = map (host: nameValuePair host block) addressList; +in +listToAttrs hostBlocks diff --git a/overlays/katpkgs/default.nix b/overlays/katpkgs/default.nix new file mode 100644 index 00000000..c2b11440 --- /dev/null +++ b/overlays/katpkgs/default.nix @@ -0,0 +1,7 @@ +self: super: +let + pkgs'' = import ./import.nix; + pkgs' = pkgs''.public // pkgs''.personal // pkgs''.overrides; + pkgs = builtins.mapAttrs (_: pkg: self.callPackage pkg { }) pkgs'; +in +pkgs diff --git a/overlays/katpkgs/import.nix b/overlays/katpkgs/import.nix new file mode 100644 index 00000000..a441bdfd --- /dev/null +++ b/overlays/katpkgs/import.nix @@ -0,0 +1,5 @@ +{ + public = import ./public; + personal = import ./personal; + overrides = import ./overrides; +} diff --git a/overlays/katpkgs/overrides/default.nix b/overlays/katpkgs/overrides/default.nix new file mode 100644 index 00000000..8ecfce32 --- /dev/null +++ b/overlays/katpkgs/overrides/default.nix @@ -0,0 +1,15 @@ +{ + dino-omemo = { dino, ... }: dino.overrideAttrs ({ patches ? [ ], ... }: { + patches = patches ++ [ + ./dino/0001-add-an-option-to-enable-omemo-by-default-in-new-conv.patch + ]; + }); + obs-studio-pipewire = { obs-studio, ... }: obs-studio.override { pipewireSupport = true; }; + konawall-sway = { arc, ... }: arc.packages.personal.konawall.override { swaySupport = true; }; + ncmpcpp-kat = { ncmpcpp, ... }: ncmpcpp.override { + visualizerSupport = true; + clockSupport = true; + }; + discord-nssfix = { discord, nss, ... }: discord.override { inherit nss; }; + element-wayland = { element-desktop, ... }: element-desktop.override { useWayland = true; }; +} diff --git a/overlays/katpkgs/overrides/dino/0001-add-an-option-to-enable-omemo-by-default-in-new-conv.patch b/overlays/katpkgs/overrides/dino/0001-add-an-option-to-enable-omemo-by-default-in-new-conv.patch new file mode 100644 index 00000000..030c165d --- /dev/null +++ b/overlays/katpkgs/overrides/dino/0001-add-an-option-to-enable-omemo-by-default-in-new-conv.patch @@ -0,0 +1,115 @@ +From cee5e27b157081a3ce55869bd5f649560a6127ea Mon Sep 17 00:00:00 2001 +From: lumi +Date: Thu, 17 Oct 2019 16:43:40 +0200 +Subject: [PATCH] add an option to enable omemo by default in new conversations + +--- + libdino/src/entity/settings.vala | 10 ++++++++++ + libdino/src/service/conversation_manager.vala | 5 +++++ + main/data/settings_dialog.ui | 12 ++++++++++++ + main/src/ui/settings_dialog.vala | 3 +++ + 4 files changed, 30 insertions(+) + +diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala +index bf1ebed..f9cd734 100644 +--- a/libdino/src/entity/settings.vala ++++ b/libdino/src/entity/settings.vala +@@ -11,6 +11,7 @@ public class Settings : Object { + send_marker_ = col_to_bool_or_default("send_marker", true); + notifications_ = col_to_bool_or_default("notifications", true); + convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true); ++ omemo_default_ = col_to_bool_or_default("omemo_default", false); + } + + private bool col_to_bool_or_default(string key, bool def) { +@@ -53,6 +54,15 @@ public class Settings : Object { + convert_utf8_smileys_ = value; + } + } ++ ++ private bool omemo_default_; ++ public bool omemo_default { ++ get { return omemo_default_; } ++ set { ++ db.settings.insert().or("REPLACE").value(db.settings.key, "omemo_default").value(db.settings.value, value.to_string()).perform(); ++ omemo_default_ = value; ++ } ++ } + } + + } +diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala +index c473ea7..e980e08 100644 +--- a/libdino/src/service/conversation_manager.vala ++++ b/libdino/src/service/conversation_manager.vala +@@ -8,6 +8,8 @@ public class ConversationManager : StreamInteractionModule, Object { + public static ModuleIdentity IDENTITY = new ModuleIdentity("conversation_manager"); + public string id { get { return IDENTITY.id; } } + ++ private Dino.Entities.Settings settings = Dino.Application.get_default().settings; ++ + public signal void conversation_activated(Conversation conversation); + public signal void conversation_deactivated(Conversation conversation); + +@@ -46,6 +48,9 @@ public class ConversationManager : StreamInteractionModule, Object { + + // Create a new converation + Conversation conversation = new Conversation(jid, account, type); ++ if (settings.omemo_default) { ++ conversation.encryption = Encryption.OMEMO; ++ } + add_conversation(conversation); + conversation.persist(db); + return conversation; +diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui +index c76f347..23ee7b8 100644 +--- a/main/data/settings_dialog.ui ++++ b/main/data/settings_dialog.ui +@@ -65,6 +65,18 @@ + 1 + + ++ ++ ++ Enable OMEMO by default ++ True ++ ++ ++ 0 ++ 4 ++ 1 ++ 1 ++ ++ + + + +diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala +index 68c711d..6401a2d 100644 +--- a/main/src/ui/settings_dialog.vala ++++ b/main/src/ui/settings_dialog.vala +@@ -9,6 +9,7 @@ class SettingsDialog : Dialog { + [GtkChild] private CheckButton marker_checkbutton; + [GtkChild] private CheckButton notification_checkbutton; + [GtkChild] private CheckButton emoji_checkbutton; ++ [GtkChild] private CheckButton omemo_default_checkbutton; + + Dino.Entities.Settings settings = Dino.Application.get_default().settings; + +@@ -19,11 +20,13 @@ class SettingsDialog : Dialog { + marker_checkbutton.active = settings.send_marker; + notification_checkbutton.active = settings.notifications; + emoji_checkbutton.active = settings.convert_utf8_smileys; ++ omemo_default_checkbutton.active = settings.omemo_default; + + typing_checkbutton.toggled.connect(() => { settings.send_typing = typing_checkbutton.active; } ); + marker_checkbutton.toggled.connect(() => { settings.send_marker = marker_checkbutton.active; } ); + notification_checkbutton.toggled.connect(() => { settings.notifications = notification_checkbutton.active; } ); + emoji_checkbutton.toggled.connect(() => { settings.convert_utf8_smileys = emoji_checkbutton.active; }); ++ omemo_default_checkbutton.toggled.connect(() => { settings.omemo_default = omemo_default_checkbutton.active; }); + } + } + +-- +2.23.0 + diff --git a/overlays/katpkgs/personal/default.nix b/overlays/katpkgs/personal/default.nix new file mode 100644 index 00000000..e466c9a5 --- /dev/null +++ b/overlays/katpkgs/personal/default.nix @@ -0,0 +1,11 @@ +{ + disk-mapper = import ./disk-mapper; + screenstub-kat = import ./screenstub-kat; + sway-scrot = import ./sway-scrot; + host-splash-site = import ./host-splash-site; + kittywitch-site = import ./kittywitch-site; + waybar-gpg = import ./waybar-gpg; + taskwarrior-export = import ./taskwarrior-export; + waybar-konawall = import ./waybar-konawall; + win10-vm = import ./win10-vm; +} diff --git a/overlays/katpkgs/personal/disk-mapper/default.nix b/overlays/katpkgs/personal/disk-mapper/default.nix new file mode 100644 index 00000000..940274a1 --- /dev/null +++ b/overlays/katpkgs/personal/disk-mapper/default.nix @@ -0,0 +1,5 @@ +{ wrapShellScriptBin, pkgs }: + +wrapShellScriptBin "disk-mapper" ./disk-mapper.sh { + depsRuntimePath = with pkgs; [ coreutils utillinux ]; +} diff --git a/overlays/katpkgs/personal/disk-mapper/disk-mapper.sh b/overlays/katpkgs/personal/disk-mapper/disk-mapper.sh new file mode 100644 index 00000000..c89710fb --- /dev/null +++ b/overlays/katpkgs/personal/disk-mapper/disk-mapper.sh @@ -0,0 +1,42 @@ +set -x +DISK=$1 +DM_NAME=$(basename $DISK) +if [[ ! -e /dev/mapper/$DM_NAME ]]; then + DISK_ID=${2-$(printf %s "$DM_NAME" | sha256sum)} + DISK_TYPE=7 # NTFS + MBR_FILE=$(mktemp -t vm-$DM_NAME-XXXXXXXX.mbr) + BLOCK=$(basename $(readlink $DISK)) + BLOCK_START=$(cat /sys/class/block/$BLOCK/start) + BLOCK_SIZE=$(cat /sys/class/block/$BLOCK/size) + DISK_SIZE=$(((BLOCK_SIZE + 2048 + 2047) / 2048 * 2048)) + dd if=/dev/zero of=$MBR_FILE bs=512 count=2048 status=none + + LDEV=$(losetup --show -f $MBR_FILE) + END_GUARD=$((DISK_SIZE - 2048 - BLOCK_SIZE)) + if [[ $END_GUARD -ne 0 ]]; then + END_GUARD="$((BLOCK_SIZE + 2048)) $END_GUARD zero" + else + END_GUARD= + fi + dmsetup create $DM_NAME < + + kat's ${hostname} + + +

mew! welcome to ${hostname} ><

+ + + +

stop snooping, it's mean! o:

+ + + ''; + }; + mewy = "${./splash.jpg}"; +in +linkFarm "index" [ + { name = "index.html"; path = mewp; } + { name = "splash.jpg"; path = mewy; } +] diff --git a/overlays/katpkgs/personal/host-splash-site/splash.jpg b/overlays/katpkgs/personal/host-splash-site/splash.jpg new file mode 100644 index 00000000..5f3231d6 Binary files /dev/null and b/overlays/katpkgs/personal/host-splash-site/splash.jpg differ diff --git a/overlays/katpkgs/personal/kittywitch-site/default.nix b/overlays/katpkgs/personal/kittywitch-site/default.nix new file mode 100644 index 00000000..3eb04269 --- /dev/null +++ b/overlays/katpkgs/personal/kittywitch-site/default.nix @@ -0,0 +1,28 @@ +{ fetchgit, stdenv, lib, bundler, ruby, bundlerEnv }: + +stdenv.mkDerivation rec { + pname = "kat-website"; + version = "0.1"; + + src = fetchgit { + rev = "d2b6c62a745e505bee4a3a5ba72648d640beb2ca"; + url = "https://github.com/kittywitch/website"; + sha256 = "1qi8rd4nw199lkjkqgvc88knra3996zl6vagw8gvjl9x5m9h4vy3"; + }; + + jekyll_env = bundlerEnv rec { + name = "jekyll_env"; + inherit ruby; + gemfile = "${src}/Gemfile"; + lockfile = "${src}/Gemfile.lock"; + gemset = ./gemset.nix; + }; + + buildInputs = [ bundler ruby jekyll_env ]; + + installPhase = '' + mkdir $out + ${jekyll_env}/bin/jekyll build -d $out + ''; +} + diff --git a/overlays/katpkgs/personal/kittywitch-site/gemset.nix b/overlays/katpkgs/personal/kittywitch-site/gemset.nix new file mode 100644 index 00000000..6023ce80 --- /dev/null +++ b/overlays/katpkgs/personal/kittywitch-site/gemset.nix @@ -0,0 +1,311 @@ +{ + addressable = { + dependencies = [ "public_suffix" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1fvchp2rhp2rmigx7qglf69xvjqvzq7x0g49naliw29r2bz656sy"; + type = "gem"; + }; + version = "2.7.0"; + }; + colorator = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0f7wvpam948cglrciyqd798gdc6z3cfijciavd0dfixgaypmvy72"; + type = "gem"; + }; + version = "1.1.0"; + }; + concurrent-ruby = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0mr23wq0szj52xnj0zcn1k0c7j4v79wlwbijkpfcscqww3l6jlg3"; + type = "gem"; + }; + version = "1.1.8"; + }; + em-websocket = { + dependencies = [ "eventmachine" "http_parser.rb" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1mg1mx735a0k1l8y14ps2mxdwhi5r01ikydf34b0sp60v66nvbkb"; + type = "gem"; + }; + version = "0.5.2"; + }; + eventmachine = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0wh9aqb0skz80fhfn66lbpr4f86ya2z5rx6gm5xlfhd05bj1ch4r"; + type = "gem"; + }; + version = "1.2.7"; + }; + ffi = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "15hgiy09i8ywjihyzyvjvk42ivi3kmy6dm21s5sgg9j7y3h3zkkx"; + type = "gem"; + }; + version = "1.14.2"; + }; + forwardable-extended = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "15zcqfxfvsnprwm8agia85x64vjzr2w0xn9vxfnxzgcv8s699v0v"; + type = "gem"; + }; + version = "2.6.0"; + }; + "http_parser.rb" = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "15nidriy0v5yqfjsgsra51wmknxci2n2grliz78sf9pga3n0l7gi"; + type = "gem"; + }; + version = "0.6.0"; + }; + i18n = { + dependencies = [ "concurrent-ruby" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "08p6b13p99j1rrcrw1l3v0kb9mxbsvy6nk31r8h4rnszdgzpga32"; + type = "gem"; + }; + version = "1.8.9"; + }; + jekyll = { + dependencies = [ + "addressable" + "colorator" + "em-websocket" + "i18n" + "jekyll-sass-converter" + "jekyll-watch" + "kramdown" + "kramdown-parser-gfm" + "liquid" + "mercenary" + "pathutil" + "rouge" + "safe_yaml" + "terminal-table" + ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0cqkh78jw8scrajyx5nla0vwm9fvp2qql3kdcvvplcq9mazy8snq"; + type = "gem"; + }; + version = "4.2.0"; + }; + jekyll-feed = { + dependencies = [ "jekyll" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1zxqkrnix0xiw98531h5ga6h69jhzlx2jh9qhvcl67p8nq3sgza9"; + type = "gem"; + }; + version = "0.15.1"; + }; + jekyll-sass-converter = { + dependencies = [ "sassc" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "04ncr44wrilz26ayqwlg7379yjnkb29mvx4j04i62b7czmdrc9dv"; + type = "gem"; + }; + version = "2.1.0"; + }; + jekyll-watch = { + dependencies = [ "listen" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1qd7hy1kl87fl7l0frw5qbn22x7ayfzlv9a5ca1m59g0ym1ysi5w"; + type = "gem"; + }; + version = "2.2.1"; + }; + kramdown = { + dependencies = [ "rexml" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1vmw752c26ny2jwl0npn0gbyqwgz4hdmlpxnsld9qi9xhk5b1qh7"; + type = "gem"; + }; + version = "2.3.0"; + }; + kramdown-parser-gfm = { + dependencies = [ "kramdown" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0a8pb3v951f4x7h968rqfsa19c8arz21zw1vaj42jza22rap8fgv"; + type = "gem"; + }; + version = "1.1.0"; + }; + liquid = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0zhg5ha8zy8zw9qr3fl4wgk4r5940n4128xm2pn4shpbzdbsj5by"; + type = "gem"; + }; + version = "4.0.3"; + }; + listen = { + dependencies = [ "rb-fsevent" "rb-inotify" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0imzd0cb9vlkc3yggl4rph1v1wm4z9psgs4z6aqsqa5hgf8gr9hj"; + type = "gem"; + }; + version = "3.4.1"; + }; + mercenary = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0f2i827w4lmsizrxixsrv2ssa3gk1b7lmqh8brk8ijmdb551wnmj"; + type = "gem"; + }; + version = "0.4.0"; + }; + pathutil = { + dependencies = [ "forwardable-extended" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "12fm93ljw9fbxmv2krki5k5wkvr7560qy8p4spvb9jiiaqv78fz4"; + type = "gem"; + }; + version = "0.16.2"; + }; + public_suffix = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1xqcgkl7bwws1qrlnmxgh8g4g9m10vg60bhlw40fplninb3ng6d9"; + type = "gem"; + }; + version = "4.0.6"; + }; + rb-fsevent = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1k9bsj7ni0g2fd7scyyy1sk9dy2pg9akniahab0iznvjmhn54h87"; + type = "gem"; + }; + version = "0.10.4"; + }; + rb-inotify = { + dependencies = [ "ffi" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1jm76h8f8hji38z3ggf4bzi8vps6p7sagxn3ab57qc0xyga64005"; + type = "gem"; + }; + version = "0.10.1"; + }; + rexml = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "1mkvkcw9fhpaizrhca0pdgjcrbns48rlz4g6lavl5gjjq3rk2sq3"; + type = "gem"; + }; + version = "3.2.4"; + }; + rouge = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0b4b300i3m4m4kw7w1n9wgxwy16zccnb7271miksyzd0wq5b9pm3"; + type = "gem"; + }; + version = "3.26.0"; + }; + safe_yaml = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0j7qv63p0vqcd838i2iy2f76c3dgwzkiz1d1xkg7n0pbnxj2vb56"; + type = "gem"; + }; + version = "1.0.5"; + }; + sassc = { + dependencies = [ "ffi" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "0gpqv48xhl8mb8qqhcifcp0pixn206a7imc07g48armklfqa4q2c"; + type = "gem"; + }; + version = "2.4.0"; + }; + terminal-table = { + dependencies = [ "unicode-display_width" ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "18rbrh464ysqbdv53iwj0r8frshn65566kyj044cp3x9c2754jwh"; + type = "gem"; + }; + version = "2.0.0"; + }; + unicode-display_width = { + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; + sha256 = "06i3id27s60141x6fdnjn5rar1cywdwy64ilc59cz937303q3mna"; + type = "gem"; + }; + version = "1.7.0"; + }; +} diff --git a/overlays/katpkgs/personal/screenstub-kat/default.nix b/overlays/katpkgs/personal/screenstub-kat/default.nix new file mode 100644 index 00000000..d4ddb6d9 --- /dev/null +++ b/overlays/katpkgs/personal/screenstub-kat/default.nix @@ -0,0 +1,21 @@ +{ fetchFromGitHub, rustPlatform, pkg-config, lib, libxcb, udev, python3 }: + +rustPlatform.buildRustPackage rec { + pname = "screenstub"; + version = "2021-01-08"; + src = fetchFromGitHub { + owner = "arcnmx"; + repo = pname; + rev = "e379279fedaaa1d06b1d89da4cf54752814a456f"; + sha256 = "0qv15rpazrpdspfcvyizbjdrrm2nrqz0790pa8zvp5bjsw4mvwvx"; + }; + + patches = [ ./main.patch ]; + + nativeBuildInputs = [ pkg-config python3 ]; + buildInputs = [ libxcb udev ]; + + cargoSha256 = "1m85lisy0085z4lr27lw0b9kbf134qz8dkjvcjnkwxgikx60pq3i"; + + doCheck = false; +} diff --git a/overlays/katpkgs/personal/screenstub-kat/main.patch b/overlays/katpkgs/personal/screenstub-kat/main.patch new file mode 100644 index 00000000..7ed86bd0 --- /dev/null +++ b/overlays/katpkgs/personal/screenstub-kat/main.patch @@ -0,0 +1,142 @@ +diff --git a/qemu/src/lib.rs b/qemu/src/lib.rs +index 6a84bd4..d83cc49 100644 +--- a/qemu/src/lib.rs ++++ b/qemu/src/lib.rs +@@ -137,7 +137,7 @@ impl Qemu { + match events.recv().await { + Ok(qapi::qmp::Event::DEVICE_DELETED { ref data, .. }) if data.device.as_ref() == Some(&id) => { + // work around qemu bug. without this delay, device_add will work but the new device might be immediately deleted +- sleep(Duration::from_millis(128)).await; ++ sleep(Duration::from_millis(256)).await; + + break Ok(()) + }, +diff --git a/src/main.rs b/src/main.rs +index 3dc30a2..ed87aaa 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -161,8 +161,8 @@ async fn main_result(spawner: &Arc) -> Result { + }; + + let repeat = false; +- let bus = None; +- let mut route_keyboard = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-kbd".into(), bus.clone(), repeat); ++ //let bus = None; ++ let mut route_keyboard = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-kbd".into(), Some("pci.23".into()), repeat); + if let Some(builder) = route_keyboard.builder() { + builder + .name("screenstub-kbd") +@@ -171,7 +171,7 @@ async fn main_result(spawner: &Arc) -> Result { + } + let mut events_keyboard = route_keyboard.spawn(spawner, error_sender.clone()); + +- let mut route_relative = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-mouse".into(), bus.clone(), repeat); ++ let mut route_relative = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-mouse".into(), Some("pci.22".into()), repeat); + if let Some(builder) = route_relative.builder() { + builder + .name("screenstub-mouse") +@@ -180,7 +180,7 @@ async fn main_result(spawner: &Arc) -> Result { + } + let mut events_relative = route_relative.spawn(spawner, error_sender.clone()); + +- let mut route_absolute = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-tablet".into(), bus, repeat); ++ let mut route_absolute = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-tablet".into(), Some("pci.21".into()), repeat); + if let Some(builder) = route_absolute.builder() { + builder + .name("screenstub-tablet") +diff --git a/src/route.rs b/src/route.rs +index 0448b52..417c197 100644 +--- a/src/route.rs ++++ b/src/route.rs +@@ -180,12 +180,10 @@ pub struct RouteUInputVirtio { + + impl UInputCommands for RouteUInputVirtio { + fn command_create(&self, qemu: &Arc, path: &Path) -> Pin> + Send>> { +- let name = match self.bus.is_some() { +- true => "virtio-input-host-device", // TODO: double-check this, what is the virtio bus for? +- false => "virtio-input-host-pci", +- }; +- let command = qmp::device_add::new(name, Some(self.id.clone()), self.bus.clone(), vec![ ++ let name = "virtio-input-host-pci"; ++ let command = qmp::device_add::new(name,Some(self.id.clone()) , self.bus.clone(), vec![ + ("evdev".into(), Any::String(path.display().to_string())), ++ //("addr".into(), Any::String("3".to_string())) + ]); + let deadline = Instant::now() + Duration::from_millis(512); // HACK: wait for udev to see device and change permissions + let qemu = qemu.clone(); +@@ -213,12 +211,15 @@ pub struct RouteUInputInputLinux { + impl UInputCommands for RouteUInputInputLinux { + fn command_create(&self, qemu: &Arc, path: &Path) -> Pin> + Send>> { + let path = path.display(); +- let command = qmp::object_add::new(&self.id, "input-linux", vec![ ++ let command = qmp::object_add::new("input-linux", &self.id, vec![ + ("evdev".into(), Any::String(path.to_string())), + ("repeat".into(), Any::Bool(self.repeat)), + ]); + let qemu = qemu.clone(); ++ let id_ = self.id.clone(); + async move { ++ let _ = qemu.execute_qmp(qmp::object_del { id: id_ }).await; ++ tokio::time::sleep(Duration::from_millis(512)).await; + qemu.execute_qmp(command).map_ok(drop).await + }.boxed() + } +@@ -283,7 +284,7 @@ pub enum Route { + impl Route { + pub fn new(routing: ConfigQemuRouting, qemu: Arc, id: String, bus: Option, repeat: bool) -> Self { + match routing { +- ConfigQemuRouting::InputLinux => Route::InputLinux(RouteUInput::new_input_linux(qemu, id, repeat)), ++ ConfigQemuRouting::InputLinux => Route::InputLinux(RouteUInput::new_input_linux(qemu, id, false)), + ConfigQemuRouting::VirtioHost => Route::VirtioHost(RouteUInput::new_virtio_host(qemu, id, bus)), + ConfigQemuRouting::Qmp => Route::Qmp(RouteQmp::new(qemu)), + ConfigQemuRouting::Spice => unimplemented!("SPICE routing"), +diff --git a/x/src/lib.rs b/x/src/lib.rs +index a517922..c37b951 100644 +--- a/x/src/lib.rs ++++ b/x/src/lib.rs +@@ -88,7 +88,7 @@ pub struct XContext { + window: xcore::Window, + ext_input: xcore::QueryExtensionReply, + ext_test: xcore::QueryExtensionReply, +- ext_dpms: xcore::QueryExtensionReply, ++// ext_dpms: xcore::QueryExtensionReply, + ext_xkb: xcore::QueryExtensionReply, + setup: xcore::Setup, + +@@ -128,8 +128,8 @@ impl XContext { + .expect("XKB required"); + let ext_test = sink.extension(ExtensionKind::Test).await.await? + .expect("XTest required"); +- let ext_dpms = sink.extension(ExtensionKind::DPMS).await.await? +- .expect("DPMS required"); ++ // let ext_dpms = sink.extension(ExtensionKind::DPMS).await.await? ++// .expect("DPMS required"); + let _ = sink.execute(xinput::XIQueryVersionRequest { + major_opcode: ext_input.major_opcode, + major_version: 2, +@@ -211,7 +211,7 @@ impl XContext { + ext_input, + ext_test, + ext_xkb, +- ext_dpms, ++ // ext_dpms, + display, + + sink, +@@ -506,13 +506,14 @@ impl XContext { + + Ok(match event { + ExtensionEvent::Core(xcore::Events::VisibilityNotify(event)) => { +- let dpms_blank = { ++/* let dpms_blank = { + let info = self.sink.execute(dpms::InfoRequest { + major_opcode: self.ext_dpms.major_opcode, + }).await.await?; + + info.power_level.get() != dpms::DPMSMode::On +- }; ++ };*/ ++ let dpms_blank = false; + self.event_queue.push(if dpms_blank { + XEvent::Visible(false) + } else { diff --git a/overlays/katpkgs/personal/sway-scrot/default.nix b/overlays/katpkgs/personal/sway-scrot/default.nix new file mode 100644 index 00000000..5c58ee58 --- /dev/null +++ b/overlays/katpkgs/personal/sway-scrot/default.nix @@ -0,0 +1,5 @@ +{ wrapShellScriptBin, pkgs }: + +wrapShellScriptBin "sway-scrot" ./sway-scrot.sh { + depsRuntimePath = with pkgs; [ coreutils wl-clipboard slurp grim sway jq libnotify ]; +} diff --git a/overlays/katpkgs/personal/sway-scrot/sway-scrot.sh b/overlays/katpkgs/personal/sway-scrot/sway-scrot.sh new file mode 100644 index 00000000..a14eb995 --- /dev/null +++ b/overlays/katpkgs/personal/sway-scrot/sway-scrot.sh @@ -0,0 +1,177 @@ +#!/bin/sh + +## Requirements: +## - `grim`: screenshot utility for wayland +## - `slurp`: to select an area +## - `swaymsg`: to read properties of current window +## - `wl-copy`: clipboard utility +## - `jq`: json utility to parse swaymsg output +## - `notify-send`: to show notifications + +getTargetDirectory() { + echo "/home/kat/media/scrots" +} + +if [ "$1" = "--notify" ]; then + NOTIFY=yes + shift 1 +else + NOTIFY=no +fi + +ACTION=${1:-usage} +SUBJECT=${2:-screen} +FILENAME="$(date -Ins).png" +FILE=${3:-$(getTargetDirectory)/$FILENAME} + +REMOTE_USER="kat" +REMOTE_SERVER="kittywit.ch" +REMOTE_PORT="62954" +REMOTE_PATH="/var/www/files/" +REMOTE_URL="https://files.kittywit.ch/" + +if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ] && [ "$ACTION" != "upload" ] && [ "$ACTION" != "copys" ]; then + echo "Usage:" + echo " kat-scrot [--notify] (copy|save|upload|copys) [active|screen|output|area|window] [FILE]" + echo " kat-scrot check" + echo " kat-scrot usage" + echo "" + echo "Commands:" + echo " copy: Copy the screenshot data into the clipboard." + echo " upload: Uses SCP to transfer the screenshot to a remote server." + echo " copys: Copy the screenshot data into the clipboard and save it to a regular file." + echo " save: Save the screenshot to a regular file." + echo " check: Verify if required tools are installed and exit." + echo " usage: Show this message and exit." + echo "" + echo "Targets:" + echo " active: Currently active window." + echo " screen: All visible outputs." + echo " output: Currently active output." + echo " area: Manually select a region." + echo " window: Manually select a window." + exit +fi + +notify() { + notify-send -t 3000 -a grimshot "$@" +} +notifyOk() { + [ "$NOTIFY" = "no" ] && return + + TITLE=${2:-"Screenshot"} + MESSAGE=${1:-"OK"} + notify "$TITLE" "$MESSAGE" +} +notifyError() { + if [ $NOTIFY = "yes" ]; then + TITLE=${2:-"Screenshot"} + MESSAGE=${1:-"Error taking screenshot with grim"} + notify -u critical "$TITLE" "$MESSAGE" + else + echo $1 + fi +} + +die() { + MSG=${1:-Bye} + notifyError "Error: $MSG" + exit 2 +} + +check() { + COMMAND=$1 + if command -v "$COMMAND" > /dev/null 2>&1; then + RESULT="OK" + else + RESULT="NOT FOUND" + fi + echo " $COMMAND: $RESULT" +} + +takeScreenshot() { + FILE=$1 + GEOM=$2 + OUTPUT=$3 + if [ ! -z "$OUTPUT" ]; then + grim -o "$OUTPUT" "$FILE" || die "Unable to invoke grim" + elif [ -z "$GEOM" ]; then + grim "$FILE" || die "Unable to invoke grim" + else + grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" + fi +} + +if [ "$ACTION" = "check" ] ; then + echo "Checking if required tools are installed. If something is missing, install it to your system and make it available in PATH..." + check grim + check slurp + check swaymsg + check wl-copy + check jq + check notify-send + exit +elif [ "$SUBJECT" = "area" ] ; then + GEOM=$(slurp -d) + # Check if user exited slurp without selecting the area + if [ -z "$GEOM" ]; then + exit + fi + WHAT="Area" +elif [ "$SUBJECT" = "active" ] ; then + FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') + GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"') + APP_ID=$(echo "$FOCUSED" | jq -r '.app_id') + WHAT="$APP_ID window" +elif [ "$SUBJECT" = "screen" ] ; then + GEOM="" + WHAT="Screen" +elif [ "$SUBJECT" = "output" ] ; then + GEOM="" + OUTPUT=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') + WHAT="$OUTPUT" +elif [ "$SUBJECT" = "window" ] ; then + GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) + # Check if user exited slurp without selecting the area + if [ -z "$GEOM" ]; then + exit + fi + WHAT="Window" +else + die "Unknown subject to take a screen shot from" "$SUBJECT" +fi + +if [ "$ACTION" = "copy" ] ; then + takeScreenshot - "$GEOM" "$OUTPUT" | wl-copy --type image/png || die "Clipboard error" + notifyOk "$WHAT copied to buffer" +elif [ "$ACTION" = "copys" ]; then + if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then + TITLE="Screenshot of $SUBJECT" + MESSAGE=$(basename "$FILE") + notifyOk "$MESSAGE" "$TITLE" + echo $FILE + cat "$FILE" | wl-copy --type image/png || die "Clipboard error" + else + notifyError "Error taking screenshot with grim" + fi +elif [ "$ACTION" = "upload" ]; then + if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then + if scp -P $REMOTE_PORT $FILE $REMOTE_USER@$REMOTE_SERVER:$REMOTE_PATH$FILENAME; then + echo -n $REMOTE_URL$FILENAME | wl-copy + notifyOk "Uploaded: $REMOTE_URL$FILENAME" + else + notifyError "Error uploading screenshot" + fi + else + notifyError "Error taking screenshot with grim" + fi +else + if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then + TITLE="Screenshot of $SUBJECT" + MESSAGE=$(basename "$FILE") + notifyOk "$MESSAGE" "$TITLE" + echo $FILE + else + notifyError "Error taking screenshot with grim" + fi +fi diff --git a/overlays/katpkgs/personal/taskwarrior-export/default.nix b/overlays/katpkgs/personal/taskwarrior-export/default.nix new file mode 100644 index 00000000..e7375cb9 --- /dev/null +++ b/overlays/katpkgs/personal/taskwarrior-export/default.nix @@ -0,0 +1,14 @@ +{ stdenv, makeWrapper, perl, perlPackages }: + +stdenv.mkDerivation rec { + pname = "kat-tw-export"; + version = "0.0.1"; + src = ./tw.pl; + buildInputs = [ perl perlPackages.JSON ]; + nativeBuildInputs = [ makeWrapper ]; + unpackPhase = "true"; + installPhase = '' + install -Dm0755 $src $out/bin/kat-tw-export + wrapProgram $out/bin/kat-tw-export --set PERL5LIB $PERL5LIB + ''; +} diff --git a/overlays/katpkgs/personal/taskwarrior-export/tw.pl b/overlays/katpkgs/personal/taskwarrior-export/tw.pl new file mode 100644 index 00000000..853f24b5 --- /dev/null +++ b/overlays/katpkgs/personal/taskwarrior-export/tw.pl @@ -0,0 +1,90 @@ +#!/usr/bin/env perl +################################################################################ +## +## Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included +## in all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +## http://www.opensource.org/licenses/mit-license.php +## +################################################################################ + +use strict; +use warnings; + +# Give a nice error if the (non-standard) JSON module is not installed. +eval "use JSON"; +if ($@) +{ + print "Error: You need to install the JSON Perl module.\n"; + exit 1; +} + +# Use the taskwarrior 2.0+ export command to filter and return JSON +my $command = join (' ', ("env PATH='$ENV{PATH}' task rc.verbose=nothing rc.json.array=no export", @ARGV)); +if ($command =~ /No matches/) +{ + printf STDERR $command; + exit 1; +} + +# Generate output. +print "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n"; + +my $count = 0; +for my $task (split "\n", qx{$command}) +{ + ++$count; + my $data = from_json ($task); + + print " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n"; +} + +print " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
IDPriDescriptionProjectDue
", ($data->{'id'} || ''), "", ($data->{'priority'} || ''), "", ($data->{'description'} || ''), "", ($data->{'project'} || ''), "", ($data->{'due'} || ''), "
", $count, " matching tasks
\n", + " \n", + "\n"; + +exit 0; + +################################################################################ + diff --git a/overlays/katpkgs/personal/waybar-gpg/default.nix b/overlays/katpkgs/personal/waybar-gpg/default.nix new file mode 100644 index 00000000..072e4293 --- /dev/null +++ b/overlays/katpkgs/personal/waybar-gpg/default.nix @@ -0,0 +1,5 @@ +{ wrapShellScriptBin, pkgs }: + +wrapShellScriptBin "kat-gpg-status" ./kat-gpg-status.sh { + depsRuntimePath = with pkgs; [ coreutils gnupg ]; +} diff --git a/overlays/katpkgs/personal/waybar-gpg/kat-gpg-status.sh b/overlays/katpkgs/personal/waybar-gpg/kat-gpg-status.sh new file mode 100644 index 00000000..0a8fceec --- /dev/null +++ b/overlays/katpkgs/personal/waybar-gpg/kat-gpg-status.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eu +set -o pipefail + +if gpg --card-status &> /dev/null; then + user="$(gpg --card-status | grep 'Login data' | awk '{print $NF}')"; + status='{"text": "", "alt": "User: '"$user"'", "class": "enabled"}' +else + status='{"text": "", "alt": "No card is connected.", "class": "disabled"}' +fi + +echo $status diff --git a/overlays/katpkgs/personal/waybar-konawall/default.nix b/overlays/katpkgs/personal/waybar-konawall/default.nix new file mode 100644 index 00000000..729b3111 --- /dev/null +++ b/overlays/katpkgs/personal/waybar-konawall/default.nix @@ -0,0 +1,17 @@ +{ stdenv, wrapShellScriptBin, pkgs }: + +let + toggle = wrapShellScriptBin "konawall-toggle" ./toggle.sh { }; + status = wrapShellScriptBin "konawall-status" ./status.sh { }; +in +stdenv.mkDerivation { + pname = "konawall-toggle"; + version = "0.0.1"; + unpackPhase = "true"; + installPhase = '' + mkdir -p $out/bin + cp ${status}/bin/konawall-status $out/bin/konawall-status + cp ${toggle}/bin/konawall-toggle $out/bin/konawall-toggle + chmod +x $out/bin/konawall-{status,toggle} + ''; +} diff --git a/overlays/katpkgs/personal/waybar-konawall/status.sh b/overlays/katpkgs/personal/waybar-konawall/status.sh new file mode 100644 index 00000000..5e7c69a5 --- /dev/null +++ b/overlays/katpkgs/personal/waybar-konawall/status.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -eu +set -o pipefail + +sleep 0.5s + +if systemctl --user is-active konawall-rotation.timer --quiet; then + status='{"text": "", "alt": "Konawall is enabled.", "class": "enabled"}' +else + status='{"text": "", "alt": "Konawall is disabled.", "class": "disabled"}' +fi + +echo $status diff --git a/overlays/katpkgs/personal/waybar-konawall/toggle.sh b/overlays/katpkgs/personal/waybar-konawall/toggle.sh new file mode 100644 index 00000000..8bc58468 --- /dev/null +++ b/overlays/katpkgs/personal/waybar-konawall/toggle.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -eu +set -o pipefail + + +if systemctl --user is-active konawall-rotation.timer --quiet; then + systemctl --user stop konawall-rotation.timer +else + systemctl --user start konawall-rotation.timer +fi diff --git a/overlays/katpkgs/personal/win10-vm/default.nix b/overlays/katpkgs/personal/win10-vm/default.nix new file mode 100644 index 00000000..608390fa --- /dev/null +++ b/overlays/katpkgs/personal/win10-vm/default.nix @@ -0,0 +1,88 @@ +{ pkgs, writeShellScriptBin }: + +writeShellScriptBin "win10-vm" '' + cat ${pkgs.OVMF.fd}/FV/OVMF_VARS.fd > /tmp/OVMF_VARS.fd + ${pkgs.qemu-vfio}/bin/qemu-system-x86_64 -name guest=win10,debug-threads=on \ + -blockdev '{"driver":"file","filename":"${pkgs.OVMF.fd}/FV/OVMF_CODE.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \ + -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}' \ + -blockdev '{"driver":"file","filename":"/tmp/OVMF_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \ + -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \ + -machine pc-q35-5.1,accel=kvm,usb=off,vmport=off,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \ + -monitor stdio \ + -cpu host,migratable=on,topoext=on,hv-time,hv-relaxed,hv-vapic,hv-spinlocks=0x1fff,host-cache-info=on,l3-cache=off -m 12288 \ + -vcpu vcpunum=0,affinity=0 \ + -vcpu vcpunum=1,affinity=1 \ + -vcpu vcpunum=2,affinity=2 \ + -vcpu vcpunum=3,affinity=3 \ + -vcpu vcpunum=4,affinity=6 \ + -vcpu vcpunum=5,affinity=7 \ + -vcpu vcpunum=6,affinity=8 \ + -vcpu vcpunum=7,affinity=9 \ + -object memory-backend-ram,id=pc.ram,size=12884901888 -overcommit mem-lock=off \ + -smp 8,sockets=1,dies=1,cores=4,threads=2 \ + -object iothread,id=iothread1 -uuid 96052919-6a83-4e9f-8e9b-628de3e27cc1 \ + -display none \ + -no-user-config \ + -nodefaults \ + -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=delay \ + -no-hpet -no-shutdown \ + -global ICH9-LPC.disable_s3=1 \ + -global ICH9-LPC.disable_s4=1 \ + -boot strict=on \ + -device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ + -device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ + -device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ + -device pcie-root-port,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ + -device pcie-root-port,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ + -device pcie-root-port,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ + -device pcie-root-port,port=0x16,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x6 \ + -device pcie-pci-bridge,id=pci.8,bus=pci.4,addr=0x0 \ + -device pcie-root-port,port=0x17,chassis=9,id=pci.9,bus=pcie.0,addr=0x2.0x7 \ + -device pcie-root-port,port=0x8,chassis=10,id=pci.10,bus=pcie.0,multifunction=on,addr=0x1 \ + -device pcie-root-port,port=0xa,chassis=11,id=pci.11,bus=pcie.0,addr=0x1.0x1 \ + -device pcie-root-port,port=0xa,chassis=12,id=pci.12,bus=pcie.0,addr=0x1.0x2 \ + -device pcie-root-port,port=0xb,chassis=13,id=pci.13,bus=pcie.0,addr=0x1.0x3 \ + -device pcie-root-port,port=0xc,chassis=14,id=pci.14,bus=pcie.0,addr=0x1.0x4 \ + -device pcie-root-port,port=0xd,chassis=15,id=pci.15,bus=pcie.0,addr=0x1.0x5 \ + -device pcie-root-port,port=0xe,chassis=16,id=pci.16,bus=pcie.0,addr=0x1.0x6 \ + -device pcie-root-port,port=0xf,chassis=17,id=pci.17,bus=pcie.0,addr=0x1.0x7 \ + -device pcie-root-port,port=0x18,chassis=18,id=pci.18,bus=pcie.0,multifunction=on,addr=0x3 \ + -device pcie-root-port,port=0x19,chassis=19,id=pci.19,bus=pcie.0,addr=0x3.0x1 \ + -device pcie-root-port,port=0x1a,chassis=20,id=pci.20,bus=pcie.0,addr=0x3.0x2 \ + -device pcie-root-port,port=0x1b,chassis=21,id=pci.21,bus=pcie.0,addr=0x3.0x3 \ + -device pcie-root-port,port=0x1c,chassis=22,id=pci.22,bus=pcie.0,addr=0x3.0x4 \ + -device pcie-root-port,port=0x1d,chassis=23,id=pci.23,bus=pcie.0,multifunction=on,addr=0x3.0x5 \ + -device pcie-pci-bridge,id=pci.24,bus=pci.10,addr=0x0 \ + -device ich9-usb-ehci1,id=usb -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on -device ich9-usb-uhci2,masterbus=usb.0,firstport=2 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4 \ + -device qemu-xhci,id=usb3,p2=4,p3=8 \ + -device virtio-scsi-pci,id=scsi0,bus=pci.6,addr=0x0 \ + -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ + -device ich9-intel-hda,id=sound0 \ + -device hda-output,audiodev=pa1 \ + -device hda-micro,audiodev=pa1 \ + -audiodev pa,id=pa1,server=/run/user/1000/pulse/native,out.buffer-length=4000,timer-period=1000 \ + -blockdev '{"driver":"host_device","filename":"/dev/disk/by-id/ata-HFS256G32TNF-N3A0A_MJ8BN15091150BM1Z","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ + -blockdev '{"node-name":"libvirt-2-format","read-only":false,"discard":"unmap","driver":"raw","file":"libvirt-2-storage"}' \ + -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi0-0-0-0,drive=libvirt-2-format,id=scsi0-0-0-0,bootindex=2 \ + -blockdev '{"driver":"host_device","filename":"/dev/mapper/ata-ST2000DM008-2FR102_WK301C3H-part2","aio":"native","node-name":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},"auto-read-only":true,"discard":"unmap"}' \ + -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,device_id=drive-scsi0-0-0-1,drive=libvirt-1-format,id=scsi0-0-0-1,bootindex=3 \ + -blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"direct":true,"no-flush":false},"driver":"raw","file":"libvirt-1-storage"}' \ + -device virtio-net-pci,netdev=hostnet0,id=net0,mac=5b:f2:eb:3c:0b:46 \ + -netdev bridge,id=hostnet0,br=br,helper=$(type -P qemu-bridge-helper) \ + -netdev user,id=smbnet0,restrict=yes,net=10.1.2.0/24,host=10.1.2.1,smb=/home/kat/shared/,smbserver=10.1.2.2 \ + -device virtio-net-pci,netdev=smbnet0,id=net1,mac=2b:c6:c4:ac:67:ba \ + -device vfio-pci,host=0000:29:00.0,id=hostdev0,bus=pci.7,addr=0x0 \ + -device vfio-pci,host=0000:29:00.1,id=hostdev1,bus=pci.9,addr=0x0 \ + -device vfio-pci,host=0000:28:00.0,id=hostdev3,bus=pci.11,addr=0x0 \ + -device vfio-pci,host=0000:2b:00.3,id=hostdev4,bus=pci.19,addr=0x0 \ + -device virtio-balloon-pci,id=balloon0,bus=pci.5,addr=0x0 \ + -chardev socket,path=/tmp/vfio-qmp,server,nowait,id=qmp0 \ + -mon chardev=qmp0,id=qmp,mode=control \ + -chardev socket,path=/tmp/vfio-qga,server,nowait,id=qga0 \ + -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \ + -set device.scsi0-0-0-0.rotation_rate=1 \ + -cpu host,hv_time,kvm=off,hv_vendor_id=null,-hypervisor \ + -msg timestamp=on +'' + +# -device vfio-pci,host=0000:21:00.0,id,addr=0x0 \ diff --git a/overlays/katpkgs/public/akiflags/default.nix b/overlays/katpkgs/public/akiflags/default.nix new file mode 100644 index 00000000..62d2deb0 --- /dev/null +++ b/overlays/katpkgs/public/akiflags/default.nix @@ -0,0 +1,18 @@ +{ lib, stdenv, fetchurl, python36, installShellFiles }: + +stdenv.mkDerivation { + pname = "akiflags"; + version = "0.0.1"; + + buildInputs = [ + python36 + ]; + + unpackPhase = "true"; + + installPhase = '' + mkdir -p $out/bin + cp ${./flags.py} $out/bin/akiflags + chmod +x $out/bin/akiflags + ''; +} diff --git a/overlays/katpkgs/public/akiflags/flags.py b/overlays/katpkgs/public/akiflags/flags.py new file mode 100644 index 00000000..7e657cd0 --- /dev/null +++ b/overlays/katpkgs/public/akiflags/flags.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause + +flags = { + 'trans': [ + ('091', '206', '250'), + ('254', '169', '184'), + ('255', '255', '255'), + ('254', '169', '184'), + ('091', '206', '250'), + ], + 'lesbian': [ + ('213', '045', '000'), + ('255', '154', '086'), + ('255', '255', '255'), + ('211', '098', '164'), + ('163', '002', '098'), + ], + 'bi': [ + ('214', '002', '112'), + ('214', '002', '112'), + ('155', '079', '150'), + ('000', '056', '168'), + ('000', '056', '168'), + ], + 'enby': [ + ('252', '244', '052'), + ('252', '252', '252'), + ('156', '089', '209'), + ('044', '044', '044'), + ], + 'rainbow': [ + ('228', '003', '003'), + ('255', '140', '000'), + ('255', '237', '000'), + ('000', '128', '038'), + ('000', '077', '255'), + ('117', '007', '135'), + ], + 'ace': [ + ('044', '044', '044'), + ('163', '163', '163'), + ('255', '255', '255'), + ('128', '000', '128'), + ], + 'pan': [ + ('255', '033', '140'), + ('255', '033', '140'), + ('255', '216', '000'), + ('255', '216', '000'), + ('033', '177', '255'), + ('033', '177', '255'), + ] +} + + + + +def print_flag(flag, width = 18): + bar = '█' * width + flag_data = flags[flag] + flg_str = '' + + for c in flag_data: + flg_str += f'\x1b[38;2;{c[0]};{c[1]};{c[2]}m\x1b[48;2;{c[0]};{c[1]};{c[2]}m{bar}\x1b[0m\n' + + print(flg_str, end = '') + + + +if __name__ == '__main__': + import sys + from os import get_terminal_size + from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter + + parser = ArgumentParser( + formatter_class = ArgumentDefaultsHelpFormatter, + description = '24-bit color terminal pride flags' + ) + + display = parser.add_argument_group('Display Options') + + display.add_argument( + '--banner', '-b', + default = False, + action = 'store_true', + help = 'Print the flag the whole width of the terminal' + ) + + display.add_argument( + '--width', '-w', + default = 18, + type = int, + help = 'Width of the flag' + ) + + display.add_argument( + '--insert-break', '-B', + default = False, + action = 'store_true', + help = 'Insert a line break between flags' + ) + + parser.add_argument( + '--random', '-r', + default = False, + action = 'store_true', + help = 'Show a random pride flag' + ) + + parser.add_argument( + '--flags', '-f', + default = [], + choices = list(flags.keys()), + nargs = '+', + help = 'The flags which to display' + ) + + args = parser.parse_args() + + width = args.width + + if args.banner: + width = get_terminal_size().columns + + if not args.random: + if len(args.flags) == 0: + print('you must specify at least one flag or --random') + sys.exit(1) + + for flag in args.flags: + print_flag(flag, width = width) + if args.insert_break: + print('') + else: + import random + print_flag(random.choice(list(flags.keys())), width = width) + + sys.exit(0) diff --git a/overlays/katpkgs/public/default.nix b/overlays/katpkgs/public/default.nix new file mode 100644 index 00000000..5a9b900a --- /dev/null +++ b/overlays/katpkgs/public/default.nix @@ -0,0 +1,15 @@ +{ + akiflags = import ./akiflags; + + fusionpbx = import ./fusionpbx; + fusionpbx-apps = import ./fusionpbx-apps; + + fusionpbxWithApps = { symlinkJoin, fusionpbx, ... }: apps: symlinkJoin { + inherit (fusionpbx) version name; + paths = [ fusionpbx ] ++ apps; + }; + + libreelec-dvb-firmware = import ./libreelec-dvb-firmware/default.nix; + + yggdrasil-held = import ./yggdrasil; +} diff --git a/overlays/katpkgs/public/fusionpbx-apps/default.nix b/overlays/katpkgs/public/fusionpbx-apps/default.nix new file mode 100644 index 00000000..9064abe9 --- /dev/null +++ b/overlays/katpkgs/public/fusionpbx-apps/default.nix @@ -0,0 +1,79 @@ +{ lib +, stdenv +, fetchFromGitHub +}: + +stdenv.mkDerivation rec { + pname = "fusionpbx-apps"; + version = "master"; + + src = fetchFromGitHub { + owner = "fusionpbx"; + repo = pname; + rev = "c0eb1c852332a8ba3010e54cd1ac634c47f832fb"; + sha256 = "0gqlzzd2m2g2njxqr1kd7bcy3wi4irv7i5njqa8d8iiwwmnvbb4r"; + }; + + apps = [ + "active_extensions" + "backup" + "bdr" + "bulk_account_settings" + "bulk_import_extensions" + "call_acl" + "cdr" + "content" + "domain_counts" + "fifo_agents" + "get_call_details" + "help" + "invoices" + "languages" + "mobile_twinning" + "php_service" + "profiles" + "roku" + "schemas" + "school_bells" + "servers" + "services" + "sessiontalk" + "sipjs" + "sipml5" + "sms" + "soft_phone" + "tickets" + "users_bulk_add" + "voicemail_msgs" + "voicemail_status" + "webrtc" + "xmpp" + "zoiper" + ]; + + outputs = lib.singleton "out" ++ apps; + + postPatch = '' + mv mobile-twinning mobile_twinning + ''; + + installPhase = '' + mkdir $out + for app in $apps; do + mkdir -p ''${!app}/app + mv $app ''${!app}/app/ + if [[ -d ''${app}/resources/install/scripts/app ]]; then + mkdir -p ''${!app}/app/scripts/resources/scripts/app + ln -s ''${!app}/resources/install/scripts/app/* ''${!app}/app/scripts/resources/scripts/app/ + fi + done + ''; + + meta = with lib; { + description = "Applications for FusionPBX."; + homepage = "https://www.fusionpbx.com/"; + license = with licenses; mpl11; + maintainers = with maintainers; [ kittywitch ]; + platforms = with platforms; unix; + }; +} diff --git a/overlays/katpkgs/public/fusionpbx/default.nix b/overlays/katpkgs/public/fusionpbx/default.nix new file mode 100644 index 00000000..e16e7cba --- /dev/null +++ b/overlays/katpkgs/public/fusionpbx/default.nix @@ -0,0 +1,29 @@ +{ lib +, stdenv +, fetchFromGitHub +}: + +stdenv.mkDerivation rec { + pname = "fusionpbx"; + version = "master"; + + src = fetchFromGitHub { + owner = pname; + repo = pname; + rev = "2b8d011321ee5f2ffba967e38fcc8c542f378502"; + sha256 = "0fsmf67hrddz6aqjrjjqxa72iw108z2skwhn9jb3p465xfq7a9ij"; + }; + + installPhase = '' + mkdir -p $out + mv * $out + ''; + + meta = with lib; { + description = "A full-featured domain based multi-tenant PBX and voice switch for FreeSWITCH."; + homepage = "https://www.fusionpbx.com/"; + license = with licenses; mpl11; + maintainers = with maintainers; [ kittywitch ]; + platforms = with platforms; unix; + }; +} diff --git a/overlays/katpkgs/public/libreelec-dvb-firmware/default.nix b/overlays/katpkgs/public/libreelec-dvb-firmware/default.nix new file mode 100644 index 00000000..49c85242 --- /dev/null +++ b/overlays/katpkgs/public/libreelec-dvb-firmware/default.nix @@ -0,0 +1,26 @@ +{ stdenv, fetchFromGitHub, lib }: + +stdenv.mkDerivation rec { + name = "libreelec-fw-dvb"; + version = "1.4.2"; + + src = fetchFromGitHub { + repo = "dvb-firmware"; + owner = "LibreElec"; + rev = version; + sha256 = "1xnfl4gp6d81gpdp86v5xgcqiqz2nf1i43sb3a4i5jqs8kxcap2k"; + }; + + buildPhase = ""; + installPhase = '' + mkdir -p $out/lib + cp -rv firmware $out/lib/ + ''; + + meta = with lib; { + license = lib.licenses.unfreeRedistributableFirmware; + maintainers = with maintainers; [ kittywitch ]; + platforms = with platforms; linux; + }; +} + diff --git a/overlays/katpkgs/public/yggdrasil/change-runtime-dir.patch b/overlays/katpkgs/public/yggdrasil/change-runtime-dir.patch new file mode 100644 index 00000000..b4edc6a8 --- /dev/null +++ b/overlays/katpkgs/public/yggdrasil/change-runtime-dir.patch @@ -0,0 +1,12 @@ +diff -ruN a/src/defaults/defaults_linux.go b/src/defaults/defaults_linux.go +--- a/src/defaults/defaults_linux.go 2019-06-17 10:23:09.495613784 -0700 ++++ b/src/defaults/defaults_linux.go 2019-07-01 10:17:11.295669440 -0700 +@@ -7,7 +7,7 @@ + func GetDefaults() platformDefaultParameters { + return platformDefaultParameters{ + // Admin +- DefaultAdminListen: "unix:///var/run/yggdrasil.sock", ++ DefaultAdminListen: "unix:///var/run/yggdrasil/yggdrasil.sock", + + // Configuration (used for yggdrasilctl) + DefaultConfigFile: "/etc/yggdrasil.conf", diff --git a/overlays/katpkgs/public/yggdrasil/default.nix b/overlays/katpkgs/public/yggdrasil/default.nix new file mode 100644 index 00000000..8228132b --- /dev/null +++ b/overlays/katpkgs/public/yggdrasil/default.nix @@ -0,0 +1,41 @@ +{ lib, buildGoModule, fetchFromGitHub, nixosTests }: + +buildGoModule rec { + pname = "yggdrasil"; + version = "0.3.16"; + + src = fetchFromGitHub { + owner = "yggdrasil-network"; + repo = "yggdrasil-go"; + rev = "v${version}"; + sha256 = "sha256-uUF0zkgtzdMZB/GKOtawjn7AQBkRoiAEj9nUUmpQSVQ="; + }; + + vendorSha256 = "sha256-619PSqd7pl3Akj/kzLQhDIp1adumBGhLrzQsZvMzC7w="; + + doCheck = false; + + # Change the default location of the management socket on Linux + # systems so that the yggdrasil system service unit does not have to + # be granted write permission to /run. + patches = [ ./change-runtime-dir.patch ]; + + subPackages = [ "cmd/yggdrasil" "cmd/yggdrasilctl" ]; + + buildFlagsArray = '' + -ldflags= + -X github.com/yggdrasil-network/yggdrasil-go/src/version.buildVersion=${version} + -X github.com/yggdrasil-network/yggdrasil-go/src/version.buildName=${pname} + -s -w + ''; + + passthru.tests.basic = nixosTests.yggdrasil; + + meta = with lib; { + description = + "An experiment in scalable routing as an encrypted IPv6 overlay network"; + homepage = "https://yggdrasil-network.github.io/"; + license = licenses.lgpl3; + maintainers = with maintainers; [ ehmry gazally lassulus ]; + }; +}