From 95999d2ef4b426c68c5d4875554ff8c3e10669e0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 31 Oct 2015 15:09:11 +0100 Subject: l 1 prism: add git.nix --- lass/1systems/prism.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lass/1systems/prism.nix b/lass/1systems/prism.nix index 570cdfb7c..bb22b471f 100644 --- a/lass/1systems/prism.nix +++ b/lass/1systems/prism.nix @@ -8,6 +8,7 @@ in { imports = [ ../2configs/base.nix ../2configs/downloading.nix + ../2configs/git.nix { users.extraGroups = { # ● systemd-tmpfiles-setup.service - Create Volatile Files and Directories -- cgit v1.2.3 From 10fc9eb4ee5151bee86026cd81a73d333551b612 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 31 Oct 2015 15:09:43 +0100 Subject: l 2: get ssh-keys via api --- lass/2configs/base.nix | 8 ++++---- lass/2configs/downloading.nix | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lass/2configs/base.nix b/lass/2configs/base.nix index 057af7bc4..11bc4f089 100644 --- a/lass/2configs/base.nix +++ b/lass/2configs/base.nix @@ -15,8 +15,8 @@ with lib; { users.extraUsers = { root = { - openssh.authorizedKeys.keys = map readFile [ - ../../krebs/Zpubkeys/lass.ssh.pub + openssh.authorizedKeys.keys = [ + config.krebs.users.lass.pubkey ]; }; mainUser = { @@ -28,8 +28,8 @@ with lib; useDefaultShell = true; extraGroups = [ ]; - openssh.authorizedKeys.keys = map readFile [ - ../../krebs/Zpubkeys/lass.ssh.pub + openssh.authorizedKeys.keys = [ + config.krebs.users.lass.pubkey ]; }; }; diff --git a/lass/2configs/downloading.nix b/lass/2configs/downloading.nix index 553a3a557..b9f3449e4 100644 --- a/lass/2configs/downloading.nix +++ b/lass/2configs/downloading.nix @@ -15,8 +15,8 @@ with lib; extraGroups = [ "download" ]; - openssh.authorizedKeys.keys = map readFile [ - ../../krebs/Zpubkeys/lass.ssh.pub + openssh.authorizedKeys.keys = [ + config.krebs.users.lass.pubkey ]; }; -- cgit v1.2.3 From e8d41346d34cf24652e8e77fab6bb0a0dd86a199 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 31 Oct 2015 15:11:15 +0100 Subject: l 2 downloading: get rpc-password from secrets --- lass/2configs/downloading.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lass/2configs/downloading.nix b/lass/2configs/downloading.nix index b9f3449e4..e80b74007 100644 --- a/lass/2configs/downloading.nix +++ b/lass/2configs/downloading.nix @@ -1,7 +1,10 @@ { config, lib, pkgs, ... }: with lib; -{ + +let + rpc-password = import ; +in { imports = [ ../3modules/folderPerms.nix ]; @@ -46,8 +49,7 @@ with lib; rpc-authentication-required = true; rpc-whitelist-enabled = false; rpc-username = "download"; - #add rpc-password in secrets - rpc-password = "test123"; + inherit rpc-password; peer-port = 51413; }; }; -- cgit v1.2.3 From f171c53dd883f57bd0acb6cc6bf0dd1b90ce83ef Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 1 Nov 2015 19:52:49 +0100 Subject: k 3 l: use rsa keys in prism --- krebs/3modules/lass/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 0be166255..2ad4353bd 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -96,8 +96,8 @@ in { ''; }; }; - ssh.privkey.path = ; - ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINKVjJrM7fHfHpvZXEA3hmX4JliHl6h6Q8AGOPcu+9fF"; + ssh.privkey.path = ; + ssh.pubkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChm4sqQ2bUZj+2YnTf6G5HHRTpSe1jTUhJRnwcYPYZKF+CBqBncipRpuGlGXEsptNa+7ZMcQC0ySsz5SUOMt3Ih+NehVe/qt3VtRz0l0MgOWmH2qBwKK9Y4IuxrJQzUmP4UGlOGlFj9DORssSMOyFIG4eZ9k2qMn3xal0NVRfGTShKlouWsiUILZ8I+sDNE00z8DAYesgc1yazvRnjzvLkRxdNdpYiAFBbmXMpPKK95McRJaWsuNSeal9kd5p5PagWcgN4DZ6+ebzz3NKnmzk4j+vuHX0U9lTXBqKMlzzmM2YNLRtDPfrtJNyHqLpZUpFhJKqZCD+4/0zdrzRfC7Th+5czzUCSvHiKPVsqw5eOdiQX6EyzNAF5zpkpRp//QdUNNXC5/Ku6GKCO491+TuA8VCha0fOwBONccTLUI/hGNmCh88mLbukVoeGJrbYNCOA/6kEz7ZLEveU4i+TT7okhDElMsNk+AWCZ8/NdJQNX3/K6+JJ9qAn+/yC8LdjgYYJ2oU/aw5/HyOgiQ0z4n9UfQ7j+nHysY9CQb1b3guX7yjJoc3KpNXCXEztuIRHjFD1EP8NRTSmGjsa/VjLmTLSsqjD+7IE5mT0tO5RJvmagDgdJSr/iR5D9zjW7hx7ttvektrlp9g0v3CiCFVaW4l95hGYT0HaNBLJ5R0YHm0lD+Q=="; }; fastpoke = { dc = "lass"; -- cgit v1.2.3 From f18a958ce57d2a91af9ba547cbf8cb21e19b99f8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 1 Nov 2015 19:57:05 +0100 Subject: l 2: add ts3.nix --- lass/2configs/ts3.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lass/2configs/ts3.nix diff --git a/lass/2configs/ts3.nix b/lass/2configs/ts3.nix new file mode 100644 index 000000000..5b92d0919 --- /dev/null +++ b/lass/2configs/ts3.nix @@ -0,0 +1,19 @@ +{ config, ... }: + +{ + services.teamspeak3 = { + enable = true; + }; + + krebs.iptables.tables.filter.INPUT.rules = [ + #voice port + { predicate = "-p tcp --dport 9987"; target = "ACCEPT"; } + { predicate = "-p udp --dport 9987"; target = "ACCEPT"; } + ##file transfer port + #{ predicate = "-p tcp --dport 30033"; target = "ACCEPT"; } + #{ predicate = "-p udp --dport 30033"; target = "ACCEPT"; } + ##query port + #{ predicate = "-p tcp --dport 10011"; target = "ACCEPT"; } + #{ predicate = "-p udp --dport 10011"; target = "ACCEPT"; } + ]; +} -- cgit v1.2.3 From a7621594563dc92684e0b9cc31a85645a4b8d3fd Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 1 Nov 2015 19:58:59 +0100 Subject: l 1 prism: activate ts3 server --- lass/1systems/prism.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lass/1systems/prism.nix b/lass/1systems/prism.nix index bb22b471f..ae90251cc 100644 --- a/lass/1systems/prism.nix +++ b/lass/1systems/prism.nix @@ -9,6 +9,7 @@ in { ../2configs/base.nix ../2configs/downloading.nix ../2configs/git.nix + ../2configs/ts3.nix { users.extraGroups = { # ● systemd-tmpfiles-setup.service - Create Volatile Files and Directories -- cgit v1.2.3 From cb5e5f452c320d0f75bd46a82fd6afc96e11d73e Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 1 Nov 2015 20:00:19 +0100 Subject: l 1 mors: add hashPassword to systemPackages --- lass/1systems/mors.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index b0b8ff573..7db3f8333 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -156,6 +156,7 @@ get genid teamspeak_client + hashPassword ]; #TODO: fix this shit -- cgit v1.2.3 From fd42a107a517d0f67005efcd9ed4f1400ffdb154 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 1 Nov 2015 20:00:43 +0100 Subject: l 1 prism: allowUnfree for ts3 --- lass/1systems/prism.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lass/1systems/prism.nix b/lass/1systems/prism.nix index ae90251cc..87334c3c2 100644 --- a/lass/1systems/prism.nix +++ b/lass/1systems/prism.nix @@ -84,6 +84,9 @@ in { #workaround for server dying after 6-7h boot.kernelPackages = pkgs.linuxPackages_4_2; } + { + nixpkgs.config.allowUnfree = true; + } ]; krebs.build.host = config.krebs.hosts.prism; -- cgit v1.2.3 From bae469d2a64165a42d93cdb31e231fa75e9813a5 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 6 Nov 2015 22:36:01 +0100 Subject: tv: condense krebs.build --- tv/1systems/mkdir.nix | 14 -------------- tv/1systems/nomic.nix | 14 -------------- tv/1systems/rmdir.nix | 14 -------------- tv/1systems/wu.nix | 18 ------------------ tv/1systems/xu.nix | 16 ---------------- tv/2configs/default.nix | 19 +++++++++++++++++++ 6 files changed, 19 insertions(+), 76 deletions(-) diff --git a/tv/1systems/mkdir.nix b/tv/1systems/mkdir.nix index 55d83f8f3..6ae4f80e8 100644 --- a/tv/1systems/mkdir.nix +++ b/tv/1systems/mkdir.nix @@ -17,23 +17,9 @@ in { krebs.build.host = config.krebs.hosts.mkdir; - krebs.build.user = config.krebs.users.tv; krebs.build.target = "root@${primary-addr4}"; - krebs.build.source = { - git.nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "c44a593aa43bba6a0708f6f36065a514a5110613"; - }; - dir.secrets = { - path = "/home/tv/secrets/mkdir"; - }; - dir.stockholm = { - path = "/home/tv/stockholm"; - }; - }; - imports = [ ../2configs/hw/CAC-Developer-1.nix ../2configs/fs/CAC-CentOS-7-64bit.nix diff --git a/tv/1systems/nomic.nix b/tv/1systems/nomic.nix index c2bb4dc78..0c6c935a3 100644 --- a/tv/1systems/nomic.nix +++ b/tv/1systems/nomic.nix @@ -4,23 +4,9 @@ with lib; { krebs.build.host = config.krebs.hosts.nomic; - krebs.build.user = config.krebs.users.tv; krebs.build.target = "root@nomic.gg23"; - krebs.build.source = { - git.nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "c44a593aa43bba6a0708f6f36065a514a5110613"; - }; - dir.secrets = { - path = "/home/tv/secrets/nomic"; - }; - dir.stockholm = { - path = "/home/tv/stockholm"; - }; - }; - imports = [ ../2configs/hw/AO753.nix #../2configs/consul-server.nix diff --git a/tv/1systems/rmdir.nix b/tv/1systems/rmdir.nix index 53f14d7df..1f1d975c9 100644 --- a/tv/1systems/rmdir.nix +++ b/tv/1systems/rmdir.nix @@ -17,23 +17,9 @@ in { krebs.build.host = config.krebs.hosts.rmdir; - krebs.build.user = config.krebs.users.tv; krebs.build.target = "root@rmdir.internet"; - krebs.build.source = { - git.nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "c44a593aa43bba6a0708f6f36065a514a5110613"; - }; - dir.secrets = { - path = "/home/tv/secrets/rmdir"; - }; - dir.stockholm = { - path = "/home/tv/stockholm"; - }; - }; - imports = [ ../2configs/hw/CAC-Developer-1.nix ../2configs/fs/CAC-CentOS-7-64bit.nix diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 33292c608..26a603e9b 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -4,24 +4,6 @@ with lib; { krebs.build.host = config.krebs.hosts.wu; - krebs.build.user = config.krebs.users.tv; - - krebs.build.target = "root@wu"; - - krebs.build.source = { - git.nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "c44a593aa43bba6a0708f6f36065a514a5110613"; - target-path = "/var/src/nixpkgs"; - }; - dir.secrets = { - path = "/home/tv/secrets/wu"; - }; - dir.stockholm = { - path = "/home/tv/stockholm"; - target-path = "/var/src/stockholm"; - }; - }; imports = [ ../2configs/hw/w110er.nix diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix index 607f89aea..65220fe3e 100644 --- a/tv/1systems/xu.nix +++ b/tv/1systems/xu.nix @@ -4,22 +4,6 @@ with lib; { krebs.build.host = config.krebs.hosts.xu; - krebs.build.user = config.krebs.users.tv; - - krebs.build.target = "root@xu"; - - krebs.build.source = { - git.nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "c44a593aa43bba6a0708f6f36065a514a5110613"; - }; - dir.secrets = { - path = "/home/tv/secrets/xu"; - }; - dir.stockholm = { - path = "/home/tv/stockholm"; - }; - }; imports = [ ../2configs/hw/x220.nix diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index d3f4eed0d..d31862b60 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -5,6 +5,25 @@ with lib; { krebs.enable = true; + krebs.build = { + user = config.krebs.users.tv; + target = mkDefault "root@${config.krebs.build.host.name}"; + source = { + git.nixpkgs = { + url = mkDefault https://github.com/NixOS/nixpkgs; + rev = mkDefault "c44a593aa43bba6a0708f6f36065a514a5110613"; + target-path = mkDefault "/var/src/nixpkgs"; + }; + dir.secrets = { + path = mkDefault "/home/tv/secrets/${config.krebs.build.host.name}"; + }; + dir.stockholm = { + path = mkDefault "/home/tv/stockholm"; + target-path = mkDefault "/var/src/stockholm"; + }; + }; + }; + networking.hostName = config.krebs.build.host.name; imports = [ -- cgit v1.2.3 From 1d8be110e1559e804d44dfdb3c5b584efa4561a8 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2015 09:43:05 +0100 Subject: nomic: bump ssh key --- 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 6c943de8f..56b4abe00 100644 --- a/krebs/3modules/tv/default.nix +++ b/krebs/3modules/tv/default.nix @@ -159,7 +159,7 @@ with lib; }; secure = true; ssh.privkey.path = ; - ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILMPMh3nHxVcPqM+LrkK7eYxNJY1ShBXOTg1vlSR45wx"; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMIHmwXHV7E9UGuk4voVCADjlLkyygqNw054jvrsPn5t root@nomic"; }; ok = { nets = { -- cgit v1.2.3 From d590cf26cd8fa33ed4140bef7a5d689c76455625 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2015 09:45:43 +0100 Subject: xu: bump ssh key --- krebs/3modules/tv/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix index 56b4abe00..6fd1c4224 100644 --- a/krebs/3modules/tv/default.nix +++ b/krebs/3modules/tv/default.nix @@ -277,7 +277,8 @@ with lib; }; }; secure = true; - ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID554niVFWomJjuSuQoiCdMUYrCFPpPzQuaoXXYYDxlw"; + ssh.privkey.path = ; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPnjfceKuHNQu7S4eYFN1FqgzMqiL7haNZMh2ZLhvuhK root@xu"; }; }; users = addNames rec { -- cgit v1.2.3 From a3f6dcb75ce73f57e1053054cf70667c2daef22d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2015 10:04:46 +0100 Subject: tv: move X-based tools to xserver --- tv/1systems/wu.nix | 7 ------- tv/1systems/xu.nix | 8 +------- tv/2configs/xserver/default.nix | 6 ++++++ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 26a603e9b..ee529f3dc 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -44,31 +44,24 @@ with lib; bind # dig cac dic - ff file get - gitAndTools.qgit gnupg21 haskellPackages.hledger htop jq manpages mkpasswd - mpv netcat nix-repl nmap nq p7zip - pavucontrol posix_man_pages - pssh push qrencode - sxiv texLive tmux - zathura #ack #apache-httpd diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix index 65220fe3e..32688aaed 100644 --- a/tv/1systems/xu.nix +++ b/tv/1systems/xu.nix @@ -44,29 +44,23 @@ with lib; bind # dig #cac dic - ff file - gitAndTools.qgit #xserver gnupg21 haskellPackages.hledger htop jq manpages mkpasswd - mpv #xserver netcat nix-repl nmap nq p7zip - pavucontrol #xserver + pass posix_man_pages - #pssh qrencode - sxiv #xserver texLive tmux - zathura #xserver #ack #apache-httpd diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index df00203be..7a48db6b8 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -34,7 +34,13 @@ let }; environment.systemPackages = [ + pkgs.ff + pkgs.gitAndTools.qgit + pkgs.mpv + pkgs.pavucontrol pkgs.slock + pkgs.sxiv + pkgs.zathura ]; security.setuidPrograms = [ -- cgit v1.2.3 From e57ce8bc98ba3d90b0044d90f4bff10475354fd1 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2015 19:21:01 +0100 Subject: xu nixpkgs: c44a593 -> 7ae05ed --- tv/1systems/xu.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix index 65220fe3e..d9aec4070 100644 --- a/tv/1systems/xu.nix +++ b/tv/1systems/xu.nix @@ -5,6 +5,9 @@ with lib; { krebs.build.host = config.krebs.hosts.xu; + krebs.build.source.git.nixpkgs.rev = + "7ae05edcdd14f6ace83ead9bf0d114e97c89a83a"; + imports = [ ../2configs/hw/x220.nix #../2configs/consul-client.nix -- cgit v1.2.3 From e35e3b5eb05cea1e3c033423c2f6ee4e0a511817 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2015 19:24:25 +0100 Subject: tv: mv user xr to sub --- tv/1systems/wu.nix | 11 +++-------- tv/1systems/xu.nix | 9 +-------- tv/2configs/sub/xr.nix | 22 ++++++++++++++++++++++ tv/2configs/xserver/default.nix | 1 + tv/2configs/z.nix | 11 +---------- tv/5pkgs/default.nix | 10 ++++++++++ 6 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 tv/2configs/sub/xr.nix diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index ee529f3dc..2c0098c1c 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -12,6 +12,7 @@ with lib; ../2configs/mail-client.nix ../2configs/xserver ../2configs/z.nix + ../2configs/sub/xr.nix { environment.systemPackages = with pkgs; [ @@ -120,6 +121,8 @@ with lib; #xkill #xl2tpd #xsel + + unison ]; } { @@ -234,14 +237,6 @@ with lib; ]; }; - xr = { - uid = 13370061; - extraGroups = [ - "audio" - "video" - ]; - }; - "23" = { uid = 13370023; }; diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix index 20e0e9681..57f318ad0 100644 --- a/tv/1systems/xu.nix +++ b/tv/1systems/xu.nix @@ -15,6 +15,7 @@ with lib; ../2configs/mail-client.nix ../2configs/xserver ../2configs/z.nix + ../2configs/sub/xr.nix { environment.systemPackages = with pkgs; [ @@ -239,14 +240,6 @@ with lib; ]; }; - xr = { - uid = 13370061; - extraGroups = [ - "audio" - "video" - ]; - }; - "23" = { uid = 13370023; }; diff --git a/tv/2configs/sub/xr.nix b/tv/2configs/sub/xr.nix new file mode 100644 index 000000000..6c9cbb93e --- /dev/null +++ b/tv/2configs/sub/xr.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + krebs.per-user.xr.packages = [ + pkgs.cr + ]; + + security.sudo.extraConfig = "tv ALL=(xr) NOPASSWD: ALL"; + + users.users.xr = { + extraGroups = [ + "audio" + "video" + ]; + group = "subusers"; + home = "/home/xr"; + uid = 1660006127; # genid xr + useDefaultShell = true; + }; +} diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 7a48db6b8..afc2d699c 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -40,6 +40,7 @@ let pkgs.pavucontrol pkgs.slock pkgs.sxiv + pkgs.xsel pkgs.zathura ]; diff --git a/tv/2configs/z.nix b/tv/2configs/z.nix index e5494ecc9..3acd168d4 100644 --- a/tv/2configs/z.nix +++ b/tv/2configs/z.nix @@ -4,16 +4,7 @@ with lib; { krebs.per-user.z.packages = [ - (pkgs.writeScriptBin "cr" '' - #! /bin/sh - set -efu - export LC_TIME=de_DE.utf8 - exec ${pkgs.chromium}/bin/chromium \ - --ssl-version-min=tls1 \ - --disk-cache-dir=/tmp/chromium-disk-cache_"$LOGNAME" \ - --disk-cache-size=50000000 \ - "%@" - '') + pkgs.cr ]; programs.bash.interactiveShellInit = '' diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix index 1ca5e70a2..2108d972c 100644 --- a/tv/5pkgs/default.nix +++ b/tv/5pkgs/default.nix @@ -1,6 +1,16 @@ { pkgs, ... }: { + cr = pkgs.writeScriptBin "cr" '' + #! /bin/sh + set -efu + export LC_TIME=de_DE.utf8 + exec ${pkgs.chromium}/bin/chromium \ + --ssl-version-min=tls1 \ + --disk-cache-dir=/tmp/chromium-disk-cache_"$LOGNAME" \ + --disk-cache-size=50000000 \ + "%@" + ''; ff = pkgs.callPackage ./ff {}; viljetic-pages = pkgs.callPackage ./viljetic-pages {}; xmonad-tv = -- cgit v1.2.3 From b166b6c29d2cfd39348073b9873da13a1581ad61 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2015 19:27:47 +0100 Subject: xu: add unison --- tv/1systems/xu.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix index 57f318ad0..168eafcc7 100644 --- a/tv/1systems/xu.nix +++ b/tv/1systems/xu.nix @@ -122,6 +122,8 @@ with lib; #xkill #xl2tpd #xsel + + unison ]; } { -- cgit v1.2.3 From 60faa6e3cf3b592a4aad71b246fbe2abdd699b9c Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2015 11:53:29 +0100 Subject: tv: remove legacy users --- tv/1systems/cd.nix | 14 ------ tv/1systems/wu.nix | 110 ---------------------------------------------- tv/1systems/xu.nix | 113 ------------------------------------------------ tv/2configs/default.nix | 43 ++++-------------- tv/2configs/sub/xr.nix | 22 ---------- tv/2configs/z.nix | 31 ------------- 6 files changed, 9 insertions(+), 324 deletions(-) delete mode 100644 tv/2configs/sub/xr.nix delete mode 100644 tv/2configs/z.nix diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix index 126c6feb5..10c87b2c6 100644 --- a/tv/1systems/cd.nix +++ b/tv/1systems/cd.nix @@ -115,7 +115,6 @@ with lib; iftop iotop iptables - mutt # for mv nethogs ntp # ntpate rxvt_unicode.terminfo @@ -126,17 +125,4 @@ with lib; SystemMaxUse=1G RuntimeMaxUse=128M ''; - - users.extraUsers = { - mv = { - uid = 1338; - group = "users"; - home = "/home/mv"; - createHome = true; - useDefaultShell = true; - openssh.authorizedKeys.keys = [ - config.krebs.users.mv.pubkey - ]; - }; - }; } diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 2c0098c1c..3fa5481e2 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -11,8 +11,6 @@ with lib; ../2configs/git.nix ../2configs/mail-client.nix ../2configs/xserver - ../2configs/z.nix - ../2configs/sub/xr.nix { environment.systemPackages = with pkgs; [ @@ -158,114 +156,6 @@ with lib; ]; }; } - { - users.extraGroups = { - tv.gid = 1337; - slaves.gid = 3799582008; # genid slaves - }; - - users.extraUsers = - mapAttrs (name: user@{ extraGroups ? [], ... }: user // { - inherit name; - home = "/home/${name}"; - createHome = true; - useDefaultShell = true; - group = "tv"; - extraGroups = ["slaves"] ++ extraGroups; - }) { - ff = { - uid = 13378001; - extraGroups = [ - "audio" - "video" - ]; - }; - - cr = { - uid = 13378002; - extraGroups = [ - "audio" - "video" - ]; - }; - - fa = { - uid = 2300001; - }; - - rl = { - uid = 2300002; - }; - - tief = { - uid = 2300702; - }; - - btc-bitcoind = { - uid = 2301001; - }; - - btc-electrum = { - uid = 2301002; - }; - - ltc-litecoind = { - uid = 2301101; - }; - - eth = { - uid = 2302001; - }; - - emse-hsdb = { - uid = 4200101; - }; - - wine = { - uid = 13370400; - extraGroups = [ - "audio" - "video" - ]; - }; - - df = { - uid = 13370401; - extraGroups = [ - "audio" - "video" - ]; - }; - - "23" = { - uid = 13370023; - }; - - electrum = { - uid = 13370102; - }; - - skype = { - uid = 6660001; - extraGroups = [ - "audio" - ]; - }; - - onion = { - uid = 6660010; - }; - }; - - security.sudo.extraConfig = - let - isSlave = u: elem "slaves" u.extraGroups; - masterOf = u: u.group; - slaves = filterAttrs (_: isSlave) config.users.extraUsers; - toSudoers = u: "${masterOf u} ALL=(${u.name}) NOPASSWD: ALL"; - in - concatMapStringsSep "\n" toSudoers (attrValues slaves); - } ]; boot.initrd.luks = { diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix index 168eafcc7..1a9dddb55 100644 --- a/tv/1systems/xu.nix +++ b/tv/1systems/xu.nix @@ -14,8 +14,6 @@ with lib; ../2configs/git.nix ../2configs/mail-client.nix ../2configs/xserver - ../2configs/z.nix - ../2configs/sub/xr.nix { environment.systemPackages = with pkgs; [ @@ -160,117 +158,6 @@ with lib; ]; }; } - { - users.extraGroups = { - tv.gid = 1337; - slaves.gid = 3799582008; # genid slaves - }; - - users.extraUsers = - mapAttrs (name: user@{ extraGroups ? [], ... }: user // { - inherit name; - home = "/home/${name}"; - createHome = true; - useDefaultShell = true; - group = "tv"; - extraGroups = ["slaves"] ++ extraGroups; - }) { - ff = { - uid = 13378001; - extraGroups = [ - "audio" - "video" - ]; - }; - - cr = { - uid = 13378002; - extraGroups = [ - "audio" - "video" - "bumblebee" - ]; - }; - - fa = { - uid = 2300001; - }; - - rl = { - uid = 2300002; - }; - - tief = { - uid = 2300702; - }; - - btc-bitcoind = { - uid = 2301001; - }; - - btc-electrum = { - uid = 2301002; - }; - - ltc-litecoind = { - uid = 2301101; - }; - - eth = { - uid = 2302001; - }; - - emse-hsdb = { - uid = 4200101; - }; - - wine = { - uid = 13370400; - extraGroups = [ - "audio" - "video" - "bumblebee" - ]; - }; - - df = { - uid = 13370401; - extraGroups = [ - "audio" - "video" - "bumblebee" - ]; - }; - - "23" = { - uid = 13370023; - }; - - electrum = { - uid = 13370102; - }; - - skype = { - uid = 6660001; - extraGroups = [ - "audio" - ]; - }; - - onion = { - uid = 6660010; - }; - }; - - security.sudo.extraConfig = - let - isSlave = u: elem "slaves" u.extraGroups; - masterOf = u: u.group; - slaves = filterAttrs (_: isSlave) config.users.extraUsers; - toSudoers = u: "${masterOf u} ALL=(${u.name}) NOPASSWD: ALL"; - in - concatMapStringsSep "\n" toSudoers (attrValues slaves); - } ]; boot.initrd.luks = { diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index d31862b60..688f8f9cf 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -27,6 +27,7 @@ with lib; networking.hostName = config.krebs.build.host.name; imports = [ + ./vim.nix { # stockholm dependencies @@ -35,40 +36,14 @@ with lib; ]; } { - # TODO never put hashedPassword into the store - users.extraUsers = - mapAttrs (_: h: { hashedPassword = h; }) - (import ); - } - { - users.groups.subusers.gid = 1093178926; # genid subusers - } - { - users.defaultUserShell = "/run/current-system/sw/bin/bash"; - users.mutableUsers = false; - } - { - users.extraUsers = { - root = { - openssh.authorizedKeys.keys = [ - config.krebs.users.tv.pubkey - config.krebs.users.tv_xu.pubkey - ]; - }; - tv = { - uid = 1337; - group = "users"; - home = "/home/tv"; - createHome = true; - useDefaultShell = true; - extraGroups = [ - "audio" - "video" - "wheel" - ]; - openssh.authorizedKeys.keys = [ - config.krebs.users.tv.pubkey - ]; + users = { + defaultUserShell = "/run/current-system/sw/bin/bash"; + mutableUsers = false; + users = { + tv = { + isNormalUser = true; + uid = 1337; + }; }; }; } diff --git a/tv/2configs/sub/xr.nix b/tv/2configs/sub/xr.nix deleted file mode 100644 index 6c9cbb93e..000000000 --- a/tv/2configs/sub/xr.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -{ - krebs.per-user.xr.packages = [ - pkgs.cr - ]; - - security.sudo.extraConfig = "tv ALL=(xr) NOPASSWD: ALL"; - - users.users.xr = { - extraGroups = [ - "audio" - "video" - ]; - group = "subusers"; - home = "/home/xr"; - uid = 1660006127; # genid xr - useDefaultShell = true; - }; -} diff --git a/tv/2configs/z.nix b/tv/2configs/z.nix deleted file mode 100644 index 3acd168d4..000000000 --- a/tv/2configs/z.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -{ - krebs.per-user.z.packages = [ - pkgs.cr - ]; - - programs.bash.interactiveShellInit = '' - case ''${XMONAD_SPAWN_WORKSPACE-} in - za|zh|zj|zs) - exec sudo -u z -i - ;; - esac - ''; - - security.sudo.extraConfig = "tv ALL=(z) NOPASSWD: ALL"; - - users.users.z = { - extraGroups = [ - "audio" - "vboxusers" - "video" - ]; - group = "subusers"; - home = "/home/z"; - uid = 3043726074; # genid z - useDefaultShell = true; - }; -} -- cgit v1.2.3 From 0faad027e7e241edbe842cf6a54aad606d00adf7 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2015 12:28:53 +0100 Subject: tv configs: set NIX_PATH --- tv/2configs/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 688f8f9cf..6ed1c65f9 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -90,6 +90,15 @@ with lib; view = "vim -R"; }; + environment.variables = { + NIX_PATH = + with config.krebs.build.source; with dir; with git; + mkForce (concatStringsSep ":" [ + "nixpkgs=${nixpkgs.target-path}" + "secrets=${stockholm.target-path}/null" + ]); + }; + programs.bash = { interactiveShellInit = '' HISTCONTROL='erasedups:ignorespace' -- cgit v1.2.3 From e734aa21ee0a2a015ae3c0c54681cca7891d5e38 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2015 12:40:53 +0100 Subject: add null module --- null/default.nix | 1 + 1 file changed, 1 insertion(+) create mode 100644 null/default.nix diff --git a/null/default.nix b/null/default.nix new file mode 100644 index 000000000..2eb33a153 --- /dev/null +++ b/null/default.nix @@ -0,0 +1 @@ +_:{} -- cgit v1.2.3 From 610a3ce59c2ba0e58205305a85e9cb86e680d481 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2015 12:46:56 +0100 Subject: push: 1.1.0 -> 1.1.1 --- krebs/5pkgs/push/default.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/krebs/5pkgs/push/default.nix b/krebs/5pkgs/push/default.nix index 410b43465..bc5c030a0 100644 --- a/krebs/5pkgs/push/default.nix +++ b/krebs/5pkgs/push/default.nix @@ -9,12 +9,12 @@ , ... }: stdenv.mkDerivation { - name = "push-1.1.0"; + name = "push-1.1.1"; src = fetchgit { url = http://cgit.cd.retiolum/push; - rev = "c5f4bda5bd00bad7778bbd5a9af8d476de0de920"; - sha256 = "d335b644b791214263cee5c6659538c8e45326531b0588e5e7eb3bd9ef969800"; + rev = "ea8b76569c6b226fe148e559477669b095408472"; + sha256 = "c305a1515d30603f6ed825d44487e863fdc7d90400620ceaf2c335a3b5d1e221"; }; phases = [ @@ -45,4 +45,3 @@ stdenv.mkDerivation { chmod +x $out/bin/push ''; } - -- cgit v1.2.3 From fa48986f3f1358fea0af9bbfe908032ae50c0034 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2015 13:42:14 +0100 Subject: cd: use default krebs.build --- tv/1systems/cd.nix | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix index 10c87b2c6..8c2a9ae43 100644 --- a/tv/1systems/cd.nix +++ b/tv/1systems/cd.nix @@ -4,23 +4,8 @@ with lib; { krebs.build.host = config.krebs.hosts.cd; - krebs.build.user = config.krebs.users.tv; - krebs.build.target = "root@cd.internet"; - krebs.build.source = { - git.nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "c44a593aa43bba6a0708f6f36065a514a5110613"; - }; - dir.secrets = { - path = "/home/tv/secrets/cd"; - }; - dir.stockholm = { - path = "/home/tv/stockholm"; - }; - }; - imports = [ ../2configs/hw/CAC-Developer-2.nix ../2configs/fs/CAC-CentOS-7-64bit.nix -- cgit v1.2.3 From b0094ce0e498b9661de62e472121aaaf5b83c40d Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Nov 2015 02:58:21 +0100 Subject: stockholm: check if default.nix exists before importing --- default.nix | 2 +- krebs/4lib/default.nix | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index ac748c286..c001b8c13 100644 --- a/default.nix +++ b/default.nix @@ -32,7 +32,7 @@ let stockholm = { upath = lib.nspath current-user-name; base-module = { config, ... }: { - imports = builtins.filter builtins.pathExists (lib.concatLists [ + imports = builtins.filter lib.dir.has-default-nix (lib.concatLists [ (map (f: f "2configs") [ upath ]) (map (f: f "3modules") [ kpath upath ]) ]); diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix index 396307c22..f907fe871 100644 --- a/krebs/4lib/default.nix +++ b/krebs/4lib/default.nix @@ -14,6 +14,8 @@ rec { types = import ./types.nix { inherit lib; }; + dir.has-default-nix = path: pathExists (path + "/default.nix"); + dns = import ./dns.nix { inherit lib; }; listset = import ./listset.nix { inherit lib; }; shell = import ./shell.nix { inherit lib; }; -- cgit v1.2.3 From 604ce6bd59c74f59ac9f18e3e82fa26e8ace8462 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Nov 2015 17:56:47 +0100 Subject: xmonad-stockholm: init at 1.0.0 --- krebs/5pkgs/haskell-overrides/xmonad-stockholm.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 krebs/5pkgs/haskell-overrides/xmonad-stockholm.nix diff --git a/krebs/5pkgs/haskell-overrides/xmonad-stockholm.nix b/krebs/5pkgs/haskell-overrides/xmonad-stockholm.nix new file mode 100644 index 000000000..5c6f068e7 --- /dev/null +++ b/krebs/5pkgs/haskell-overrides/xmonad-stockholm.nix @@ -0,0 +1,16 @@ +{ mkDerivation, base, containers, fetchgit, stdenv, X11, X11-xshape +, xmonad, xmonad-contrib +}: +mkDerivation { + pname = "xmonad-stockholm"; + version = "1.0.0"; + src = fetchgit { + url = "http://cgit.cd/xmonad-stockholm"; + sha256 = "35dda5d16acc90af94ae2fae10ab5cc2d5b450c3f1ff2e7f515ac53877269abf"; + rev = "2dbefe42fc5cfe9093465bf3e22ba8f82feeef6e"; + }; + libraryHaskellDepends = [ + base containers X11 X11-xshape xmonad xmonad-contrib + ]; + license = stdenv.lib.licenses.mit; +} -- cgit v1.2.3 From 619e0ea9489d4d3e141671f600598468b26b4e72 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Nov 2015 17:58:53 +0100 Subject: xmonad-tv: use xmonad-stockholm --- tv/5pkgs/xmonad-tv/Main.hs | 6 +- tv/5pkgs/xmonad-tv/Util/Font.hs | 123 ------------ tv/5pkgs/xmonad-tv/Util/Pager.hs | 172 ----------------- tv/5pkgs/xmonad-tv/Util/Rhombus.hs | 369 ------------------------------------ tv/5pkgs/xmonad-tv/Util/Shutdown.hs | 53 ------ tv/5pkgs/xmonad-tv/Util/Submap.hs | 31 --- tv/5pkgs/xmonad-tv/Util/XUtils.hs | 47 ----- tv/5pkgs/xmonad-tv/xmonad.cabal | 6 +- 8 files changed, 5 insertions(+), 802 deletions(-) delete mode 100644 tv/5pkgs/xmonad-tv/Util/Font.hs delete mode 100644 tv/5pkgs/xmonad-tv/Util/Pager.hs delete mode 100644 tv/5pkgs/xmonad-tv/Util/Rhombus.hs delete mode 100644 tv/5pkgs/xmonad-tv/Util/Shutdown.hs delete mode 100644 tv/5pkgs/xmonad-tv/Util/Submap.hs delete mode 100644 tv/5pkgs/xmonad-tv/Util/XUtils.hs diff --git a/tv/5pkgs/xmonad-tv/Main.hs b/tv/5pkgs/xmonad-tv/Main.hs index 2cc48efa3..2258b34a6 100644 --- a/tv/5pkgs/xmonad-tv/Main.hs +++ b/tv/5pkgs/xmonad-tv/Main.hs @@ -35,9 +35,9 @@ import XMonad.Layout.PerWorkspace (onWorkspace) --import XMonad.Layout.BinarySpacePartition --import XMonad.Actions.Submap -import Util.Pager -import Util.Rhombus -import Util.Shutdown +import XMonad.Stockholm.Pager +import XMonad.Stockholm.Rhombus +import XMonad.Stockholm.Shutdown myTerm :: String diff --git a/tv/5pkgs/xmonad-tv/Util/Font.hs b/tv/5pkgs/xmonad-tv/Util/Font.hs deleted file mode 100644 index 5352cf5ad..000000000 --- a/tv/5pkgs/xmonad-tv/Util/Font.hs +++ /dev/null @@ -1,123 +0,0 @@ -{-# 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/5pkgs/xmonad-tv/Util/Pager.hs b/tv/5pkgs/xmonad-tv/Util/Pager.hs deleted file mode 100644 index b8168b5b0..000000000 --- a/tv/5pkgs/xmonad-tv/Util/Pager.hs +++ /dev/null @@ -1,172 +0,0 @@ -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/5pkgs/xmonad-tv/Util/Rhombus.hs b/tv/5pkgs/xmonad-tv/Util/Rhombus.hs deleted file mode 100644 index 9d46e4127..000000000 --- a/tv/5pkgs/xmonad-tv/Util/Rhombus.hs +++ /dev/null @@ -1,369 +0,0 @@ -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.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/5pkgs/xmonad-tv/Util/Shutdown.hs b/tv/5pkgs/xmonad-tv/Util/Shutdown.hs deleted file mode 100644 index 89e22b4e7..000000000 --- a/tv/5pkgs/xmonad-tv/Util/Shutdown.hs +++ /dev/null @@ -1,53 +0,0 @@ -{-# 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 (unlines s) - exitSuccess - return () diff --git a/tv/5pkgs/xmonad-tv/Util/Submap.hs b/tv/5pkgs/xmonad-tv/Util/Submap.hs deleted file mode 100644 index b09