From e5ac86ee44c4e7a5784cef1569873d246352e4fe Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2015 11:27:02 +0100 Subject: tv xmonad: provide XMONAD_SPAWN_WORKSPACE --- tv/2configs/xserver/xmonad/Main.hs | 10 +++++++--- tv/2configs/xserver/xmonad/xmonad.cabal | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index 186a5e22c..cc958155e 100644 --- a/tv/2configs/xserver/xmonad/Main.hs +++ b/tv/2configs/xserver/xmonad/Main.hs @@ -8,7 +8,8 @@ module Main where import Control.Exception import Text.Read (readEither) import XMonad -import System.Environment (getArgs, getEnv) +import System.Environment (getArgs, getEnv, getEnvironment) +import System.Posix.Process (executeFile) import XMonad.Prompt (defaultXPConfig) import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace , removeEmptyWorkspace) @@ -100,8 +101,11 @@ displaySomeException = displayException spawnTermAt :: String -> X () --spawnTermAt _ = floatNext True >> spawn myTerm --spawnTermAt "ff" = floatNext True >> spawn myTerm -spawnTermAt _ = spawn myTerm - +--spawnTermAt _ = spawn myTerm +spawnTermAt ws = do + env <- liftIO getEnvironment + let env' = ("XMONAD_SPAWN_WORKSPACE", ws) : env + xfork (executeFile "urxvtc" True [] (Just env')) >> return () myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) myKeys conf = Map.fromList $ diff --git a/tv/2configs/xserver/xmonad/xmonad.cabal b/tv/2configs/xserver/xmonad/xmonad.cabal index 00acf1704..cc72d3953 100644 --- a/tv/2configs/xserver/xmonad/xmonad.cabal +++ b/tv/2configs/xserver/xmonad/xmonad.cabal @@ -10,6 +10,7 @@ Executable xmonad base, containers, filepath, + unix, X11, X11-xshape, xmonad, -- cgit v1.2.3 From 4e7a5a107f18037d126120fe0f59c6b80658bd46 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2015 11:27:24 +0100 Subject: tv xmonad.workspaces0 += zh --- 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 c5cffbb30..26575106e 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -89,7 +89,7 @@ let "im" "mail" "stockholm" - "za" "zj" "zs" + "za" "zh" "zj" "zs" ]); }; -- cgit v1.2.3 From 877f2b6c6bc8c7721588638836fb1288cc3f7f80 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2015 11:31:40 +0100 Subject: tv xserver bash: sudo per XMONAD_SPAWN_WORKSPACE --- tv/2configs/xserver/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 26575106e..3ea5cec9e 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -70,6 +70,14 @@ let ExecStart = "${xserver}/bin/xserver"; }; }; + + programs.bash.interactiveShellInit = '' + case ''${XMONAD_SPAWN_WORKSPACE-} in + za|zh|zj|zs) + exec sudo -u zalora -i + ;; + esac + ''; }; xmonad-pkg = pkgs.haskellPackages.callPackage xmonad-src {}; -- cgit v1.2.3 From b7d9c3476bd015ddb1a1d6cd66ebdd1b96003b2a Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Oct 2015 16:12:54 +0100 Subject: tv xmonad: make [ghci] --- tv/2configs/xserver/xmonad/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tv/2configs/xserver/xmonad/Makefile diff --git a/tv/2configs/xserver/xmonad/Makefile b/tv/2configs/xserver/xmonad/Makefile new file mode 100644 index 000000000..cbb0776e6 --- /dev/null +++ b/tv/2configs/xserver/xmonad/Makefile @@ -0,0 +1,6 @@ +.PHONY: ghci +ghci: shell.nix + nix-shell --command 'exec ghci -Wall' + +shell.nix: xmonad.cabal + cabal2nix --shell . > $@ -- cgit v1.2.3 From 737922a20e1b15ef5a8d11956c9395f7fede735c Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Oct 2015 20:18:31 +0100 Subject: tv xmonad: s/concatMap (++"\n")/unlines/ --- tv/2configs/xserver/xmonad/Util/Shutdown.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/2configs/xserver/xmonad/Util/Shutdown.hs b/tv/2configs/xserver/xmonad/Util/Shutdown.hs index c5a3edb80..89e22b4e7 100644 --- a/tv/2configs/xserver/xmonad/Util/Shutdown.hs +++ b/tv/2configs/xserver/xmonad/Util/Shutdown.hs @@ -48,6 +48,6 @@ shutdown = do s <- gets (\s -> (wsData s : extState s)) _ <- io $ do path <- getEnv "XMONAD_STATE" - writeFile path (concatMap (++"\n") s) + writeFile path (unlines s) exitSuccess return () -- cgit v1.2.3 From 057c4836c10eebf3141d7b20a9e942518357606c Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Oct 2015 21:00:29 +0100 Subject: tv xmonad: resume by reading state from file --- tv/2configs/xserver/default.nix | 7 +------ tv/2configs/xserver/xmonad/Main.hs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 3ea5cec9e..388a33bbe 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -119,12 +119,7 @@ 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' - if test -e "$XMONAD_STATE"; then - IFS=''$'\n' - exec ${xmonad-pkg}/bin/xmonad --resume $(< "$XMONAD_STATE") - else - exec ${xmonad-pkg}/bin/xmonad - fi + exec ${xmonad-pkg}/bin/xmonad ''; xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index cc958155e..fe7304904 100644 --- a/tv/2configs/xserver/xmonad/Main.hs +++ b/tv/2configs/xserver/xmonad/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE DeriveDataTypeable #-} -- for XS +{-# LANGUAGE FlexibleContexts #-} -- for xmonad' {-# LANGUAGE LambdaCase #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -8,7 +9,7 @@ module Main where import Control.Exception import Text.Read (readEither) import XMonad -import System.Environment (getArgs, getEnv, getEnvironment) +import System.Environment (getArgs, withArgs, getEnv, getEnvironment) import System.Posix.Process (executeFile) import XMonad.Prompt (defaultXPConfig) import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace @@ -56,7 +57,7 @@ main = getArgs >>= \case mainNoArgs :: IO () mainNoArgs = do workspaces0 <- getWorkspaces0 - xmonad + xmonad' -- $ withUrgencyHookC dzenUrgencyHook { args = ["-bg", "magenta", "-fg", "magenta", "-h", "2"], duration = 500000 } -- urgencyConfig { remindWhen = Every 1 } -- $ withUrgencyHook borderUrgencyHook "magenta" @@ -82,6 +83,17 @@ mainNoArgs = do (FixedColumn 1 20 80 10 ||| Full) +xmonad' :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO () +xmonad' conf = do + path <- getEnv "XMONAD_STATE" + try (readFile path) >>= \case + Right content -> do + putStrLn ("resuming from " ++ path) + withArgs ("--resume" : lines content) (xmonad conf) + Left e -> do + putStrLn (displaySomeException e) + xmonad conf + getWorkspaces0 :: IO [String] getWorkspaces0 = try (getEnv "XMONAD_WORKSPACES0_FILE") >>= \case -- cgit v1.2.3 From 00d03622d187397fd0cb46c17fe1f6750883d774 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Oct 2015 21:21:27 +0100 Subject: tv xmonad: print stuff to stderr everywhere --- tv/2configs/xserver/xmonad/Main.hs | 10 +++++----- tv/2configs/xserver/xmonad/Util/Debunk.hs | 16 ---------------- tv/2configs/xserver/xmonad/Util/Rhombus.hs | 1 - 3 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 tv/2configs/xserver/xmonad/Util/Debunk.hs diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index fe7304904..2cc48efa3 100644 --- a/tv/2configs/xserver/xmonad/Main.hs +++ b/tv/2configs/xserver/xmonad/Main.hs @@ -9,6 +9,7 @@ module Main where import Control.Exception import Text.Read (readEither) import XMonad +import System.IO (hPutStrLn, stderr) import System.Environment (getArgs, withArgs, getEnv, getEnvironment) import System.Posix.Process (executeFile) import XMonad.Prompt (defaultXPConfig) @@ -36,7 +37,6 @@ import XMonad.Layout.PerWorkspace (onWorkspace) --import XMonad.Actions.Submap import Util.Pager import Util.Rhombus -import Util.Debunk import Util.Shutdown @@ -88,10 +88,10 @@ xmonad' conf = do path <- getEnv "XMONAD_STATE" try (readFile path) >>= \case Right content -> do - putStrLn ("resuming from " ++ path) + hPutStrLn stderr ("resuming from " ++ path) withArgs ("--resume" : lines content) (xmonad conf) Left e -> do - putStrLn (displaySomeException e) + hPutStrLn stderr (displaySomeException e) xmonad conf getWorkspaces0 :: IO [String] @@ -104,7 +104,7 @@ getWorkspaces0 = Left e -> warn e Right y -> return y where - warn msg = putStrLn ("getWorkspaces0: " ++ msg) >> return [] + warn msg = hPutStrLn stderr ("getWorkspaces0: " ++ msg) >> return [] displaySomeException :: SomeException -> String displaySomeException = displayException @@ -135,7 +135,7 @@ myKeys conf = Map.fromList $ , ((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"] ) + , ((_4 , xK_Menu ), rhombus horseConfig (liftIO . hPutStrLn stderr) ["Correct", "Horse", "Battery", "Staple", "Stuhl", "Tisch"] ) -- %! Rotate through the available layout algorithms , ((_4 , xK_space ), sendMessage NextLayout) diff --git a/tv/2configs/xserver/xmonad/Util/Debunk.hs b/tv/2configs/xserver/xmonad/Util/Debunk.hs deleted file mode 100644 index b4772e582..000000000 --- a/tv/2configs/xserver/xmonad/Util/Debunk.hs +++ /dev/null @@ -1,16 +0,0 @@ -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/Util/Rhombus.hs b/tv/2configs/xserver/xmonad/Util/Rhombus.hs index 5f43cb28a..9d46e4127 100644 --- a/tv/2configs/xserver/xmonad/Util/Rhombus.hs +++ b/tv/2configs/xserver/xmonad/Util/Rhombus.hs @@ -18,7 +18,6 @@ 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 -- cgit v1.2.3 From 31074d797c62f64009375e60b15d4b55a8937cab Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 29 Oct 2015 01:09:54 +0100 Subject: tv config: split stuff into fs and hw --- tv/1systems/cd.nix | 4 +-- tv/1systems/mkdir.nix | 4 +-- tv/1systems/nomic.nix | 9 +------ tv/1systems/rmdir.nix | 4 +-- tv/1systems/wu.nix | 4 +-- tv/2configs/AO753.nix | 39 ----------------------------- tv/2configs/CAC-CentOS-7-64bit.nix | 47 ----------------------------------- tv/2configs/CAC-Developer-1.nix | 6 ----- tv/2configs/CAC-Developer-2.nix | 6 ----- tv/2configs/cryptoroot.nix | 4 --- tv/2configs/fs/CAC-CentOS-7-64bit.nix | 20 +++++++++++++++ tv/2configs/hw/AO753.nix | 46 ++++++++++++++++++++++++++++++++++ tv/2configs/hw/CAC-Developer-1.nix | 8 ++++++ tv/2configs/hw/CAC-Developer-2.nix | 8 ++++++ tv/2configs/hw/CAC.nix | 13 ++++++++++ tv/2configs/hw/w110er.nix | 46 ++++++++++++++++++++++++++++++++++ tv/2configs/w110er.nix | 42 ------------------------------- 17 files changed, 149 insertions(+), 161 deletions(-) delete mode 100644 tv/2configs/AO753.nix delete mode 100644 tv/2configs/CAC-CentOS-7-64bit.nix delete mode 100644 tv/2configs/CAC-Developer-1.nix delete mode 100644 tv/2configs/CAC-Developer-2.nix delete mode 100644 tv/2configs/cryptoroot.nix create mode 100644 tv/2configs/fs/CAC-CentOS-7-64bit.nix create mode 100644 tv/2configs/hw/AO753.nix create mode 100644 tv/2configs/hw/CAC-Developer-1.nix create mode 100644 tv/2configs/hw/CAC-Developer-2.nix create mode 100644 tv/2configs/hw/CAC.nix create mode 100644 tv/2configs/hw/w110er.nix delete mode 100644 tv/2configs/w110er.nix diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix index d2b08bef7..69f1300be 100644 --- a/tv/1systems/cd.nix +++ b/tv/1systems/cd.nix @@ -24,8 +24,8 @@ with lib; }; imports = [ - ../2configs/CAC-Developer-2.nix - ../2configs/CAC-CentOS-7-64bit.nix + ../2configs/hw/CAC-Developer-2.nix + ../2configs/fs/CAC-CentOS-7-64bit.nix ../2configs/base.nix #../2configs/consul-server.nix ../2configs/exim-smarthost.nix diff --git a/tv/1systems/mkdir.nix b/tv/1systems/mkdir.nix index f0c7dc2a0..305ea7269 100644 --- a/tv/1systems/mkdir.nix +++ b/tv/1systems/mkdir.nix @@ -37,8 +37,8 @@ in }; imports = [ - ../2configs/CAC-Developer-1.nix - ../2configs/CAC-CentOS-7-64bit.nix + ../2configs/hw/CAC-Developer-1.nix + ../2configs/fs/CAC-CentOS-7-64bit.nix ../2configs/base.nix ../2configs/consul-server.nix ../2configs/exim-smarthost.nix diff --git a/tv/1systems/nomic.nix b/tv/1systems/nomic.nix index 210846215..61f833d41 100644 --- a/tv/1systems/nomic.nix +++ b/tv/1systems/nomic.nix @@ -24,7 +24,7 @@ with lib; }; imports = [ - ../2configs/AO753.nix + ../2configs/hw/AO753.nix ../2configs/base.nix #../2configs/consul-server.nix ../2configs/git.nix @@ -87,13 +87,6 @@ with lib; swapDevices = [ ]; - nix = { - buildCores = 2; - maxJobs = 2; - daemonIONiceLevel = 1; - daemonNiceLevel = 1; - }; - # TODO base boot.tmpOnTmpfs = true; diff --git a/tv/1systems/rmdir.nix b/tv/1systems/rmdir.nix index c52222cd1..f77268b53 100644 --- a/tv/1systems/rmdir.nix +++ b/tv/1systems/rmdir.nix @@ -37,8 +37,8 @@ in }; imports = [ - ../2configs/CAC-Developer-1.nix - ../2configs/CAC-CentOS-7-64bit.nix + ../2configs/hw/CAC-Developer-1.nix + ../2configs/fs/CAC-CentOS-7-64bit.nix ../2configs/base.nix ../2configs/consul-server.nix ../2configs/exim-smarthost.nix diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 586ad1725..65389b662 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -24,7 +24,7 @@ with lib; }; imports = [ - ../2configs/w110er.nix + ../2configs/hw/w110er.nix ../2configs/base.nix #../2configs/consul-client.nix ../2configs/git.nix @@ -389,6 +389,4 @@ with lib; services.tor.enable = true; services.virtualboxHost.enable = true; - # TODO w110er if xserver is enabled - services.xserver.vaapiDrivers = [ pkgs.vaapiIntel ]; } diff --git a/tv/2configs/AO753.nix b/tv/2configs/AO753.nix deleted file mode 100644 index 96167ce01..000000000 --- a/tv/2configs/AO753.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ../2configs/smartd.nix - ]; - - boot.loader.grub = { - device = "/dev/sda"; - splashImage = null; - }; - - boot.initrd.availableKernelModules = [ - "ahci" - ]; - - boot.kernelModules = [ - "kvm-intel" - "wl" - ]; - - boot.extraModulePackages = [ - config.boot.kernelPackages.broadcom_sta - ]; - - networking.wireless.enable = true; - - services.logind.extraConfig = '' - HandleHibernateKey=ignore - HandleLidSwitch=ignore - HandlePowerKey=ignore - HandleSuspendKey=ignore - ''; - - nixpkgs.config = { - allowUnfree = false; - allowUnfreePredicate = (x: pkgs.lib.hasPrefix "broadcom-sta-" x.name); - }; -} diff --git a/tv/2configs/CAC-CentOS-7-64bit.nix b/tv/2configs/CAC-CentOS-7-64bit.nix deleted file mode 100644 index 168d1d97b..000000000 --- a/tv/2configs/CAC-CentOS-7-64bit.nix +++ /dev/null @@ -1,47 +0,0 @@ -_: - -{ - boot.loader.grub = { - device = "/dev/sda"; - splashImage = null; - }; - - boot.initrd.availableKernelModules = [ - "ata_piix" - "vmw_pvscsi" - ]; - - fileSystems."/" = { - device = "/dev/centos/root"; - fsType = "xfs"; - }; - - fileSystems."/boot" = { - device = "/dev/sda1"; - fsType = "xfs"; - }; - - swapDevices = [ - { device = "/dev/centos/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; - }; -} diff --git a/tv/2configs/CAC-Developer-1.nix b/tv/2configs/CAC-Developer-1.nix deleted file mode 100644 index 37bc32afb..000000000 --- a/tv/2configs/CAC-Developer-1.nix +++ /dev/null @@ -1,6 +0,0 @@ -_: - -{ - nix.maxJobs = 1; - sound.enable = false; -} diff --git a/tv/2configs/CAC-Developer-2.nix b/tv/2configs/CAC-Developer-2.nix deleted file mode 100644 index fedb808df..000000000 --- a/tv/2configs/CAC-Developer-2.nix +++ /dev/null @@ -1,6 +0,0 @@ -_: - -{ - nix.maxJobs = 2; - sound.enable = false; -} diff --git a/tv/2configs/cryptoroot.nix b/tv/2configs/cryptoroot.nix deleted file mode 100644 index 04618ac4a..000000000 --- a/tv/2configs/cryptoroot.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ ... }: - -{ -} diff --git a/tv/2configs/fs/CAC-CentOS-7-64bit.nix b/tv/2configs/fs/CAC-CentOS-7-64bit.nix new file mode 100644 index 000000000..c9eb97f44 --- /dev/null +++ b/tv/2configs/fs/CAC-CentOS-7-64bit.nix @@ -0,0 +1,20 @@ +_: + +{ + boot.loader.grub = { + device = "/dev/sda"; + }; + fileSystems = { + "/" = { + device = "/dev/centos/root"; + fsType = "xfs"; + }; + "/boot" = { + device = "/dev/sda1"; + fsType = "xfs"; + }; + }; + swapDevices = [ + { device = "/dev/centos/swap"; } + ]; +} diff --git a/tv/2configs/hw/AO753.nix b/tv/2configs/hw/AO753.nix new file mode 100644 index 000000000..acd9ee32b --- /dev/null +++ b/tv/2configs/hw/AO753.nix @@ -0,0 +1,46 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../smartd.nix + ]; + + boot.loader.grub = { + device = "/dev/sda"; + splashImage = null; + }; + + boot.initrd.availableKernelModules = [ + "ahci" + ]; + + boot.kernelModules = [ + "kvm-intel" + "wl" + ]; + + boot.extraModulePackages = [ + config.boot.kernelPackages.broadcom_sta + ]; + + networking.wireless.enable = true; + + nix = { + buildCores = 2; + maxJobs = 2; + daemonIONiceLevel = 1; + daemonNiceLevel = 1; + }; + + services.logind.extraConfig = '' + HandleHibernateKey=ignore + HandleLidSwitch=ignore + HandlePowerKey=ignore + HandleSuspendKey=ignore + ''; + + nixpkgs.config = { + allowUnfree = false; + allowUnfreePredicate = (x: pkgs.lib.hasPrefix "broadcom-sta-" x.name); + }; +} diff --git a/tv/2configs/hw/CAC-Developer-1.nix b/tv/2configs/hw/CAC-Developer-1.nix new file mode 100644 index 000000000..5143c8359 --- /dev/null +++ b/tv/2configs/hw/CAC-Developer-1.nix @@ -0,0 +1,8 @@ +_: +{ + imports = [ ./CAC.nix ]; + nix = { + buildCores = 1; + maxJobs = 1; + }; +} diff --git a/tv/2configs/hw/CAC-Developer-2.nix b/tv/2configs/hw/CAC-Developer-2.nix new file mode 100644 index 000000000..1b3b102cc --- /dev/null +++ b/tv/2configs/hw/CAC-Developer-2.nix @@ -0,0 +1,8 @@ +_: +{ + imports = [ ./CAC.nix ]; + nix = { + buildCores = 2; + maxJobs = 2; + }; +} diff --git a/tv/2configs/hw/CAC.nix b/tv/2configs/hw/CAC.nix new file mode 100644 index 000000000..9ed18344a --- /dev/null +++ b/tv/2configs/hw/CAC.nix @@ -0,0 +1,13 @@ +_: +{ + boot.initrd.availableKernelModules = [ + "ata_piix" + "vmw_pvscsi" + ]; + boot.loader.grub.splashImage = null; + nix = { + daemonIONiceLevel = 1; + daemonNiceLevel = 1; + }; + sound.enable = false; +} diff --git a/tv/2configs/hw/w110er.nix b/tv/2configs/hw/w110er.nix new file mode 100644 index 000000000..aa8292441 --- /dev/null +++ b/tv/2configs/hw/w110er.nix @@ -0,0 +1,46 @@ +{ pkgs, ... }: + +{ + imports = [ + ../smartd.nix + ]; + + boot.extraModprobeConfig = '' + options kvm_intel nested=1 + ''; + + boot.initrd.availableKernelModules = [ "ahci" ]; + boot.kernelModules = [ "kvm-intel" ]; + + boot.loader.gummiboot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.wireless.enable = true; + + nix = { + buildCores = 4; + maxJobs = 4; + daemonIONiceLevel = 1; + daemonNiceLevel = 1; + }; + + services.logind.extraConfig = '' + HandleHibernateKey=ignore + HandleLidSwitch=ignore + HandlePowerKey=ignore + HandleSuspendKey=ignore + ''; + + services.xserver = { + vaapiDrivers = [ pkgs.vaapiIntel ]; + }; + + system.activationScripts.powertopTunables = '' + echo 1 > /sys/module/snd_hda_intel/parameters/power_save + echo 1500 > /proc/sys/vm/dirty_writeback_centisecs + (cd /sys/bus/pci/devices + for i in *; do + echo auto > $i/power/control # defaults to 'on' + done) + ''; +} diff --git a/tv/2configs/w110er.nix b/tv/2configs/w110er.nix deleted file mode 100644 index e580b2161..000000000 --- a/tv/2configs/w110er.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ pkgs, ... }: - -{ - imports = [ - ../2configs/smartd.nix - ]; - - boot.extraModprobeConfig = '' - options kvm_intel nested=1 - ''; - - boot.initrd.availableKernelModules = [ "ahci" ]; - boot.kernelModules = [ "kvm-intel" ]; - - boot.loader.gummiboot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.wireless.enable = true; - - nix = { - buildCores = 4; - maxJobs = 4; - daemonIONiceLevel = 1; - daemonNiceLevel = 1; - }; - - services.logind.extraConfig = '' - HandleHibernateKey=ignore - HandleLidSwitch=ignore - HandlePowerKey=ignore - HandleSuspendKey=ignore - ''; - - system.activationScripts.powertopTunables = '' - echo 1 > /sys/module/snd_hda_intel/parameters/power_save - echo 1500 > /proc/sys/vm/dirty_writeback_centisecs - (cd /sys/bus/pci/devices - for i in *; do - echo auto > $i/power/control # defaults to 'on' - done) - ''; -} -- cgit v1.2.3 From 43d3116dc08aefd2ce008b9905811b8d92d88fac Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 29 Oct 2015 01:11:44 +0100 Subject: tv: init xu/x220 --- tv/1systems/xu.nix | 390 ++++++++++++++++++++++++++++++++++++++++++++++++ tv/2configs/hw/x220.nix | 60 ++++++++ 2 files changed, 450 insertions(+) create mode 100644 tv/1systems/xu.nix create mode 100644 tv/2configs/hw/x220.nix diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix new file mode 100644 index 000000000..82f5abf73 --- /dev/null +++ b/tv/1systems/xu.nix @@ -0,0 +1,390 @@ +{ config, lib, pkgs, ... }: + +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 = "e57024f821c94caf5684964474073649b8b6356b"; + }; + dir.secrets = { + host = config.krebs.hosts.wu; + path = "/home/tv/secrets/xu"; + }; + dir.stockholm = { + host = config.krebs.hosts.wu; + path = "/home/tv/stockholm"; + }; + }; + + imports = [ + ../2configs/hw/x220.nix + ../2configs/base.nix + #../2configs/consul-client.nix + ../2configs/git.nix + ../2configs/mail-client.nix + ../2configs/xserver + { + environment.systemPackages = with pkgs; [ + + # stockholm + genid + gnumake + hashPassword + lentil + parallel + (pkgs.writeScriptBin "im" '' + #! ${pkgs.bash}/bin/bash + export PATH=${makeSearchPath "bin" (with pkgs; [ + tmux + gnugrep + weechat + ])} + if tmux list-sessions -F\#S | grep -q '^im''$'; then + exec tmux attach -t im + else + exec tmux new -s im weechat + fi + '') + + # root + cryptsetup + ntp # ntpate + + # tv + bc + 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 + posix_man_pages + #pssh + qrencode + sxiv #xserver + texLive + tmux + zathura #xserver + + #ack + #apache-httpd + #ascii + #emacs + #es + #esniper + #gcc + #gptfdisk + #graphviz + #haskellPackages.cabal2nix + #haskellPackages.ghc + #haskellPackages.shake + #hdparm + #i7z + #iftop + #imagemagick + #inotifyTools + #iodine + #iotop + #lshw + #lsof + #minicom + #mtools + #ncmpc + #neovim + #nethogs + #nix-prefetch-scripts #cvs bug + #openssl + #openswan + #parted + #perl + #powertop + #ppp + #proot + #pythonPackages.arandr + #pythonPackages.youtube-dl + #racket + #rxvt_unicode-with-plugins + #scrot + #sec + #silver-searcher + #sloccount + #smartmontools + #socat + #sshpass + #strongswan + #sysdig + #sysstat + #tcpdump + #tlsdate + #unetbootin + #utillinuxCurses + #wvdial + #xdotool + #xkill + #xl2tpd + #xsel + ]; + } + { + tv.iptables = { + enable = true; + input-internet-accept-new-tcp = [ + "ssh" + "http" + "tinc" + "smtp" + ]; + }; + } + { + krebs.exim-retiolum.enable = true; + } + { + krebs.nginx = { + enable = true; + servers.default.locations = [ + (nameValuePair "~ ^/~(.+?)(/.*)?\$" '' + alias /home/$1/public_html$2; + '') + ]; + }; + } + { + krebs.retiolum = { + enable = true; + connectTo = [ + "cd" + "gum" + "pigstarter" + ]; + }; + } + { + 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" + ]; + }; + + xr = { + uid = 13370061; + extraGroups = [ + "audio" + "video" + ]; + }; + + "23" = { + uid = 13370023; + }; + + electrum = { + uid = 13370102; + }; + + skype = { + uid = 6660001; + extraGroups = [ + "audio" + ]; + }; + + onion = { + uid = 6660010; + }; + + zalora = { + uid = 1000301; + extraGroups = [ + "audio" + # TODO remove vboxusers when hardening is active + "vboxusers" + "video" + ]; + }; + }; + + 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 = { + cryptoModules = [ "aes" "sha512" "xts" ]; + devices = [ + { name = "xuca"; device = "/dev/sda2"; } + ]; + }; + + fileSystems = { + "/" = { + device = "/dev/mapper/xuvga-root"; + fsType = "btrfs"; + options = "defaults,noatime,ssd,compress=lzo"; + }; + "/home" = { + device = "/dev/mapper/xuvga-home"; + fsType = "btrfs"; + options = "defaults,noatime,ssd,compress=lzo"; + }; + "/boot" = { + device = "/dev/sda1"; + }; + "/tmp" = { + device = "tmpfs"; + fsType = "tmpfs"; + options = "nosuid,nodev,noatime"; + }; + }; + + nixpkgs.config.chromium.enablePepperFlash = true; + + nixpkgs.config.allowUnfree = true; + #hardware.bumblebee.enable = true; + #hardware.bumblebee.group = "video"; + hardware.enableAllFirmware = true; + #hardware.opengl.driSupport32Bit = true; + hardware.pulseaudio.enable = true; + + environment.systemPackages = with pkgs; [ + #xlibs.fontschumachermisc + #slock + ethtool + #firefoxWrapper # with plugins + #chromiumDevWrapper + tinc + iptables + #jack2 + + gptfdisk + ]; + + security.setuidPrograms = [ + "sendmail" # for cron + #"slock" + ]; + + services.printing.enable = true; + + services.journald.extraConfig = '' + SystemMaxUse=1G + RuntimeMaxUse=128M + ''; + + # see tmpfiles.d(5) + systemd.tmpfiles.rules = [ + "d /tmp 1777 root root - -" # does this work with mounted /tmp? + ]; + + #virtualisation.libvirtd.enable = true; + + #services.bitlbee.enable = true; + #services.tor.client.enable = true; + #services.tor.enable = true; + #services.virtualboxHost.enable = true; + + + # The NixOS release to be compatible with for stateful data such as databases. + system.stateVersion = "15.09"; +} diff --git a/tv/2configs/hw/x220.nix b/tv/2configs/hw/x220.nix new file mode 100644 index 000000000..8549311e7 --- /dev/null +++ b/tv/2configs/hw/x220.nix @@ -0,0 +1,60 @@ +{ pkgs, ... }: + +{ + imports = [ + ../smartd.nix + ]; + + boot.initrd.availableKernelModules = [ "ahci" ]; + boot.kernelModules = [ "kvm-intel" ]; + + boot.loader.gummiboot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.wireless.enable = true; + + #hardware.enableAllFirmware = true; + #nixpkgs.config.allowUnfree = true; + #zramSwap.enable = true; + #zramSwap.numDevices = 2; + + hardware.trackpoint = { + enable = true; + sensitivity = 220; + speed = 0; + emulateWheel = true; + }; + + services.tlp.enable = true; + services.tlp.extraConfig = '' + START_CHARGE_THRESH_BAT0=80 + ''; + + nix = { + buildCores = 2; + maxJobs = 2; + daemonIONiceLevel = 1; + daemonNiceLevel = 1; + }; + + services.logind.extraConfig = '' + HandleHibernateKey=ignore + HandleLidSwitch=ignore + HandlePowerKey=ignore + HandleSuspendKey=ignore + ''; + + services.xserver = { + videoDriver = "intel"; + vaapiDrivers = [ pkgs.vaapiIntel pkgs.vaapiVdpau ]; + deviceSection = '' + Option "AccelMethod" "sna" + ''; + }; + + #services.xserver.displayManager.sessionCommands ='' + # xinput set-int-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation" 8 1 + # xinput set-int-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Button" 8 2 + # xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5 + #''; +} -- cgit v1.2.3 From bcaf3771d9503f1b0d01a2c15ca0712ee454342f Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 29 Oct 2015 01:49:27 +0100 Subject: tv: {2configs/xserver => 5pkgs}/xmonad-tv --- tv/2configs/xserver/default.nix | 7 +- tv/2configs/xserver/xmonad/.gitignore | 1 - tv/2configs/xserver/xmonad/Main.hs | 277 --------------------- tv/2configs/xserver/xmonad/Makefile | 6 - tv/2configs/xserver/xmonad/Util/Font.hs | 123 ---------- tv/2configs/xserver/xmonad/Util/Pager.hs | 172 ------------- tv/2configs/xserver/xmonad/Util/Rhombus.hs | 369 ---------------------------- tv/2configs/xserver/xmonad/Util/Shutdown.hs | 53 ---- tv/2configs/xserver/xmonad/Util/Submap.hs | 31 --- tv/2configs/xserver/xmonad/Util/XUtils.hs | 47 ---- tv/2configs/xserver/xmonad/xmonad.cabal | 19 -- tv/5pkgs/default.nix | 3 + tv/5pkgs/xmonad-tv/.gitignore | 1 + tv/5pkgs/xmonad-tv/Main.hs | 277 +++++++++++++++++++++ tv/5pkgs/xmonad-tv/Makefile | 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 | 19 ++ 22 files changed, 1103 insertions(+), 1103 deletions(-) delete mode 100644 tv/2configs/xserver/xmonad/.gitignore delete mode 100644 tv/2configs/xserver/xmonad/Main.hs delete mode 100644 tv/2configs/xserver/xmonad/Makefile delete mode 100644 tv/2configs/xserver/xmonad/Util/Font.hs delete mode 100644 tv/2configs/xserver/xmonad/Util/Pager.hs delete mode 100644 tv/2configs/xserver/xmonad/Util/Rhombus.hs delete mode 100644 tv/2configs/xserver/xmonad/Util/Shutdown.hs delete mode 100644 tv/2configs/xserver/xmonad/Util/Submap.hs delete mode 100644 tv/2configs/xserver/xmonad/Util/XUtils.hs delete mode 100644 tv/2configs/xserver/xmonad/xmonad.cabal create mode 100644 tv/5pkgs/xmonad-tv/.gitignore create mode 100644 tv/5pkgs/xmonad-tv/Main.hs create mode 100644 tv/5pkgs/xmonad-tv/Makefile create mode 100644 tv/5pkgs/xmonad-tv/Util/Font.hs create mode 100644 tv/5pkgs/xmonad-tv/Util/Pager.hs create mode 100644 tv/5pkgs/xmonad-tv/Util/Rhombus.hs create mode 100644 tv/5pkgs/xmonad-tv/Util/Shutdown.hs create mode 100644 tv/5pkgs/xmonad-tv/Util/Submap.hs create mode 100644 tv/5pkgs/xmonad-tv/Util/XUtils.hs create mode 100644 tv/5pkgs/xmonad-tv/xmonad.cabal diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 388a33bbe..4d2fe9e45 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -80,9 +80,6 @@ let ''; }; - xmonad-pkg = pkgs.haskellPackages.callPackage xmonad-src {}; - xmonad-src = pkgs.writeNixFromCabal "xmonad.nix" ./xmonad; - xmonad-environment = { DISPLAY = ":${toString config.services.xserver.display}"; XMONAD_STATE = "/tmp/xmonad.state"; @@ -119,12 +116,12 @@ 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 ${xmonad-pkg}/bin/xmonad + exec ${pkgs.xmonad-tv}/bin/xmonad ''; xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' #! /bin/sh - exec ${xmonad-pkg}/bin/xmonad --shutdown + exec ${pkgs.xmonad-tv}/bin/xmonad --shutdown ''; xserver-environment = { diff --git a/tv/2configs/xserver/xmonad/.gitignore b/tv/2configs/xserver/xmonad/.gitignore deleted file mode 100644 index 616204547..000000000 --- a/tv/2configs/xserver/xmonad/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/shell.nix diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs deleted file mode 100644 index 2cc48efa3..000000000 --- a/tv/2configs/xserver/xmonad/Main.hs +++ /dev/null @@ -1,277 +0,0 @@ -{-# LANGUAGE DeriveDataTypeable #-} -- for XS -{-# LANGUAGE FlexibleContexts #-} -- for xmonad' -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE ScopedTypeVariables #-} - - -module Main where - -import Control.Exception -import Text.Read (readEither) -import XMonad -import System.IO (hPutStrLn, stderr) -import System.Environment (getArgs, withArgs, getEnv, getEnvironment) -import System.Posix.Process (executeFile) -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.Shutdown - - -myTerm :: String -myTerm = "urxvtc" - -myRootTerm :: String -myRootTerm = "urxvtc -name root-urxvt -e su -" - -myFont :: String -myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" - -main :: IO () -main = getArgs >>= \case - ["--shutdown"] -> sendShutdownEvent - _ -> mainNoArgs - -mainNoArgs :: IO () -mainNoArgs = do - workspaces0 <- getWorkspaces0 - 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 = workspaces0 - , layoutHook = smartBorders $ myLayout - -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent - --, handleEventHook = handleTimerEvent - , manageHook = placeHook (smart (1,0)) <+> floatNextHook - , startupHook = spawn "echo emit XMonadStartup" - , normalBorderColor = "#1c1c1c" - , focusedBorderColor = "#f000b0" - , handleEventHook = handleShutdownEvent - } - where - myLayout = - (onWorkspace "im" $ reflectVert $ Mirror $ Tall 1 (3/100) (12/13)) - (FixedColumn 1 20 80 10 ||| Full) - - -xmonad' :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO () -xmonad' conf = do - path <- getEnv "XMONAD_STATE" - try (readFile path) >>= \case - Right content -> do - hPutStrLn stderr ("resuming from " ++ path) - withArgs ("--resume" : lines content) (xmonad conf) - Left e -> do - hPutStrLn stderr (displaySomeException e) - xmonad conf - -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 = hPutStrLn stderr ("getWorkspaces0: " ++ msg) >> return [] - -displaySomeException :: SomeException -> String -displaySomeException = displayException - - -spawnTermAt :: String -> X () ---spawnTermAt _ = floatNext True >> spawn myTerm ---spawnTermAt "ff" = floatNext True >> spawn myTerm ---spawnTermAt _ = spawn myTerm -spawnTermAt ws = do - env <- liftIO getEnvironment - let env' = ("XMONAD_SPAWN_WORKSPACE", ws) : env - xfork (executeFile "urxvtc" True [] (Just env')) >> return () - -myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) -myKeys conf = Map.fromList $ - [ ((_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 . hPutStrLn stderr) ["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] diff --git a/tv/2configs/xserver/xmonad/Makefile b/tv/2configs/xserver/xmonad/Makefile deleted file mode 100644 index cbb0776e6..000000000 --- a/tv/2configs/xserver/xmonad/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -.PHONY: ghci -ghci: shell.nix - nix-shell --command 'exec ghci -Wall' - -shell.nix: xmonad.cabal - cabal2nix --shell . > $@ diff --git a/tv/2configs/xserver/xmonad/Util/Font.hs b/tv/2configs/xserver/xmonad/Util/Font.hs deleted file mode 100644 index 5352cf5ad..000000000 --- a/tv/2configs/xserver/xmonad/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/2configs/xserver/xmonad/Util/Pager.hs b/tv/2configs/xserver/xmonad/Util/Pager.hs deleted file mode 100644 index b8168b5b0..000000000 --- a/tv/2configs/xserver/xmonad/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/2configs/xserver/xmonad/Util/Rhombus.hs b/tv/2configs/xserver/xmonad/Util/Rhombus.hs deleted file mode 100644 index 9d46e4127..000000000 --- a/tv/2configs/xserver/xmonad/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