summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-05-25 11:14:32 +0200
committerlassulus <lass@aidsballs.de>2016-05-25 11:14:32 +0200
commita240a60b52684466a207a43e944e0f040ec75361 (patch)
tree13e872ba019942f6509e2ed17649d44603c3e841
parent0f2fc7c4a6a9bb41b965c905949aefebbb6c3f49 (diff)
parent36c5834c288b56b6955e35d95708ae7f65f199f9 (diff)
Merge remote-tracking branch 'cd/master' into HEAD
-rw-r--r--krebs/5pkgs/builders.nix51
-rw-r--r--tv/2configs/vim.nix7
-rw-r--r--tv/2configs/xserver/Xmodmap.nix27
-rw-r--r--tv/2configs/xserver/default.nix87
-rw-r--r--tv/5pkgs/default.nix4
-rw-r--r--tv/5pkgs/xmonad-tv.nix (renamed from tv/5pkgs/xmonad-tv/Main.hs)56
-rw-r--r--tv/5pkgs/xmonad-tv/.gitignore1
-rw-r--r--tv/5pkgs/xmonad-tv/Makefile6
-rw-r--r--tv/5pkgs/xmonad-tv/xmonad.cabal18
9 files changed, 156 insertions, 101 deletions
diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix
index 19169b186..39b91d144 100644
--- a/krebs/5pkgs/builders.nix
+++ b/krebs/5pkgs/builders.nix
@@ -66,7 +66,52 @@ rec {
mv "$textPath" $out
'';
- writeNixFromCabal = name: path: pkgs.runCommand name {} ''
- ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
- '';
+ writeHaskellBin =
+ k:
+ let
+ k' = parseDrvName k;
+ name = k'.name;
+ version = if k'.version != "" then k'.version else "0";
+ in
+ { build-depends ? ["base"] ++ depends
+ , depends ? []
+ , ghc-options ? ["-Wall" "-O3" "-threaded" "-rtsopts"]
+ , haskellPackages ? pkgs.haskellPackages
+ , license ? "WTFPL"
+ }:
+ main-text:
+ let
+ cabal-file = pkgs.writeText "${name}-${version}.cabal" ''
+ build-type: Simple
+ cabal-version: >= 1.2
+ name: ${name}
+ version: ${version}
+
+ executable ${name}
+ build-depends: ${concatStringsSep "," build-depends}
+ ghc-options: ${toString ghc-options}
+ main-is: ${main-file.name}
+ '';
+ main-file = pkgs.writeText "${name}-${version}.hs" main-text;
+ in
+ haskellPackages.mkDerivation rec {
+ inherit license version;
+ executableHaskellDepends = attrVals build-depends haskellPackages;
+ isExecutable = true;
+ isLibrary = false;
+ pname = name;
+ src = pkgs.runCommand "${name}-${version}-src" {} ''
+ install -D ${cabal-file} $out/${cabal-file.name}
+ install -D ${main-file} $out/${main-file.name}
+ '';
+ };
+
+ writeNixFromCabal =
+ trace (toString [
+ "The function `writeNixFromCabal` has been deprecated in favour of"
+ "`writeHaskellBin'."
+ ])
+ (name: path: pkgs.runCommand name {} ''
+ ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
+ '');
}
diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix
index 6e2059484..10e5aab52 100644
--- a/tv/2configs/vim.nix
+++ b/tv/2configs/vim.nix
@@ -111,6 +111,13 @@ let
syn match String /"\([^\\"]\|\\.\)*"/
syn match Comment /\(^\|\s\)#.*/
+ " Haskell comments
+ syn region Comment start=/\(^\|\s\){-#/ end=/#-}/
+ syn match Comment /\(^\|\s\)--.*/
+
+ " Vim comments
+ syn match Comment /\(^\|\s\)"[^"]*$/
+
let b:current_syntax = "nix"
''}
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 4b936f473..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;
@@ -56,8 +62,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;
};
@@ -73,13 +79,30 @@ 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"
+ ];
};
};
};
xmonad-environment = {
DISPLAY = ":${toString config.services.xserver.display}";
+
+ 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
+ '';
+
XMONAD_STATE = "/tmp/xmonad.state";
# XXX JSON is close enough :)
@@ -96,34 +119,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##*/}
- 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
- '';
-
- xmonad-stop = pkgs.writeScriptBin "xmonad-stop" ''
- #! /bin/sh
- exec ${pkgs.xmonad-tv}/bin/xmonad --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.
@@ -132,23 +127,9 @@ 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
- echo "$*"
- '';
- in "${pkg}/bin/need-reload ${s}";
+ need-reload = s: toString [
+ "${pkgs.writeDashBin "need-reload" ''echo "$*"''}/bin/need-reload"
+ (shell.escape s)
+ ];
in out
diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix
index b520e1a32..05dc02887 100644
--- a/tv/5pkgs/default.nix
+++ b/tv/5pkgs/default.nix
@@ -18,8 +18,6 @@
};
ff = pkgs.callPackage ./ff {};
viljetic-pages = pkgs.callPackage ./viljetic-pages {};
- xmonad-tv =
- let src = pkgs.writeNixFromCabal "xmonad-tv.nix" ./xmonad-tv; in
- pkgs.haskellPackages.callPackage src {};
+ xmonad-tv = import ./xmonad-tv.nix { inherit pkgs; };
};
}
diff --git a/tv/5pkgs/xmonad-tv/Main.hs b/tv/5pkgs/xmonad-tv.nix
index 817d0092e..74e43dc79 100644
--- a/tv/5pkgs/xmonad-tv/Main.hs
+++ b/tv/5pkgs/xmonad-tv.nix
@@ -1,3 +1,14 @@
+{ pkgs, ... }:
+pkgs.writeHaskellBin "xmonad-tv" {
+ depends = [
+ "containers"
+ "unix"
+ "X11"
+ "xmonad"
+ "xmonad-contrib"
+ "xmonad-stockholm"
+ ];
+} ''
{-# LANGUAGE DeriveDataTypeable #-} -- for XS
{-# LANGUAGE FlexibleContexts #-} -- for xmonad'
{-# LANGUAGE LambdaCase #-}
@@ -40,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-*"
@@ -64,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
@@ -72,7 +83,9 @@ mainNoArgs = do
-- , handleEventHook = myHandleEventHooks <+> handleTimerEvent
--, handleEventHook = handleTimerEvent
, manageHook = placeHook (smart (1,0)) <+> floatNextHook
- , startupHook = spawn "echo emit XMonadStartup"
+ , startupHook = do
+ path <- liftIO (getEnv "XMONAD_STARTUP_HOOK")
+ forkFile path [] Nothing
, normalBorderColor = "#1c1c1c"
, focusedBorderColor = "#f000b0"
, handleEventHook = handleShutdownEvent
@@ -110,24 +123,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)
@@ -187,9 +206,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
@@ -202,6 +221,8 @@ myKeys conf = Map.fromList $
_4CM = _4 .|. _C .|. _M
_4SM = _4 .|. _S .|. _M
+ amixer args = forkFile amixerPath args Nothing
+
pagerConfig :: PagerConfig
pagerConfig = def
@@ -278,3 +299,4 @@ wGSConfig = def
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/5pkgs/xmonad-tv/.gitignore b/tv/5pkgs/xmonad-tv/.gitignore
deleted file mode 100644
index 616204547..000000000
--- a/tv/5pkgs/xmonad-tv/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/shell.nix
diff --git a/tv/5pkgs/xmonad-tv/Makefile b/tv/5pkgs/xmonad-tv/Makefile
deleted file mode 100644
index cbb0776e6..000000000
--- a/tv/5pkgs/xmonad-tv/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/5pkgs/xmonad-tv/xmonad.cabal b/tv/5pkgs/xmonad-tv/xmonad.cabal
deleted file mode 100644
index f9ea4dd7d..000000000
--- a/tv/5pkgs/xmonad-tv/xmonad.cabal
+++ /dev/null
@@ -1,18 +0,0 @@
-Author: tv
-Build-Type: Simple
-Cabal-Version: >= 1.2
-License: MIT
-Name: xmonad-tv
-Version: 0
-
-Executable xmonad
- Build-Depends:
- base,
- containers,
- unix,
- X11,
- xmonad,
- xmonad-contrib,
- xmonad-stockholm
- GHC-Options: -Wall -O3 -threaded -rtsopts
- Main-Is: Main.hs