From 37ee40759f1e6feda51fb36dd3c951b4f3045944 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:31:49 +0200 Subject: xmonad-tv: convert to writeHaskellBin --- tv/2configs/xserver/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 4b936f473..08b69067c 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -116,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 ${pkgs.xmonad-tv}/bin/xmonad + exec ${pkgs.xmonad-tv}/bin/xmonad-tv ''; xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' #! /bin/sh - exec ${pkgs.xmonad-tv}/bin/xmonad --shutdown + exec ${pkgs.xmonad-tv}/bin/xmonad-tv --shutdown ''; xserver-environment = { -- cgit v1.3.1 From bd64bc1eb05cc95a32165288481d9ff9be4f33c8 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:39:17 +0200 Subject: tv nix.vim: admit Haskell comments --- tv/2configs/vim.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 6e2059484..6eefca307 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -111,6 +111,10 @@ let syn match String /"\([^\\"]\|\\.\)*"/ syn match Comment /\(^\|\s\)#.*/ + " Haskell comments + syn region Comment start=/\(^\|\s\){-#/ end=/#-}/ + syn match Comment /\(^\|\s\)--.*/ + let b:current_syntax = "nix" ''} -- cgit v1.3.1 From 00d4320545eba17227983eaa8c7578cfc5afc1e4 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:47:22 +0200 Subject: tv nix.vim: admit Vim comments --- tv/2configs/vim.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 6eefca307..10e5aab52 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -115,6 +115,9 @@ let syn region Comment start=/\(^\|\s\){-#/ end=/#-}/ syn match Comment /\(^\|\s\)--.*/ + " Vim comments + syn match Comment /\(^\|\s\)"[^"]*$/ + let b:current_syntax = "nix" ''} -- cgit v1.3.1 From 9172da3aa08672ad178128663afa4331059475ad Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 01:26:25 +0200 Subject: xmonad-tv: don't use PATH --- tv/2configs/xserver/default.nix | 5 ----- tv/5pkgs/xmonad-tv.nix | 42 ++++++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 22 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 08b69067c..51e243284 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -99,11 +99,6 @@ let xmonad-start = pkgs.writeScriptBin "xmonad" '' #! ${pkgs.bash}/bin/bash set -efu - export PATH; PATH=${makeSearchPath "bin" [ - # TODO put paths into a Haskell module instead of PATH - pkgs.alsaUtils - pkgs.rxvt_unicode - ]}:/var/setuid-wrappers settle() {( # Use PATH for a clean journal command=''${1##*/} diff --git a/tv/5pkgs/xmonad-tv.nix b/tv/5pkgs/xmonad-tv.nix index 086fd911e..794d90688 100644 --- a/tv/5pkgs/xmonad-tv.nix +++ b/tv/5pkgs/xmonad-tv.nix @@ -51,11 +51,11 @@ import XMonad.Stockholm.Rhombus import XMonad.Stockholm.Shutdown -myTerm :: String -myTerm = "urxvtc" +amixerPath :: FilePath +amixerPath = "${pkgs.alsaUtils}/bin/amixer" -myRootTerm :: String -myRootTerm = "urxvtc -name root-urxvt -e su -" +urxvtcPath :: FilePath +urxvtcPath = "${pkgs.rxvt_unicode}/bin/urxvtc" myFont :: String myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" @@ -75,7 +75,7 @@ mainNoArgs = do -- $ withUrgencyHookC BorderUrgencyHook { urgencyBorderColor = "magenta" } urgencyConfig { suppressWhen = Never } $ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ") $ def - { terminal = myTerm + { terminal = urxvtcPath , modMask = mod4Mask , keys = myKeys , workspaces = workspaces0 @@ -83,7 +83,7 @@ mainNoArgs = do -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent --, handleEventHook = handleTimerEvent , manageHook = placeHook (smart (1,0)) <+> floatNextHook - , startupHook = spawn "echo emit XMonadStartup" + , startupHook = liftIO (putStrLn "emit XMonadStartup") , normalBorderColor = "#1c1c1c" , focusedBorderColor = "#f000b0" , handleEventHook = handleShutdownEvent @@ -121,24 +121,30 @@ displaySomeException :: SomeException -> String displaySomeException = displayException +forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X () +forkFile path args env = + xfork (executeFile path False args env) >> return () + +spawnRootTerm :: X () +spawnRootTerm = + forkFile + urxvtcPath + ["-name", "root-urxvt", "-e", "/var/setuid-wrappers/su", "-"] + Nothing + 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 () + forkFile urxvtcPath [] (Just env') myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) myKeys conf = Map.fromList $ - [ ((_4 , xK_Escape ), spawn "/var/setuid-wrappers/slock") + [ ((_4 , xK_Escape ), forkFile "/var/setuid-wrappers/slock" [] Nothing) , ((_4S , xK_c ), kill) , ((_4 , xK_x ), chooseAction spawnTermAt) - , ((_4C , xK_x ), spawn myRootTerm) - --, ((_4M , xK_x ), spawn "xterm") - --, ((_4M , xK_x ), mySpawn "xterm") + , ((_4C , xK_x ), spawnRootTerm) --, ((_4 , xK_F1 ), withFocused jojo) --, ((_4 , xK_F1 ), printAllGeometries) @@ -198,9 +204,9 @@ myKeys conf = Map.fromList $ --, (_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 }) - , ((noModMask, xF86XK_AudioLowerVolume), spawn "amixer sset Master 5%-") - , ((noModMask, xF86XK_AudioRaiseVolume), spawn "amixer sset Master 5%+") - , ((noModMask, xF86XK_AudioMute), spawn "amixer sset Master toggle") + , ((noModMask, xF86XK_AudioLowerVolume), amixer ["sset", "Master", "5%+"]) + , ((noModMask, xF86XK_AudioRaiseVolume), amixer ["sset", "Master", "5%-"]) + , ((noModMask, xF86XK_AudioMute), amixer ["sset", "Master", "toggle"]) ] where _4 = mod4Mask @@ -213,6 +219,8 @@ myKeys conf = Map.fromList $ _4CM = _4 .|. _C .|. _M _4SM = _4 .|. _S .|. _M + amixer args = forkFile amixerPath args Nothing + pagerConfig :: PagerConfig pagerConfig = def -- cgit v1.3.1 From 73a63312255821f2b3b0315232cdd5b8ea1b994d Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 01:37:52 +0200 Subject: xmonad-tv: startupHook = $XMONAD_STARTUP_HOOK & --- tv/2configs/xserver/default.nix | 35 ++++++++++------------------------- tv/5pkgs/xmonad-tv.nix | 4 +++- 2 files changed, 13 insertions(+), 26 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 51e243284..efc06be14 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -56,8 +56,8 @@ let requires = [ "xserver.service" ]; environment = xmonad-environment; serviceConfig = { - ExecStart = "${xmonad-start}/bin/xmonad"; - ExecStop = "${xmonad-stop}/bin/xmonad-stop"; + ExecStart = "${pkgs.xmonad-tv}/bin/xmonad-tv"; + ExecStop = "${pkgs.xmonad-tv}/bin/xmonad-tv --shutdown"; User = user.name; WorkingDirectory = user.home; }; @@ -80,6 +80,14 @@ let xmonad-environment = { DISPLAY = ":${toString config.services.xserver.display}"; + + XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-startup-hook" '' + ${pkgs.xorg.xhost}/bin/xhost +LOCAL: & + ${pkgs.xorg.xrdb}/bin/xrdb -merge ${import ./Xresources.nix args} & + ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' & + wait + ''; + XMONAD_STATE = "/tmp/xmonad.state"; # XXX JSON is close enough :) @@ -96,29 +104,6 @@ let ]); }; - xmonad-start = pkgs.writeScriptBin "xmonad" '' - #! ${pkgs.bash}/bin/bash - set -efu - settle() {( - # Use PATH for a clean journal - command=''${1##*/} - PATH=''${1%/*}; export PATH - shift - until "$command" "$@"; do - ${pkgs.coreutils}/bin/sleep 1 - done - )&} - settle ${pkgs.xorg.xhost}/bin/xhost +LOCAL: - settle ${pkgs.xorg.xrdb}/bin/xrdb -merge ${import ./Xresources.nix args} - settle ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' - exec ${pkgs.xmonad-tv}/bin/xmonad-tv - ''; - - xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' - #! /bin/sh - exec ${pkgs.xmonad-tv}/bin/xmonad-tv --shutdown - ''; - xserver-environment = { XKB_BINDIR = "${pkgs.xorg.xkbcomp}/bin"; # Needed for the Xkb extension. XORG_DRI_DRIVER_PATH = "/run/opengl-driver/lib/dri"; # !!! Depends on the driver selected at runtime. diff --git a/tv/5pkgs/xmonad-tv.nix b/tv/5pkgs/xmonad-tv.nix index 794d90688..74e43dc79 100644 --- a/tv/5pkgs/xmonad-tv.nix +++ b/tv/5pkgs/xmonad-tv.nix @@ -83,7 +83,9 @@ mainNoArgs = do -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent --, handleEventHook = handleTimerEvent , manageHook = placeHook (smart (1,0)) <+> floatNextHook - , startupHook = liftIO (putStrLn "emit XMonadStartup") + , startupHook = do + path <- liftIO (getEnv "XMONAD_STARTUP_HOOK") + forkFile path [] Nothing , normalBorderColor = "#1c1c1c" , focusedBorderColor = "#f000b0" , handleEventHook = handleShutdownEvent -- cgit v1.3.1 From f48cd0f2a3b9970fee3f4100c9656e6b6b4fd6d8 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 01:50:06 +0200 Subject: tv xserver: drop wrapper --- tv/2configs/xserver/default.nix | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index efc06be14..802542020 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -73,7 +73,15 @@ let environment = xserver-environment; serviceConfig = { ExecReload = need-reload "xserver.service"; - ExecStart = "${xserver}/bin/xserver"; + ExecStart = toString [ + "${pkgs.xorg.xorgserver}/bin/X" + ":${toString config.services.xserver.display}" + "vt${toString config.services.xserver.tty}" + "-config ${import ./xserver.conf.nix args}" + "-logfile /var/log/X.${toString config.services.xserver.display}.log" + "-nolisten tcp" + "-xkbdir ${pkgs.xkeyboard_config}/etc/X11/xkb" + ]; }; }; }; @@ -112,18 +120,6 @@ let ++ concatLists (catAttrs "libPath" config.services.xserver.drivers)); }; - xserver = pkgs.writeScriptBin "xserver" '' - #! /bin/sh - set -efu - exec ${pkgs.xorg.xorgserver}/bin/X \ - :${toString config.services.xserver.display} \ - vt${toString config.services.xserver.tty} \ - -config ${import ./xserver.conf.nix args} \ - -logfile /var/log/X.${toString config.services.xserver.display}.log \ - -nolisten tcp \ - -xkbdir ${pkgs.xkeyboard_config}/etc/X11/xkb \ - ''; - need-reload = s: let pkg = pkgs.writeScriptBin "need-reload" '' #! /bin/sh -- cgit v1.3.1 From 5903c47cffee90824256994470e92d2956185e8c Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 02:36:24 +0200 Subject: tv xmodmap: init --- tv/2configs/xserver/Xmodmap.nix | 27 +++++++++++++++++++++++++++ tv/2configs/xserver/default.nix | 1 + 2 files changed, 28 insertions(+) create mode 100644 tv/2configs/xserver/Xmodmap.nix (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/Xmodmap.nix b/tv/2configs/xserver/Xmodmap.nix new file mode 100644 index 000000000..02b6c730e --- /dev/null +++ b/tv/2configs/xserver/Xmodmap.nix @@ -0,0 +1,27 @@ +{ config, pkgs, ... }: + +with config.krebs.lib; + +pkgs.writeText "Xmodmap" '' + !keycode 66 = Caps_Lock + !remove Lock = Caps_Lock + clear Lock + + ! caps lock + keycode 66 = Mode_switch + + keycode 13 = 4 dollar EuroSign cent + keycode 30 = u U udiaeresis Udiaeresis + keycode 32 = o O odiaeresis Odiaeresis + keycode 38 = a A adiaeresis Adiaeresis + keycode 39 = s S ssharp + + keycode 33 = p P Greek_pi Greek_PI + keycode 46 = l L Greek_lambda Greek_LAMBDA + + keycode 54 = c C cacute Cacute + + ! BULLET OPERATOR + keycode 17 = 8 asterisk U2219 + keycode 27 = r R r U211D +'' diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 802542020..e85c07fad 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -91,6 +91,7 @@ let XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-startup-hook" '' ${pkgs.xorg.xhost}/bin/xhost +LOCAL: & + ${pkgs.xorg.xmodmap}/bin/xmodmap ${import ./Xmodmap.nix args} & ${pkgs.xorg.xrdb}/bin/xrdb -merge ${import ./Xresources.nix args} & ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' & wait -- cgit v1.3.1 From 82a8e7eca896c94e35de22a734d538f25e028faf Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 02:41:55 +0200 Subject: tv xserver: compress need-reload --- tv/2configs/xserver/default.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index e85c07fad..a6a820507 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -121,11 +121,9 @@ let ++ concatLists (catAttrs "libPath" config.services.xserver.drivers)); }; - need-reload = s: let - pkg = pkgs.writeScriptBin "need-reload" '' - #! /bin/sh - echo "$*" - ''; - in "${pkg}/bin/need-reload ${s}"; + need-reload = s: toString [ + "${pkgs.writeDashBin "need-reload" ''echo "$*"''}/bin/need-reload" + (shell.escape s) + ]; in out -- cgit v1.3.1 From 36c5834c288b56b6955e35d95708ae7f65f199f9 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 03:03:21 +0200 Subject: tv slock: user krebs.setuid --- tv/2configs/xserver/default.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index a6a820507..b5b116786 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -37,15 +37,21 @@ let pkgs.ff pkgs.gitAndTools.qgit pkgs.mpv - pkgs.slock pkgs.sxiv pkgs.xsel pkgs.zathura ]; - security.setuidPrograms = [ - "slock" - ]; + # TODO dedicated group, i.e. with a single user + # TODO krebs.setuid.slock.path vs /var/setuid-wrappers + krebs.setuid.slock = { + filename = "${pkgs.slock}/bin/slock"; + group = "wheel"; + envp = { + DISPLAY = ":${toString config.services.xserver.display}"; + USER = user.name; + }; + }; systemd.services.display-manager.enable = false; -- cgit v1.3.1