summaryrefslogtreecommitdiffstats
path: root/tv
diff options
context:
space:
mode:
authorjeschli <jeschli@gmail.com>2019-01-29 19:17:43 +0100
committerjeschli <jeschli@gmail.com>2019-01-29 19:17:43 +0100
commit924c8fb748a92720c75750cee528ac2f4b7c5c8e (patch)
tree1a3b956f7f8527e533040cee1138810fe304bbc9 /tv
parent06b6454af78e8236a67d69cab94f62c32054be47 (diff)
parente64bbd8d6864e21f9e7b6b9a11cf95c976bdc109 (diff)
Merge branch 'master' of prism.r:stockholm
Diffstat (limited to 'tv')
-rw-r--r--tv/1systems/xu/config.nix6
-rw-r--r--tv/2configs/backup.nix4
-rw-r--r--tv/2configs/default.nix1
-rw-r--r--tv/2configs/gitrepos.nix3
-rw-r--r--tv/2configs/htop.nix2
-rw-r--r--tv/2configs/mail-client.nix17
-rw-r--r--tv/2configs/xserver/Xmodmap.nix1
-rw-r--r--tv/2configs/xserver/xkiller.nix14
-rw-r--r--tv/3modules/default.nix1
-rw-r--r--tv/3modules/ejabberd/default.nix2
-rw-r--r--tv/3modules/nixpkgs-overlays.nix23
-rw-r--r--tv/3modules/slock.nix20
-rw-r--r--tv/5pkgs/default.nix6
-rw-r--r--tv/5pkgs/simple/q/default.nix61
-rw-r--r--tv/5pkgs/simple/xkiller.nix25
15 files changed, 101 insertions, 85 deletions
diff --git a/tv/1systems/xu/config.nix b/tv/1systems/xu/config.nix
index b9c76cf49..33f9539c9 100644
--- a/tv/1systems/xu/config.nix
+++ b/tv/1systems/xu/config.nix
@@ -20,6 +20,7 @@ with import <stockholm/lib>;
<stockholm/tv/2configs/br.nix>
<stockholm/tv/2configs/xp-332.nix>
<stockholm/tv/2configs/xserver>
+ <stockholm/tv/2configs/xserver/xkiller.nix>
{
environment.systemPackages = with pkgs; [
@@ -156,10 +157,5 @@ with import <stockholm/lib>;
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "15.09";
- tv.nixpkgs-overlays = {
- krebs = "/home/tv/stockholm/krebs/5pkgs";
- tv = "/home/tv/stockholm/tv/5pkgs";
- };
-
virtualisation.virtualbox.host.enable = true;
}
diff --git a/tv/2configs/backup.nix b/tv/2configs/backup.nix
index f8de72d00..b8dec8da4 100644
--- a/tv/2configs/backup.nix
+++ b/tv/2configs/backup.nix
@@ -60,7 +60,7 @@ with import <stockholm/lib>;
};
xu-pull-ni-ejabberd = {
method = "pull";
- src = { host = config.krebs.hosts.ni; path = "/var/ejabberd"; };
+ src = { host = config.krebs.hosts.ni; path = "/var/lib/ejabberd"; };
dst = { host = config.krebs.hosts.xu; path = "/bku/ni-ejabberd"; };
startAt = "07:00";
};
@@ -78,7 +78,7 @@ with import <stockholm/lib>;
};
zu-pull-ni-ejabberd = {
method = "pull";
- src = { host = config.krebs.hosts.ni; path = "/var/ejabberd"; };
+ src = { host = config.krebs.hosts.ni; path = "/var/lib/ejabberd"; };
dst = { host = config.krebs.hosts.zu; path = "/bku/ni-ejabberd"; };
startAt = "06:00";
};
diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix
index 484a337b7..e18ba31b0 100644
--- a/tv/2configs/default.nix
+++ b/tv/2configs/default.nix
@@ -92,7 +92,6 @@ with import <stockholm/lib>;
environment.variables = {
NIX_PATH = mkForce (concatStringsSep ":" [
"secrets=/var/src/stockholm/null"
- "nixpkgs-overlays=${config.tv.nixpkgs-overlays}"
"/var/src"
]);
};
diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix
index a89d1302c..725ddefa8 100644
--- a/tv/2configs/gitrepos.nix
+++ b/tv/2configs/gitrepos.nix
@@ -67,10 +67,12 @@ let {
cgit.desc = "source code installer";
};
q = {};
+ reaktor2 = {};
regfish = {};
stockholm = {
cgit.desc = "NixOS configuration";
};
+ with-ssh = {};
} // mapAttrs (_: recursiveUpdate { cgit.section = "2. Host configurations"; }) {
ni = {
};
@@ -102,6 +104,7 @@ let {
nixos-infest = {};
painload = {};
push = {};
+ Reaktor = {};
with-tmpdir = {};
get = {};
load-env = {};
diff --git a/tv/2configs/htop.nix b/tv/2configs/htop.nix
index d7d2d7bfd..e78caeb5f 100644
--- a/tv/2configs/htop.nix
+++ b/tv/2configs/htop.nix
@@ -22,7 +22,7 @@ with import <stockholm/lib>;
highlight_megabytes=1
highlight_threads=1
tree_view=1
- header_margin=1
+ header_margin=0
detailed_cpu_time=0
cpu_count_from_zero=0
update_process_names=0
diff --git a/tv/2configs/mail-client.nix b/tv/2configs/mail-client.nix
index 8b6f8bbcd..0caf5264a 100644
--- a/tv/2configs/mail-client.nix
+++ b/tv/2configs/mail-client.nix
@@ -1,13 +1,10 @@
-{ pkgs, ... }:
-
-with pkgs;
-{
+{ pkgs, ... }: {
environment.systemPackages = [
- much
- msmtp
- notmuch
- pythonPackages.alot
- qprint
- w3m
+ pkgs.haskellPackages.much
+ pkgs.msmtp
+ pkgs.notmuch
+ pkgs.pythonPackages.alot
+ pkgs.qprint
+ pkgs.w3m
];
}
diff --git a/tv/2configs/xserver/Xmodmap.nix b/tv/2configs/xserver/Xmodmap.nix
index d2b1b2604..8e8e3dfdd 100644
--- a/tv/2configs/xserver/Xmodmap.nix
+++ b/tv/2configs/xserver/Xmodmap.nix
@@ -17,6 +17,7 @@ pkgs.writeText "Xmodmap" ''
keycode 39 = s S ssharp
keycode 33 = p P Greek_pi Greek_PI
+ keycode 40 = d D Greek_delta Greek_DELTA
keycode 46 = l L Greek_lambda Greek_LAMBDA
keycode 54 = c C cacute Cacute
diff --git a/tv/2configs/xserver/xkiller.nix b/tv/2configs/xserver/xkiller.nix
new file mode 100644
index 000000000..2f9763093
--- /dev/null
+++ b/tv/2configs/xserver/xkiller.nix
@@ -0,0 +1,14 @@
+{ pkgs, ... }: {
+
+ services.acpid.enable = true;
+ services.acpid.handlers.xkiller = {
+ action = /* sh */ ''
+ event=($1)
+ if test "''${event[2]}" = 00000080; then
+ ${pkgs.systemd}/bin/systemd-cat -t xkiller ${pkgs.xkiller}
+ fi
+ '';
+ event = "button/prog1";
+ };
+
+}
diff --git a/tv/3modules/default.nix b/tv/3modules/default.nix
index f53a58e9a..67fb3f650 100644
--- a/tv/3modules/default.nix
+++ b/tv/3modules/default.nix
@@ -5,7 +5,6 @@
./ejabberd
./hosts.nix
./iptables.nix
- ./nixpkgs-overlays.nix
./slock.nix
./x0vncserver.nix
];
diff --git a/tv/3modules/ejabberd/default.nix b/tv/3modules/ejabberd/default.nix
index e99b94ff9..f16dfac86 100644
--- a/tv/3modules/ejabberd/default.nix
+++ b/tv/3modules/ejabberd/default.nix
@@ -67,7 +67,7 @@ in {
type = types.user;
default = {
name = "ejabberd";
- home = "/var/ejabberd";
+ home = "/var/lib/ejabberd";
};
};
};
diff --git a/tv/3modules/nixpkgs-overlays.nix b/tv/3modules/nixpkgs-overlays.nix
deleted file mode 100644
index 4eb7a86bd..000000000
--- a/tv/3modules/nixpkgs-overlays.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-with import <stockholm/lib>;
-{ config, pkgs, ... }: {
-
- options.tv.nixpkgs-overlays = mkOption {
- apply = src:
- pkgs.runCommand "nixpkgs-overlays" {} ''
- mkdir $out
- ${concatStringsSep "\n" (mapAttrsToList (name: path:
- "ln -s ${shell.escape path} $out/${shell.escape name}"
- ) src)}
- '' // {
- inherit src;
- };
- type = types.attrsOf types.absolute-pathname;
- };
-
- config = {
- tv.nixpkgs-overlays = {
- krebs = mkDefault "/var/src/stockholm/krebs/5pkgs";
- tv = mkDefault "/var/src/stockholm/tv/5pkgs";
- };
- };
-}
diff --git a/tv/3modules/slock.nix b/tv/3modules/slock.nix
index 1c84b1e9e..53f7f1f62 100644
--- a/tv/3modules/slock.nix
+++ b/tv/3modules/slock.nix
@@ -5,10 +5,12 @@ in {
options.tv.slock = {
enable = mkEnableOption "tv.slock";
package = mkOption {
- default = pkgs.execBin "slock" rec {
- filename = "${pkgs.systemd}/bin/systemctl";
- argv = [ filename "start" "slock-${cfg.user.name}.service" ];
- };
+ default = pkgs.writeDashBin "slock" ''
+ set -efu
+ display=''${DISPLAY#:}
+ service=slock-$LOGNAME@$display.service
+ exec ${pkgs.systemd}/bin/systemctl start "$service"
+ '';
type = types.package;
};
user = mkOption {
@@ -18,16 +20,16 @@ in {
config = mkIf cfg.enable {
security.polkit.extraConfig = /* js */ ''
polkit.addRule(function(action, subject) {
- if (action.id == "org.freedesktop.systemd1.manage-units" &&
- action.lookup("unit") == "slock-${cfg.user.name}.service" &&
- subject.user == ${toJSON cfg.user.name}) {
+ if (action.id === "org.freedesktop.systemd1.manage-units" &&
+ subject.user === ${toJSON cfg.user.name} &&
+ /^slock-${cfg.user.name}@[0-9]+\.service$/.test(action.lookup("unit")) ) {
return polkit.Result.YES;
}
});
'';
- systemd.services."slock-${cfg.user.name}" = {
+ systemd.services."slock-${cfg.user.name}@" = {
environment = {
- DISPLAY = ":${toString config.services.xserver.display}";
+ DISPLAY = ":%I";
LD_PRELOAD = pkgs.runCommandCC "slock-${cfg.user.name}.so" {
passAsFile = ["text"];
text = /* c */ ''
diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix
index c5c800b55..605d827ef 100644
--- a/tv/5pkgs/default.nix
+++ b/tv/5pkgs/default.nix
@@ -24,6 +24,12 @@ foldl' mergeAttrs {}
"$@"
'';
+ dhcpcd = overrideDerivation super.dhcpcd (old: {
+ configureFlags = old.configureFlags ++ [
+ "--dbdir=/var/lib/dhcpcd"
+ ];
+ });
+
gitAndTools = super.gitAndTools // {
inherit (self) diff-so-fancy;
};
diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix
index cbcec1bae..7906b968f 100644
--- a/tv/5pkgs/simple/q/default.nix
+++ b/tv/5pkgs/simple/q/default.nix
@@ -14,7 +14,7 @@ let
assert n >= 1;
n * calwidth + (n - 1) * hspace;
- pad = ''{
+ pad = /* sh */ ''{
${pkgs.gnused}/bin/sed '
# rtrim
s/ *$//
@@ -31,7 +31,7 @@ let
s/^[ 1-9][0-9]/&/
'
}'';
- in ''
+ in /* sh */ ''
cols=$(${pkgs.ncurses}/bin/tput cols)
${pkgs.coreutils}/bin/paste \
<(if test $cols -ge ${toString (need_width 3)}; then
@@ -59,24 +59,24 @@ let
'
'';
- q-isodate = ''
+ q-isodate = /* sh */ ''
${pkgs.coreutils}/bin/date \
'+%Y-%m-%dT%H:%M:%S%:z'
'';
# Singapore's red is #ED2E38
- q-sgtdate = ''
+ q-sgtdate = /* sh */ ''
TZ=Asia/Singapore \
${pkgs.coreutils}/bin/date \
'+%Y-%m-%dT%H:%M:%S%:z'
'';
- q-utcdate = ''
+ q-utcdate = /* sh */ ''
${pkgs.coreutils}/bin/date -u \
'+%Y-%m-%dT%H:%M:%S%:z'
'';
- q-gitdir = ''
+ q-gitdir = /* sh */ ''
if test -d .git; then
#git status --porcelain
branch=$(
@@ -87,7 +87,7 @@ let
fi
'';
- q-intel_backlight = ''
+ q-intel_backlight = /* sh */ ''
cd /sys/class/backlight/intel_backlight
</dev/null exec ${pkgs.gawk}/bin/awk '
END {
@@ -227,11 +227,11 @@ let
done
'';
- q-virtualization = ''
+ q-virtualization = /* sh */ ''
echo "VT: $(${pkgs.systemd}/bin/systemd-detect-virt)"
'';
- q-wireless = ''
+ q-wireless = /* sh */ ''
for dev in $(
${pkgs.iw}/bin/iw dev \
| ${pkgs.gnused}/bin/sed -n 's/^\s*Interface\s\+\([0-9a-z]\+\)$/\1/p'
@@ -250,7 +250,7 @@ let
done
'';
- q-online = ''
+ q-online = /* sh */ ''
if ${pkgs.curl}/bin/curl -s google.com >/dev/null; then
echo 'online'
else
@@ -258,7 +258,7 @@ let
fi
'';
- q-thermal_zone = ''
+ q-thermal_zone = /* sh */ ''
for i in /sys/class/thermal/thermal_zone*; do
type=$(${pkgs.coreutils}/bin/cat $i/type)
temp=$(${pkgs.coreutils}/bin/cat $i/temp)
@@ -266,29 +266,26 @@ let
done
'';
- q-todo = ''
+ q-todo = /* sh */ ''
TODO_file=$PWD/TODO
if test -e "$TODO_file"; then
- ${pkgs.coreutils}/bin/cat "$TODO_file" \
- | ${pkgs.gawk}/bin/gawk -v now=$(${pkgs.coreutils}/bin/date +%s) '
- BEGIN { print "remind=0" }
- /^[0-9]/{
- x = $1
- gsub(".", "\\\\&", x)
- rest = substr($0, index($0, " "))
- rest = $0
- sub(" *", "", rest)
- gsub(".", "\\\\&", rest)
- print "test $(${pkgs.coreutils}/bin/date +%s -d"x") -lt "now" && \
- echo \"\x1b[38;5;208m\""rest esc "\"\x1b[m\" && \
- (( remind++ ))"
- }
- END { print "test $remind = 0 && echo \"nothing to remind\"" }
- ' \
- | {
- # bash needed for (( ... ))
- ${pkgs.bash}/bin/bash
- }
+ ${pkgs.jq}/bin/jq -Rrs <"$TODO_file" -f ${pkgs.writeJq "q-todo.jq" ''
+ split("\n") | map(
+ (match("^([0-9]+-\\d{2}-\\d{2})\\s+(.*)$").captures | map(.string))
+ as $captures |
+ ($captures[0] | strptime("%Y-%m-%d") | mktime) as $date |
+ $captures[1] as $text |
+
+ select(now >= $date) |
+
+ ($text | test("\\[URGENT]"; "i")) as $urgent |
+ (if $urgent then "38;5;196" else "38;5;208" end) as $sgr |
+ if $urgent then sub("\\s*\\[URGENT]\\s*"; " "; "i") else . end |
+
+ "\u001b[\($sgr)m\(.)\u001b[m"
+ ) |
+ if length == 0 then "nothing to remind" else .[] end
+ ''}
else
echo "$TODO_file: no such file or directory"
fi
diff --git a/tv/5pkgs/simple/xkiller.nix b/tv/5pkgs/simple/xkiller.nix
new file mode 100644
index 000000000..8d8f01690
--- /dev/null
+++ b/tv/5pkgs/simple/xkiller.nix
@@ -0,0 +1,25 @@
+{ pkgs }:
+pkgs.writeDash "xkiller" ''
+ set -efu
+ exec >&2
+ ${pkgs.iproute}/bin/ss -lp src unix:/tmp/.X11-unix/X* |
+ ${pkgs.gnused}/bin/sed -n '
+ s|.*/tmp/.X11-unix/X\([0-9]\+\)\>.*("X[^"]*",pid=\([0-9]\+\)\>.*|\1 \2|p
+ ' |
+ while read -r display pid; do
+ {
+ exit_code=$(
+ DISPLAY=:$display ${pkgs.coreutils}/bin/timeout 1 \
+ ${pkgs.xorg.xset}/bin/xset q >/dev/null 2>&1 &&
+ echo 0 || echo $?
+ )
+ if test $exit_code = 124; then
+ echo "X on display :$display is locked up; killing PID $pid..."
+ ${pkgs.coreutils}/bin/kill -SIGKILL "$pid"
+ else
+ echo "X on display :$display is healthy"
+ fi
+ } &
+ done
+ wait
+''