From 4aa2f9de3d40020c2e93efa942c76c4416d79fb0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 17 Oct 2015 20:11:00 +0200 Subject: [PATCH 01/71] l 2 desktop-base: add push pkg --- lass/2configs/desktop-base.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lass/2configs/desktop-base.nix b/lass/2configs/desktop-base.nix index 4e693997d..27aadb590 100644 --- a/lass/2configs/desktop-base.nix +++ b/lass/2configs/desktop-base.nix @@ -30,6 +30,7 @@ in { powertop sxiv much + push #window manager stuff haskellPackages.xmobar From 1022e82c0d71ecb072c60f16bfc6475c23bcc3e4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 17 Oct 2015 20:11:43 +0200 Subject: [PATCH 02/71] l 5 newsbot-js: cd32ef7 -> b227296 --- lass/5pkgs/newsbot-js/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lass/5pkgs/newsbot-js/default.nix b/lass/5pkgs/newsbot-js/default.nix index 7758b04db..ace2a976f 100644 --- a/lass/5pkgs/newsbot-js/default.nix +++ b/lass/5pkgs/newsbot-js/default.nix @@ -26,8 +26,8 @@ in nodePackages.buildNodePackage { src = fetchgit { url = "http://cgit.echelon/newsbot-js/"; - rev = "cd32ef7b39819f53c7125b22c594202724cc8754"; - sha256 = "425e800f7638a5679ed8a049614a7533f3c8dd09659061885240dc93952ff0ae"; + rev = "b22729670236bfa6491207d57c5d7565137625ca"; + sha256 = "8ff00de56d85543399776c82d41d92ccc68000e5dce0f008d926748e188f3c69"; }; phases = [ From b4326e31444e1dab51d7c4469f43d37dab2d73d5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 18 Oct 2015 01:05:49 +0200 Subject: [PATCH 03/71] krebs 4 infest: umount /mnt/boot prior to /boot --- krebs/4lib/infest/finalize.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/4lib/infest/finalize.sh b/krebs/4lib/infest/finalize.sh index 0039960c5..94b13e0be 100644 --- a/krebs/4lib/infest/finalize.sh +++ b/krebs/4lib/infest/finalize.sh @@ -3,8 +3,8 @@ set -eux { umount /mnt/nix umount /mnt/root - umount /boot || : umount /mnt/boot + umount /boot || : umount /mnt coreutils_path=$(set +f; for i in /nix/store/*coreutils*/bin; do :; done; echo $i) From c3a1bca74c1d7f6e598918a8fb52c192c38999d6 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 18 Oct 2015 04:12:51 +0200 Subject: [PATCH 04/71] krebs 4 infest: add compatibility for centos 6.5 --- krebs/4lib/infest/prepare.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/krebs/4lib/infest/prepare.sh b/krebs/4lib/infest/prepare.sh index 9fbd5be86..94c9b0fb5 100644 --- a/krebs/4lib/infest/prepare.sh +++ b/krebs/4lib/infest/prepare.sh @@ -18,6 +18,13 @@ prepare() {( esac ;; esac + elif test -e /etc/centos-release; then + case $(cat /etc/centos-release) in + 'CentOS release 6.5 (Final)') + prepare_centos "$@" + exit + ;; + esac fi echo "$0 prepare: unknown OS" >&2 exit -1 From b5316b0458f30fb38600fba2ca74bdd16ac7dce6 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 18 Oct 2015 04:24:39 +0200 Subject: [PATCH 05/71] lass 2 os-templatex: add cac centos 6.5 template --- .../os-templates/CAC-CentOS-6.5-64bit.nix | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lass/2configs/os-templates/CAC-CentOS-6.5-64bit.nix diff --git a/lass/2configs/os-templates/CAC-CentOS-6.5-64bit.nix b/lass/2configs/os-templates/CAC-CentOS-6.5-64bit.nix new file mode 100644 index 000000000..b5ec722a0 --- /dev/null +++ b/lass/2configs/os-templates/CAC-CentOS-6.5-64bit.nix @@ -0,0 +1,47 @@ +_: + +{ + boot.loader.grub = { + device = "/dev/sda"; + splashImage = null; + }; + + boot.initrd.availableKernelModules = [ + "ata_piix" + "vmw_pvscsi" + ]; + + fileSystems."/" = { + device = "/dev/VolGroup/lv_root"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/sda1"; + fsType = "ext4"; + }; + + swapDevices = [ + { device = "/dev/VolGroup/lv_swap"; } + ]; + + users.extraGroups = { + # ● systemd-tmpfiles-setup.service - Create Volatile Files and Directories + # Loaded: loaded (/nix/store/2l33gg7nmncqkpysq9f5fxyhlw6ncm2j-systemd-217/example/systemd/system/systemd-tmpfiles-setup.service) + # Active: failed (Result: exit-code) since Mon 2015-03-16 10:29:18 UTC; 4s ago + # Docs: man:tmpfiles.d(5) + # man:systemd-tmpfiles(8) + # Process: 19272 ExecStart=/nix/store/2l33gg7nmncqkpysq9f5fxyhlw6ncm2j-systemd-217/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev (code=exited, status=1/FAILURE) + # Main PID: 19272 (code=exited, status=1/FAILURE) + # + # Mar 16 10:29:17 cd systemd-tmpfiles[19272]: [/usr/lib/tmpfiles.d/legacy.conf:26] Unknown group 'lock'. + # Mar 16 10:29:18 cd systemd-tmpfiles[19272]: Two or more conflicting lines for /var/log/journal configured, ignoring. + # Mar 16 10:29:18 cd systemd-tmpfiles[19272]: Two or more conflicting lines for /var/log/journal/7b35116927d74ea58785e00b47ac0f0d configured, ignoring. + # Mar 16 10:29:18 cd systemd[1]: systemd-tmpfiles-setup.service: main process exited, code=exited, status=1/FAILURE + # Mar 16 10:29:18 cd systemd[1]: Failed to start Create Volatile Files and Directories. + # Mar 16 10:29:18 cd systemd[1]: Unit systemd-tmpfiles-setup.service entered failed state. + # Mar 16 10:29:18 cd systemd[1]: systemd-tmpfiles-setup.service failed. + # warning: error(s) occured while switching to the new configuration + lock.gid = 10001; + }; +} From 2e4573d2dd9f69da1dbd40c41ee70615171abebe Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 18 Oct 2015 04:25:26 +0200 Subject: [PATCH 06/71] lass 3: add newsbot-js.nix --- lass/3modules/newsbot-js.nix | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 lass/3modules/newsbot-js.nix diff --git a/lass/3modules/newsbot-js.nix b/lass/3modules/newsbot-js.nix new file mode 100644 index 000000000..6d87d256d --- /dev/null +++ b/lass/3modules/newsbot-js.nix @@ -0,0 +1,87 @@ +{ config, lib, pkgs, ... }: + +with builtins; +with lib; + +let + cfg = config.lass.newsbot-js; + + out = { + options.lass.newsbot-js = api; + config = mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "Enable krebs newsbot"; + ircServer = mkOption { + type = types.str; + default = "echelon.retiolum"; + description = "to which server the bot should connect"; + }; + channel = mkOption { + type = types.str; + default = "#news"; + description = "post the news in this channel"; + }; + masterNick = mkOption { + type = types.str; + default = "knews"; + description = "nickname of the master bot"; + }; + feeds = mkOption { + type = types.path; + description = '' + file with feeds to post + format: + $nick|$feedURI + ''; + }; + urlShortenerHost = mkOption { + type = types.str; + default = "echelon"; + description = "what server to use for url shortening, host"; + }; + urlShortenerPort = mkOption { + type = types.str; + default = "80"; + description = "what server to use for url shortening, port"; + }; + }; + + imp = { + users.extraUsers.newsbot-js = { + name = "newsbot-js"; + uid = 1616759810; #genid newsbot-js + description = "newsbot-js user"; + home = "/var/empty"; + }; + + systemd.services.newsbot-js = { + description = "krebs newsbot"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + path = with pkgs; [ + newsbot-js + ]; + + environment = { + irc_server = cfg.ircServer; + master_nick = cfg.masterNick; + news_channel = cfg.channel; + feeds_file = cfg.feeds; + url_shortener_host = cfg.urlShortenerHost; + url_shortener_port = cfg.urlShortenerPort; + }; + + restartIfChanged = true; + + serviceConfig = { + User = "newsbot-js"; + Restart = "always"; + ExecStart = "${pkgs.newsbot-js}/bin/newsbot"; + }; + }; + }; + +in out From ffef87c5dfc7cf6443bbef2fcc6661a06365e098 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 18 Oct 2015 17:50:54 +0200 Subject: [PATCH 07/71] l: specify krebs.hosts.*.nets.gg23 --- krebs/3modules/lass/default.nix | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index afedf95f2..5c48d9642 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -104,7 +104,11 @@ with import ../../4lib { inherit lib; }; uriel = { cores = 1; dc = "lass"; - nets = rec { + nets = { + gg23 = { + addrs4 = ["10.23.1.12"]; + aliases = ["uriel.gg23"]; + }; retiolum = { addrs4 = ["10.243.81.176"]; addrs6 = ["42:dc25:60cf:94ef:759b:d2b6:98a9:2e56"]; @@ -131,7 +135,11 @@ with import ../../4lib { inherit lib; }; mors = { cores = 2; dc = "lass"; - nets = rec { + nets = { + gg23 = { + addrs4 = ["10.23.1.11"]; + aliases = ["mors.gg23"]; + }; retiolum = { addrs4 = ["10.243.0.2"]; addrs6 = ["42:0:0:0:0:0:0:dea7"]; @@ -155,6 +163,22 @@ with import ../../4lib { inherit lib; }; ssh.privkey.path = ; ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINAMPlIG+6u75GJ3kvsPF6OoIZsU+u8ZQ+rdviv5fNMD"; }; + schnabel-ap = { + nets = { + gg23 = { + addrs4 = ["10.23.1.20"]; + aliases = ["schnabel-ap.gg23"]; + }; + }; + }; + Reichsfunk-ap = { + nets = { + gg23 = { + addrs4 = ["10.23.1.10"]; + aliases = ["Reichsfunk-ap.gg23"]; + }; + }; + }; }; users = addNames { From 21b4d9ac2e14315a2c83ea9a2331dfe4baf3a913 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 13:01:07 +0200 Subject: [PATCH 08/71] lass: remove obsolete sshkeys.nix --- lass/2configs/sshkeys.nix | 11 ----------- lass/3modules/sshkeys.nix | 26 -------------------------- 2 files changed, 37 deletions(-) delete mode 100644 lass/2configs/sshkeys.nix delete mode 100644 lass/3modules/sshkeys.nix diff --git a/lass/2configs/sshkeys.nix b/lass/2configs/sshkeys.nix deleted file mode 100644 index f6081cf37..000000000 --- a/lass/2configs/sshkeys.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, ... }: - -{ - imports = [ - ../3modules/sshkeys.nix - ]; - - config.sshKeys.lass.pub = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAp83zynhIueJJsWlSEykVSBrrgBFKq38+vT8bRfa+csqyjZBl2SQFuCPo+Qbh49mwchpZRshBa9jQEIGqmXxv/PYdfBFQuOFgyUq9ZcTZUXqeynicg/SyOYFW86iiqYralIAkuGPfQ4howLPVyjTZtWeEeeEttom6p6LMY5Aumjz2em0FG0n9rRFY2fBzrdYAgk9C0N6ojCs/Gzknk9SGntA96MDqHJ1HXWFMfmwOLCnxtE5TY30MqSmkrJb7Fsejwjoqoe9Y/mCaR0LpG2cStC1+37GbHJNH0caCMaQCX8qdfgMVbWTVeFWtV6aWOaRgwLrPDYn4cHWQJqTfhtPrNQ== lass@mors"; - - config.sshKeys.uriel.pub = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDExWuRcltGM2FqXO695nm6/QY3wU3r1bDTyCpMrLfUSym7TxcXDSmZSWcueexPXV6GENuUfjJPZswOdWqIo5u2AXw9t0aGvwEDmI6uJ7K5nzQOsXIneGMdYuoOaAzWI8pxZ4N+lIP1HsOYttIPDp8RwU6kyG+Ud8mnVHWSTO13C7xC9vePnDP6b+44nHS691Zj3X/Cq35Ls0ISC3EM17jreucdP62L3TKk2R4NCm3Sjqj+OYEv0LAqIpgqSw5FypTYQgNByxRcIcNDlri63Q1yVftUP1338UiUfxtraUu6cqa2CdsHQmtX5mTNWEluVWO3uUKTz9zla3rShC+d3qvr lass@uriel"; -} diff --git a/lass/3modules/sshkeys.nix b/lass/3modules/sshkeys.nix deleted file mode 100644 index 5f1c60668..000000000 --- a/lass/3modules/sshkeys.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ lib, ... }: - -with lib; - -{ - options = { - sshKeys = mkOption { - type = types.attrsOf (types.submodule ( - { config, ... }: - { - options = { - pub = mkOption { - type = types.str; - description = "Public part of the ssh key."; - }; - - priv = mkOption { - type = types.str; - description = "Private part of the ssh key."; - }; - }; - })); - description = "collection of ssh-keys"; - }; - }; -} From 3384165fcf31d0afa2e47b784b409ec6345f1ebc Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 13:31:06 +0200 Subject: [PATCH 09/71] l: import urxvt in desktop-base.nix --- lass/1systems/mors.nix | 2 -- lass/1systems/uriel.nix | 1 - lass/2configs/desktop-base.nix | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index 7076c8b14..05efea472 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -10,7 +10,6 @@ ../2configs/pass.nix ../2configs/virtualbox.nix ../2configs/elster.nix - ../2configs/urxvt.nix ../2configs/steam.nix ../2configs/wine.nix ../2configs/texlive.nix @@ -18,7 +17,6 @@ #../2configs/ircd.nix ../2configs/chromium-patched.nix ../2configs/git.nix - #../../2configs/tv/synaptics.nix ../2configs/retiolum.nix ../2configs/wordpress.nix ../2configs/bitlbee.nix diff --git a/lass/1systems/uriel.nix b/lass/1systems/uriel.nix index 62338d054..2b36912e5 100644 --- a/lass/1systems/uriel.nix +++ b/lass/1systems/uriel.nix @@ -7,7 +7,6 @@ with builtins; ../2configs/browsers.nix ../2configs/games.nix ../2configs/pass.nix - ../2configs/urxvt.nix ../2configs/bird.nix ../2configs/git.nix ../2configs/chromium-patched.nix diff --git a/lass/2configs/desktop-base.nix b/lass/2configs/desktop-base.nix index 27aadb590..1f5c3de55 100644 --- a/lass/2configs/desktop-base.nix +++ b/lass/2configs/desktop-base.nix @@ -5,6 +5,7 @@ let in { imports = [ ./base.nix + ./urxvt.nix ]; time.timeZone = "Europe/Berlin"; From c52c48366eae0b06aa51a3f6d2cc85b34ba680c9 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 13:57:42 +0200 Subject: [PATCH 10/71] l 2: rename desktop-base.nix to baseX.nix --- lass/1systems/mors.nix | 2 +- lass/1systems/uriel.nix | 2 +- lass/2configs/{desktop-base.nix => baseX.nix} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename lass/2configs/{desktop-base.nix => baseX.nix} (100%) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index 05efea472..a21518e14 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -2,7 +2,7 @@ { imports = [ - ../2configs/desktop-base.nix + ../2configs/baseX.nix ../2configs/programs.nix ../2configs/bitcoin.nix ../2configs/browsers.nix diff --git a/lass/1systems/uriel.nix b/lass/1systems/uriel.nix index 2b36912e5..d18559779 100644 --- a/lass/1systems/uriel.nix +++ b/lass/1systems/uriel.nix @@ -3,7 +3,7 @@ with builtins; { imports = [ - ../2configs/desktop-base.nix + ../2configs/baseX.nix ../2configs/browsers.nix ../2configs/games.nix ../2configs/pass.nix diff --git a/lass/2configs/desktop-base.nix b/lass/2configs/baseX.nix similarity index 100% rename from lass/2configs/desktop-base.nix rename to lass/2configs/baseX.nix From 35b476288acce3810bb3ccba0a43dca3ebc094b5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 13:58:40 +0200 Subject: [PATCH 11/71] l 1 cloudkrebs: remove dic --- lass/1systems/cloudkrebs.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lass/1systems/cloudkrebs.nix b/lass/1systems/cloudkrebs.nix index 17915e087..f3e039433 100644 --- a/lass/1systems/cloudkrebs.nix +++ b/lass/1systems/cloudkrebs.nix @@ -49,8 +49,4 @@ in { networking.hostName = "cloudkrebs"; - environment.systemPackages = [ - pkgs.dic - ]; - } From 1d4f2bf01131d90e370bb8da2d5023aeaacf0b1d Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 14:00:15 +0200 Subject: [PATCH 12/71] l: move more config to base.nix --- lass/1systems/cloudkrebs.nix | 19 +------------------ lass/1systems/echelon.nix | 19 +------------------ lass/1systems/mors.nix | 18 +----------------- lass/1systems/uriel.nix | 19 +------------------ lass/2configs/base.nix | 22 ++++++++++++++++++---- 5 files changed, 22 insertions(+), 75 deletions(-) diff --git a/lass/1systems/cloudkrebs.nix b/lass/1systems/cloudkrebs.nix index f3e039433..ab24b584b 100644 --- a/lass/1systems/cloudkrebs.nix +++ b/lass/1systems/cloudkrebs.nix @@ -27,26 +27,9 @@ in { } { - nix.maxJobs = 1; sound.enable = false; } ]; - krebs.build = { - user = config.krebs.users.lass; - host = config.krebs.hosts.cloudkrebs; - source = { - dir.secrets = { - host = config.krebs.hosts.mors; - path = "/home/lass/secrets/${config.krebs.build.host.name}"; - }; - dir.stockholm = { - host = config.krebs.hosts.mors; - path = "/home/lass/dev/stockholm"; - }; - }; - }; - - networking.hostName = "cloudkrebs"; - + krebs.build.host = config.krebs.hosts.cloudkrebs; } diff --git a/lass/1systems/echelon.nix b/lass/1systems/echelon.nix index feaf77ef6..80cb51060 100644 --- a/lass/1systems/echelon.nix +++ b/lass/1systems/echelon.nix @@ -31,26 +31,9 @@ in { } { - nix.maxJobs = 1; sound.enable = false; } ]; - krebs.build = { - user = config.krebs.users.lass; - host = config.krebs.hosts.echelon; - source = { - dir.secrets = { - host = config.krebs.hosts.mors; - path = "/home/lass/secrets/${config.krebs.build.host.name}"; - }; - dir.stockholm = { - host = config.krebs.hosts.mors; - path = "/home/lass/dev/stockholm"; - }; - }; - }; - - networking.hostName = config.krebs.build.host.name; - + krebs.build.host = config.krebs.hosts.echelon; } diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index a21518e14..fcdabed40 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -24,22 +24,8 @@ ../2configs/skype.nix ]; - krebs.build = { - user = config.krebs.users.lass; - host = config.krebs.hosts.mors; - source = { - dir.secrets = { - host = config.krebs.hosts.mors; - path = "/home/lass/secrets/${config.krebs.build.host.name}"; - }; - dir.stockholm = { - host = config.krebs.hosts.mors; - path = "/home/lass/dev/stockholm"; - }; - }; - }; + krebs.build.host = config.krebs.hosts.mors; - networking.hostName = "mors"; networking.wireless.enable = true; networking.extraHosts = '' @@ -50,8 +36,6 @@ 10.243.206.102 apanowicz.de ''; - nix.maxJobs = 4; - hardware.enableAllFirmware = true; nixpkgs.config.allowUnfree = true; diff --git a/lass/1systems/uriel.nix b/lass/1systems/uriel.nix index d18559779..3514459fd 100644 --- a/lass/1systems/uriel.nix +++ b/lass/1systems/uriel.nix @@ -24,26 +24,9 @@ with builtins; } ]; - krebs.build = { - user = config.krebs.users.lass; - target = "root@uriel"; - host = config.krebs.hosts.uriel; - source = { - dir.secrets = { - host = config.krebs.hosts.mors; - path = "/home/lass/secrets/${config.krebs.build.host.name}"; - }; - dir.stockholm = { - host = config.krebs.hosts.mors; - path = "/home/lass/dev/stockholm"; - }; - }; - }; - - networking.hostName = "uriel"; + krebs.build.host = config.krebs.hosts.uriel; networking.wireless.enable = true; - nix.maxJobs = 2; hardware.enableAllFirmware = true; nixpkgs.config.allowUnfree = true; diff --git a/lass/2configs/base.nix b/lass/2configs/base.nix index f313054d9..2e42f86ae 100644 --- a/lass/2configs/base.nix +++ b/lass/2configs/base.nix @@ -38,14 +38,28 @@ with lib; } ]; + networking.hostName = config.krebs.build.host.name; + nix.maxJobs = config.krebs.build.host.cores; + krebs = { enable = true; search-domain = "retiolum"; exim-retiolum.enable = true; - build.source = { - git.nixpkgs = { - url = https://github.com/Lassulus/nixpkgs; - rev = "b9270a2e8ac3d2cf4c95075a9529528aa1d859da"; + build = { + user = config.krebs.users.lass; + source = { + git.nixpkgs = { + url = https://github.com/Lassulus/nixpkgs; + rev = "b9270a2e8ac3d2cf4c95075a9529528aa1d859da"; + }; + dir.secrets = { + host = config.krebs.hosts.mors; + path = "/home/lass/secrets/${config.krebs.build.host.name}"; + }; + dir.stockholm = { + host = config.krebs.hosts.mors; + path = "/home/lass/stockholm"; + }; }; }; }; From cd237e5f45a6fe0e155dec9cfa9a63d63c0f7b00 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 14:01:30 +0200 Subject: [PATCH 13/71] l 1: remove dead code --- lass/1systems/mors.nix | 5 ----- lass/1systems/uriel.nix | 6 ------ 2 files changed, 11 deletions(-) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index fcdabed40..190ddb799 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -141,11 +141,6 @@ emulateWheel = true; }; - #system.activationScripts.trackpoint = '' - # echo 0 > '/sys/devices/platform/i8042/serio1/serio2/speed' - # echo 220 > '/sys/devices/platform/i8042/serio1/serio2/sensitivity' - #''; - services.xserver = { videoDriver = "intel"; vaapiDrivers = [ pkgs.vaapiIntel ]; diff --git a/lass/1systems/uriel.nix b/lass/1systems/uriel.nix index 3514459fd..2565f4c09 100644 --- a/lass/1systems/uriel.nix +++ b/lass/1systems/uriel.nix @@ -47,8 +47,6 @@ with builtins; initrd.availableKernelModules = [ "xhci_hcd" "ehci_pci" "ahci" "usb_storage" ]; #kernelModules = [ "kvm-intel" "msr" ]; kernelModules = [ "msr" ]; - extraModprobeConfig = '' - ''; }; fileSystems = { "/" = { @@ -75,10 +73,6 @@ with builtins; Option "FingerLow" "60" ''; }; - - environment.systemPackages = with pkgs; [ - ]; - #for google hangout users.extraUsers.google.extraGroups = [ "audio" "video" ]; From d5096084d0ed25861309501d0f6c6730117f8713 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 14:02:17 +0200 Subject: [PATCH 14/71] l 1 mors: configure touchpad --- lass/1systems/mors.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index 190ddb799..0e7ed7c62 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -187,9 +187,16 @@ ]; }; }; + #touchpad config services.xserver.synaptics = { enable = true; + accelFactor = "0.035"; + additionalOptions = '' + Option "FingerHigh" "60" + Option "FingerLow" "60" + ''; tapButtons = false; + twoFingerScroll = true; }; } From bb713845190d558d52ab29327055530e73345340 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 14:02:38 +0200 Subject: [PATCH 15/71] l 1 uriel: remove obsolete code --- lass/1systems/uriel.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/lass/1systems/uriel.nix b/lass/1systems/uriel.nix index 2565f4c09..1b008cbfd 100644 --- a/lass/1systems/uriel.nix +++ b/lass/1systems/uriel.nix @@ -73,7 +73,4 @@ with builtins; Option "FingerLow" "60" ''; }; - #for google hangout - - users.extraUsers.google.extraGroups = [ "audio" "video" ]; } From 517e6e00097f4f9ebb1f7bd784d2bb44dce5f4b8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 14:03:08 +0200 Subject: [PATCH 16/71] l 2 base: remove old code --- lass/2configs/base.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lass/2configs/base.nix b/lass/2configs/base.nix index 2e42f86ae..902fcb70b 100644 --- a/lass/2configs/base.nix +++ b/lass/2configs/base.nix @@ -137,12 +137,6 @@ with lib; "sendmail" ]; - #services.gitolite = { - # enable = true; - # dataDir = "/home/gitolite"; - # adminPubkey = config.sshKeys.lass.pub; - #}; - services.openssh = { enable = true; hostKeys = [ From 34eb9a67a26ee847891d3c2a4d0172519da3e2fc Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 14:03:50 +0200 Subject: [PATCH 17/71] l 2: add newsbot-js.nix --- lass/2configs/newsbot-js.nix | 202 +++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 lass/2configs/newsbot-js.nix diff --git a/lass/2configs/newsbot-js.nix b/lass/2configs/newsbot-js.nix new file mode 100644 index 000000000..211b29780 --- /dev/null +++ b/lass/2configs/newsbot-js.nix @@ -0,0 +1,202 @@ +{ config, pkgs, ... }: + +let + newsfile = pkgs.writeText "feeds" '' + aje|http://www.aljazeera.com/Services/Rss/?PostingId=2007731105943979989|#news + aktuelle_themen|http://bundestag.de/service/rss/Bundestag_Aktuelle_Themen.rss|#news #bundestag + allafrica|http://allafrica.com/tools/headlines/rdf/latest/headlines.rdf|#news + anon|http://anoninsiders.net/feed/|#news + antirez|http://antirez.com/rss|#news + arbor|http://feeds2.feedburner.com/asert/|#news + archlinux|http://www.archlinux.org/feeds/news/|#news + ars|http://feeds.arstechnica.com/arstechnica/index?format=xml|#news + asiaone_asia|http://news.asiaone.com/rss/asia|#news + asiaone_business|http://business.asiaone.com/rss.xml|#news + asiaone_sci|http://news.asiaone.com/rss/science-and-tech|#news + asiaone_world|http://news.asiaone.com/rss/world|#news + augustl|http://augustl.com/atom.xml|#news + bbc|http://feeds.bbci.co.uk/news/rss.xml|#news + bdt_drucksachen|http://www.bundestag.de/dip21rss/bundestag_drucksachen.rss|#news #bundestag + bdt_plenarproto|http://www.bundestag.de/rss_feeds/plenarprotokolle.rss|#news #bundestag + bdt_pressemitteilungen|http://bundestag.de/service/rss/Bundestag_Presse.rss|#news #bundestag + bdt_wd|http://bundestag.de/service/rss/Bundestag_WD.rss|#news #bundestag + bitcoinpakistan|https://bitcoinspakistan.com/feed/|#news #financial + cancer|http://feeds.feedburner.com/ncinewsreleases?format=xml|#news + carta|http://feeds2.feedburner.com/carta-standard-rss|#news + catholic_news|http://feeds.feedburner.com/catholicnewsagency/dailynews|#news + cbc_busi|http://rss.cbc.ca/lineup/business.xml|#news + cbc_offbeat|http://www.cbc.ca/cmlink/rss-offbeat|#news + cbc_pol|http://rss.cbc.ca/lineup/politics.xml|#news + cbc_tech|http://rss.cbc.ca/lineup/technology.xml|#news + cbc_top|http://rss.cbc.ca/lineup/topstories.xml|#news + ccc|http://www.ccc.de/rss/updates.rdf|#news + chan_b|https://boards.4chan.org/b/index.rss|#brainfuck + chan_biz|https://boards.4chan.org/biz/index.rss|#news #brainfuck + chan_int|https://boards.4chan.org/int/index.rss|#news #brainfuck + cna|http://www.channelnewsasia.com/starterkit/servlet/cna/rss/home.xml|#news + coinspotting|http://coinspotting.com/rss|#news #financial + cryptanalysis|https://cryptanalys.is/rss.php|#news + cryptocoinsnews|http://www.cryptocoinsnews.com/feed/|#news #financial + cryptogon|http://www.cryptogon.com/?feed=rss2|#news + csm|http://rss.csmonitor.com/feeds/csm|#news + csm_world|http://rss.csmonitor.com/feeds/world|#news + cyberguerrilla|https://www.cyberguerrilla.org/a/2012/?feed=rss2|#news + danisch|http://www.danisch.de/blog/feed/|#news + dod|http://www.defense.gov/news/afps2.xml|#news + dwn|http://deutsche-wirtschafts-nachrichten.de/feed/customfeed/|#news + ecat|http://ecat.com/feed|#news + eia_press|http://www.eia.gov/rss/press_rss.xml|#news + eia_today|http://www.eia.gov/rss/todayinenergy.xml|#news + embargowatch|https://embargowatch.wordpress.com/feed/|#news + ethereum-comments|http://blog.ethereum.org/comments/feed|#news + ethereum|http://blog.ethereum.org/feed|#news + europa_ric|http://ec.europa.eu/research/infocentre/rss/infocentre-rss.xml|#news + eu_survei|http://www.eurosurveillance.org/public/RSSFeed/RSS.aspx|#news + exploitdb|http://www.exploit-db.com/rss.xml|#news + fars|http://www.farsnews.com/rss.php|#news #test + faz_feui|http://www.faz.net/rss/aktuell/feuilleton/|#news + faz_politik|http://www.faz.net/rss/aktuell/politik/|#news + faz_wirtschaft|http://www.faz.net/rss/aktuell/wirtschaft/|#news #financial + fbi|http://www.fbi.gov/homepage/RSS|#news #bullerei + fbi_news|http://www.fbi.gov/news/news_blog/rss.xml|#news + fbi_press|http://www.fbi.gov/news/current/rss.xml|#news #bullerei + fbi_stories|http://www.fbi.gov/news/stories/all-stories/rss.xml|#news #bullerei + fedreserve|http://www.federalreserve.gov/feeds/press_all.xml|#news #financial + fefe|http://blog.fefe.de/rss.xml|#news + forbes|http://www.forbes.com/forbes/feed2/|#news + forbes_realtime|http://www.forbes.com/real-time/feed2/|#news + fox|http://feeds.foxnews.com/foxnews/latest|#news + geheimorganisation|http://geheimorganisation.org/feed/|#news + GerForPol|http://www.german-foreign-policy.com/de/news/rss-2.0|#news + gmanet|http://www.gmanetwork.com/news/rss/news|#news + golem|http://www.golem.de/rss.php?feed=RSS1.0|#news + google|http://news.google.com/?output=rss|#news + greenpeace|http://feeds.feedburner.com/GreenpeaceNews|#news + guardian_uk|http://feeds.theguardian.com/theguardian/uk-news/rss|#news + gulli|http://ticker.gulli.com/rss/|#news + handelsblatt|http://www.handelsblatt.com/contentexport/feed/schlagzeilen|#news #financial + heise|http://heise.de.feedsportal.com/c/35207/f/653902/index.rss|#news + hindu_business|http://www.thehindubusinessline.com/?service=rss|#news #financial + hindu|http://www.thehindu.com/?service=rss|#news + hintergrund|http://www.hintergrund.de/index.php?option=com_bca-rss-syndicator&feed_id=8|#news + ign|http://feeds.ign.com/ign/all|#news + independent|http://www.independent.com/rss/headlines/|#news + indymedia|http://de.indymedia.org/RSS/newswire.xml|#news + info_libera|http://www.informationliberation.com/rss.xml|#news + klagen-gegen-rundfuckbeitrag|http://klagen-gegen-rundfunkbeitrag.blogspot.com/feeds/posts/default|#news + korea_herald|http://www.koreaherald.com/rss_xml.php|#news + linuxinsider|http://www.linuxinsider.com/perl/syndication/rssfull.pl|#news + lisp|http://planet.lisp.org/rss20.xml|#news + liveleak|http://www.liveleak.com/rss|#news + lolmythesis|http://lolmythesis.com/rss|#news + LtU|http://lambda-the-ultimate.org/rss.xml|#news + lukepalmer|http://lukepalmer.wordpress.com/feed/|#news + mit|http://web.mit.edu/newsoffice/rss-feeds.feed?type=rss|#news + mongrel2_master|https://github.com/zedshaw/mongrel2/commits/master.atom|#news + nds|http://www.nachdenkseiten.de/?feed=atom|#news + netzpolitik|https://netzpolitik.org/feed/|#news + newsbtc|http://newsbtc.com/feed/|#news #financial + nnewsg|http://www.net-news-global.net/rss/rssfeed.xml|#news + npr_busi|http://www.npr.org/rss/rss.php?id=1006|#news + npr_headlines|http://www.npr.org/rss/rss.php?id=1001|#news + npr_pol|http://www.npr.org/rss/rss.php?id=1012|#news + npr_world|http://www.npr.org/rss/rss.php?id=1004|#news + nsa|http://www.nsa.gov/rss.shtml|#news #bullerei + nytimes|http://rss.nytimes.com/services/xml/rss/nyt/World.xml|#news + painload|https://github.com/krebscode/painload/commits/master.atom|#news + phys|http://phys.org/rss-feed/|#news + piraten|https://www.piratenpartei.de/feed/|#news + polizei_berlin|http://www.berlin.de/polizei/presse-fahndung/_rss_presse.xml|#news #bullerei + presse_polizei|http://www.presseportal.de/rss/polizei.rss2|#news #bullerei + presseportal|http://www.presseportal.de/rss/presseportal.rss2|#news + prisonplanet|http://prisonplanet.com/feed.rss|#news + proofmarket|https://proofmarket.org/feed_problem|#news + rawstory|http://www.rawstory.com/rs/feed/|#news + reddit_4chan|http://www.reddit.com/r/4chan/new/.rss|#news #brainfuck + reddit_anticonsum|http://www.reddit.com/r/Anticonsumption/new/.rss|#news + reddit_btc|http://www.reddit.com/r/Bitcoin/new/.rss|#news #financial + reddit_prog|http://www.reddit.com/r/programming/new/.rss|#news + reddit_tpp|http://www.reddit.com/r/twitchplayspokemon/.rss|#news #tpp + reddit_world|http://www.reddit.com/r/worldnews/.rss|#news + r-ethereum|http://www.reddit.com/r/ethereum/.rss|#news + reuters|http://feeds.reuters.com/Reuters/worldNews|#news + reuters-odd|http://feeds.reuters.com/reuters/oddlyEnoughNews?format=xml|#news + rt|http://rt.com/rss/news/|#news + schallurauch|http://feeds.feedburner.com/SchallUndRauch|#news + sciencemag|http://news.sciencemag.org/rss/current.xml|#news + scmp|http://www.scmp.com/rss/91/feed|#news + sec-db|http://feeds.security-database.com/SecurityDatabaseToolsWatch|#news + shackspace|http://shackspace.de/?feed=rss2|#news + shz_news|http://www.shz.de/nachrichten/newsticker/rss|#news + sky_busi|http://news.sky.com/feeds/rss/business.xml|#news + sky_pol|http://news.sky.com/feeds/rss/politics.xml|#news + sky_strange|http://news.sky.com/feeds/rss/strange.xml|#news + sky_tech|http://news.sky.com/feeds/rss/technology.xml|#news + sky_world|http://news.sky.com/feeds/rss/world.xml|#news + slashdot|http://rss.slashdot.org/Slashdot/slashdot|#news + slate|http://feeds.slate.com/slate|#news + spiegel_eil|http://www.spiegel.de/schlagzeilen/eilmeldungen/index.rss|#news + spiegelfechter|http://feeds.feedburner.com/DerSpiegelfechter?format=xml|#news + spiegel_top|http://www.spiegel.de/schlagzeilen/tops/index.rss|#news + standardmedia_ke|http://www.standardmedia.co.ke/rss/headlines.php|#news + stern|http://www.stern.de/feed/standard/all/|#news + stz|http://www.stuttgarter-zeitung.de/rss/topthemen.rss.feed|#news + sz_politik|http://rss.sueddeutsche.de/rss/Politik|#news + sz_wirtschaft|http://rss.sueddeutsche.de/rss/Wirtschaft|#news #financial + sz_wissen|http://suche.sueddeutsche.de/rss/Wissen|#news + tagesschau|http://www.tagesschau.de/newsticker.rdf|#news + taz|http://taz.de/Themen-des-Tages/!p15;rss/|#news + telegraph_finance|http://www.telegraph.co.uk/finance/rss|#news #financial + telegraph_pol|http://www.telegraph.co.uk/news/politics/rss|#news + telegraph_uk|http://www.telegraph.co.uk/news/uknews/rss|#news + telegraph_world|http://www.telegraph.co.uk/news/worldnews/rss|#news + telepolis|http://www.heise.de/tp/rss/news-atom.xml|#news + the_insider|http://www.theinsider.org/rss/news/headlines-xml.asp|#news + tigsource|http://www.tigsource.com/feed/|#news + times|http://www.thetimes.co.uk/tto/news/rss|#news + tinc|http://tinc-vpn.org/news/index.rss|#news + topix_b|http://www.topix.com/rss/wire/de/berlin|#news + torr_bits|http://feeds.feedburner.com/TorrentfreakBits|#news + torrentfreak|http://feeds.feedburner.com/Torrentfreak|#news + torr_news|http://feed.torrentfreak.com/Torrentfreak/|#news + travel_warnings|http://feeds.travel.state.gov/ca/travelwarnings-alerts|#news + truther|http://truthernews.wordpress.com/feed/|#news + un_afr|http://www.un.org/apps/news/rss/rss_africa.asp|#news + un_am|http://www.un.org/apps/news/rss/rss_americas.asp|#news + un_eu|http://www.un.org/apps/news/rss/rss_europe.asp|#news + un_me|http://www.un.org/apps/news/rss/rss_mideast.asp|#news + un_pac|http://www.un.org/apps/news/rss/rss_asiapac.asp|#news + un_top|http://www.un.org/apps/news/rss/rss_top.asp|#news + us_math_society|http://www.ams.org/cgi-bin/content/news_items.cgi?rss=1|#news + vimperator|https://sites.google.com/a/vimperator.org/www/blog/posts.xml|#news + weechat|http://dev.weechat.org/feed/atom|#news + wired_sci|http://www.wired.com/category/science/feed/|#news + wp_world|http://feeds.washingtonpost.com/rss/rss_blogpost|#news + xkcd|https://xkcd.com/rss.xml|#news + zdnet|http://www.zdnet.com/news/rss.xml|#news + + chan_g|https://boards.4chan.org/g/index.rss|#news + chan_x|https://boards.4chan.org/x/index.rss|#news + chan_sci|https://boards.4chan.org/sci/index.rss|#news + reddit_consp|http://reddit.com/r/conspiracy/.rss|#news + reddit_sci|http://www.reddit.com/r/science/.rss|#news + reddit_tech|http://www.reddit.com/r/technology/.rss|#news + reddit_nix|http://www.reddit.com/r/nixos/.rss|#news + reddit_haskell|http://www.reddit.com/r/haskell/.rss|#news + hackernews|https://news.ycombinator.com/rss|#news + ''; +in { + imports = [ + ../3modules/newsbot-js.nix + ]; + environment.systemPackages = [ + pkgs.newsbot-js + ]; + lass.newsbot-js = { + enable = true; + ircServer = "localhost"; + feeds = newsfile; + urlShortenerHost = "go"; + urlShortenerPort = "80"; + }; +} From 281ba78969e0c0233fef0746d42f0ec85179b1bd Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 Oct 2015 14:06:04 +0200 Subject: [PATCH 18/71] l 3: add modules to default.nix --- lass/3modules/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 9de987bf3..b081dc3cc 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -1,7 +1,13 @@ _: - { imports = [ ./xresources.nix + ./bitlbee.nix + ./folderPerms.nix + ./go.nix + ./newsbot-js.nix + ./per-user.nix + ./urxvtd.nix + ./xresources.nix ]; } From 2efaf0f219850cd02cc77cb41d6c1c1bdd9de6ba Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 20:06:17 +0200 Subject: [PATCH 19/71] populate dir: improve error message --- krebs/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index c23cf152a..5e6595ced 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -221,11 +221,15 @@ let out = { ${config.path}/ \ root@${target}:${config.target-path} ''; - url = "file://${config.host.name}${config.path}"; + current-url = "${current-user-name}@${current-host.name}"; + source-url = "file://${config.host.name}${config.path}"; + target-url = "root@${target}:${config.target-path}"; in #if can-link then link-method else if can-push then push-method else - throw "cannot source ${url}"; + throw + # /!\ revise this message when using more than just push-method + "No way to push ${source-url} from ${current-url} to ${target-url}"; methods.git = config: rootssh target '' From acb53c23dcb11de02e642e7f99e83401531e48c1 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 20:19:40 +0200 Subject: [PATCH 20/71] populate dir: drop link-method fragments --- krebs/default.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index 5e6595ced..40b3550c8 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -203,11 +203,8 @@ let out = { current-host = config.krebs.hosts.${current-host-name}; current-user = config.krebs.users.${current-user-name}; - target-host = config.krebs.hosts.${system}; - methods.dir = config: let - can-link = config.host.name == target-host.name; can-push = config.host.name == current-host.name; push-method = '' rsync \ @@ -219,13 +216,12 @@ let out = { --delete-excluded \ -vrLptgoD \ ${config.path}/ \ - root@${target}:${config.target-path} + ${target-url} ''; current-url = "${current-user-name}@${current-host.name}"; source-url = "file://${config.host.name}${config.path}"; target-url = "root@${target}:${config.target-path}"; in - #if can-link then link-method else if can-push then push-method else throw # /!\ revise this message when using more than just push-method From 9cb1fdc946aecc96bd9bbadca77b6d7e3c87abd3 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 20:24:25 +0200 Subject: [PATCH 21/71] populate dir: reduce noise in error message --- krebs/default.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index 40b3550c8..3e86c0466 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -216,16 +216,13 @@ let out = { --delete-excluded \ -vrLptgoD \ ${config.path}/ \ - ${target-url} + root@${target}:${config.target-path} ''; - current-url = "${current-user-name}@${current-host.name}"; - source-url = "file://${config.host.name}${config.path}"; - target-url = "root@${target}:${config.target-path}"; in if can-push then push-method else - throw - # /!\ revise this message when using more than just push-method - "No way to push ${source-url} from ${current-url} to ${target-url}"; + let dir = "file://${config.host.name}${config.path}"; in + # /!\ revise this message when using more than just push-method + throw "No way to push ${dir} from ${current-host.name} to ${target}"; methods.git = config: rootssh target '' From 914c4c4a2fb6be95f7f4dbc9134fd272ec210c26 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 20:28:26 +0200 Subject: [PATCH 22/71] krebs default: drop redundant "lib." --- krebs/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index 3e86c0466..9258c236b 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -48,14 +48,14 @@ let out = { # eval "$RSYNC_RSH \"\$@\"" #} - ${lib.rootssh target '' + ${rootssh target '' ${builtins.readFile ./4lib/infest/prepare.sh} ${builtins.readFile ./4lib/infest/install-nix.sh} ''} - (${lib.populate args}) + (${populate args}) - ${lib.rootssh target '' + ${rootssh target '' export PATH; PATH=/root/.nix-profile/bin:$PATH src=$(type -p nixos-install) @@ -79,7 +79,7 @@ let out = { { cat_src | sed -n "1,$i{p}" - cat ${lib.doc (install args)} + cat ${doc (install args)} cat_src | sed -n "$i,\''${$i!p}" } > nixos-install chmod +x nixos-install From d2c121e651e7b175b93a9962e861f286391ab3ca Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 20:30:37 +0200 Subject: [PATCH 23/71] tv urlwatch: drop nixops Because nixops 1.2 -> 1.3 in NixOS/nixpkgs@92e98c2. --- tv/2configs/urlwatch.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index c1c5d19d9..373803cc6 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -29,10 +29,6 @@ # 2014-09-24 ref https://github.com/4z3/xintmap http://www.mathstat.dal.ca/~selinger/quipper/ - # 2014-12-12 remove nixopsUnstable when nixops get's bumped to 1.3 - # ref https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/package-management/nixops/unstable.nix - http://nixos.org/releases/nixops/ - ## other https://nixos.org/channels/nixos-unstable/git-revision From 9bbdfb85cf333fde4050bbef738c54ca988db228 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 22:13:42 +0200 Subject: [PATCH 24/71] export krebs.populate --- krebs/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/default.nix b/krebs/default.nix index 9258c236b..4d09075cb 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -8,6 +8,7 @@ let out = { inherit deploy; inherit infest; inherit init; + inherit populate; inherit lib; }; From fc45cc29265e9b3e51033fddd5d8ea1042c1aa41 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 23:17:32 +0200 Subject: [PATCH 25/71] export krebs.nixos-install Collaterally, unexport krebs.populate again. --- krebs/default.nix | 101 ++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index 4d09075cb..de805a89c 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -8,8 +8,8 @@ let out = { inherit deploy; inherit infest; inherit init; - inherit populate; inherit lib; + inherit nixos-install; }; deploy = @@ -24,7 +24,7 @@ let out = { set -efu (${populate args}) ${rootssh target '' - ${install args} + ${nix-install args} ${config.krebs.build.profile}/bin/switch-to-configuration switch ''} echo OK @@ -40,63 +40,14 @@ let out = { # krebs.infest set -efu - # XXX type -p is non-standard - #export RSYNC_RSH; RSYNC_RSH="$(type -p ssh) \ - # -o 'HostName $ {target.host.infest.addr}' \ - # -o 'Port $ {toString target.host.infest.port}' \ - #" - #ssh() { - # eval "$RSYNC_RSH \"\$@\"" - #} - ${rootssh target '' ${builtins.readFile ./4lib/infest/prepare.sh} ${builtins.readFile ./4lib/infest/install-nix.sh} ''} - (${populate args}) + (${nixos-install args}) ${rootssh target '' - export PATH; PATH=/root/.nix-profile/bin:$PATH - - src=$(type -p nixos-install) - cat_src() { - sed < "$src" "$( - { sed < "$src" -n ' - /^if ! test -e "\$mountPoint\/\$NIXOS_CONFIG/,/^fi$/= - /^nixpkgs=/= - /^NIX_PATH=/,/^$/{/./=} - - # Disable: Copy the NixOS/Nixpkgs sources to the target as - # the initial contents of the NixOS channel. - /^srcs=/,/^ln -sfn /= - ' - } | sed 's:$:s/^/#krebs#/:' - )" - } - - # Location to insert install - i=$(sed -n '/^echo "building the system configuration/=' "$src") - - { - cat_src | sed -n "1,$i{p}" - cat ${doc (install args)} - cat_src | sed -n "$i,\''${$i!p}" - } > nixos-install - chmod +x nixos-install - - ## Wrap inserted install into chroot. - #nix_env=$(cat_src | sed -n ' - # s:.*\(/nix/store/[a-z0-9]*-nix-[0-9.]\+/bin/nix-env\).*:\1:p;T;q - #') - #echo nix-env is $nix_env - #sed -i ' - # s:^nix-env:chroot $mountPoint '"$nix_env"': - #' nixos-install - - unset SSL_CERT_FILE - ./nixos-install - ${builtins.readFile ./4lib/infest/finalize.sh} ''} ''; @@ -136,6 +87,50 @@ let out = { EOF ''; + nixos-install = + { system ? current-host-name + , target ? system + }@args: let + in '' + #! /bin/sh + # ${current-date} ${current-user-name}@${current-host-name} + # krebs.nixos-install + (${populate args}) + + ${rootssh target '' + export PATH; PATH=/root/.nix-profile/bin:$PATH + + src=$(type -p nixos-install) + cat_src() { + sed < "$src" "$( + { sed < "$src" -n ' + /^if ! test -e "\$mountPoint\/\$NIXOS_CONFIG/,/^fi$/= + /^nixpkgs=/= + /^NIX_PATH=/,/^$/{/./=} + + # Disable: Copy the NixOS/Nixpkgs sources to the target as + # the initial contents of the NixOS channel. + /^srcs=/,/^ln -sfn /= + ' + } | sed 's:$:s/^/#krebs#/:' + )" + } + + # Location to insert `nix-install` + i=$(sed -n '/^echo "building the system configuration/=' "$src") + + { + cat_src | sed -n "1,$i{p}" + cat ${doc (nix-install args)} + cat_src | sed -n "$i,\''${$i!p}" + } > nixos-install + chmod +x nixos-install + + unset SSL_CERT_FILE + ./nixos-install + ''} + ''; + lib = import ./4lib { lib = import ; } // rec { stockholm-path = ../.; nspath = ns: p: stockholm-path + "/${ns}/${p}"; @@ -153,7 +148,7 @@ let out = { stockholm.users.${current-user-name}.${system}.config or (abort "unknown system: ${system}, user: ${current-user-name}"); - install = + nix-install = { system ? current-host-name , target ? system }: From 226ea391caec5b3f2f112de263dd2db3a0e012f4 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 00:08:18 +0200 Subject: [PATCH 26/71] stockholm: provide krebs lib --- default.nix | 24 +++++++++++++++++++----- krebs/3modules/build.nix | 2 +- krebs/3modules/default.nix | 2 +- krebs/3modules/git.nix | 2 +- krebs/3modules/github-hosts-sync.nix | 3 +-- krebs/3modules/lass/default.nix | 2 +- krebs/3modules/makefu/default.nix | 2 +- krebs/3modules/tv/default.nix | 2 +- krebs/4lib/default.nix | 2 -- krebs/5pkgs/default.nix | 5 ++--- krebs/default.nix | 7 +------ tv/2configs/test.nix | 2 +- tv/3modules/consul.nix | 2 +- tv/4lib/default.nix | 14 ++++---------- 14 files changed, 35 insertions(+), 36 deletions(-) diff --git a/default.nix b/default.nix index 11bae7d98..c70225174 100644 --- a/default.nix +++ b/default.nix @@ -47,8 +47,20 @@ let stockholm = { inherit (eval {}) pkgs; }; - krebs = import ./krebs (current // { inherit stockholm; }); - inherit (krebs) lib; + krebs = import ./krebs (current // { inherit lib stockholm; }); + + lib = + let + lib = import ; + klib = import ./krebs/4lib { inherit lib; }; + #ulib = import (./. + "/${current-user-name}/4lib") { lib = lib // klib; }; + ulib = {}; # TODO + in + builtins // lib // klib // ulib // rec { + # TODO move this stuff + stockholm-path = ./.; + nspath = ns: p: stockholm-path + "/${ns}/${p}"; + }; # Path resolvers for common and individual files. # Example: `upath "3modules"` produces the current user's 3modules directory @@ -65,8 +77,8 @@ let stockholm = { let # Notice the ordering. Krebs packages can only depend on Nixpkgs, # whereas user packages additionally can depend on krebs packages. - kpkgs = import (kpath "5pkgs") { inherit pkgs; }; - upkgs = import (upath "5pkgs") { pkgs = pkgs // kpkgs; }; + kpkgs = import (kpath "5pkgs") { inherit lib pkgs; }; + upkgs = import (upath "5pkgs") { inherit lib; pkgs = pkgs // kpkgs; }; in kpkgs // upkgs; }; @@ -76,8 +88,10 @@ let stockholm = { # packages and modules on top of NixOS. Some of this stuff might become # useful to a broader audience, at which point it should probably be merged # and pull-requested for inclusion into NixOS/nixpkgs. - # TODO provide krebs lib, so modules don't have to import it awkwardly eval = config: import { + specialArgs = { + inherit lib; + }; modules = [ base-module config diff --git a/krebs/3modules/build.nix b/krebs/3modules/build.nix index 57495ea69..1205e192b 100644 --- a/krebs/3modules/build.nix +++ b/krebs/3modules/build.nix @@ -1,6 +1,6 @@ { config, lib, ... }: -with import ../4lib { inherit lib; }; +with lib; let target = config.krebs.build // { user.name = "root"; }; diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index ff0cc8346..e2aea7057 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -1,6 +1,6 @@ { config, lib, ... }: -with import ../4lib { inherit lib; }; +with lib; let cfg = config.krebs; diff --git a/krebs/3modules/git.nix b/krebs/3modules/git.nix index 64b7820b2..234129497 100644 --- a/krebs/3modules/git.nix +++ b/krebs/3modules/git.nix @@ -6,7 +6,7 @@ # TODO when authorized_keys changes, then restart ssh # (or kill already connected users somehow) -with import ../4lib { inherit lib; }; +with lib; let cfg = config.krebs.git; diff --git a/krebs/3modules/github-hosts-sync.nix b/krebs/3modules/github-hosts-sync.nix index 2a1df9e03..5503ee8d6 100644 --- a/krebs/3modules/github-hosts-sync.nix +++ b/krebs/3modules/github-hosts-sync.nix @@ -1,7 +1,6 @@ { config, lib, pkgs, ... }: -with builtins; -with import ../4lib { inherit lib; }; +with lib; let cfg = config.krebs.github-hosts-sync; diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index afedf95f2..59052021b 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -1,6 +1,6 @@ { lib, ... }: -with import ../../4lib { inherit lib; }; +with lib; { hosts = addNames { diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix index 4628b2acc..9cf5c9aea 100644 --- a/krebs/3modules/makefu/default.nix +++ b/krebs/3modules/makefu/default.nix @@ -1,6 +1,6 @@ { lib, ... }: -with import ../../4lib { inherit lib; }; +with lib; { hosts = addNames { diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix index 5d5fead8f..5a1ff1416 100644 --- a/krebs/3modules/tv/default.nix +++ b/krebs/3modules/tv/default.nix @@ -1,6 +1,6 @@ { lib, ... }: -with import ../../4lib { inherit lib; }; +with lib; { dns.providers = { diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix index 0a6101314..396307c22 100644 --- a/krebs/4lib/default.nix +++ b/krebs/4lib/default.nix @@ -3,8 +3,6 @@ with builtins; with lib; -builtins // -lib // rec { eq = x: y: x == y; diff --git a/krebs/5pkgs/default.nix b/krebs/5pkgs/default.nix index 84fb8725b..0ec4b3ded 100644 --- a/krebs/5pkgs/default.nix +++ b/krebs/5pkgs/default.nix @@ -1,7 +1,6 @@ -{ pkgs, ... }: - -with import ../4lib { inherit (pkgs) lib; }; +{ lib, pkgs, ... }: +with lib; let subdirs = mapAttrs (_: flip pkgs.callPackage {}) (subdirsOf ./.); pkgs' = pkgs // subdirs; diff --git a/krebs/default.nix b/krebs/default.nix index de805a89c..5518a4496 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -1,6 +1,7 @@ { current-date , current-host-name , current-user-name +, lib , stockholm }: @@ -8,7 +9,6 @@ let out = { inherit deploy; inherit infest; inherit init; - inherit lib; inherit nixos-install; }; @@ -131,11 +131,6 @@ let out = { ''} ''; - lib = import ./4lib { lib = import ; } // rec { - stockholm-path = ../.; - nspath = ns: p: stockholm-path + "/${ns}/${p}"; - }; - doc = s: let b = "EOF${builtins.hashString "sha256" s}"; in '' diff --git a/tv/2configs/test.nix b/tv/2configs/test.nix index 409b4e9b4..f5f068d6f 100644 --- a/tv/2configs/test.nix +++ b/tv/2configs/test.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with import ../4lib { inherit lib pkgs; }; +with lib; let out = { diff --git a/tv/3modules/consul.nix b/tv/3modules/consul.nix index e764ab7b2..ccdee07f5 100644 --- a/tv/3modules/consul.nix +++ b/tv/3modules/consul.nix @@ -5,7 +5,7 @@ # TODO consul-bootstrap HOST that actually does is # TODO tools to inspect state of a cluster in outage state -with import ../4lib { inherit lib pkgs; }; +with lib; let cfg = config.tv.consul; diff --git a/tv/4lib/default.nix b/tv/4lib/default.nix index 106535ba2..7e6b2ab17 100644 --- a/tv/4lib/default.nix +++ b/tv/4lib/default.nix @@ -1,20 +1,14 @@ { lib, pkgs, ... }: -let - krebs = import ../../krebs/4lib { inherit lib; }; -in - -with krebs; - -krebs // rec { +lib // rec { git = import ./git.nix { - lib = krebs; - inherit pkgs; + inherit lib pkgs; }; # "7.4.335" -> "74" majmin = with lib; x : concatStrings (take 2 (splitString "." x)); - shell-escape = krebs.shell.escape; + # TODO deprecate shell-escape for lass + shell-escape = lib.shell.escape; } From 309102967ebad616d3f6a0dec361d80a61092ec8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 01:32:44 +0200 Subject: [PATCH 27/71] l: add test systems --- krebs/3modules/lass/default.nix | 31 ++++++++++++++++++++++++++-- lass/1systems/test-arch.nix | 36 +++++++++++++++++++++++++++++++++ lass/1systems/test-centos6.nix | 30 +++++++++++++++++++++++++++ lass/1systems/test-centos7.nix | 31 ++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 lass/1systems/test-arch.nix create mode 100644 lass/1systems/test-centos6.nix create mode 100644 lass/1systems/test-centos7.nix diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 5c48d9642..3f81acb9e 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -2,7 +2,34 @@ with import ../../4lib { inherit lib; }; -{ +let + testHosts = lib.genAttrs [ + "test-arch" + "test-centos6" + "test-centos7" + ] (name: { + inherit name; + nets = { + retiolum = { + addrs4 = ["10.243.111.111"]; + addrs6 = ["42:0:0:0:0:0:0:7357"]; + aliases = [ + "test.retiolum" + ]; + tinc.pubkey = '' + -----BEGIN RSA PUBLIC KEY----- + MIIBCgKCAQEAy41YKF/wpHLnN370MSdnAo63QUW30aw+6O79cnaJyxoL6ZQkk4Nd + mrX2tBIfb2hhhgm4Jecy33WVymoEL7EiRZ6gshJaYwte51Jnrac6IFQyiRGMqHY5 + TG/6IzzTOkeQrT1fw3Yfh0NRfqLBZLr0nAFoqgzIVRxvy+QO1gCU2UDKkQ/y5df1 + K+YsMipxU08dsOkPkmLdC/+vDaZiEdYljIS3Omd+ED5JmLM3MSs/ZPQ8xjkjEAy8 + QqD9/67bDoeXyg1ZxED2n0+aRKtU/CK/66Li//yev6yv38OQSEM4t/V0dr9sjLcY + VIdkxKf96F9r3vcDf/9xw2HrqVoy+D5XYQIDAQAB + -----END RSA PUBLIC KEY----- + ''; + }; + }; + }); +in { hosts = addNames { echelon = { cores = 4; @@ -180,7 +207,7 @@ with import ../../4lib { inherit lib; }; }; }; - }; + } // testHosts; users = addNames { lass = { pubkey = readFile ../../Zpubkeys/lass.ssh.pub; diff --git a/lass/1systems/test-arch.nix b/lass/1systems/test-arch.nix new file mode 100644 index 000000000..0ab9da2f3 --- /dev/null +++ b/lass/1systems/test-arch.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +let + inherit (import ../4lib { inherit pkgs lib; }) getDefaultGateway; + inherit (lib) head; + +in { + imports = [ + ../2configs/base.nix + { + boot.loader.grub = { + device = "/dev/sda"; + splashImage = null; + }; + + boot.initrd.availableKernelModules = [ + "ata_piix" + "vmw_pvscsi" + ]; + + fileSystems."/" = { + device = "/dev/sda1"; + }; + } + { + networking.dhcpcd.allowInterfaces = [ + "enp*" + ]; + } + { + sound.enable = false; + } + ]; + + krebs.build.host = config.krebs.hosts.test-arch; +} diff --git a/lass/1systems/test-centos6.nix b/lass/1systems/test-centos6.nix new file mode 100644 index 000000000..7270c2262 --- /dev/null +++ b/lass/1systems/test-centos6.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +let + inherit (import ../4lib { inherit pkgs lib; }) getDefaultGateway; + inherit (lib) head; + + ip = "168.235.148.52"; +in { + imports = [ + ../2configs/base.nix + ../2configs/os-templates/CAC-CentOS-6.5-64bit.nix + { + networking.interfaces.enp11s0.ip4 = [ + { + address = ip; + prefixLength = 24; + } + ]; + networking.defaultGateway = getDefaultGateway ip; + networking.nameservers = [ + "8.8.8.8" + ]; + } + { + sound.enable = false; + } + ]; + + krebs.build.host = config.krebs.hosts.test-centos6; +} diff --git a/lass/1systems/test-centos7.nix b/lass/1systems/test-centos7.nix new file mode 100644 index 000000000..91bd3e0fe --- /dev/null +++ b/lass/1systems/test-centos7.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +let + inherit (import ../4lib { inherit pkgs lib; }) getDefaultGateway; + inherit (lib) head; + + ip = "168.235.145.85"; +in { + imports = [ + ../2configs/base.nix + ../2configs/os-templates/CAC-CentOS-7-64bit.nix + { + networking.interfaces.enp2s1.ip4 = [ + { + address = ip; + prefixLength = 24; + } + ]; + networking.defaultGateway = getDefaultGateway ip; + networking.nameservers = [ + "8.8.8.8" + ]; + + } + { + sound.enable = false; + } + ]; + + krebs.build.host = config.krebs.hosts.test-centos7; +} From 61c72512989a9c83645493002d0f8230691a58e1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 01:33:00 +0200 Subject: [PATCH 28/71] l 1 mors: add hangouts permissions --- lass/1systems/mors.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index 0e7ed7c62..b0b8ff573 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -199,4 +199,7 @@ tapButtons = false; twoFingerScroll = true; }; + + #for google hangout + users.extraUsers.gm.extraGroups = [ "audio" "video" ]; } From 8144b59c5786459619b4a06ecc150b6a96af014b Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 01:34:05 +0200 Subject: [PATCH 29/71] l 2 base: nixpkgs b9270a2 -> 33bdc01 --- lass/2configs/base.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lass/2configs/base.nix b/lass/2configs/base.nix index 902fcb70b..52501441a 100644 --- a/lass/2configs/base.nix +++ b/lass/2configs/base.nix @@ -50,7 +50,7 @@ with lib; source = { git.nixpkgs = { url = https://github.com/Lassulus/nixpkgs; - rev = "b9270a2e8ac3d2cf4c95075a9529528aa1d859da"; + rev = "33bdc011f5360288cd10b9fda90da2950442b2ab"; }; dir.secrets = { host = config.krebs.hosts.mors; From 8f7253184ac53792d125c6713b0757da58389b1e Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 01:34:27 +0200 Subject: [PATCH 30/71] l 2 base: add aria2 to base install --- lass/2configs/base.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lass/2configs/base.nix b/lass/2configs/base.nix index 52501441a..6fa9c5b2d 100644 --- a/lass/2configs/base.nix +++ b/lass/2configs/base.nix @@ -96,6 +96,9 @@ with lib; #network iptables + + #stuff for dl + aria2 ]; programs.bash = { From 3ce57c3de3f3dc95669d3a0564f6f7d0ff425321 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 00:08:18 +0200 Subject: [PATCH 31/71] stockholm: provide krebs lib --- default.nix | 24 +++++++++++++++++++----- krebs/3modules/build.nix | 2 +- krebs/3modules/default.nix | 2 +- krebs/3modules/git.nix | 2 +- krebs/3modules/github-hosts-sync.nix | 3 +-- krebs/3modules/lass/default.nix | 2 +- krebs/3modules/makefu/default.nix | 2 +- krebs/3modules/tv/default.nix | 2 +- krebs/4lib/default.nix | 2 -- krebs/5pkgs/default.nix | 5 ++--- krebs/default.nix | 7 +------ tv/2configs/test.nix | 2 +- tv/3modules/consul.nix | 2 +- tv/4lib/default.nix | 14 ++++---------- 14 files changed, 35 insertions(+), 36 deletions(-) diff --git a/default.nix b/default.nix index 11bae7d98..c70225174 100644 --- a/default.nix +++ b/default.nix @@ -47,8 +47,20 @@ let stockholm = { inherit (eval {}) pkgs; }; - krebs = import ./krebs (current // { inherit stockholm; }); - inherit (krebs) lib; + krebs = import ./krebs (current // { inherit lib stockholm; }); + + lib = + let + lib = import ; + klib = import ./krebs/4lib { inherit lib; }; + #ulib = import (./. + "/${current-user-name}/4lib") { lib = lib // klib; }; + ulib = {}; # TODO + in + builtins // lib // klib // ulib // rec { + # TODO move this stuff + stockholm-path = ./.; + nspath = ns: p: stockholm-path + "/${ns}/${p}"; + }; # Path resolvers for common and individual files. # Example: `upath "3modules"` produces the current user's 3modules directory @@ -65,8 +77,8 @@ let stockholm = { let # Notice the ordering. Krebs packages can only depend on Nixpkgs, # whereas user packages additionally can depend on krebs packages. - kpkgs = import (kpath "5pkgs") { inherit pkgs; }; - upkgs = import (upath "5pkgs") { pkgs = pkgs // kpkgs; }; + kpkgs = import (kpath "5pkgs") { inherit lib pkgs; }; + upkgs = import (upath "5pkgs") { inherit lib; pkgs = pkgs // kpkgs; }; in kpkgs // upkgs; }; @@ -76,8 +88,10 @@ let stockholm = { # packages and modules on top of NixOS. Some of this stuff might become # useful to a broader audience, at which point it should probably be merged # and pull-requested for inclusion into NixOS/nixpkgs. - # TODO provide krebs lib, so modules don't have to import it awkwardly eval = config: import { + specialArgs = { + inherit lib; + }; modules = [ base-module config diff --git a/krebs/3modules/build.nix b/krebs/3modules/build.nix index 57495ea69..1205e192b 100644 --- a/krebs/3modules/build.nix +++ b/krebs/3modules/build.nix @@ -1,6 +1,6 @@ { config, lib, ... }: -with import ../4lib { inherit lib; }; +with lib; let target = config.krebs.build // { user.name = "root"; }; diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 756245c0b..c695589ca 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -1,6 +1,6 @@ { config, lib, ... }: -with import ../4lib { inherit lib; }; +with lib; let cfg = config.krebs; diff --git a/krebs/3modules/git.nix b/krebs/3modules/git.nix index 64b7820b2..234129497 100644 --- a/krebs/3modules/git.nix +++ b/krebs/3modules/git.nix @@ -6,7 +6,7 @@ # TODO when authorized_keys changes, then restart ssh # (or kill already connected users somehow) -with import ../4lib { inherit lib; }; +with lib; let cfg = config.krebs.git; diff --git a/krebs/3modules/github-hosts-sync.nix b/krebs/3modules/github-hosts-sync.nix index 2a1df9e03..5503ee8d6 100644 --- a/krebs/3modules/github-hosts-sync.nix +++ b/krebs/3modules/github-hosts-sync.nix @@ -1,7 +1,6 @@ { config, lib, pkgs, ... }: -with builtins; -with import ../4lib { inherit lib; }; +with lib; let cfg = config.krebs.github-hosts-sync; diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 3f81acb9e..d86c00563 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -1,6 +1,6 @@ { lib, ... }: -with import ../../4lib { inherit lib; }; +with lib; let testHosts = lib.genAttrs [ diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix index acc5d7dd2..42764e48c 100644 --- a/krebs/3modules/makefu/default.nix +++ b/krebs/3modules/makefu/default.nix @@ -1,6 +1,6 @@ { lib, ... }: -with import ../../4lib { inherit lib; }; +with lib; { hosts = addNames { diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix index 5d5fead8f..5a1ff1416 100644 --- a/krebs/3modules/tv/default.nix +++ b/krebs/3modules/tv/default.nix @@ -1,6 +1,6 @@ { lib, ... }: -with import ../../4lib { inherit lib; }; +with lib; { dns.providers = { diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix index 0a6101314..396307c22 100644 --- a/krebs/4lib/default.nix +++ b/krebs/4lib/default.nix @@ -3,8 +3,6 @@ with builtins; with lib; -builtins // -lib // rec { eq = x: y: x == y; diff --git a/krebs/5pkgs/default.nix b/krebs/5pkgs/default.nix index 84fb8725b..0ec4b3ded 100644 --- a/krebs/5pkgs/default.nix +++ b/krebs/5pkgs/default.nix @@ -1,7 +1,6 @@ -{ pkgs, ... }: - -with import ../4lib { inherit (pkgs) lib; }; +{ lib, pkgs, ... }: +with lib; let subdirs = mapAttrs (_: flip pkgs.callPackage {}) (subdirsOf ./.); pkgs' = pkgs // subdirs; diff --git a/krebs/default.nix b/krebs/default.nix index de805a89c..5518a4496 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -1,6 +1,7 @@ { current-date , current-host-name , current-user-name +, lib , stockholm }: @@ -8,7 +9,6 @@ let out = { inherit deploy; inherit infest; inherit init; - inherit lib; inherit nixos-install; }; @@ -131,11 +131,6 @@ let out = { ''} ''; - lib = import ./4lib { lib = import ; } // rec { - stockholm-path = ../.; - nspath = ns: p: stockholm-path + "/${ns}/${p}"; - }; - doc = s: let b = "EOF${builtins.hashString "sha256" s}"; in '' diff --git a/tv/2configs/test.nix b/tv/2configs/test.nix index 409b4e9b4..f5f068d6f 100644 --- a/tv/2configs/test.nix +++ b/tv/2configs/test.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with import ../4lib { inherit lib pkgs; }; +with lib; let out = { diff --git a/tv/3modules/consul.nix b/tv/3modules/consul.nix index e764ab7b2..ccdee07f5 100644 --- a/tv/3modules/consul.nix +++ b/tv/3modules/consul.nix @@ -5,7 +5,7 @@ # TODO consul-bootstrap HOST that actually does is # TODO tools to inspect state of a cluster in outage state -with import ../4lib { inherit lib pkgs; }; +with lib; let cfg = config.tv.consul; diff --git a/tv/4lib/default.nix b/tv/4lib/default.nix index 106535ba2..7e6b2ab17 100644 --- a/tv/4lib/default.nix +++ b/tv/4lib/default.nix @@ -1,20 +1,14 @@ { lib, pkgs, ... }: -let - krebs = import ../../krebs/4lib { inherit lib; }; -in - -with krebs; - -krebs // rec { +lib // rec { git = import ./git.nix { - lib = krebs; - inherit pkgs; + inherit lib pkgs; }; # "7.4.335" -> "74" majmin = with lib; x : concatStrings (take 2 (splitString "." x)); - shell-escape = krebs.shell.escape; + # TODO deprecate shell-escape for lass + shell-escape = lib.shell.escape; } From 9c9a7d611ed9201e84ed49067027e85389313b7c Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 02:21:56 +0200 Subject: [PATCH 32/71] krebs.nixos-install: bring back chroot wrapper Because we _do_ need it. :D --- krebs/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/krebs/default.nix b/krebs/default.nix index 5518a4496..5f1cfb95b 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -126,6 +126,16 @@ let out = { } > nixos-install chmod +x nixos-install + # Wrap inserted nix-install into chroot. + nix_env=$(cat_src | sed -n ' + s:.*\(/nix/store/[a-z0-9]*-nix-[0-9.]\+/bin/nix-env\).*:\1:p;T;q + ') + echo nix-env is $nix_env + sed -i ' + s:^NIX_PATH=:chroot $mountPoint /usr/bin/env &: + s:^nix-env:'"$nix_env"': + ' nixos-install + unset SSL_CERT_FILE ./nixos-install ''} From 5f0e54f3cc8775fa609c3e790b2a287e0f4e9d4d Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 02:23:57 +0200 Subject: [PATCH 33/71] l 4: no longer import krebs --- lass/4lib/default.nix | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lass/4lib/default.nix b/lass/4lib/default.nix index 2e493177d..6a8a28972 100644 --- a/lass/4lib/default.nix +++ b/lass/4lib/default.nix @@ -1,12 +1,8 @@ { lib, pkgs, ... }: -let - krebs = import ../../krebs/4lib { inherit lib; }; -in +with lib; -with krebs; - -krebs // rec { +{ simpleScript = name: content: pkgs.stdenv.mkDerivation { From 48abef60c172bdd5d15e574138824a89b23fa86d Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 12:45:50 +0200 Subject: [PATCH 34/71] krebs.nixos-install: discover coreutils in /mnt --- krebs/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/krebs/default.nix b/krebs/default.nix index 5f1cfb95b..24d9e843b 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -130,9 +130,12 @@ let out = { nix_env=$(cat_src | sed -n ' s:.*\(/nix/store/[a-z0-9]*-nix-[0-9.]\+/bin/nix-env\).*:\1:p;T;q ') + coreutils=$(find /mnt/nix/store \ + -mindepth 1 -maxdepth 1 -type d -name '*-coreutils-*' \ + | head -n 1 | sed s:^/mnt::) echo nix-env is $nix_env sed -i ' - s:^NIX_PATH=:chroot $mountPoint /usr/bin/env &: + s:^NIX_PATH=:chroot $mountPoint '"$coreutils"'/bin/env &: s:^nix-env:'"$nix_env"': ' nixos-install From df04a82426ad36726da7becae5ec4b6c33d8d14b Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 13:13:49 +0200 Subject: [PATCH 35/71] krebs.nixos-infest: set SSL_CERT_FILE properly --- krebs/default.nix | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index 24d9e843b..0b055cd24 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -130,16 +130,24 @@ let out = { nix_env=$(cat_src | sed -n ' s:.*\(/nix/store/[a-z0-9]*-nix-[0-9.]\+/bin/nix-env\).*:\1:p;T;q ') - coreutils=$(find /mnt/nix/store \ - -mindepth 1 -maxdepth 1 -type d -name '*-coreutils-*' \ - | head -n 1 | sed s:^/mnt::) - echo nix-env is $nix_env + echo "nix-env is $nix_env" >&2 + getchrootpath() {( + name=$1 + path=$(find /mnt/nix/store \ + -mindepth 1 -maxdepth 1 -type d -name '*-'"$name"'-*' \ + | head -n 1 | sed s:^/mnt::) + echo "$name is $path" >&2 + echo "$path" + )} + cacert=$(getchrootpath cacert) + coreutils=$(getchrootpath coreutils) + env="$coreutils/bin/env \ + SSL_CERT_FILE=$cacert/etc/ssl/certs/ca-bundle.crt" sed -i ' - s:^NIX_PATH=:chroot $mountPoint '"$coreutils"'/bin/env &: + s:^NIX_PATH=:chroot $mountPoint '"$env"' &: s:^nix-env:'"$nix_env"': ' nixos-install - unset SSL_CERT_FILE ./nixos-install ''} ''; From 0863983b7d7568266ed078dbce7ff96e08f2f082 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 13:16:04 +0200 Subject: [PATCH 36/71] wu: add alias cgit.wu.retiolum --- krebs/3modules/tv/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix index 5a1ff1416..f3dcd18b0 100644 --- a/krebs/3modules/tv/default.nix +++ b/krebs/3modules/tv/default.nix @@ -231,6 +231,7 @@ with lib; addrs6 = ["42:0:0:0:0:0:0:1337"]; aliases = [ "wu.retiolum" + "cgit.wu.retiolum" ]; tinc.pubkey = '' -----BEGIN RSA PUBLIC KEY----- From b55f07e57af69f918182405d473d22981c515b86 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 13:48:53 +0200 Subject: [PATCH 37/71] mkdir: 104.233.84.215 -> 104.167.114.142 --- krebs/3modules/tv/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix index f3dcd18b0..4c295dffe 100644 --- a/krebs/3modules/tv/default.nix +++ b/krebs/3modules/tv/default.nix @@ -65,7 +65,7 @@ with lib; dc = "tv"; #dc = "cac"; nets = rec { internet = { - addrs4 = ["104.233.84.215"]; + addrs4 = ["104.167.114.142"]; aliases = [ "mkdir.internet" ]; From 14f08e2a1c6e8065c0fef15539df030eb2054ac1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 13:51:10 +0200 Subject: [PATCH 38/71] k 3 l: add cores to testsystems --- krebs/3modules/lass/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index d86c00563..498282b03 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -9,6 +9,7 @@ let "test-centos7" ] (name: { inherit name; + cores = 1; nets = { retiolum = { addrs4 = ["10.243.111.111"]; From 10be0e70063ba83fef47295ebcbb1ac11a22c6b5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 15:59:36 +0200 Subject: [PATCH 39/71] l 3: add dnsmasq.nix --- lass/3modules/dnsmasq.nix | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lass/3modules/dnsmasq.nix diff --git a/lass/3modules/dnsmasq.nix b/lass/3modules/dnsmasq.nix new file mode 100644 index 000000000..99c165479 --- /dev/null +++ b/lass/3modules/dnsmasq.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ... }: + +with builtins; +with lib; + +let + cfg = config.lass.dnsmasq; + + out = { + options.lass.dnsmasq = api; + config = mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "dnsmasq"; + config = mkOption { + type = types.str; + #TODO: find a good default + default = '' + ''; + description = "configuration dnsmasq is started with"; + }; + }; + + configFile = pkgs.writeText "dnsmasq.conf" cfg.config; + + imp = { + #users.extraUsers.go = { + # name = "go"; + # uid = 42774411; #genid go + # description = "go url shortener user"; + # home = "/var/lib/go"; + # createHome = true; + #}; + + systemd.services.dnsmasq = { + description = "dnsmasq"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + path = with pkgs; [ + dnsmasq + ]; + + + restartIfChanged = true; + + serviceConfig = { + Restart = "always"; + ExecStart = "${pkgs.dnsmasq}/bin/dnsmasq -k -C ${configFile}"; + }; + }; + }; + +in out From 27a4aa4a49b9befe278bb4dfa68a749822aea2c0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 21 Oct 2015 15:59:47 +0200 Subject: [PATCH 40/71] l 1 echelon: add dnsmasq config --- lass/1systems/echelon.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lass/1systems/echelon.nix b/lass/1systems/echelon.nix index 80cb51060..94c793b08 100644 --- a/lass/1systems/echelon.nix +++ b/lass/1systems/echelon.nix @@ -33,6 +33,20 @@ in { { sound.enable = false; } + { + imports = [ + ../3modules/dnsmasq.nix + ]; + lass.dnsmasq = { + enable = true; + config = '' + interface=retiolum + ''; + }; + krebs.iptables.tables.filter.INPUT.rules = [ + { predicate = "-i retiolum -p udp --dport 53"; target = "ACCEPT"; } + ]; + } ]; krebs.build.host = config.krebs.hosts.echelon; From 714a2e492270d984e8987532c247ae4caf69fce0 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 22:29:35 +0200 Subject: [PATCH 41/71] stockholm: only inherit in out --- default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index c70225174..fc322cb80 100644 --- a/default.nix +++ b/default.nix @@ -44,7 +44,7 @@ let stockholm = { # Additionally, output lib and pkgs for easy access from the shell. # Notice how we're evaluating just the base module to obtain pkgs. inherit lib; - inherit (eval {}) pkgs; + inherit pkgs; }; krebs = import ./krebs (current // { inherit lib stockholm; }); @@ -62,6 +62,8 @@ let stockholm = { nspath = ns: p: stockholm-path + "/${ns}/${p}"; }; + inherit (eval {}) pkgs; + # Path resolvers for common and individual files. # Example: `upath "3modules"` produces the current user's 3modules directory kpath = lib.nspath "krebs"; From 5206c11026245b1fe20a66fb5b14165e51195f0b Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 22:43:11 +0200 Subject: [PATCH 42/71] wu nixpkgs: f77bf46 -> 9048637 --- tv/1systems/wu.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index c691066cb..c687ae52d 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -10,8 +10,11 @@ with lib; krebs.build.source = { git.nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "e916273209560b302ab231606babf5ce1c481f08"; + #url = https://github.com/NixOS/nixpkgs; + #rev = "f77bf46c1e705934a00c52d90cc62a76fbb1f6b5"; + # Revert "rxvt_unicode: add patch to fix Shift+PgUp/PgDown bug" + url = https://github.com/4z3/nixpkgs; + rev = "9048637"; }; dir.secrets = { host = config.krebs.hosts.wu; From fc64fd18cb8677f08d038a086de879fd69f89b8c Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2015 00:20:16 +0200 Subject: [PATCH 43/71] krebs.*: make StrictHostKeyChecking configurable --- default.nix | 5 +++-- krebs/default.nix | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index fc322cb80..b261e51e7 100644 --- a/default.nix +++ b/default.nix @@ -17,7 +17,8 @@ { current-date ? abort "current-date not defined" , current-host-name ? abort "current-host-name not defined" , current-user-name ? builtins.getEnv "LOGNAME" -}@current: +, StrictHostKeyChecking ? "yes" +}@args: let stockholm = { # The generated scripts to deploy (or infest) systems can be found in the @@ -47,7 +48,7 @@ let stockholm = { inherit pkgs; }; - krebs = import ./krebs (current // { inherit lib stockholm; }); + krebs = import ./krebs (args // { inherit lib stockholm; }); lib = let diff --git a/krebs/default.nix b/krebs/default.nix index 0b055cd24..08de72294 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -3,6 +3,7 @@ , current-user-name , lib , stockholm +, StrictHostKeyChecking ? "yes" }: let out = { @@ -260,7 +261,10 @@ let out = { in out; rootssh = target: script: - "ssh root@${target} -T ${doc '' + let + flags = "-o StrictHostKeyChecking=${StrictHostKeyChecking}"; + in + "ssh ${flags} root@${target} -T ${doc '' set -efu ${script} ''}"; From 4b8ffc1bfd494de1fafde2527a337ad5eb31a27c Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2015 00:23:02 +0200 Subject: [PATCH 44/71] krebs.nixos-install: fail if pkg cannot be found Collaterally, search in /nix instead of /mnt/nix --- krebs/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index 08de72294..40d245f98 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -132,16 +132,20 @@ let out = { s:.*\(/nix/store/[a-z0-9]*-nix-[0-9.]\+/bin/nix-env\).*:\1:p;T;q ') echo "nix-env is $nix_env" >&2 - getchrootpath() {( + findpkg() {( name=$1 - path=$(find /mnt/nix/store \ + path=$(find /nix/store \ -mindepth 1 -maxdepth 1 -type d -name '*-'"$name"'-*' \ | head -n 1 | sed s:^/mnt::) - echo "$name is $path" >&2 - echo "$path" + if echo "$path" | grep .; then + echo "$name is $path" >&2 + else + echo "Error: package not found: $name" >&2 + exit 1 + fi )} - cacert=$(getchrootpath cacert) - coreutils=$(getchrootpath coreutils) + cacert=$(findpkg cacert) + coreutils=$(findpkg coreutils) env="$coreutils/bin/env \ SSL_CERT_FILE=$cacert/etc/ssl/certs/ca-bundle.crt" sed -i ' From df6f0392cbdf7923537eb5d328bd345cde11eb53 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2015 00:49:51 +0200 Subject: [PATCH 45/71] krebs.nixos-install: cacert -> /root/SSL_CERT_FILE --- krebs/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/default.nix b/krebs/default.nix index 40d245f98..31a7f7d04 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -146,8 +146,8 @@ let out = { )} cacert=$(findpkg cacert) coreutils=$(findpkg coreutils) - env="$coreutils/bin/env \ - SSL_CERT_FILE=$cacert/etc/ssl/certs/ca-bundle.crt" + cp "$cacert"/etc/ssl/certs/ca-bundle.crt /mnt/root/SSL_CERT_FILE + env="$coreutils/bin/env SSL_CERT_FILE=/root/SSL_CERT_FILE" sed -i ' s:^NIX_PATH=:chroot $mountPoint '"$env"' &: s:^nix-env:'"$nix_env"': From e557bc2e58c3e276656853c42cb00db979570135 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2015 01:25:44 +0200 Subject: [PATCH 46/71] nomic: bump file systems --- tv/1systems/nomic.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tv/1systems/nomic.nix b/tv/1systems/nomic.nix index 718f6ae24..210846215 100644 --- a/tv/1systems/nomic.nix +++ b/tv/1systems/nomic.nix @@ -64,27 +64,24 @@ with lib; ]; boot.initrd.luks = { - cryptoModules = [ "aes" "sha1" "xts" ]; + cryptoModules = [ "aes" "sha512" "xts" ]; devices = [ - { - name = "luks1"; - device = "/dev/disk/by-uuid/cac73902-1023-4906-8e95-3a8b245337d4"; - } + { name = "luks1"; device = "/dev/sda2"; } ]; }; fileSystems."/" = - { device = "/dev/disk/by-uuid/de4780fc-0473-4708-81df-299b7383274c"; + { device = "/dev/mapper/nomic1-root"; fsType = "btrfs"; }; fileSystems."/boot" = - { device = "/dev/disk/by-uuid/be3a1d80-3157-4d7c-86cc-ef01b64eff5e"; + { device = "/dev/sda1"; fsType = "ext4"; }; fileSystems."/home" = - { device = "/dev/disk/by-uuid/9db9c8ff-51da-4cbd-9f0a-0cd3333bbaff"; + { device = "/dev/mapper/nomic1-home"; fsType = "btrfs"; }; From c2e1ab2bd09c204e1fa1c4ecd637c2e5b8a4b9ab Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2015 01:25:02 +0200 Subject: [PATCH 47/71] tv base systemPackages += git --- tv/1systems/cd.nix | 1 - tv/1systems/mkdir.nix | 1 - tv/1systems/rmdir.nix | 1 - tv/1systems/wu.nix | 1 - tv/2configs/base.nix | 6 ++++++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix index 12e52cd11..d2b08bef7 100644 --- a/tv/1systems/cd.nix +++ b/tv/1systems/cd.nix @@ -114,7 +114,6 @@ with lib; ]; environment.systemPackages = with pkgs; [ - git # required for ./deploy, clone_or_update htop iftop iotop diff --git a/tv/1systems/mkdir.nix b/tv/1systems/mkdir.nix index 669dcc2f3..f0c7dc2a0 100644 --- a/tv/1systems/mkdir.nix +++ b/tv/1systems/mkdir.nix @@ -88,7 +88,6 @@ in ]; environment.systemPackages = with pkgs; [ - git # required for ./deploy, clone_or_update htop iftop iotop diff --git a/tv/1systems/rmdir.nix b/tv/1systems/rmdir.nix index 79e47c539..c52222cd1 100644 --- a/tv/1systems/rmdir.nix +++ b/tv/1systems/rmdir.nix @@ -84,7 +84,6 @@ in ]; environment.systemPackages = with pkgs; [ - git # required for ./deploy, clone_or_update htop iftop iotop diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index c687ae52d..404fdb3d1 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -40,7 +40,6 @@ with lib; # stockholm genid - git gnumake hashPassword lentil diff --git a/tv/2configs/base.nix b/tv/2configs/base.nix index 010d4b326..4de980cf1 100644 --- a/tv/2configs/base.nix +++ b/tv/2configs/base.nix @@ -14,6 +14,12 @@ in networking.hostName = config.krebs.build.host.name; imports = [ + { + # stockholm dependencies + environment.systemPackages = with pkgs; [ + git + ]; + } { # TODO never put hashedPassword into the store users.extraUsers = From 9ba8fc142cb14aa3768cb99bf9170f7875beafd1 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2015 12:48:17 +0200 Subject: [PATCH 48/71] wu nixpkgs: 9048637 -> e916273 Current unstable is really unstable w/system hangs. --- tv/1systems/wu.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 404fdb3d1..89ad257f0 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -10,11 +10,8 @@ with lib; krebs.build.source = { git.nixpkgs = { - #url = https://github.com/NixOS/nixpkgs; - #rev = "f77bf46c1e705934a00c52d90cc62a76fbb1f6b5"; - # Revert "rxvt_unicode: add patch to fix Shift+PgUp/PgDown bug" - url = https://github.com/4z3/nixpkgs; - rev = "9048637"; + url = https://github.com/NixOS/nixpkgs; + rev = "e916273209560b302ab231606babf5ce1c481f08"; }; dir.secrets = { host = config.krebs.hosts.wu; From 709ebf6bbcc2e0d4644ed35cd42db47c4f2e78c5 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Oct 2015 15:31:31 +0200 Subject: [PATCH 49/71] krebs 3 zone-generation: for consistency, add newline at the end --- krebs/3modules/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 075db1826..bc858f668 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -105,8 +105,8 @@ let # Implements environment.etc."zones/" environment.etc = let - stripEmptyLines = s: concatStringsSep "\n" - (remove "\n" (remove "" (splitString "\n" s))); + stripEmptyLines = s: (concatStringsSep "\n" + (remove "\n" (remove "" (splitString "\n" s)))) + "\n"; all-zones = foldAttrs (sum: current: sum + "\n" +current ) "" ([cfg.zone-head-config] ++ combined-hosts); combined-hosts = (mapAttrsToList (name: value: value.extraZones) cfg.hosts ); From cc59f4d6b640752c1277ec3bdfca88404c3b4357 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 10:40:07 +0200 Subject: [PATCH 50/71] l 2: add c --- lass/2configs/newsbot-js.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lass/2configs/newsbot-js.nix b/lass/2configs/newsbot-js.nix index 211b29780..74d09b7fa 100644 --- a/lass/2configs/newsbot-js.nix +++ b/lass/2configs/newsbot-js.nix @@ -21,6 +21,7 @@ let bdt_pressemitteilungen|http://bundestag.de/service/rss/Bundestag_Presse.rss|#news #bundestag bdt_wd|http://bundestag.de/service/rss/Bundestag_WD.rss|#news #bundestag bitcoinpakistan|https://bitcoinspakistan.com/feed/|#news #financial + c|http://www.tempolimit-lichtgeschwindigkeit.de/news.xml|#news cancer|http://feeds.feedburner.com/ncinewsreleases?format=xml|#news carta|http://feeds2.feedburner.com/carta-standard-rss|#news catholic_news|http://feeds.feedburner.com/catholicnewsagency/dailynews|#news From abcfba84ca375f868f84188aed704be26d145221 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 15:15:57 +0200 Subject: [PATCH 51/71] stockholm: lol literate --- default.nix | 55 ----------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/default.nix b/default.nix index b261e51e7..c78464198 100644 --- a/default.nix +++ b/default.nix @@ -1,19 +1,3 @@ -# Welcome to the top-level default.nix of stockholm. -# -# You can discover the whole thing easily using the `get` utility, -# which can be found at http://cgit.cd.krebsco.de/get/tree/get -# To install `get` on any Nix-enabled system, use: -# -# nix-env -f /path/to/stockholm -iA pkgs.get -# -# The "current" arguments are used to provide information about the user who's -# evaluating this file. This information is used to determine which user -# namespace is to be used. Of course there's nothing trying to prevent you -# from forging this information. E.g. you could try to generate the deployment -# script for some random user's system, targeting some random host: -# -# LOGNAME=tv get krebs.deploy system=nomic target=8.8.8.8 -# { current-date ? abort "current-date not defined" , current-host-name ? abort "current-host-name not defined" , current-user-name ? builtins.getEnv "LOGNAME" @@ -21,29 +5,8 @@ }@args: let stockholm = { - # The generated scripts to deploy (or infest) systems can be found in the - # `krebs` attribute. There's also an init script, but it's in its early - # stages, not well integrated and mostly useless at the moment. :) - # - # You'll also find lib here, which is nixpkgs/lib + krebs lib, but nobody - # is really accessing this directly, as this lib gets reexported below. inherit krebs; - - # All systems of all users can be found here. - # - # /!\ Please note that `get users.${user-name}.${host-name}.system` is a - # bad idea because it will produce vast amounts of output. These are the - # actual and complete system derivations that can be installed on the - # respective host. - # - # Another thing to notice here is that other user's systems might not be - # evaluable because of missing secrets. If you _are_ able to evaluate - # another user's system, then you probably share a similar naming scheme - # for your secret files! :) inherit users; - - # Additionally, output lib and pkgs for easy access from the shell. - # Notice how we're evaluating just the base module to obtain pkgs. inherit lib; inherit pkgs; }; @@ -65,32 +28,20 @@ let stockholm = { inherit (eval {}) pkgs; - # Path resolvers for common and individual files. - # Example: `upath "3modules"` produces the current user's 3modules directory kpath = lib.nspath "krebs"; upath = lib.nspath current-user-name; - # This is the base module. Its purpose is to provide modules and - # packages, both common ones, found in krebs/ as well as the current user's, - # found in the user's namespace. base-module = { imports = map (f: f "3modules") [ kpath upath ]; nixpkgs.config.packageOverrides = pkgs: let - # Notice the ordering. Krebs packages can only depend on Nixpkgs, - # whereas user packages additionally can depend on krebs packages. kpkgs = import (kpath "5pkgs") { inherit lib pkgs; }; upkgs = import (upath "5pkgs") { inherit lib; pkgs = pkgs // kpkgs; }; in kpkgs // upkgs; }; - # The above base module is used together with a NixOS configuration to - # produce a system. Notice how stockholm really just provides additional - # packages and modules on top of NixOS. Some of this stuff might become - # useful to a broader audience, at which point it should probably be merged - # and pull-requested for inclusion into NixOS/nixpkgs. eval = config: import { specialArgs = { inherit lib; @@ -101,10 +52,6 @@ let stockholm = { ]; }; - # Any top-level directory other than krebs/ is considered to be a user - # namespace, configuring a bunch of systems. - # Have a look at the definition of install in krebs/default.nix to see how - # nix-env is using this attribute set to obtain the system to be installed. # TODO move user namespaces' to users/, so no exception for krebs/ is needed users = lib.mapAttrs @@ -113,8 +60,6 @@ let stockholm = { (n: t: !lib.hasPrefix "." n && t == "directory" && n != "krebs") (builtins.readDir ./.)); - # Given a path to a user namespace, provide an attribute of evaluated - # system configurations, keyed by system names (AKA host names). eval-all-systems = path: lib.mapAttrs' (n: _: (lib.nameValuePair (lib.removeSuffix ".nix" n) From a01651485b21501df2f602c67381a1f5e9ce656b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 21:15:54 +0200 Subject: [PATCH 52/71] tv: import ~/.Xresources --- tv/2configs/xserver/Xresources.nix | 214 +++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 tv/2configs/xserver/Xresources.nix diff --git a/tv/2configs/xserver/Xresources.nix b/tv/2configs/xserver/Xresources.nix new file mode 100644 index 000000000..f8414b861 --- /dev/null +++ b/tv/2configs/xserver/Xresources.nix @@ -0,0 +1,214 @@ +{ config, lib, pkgs, ... }: + +with lib; + +pkgs.writeText "Xresources" '' + !URxvt*background: #050505 + + ! 2013-02-25 \e was reas escape before + ! *VT100.Translations: #override\ + ! :: string("\e[5~")\n\ + ! :: string("\e[6~") + + ! XTerm*VT100*Translations: #override \ + ! ShiftReturn: string(" &") string(0x0A) \n\ + ! MetaReturn: string(" | less") string(0x0A) \n\ + ! ~ShiftPrior: scroll-back(1,page) \n\ + ! ~ShiftNext: scroll-forw(1,page) \n\ + ! ShiftPrior: scroll-back(1) \n\ + ! ShiftNext: scroll-forw(1) \n\ + ! Delete: string(0x1b) string("[2~") + ! \n\ + ! BackSpace: string(0x7f) + + ! 2013-02-2013-02-25 + ! ! : load bash-completion (if not already) + ! URxvt*VT100*Translations: #override\ + ! Metac:\ + ! string("\eOH# \eOF\n+compl\n\eOA\eOA\eOH\e[3~\e[3~\eOF")\ + ! string(0x7)\n + + ! do not scroll automatically on output: + ! XTerm*scrollTtyOutput: false + URxvt*cutchars: "\\`\"'&()*,;<=>?@[]^{|}‘’" + ! URxvt*secondaryScreen: false + + ! URxvt*loginShell: true + + URxvt*eightBitInput: false + ! *eightBitOutput: 1 + ! URxvt*decTerminalID: 220 + ! URxvt*utf8: 1 + ! URxvt*locale: UTF-8 + ! XTerm*customization: -color + URxvt*SaveLines: 4096 + URxvt*font: -*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1 + URxvt*boldFont: -*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1 + + ! 2013-05-23 if this does not work try + ! xset +fp /usr/share/fonts/local/ + ! xset fp rehash + ! URxvt*font: -*-termsynu-edium-*-*-*-12-*-*-*-*-*-iso10646-1 + ! URxvt*boldFont: -*-termsynu-bold-*-*-*-12-*-*-*-*-*-iso10646-1 + ! + !-misc-termsynu-medium-r-normal--12-87-100-100-c-70-iso10646-1 + + ! XTerm*font: -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1 + URxvt*scrollBar: false + + ! XTerm*font:-nil-profont-medium-r-normal--11-110-72-72-c-60-iso8859-1 + ! URxvt*boldFont:-nil-profont-medium-r-normal--11-110-72-72-c-60-iso8859-1 + + URxvt*background: #050505 + ! URxvt*background: #041204 + + !URxvt.depth: 32 + !URxvt*background: rgba:0500/0500/0500/cccc + + ! URxvt*background: #080810 + URxvt*foreground: #d0d7d0 + ! URxvt*background: black + ! URxvt*foreground: white + ! URxvt*background: rgb:00/00/40 + ! URxvt*foreground: rgb:a0/a0/d0 + ! XTerm*cursorColor: rgb:00/00/60 + URxvt*cursorColor: #f042b0 + URxvt*cursorColor2: #f0b000 + URxvt*cursorBlink: off + ! URxvt*cursorUnderline: true + ! URxvt*highlightColor: #232323 + ! URxvt*highlightTextColor: #b0ffb0 + + URxvt*.pointerBlank: true + URxvt*.pointerBlankDelay: 987654321 + URxvt*.pointerColor: #f042b0 + URxvt*.pointerColor2: #050505 + + ! URxvt*fading: 50 + ! URxvt*fadeColor: #0f0f0f + + ! XTerm*colorMode: on + ! URxvt*dynamicColors: on + ! URxvt*boldColors: off + + URxvt*jumpScroll: true + + ! allow synthetic events for fvwm, so pass window specific keys + ! XTerm*allowSendEvents: true + URxvt*allowSendEvents: false + + ! better double/tripple clicking in xterms + ! Format: csv, [low-]high:value + ! + ! extend character class 48 due they are used in urls + ! (see: man xterm; /CHARACTER CLASSES) + ! ! % -./ @ & = ? + URxvt*charClass: 33:48,37:48,45-47:48,64:48,38:48,61:48,63:48 + URxvt*cutNewline: False + URxvt*cutToBeginningOfLine: False + + ! BLACK for indigo background + URxvt*color0: #232342 + + ! TODO: man xterm; /ACTIONS + + ! *VT100*colorULMode: on + ! XTerm*underLine: on + ! + ! URxvt*color0: black + ! URxvt*color1: red3 + ! URxvt*color2: green3 + ! URxvt*color3: yellow3 + ! URxvt*color4: blue2 + ! URxvt*color5: magenta3 + ! URxvt*color6: cyan3 + ! URxvt*color7: gray90 + ! URxvt*color8: burlywood1 + ! URxvt*color9: sienna1 + ! URxvt*color10: PaleVioletRed1 + ! URxvt*color11: LightSkyBlue + ! URxvt*color12: white + ! URxvt*color13: white + ! URxvt*color14: white + ! URxvt*color33: #f0b0f0 + + + ! URxvt*color0: #000000 + ! URxvt*color1: #c00000 + ! URxvt*color2: #80c070 + URxvt*color3: #c07000 + ! URxvt*color4: #0000c0 + URxvt*color4: #4040c0 + ! URxvt*color5: #c000c0 + ! URxvt*color6: #008080 + URxvt*color7: #c0c0c0 + + URxvt*color8: #707070 + URxvt*color9: #ff6060 + URxvt*color10: #70ff70 + URxvt*color11: #ffff70 + URxvt*color12: #7070ff + URxvt*color13: #ff50ff + URxvt*color14: #70ffff + URxvt*color15: #ffffff + + ! XTerm*color91: #000070 + ! XTerm*color92: #000080 + ! XTerm*color93: #000090 + ! XTerm*color94: #0000a0 + ! XTerm*color95: #0000b0 + ! XTerm*color96: #0000c0 + ! XTerm*color97: #0000d0 + ! XTerm*color98: #0000e0 + ! XTerm*color99: #0000f0 + + ! !! vim-create-colorscheme {{{ + ! !! Question cterm=none + ! XTerm*color20: #f0b000 + ! !! }}} + ! + ! + ! #include ".xrdb/look-zenburn.xrdb" + ! #include ".xrdb/xterm.xrdb" + + + + ! URxvt.perl-ext: matcher + ! URxvt.urlLauncher: cr + ! URxvt.underlineColor: blue + + ! URxvt.matcher.button: 1 + ! URxvt.perl-ext: default,matcher + ! URxvt.urlLauncher: cr + ! URxvt.matcher.pattern.1: \\bwww\\.[\\w-]+\\.[\\w./?&@#-]*[\\w/-] + ! URxvt.underlineColor: blue + + ! 2014-05-12 von lass + !URxvt.perl-ext-common: default,clipboard,url-select,keyboard-select + !URxvt.url-select.launcher: /home/tv/bin/ff -new-tab + !URxvt.url-select.underline: true + !URxvt.keysym.M-u: perl:url-select:select_next + !URxvt.keysym.M-Escape: perl:keyboard-select:activate + !URxvt.keysym.M-s: perl:keyboard-select:search + + + + + ! 2013-02-25 I neve use this + URxvt*iso14755: False + + URxvt*urgentOnBell: True + URxvt*visualBell: True + + ! ref https://github.com/muennich/urxvt-perls + URxvt*perl-ext: default,url-select + URxvt*keysym.M-u: perl:url-select:select_next + !URxvt*url-select.launcher: /home/tv/free/firefox -new-tab + ! 2014-05-12 nix: + !URxvt.url-select.launcher: /home/tv/bin/ff -new-tab + ! 2015-07-26 stockholm: + URxvt*url-select.launcher: ff -new-tab + URxvt*url-select.underline: true + URxvt*colorUL: #4682B4 + URxvt.perl-lib: ${pkgs.urxvt_perls}/lib/urxvt/perl +'' From b2deab26bd52a994003cafc33872b6c084cdd716 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 22:09:55 +0200 Subject: [PATCH 53/71] tv: nano really is just vim This is required or else we have to modify glorious packages like cvs. --- tv/2configs/base.nix | 7 +- tv/2configs/xserver/xmonad-tv/Main.hs | 277 +++++++++++++ tv/2configs/xserver/xmonad-tv/Util/Debunk.hs | 16 + tv/2configs/xserver/xmonad-tv/Util/Font.hs | 123 ++++++ tv/2configs/xserver/xmonad-tv/Util/Pager.hs | 172 ++++++++ tv/2configs/xserver/xmonad-tv/Util/Rhombus.hs | 370 ++++++++++++++++++ tv/2configs/xserver/xmonad-tv/Util/Submap.hs | 31 ++ tv/2configs/xserver/xmonad-tv/Util/XUtils.hs | 47 +++ tv/2configs/xserver/xmonad-tv/default.nix | 1 + tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal | 19 + 10 files changed, 1059 insertions(+), 4 deletions(-) create mode 100644 tv/2configs/xserver/xmonad-tv/Main.hs create mode 100644 tv/2configs/xserver/xmonad-tv/Util/Debunk.hs create mode 100644 tv/2configs/xserver/xmonad-tv/Util/Font.hs create mode 100644 tv/2configs/xserver/xmonad-tv/Util/Pager.hs create mode 100644 tv/2configs/xserver/xmonad-tv/Util/Rhombus.hs create mode 100644 tv/2configs/xserver/xmonad-tv/Util/Submap.hs create mode 100644 tv/2configs/xserver/xmonad-tv/Util/XUtils.hs create mode 100644 tv/2configs/xserver/xmonad-tv/default.nix create mode 100644 tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal diff --git a/tv/2configs/base.nix b/tv/2configs/base.nix index 4de980cf1..0a8dbdcc2 100644 --- a/tv/2configs/base.nix +++ b/tv/2configs/base.nix @@ -153,10 +153,9 @@ in } { - nixpkgs.config.packageOverrides = pkgs: - { - nano = pkgs.runCommand "empty" {} "mkdir -p $out"; - }; + nixpkgs.config.packageOverrides = pkgs: { + nano = pkgs.vim; + }; services.cron.enable = false; services.nscd.enable = false; diff --git a/tv/2configs/xserver/xmonad-tv/Main.hs b/tv/2configs/xserver/xmonad-tv/Main.hs new file mode 100644 index 000000000..a298d72e7 --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/Main.hs @@ -0,0 +1,277 @@ +{-# LANGUAGE DeriveDataTypeable #-} -- for XS + + +module Main where + +import XMonad +import XMonad.Prompt (defaultXPConfig) +import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace + , removeEmptyWorkspace) +import XMonad.Actions.GridSelect +import XMonad.Actions.CycleWS (toggleWS) +--import XMonad.Actions.CopyWindow ( copy ) +import XMonad.Layout.NoBorders ( smartBorders ) +import qualified XMonad.StackSet as W +import Data.Map (Map) +import qualified Data.Map as Map +-- TODO import XMonad.Layout.WorkspaceDir +import XMonad.Hooks.UrgencyHook (SpawnUrgencyHook(..), withUrgencyHook) +-- import XMonad.Layout.Tabbed +--import XMonad.Layout.MouseResizableTile +import XMonad.Layout.Reflect (reflectVert) +import XMonad.Layout.FixedColumn (FixedColumn(..)) +import XMonad.Hooks.Place (placeHook, smart) +import XMonad.Hooks.FloatNext (floatNextHook) +import XMonad.Actions.PerWorkspaceKeys (chooseAction) +import XMonad.Layout.PerWorkspace (onWorkspace) +--import XMonad.Layout.BinarySpacePartition + +--import XMonad.Actions.Submap +import Util.Pager +import Util.Rhombus +import Util.Debunk + + +--data MyState = MyState deriving Typeable + +myTerm :: String +myTerm = "urxvtc" + +myRootTerm :: String +myRootTerm = "XENVIRONMENT=\"$HOME/.Xdefaults/root-urxvt\" urxvtc -e su -" + +-- TODO execRootTerm = exec (shlex "urxvtc -e su -") +-- [ ("XENVIRONMENT", HOME ++ "/.Xdefaults/root-urxvt") ] + + +myFont :: String +myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" + +main :: IO () +main = do + -- TODO exec (shlex "xrdb -merge" ++ [HOME ++ "/.Xresources"]) + -- TODO exec (shlex "xsetroot -solid '#1c1c1c'") + --spawn "xrdb -merge \"$HOME/.Xresources\"" + --spawn "xsetroot -solid '#1c1c1c'" + xmonad + -- $ withUrgencyHookC dzenUrgencyHook { args = ["-bg", "magenta", "-fg", "magenta", "-h", "2"], duration = 500000 } + -- urgencyConfig { remindWhen = Every 1 } + -- $ withUrgencyHook borderUrgencyHook "magenta" + -- $ withUrgencyHookC BorderUrgencyHook { urgencyBorderColor = "magenta" } urgencyConfig { suppressWhen = Never } + $ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ") + $ defaultConfig + { terminal = myTerm + , modMask = mod4Mask + , keys = myKeys + , workspaces = + [ "Dashboard" -- we start here + , "23" + , "cr" + , "ff" + , "hack" + , "im" + , "mail" + , "zalora", "zjournal", "zskype" + ] + , layoutHook = smartBorders $ myLayout + -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent + --, handleEventHook = handleTimerEvent + , manageHook = placeHook (smart (1,0)) <+> floatNextHook + , startupHook = spawn "echo emit XMonadStartup" + , normalBorderColor = "#1c1c1c" + , focusedBorderColor = "#f000b0" + } + where + myLayout = + (onWorkspace "im" $ reflectVert $ Mirror $ Tall 1 (3/100) (12/13)) + (FixedColumn 1 20 80 10 ||| Full) + + +spawnTermAt :: String -> X () +--spawnTermAt _ = floatNext True >> spawn myTerm +--spawnTermAt "ff" = floatNext True >> spawn myTerm +spawnTermAt _ = spawn myTerm + + + +--jojo w = withDisplay $ \d -> liftIO $ do +-- wa <- getWindowAttributes d w +-- printToErrors (wa_width wa, wa_height wa, wa_x wa, wa_y wa) + + --sh <- getWMNormalHints d w + --bw <- fmap (fi . wa_border_width) $ getWindowAttributes d w + --return $ applySizeHints bw sh + + +--data WindowDetails = WindowDetails +-- { wd_name :: Maybe String +-- , wd_rect :: Rectangle +-- } deriving (Show) + +-- urxvtc +-- -title sets {,_NET_}WM_NAME but not WM_CLASS and {,_NET_}WM_ICON_NAME res: title +-- -name sets all res: +--mySpawn cmd = do +-- p <- xfork $ executeFile "/run/current-system/sw/bin/urxvtc" False [] Nothing +-- liftIO $ printToErrors $ (cmd, p) + + +myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) +myKeys conf = Map.fromList $ + [ ((_4C , xK_Delete ), spawn "make -C $HOME/.xmonad reload") + , ((_4 , xK_Escape ), spawn "/var/setuid-wrappers/slock") + , ((_4S , xK_c ), kill) + + , ((_4 , xK_x ), chooseAction spawnTermAt) + , ((_4C , xK_x ), spawn myRootTerm) + --, ((_4M , xK_x ), spawn "xterm") + --, ((_4M , xK_x ), mySpawn "xterm") + + --, ((_4 , xK_F1 ), withFocused jojo) + --, ((_4 , xK_F1 ), printAllGeometries) + + , ((0 , xK_Menu ), gets windowset >>= allWorkspaceNames >>= pager pagerConfig (windows . W.view) ) + , ((_S , xK_Menu ), gets windowset >>= allWorkspaceNames >>= pager pagerConfig (windows . W.shift) ) + , ((_C , xK_Menu ), toggleWS) + , ((_4 , xK_Menu ), rhombus horseConfig (liftIO . printToErrors) ["Correct", "Horse", "Battery", "Staple", "Stuhl", "Tisch"] ) + + -- %! Rotate through the available layout algorithms + , ((_4 , xK_space ), sendMessage NextLayout) + , ((_4S , xK_space ), setLayout $ XMonad.layoutHook conf) -- reset layout + + ---- BinarySpacePartition + --, ((_4 , xK_l), sendMessage $ ExpandTowards R) + --, ((_4 , xK_h), sendMessage $ ExpandTowards L) + --, ((_4 , xK_j), sendMessage $ ExpandTowards D) + --, ((_4 , xK_k), sendMessage $ ExpandTowards U) + --, ((_4S , xK_l), sendMessage $ ShrinkFrom R) + --, ((_4S , xK_h), sendMessage $ ShrinkFrom L) + --, ((_4S , xK_j), sendMessage $ ShrinkFrom D) + --, ((_4S , xK_k), sendMessage $ ShrinkFrom U) + --, ((_4 , xK_n), sendMessage Rotate) + --, ((_4S , xK_n), sendMessage Swap) + + ---- mouseResizableTile + --, ((_4 , xK_u), sendMessage ShrinkSlave) + --, ((_4 , xK_i), sendMessage ExpandSlave) + + -- move focus up or down the window stack + --, ((_4 , xK_m ), windows W.focusMaster) + , ((_4 , xK_j ), windows W.focusDown) + , ((_4 , xK_k ), windows W.focusUp) + + -- modifying the window order + , ((_4S , xK_m ), windows W.swapMaster) + , ((_4S , xK_j ), windows W.swapDown) + , ((_4S , xK_k ), windows W.swapUp) + + -- resizing the master/slave ratio + , ((_4 , xK_h ), sendMessage Shrink) -- %! Shrink the master area + , ((_4 , xK_l ), sendMessage Expand) -- %! Expand the master area + + -- floating layer support + , ((_4 , xK_t ), withFocused $ windows . W.sink) -- make tiling + + -- increase or decrease number of windows in the master area + , ((_4 , xK_comma ), sendMessage $ IncMasterN 1) + , ((_4 , xK_period ), sendMessage $ IncMasterN (-1)) + + , ((_4 , xK_a ), addWorkspacePrompt defaultXPConfig) + , ((_4 , xK_r ), renameWorkspace defaultXPConfig) + , ((_4 , xK_Delete ), removeEmptyWorkspace) + + , ((_4 , xK_Return ), toggleWS) + --, (0 , xK_Menu ) & \k -> (k, gridselectWorkspace wsGSConfig { gs_navigate = makeGSNav k } W.view) + --, (_4 , xK_v ) & \k -> (k, gridselectWorkspace wsGSConfig { gs_navigate = makeGSNav k } W.view) + --, (_4S , xK_v ) & \k -> (k, gridselectWorkspace wsGSConfig { gs_navigate = makeGSNav k } W.shift) + --, (_4 , xK_b ) & \k -> (k, goToSelected wGSConfig { gs_navigate = makeGSNav k }) + ] + where + _4 = mod4Mask + _C = controlMask + _S = shiftMask + _M = mod1Mask + _4C = _4 .|. _C + _4S = _4 .|. _S + _4M = _4 .|. _M + _4CM = _4 .|. _C .|. _M + _4SM = _4 .|. _S .|. _M + + +pagerConfig :: PagerConfig +pagerConfig = defaultPagerConfig + { pc_font = myFont + , pc_cellwidth = 64 + --, pc_cellheight = 36 -- TODO automatically keep screen aspect + --, pc_borderwidth = 1 + --, pc_matchcolor = "#f0b000" + , pc_matchmethod = MatchPrefix + --, pc_colors = pagerWorkspaceColors + , pc_windowColors = windowColors + } + where + windowColors _ _ _ True _ = ("#ef4242","#ff2323") + windowColors wsf m c u wf = do + let def = defaultWindowColors wsf m c u wf + if m == False && wf == True + then ("#402020", snd def) + else def + +horseConfig :: RhombusConfig +horseConfig = defaultRhombusConfig + { rc_font = myFont + , rc_cellwidth = 64 + --, rc_cellheight = 36 -- TODO automatically keep screen aspect + --, rc_borderwidth = 1 + --, rc_matchcolor = "#f0b000" + , rc_matchmethod = MatchPrefix + --, rc_colors = pagerWorkspaceColors + --, rc_paint = myPaint + } + +wGSConfig :: GSConfig Window +wGSConfig = defaultGSConfig + { gs_cellheight = 20 + , gs_cellwidth = 192 + , gs_cellpadding = 5 + , gs_font = myFont + , gs_navigate = navNSearch + } + +-- wsGSConfig = defaultGSConfig +-- { gs_cellheight = 20 +-- , gs_cellwidth = 64 +-- , gs_cellpadding = 5 +-- , gs_font = myFont +-- , gs_navigate = navNSearch +-- } + +-- custom navNSearch +--makeGSNav :: (KeyMask, KeySym) -> TwoD a (Maybe a) +--makeGSNav esc = nav +-- where +-- nav = makeXEventhandler $ shadowWithKeymap keyMap navNSearchDefaultHandler +-- keyMap = Map.fromList +-- [ (esc , cancel) +-- , ((0,xK_Escape) , cancel) +-- , ((0,xK_Return) , select) +-- , ((0,xK_Left) , move (-1, 0) >> nav) +-- , ((0,xK_Right) , move ( 1, 0) >> nav) +-- , ((0,xK_Down) , move ( 0, 1) >> nav) +-- , ((0,xK_Up) , move ( 0,-1) >> nav) +-- , ((0,xK_BackSpace) , transformSearchString (\s -> if (s == "") then "" else init s) >> nav) +-- ] +-- -- The navigation handler ignores unknown key symbols, therefore we const +-- navNSearchDefaultHandler (_,s,_) = do +-- transformSearchString (++ s) +-- nav + + +(&) :: a -> (a -> c) -> c +(&) = flip ($) + +allWorkspaceNames :: W.StackSet i l a sid sd -> X [i] +allWorkspaceNames ws = + return $ map W.tag (W.hidden ws) ++ [W.tag $ W.workspace $ W.current ws] + +-- vim:set fdm=marker: diff --git a/tv/2configs/xserver/xmonad-tv/Util/Debunk.hs b/tv/2configs/xserver/xmonad-tv/Util/Debunk.hs new file mode 100644 index 000000000..b4772e582 --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/Util/Debunk.hs @@ -0,0 +1,16 @@ +module Util.Debunk + ( printToErrors + ) where + +import XMonad +import System.FilePath ( () ) +import Control.Exception ( bracket ) +import System.IO ( hPrint, stderr, openFile, hClose, IOMode( AppendMode ) ) + + +printToErrors x = do + dir <- getXMonadDir + let base = dir "xmonad" + err = base ++ ".errors" + bracket (openFile err AppendMode) hClose $ \h -> hPrint h x + diff --git a/tv/2configs/xserver/xmonad-tv/Util/Font.hs b/tv/2configs/xserver/xmonad-tv/Util/Font.hs new file mode 100644 index 000000000..5352cf5ad --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/Util/Font.hs @@ -0,0 +1,123 @@ +{-# LANGUAGE CPP #-} +module Util.Font + ( printStringCentered + , printStringXMF' + ) where + +import XMonad +import XMonad.Util.Font + + +printStringCentered :: (Functor m, MonadIO m) + => Display -> Drawable -> XMonadFont + -> GC -> Rectangle -> String + -> m () +printStringCentered d p xmf gc r s = do + let x = rect_x r + y = rect_y r + w = rect_width r + h = rect_height r + + text_w <- textWidthXMF d xmf s + (text_ascent, _) <- textExtentsXMF xmf s + + let text_x = x + round ((fi w - fi text_w) / 2) + text_y = y + round ((fi h + fi text_h) / 2) + text_h = text_ascent + + printStringXMF' d p xmf gc "" "" text_x text_y s + + +-- from xmonad-contrib's XMonad.Util.Font, (c) 2007 Andrea Rossato and Spencer Janssen +printStringXMF' :: (Functor m, MonadIO m) => Display -> Drawable -> XMonadFont -> GC -> String -> String + -> Position -> Position -> String -> m () +printStringXMF' d p (Core fs) gc fc bc x y s = io $ do + setFont d gc $ fontFromFontStruct fs + --tv [fc',bc'] <- mapM (stringToPixel d) [fc,bc] + --tv setForeground d gc fc' + --tv setBackground d gc bc' + drawImageString d p gc x y s +printStringXMF' d p (Utf8 fs) gc fc bc x y s = io $ do + --tv [fc',bc'] <- mapM (stringToPixel d) [fc,bc] + --tv setForeground d gc fc' + --tv setBackground d gc bc' + io $ wcDrawImageString d p fs gc x y s +#ifdef XFT +printStringXMF' dpy drw fs@(Xft font) gc fc bc x y s = do + let screen = defaultScreenOfDisplay dpy + colormap = defaultColormapOfScreen screen + visual = defaultVisualOfScreen screen + --tv bcolor <- stringToPixel dpy bc + (a,d) <- textExtentsXMF fs s + gi <- io $ xftTextExtents dpy font s + --tv io $ setForeground dpy gc bcolor + io $ fillRectangle dpy drw gc (x - fi (xglyphinfo_x gi)) + (y - fi a) + (fi $ xglyphinfo_xOff gi) + (fi $ a + d) + io $ withXftDraw dpy drw visual colormap $ + \draw -> withXftColorName dpy visual colormap fc $ + \color -> xftDrawString draw color font x y s +#endif + + + + + +-- --my_printStringXMF :: (Functor m, MonadIO m) => Display -> Drawable -> XMonadFont -> GC -> String -> String +-- -- -> Position -> Position -> String -> m () +-- my_printStringXMF (Core fs) d p gc x y s = do +-- setFont d gc $ fontFromFontStruct fs +-- -- [fc',bc'] <- mapM (stringToPixel d) [fc,bc] +-- -- setForeground d gc fc' +-- -- setBackground d gc bc' +-- drawImageString d p gc x y s +-- my_printStringXMF (Utf8 fs) d p gc x y s = do +-- -- [fc',bc'] <- mapM (stringToPixel d) [fc,bc] +-- -- setForeground d gc fc' +-- -- setBackground d gc bc' +-- wcDrawImageString d p fs gc x y s +-- #ifdef XFT +-- my_printStringXMF dpy drw fs@(Xft font) gc fc bc x y s = do +-- let screen = defaultScreenOfDisplay dpy +-- colormap = defaultColormapOfScreen screen +-- visual = defaultVisualOfScreen screen +-- bcolor <- stringToPixel dpy bc +-- (a,d) <- textExtentsXMF fs s +-- gi <- io $ xftTextExtents dpy font s +-- io $ setForeground dpy gc bcolor +-- io $ fillRectangle dpy drw gc (x - fromIntegral (xglyphinfo_x gi)) +-- (y - fromIntegral a) +-- (fromIntegral $ xglyphinfo_xOff gi) +-- (fromIntegral $ a + d) +-- io $ withXftDraw dpy drw visual colormap $ +-- \draw -> withXftColorName dpy visual colormap fc $ +-- \color -> xftDrawString draw color font x y s +-- #endif + + + +-- --textWidthXMF :: MonadIO m => Display -> XMonadFont -> String -> m Int +-- my_textWidthXMF _ (Utf8 fs) s = return $ fromIntegral $ wcTextEscapement fs s +-- my_textWidthXMF _ (Core fs) s = return $ fromIntegral $ textWidth fs s +-- #ifdef XFT +-- my_TextWidthXMF dpy (Xft xftdraw) s = liftIO $ do +-- gi <- xftTextExtents dpy xftdraw s +-- return $ xglyphinfo_xOff gi +-- #endif +-- +-- my_textExtentsXMF :: MonadIO m => XMonadFont -> String -> m (Int32,Int32) +-- my_textExtentsXMF (Utf8 fs) s = do +-- let (_,rl) = wcTextExtents fs s +-- ascent = fromIntegral $ - (rect_y rl) +-- descent = fromIntegral $ rect_height rl + (fromIntegral $ rect_y rl) +-- return (ascent, descent) +-- my_textExtentsXMF (Core fs) s = do +-- let (_,a,d,_) = textExtents fs s +-- return (a,d) +-- #ifdef XFT +-- my_textExtentsXMF (Xft xftfont) _ = io $ do +-- ascent <- fromIntegral `fmap` xftfont_ascent xftfont +-- descent <- fromIntegral `fmap` xftfont_descent xftfont +-- return (ascent, descent) +-- #endif diff --git a/tv/2configs/xserver/xmonad-tv/Util/Pager.hs b/tv/2configs/xserver/xmonad-tv/Util/Pager.hs new file mode 100644 index 000000000..b8168b5b0 --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/Util/Pager.hs @@ -0,0 +1,172 @@ +module Util.Pager + ( defaultPagerConfig + , defaultWindowColors + , defaultWorkspaceColors + , MatchMethod(..) + , pager + , PagerConfig(..) + ) where + +import Data.List ( find ) +import Data.Maybe ( catMaybes ) +import Graphics.X11 +import Util.Rhombus +import XMonad +import qualified XMonad.StackSet as W +import XMonad.Hooks.UrgencyHook +import XMonad.Util.Font ( fi, stringToPixel ) + + +data PagerConfig = PagerConfig + { pc_font :: String + , pc_cellwidth :: Dimension + , pc_margin :: Dimension + , pc_matchmethod :: MatchMethod + , pc_wrap :: Bool + , pc_workspaceColors :: Bool -> Bool -> Bool -> (String, String, String) + , pc_windowColors :: Bool -> Bool -> Bool -> Bool -> Bool -> (String, String) + } + + +defaultPagerConfig :: PagerConfig +defaultPagerConfig = PagerConfig "xft:Sans-8" 100 0 MatchInfix True defaultWorkspaceColors defaultWindowColors + + +pager :: PagerConfig -> (String -> X ()) -> [String] -> X () +pager pc = rhombus defaultRhombusConfig + { rc_font = pc_font pc + , rc_cellwidth = pc_cellwidth pc + , rc_margin = pc_margin pc + , rc_matchmethod = pc_matchmethod pc + , rc_wrap = pc_wrap pc + , rc_colors = pc_workspaceColors pc + , rc_paint = pagerPaint pc + } + + +defaultWorkspaceColors :: Bool -- workspace has focus + -> Bool -- workspace name matches incremental search + -> Bool -- workspace is the current one + -> (String, String, String) -- workspace border, background color, and foreground color +defaultWorkspaceColors False False False = ("#101010","#050505","#202020") +defaultWorkspaceColors False False True = ("#101010","#050505","#202020") +defaultWorkspaceColors False True False = ("#404040","#202020","#b0b0b0") +defaultWorkspaceColors False True True = ("#101010","#050505","#505050") +defaultWorkspaceColors True _ False = ("#808020","#404010","#f0f0b0") +defaultWorkspaceColors True _ True = ("#404010","#202005","#909050") + + +defaultWindowColors :: Bool -- window's workspace has focus + -> Bool -- window's workspace name matches incremental search + -> Bool -- window's workspace the current one + -> Bool -- window is urgent + -> Bool -- window has focus + -> (String, String) -- window border and background color + +defaultWindowColors wsf m c u True = ("#802020", snd $ defaultWindowColors wsf m c u False) + +defaultWindowColors False False False False _ = ("#111111","#060606") +defaultWindowColors False False False True _ = ("#802020","#401010") +defaultWindowColors False False True False _ = ("#101010","#050505") +defaultWindowColors False False True True _ = ("#401010","#200505") +defaultWindowColors False True False False _ = ("#202080","#101040") +defaultWindowColors False True False True _ = ("#802080","#401040") +defaultWindowColors False True True False _ = ("#101040","#100520") +defaultWindowColors False True True True _ = ("#401040","#200520") + +defaultWindowColors True False False False _ = ("#208020","#104010") +defaultWindowColors True False False True _ = ("#808020","#404010") +defaultWindowColors True False True False _ = ("#104010","#052005") +defaultWindowColors True False True True _ = ("#404010","#202005") +defaultWindowColors True True False False _ = ("#208080","#104040") +defaultWindowColors True True False True _ = ("#808080","#404040") +defaultWindowColors True True True False _ = ("#104040","#102020") +defaultWindowColors True True True True _ = ("#404040","#202020") + + +pagerPaint :: + PagerConfig + -> RhombusConfig + -> Display + -> Drawable + -> GC + -> WorkspaceId + -> Rectangle + -> Bool + -> Bool + -> Bool + -> X () +pagerPaint pc rc d p gc t r focus match current = do + ss <- gets windowset + + let x = rect_x r + y = rect_y r + + urgents <- readUrgents + let foci = map W.focus $ catMaybes $ map W.stack $ W.workspaces ss + + let color = pc_windowColors pc focus match current -- :: Bool -> (String, String) + (_, _, _fg_color) = pc_workspaceColors pc focus match current + + fg_color <- stringToPixel d _fg_color + + let r = screenRect $ W.screenDetail $ W.current ss + let a = fi (rect_width r) / fi (rect_height r) + let scale = fi (rc_cellwidth rc) / fi (rect_width r) + + -- TODO whenNothing print error + whenJust (findWorkspace t ss) $ \ ws -> do + whenJust (W.stack ws) $ \ s -> + withDisplay $ \ d -> io $ do + + let color' w = color (w `elem` urgents) (w `elem` foci) + + -- TODO painting of floating windows is broken + mapM_ (drawMiniWindow d p gc x y color' scale) (W.down s) + drawMiniWindow d p gc x y color' scale (W.focus s) + mapM_ (drawMiniWindow d p gc x y color' scale) (W.up s) + +drawMiniWindow + :: RealFrac a + => Display + -> Drawable + -> GC + -> Position + -> Position + -> (Window -> (String, String)) + -> a + -> Window + -> IO () +drawMiniWindow d p gc ox oy color s win = do + let scale x = round $ fi x * s + + wa <- getWindowAttributes d win + + let x = ox + (scale $ wa_x wa) + y = oy + (scale $ wa_y wa) + w = (scale $ wa_width wa) + h = (scale $ wa_height wa) + + let (fg, bg) = color win + + fg' <- stringToPixel d fg + bg' <- stringToPixel d bg + + setForeground d gc bg' + fillRectangle d p gc (x + 1) (y + 1) (w - 2) (h - 2) + + setForeground d gc fg' + drawLines d p gc + [ Point x y + , Point (fi w - 1) 0 + , Point 0 (fi h - 2) + , Point (- fi w + 1) 0 + , Point 0 (- fi h + 2) + ] + coordModePrevious + + + +-- TODO externalize findWorkspace +findWorkspace :: (Eq i) => i -> W.StackSet i l a sid sd -> Maybe (W.Workspace i l a) +findWorkspace t ss = find ((==)t . W.tag) (W.workspaces ss) diff --git a/tv/2configs/xserver/xmonad-tv/Util/Rhombus.hs b/tv/2configs/xserver/xmonad-tv/Util/Rhombus.hs new file mode 100644 index 000000000..5f43cb28a --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/Util/Rhombus.hs @@ -0,0 +1,370 @@ +module Util.Rhombus + ( defaultRhombusConfig + , MatchMethod(..) + , rhombus + , RhombusConfig(..) + , RhombusState(..) + ) where + +import Control.Monad ( forM_, zipWithM_ ) +import Data.Char +import Data.List +import Data.Ord +import Data.Map ( fromList ) +import Data.Maybe ( isJust, fromJust ) +import XMonad +import XMonad.StackSet hiding ( filter ) +import XMonad.Util.Font +import XMonad.Util.Image ( drawIcon ) +import XMonad.Util.XUtils + +import Util.Debunk +import Util.Submap +import Util.XUtils +import Util.Font + + +data MatchMethod = MatchInfix | MatchPrefix + +data RhombusConfig = RhombusConfig + { rc_font :: String + , rc_cellwidth :: Dimension + , rc_margin :: Dimension + , rc_matchmethod :: MatchMethod + , rc_wrap :: Bool + , rc_colors :: Bool -> Bool -> Bool -> (String, String, String) + , rc_paint :: RhombusConfig -> Display -> Pixmap -> GC -> String -> Rectangle -> Bool -> Bool -> Bool -> X () + } + + +-- TODO currently xft is broken +defaultRhombusConfig = RhombusConfig "xft:Sans-8" 100 0 MatchInfix True stupidColors noPaint + where + stupidColors _ _ _ = ("red", "magenta", "yellow") + noPaint _ _ _ _ _ _ _ _ _ = return () + + +data RhombusState = RhombusState + { rs_window :: Window + , rs_search :: String + , rs_font :: XMonadFont + , rs_focus :: (Position, Position) + , rs_strings :: [String] + } + + +reachableCoords :: RhombusState -> [(Position, Position)] +reachableCoords RhombusState{rs_strings=xs} = take (length xs) wave + + +matchingReachableCoords :: RhombusConfig -> RhombusState -> [(Position, Position)] +matchingReachableCoords rc rs = + snd $ unzip + $ filter (isXOf (rc_matchmethod rc) (rs_search rs) . fst) + $ zip (rs_strings rs) (reachableCoords rs) + + +match :: MatchMethod -> String -> [String] -> Maybe String +match m s ws = do + let cands = filter (isXOf m s) ws + if length cands == 1 + then Just $ head cands + else Nothing + +rhombus :: RhombusConfig -> (String -> X ()) -> [String] -> X () +rhombus rc viewFunc as = withGrabbedKeyboard $ do + rs <- newRhombus rc as + --redraw rc rs + showWindow (rs_window rs) + rhombusMode viewFunc rc rs + + +rhombusMode :: (String -> X ()) -> RhombusConfig -> RhombusState -> X () +rhombusMode viewFunc rc rs = + case match (rc_matchmethod rc) (rs_search rs) (init $ rs_strings rs) of + Nothing -> redraw rc rs >> submapString def keys + Just i -> removeRhombus rs >> viewFunc i + where + def (ch:[]) | isPrint ch = + incSearchPushChar ch rs >>= rhombusMode viewFunc rc + + def _ = + failbeep >> rhombusMode viewFunc rc rs + + keys = fromList $ + [ ((0 , xK_BackSpace ), incSearchPopChar rs >>= rhombusMode viewFunc rc) + , ((0 , xK_Escape ), removeRhombus rs) + , ((0 , xK_Menu ), removeRhombus rs) + , ((0 , xK_Left ), goto rc (-1, 0) rs >>= rhombusMode viewFunc rc) + , ((0 , xK_Right ), goto rc ( 1, 0) rs >>= rhombusMode viewFunc rc) + , ((0 , xK_Up ), goto rc ( 0,-1) rs >>= rhombusMode viewFunc rc) + , ((0 , xK_Down ), goto rc ( 0, 1) rs >>= rhombusMode viewFunc rc) + , ((0 , xK_Tab ), gotoNextMatch rc rs >>= rhombusMode viewFunc rc) + , ((_S , xK_Tab ), gotoPrevMatch rc rs >>= rhombusMode viewFunc rc) + , ((0 , xK_Return ), removeRhombus rs >> return (selectFocused rs) >>= viewFunc) + ] + + _S = shiftMask + + +-- TODO make failbeep configurable +failbeep = spawn "beep -l 100 -f 500" + + +goto :: RhombusConfig -> (Position, Position) -> RhombusState -> X RhombusState +goto RhombusConfig{rc_wrap=True} xy rs = maybe (failbeep >> return rs) return $ wrapFocus xy rs +goto RhombusConfig{rc_wrap=False} xy rs = maybe (failbeep >> return rs) return $ moveFocus xy rs + + +moveFocus :: (Position, Position) -> RhombusState -> Maybe RhombusState +moveFocus (dx, dy) rs@RhombusState{rs_focus=(x,y)} = do + let focus' = (x + dx, y + dy) + if elem focus' (reachableCoords rs) + then Just rs { rs_focus = focus' } + else Nothing + + +wrapFocus :: (Position, Position) -> RhombusState -> Maybe RhombusState + +wrapFocus (0, dy) rs@RhombusState{rs_focus=focus} = do + let column = sortBy (comparing snd) $ filter ((==) (fst focus) . fst) (reachableCoords rs) + i <- elemIndex focus column + return rs { rs_focus = column `modIndex` (i + fromIntegral dy) } + +wrapFocus (dx, 0) rs@RhombusState{rs_focus=focus} = do + let column = sortBy (comparing fst) $ filter ((==) (snd focus) . snd) (reachableCoords rs) + i <- elemIndex focus column + return rs { rs_focus = column `modIndex` (i + fromIntegral dx) } + +wrapFocus _ _ = Nothing + + +gotoPrevMatch :: RhombusConfig -> RhombusState -> X RhombusState +gotoPrevMatch rc rs@RhombusState{rs_focus=focus} = do + case reverse (matchingReachableCoords rc rs) of + [] -> failbeep >> return rs + xs -> return rs + { rs_focus = maybe (head xs) + (modIndex xs . (+1)) + (focus `elemIndex` xs) + } + + +gotoNextMatch :: RhombusConfig -> RhombusState -> X RhombusState +gotoNextMatch rc rs@RhombusState{rs_focus=focus} = do + case matchingReachableCoords rc rs of + [] -> failbeep >> return rs + xs -> return rs + { rs_focus = maybe (head xs) + (modIndex xs . (+1)) + (focus `elemIndex` xs) + } + + +selectFocused :: RhombusState -> String +selectFocused rs = + -- TODO the rhombus must never "focus" something inexistent + fromJust $ lookup (rs_focus rs) $ zip wave (rs_strings rs) + + +incSearchPushChar :: Char -> RhombusState -> X RhombusState +incSearchPushChar c rs = return rs { rs_search = rs_search rs ++ [c] } + + +incSearchPopChar :: RhombusState -> X RhombusState + +-- only rubout if we have at least one char +incSearchPopChar rs@RhombusState{rs_search=xs@(_:_)} = + return rs { rs_search = init xs } + +incSearchPopChar rs = return rs + + +redraw :: RhombusConfig -> RhombusState -> X () +redraw rc rs = do + ss <- gets windowset + + let Screen _ _ (SD (Rectangle _ _ s_width s_height)) = current ss + + -- TODO this let is duplicated in newRhombus + let scale x = x * cell_w `div` s_width -- TODO use bw + cell_w = rc_cellwidth rc + cell_h = scale s_height + + -- txy is the top-left corner of the first (center) cell + -- XXX div and (-) are not distributive + -- we could round $ (s_* - cell_*) / 2, though... + tx = fi $ s_width `div` 2 - cell_w `div` 2 + ty = fi $ s_height `div` 2 - cell_h `div` 2 + + margin = rc_margin rc + + -- dxy are the outer cell dimensions (i.e. including the border) + dx = fi $ cell_w + 2 + margin + dy = fi $ cell_h + 2 + margin + + paint = rc_paint rc + xmf = rs_font rs + tags = rs_strings rs + --currentTag = last tags + + withDisplay $ \ d -> do + -- XXX we cannot use withPixmapAndGC because rc_paint is an X monad + p <- io $ createPixmap d (rs_window rs) s_width s_height (defaultDepthOfScreen $ defaultScreenOfDisplay d) + g <- io $ createGC d p + + -- TODO fixme + color_black <- stringToPixel d "black" + + forZipWithM_ tags (reachableCoords rs) $ \ tag oxy@(ox, oy) -> do + + let focus = oxy == rs_focus rs + match = isXOf (rc_matchmethod rc) (rs_search rs) tag + current = tag == last tags + (_b_color, _bg_color, _fg_color) = rc_colors rc focus match current + --cell_x = (ox * dx) + x - fi (cell_w `div` 2) + --cell_y = (oy * dy) + y - fi (cell_h `div` 2) + cell_x = (ox * dx) + tx + 1 + cell_y = (oy * dy) + ty + 1 + + b_color <- stringToPixel d _b_color + bg_color <- stringToPixel d _bg_color + fg_color <- stringToPixel d _fg_color + + -- draw background + io $ setForeground d g bg_color + io $ fillRectangle d p g cell_x cell_y cell_w cell_h + + -- draw border + io $ setForeground d g b_color + io $ drawLines d p g + [ Point (cell_x - 1) (cell_y - 1) + , Point (fi cell_w + 1) 0 + , Point 0 (fi cell_h + 1) + , Point (-(fi cell_w + 1)) 0 + , Point 0 (-(fi cell_h + 1)) + ] + coordModePrevious + + -- custom draw + paint rc d p g tag (Rectangle cell_x cell_y cell_w cell_h) focus match current + + -- paint text + -- TODO custom paint text? + -- TODO withCopyArea + io $ withPixmapAndGC d p s_width s_height (defaultDepthOfScreen $ defaultScreenOfDisplay d) $ \ f_pm f_gc -> do + withPixmapAndGC d f_pm s_width s_height 1 $ \ clip_mask clip_gc -> do + setForeground d clip_gc 0 + setBackground d clip_gc 0 + fillRectangle d clip_mask clip_gc 0 0 s_width s_height + setForeground d clip_gc 1 + + let r = Rectangle cell_x cell_y cell_w cell_h + + printStringCentered d clip_mask xmf clip_gc r tag + + setForeground d f_gc fg_color + setBackground d f_gc color_black -- TODO + + printStringCentered d f_pm xmf f_gc r tag + + setClipMask d f_gc clip_mask + + copyArea d f_pm p f_gc 0 0 s_width s_height 0 0 + + io $ copyArea d p (rs_window rs) g 0 0 s_width s_height 0 0 + io $ freePixmap d p + io $ freeGC d g + + +newRhombus :: RhombusConfig -> [String] -> X RhombusState +newRhombus rc tags = do + ss <- gets windowset + + let Screen _ _ (SD (Rectangle _ _ s_width s_height)) = current ss + (_, def_win_bg, _) = rc_colors rc False True False + + -- TODO this let is duplicated in redraw + let scale x = x * cell_w `div` s_width -- TODO use bw + cell_w = rc_cellwidth rc + cell_h = scale s_height + + -- TODO don't delete this let but use it instead of s_{width,height} + -- (xcoords, ycoords) = unzip $ take (length tags) wave -- this is reachableCoords + -- win_width = (maximum xcoords - minimum xcoords) * dx + -- win_height = (maximum ycoords - minimum ycoords) * dy + + -- txy is the top-left corner of the first (center) cell + -- XXX div and (-) are not distributive + -- we could round $ (s_* - cell_*) / 2, though... + tx = fi $ s_width `div` 2 - cell_w `div` 2 + ty = fi $ s_height `div` 2 - cell_h `div` 2 + + margin = rc_margin rc + + -- dxy are the outer cell dimensions (i.e. including the border) + dx = fi $ cell_w + 2 + margin + dy = fi $ cell_h + 2 + margin + + fn <- initXMF (rc_font rc) + win <- createNewWindow (Rectangle 0 0 s_width s_height) Nothing def_win_bg True + + withDisplay $ \ d -> + io $ shapeWindow d win $ \ p g -> + forZipWithM_ tags wave $ \ _ (ox, oy) -> + fillRectangle d p g (tx + ox * dx) (ty + oy * dy) (fi cell_w + 2) (fi cell_h + 2) + + return $ RhombusState win "" fn (0,0) tags + + +removeRhombus :: RhombusState -> X () +removeRhombus (RhombusState w _ fn _ _) = do + deleteWindow w + releaseXMF fn + +wave :: [(Position, Position)] +wave = zip (0:(concat $ map (\i -> [0..i]++[i-1,i-2..1] ++ [0,-1..(-i)]++[-i,-i+1..(-1)]) [1..])) (concat $ map (\i -> [0..i]++[i-1,i-2..1] ++ [0,-1..(-i)]++[-i+1,-i+2..(-1)]) [1..]) + where + wave1 = 0:(concat $ map (\i -> [0..i]++[i-1,i-2..1] ++ [0,-1..(-i)]++[-i,-i+1..(-1)]) [1..]) + wave2 = concat $ map (\i -> [0..i]++[i-1,i-2..1] ++ [0,-1..(-i)]++[-i+1,-i+2..(-1)]) [1..] + +commonPrefix (x:xs) (y:ys) | x == y = x:commonPrefix xs ys +commonPrefix _ _ = [] + + +isXOf :: MatchMethod -> String -> String -> Bool +isXOf MatchInfix = isInfixOf +isXOf MatchPrefix = isPrefixOf + + +findXIndex :: (Eq a) => MatchMethod -> [a] -> [a] -> Maybe Int +findXIndex MatchInfix = findInfixIndex +findXIndex MatchPrefix = findPrefixIndex + + +findInfixIndex :: (Eq a) => [a] -> [a] -> Maybe Int +findInfixIndex needle haystack + = (\x -> if null x then Nothing else Just (fst $ head x)) + . dropWhile (\(_,x) -> not $ isPrefixOf needle x) + $ zip [0..] (tails haystack) + + +findPrefixIndex :: (Eq a) => [a] -> [a] -> Maybe Int +findPrefixIndex needle haystack = + if isPrefixOf needle haystack + then Just 0 + else Nothing + + +modIndex :: Integral i => [a] -> i -> a +modIndex xs i = xs `genericIndex` (i `mod` genericLength xs) + + +forZipWithM_ a b f = zipWithM_ f a b + + +withGrabbedKeyboard f = do + XConf { theRoot = root, display = d } <- ask + catchX (io (grabKeyboard d root False grabModeAsync grabModeAsync currentTime) >> f) + (return ()) + io $ ungrabKeyboard d currentTime diff --git a/tv/2configs/xserver/xmonad-tv/Util/Submap.hs b/tv/2configs/xserver/xmonad-tv/Util/Submap.hs new file mode 100644 index 000000000..b09b97cc2 --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/Util/Submap.hs @@ -0,0 +1,31 @@ +-- This module is based on Jason Creighton's XMonad.Actions.Submap + +module Util.Submap + ( submapString + ) where + +import Data.Bits +import XMonad hiding (keys) +import qualified Data.Map as M +import Control.Monad.Fix (fix) + + +-- | Like 'XMonad.Actions.Submap.submapDefault', but provides the looked up string to the default action. +submapString :: (String -> X ()) -> M.Map (KeyMask, KeySym) (X ()) -> X () +submapString def keys = do + XConf { theRoot = root, display = d } <- ask + + (m, s, str) <- io $ allocaXEvent $ \p -> fix $ \nextkey -> do + maskEvent d keyPressMask p + KeyEvent { ev_keycode = code, ev_state = m } <- getEvent p + keysym <- keycodeToKeysym d code 0 + if isModifierKey keysym + then nextkey + else do + (mbKeysym, str) <- lookupString (asKeyEvent p) + return (m, keysym, str) + + -- Remove num lock mask and Xkb group state bits + m' <- cleanMask $ m .&. ((1 `shiftL` 12) - 1) + + maybe (def str) id (M.lookup (m', s) keys) diff --git a/tv/2configs/xserver/xmonad-tv/Util/XUtils.hs b/tv/2configs/xserver/xmonad-tv/Util/XUtils.hs new file mode 100644 index 000000000..de1d8247c --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/Util/XUtils.hs @@ -0,0 +1,47 @@ +module Util.XUtils + ( shapeWindow + , withGC + , withPixmap + , withPixmapAndGC + ) where + +import Control.Exception ( bracket ) +import Foreign.C.Types ( CInt ) +import Graphics.X11.Xlib +import Graphics.X11.Xlib.Extras +import Graphics.X11.Xshape + + +shapeWindow :: Display -> Window -> (Pixmap -> GC -> IO ()) -> IO () +shapeWindow d w f = do + wa <- getWindowAttributes d w + + let width = fromIntegral $ wa_width wa + height = fromIntegral $ wa_height wa + + withPixmapAndGC d w width height 1 $ \ p g -> do + + setForeground d g 0 + fillRectangle d p g 0 0 width height + + setForeground d g 1 + + f p g + + xshapeCombineMask d w shapeBounding 0 0 p shapeSet + + +withGC :: Display -> Drawable -> (GC -> IO ()) -> IO () +withGC d p = + bracket (createGC d p) (freeGC d) + + +withPixmap :: Display -> Drawable -> Dimension -> Dimension -> CInt -> (Pixmap -> IO ()) -> IO () +withPixmap d p w h depth = + bracket (createPixmap d p w h depth) (freePixmap d) + + +withPixmapAndGC :: Display -> Drawable -> Dimension -> Dimension -> CInt -> (Pixmap -> GC -> IO ()) -> IO () +withPixmapAndGC d w width height depth f = + withPixmap d w width height depth $ \ p -> + withGC d p $ \ g -> f p g diff --git a/tv/2configs/xserver/xmonad-tv/default.nix b/tv/2configs/xserver/xmonad-tv/default.nix new file mode 100644 index 000000000..f0cb8e08d --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/default.nix @@ -0,0 +1 @@ +import ./xmonad-tv.nix diff --git a/tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal b/tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal new file mode 100644 index 000000000..72494abe1 --- /dev/null +++ b/tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal @@ -0,0 +1,19 @@ +Author: tv +Build-Type: Simple +Cabal-Version: >= 1.2 +License: MIT +Name: xmonad-tv +Version: 0 + +Executable xmonad + Build-Depends: + base, + containers, + filepath, + scanner, + X11, + X11-xshape, + xmonad, + xmonad-contrib + GHC-Options: -Wall -O3 -threaded -rtsopts + Main-Is: Main.hs From 0306ec4294f6d825ca65c7b0c98a80a3bced8fdf Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 22:31:10 +0200 Subject: [PATCH 54/71] tv: lol display-manager --- tv/1systems/wu.nix | 3 +- tv/2configs/synaptics.nix | 14 -- tv/2configs/urlwatch.nix | 4 + tv/2configs/xserver.nix | 41 ------ tv/2configs/xserver/default.nix | 126 ++++++++++++++++++ tv/2configs/xserver/xmonad-tv/default.nix | 1 - .../xserver/{xmonad-tv => xmonad}/Main.hs | 0 .../{xmonad-tv => xmonad}/Util/Debunk.hs | 0 .../{xmonad-tv => xmonad}/Util/Font.hs | 0 .../{xmonad-tv => xmonad}/Util/Pager.hs | 0 .../{xmonad-tv => xmonad}/Util/Rhombus.hs | 0 .../{xmonad-tv => xmonad}/Util/Submap.hs | 0 .../{xmonad-tv => xmonad}/Util/XUtils.hs | 0 .../xmonad-tv.cabal => xmonad/xmonad.cabal} | 1 - tv/2configs/xserver/xserver.conf.nix | 40 ++++++ 15 files changed, 171 insertions(+), 59 deletions(-) delete mode 100644 tv/2configs/synaptics.nix delete mode 100644 tv/2configs/xserver.nix create mode 100644 tv/2configs/xserver/default.nix delete mode 100644 tv/2configs/xserver/xmonad-tv/default.nix rename tv/2configs/xserver/{xmonad-tv => xmonad}/Main.hs (100%) rename tv/2configs/xserver/{xmonad-tv => xmonad}/Util/Debunk.hs (100%) rename tv/2configs/xserver/{xmonad-tv => xmonad}/Util/Font.hs (100%) rename tv/2configs/xserver/{xmonad-tv => xmonad}/Util/Pager.hs (100%) rename tv/2configs/xserver/{xmonad-tv => xmonad}/Util/Rhombus.hs (100%) rename tv/2configs/xserver/{xmonad-tv => xmonad}/Util/Submap.hs (100%) rename tv/2configs/xserver/{xmonad-tv => xmonad}/Util/XUtils.hs (100%) rename tv/2configs/xserver/{xmonad-tv/xmonad-tv.cabal => xmonad/xmonad.cabal} (95%) create mode 100644 tv/2configs/xserver/xserver.conf.nix diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 89ad257f0..987748de0 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -29,8 +29,7 @@ with lib; #../2configs/consul-client.nix ../2configs/git.nix ../2configs/mail-client.nix - ../2configs/xserver.nix - ../2configs/synaptics.nix # TODO w110er if xserver is enabled + ../2configs/xserver ../2configs/test.nix { environment.systemPackages = with pkgs; [ diff --git a/tv/2configs/synaptics.nix b/tv/2configs/synaptics.nix deleted file mode 100644 index c47cb9deb..000000000 --- a/tv/2configs/synaptics.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, pkgs, ... }: - -{ - # TODO this is host specific - services.xserver.synaptics = { - enable = true; - twoFingerScroll = true; - accelFactor = "0.035"; - additionalOptions = '' - Option "FingerHigh" "60" - Option "FingerLow" "60" - ''; - }; -} diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index 373803cc6..8189f6345 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -47,6 +47,10 @@ # ref , services.openssh.knownHosts.github* https://help.github.com/articles/what-ip-addresses-does-github-use-that-i-should-whitelist/ + + # + # is derived from `configFile` in: + https://raw.githubusercontent.com/NixOS/nixpkgs/master/nixos/modules/services/x11/xserver.nix ]; }; } diff --git a/tv/2configs/xserver.nix b/tv/2configs/xserver.nix deleted file mode 100644 index 7fc07f927..000000000 --- a/tv/2configs/xserver.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ../2configs/urxvt.nix # TODO via xserver - ]; - - services.xserver.enable = true; - - - #fonts.enableFontConfig = true; - #fonts.enableFontDir = true; - fonts.fonts = [ - pkgs.xlibs.fontschumachermisc - ]; - #services.xfs.enable = true; - #services.xserver.useXFS = "unix/:7100"; - - services.xserver.displayManager.desktopManagerHandlesLidAndPower = true; - - #services.xserver.display = 11; - #services.xserver.tty = 11; - # services.xserver.layout = "us"; - # services.xserver.xkbOptions = "eurosign:e"; - - #services.xserver.multitouch.enable = true; - - services.xserver.windowManager.xmonad.extraPackages = hspkgs: with hspkgs; [ - X11-xshape - ]; - services.xserver.windowManager.xmonad.enable = true; - services.xserver.windowManager.xmonad.enableContribAndExtras = true; - services.xserver.windowManager.default = "xmonad"; - services.xserver.desktopManager.default = "none"; - services.xserver.desktopManager.xterm.enable = false; - - services.xserver.displayManager.slim.enable = true; - #services.xserver.displayManager.auto.enable = true; - #services.xserver.displayManager.auto.user = "tv"; - #services.xserver.displayManager.job.logsXsession = true; -} diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix new file mode 100644 index 000000000..b590fbd64 --- /dev/null +++ b/tv/2configs/xserver/default.nix @@ -0,0 +1,126 @@ +{ config, lib, pkgs, ... }@args: + +with lib; + +let + # TODO krebs.build.user + user = config.users.users.tv; + + out = { + services.xserver.display = 11; + services.xserver.tty = 11; + + services.xserver.synaptics = { + enable = true; + twoFingerScroll = true; + accelFactor = "0.035"; + }; + + fonts.fonts = [ + pkgs.xlibs.fontschumachermisc + ]; + + systemd.services.urxvtd = { + wantedBy = [ "multi-user.target" ]; + reloadIfChanged = true; + serviceConfig = { + ExecReload = need-reload "urxvtd.service"; + ExecStart = "${pkgs.rxvt_unicode}/bin/urxvtd"; + Restart = "always"; + RestartSec = "2s"; + StartLimitBurst = 0; + User = user.name; + }; + }; + + environment.systemPackages = [ + pkgs.slock + ]; + + security.setuidPrograms = [ + "slock" + ]; + + systemd.services.display-manager = mkForce {}; + + services.xserver.enable = true; + systemd.services.xmonad = { + wantedBy = [ "multi-user.target" ]; + requires = [ "xserver.service" ]; + serviceConfig = { + ExecStart = "${xmonad}/bin/xmonad"; + User = user.name; + WorkingDirectory = user.home; + }; + }; + + systemd.services.xserver = { + after = [ + "systemd-udev-settle.service" + "local-fs.target" + "acpid.service" + ]; + reloadIfChanged = true; + environment = xserver-environment; + serviceConfig = { + ExecReload = need-reload "xserver.service"; + ExecStart = "${xserver}/bin/xserver"; + }; + }; + }; + + xmonad = let + pkg = pkgs.haskellPackages.callPackage src {}; + src = pkgs.runCommand "xmonad-package" {} '' + ${pkgs.cabal2nix}/bin/cabal2nix ${./xmonad} > $out + ''; + in pkgs.writeScriptBin "xmonad" '' + #! /bin/sh + set -efu + export DISPLAY; DISPLAY=:${toString config.services.xserver.display} + export PATH; PATH=${makeSearchPath "bin" [ + pkgs.rxvt_unicode + ]} + settle() {( + # Use PATH for a clean journal + command=''${1##*/} + PATH=''${1%/*}; export PATH + shift + until "$command" "$@"; do + ${pkgs.coreutils}/bin/sleep 1 + done + )&} + settle ${pkgs.xorg.xhost}/bin/xhost +LOCAL: + settle ${pkgs.xorg.xrdb}/bin/xrdb -merge ${import ./Xresources.nix args} + settle ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' + exec ${pkg}/bin/xmonad + ''; + + xserver-environment = { + XKB_BINDIR = "${pkgs.xorg.xkbcomp}/bin"; # Needed for the Xkb extension. + XORG_DRI_DRIVER_PATH = "/run/opengl-driver/lib/dri"; # !!! Depends on the driver selected at runtime. + LD_LIBRARY_PATH = concatStringsSep ":" ( + [ "${pkgs.xorg.libX11}/lib" "${pkgs.xorg.libXext}/lib" ] + ++ concatLists (catAttrs "libPath" config.services.xserver.drivers)); + }; + + xserver = pkgs.writeScriptBin "xserver" '' + #! /bin/sh + set -efu + exec ${pkgs.xorg.xorgserver}/bin/X \ + :${toString config.services.xserver.display} \ + vt${toString config.services.xserver.tty} \ + -config ${import ./xserver.conf.nix args} \ + -logfile /var/log/X.${toString config.services.xserver.display}.log \ + -nolisten tcp \ + -xkbdir ${pkgs.xkeyboard_config}/etc/X11/xkb \ + ''; + + need-reload = s: let + pkg = pkgs.writeScriptBin "need-reload" '' + #! /bin/sh + echo "$*" + ''; + in "${pkg}/bin/need-reload ${s}"; + +in out diff --git a/tv/2configs/xserver/xmonad-tv/default.nix b/tv/2configs/xserver/xmonad-tv/default.nix deleted file mode 100644 index f0cb8e08d..000000000 --- a/tv/2configs/xserver/xmonad-tv/default.nix +++ /dev/null @@ -1 +0,0 @@ -import ./xmonad-tv.nix diff --git a/tv/2configs/xserver/xmonad-tv/Main.hs b/tv/2configs/xserver/xmonad/Main.hs similarity index 100% rename from tv/2configs/xserver/xmonad-tv/Main.hs rename to tv/2configs/xserver/xmonad/Main.hs diff --git a/tv/2configs/xserver/xmonad-tv/Util/Debunk.hs b/tv/2configs/xserver/xmonad/Util/Debunk.hs similarity index 100% rename from tv/2configs/xserver/xmonad-tv/Util/Debunk.hs rename to tv/2configs/xserver/xmonad/Util/Debunk.hs diff --git a/tv/2configs/xserver/xmonad-tv/Util/Font.hs b/tv/2configs/xserver/xmonad/Util/Font.hs similarity index 100% rename from tv/2configs/xserver/xmonad-tv/Util/Font.hs rename to tv/2configs/xserver/xmonad/Util/Font.hs diff --git a/tv/2configs/xserver/xmonad-tv/Util/Pager.hs b/tv/2configs/xserver/xmonad/Util/Pager.hs similarity index 100% rename from tv/2configs/xserver/xmonad-tv/Util/Pager.hs rename to tv/2configs/xserver/xmonad/Util/Pager.hs diff --git a/tv/2configs/xserver/xmonad-tv/Util/Rhombus.hs b/tv/2configs/xserver/xmonad/Util/Rhombus.hs similarity index 100% rename from tv/2configs/xserver/xmonad-tv/Util/Rhombus.hs rename to tv/2configs/xserver/xmonad/Util/Rhombus.hs diff --git a/tv/2configs/xserver/xmonad-tv/Util/Submap.hs b/tv/2configs/xserver/xmonad/Util/Submap.hs similarity index 100% rename from tv/2configs/xserver/xmonad-tv/Util/Submap.hs rename to tv/2configs/xserver/xmonad/Util/Submap.hs diff --git a/tv/2configs/xserver/xmonad-tv/Util/XUtils.hs b/tv/2configs/xserver/xmonad/Util/XUtils.hs similarity index 100% rename from tv/2configs/xserver/xmonad-tv/Util/XUtils.hs rename to tv/2configs/xserver/xmonad/Util/XUtils.hs diff --git a/tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal b/tv/2configs/xserver/xmonad/xmonad.cabal similarity index 95% rename from tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal rename to tv/2configs/xserver/xmonad/xmonad.cabal index 72494abe1..00acf1704 100644 --- a/tv/2configs/xserver/xmonad-tv/xmonad-tv.cabal +++ b/tv/2configs/xserver/xmonad/xmonad.cabal @@ -10,7 +10,6 @@ Executable xmonad base, containers, filepath, - scanner, X11, X11-xshape, xmonad, diff --git a/tv/2configs/xserver/xserver.conf.nix b/tv/2configs/xserver/xserver.conf.nix new file mode 100644 index 000000000..e8a997a99 --- /dev/null +++ b/tv/2configs/xserver/xserver.conf.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.xserver; +in + +pkgs.stdenv.mkDerivation { + name = "xserver.conf"; + + xfs = optionalString (cfg.useXFS != false) + ''FontPath "${toString cfg.useXFS}"''; + + inherit (cfg) config; + + buildCommand = + '' + echo 'Section "Files"' >> $out + echo $xfs >> $out + + for i in ${toString config.fonts.fonts}; do + if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then + for j in $(find $i -name fonts.dir); do + echo " FontPath \"$(dirname $j)\"" >> $out + done + fi + done + + for i in $(find ${toString cfg.modules} -type d); do + if test $(echo $i/*.so* | wc -w) -ne 0; then + echo " ModulePath \"$i\"" >> $out + fi + done + + echo 'EndSection' >> $out + + echo "$config" >> $out + ''; +} From 6bdcab40b4e51f113ae30903152adcf778f33e53 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 22:36:24 +0200 Subject: [PATCH 55/71] tv xmonad: PATH += su (setuid-wrappers) --- tv/2configs/xserver/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index b590fbd64..5d3372609 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -80,7 +80,7 @@ let export DISPLAY; DISPLAY=:${toString config.services.xserver.display} export PATH; PATH=${makeSearchPath "bin" [ pkgs.rxvt_unicode - ]} + ]}:/var/setuid-wrappers settle() {( # Use PATH for a clean journal command=''${1##*/} From 6b118151f9a60e07abf2272172e9add0b0add14d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 22:43:24 +0200 Subject: [PATCH 56/71] tv xmonad: provide xresources to myRootTerm --- tv/2configs/xserver/Xresources.nix | 5 +++++ tv/2configs/xserver/xmonad/Main.hs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tv/2configs/xserver/Xresources.nix b/tv/2configs/xserver/Xresources.nix index f8414b861..3936a26f7 100644 --- a/tv/2configs/xserver/Xresources.nix +++ b/tv/2configs/xserver/Xresources.nix @@ -211,4 +211,9 @@ pkgs.writeText "Xresources" '' URxvt*url-select.underline: true URxvt*colorUL: #4682B4 URxvt.perl-lib: ${pkgs.urxvt_perls}/lib/urxvt/perl + + root-urxvt*background: #230000 + root-urxvt*foreground: #e0c0c0 + root-urxvt*BorderColor: #400000 + root-urxvt*color0: #800000 '' diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index a298d72e7..cca2902a0 100644 --- a/tv/2configs/xserver/xmonad/Main.hs +++ b/tv/2configs/xserver/xmonad/Main.hs @@ -38,7 +38,7 @@ myTerm :: String myTerm = "urxvtc" myRootTerm :: String -myRootTerm = "XENVIRONMENT=\"$HOME/.Xdefaults/root-urxvt\" urxvtc -e su -" +myRootTerm = "urxvtc -name root-urxvt -e su -" -- TODO execRootTerm = exec (shlex "urxvtc -e su -") -- [ ("XENVIRONMENT", HOME ++ "/.Xdefaults/root-urxvt") ] From a4d7f920bf49de6237191558d02b0f58ed307fd4 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 22:55:50 +0200 Subject: [PATCH 57/71] tv URxvt*url-select.launcher = ff --- tv/1systems/wu.nix | 7 +------ tv/2configs/xserver/Xresources.nix | 6 +----- tv/5pkgs/default.nix | 7 ++----- tv/5pkgs/ff/default.nix | 8 ++++++++ 4 files changed, 12 insertions(+), 16 deletions(-) create mode 100644 tv/5pkgs/ff/default.nix diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 987748de0..a5232c9e1 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -40,12 +40,6 @@ with lib; hashPassword lentil parallel - (pkgs.writeScriptBin "ff" '' - #! ${pkgs.bash}/bin/bash - exec sudo -u ff -i < Date: Sun, 25 Oct 2015 02:06:37 +0100 Subject: [PATCH 58/71] tv xmonad service: save state on shutdown --- tv/2configs/xserver/default.nix | 39 ++++++++++----- tv/2configs/xserver/xmonad/Main.hs | 18 ++++--- tv/2configs/xserver/xmonad/Util/Shutdown.hs | 53 +++++++++++++++++++++ 3 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 tv/2configs/xserver/xmonad/Util/Shutdown.hs diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 5d3372609..9e20bda18 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -44,11 +44,14 @@ let systemd.services.display-manager = mkForce {}; services.xserver.enable = true; + systemd.services.xmonad = { wantedBy = [ "multi-user.target" ]; requires = [ "xserver.service" ]; + environment = xmonad-environment; serviceConfig = { - ExecStart = "${xmonad}/bin/xmonad"; + ExecStart = "${xmonad-start}/bin/xmonad"; + ExecStop = "${xmonad-stop}/bin/xmonad-stop"; User = user.name; WorkingDirectory = user.home; }; @@ -69,15 +72,19 @@ let }; }; - xmonad = let - pkg = pkgs.haskellPackages.callPackage src {}; - src = pkgs.runCommand "xmonad-package" {} '' - ${pkgs.cabal2nix}/bin/cabal2nix ${./xmonad} > $out - ''; - in pkgs.writeScriptBin "xmonad" '' - #! /bin/sh + xmonad-pkg = pkgs.haskellPackages.callPackage xmonad-src {}; + xmonad-src = pkgs.runCommand "xmonad-package" {} '' + ${pkgs.cabal2nix}/bin/cabal2nix ${./xmonad} > $out + ''; + + xmonad-environment = { + DISPLAY = ":${toString config.services.xserver.display}"; + XMONAD_STATE = "/tmp/xmonad.state"; + }; + + xmonad-start = pkgs.writeScriptBin "xmonad" '' + #! ${pkgs.bash}/bin/bash set -efu - export DISPLAY; DISPLAY=:${toString config.services.xserver.display} export PATH; PATH=${makeSearchPath "bin" [ pkgs.rxvt_unicode ]}:/var/setuid-wrappers @@ -93,7 +100,17 @@ let settle ${pkgs.xorg.xhost}/bin/xhost +LOCAL: settle ${pkgs.xorg.xrdb}/bin/xrdb -merge ${import ./Xresources.nix args} settle ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' - exec ${pkg}/bin/xmonad + if test -e "$XMONAD_STATE"; then + IFS=''$'\n' + exec ${xmonad-pkg}/bin/xmonad --resume $(< "$XMONAD_STATE") + else + exec ${xmonad-pkg}/bin/xmonad + fi + ''; + + xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' + #! /bin/sh + exec ${xmonad-pkg}/bin/xmonad --shutdown ''; xserver-environment = { @@ -103,7 +120,7 @@ let [ "${pkgs.xorg.libX11}/lib" "${pkgs.xorg.libXext}/lib" ] ++ concatLists (catAttrs "libPath" config.services.xserver.drivers)); }; - + xserver = pkgs.writeScriptBin "xserver" '' #! /bin/sh set -efu diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index cca2902a0..6e0be0579 100644 --- a/tv/2configs/xserver/xmonad/Main.hs +++ b/tv/2configs/xserver/xmonad/Main.hs @@ -1,9 +1,11 @@ {-# LANGUAGE DeriveDataTypeable #-} -- for XS +{-# LANGUAGE LambdaCase #-} module Main where import XMonad +import System.Environment (getArgs) import XMonad.Prompt (defaultXPConfig) import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace , removeEmptyWorkspace) @@ -30,6 +32,7 @@ import XMonad.Layout.PerWorkspace (onWorkspace) import Util.Pager import Util.Rhombus import Util.Debunk +import Util.Shutdown --data MyState = MyState deriving Typeable @@ -48,11 +51,12 @@ myFont :: String myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" main :: IO () -main = do - -- TODO exec (shlex "xrdb -merge" ++ [HOME ++ "/.Xresources"]) - -- TODO exec (shlex "xsetroot -solid '#1c1c1c'") - --spawn "xrdb -merge \"$HOME/.Xresources\"" - --spawn "xsetroot -solid '#1c1c1c'" +main = getArgs >>= \case + ["--shutdown"] -> sendShutdownEvent + _ -> mainNoArgs + +mainNoArgs :: IO () +mainNoArgs = do xmonad -- $ withUrgencyHookC dzenUrgencyHook { args = ["-bg", "magenta", "-fg", "magenta", "-h", "2"], duration = 500000 } -- urgencyConfig { remindWhen = Every 1 } @@ -80,6 +84,7 @@ main = do , startupHook = spawn "echo emit XMonadStartup" , normalBorderColor = "#1c1c1c" , focusedBorderColor = "#f000b0" + , handleEventHook = handleShutdownEvent } where myLayout = @@ -118,8 +123,7 @@ spawnTermAt _ = spawn myTerm myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) myKeys conf = Map.fromList $ - [ ((_4C , xK_Delete ), spawn "make -C $HOME/.xmonad reload") - , ((_4 , xK_Escape ), spawn "/var/setuid-wrappers/slock") + [ ((_4 , xK_Escape ), spawn "/var/setuid-wrappers/slock") , ((_4S , xK_c ), kill) , ((_4 , xK_x ), chooseAction spawnTermAt) diff --git a/tv/2configs/xserver/xmonad/Util/Shutdown.hs b/tv/2configs/xserver/xmonad/Util/Shutdown.hs new file mode 100644 index 000000000..c5a3edb80 --- /dev/null +++ b/tv/2configs/xserver/xmonad/Util/Shutdown.hs @@ -0,0 +1,53 @@ +{-# LANGUAGE LambdaCase #-} +module Util.Shutdown + ( sendShutdownEvent + , handleShutdownEvent + , shutdown + ) + where + +import Control.Monad +import Data.Monoid +import Data.Maybe (catMaybes) +import qualified Data.Map as Map +import System.Environment (getEnv) +import System.Exit (exitSuccess) +import XMonad +import qualified XMonad.StackSet as W + +sendShutdownEvent :: IO () +sendShutdownEvent = do + dpy <- openDisplay "" + rw <- rootWindow dpy $ defaultScreen dpy + a <- internAtom dpy "XMONAD_SHUTDOWN" False + allocaXEvent $ \e -> do + setEventType e clientMessage + setClientMessageEvent e rw a 32 0 currentTime + sendEvent dpy rw False structureNotifyMask e + sync dpy False + +handleShutdownEvent :: Event -> X All +handleShutdownEvent = \case + ClientMessageEvent { ev_message_type = mt } -> do + c <- (mt ==) <$> getAtom "XMONAD_SHUTDOWN" + when c shutdown + return (All c) + _ -> + return (All True) + +shutdown :: X () +shutdown = do + broadcastMessage ReleaseResources + io . flush =<< asks display + let wsData = show . W.mapLayout show . windowset + maybeShow (t, Right (PersistentExtension ext)) = Just (t, show ext) + maybeShow (t, Left str) = Just (t, str) + maybeShow _ = Nothing + extState = + return . show . catMaybes . map maybeShow . Map.toList . extensibleState + s <- gets (\s -> (wsData s : extState s)) + _ <- io $ do + path <- getEnv "XMONAD_STATE" + writeFile path (concatMap (++"\n") s) + exitSuccess + return () From 7d8887386623b8807acba4afbbcc8c0843e60293 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 02:16:26 +0100 Subject: [PATCH 59/71] gitignore tv xmonad shell.nix --- tv/2configs/xserver/xmonad/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 tv/2configs/xserver/xmonad/.gitignore diff --git a/tv/2configs/xserver/xmonad/.gitignore b/tv/2configs/xserver/xmonad/.gitignore new file mode 100644 index 000000000..616204547 --- /dev/null +++ b/tv/2configs/xserver/xmonad/.gitignore @@ -0,0 +1 @@ +/shell.nix From 6f470727a360bcf2f1c1f8a00c87e6bc4c775ba1 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 02:19:14 +0100 Subject: [PATCH 60/71] tv xmonad: purge some stale comments --- tv/2configs/xserver/xmonad/Main.hs | 31 ------------------------------ 1 file changed, 31 deletions(-) diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index 6e0be0579..b71b9a4de 100644 --- a/tv/2configs/xserver/xmonad/Main.hs +++ b/tv/2configs/xserver/xmonad/Main.hs @@ -35,18 +35,12 @@ import Util.Debunk import Util.Shutdown ---data MyState = MyState deriving Typeable - myTerm :: String myTerm = "urxvtc" myRootTerm :: String myRootTerm = "urxvtc -name root-urxvt -e su -" --- TODO execRootTerm = exec (shlex "urxvtc -e su -") --- [ ("XENVIRONMENT", HOME ++ "/.Xdefaults/root-urxvt") ] - - myFont :: String myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" @@ -98,29 +92,6 @@ spawnTermAt :: String -> X () spawnTermAt _ = spawn myTerm - ---jojo w = withDisplay $ \d -> liftIO $ do --- wa <- getWindowAttributes d w --- printToErrors (wa_width wa, wa_height wa, wa_x wa, wa_y wa) - - --sh <- getWMNormalHints d w - --bw <- fmap (fi . wa_border_width) $ getWindowAttributes d w - --return $ applySizeHints bw sh - - ---data WindowDetails = WindowDetails --- { wd_name :: Maybe String --- , wd_rect :: Rectangle --- } deriving (Show) - --- urxvtc --- -title sets {,_NET_}WM_NAME but not WM_CLASS and {,_NET_}WM_ICON_NAME res: title --- -name sets all res: ---mySpawn cmd = do --- p <- xfork $ executeFile "/run/current-system/sw/bin/urxvtc" False [] Nothing --- liftIO $ printToErrors $ (cmd, p) - - myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) myKeys conf = Map.fromList $ [ ((_4 , xK_Escape ), spawn "/var/setuid-wrappers/slock") @@ -277,5 +248,3 @@ wGSConfig = defaultGSConfig allWorkspaceNames :: W.StackSet i l a sid sd -> X [i] allWorkspaceNames ws = return $ map W.tag (W.hidden ws) ++ [W.tag $ W.workspace $ W.current ws] - --- vim:set fdm=marker: From e281271239289a266777d0b429e604ec9aeaed41 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 02:32:19 +0100 Subject: [PATCH 61/71] {tv cfgs => krebs pkgs} writeNixFromCabal --- krebs/5pkgs/default.nix | 4 ++++ tv/2configs/xserver/default.nix | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/krebs/5pkgs/default.nix b/krebs/5pkgs/default.nix index 0ec4b3ded..7df7b7d3c 100644 --- a/krebs/5pkgs/default.nix +++ b/krebs/5pkgs/default.nix @@ -54,4 +54,8 @@ subdirs // rec { gcc -O -Wall -o "$exe" $src strip --strip-unneeded "$exe" ''; + + writeNixFromCabal = name: path: pkgs.runCommand name {} '' + ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out + ''; } diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 9e20bda18..facdf6df2 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -73,9 +73,7 @@ let }; xmonad-pkg = pkgs.haskellPackages.callPackage xmonad-src {}; - xmonad-src = pkgs.runCommand "xmonad-package" {} '' - ${pkgs.cabal2nix}/bin/cabal2nix ${./xmonad} > $out - ''; + xmonad-src = pkgs.writeNixFromCabal "xmonad.nix" ./xmonad; xmonad-environment = { DISPLAY = ":${toString config.services.xserver.display}"; From 8afb910e2a87e0edc9fc4693ed09b4a0ce0fb206 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 09:55:51 +0100 Subject: [PATCH 62/71] tv: drop test.nix --- tv/1systems/wu.nix | 1 - tv/2configs/test.nix | 31 ------------------------------- 2 files changed, 32 deletions(-) delete mode 100644 tv/2configs/test.nix diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index a5232c9e1..586ad1725 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -30,7 +30,6 @@ with lib; ../2configs/git.nix ../2configs/mail-client.nix ../2configs/xserver - ../2configs/test.nix { environment.systemPackages = with pkgs; [ diff --git a/tv/2configs/test.nix b/tv/2configs/test.nix deleted file mode 100644 index f5f068d6f..000000000 --- a/tv/2configs/test.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - out = { - environment.systemPackages = [ - su-test - ]; - security.sudo.extraConfig = '' - tv ALL=(test) NOPASSWD: ALL - ''; - users.extraUsers.test = { - shell = "${test-shell}"; - }; - }; - - su-test = pkgs.execveBin "su-test" rec { - filename = "/var/setuid-wrappers/sudo"; - argv = ["sudo" "-u" "test" "-i"]; - }; - - test-shell = pkgs.execve "test-shell" rec { - filename = "${pkgs.bash}/bin/bash"; - argv = ["sh" "--noprofile" "-l"]; - envp.ENV = pkgs.writeText "test-env" '' - ${shell.cat "Hello, `$(j0w\nd0g!)`!\\o/\n"} >&2 - ''; - }; - -in out From 39236213abc668d35fab45e6bb747f11862e992d Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 12:21:46 +0100 Subject: [PATCH 63/71] tv xmonad: read initial workspaces from file --- tv/2configs/xserver/default.nix | 13 ++++++++++++ tv/2configs/xserver/xmonad/Main.hs | 33 ++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index facdf6df2..c5cffbb30 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -78,6 +78,19 @@ let xmonad-environment = { DISPLAY = ":${toString config.services.xserver.display}"; XMONAD_STATE = "/tmp/xmonad.state"; + + # XXX JSON is close enough :) + XMONAD_WORKSPACES0_FILE = pkgs.writeText "xmonad.workspaces0" (toJSON [ + "Dashboard" # we start here + "23" + "cr" + "ff" + "hack" + "im" + "mail" + "stockholm" + "za" "zj" "zs" + ]); }; xmonad-start = pkgs.writeScriptBin "xmonad" '' diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index b71b9a4de..186a5e22c 100644 --- a/tv/2configs/xserver/xmonad/Main.hs +++ b/tv/2configs/xserver/xmonad/Main.hs @@ -1,11 +1,14 @@ {-# LANGUAGE DeriveDataTypeable #-} -- for XS {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE ScopedTypeVariables #-} module Main where +import Control.Exception +import Text.Read (readEither) import XMonad -import System.Environment (getArgs) +import System.Environment (getArgs, getEnv) import XMonad.Prompt (defaultXPConfig) import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace , removeEmptyWorkspace) @@ -51,6 +54,7 @@ main = getArgs >>= \case mainNoArgs :: IO () mainNoArgs = do + workspaces0 <- getWorkspaces0 xmonad -- $ withUrgencyHookC dzenUrgencyHook { args = ["-bg", "magenta", "-fg", "magenta", "-h", "2"], duration = 500000 } -- urgencyConfig { remindWhen = Every 1 } @@ -61,16 +65,7 @@ mainNoArgs = do { terminal = myTerm , modMask = mod4Mask , keys = myKeys - , workspaces = - [ "Dashboard" -- we start here - , "23" - , "cr" - , "ff" - , "hack" - , "im" - , "mail" - , "zalora", "zjournal", "zskype" - ] + , workspaces = workspaces0 , layoutHook = smartBorders $ myLayout -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent --, handleEventHook = handleTimerEvent @@ -86,6 +81,22 @@ mainNoArgs = do (FixedColumn 1 20 80 10 ||| Full) +getWorkspaces0 :: IO [String] +getWorkspaces0 = + try (getEnv "XMONAD_WORKSPACES0_FILE") >>= \case + Left e -> warn (displaySomeException e) + Right p -> try (readFile p) >>= \case + Left e -> warn (displaySomeException e) + Right x -> case readEither x of + Left e -> warn e + Right y -> return y + where + warn msg = putStrLn ("getWorkspaces0: " ++ msg) >> return [] + +displaySomeException :: SomeException -> String +displaySomeException = displayException + + spawnTermAt :: String -> X () --spawnTermAt _ = floatNext True >> spawn myTerm --spawnTermAt "ff" = floatNext True >> spawn myTerm From daa8fe2aa83451e7d4fc120f7fd417409ac2666c Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 14:07:51 +0100 Subject: [PATCH 64/71] init users.shared.wolf --- krebs/3modules/default.nix | 1 + krebs/3modules/shared/default.nix | 42 ++++++++++++ krebs/Zhosts/wolf | 10 +++ shared/1systems/wolf.nix | 108 ++++++++++++++++++++++++++++++ shared/3modules/default.nix | 5 ++ shared/5pkgs/default.nix | 5 ++ 6 files changed, 171 insertions(+) create mode 100644 krebs/3modules/shared/default.nix create mode 100644 krebs/Zhosts/wolf create mode 100644 shared/1systems/wolf.nix create mode 100644 shared/3modules/default.nix create mode 100644 shared/5pkgs/default.nix diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index e244ef7b7..dd2f9e762 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -76,6 +76,7 @@ let imp = mkMerge [ { krebs = import ./lass { inherit lib; }; } { krebs = import ./makefu { inherit lib; }; } + { krebs = import ./shared { inherit lib; }; } { krebs = import ./tv { inherit lib; }; } { krebs.dns.providers = { diff --git a/krebs/3modules/shared/default.nix b/krebs/3modules/shared/default.nix new file mode 100644 index 000000000..24dd7b782 --- /dev/null +++ b/krebs/3modules/shared/default.nix @@ -0,0 +1,42 @@ +{ lib, ... }: + +with lib; + +{ + hosts = addNames { + wolf = { + #dc = "shack"; + nets = { + #shack = { + # addrs4 = [ TODO ]; + # aliases = ["wolf.shack"]; + #}; + retiolum = { + addrs4 = ["10.243.77.1"]; + addrs6 = ["42:0:0:0:0:0:77:1"]; + aliases = [ + "wolf.retiolum" + ]; + tinc.pubkey = '' + -----BEGIN RSA PUBLIC KEY----- + MIIBCgKCAQEAzpXyEATt8+ElxPq650/fkboEC9RvTWqN6UIAl/R4Zu+uDhAZ2ekb + HBjoSbRxu/0w2I37nwWUhEOemxGm4PXCgWrtO0jeRF4nVNYu3ZBppA3vuVALUWq7 + apxRUEL9FdsWQlXGo4PVd20dGaDTi8M/Ggo755MStVTY0rRLluxyPq6VAa015sNg + 4NOFuWm0NDn4e+qrahTCTiSjbCU8rWixm0GktV40kdg0QAiFbEcRhuXF1s9/yojk + 7JT/nFg6LELjWUSSNZnioj5oSfVbThDRelIld9VaAKBAZZ5/zy6T2XSeDfoepytH + 8aw6itEuTCy1M1DTiTG+12SPPw+ubG+NqQIDAQAB + -----END RSA PUBLIC KEY----- + ''; + }; + }; + ssh.privkey.path = ; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKYMXMWZIK0jjnZDM9INiYAKcwjXs2241vew54K8veCR"; + }; + }; + users = addNames { + shared = { + mail = "spam@krebsco.de"; + pubkey = "lol"; # TODO krebs.users.shared.pubkey should be unnecessary + }; + }; +} diff --git a/krebs/Zhosts/wolf b/krebs/Zhosts/wolf new file mode 100644 index 000000000..ded8275bd --- /dev/null +++ b/krebs/Zhosts/wolf @@ -0,0 +1,10 @@ +Subnet = 10.243.77.1/32 +Subnet = 42:0:0:0:0:0:77:1/128 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAzpXyEATt8+ElxPq650/fkboEC9RvTWqN6UIAl/R4Zu+uDhAZ2ekb +HBjoSbRxu/0w2I37nwWUhEOemxGm4PXCgWrtO0jeRF4nVNYu3ZBppA3vuVALUWq7 +apxRUEL9FdsWQlXGo4PVd20dGaDTi8M/Ggo755MStVTY0rRLluxyPq6VAa015sNg +4NOFuWm0NDn4e+qrahTCTiSjbCU8rWixm0GktV40kdg0QAiFbEcRhuXF1s9/yojk +7JT/nFg6LELjWUSSNZnioj5oSfVbThDRelIld9VaAKBAZZ5/zy6T2XSeDfoepytH +8aw6itEuTCy1M1DTiTG+12SPPw+ubG+NqQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/shared/1systems/wolf.nix b/shared/1systems/wolf.nix new file mode 100644 index 000000000..d4ed40956 --- /dev/null +++ b/shared/1systems/wolf.nix @@ -0,0 +1,108 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ + + ]; + + krebs.build.host = config.krebs.hosts.wolf; + # TODO rename shared user to "krebs" + krebs.build.user = config.krebs.users.shared; + krebs.build.target = "wolf"; + + krebs.enable = true; + krebs.retiolum = { + enable = true; + connectTo = [ + # TODO remove connectTo cd, this was only used for bootstrapping + "cd" + "gum" + "pigstarter" + ]; + }; + + krebs.build.source = { + git.nixpkgs = { + url = https://github.com/NixOS/nixpkgs; + rev = "e916273209560b302ab231606babf5ce1c481f08"; + }; + dir.secrets = { + # TODO use current-host-name to determine secrets host + host = config.krebs.hosts.wu; + path = "${getEnv "HOME"}/secrets/krebs/wolf"; + }; + dir.stockholm = { + # TODO use current-host-name to determine stockholm host + host = config.krebs.hosts.wu; + path = "${getEnv "HOME"}/stockholm"; + }; + }; + + networking.hostName = config.krebs.build.host.name; + + boot.kernel.sysctl = { + # Enable IPv6 Privacy Extensions + "net.ipv6.conf.all.use_tempaddr" = 2; + "net.ipv6.conf.default.use_tempaddr" = 2; + }; + + boot.initrd.availableKernelModules = [ + "ata_piix" "uhci_hcd" "ehci_pci" "virtio_pci" "virtio_blk" + ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.device = "/dev/vda"; + + fileSystems."/" = { device = "/dev/disk/by-label/nixos"; fsType = "ext4"; }; + + swapDevices = [ + { device = "/dev/disk/by-label/swap"; } + ]; + + nix.maxJobs = 1; + nix.trustedBinaryCaches = [ + "https://cache.nixos.org" + "http://cache.nixos.org" + "http://hydra.nixos.org" + ]; + nix.useChroot = true; + + nixpkgs.config.packageOverrides = pkgs: { + nano = pkgs.vim; + }; + + environment.systemPackages = with pkgs; [ + git + rxvt_unicode.terminfo + ]; + + time.timeZone = "Europe/Berlin"; + + programs.ssh.startAgent = false; + + services.openssh = { + enable = true; + hostKeys = [ + { type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; } + ]; + }; + services.cron.enable = false; + services.nscd.enable = false; + services.ntp.enable = false; + + users.mutableUsers = false; + users.extraUsers.root.openssh.authorizedKeys.keys = [ + # TODO + config.krebs.users.lass.pubkey + config.krebs.users.makefu.pubkey + config.krebs.users.tv.pubkey + ]; + + # The NixOS release to be compatible with for stateful data such as databases. + system.stateVersion = "15.09"; +} diff --git a/shared/3modules/default.nix b/shared/3modules/default.nix new file mode 100644 index 000000000..7fbdb77f4 --- /dev/null +++ b/shared/3modules/default.nix @@ -0,0 +1,5 @@ +# TODO don't require 3modules +_: + +{ +} diff --git a/shared/5pkgs/default.nix b/shared/5pkgs/default.nix new file mode 100644 index 000000000..fdcfbb209 --- /dev/null +++ b/shared/5pkgs/default.nix @@ -0,0 +1,5 @@ +# TODO don't require 5pkgs +_: + +{ +} From 8f15daf2ea25304e9cbc8d449fb92078b2fb6f03 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 14:15:21 +0100 Subject: [PATCH 65/71] init krebs.current --- default.nix | 6 +++++- krebs/3modules/current.nix | 26 ++++++++++++++++++++++++++ krebs/3modules/default.nix | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 krebs/3modules/current.nix diff --git a/default.nix b/default.nix index c78464198..472d7597d 100644 --- a/default.nix +++ b/default.nix @@ -31,9 +31,13 @@ let stockholm = { kpath = lib.nspath "krebs"; upath = lib.nspath current-user-name; - base-module = { + base-module = { config, ... }: { imports = map (f: f "3modules") [ kpath upath ]; + krebs.current.enable = true; + krebs.current.host = config.krebs.hosts.${current-host-name}; + krebs.current.user = config.krebs.users.${current-user-name}; + nixpkgs.config.packageOverrides = pkgs: let kpkgs = import (kpath "5pkgs") { inherit lib pkgs; }; diff --git a/krebs/3modules/current.nix b/krebs/3modules/current.nix new file mode 100644 index 000000000..41941e289 --- /dev/null +++ b/krebs/3modules/current.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.krebs.current; + + out = { + options.krebs.current = api; + config = mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "krebs.current"; + host = mkOption { + type = types.host; + }; + user = mkOption { + type = types.user; + }; + }; + + imp = { + }; + +in out diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index dd2f9e762..2b5fc478c 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -8,6 +8,7 @@ let imports = [ ./bepasty-server.nix ./build.nix + ./current.nix ./exim-retiolum.nix ./exim-smarthost.nix ./github-hosts-sync.nix From 4b22988392f940c705e7f3fddc39481635777895 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 14:17:45 +0100 Subject: [PATCH 66/71] wolf: build.source.dir.*.host = current.host --- shared/1systems/wolf.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shared/1systems/wolf.nix b/shared/1systems/wolf.nix index d4ed40956..aeaeee288 100644 --- a/shared/1systems/wolf.nix +++ b/shared/1systems/wolf.nix @@ -29,13 +29,11 @@ with lib; rev = "e916273209560b302ab231606babf5ce1c481f08"; }; dir.secrets = { - # TODO use current-host-name to determine secrets host - host = config.krebs.hosts.wu; + host = config.krebs.current.host; path = "${getEnv "HOME"}/secrets/krebs/wolf"; }; dir.stockholm = { - # TODO use current-host-name to determine stockholm host - host = config.krebs.hosts.wu; + host = config.krebs.current.host; path = "${getEnv "HOME"}/stockholm"; }; }; From cca25c7b66c44e0ec826d466bd48f2463df03fe9 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 25 Oct 2015 18:06:46 +0100 Subject: [PATCH 67/71] wry: listen for graphs.retiolum --- krebs/3modules/makefu/default.nix | 1 + makefu/1systems/wry.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix index d328033cc..e36a083f2 100644 --- a/krebs/3modules/makefu/default.nix +++ b/krebs/3modules/makefu/default.nix @@ -185,6 +185,7 @@ with lib; addrs6 = ["42:6e1e:cc8a:7cef:827:f938:8c64:baad"]; aliases = [ "graphs.wry.retiolum" + "graphs.retiolum" "paste.wry.retiolum" "paste.retiolum" "wry.retiolum" diff --git a/makefu/1systems/wry.nix b/makefu/1systems/wry.nix index 6627d87b5..3baf31dc5 100644 --- a/makefu/1systems/wry.nix +++ b/makefu/1systems/wry.nix @@ -47,7 +47,7 @@ in { # TODO: remove hard-coded hostname complete = { listen = [ "${internal-ip}:80" ]; - server-names = [ "graphs.wry" ]; + server-names = [ "graphs.wry" "graphs.retiolum" "graphs.wry.retiolum" ]; }; anonymous = { listen = [ "${external-ip}:80" ] ; From 642583145200f5a2cb8be1b38707e2b2ea3dc3e5 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 25 Oct 2015 21:54:59 +0100 Subject: [PATCH 68/71] k 3 tinc_graphs: is now completely self-contained --- krebs/3modules/tinc_graphs.nix | 7 +++++-- {makefu => krebs}/5pkgs/tinc_graphs/default.nix | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) rename {makefu => krebs}/5pkgs/tinc_graphs/default.nix (89%) diff --git a/krebs/3modules/tinc_graphs.nix b/krebs/3modules/tinc_graphs.nix index a6c628353..e415d20ab 100644 --- a/krebs/3modules/tinc_graphs.nix +++ b/krebs/3modules/tinc_graphs.nix @@ -95,8 +95,12 @@ let ExecStartPre = pkgs.writeScript "tinc_graphs-init" '' #!/bin/sh + mkdir -p "${internal_dir}" "${external_dir}" if ! test -e "${cfg.workingDir}/internal/index.html"; then - cp -fr "$(${pkgs.tinc_graphs}/bin/tincstats-static-dir)/internal/" "${internal_dir}" + cp -fr "$(${pkgs.tinc_graphs}/bin/tincstats-static-dir)/internal/." "${internal_dir}" + fi + if ! test -e "${cfg.workingDir}/external/index.html"; then + cp -fr "$(${pkgs.tinc_graphs}/bin/tincstats-static-dir)/external/." "${external_dir}" fi ''; @@ -118,7 +122,6 @@ let users.extraUsers.tinc_graphs = { uid = 3925439960; #genid tinc_graphs home = "/var/spool/tinc_graphs"; - createHome = true; }; krebs.nginx.servers = mkIf cfg.nginx.enable { diff --git a/makefu/5pkgs/tinc_graphs/default.nix b/krebs/5pkgs/tinc_graphs/default.nix similarity index 89% rename from makefu/5pkgs/tinc_graphs/default.nix rename to krebs/5pkgs/tinc_graphs/default.nix index 62a787d30..3040cabe8 100644 --- a/makefu/5pkgs/tinc_graphs/default.nix +++ b/krebs/5pkgs/tinc_graphs/default.nix @@ -2,14 +2,14 @@ python3Packages.buildPythonPackage rec { name = "tinc_graphs-${version}"; - version = "0.3.6"; + version = "0.3.8"; propagatedBuildInputs = with pkgs;[ python3Packages.pygeoip ## ${geolite-legacy}/share/GeoIP/GeoIPCity.dat ]; src = fetchurl { url = "https://pypi.python.org/packages/source/t/tinc_graphs/tinc_graphs-${version}.tar.gz"; - sha256 = "0ghdx9aaipmppvc2b6cgks4nxw6zsb0fhjrmnisbx7rz0vjvzc74"; + sha256 = "0jc014ipx9pbx5dwi9s5n921c2c26m5vvzrvpjmca550gpdqd5f4"; }; preFixup = with pkgs;'' wrapProgram $out/bin/build-graphs --prefix PATH : "$out/bin" From cb1b101dfa2c8e0aa9a3ef0c64788912e0148085 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 26 Oct 2015 00:02:51 +0100 Subject: [PATCH 69/71] tinc_graphs: clean up mv {makefu,krebs} --- krebs/5pkgs/tinc_graphs/default.nix | 4 ++-- makefu/5pkgs/default.nix | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/krebs/5pkgs/tinc_graphs/default.nix b/krebs/5pkgs/tinc_graphs/default.nix index 3040cabe8..e5f1e40e8 100644 --- a/krebs/5pkgs/tinc_graphs/default.nix +++ b/krebs/5pkgs/tinc_graphs/default.nix @@ -2,14 +2,14 @@ python3Packages.buildPythonPackage rec { name = "tinc_graphs-${version}"; - version = "0.3.8"; + version = "0.3.9"; propagatedBuildInputs = with pkgs;[ python3Packages.pygeoip ## ${geolite-legacy}/share/GeoIP/GeoIPCity.dat ]; src = fetchurl { url = "https://pypi.python.org/packages/source/t/tinc_graphs/tinc_graphs-${version}.tar.gz"; - sha256 = "0jc014ipx9pbx5dwi9s5n921c2c26m5vvzrvpjmca550gpdqd5f4"; + sha256 = "0hjmkiclvyjb3707285x4b8mk5aqjcvh383hvkad1h7p1n61qrfx"; }; preFixup = with pkgs;'' wrapProgram $out/bin/build-graphs --prefix PATH : "$out/bin" diff --git a/makefu/5pkgs/default.nix b/makefu/5pkgs/default.nix index 7945b6ebd..b9661e1cd 100644 --- a/makefu/5pkgs/default.nix +++ b/makefu/5pkgs/default.nix @@ -7,6 +7,5 @@ in alsa-hdspmixer = callPackage ./alsa-tools { alsaToolTarget="hdspmixer";}; alsa-hdspconf = callPackage ./alsa-tools { alsaToolTarget="hdspconf";}; alsa-hdsploader = callPackage ./alsa-tools { alsaToolTarget="hdsploader";}; - tinc_graphs = callPackage ./tinc_graphs {}; awesomecfg = callPackage ./awesomecfg {}; } From 526adba3c81d267266946e7fc96a4a3b51cab366 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 26 Oct 2015 00:04:15 +0100 Subject: [PATCH 70/71] k 3 urlwatch: add verbose flag --- krebs/3modules/urlwatch.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 80d9f5e93..206bc5697 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -56,6 +56,13 @@ let https://nixos.org/channels/nixos-unstable/git-revision ]; }; + verbose = mkOption { + type = types.bool; + default = false; + description = '' + verbose output of urlwatch + ''; + }; }; urlsFile = toFile "urls" (concatStringsSep "\n" cfg.urls); @@ -106,7 +113,7 @@ let cd /tmp - urlwatch -e --urls="$urlsFile" > changes 2>&1 || : + urlwatch -e ${optionalString cfg.verbose "-v"} --urls="$urlsFile" > changes || : if test -s changes; then date=$(date -R) From 20ad77468131b7c69c5b3a26ea149ae7fdc0173b Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 26 Oct 2015 00:47:10 +0100 Subject: [PATCH 71/71] m 1 pnp: make urlwatch verbose, update url list --- makefu/1systems/pnp.nix | 2 ++ makefu/2configs/urlwatch.nix | 2 ++ 2 files changed, 4 insertions(+) diff --git a/makefu/1systems/pnp.nix b/makefu/1systems/pnp.nix index e7ceca60d..80600e988 100644 --- a/makefu/1systems/pnp.nix +++ b/makefu/1systems/pnp.nix @@ -32,6 +32,8 @@ # ../2configs/graphite-standalone.nix ]; + krebs.urlwatch.verbose = true; + krebs.Reaktor.enable = true; krebs.Reaktor.debug = true; krebs.Reaktor.nickname = "Reaktor|bot"; diff --git a/makefu/2configs/urlwatch.nix b/makefu/2configs/urlwatch.nix index 933cb93c5..01e5e8be5 100644 --- a/makefu/2configs/urlwatch.nix +++ b/makefu/2configs/urlwatch.nix @@ -10,6 +10,8 @@ https://api.github.com/repos/ovh/python-ovh/tags https://api.github.com/repos/embray/d2to1/tags http://git.sysphere.org/vicious/log/?qt=grep&q=Next+release + https://github.com/bepasty/bepasty-server/tags + https://pypi.python.org/simple/xstatic/ ]; };