diff options
author | lassulus <lassulus@lassul.us> | 2021-03-19 09:19:54 +0100 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2021-03-19 09:19:54 +0100 |
commit | 6f4ef0a0e65be0bda6dfca2514c92d2b3ff452f0 (patch) | |
tree | 40f3d8628d10fb5e7d0fcf7d16f114d6d6011a2b | |
parent | 572d1ec9a045ee8b4a0422387e2969e705e018f7 (diff) | |
parent | 4ecf2a1db88b1862a93c99a36683bf462a3ace22 (diff) |
Merge remote-tracking branch 'ni/master'
-rw-r--r-- | lib/default.nix | 1 | ||||
-rw-r--r-- | lib/haskell.nix | 51 | ||||
-rw-r--r-- | tv/2configs/pulse.nix | 15 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/Helpers/Path.hs | 15 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/Paths.hs | 37 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/main.hs | 31 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal | 2 |
7 files changed, 82 insertions, 70 deletions
diff --git a/lib/default.nix b/lib/default.nix index 4190f8f..738e521 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -5,6 +5,7 @@ let evalSource = import ./eval-source.nix; git = import ./git.nix { inherit lib; }; + haskell = import ./haskell.nix { inherit lib; }; krebs = import ./krebs lib; krops = import ../submodules/krops/lib; shell = import ./shell.nix { inherit lib; }; diff --git a/lib/haskell.nix b/lib/haskell.nix new file mode 100644 index 0000000..b1889ca --- /dev/null +++ b/lib/haskell.nix @@ -0,0 +1,51 @@ +{ lib }: + +with builtins; + +rec { + + # Derive a file by substituting + # "${pkgs.foo}/bin/foo" for each {-pkg-}"foo", and + # "${pkgs.bar}/bin/foo" for each {-pkg:bar-}"foo". + # If a package doesn't exist, a warning gets printed. + substitutePkgs = name: { callsite ? null, pkgs, path }: + pkgs.writeText name (substitutePkgs' { + inherit pkgs; + sourceDescription = + if callsite != null then + "${name} in ${toString callsite}" + else + "${name} from ${toString path}"; + text = readFile path; + }); + + substitutePkgs' = { pkgs, sourceDescription, text }: + let + f = s: + let + parse = match "(.*)([{]-pkg(:([^}]+))?-[}]\"([^\"]+)\")(.*)" s; + prefix = elemAt parse 0; + pname = if elemAt parse 3 != null then elemAt parse 3 else exename; + exename = elemAt parse 4; + suffix = elemAt parse 5; + pkg = pkgs.${pname} or null; + + substitute = + if pkg != null then + "${pkg}/bin/${exename}" + else + trace (toString [ + "lib.haskell.replacePkg:" + "warning:" + "while deriving ${sourceDescription}:" + "no substitute found for ${elemAt parse 1}" + ]) + exename; + in + if parse == null then + s + else + f (prefix + toJSON substitute + suffix); + in + f text; +} diff --git a/tv/2configs/pulse.nix b/tv/2configs/pulse.nix index ea39701..79c31e9 100644 --- a/tv/2configs/pulse.nix +++ b/tv/2configs/pulse.nix @@ -43,6 +43,21 @@ let "auth-anonymous=1" "socket=${runDir}/socket" ]} + ${lib.optionalString (config.krebs.build.host.name == "au") '' + load-module ${toString [ + "module-native-protocol-tcp" + "auth-ip-acl=127.0.0.1;10.23.1.0/24" + ]} + ''} + ${lib.optionalString (config.krebs.build.host.name != "au") '' + load-module ${toString [ + "module-tunnel-sink-new" + "server=au.hkw" + "sink_name=au" + "channels=2" + "rate=44100" + ]} + ''} ''; in diff --git a/tv/5pkgs/haskell/xmonad-tv/src/Helpers/Path.hs b/tv/5pkgs/haskell/xmonad-tv/src/Helpers/Path.hs deleted file mode 100644 index 1029d60..0000000 --- a/tv/5pkgs/haskell/xmonad-tv/src/Helpers/Path.hs +++ /dev/null @@ -1,15 +0,0 @@ -module Helpers.Path where - -import qualified Data.List -import qualified System.Directory -import qualified System.IO.Unsafe - - -findExecutable :: String -> FilePath -findExecutable = - System.IO.Unsafe.unsafePerformIO . find - where - find name = - maybe failure id <$> System.Directory.findExecutable name - where - failure = error (Data.List.intercalate " " [name, "not found"]) diff --git a/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs b/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs deleted file mode 100644 index 2569b60..0000000 --- a/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs +++ /dev/null @@ -1,37 +0,0 @@ -module Paths where - -import Helpers.Path - - -flameshot :: FilePath -flameshot = findExecutable "flameshot-once" - -otpmenu :: FilePath -otpmenu = findExecutable "otpmenu" - -pactl :: FilePath -pactl = findExecutable "pactl" - -passmenu :: FilePath -passmenu = findExecutable "passmenu" - -pavucontrol :: FilePath -pavucontrol = findExecutable "pavucontrol" - -slock :: FilePath -slock = findExecutable "slock" - -su :: FilePath -su = findExecutable "su" - -urxvtc :: FilePath -urxvtc = findExecutable "urxvtc" - -xcalib :: FilePath -xcalib = findExecutable "xcalib" - -xdpychvt :: FilePath -xdpychvt = findExecutable "xdpychvt" - -xterm :: FilePath -xterm = findExecutable "xterm" diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index 48127a5..e720981 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -34,7 +34,6 @@ import XMonad.Actions.PerWorkspaceKeys (chooseAction) import XMonad.Stockholm.Pager import XMonad.Stockholm.Shutdown -import qualified Paths import THEnv.JSON (getCompileEnvJSONExp) @@ -72,7 +71,7 @@ mainNoArgs = do launch $ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ") $ def - { terminal = Paths.urxvtc + { terminal = {-pkg:rxvt_unicode-}"urxvtc" , modMask = mod4Mask , keys = myKeys , workspaces = workspaces0 @@ -122,14 +121,14 @@ displaySomeException = displayException forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X () forkFile path args env = - xfork (executeFile path False args env) >> return () + xfork (executeFile path True args env) >> return () spawnRootTerm :: X () spawnRootTerm = forkFile - Paths.urxvtc - ["-name", "root-urxvt", "-e", Paths.su, "-"] + {-pkg:rxvt_unicode-}"urxvtc" + ["-name", "root-urxvt", "-e", "/run/wrappers/bin/su", "-"] Nothing @@ -137,16 +136,16 @@ spawnTermAt :: String -> X () spawnTermAt ws = do env <- io getEnvironment let env' = ("XMONAD_SPAWN_WORKSPACE", ws) : env - forkFile Paths.urxvtc [] (Just env') + forkFile {-pkg:rxvt_unicode-}"urxvtc" [] (Just env') myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) myKeys conf = Map.fromList $ - [ ((_4 , xK_Escape ), forkFile Paths.slock [] Nothing) + [ ((_4 , xK_Escape ), forkFile {-pkg-}"slock" [] Nothing) , ((_4S , xK_c ), kill) - , ((_4 , xK_o ), forkFile Paths.otpmenu [] Nothing) - , ((_4 , xK_p ), forkFile Paths.passmenu [] Nothing) + , ((_4 , xK_o ), forkFile {-pkg:fzmenu-}"otpmenu" [] Nothing) + , ((_4 , xK_p ), forkFile {-pkg:fzmenu-}"passmenu" [] Nothing) , ((_4 , xK_x ), chooseAction spawnTermAt) , ((_4C , xK_x ), spawnRootTerm) @@ -188,12 +187,12 @@ myKeys conf = Map.fromList $ , ((0, xF86XK_AudioMute), audioMute) , ((_4, xF86XK_AudioMute), pavucontrol []) - , ((_4, xK_Prior), forkFile Paths.xcalib ["-invert", "-alter"] Nothing) + , ((_4, xK_Prior), forkFile {-pkg-}"xcalib" ["-invert", "-alter"] Nothing) - , ((0, xK_Print), forkFile Paths.flameshot [] Nothing) + , ((0, xK_Print), forkFile {-pkg-}"flameshot" [] Nothing) - , ((_C, xF86XK_Forward), forkFile Paths.xdpychvt ["next"] Nothing) - , ((_C, xF86XK_Back), forkFile Paths.xdpychvt ["prev"] Nothing) + , ((_C, xF86XK_Forward), forkFile {-pkg:xdpytools-}"xdpychvt" ["next"] Nothing) + , ((_C, xF86XK_Back), forkFile {-pkg:xdpytools-}"xdpychvt" ["prev"] Nothing) ] where _4 = mod4Mask @@ -206,8 +205,8 @@ myKeys conf = Map.fromList $ _4CM = _4 .|. _C .|. _M _4SM = _4 .|. _S .|. _M - pactl args = forkFile Paths.pactl args Nothing - pavucontrol args = forkFile Paths.pavucontrol args Nothing + pactl args = forkFile {-pkg:pulseaudio-}"pactl" args Nothing + pavucontrol args = forkFile {-pkg-}"pavucontrol" args Nothing audioLowerVolume = pactl ["--", "set-sink-volume", "@DEFAULT_SINK@", "-5%"] audioRaiseVolume = pactl ["--", "set-sink-volume", "@DEFAULT_SINK@", "+5%"] @@ -222,7 +221,7 @@ myKeys conf = Map.fromList $ xdeny :: X () xdeny = forkFile - Paths.xterm + {-pkg-}"xterm" [ "-fn", myFont , "-geometry", "300x100" , "-name", "AlertFloat" diff --git a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal index d07e2b1..f3bd2e0 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal +++ b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal @@ -23,8 +23,6 @@ executable xmonad xmonad-contrib, xmonad-stockholm other-modules: - Helpers.Path, - Paths, THEnv.JSON default-language: Haskell2010 ghc-options: -O2 -Wall -threaded |