diff options
author | tv <tv@krebsco.de> | 2023-09-12 12:56:39 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2023-09-13 16:23:38 +0200 |
commit | fbd485cd86c7e9984819357398f912a2d5510845 (patch) | |
tree | e1a9e2eedacfa25018d6b0eef3f4628a4d503ebc /tv/5pkgs | |
parent | 5370e0485788224126861e076110ac705013d2de (diff) |
tv: emigrate
Diffstat (limited to 'tv/5pkgs')
84 files changed, 0 insertions, 3278 deletions
diff --git a/tv/5pkgs/compat/default.nix b/tv/5pkgs/compat/default.nix deleted file mode 100644 index 0d1e61b3b..000000000 --- a/tv/5pkgs/compat/default.nix +++ /dev/null @@ -1 +0,0 @@ -self: super: {} diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix deleted file mode 100644 index 245d0542b..000000000 --- a/tv/5pkgs/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -with import ./lib; -let - pushBack = x: xs: - if elem x xs then - remove x xs ++ [ x ] - else - xs; -in - -self: super: - -# Import files and subdirectories like they are overlays. -fix - (foldl' (flip extends) (_: super) - (map - (name: import (./. + "/${name}")) - (pushBack "override" - (attrNames - (filterAttrs isNixDirEntry (readDir ./.)))))) diff --git a/tv/5pkgs/haskell/default.nix b/tv/5pkgs/haskell/default.nix deleted file mode 100644 index 193a2630d..000000000 --- a/tv/5pkgs/haskell/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -with import ./lib; -let - overrides = self: super: - mapNixDir (path: self.callPackage path {}) [ - <stockholm/krebs/5pkgs/haskell> - ./. - ] // { - xmonad-tv = self.callPackage ./xmonad-tv { - pager = self.desktop-pager; - }; - }; -in - self: super: { - haskell = super.haskell // { - packages = mapAttrs (name: value: - if hasAttr "override" value - then value.override (old: { - overrides = - composeExtensions (old.overrides or (_: _: { })) overrides; - }) - else value - ) super.haskell.packages; - }; - haskellPackages = super.haskellPackages.override (old: { - overrides = - composeExtensions (old.overrides or (_: _: { })) overrides; - }); - } diff --git a/tv/5pkgs/haskell/lib b/tv/5pkgs/haskell/lib deleted file mode 120000 index dc598c56d..000000000 --- a/tv/5pkgs/haskell/lib +++ /dev/null @@ -1 +0,0 @@ -../lib
\ No newline at end of file diff --git a/tv/5pkgs/haskell/th-env/default.nix b/tv/5pkgs/haskell/th-env/default.nix deleted file mode 100644 index 158fb165a..000000000 --- a/tv/5pkgs/haskell/th-env/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ mkDerivation, base, lib, template-haskell, text }: -mkDerivation { - pname = "th-env"; - version = "1.0.0"; - src = ./.; - libraryHaskellDepends = [ base template-haskell text ]; - homepage = "https://stackoverflow.com/q/57635686"; - license = "unknown"; - hydraPlatforms = lib.platforms.none; -} diff --git a/tv/5pkgs/haskell/th-env/src/THEnv.hs b/tv/5pkgs/haskell/th-env/src/THEnv.hs deleted file mode 100644 index b04f2ce0b..000000000 --- a/tv/5pkgs/haskell/th-env/src/THEnv.hs +++ /dev/null @@ -1,49 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -module THEnv - ( - -- * Compile-time configuration - lookupCompileEnv - , lookupCompileEnvExp - , getCompileEnv - , getCompileEnvExp - , fileAsString - ) where - -import Control.Monad -import qualified Data.Text as T -import qualified Data.Text.IO as T -import Language.Haskell.TH -import Language.Haskell.TH.Syntax (Lift(..)) -import System.Environment (getEnvironment) - --- Functions that work with compile-time configuration - --- | Looks up a compile-time environment variable. -lookupCompileEnv :: String -> Q (Maybe String) -lookupCompileEnv key = lookup key `liftM` runIO getEnvironment - --- | Looks up a compile-time environment variable. The result is a TH --- expression of type @Maybe String@. -lookupCompileEnvExp :: String -> Q Exp -lookupCompileEnvExp = (`sigE` [t| Maybe String |]) . lift <=< lookupCompileEnv - -- We need to explicly type the result so that things like `print Nothing` - -- work. - --- | Looks up an compile-time environment variable and fail, if it's not --- present. -getCompileEnv :: String -> Q String -getCompileEnv key = - lookupCompileEnv key >>= - maybe (fail $ "Environment variable " ++ key ++ " not defined") return - --- | Looks up an compile-time environment variable and fail, if it's not --- present. The result is a TH expression of type @String@. -getCompileEnvExp :: String -> Q Exp -getCompileEnvExp = lift <=< getCompileEnv - --- | Loads the content of a file as a string constant expression. --- The given path is relative to the source directory. -fileAsString :: FilePath -> Q Exp -fileAsString = do - -- addDependentFile path -- works only with template-haskell >= 2.7 - stringE . T.unpack . T.strip <=< runIO . T.readFile diff --git a/tv/5pkgs/haskell/th-env/th-env.cabal b/tv/5pkgs/haskell/th-env/th-env.cabal deleted file mode 100644 index b9a2cff39..000000000 --- a/tv/5pkgs/haskell/th-env/th-env.cabal +++ /dev/null @@ -1,20 +0,0 @@ -name: th-env -version: 1.0.0 --- license: https://creativecommons.org/licenses/by-sa/4.0/ -license: OtherLicense -author: https://stackoverflow.com/users/9348482 -homepage: https://stackoverflow.com/q/57635686 -maintainer: tv <tv@krebsco.de> -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - build-depends: - base, - template-haskell, - text - exposed-modules: - THEnv - default-language: Haskell2010 - ghc-options: -O2 -Wall diff --git a/tv/5pkgs/haskell/xmonad-tv/default.nix b/tv/5pkgs/haskell/xmonad-tv/default.nix deleted file mode 100644 index f42f97c2a..000000000 --- a/tv/5pkgs/haskell/xmonad-tv/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ mkDerivation, aeson, base, bytestring, containers, directory -, extra, filepath, lib, pager, unix, X11, xmonad, xmonad-contrib -}: -mkDerivation { - pname = "xmonad-tv"; - version = "1.0.0"; - src = ./src; - isLibrary = false; - isExecutable = true; - executableHaskellDepends = [ - aeson base bytestring containers directory extra filepath pager - unix X11 xmonad xmonad-contrib - ]; - license = lib.licenses.mit; - mainProgram = "xmonad"; -} diff --git a/tv/5pkgs/haskell/xmonad-tv/shell.nix b/tv/5pkgs/haskell/xmonad-tv/shell.nix deleted file mode 100644 index 6ca00bc05..000000000 --- a/tv/5pkgs/haskell/xmonad-tv/shell.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ compiler ? "default" }: let - - stockholm = import <stockholm>; - - inherit (stockholm.systems.${lib.krops.getHostName}) config pkgs; - inherit (stockholm) lib; - - haskellPackages = - if compiler == "default" - then pkgs.haskellPackages - else pkgs.haskell.packages.${compiler}; - - xmonadDrv = haskellPackages.callPackage (import ./.) {}; - -in - - lib.overrideDerivation xmonadDrv.env (oldAttrs: { - shellHook = '' - pkg_name=${lib.shell.escape (lib.baseNameOf (toString ./.))} - - WORKDIR=${toString ./src} - CACHEDIR=$HOME/tmp/$pkg_name - HISTFILE=$CACHEDIR/bash_history - - mkdir -p "$CACHEDIR" - - config_XMONAD_CACHE_DIR=${lib.shell.escape - config.systemd.services.xmonad.environment.XMONAD_CACHE_DIR - } - - xmonad=$CACHEDIR/xmonad-${lib.currentSystem} - - xmonad_build() {( - set -efu - cd "$WORKDIR" - options=$( - ${pkgs.cabal-read}/bin/ghc-options "$WORKDIR/$pkg_name.cabal" xmonad - ) - ghc $options \ - -odir "$CACHEDIR" \ - -hidir "$CACHEDIR" \ - -o "$xmonad" \ - main.hs - )} - - xmonad_restart() {( - set -efu - cd "$WORKDIR" - if systemctl --quiet is-active xmonad; then - sudo systemctl stop xmonad - cp -b "$config_XMONAD_CACHE_DIR"/xmonad.state "$CACHEDIR"/ - echo "xmonad.state: $(cat "$CACHEDIR"/xmonad.state)" - else - "$xmonad" --shutdown || : - fi - "$xmonad" & - echo xmonad pid: $! >&2 - )} - - xmonad_yield() {( - set -efu - if ! systemctl --quiet is-active xmonad; then - "$xmonad" --shutdown - cp -b "$CACHEDIR"/xmonad.state "$config_XMONAD_CACHE_DIR"/ - sudo systemctl start xmonad - else - echo "xmonad.service is already running" >&2 - exit -1 - fi - )} - - export PATH=${config.systemd.services.xmonad.path}:$PATH - export SHELL=/run/current-system/sw/bin/bash - - export XMONAD_CACHE_DIR="$CACHEDIR" - export XMONAD_DATA_DIR="$CACHEDIR" - export XMONAD_CONFIG_DIR=/var/empty - - unset XMONAD_STARTUP_HOOK - - cd "$WORKDIR" - ''; - }) diff --git a/tv/5pkgs/haskell/xmonad-tv/src/Shutdown.hs b/tv/5pkgs/haskell/xmonad-tv/src/Shutdown.hs deleted file mode 100644 index d4a4d93cf..000000000 --- a/tv/5pkgs/haskell/xmonad-tv/src/Shutdown.hs +++ /dev/null @@ -1,113 +0,0 @@ -{-# LANGUAGE LambdaCase #-} - -module Shutdown - ( newShutdownEventHandler - , shutdown - ) - where - -import Control.Applicative ((<|>), empty) -import Control.Concurrent (threadDelay) -import Control.Monad (forever, guard, when) -import Data.Monoid (All(All)) -import System.Directory (XdgDirectory(XdgData), createDirectoryIfMissing, doesFileExist, getAppUserDataDirectory, getXdgDirectory) -import System.Exit (exitSuccess) -import System.Environment (lookupEnv) -import System.FilePath ((</>)) -import System.IO.Error (isDoesNotExistError, tryIOError) -import System.IO (hPutStrLn, stderr) -import System.Posix.Process (getProcessID) -import System.Posix.Signals (nullSignal, signalProcess) -import System.Posix.Types (ProcessID) -import XMonad hiding (getXMonadDataDir) - - --- XXX this is for compatibility with both xmonad<0.17 and xmonad>=0.17 -getXMonadDataDir :: IO String -getXMonadDataDir = xmEnvDir <|> xmDir <|> xdgDir - where - -- | Check for xmonad's environment variables first - xmEnvDir :: IO String - xmEnvDir = - maybe empty pure =<< lookupEnv "XMONAD_DATA_DIR" - - -- | Check whether the config file or a build script is in the - -- @~\/.xmonad@ directory - xmDir :: IO String - xmDir = do - d <- getAppUserDataDirectory "xmonad" - conf <- doesFileExist $ d </> "xmonad.hs" - build <- doesFileExist $ d </> "build" - pid <- doesFileExist $ d </> "xmonad.pid" - - -- Place *everything* in ~/.xmonad if yes - guard $ conf || build || pid - pure d - - -- | Use XDG directories as a fallback - xdgDir :: IO String - xdgDir = do - d <- getXdgDirectory XdgData "xmonad" - d <$ createDirectoryIfMissing True d - - -newShutdownEventHandler :: IO (Event -> X All) -newShutdownEventHandler = do - writeProcessIDToFile - return handleShutdownEvent - -handleShutdownEvent :: Event -> X All -handleShutdownEvent = \case - ClientMessageEvent { ev_message_type = mt } -> do - isShutdownEvent <- (mt ==) <$> getAtom "XMONAD_SHUTDOWN" - when isShutdownEvent $ do - broadcastMessage ReleaseResources - writeStateToFile - io exitSuccess >> return () - return (All (not isShutdownEvent)) - _ -> - return (All True) - -sendShutdownEvent :: IO () -sendShutdownEvent = do - dpy <- openDisplay "" - rw <- rootWindow dpy $ defaultScreen dpy - a <- internAtom dpy "XMONAD_SHUTDOWN" False - allocaXEvent $ \e -> do - setEventType e clientMessage - setClientMessageEvent e rw a 32 0 currentTime - sendEvent dpy rw False structureNotifyMask e - sync dpy False - -shutdown :: IO () -shutdown = do - pid <- readProcessIDFromFile - sendShutdownEvent - hPutStrLn stderr ("waiting for: " <> show pid) - result <- tryIOError (waitProcess pid) - if isSuccess result - then hPutStrLn stderr ("result: " <> show result <> " [AKA success^_^]") - else hPutStrLn stderr ("result: " <> show result) - where - isSuccess = either isDoesNotExistError (const False) - -waitProcess :: ProcessID -> IO () -waitProcess pid = forever (signalProcess nullSignal pid >> threadDelay 10000) - --- --- PID file stuff --- - -getProcessIDFileName :: IO FilePath -getProcessIDFileName = (</> "xmonad.pid") <$> getXMonadDataDir - -writeProcessIDToFile :: IO () -writeProcessIDToFile = do - pidFileName <- getProcessIDFileName - pid <- getProcessID - writeFile pidFileName (show pid) - -readProcessIDFromFile :: IO ProcessID -readPro |