summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tv/1systems/au/config.nix1
-rw-r--r--tv/2configs/default.nix7
-rw-r--r--tv/2configs/ppp.nix78
-rw-r--r--tv/2configs/xserver/default.nix15
-rw-r--r--tv/5pkgs/haskell/th-env/default.nix10
-rw-r--r--tv/5pkgs/haskell/th-env/src/THEnv.hs49
-rw-r--r--tv/5pkgs/haskell/th-env/th-env.cabal20
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/default.nix9
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs18
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/main.hs21
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal7
-rw-r--r--tv/5pkgs/simple/viljetic-pages/default.nix1
-rw-r--r--tv/5pkgs/vim/nix.nix3
-rw-r--r--tv/dummy_secrets/o2.pin1
14 files changed, 211 insertions, 29 deletions
diff --git a/tv/1systems/au/config.nix b/tv/1systems/au/config.nix
index fc4b216f5..3891b7570 100644
--- a/tv/1systems/au/config.nix
+++ b/tv/1systems/au/config.nix
@@ -3,6 +3,7 @@
./disks.nix
<stockholm/tv>
<stockholm/tv/2configs/hw/x220.nix>
+ <stockholm/tv/2configs/ppp.nix>
<stockholm/tv/2configs/retiolum.nix>
];
diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix
index 9db35184a..2d813fe32 100644
--- a/tv/2configs/default.nix
+++ b/tv/2configs/default.nix
@@ -1,7 +1,7 @@
with import <stockholm/lib>;
{ config, pkgs, ... }: {
- boot.kernelPackages = pkgs.linuxPackages_latest;
+ boot.kernelPackages = mkDefault pkgs.linuxPackages_latest;
boot.tmpOnTmpfs = true;
@@ -68,18 +68,13 @@ with import <stockholm/lib>;
];
environment.shellAliases = mkForce {
- # alias cal='cal -m3'
gp = "${pkgs.pari}/bin/gp -q";
df = "df -h";
du = "du -h";
- # alias grep='grep --color=auto'
# TODO alias cannot contain #\'
# "ps?" = "ps ax | head -n 1;ps ax | fgrep -v ' grep --color=auto ' | grep";
- # alias la='ls -lA'
- lAtr = "ls -lAtr";
- # alias ll='ls -l'
ls = "ls -h --color=auto --group-directories-first";
dmesg = "dmesg -L --reltime";
view = "vim -R";
diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix
index 9cc7568a5..ff61f943f 100644
--- a/tv/2configs/ppp.nix
+++ b/tv/2configs/ppp.nix
@@ -1,9 +1,25 @@
-{ pkgs, ... }: {
-
- # usage: pppd call default
-
- environment.etc."ppp/peers/default".text = ''
- /dev/ttyACM2
+{ config, pkgs, ... }: let
+ lib = import <stockholm/lib>;
+ cfg = {
+ pin = "@${toString <secrets/o2.pin>}";
+ ttys.ppp = "/dev/ttyACM0";
+ ttys.com = "/dev/ttyACM1";
+ };
+in {
+ assertions = [
+ {
+ assertion = config.networking.resolvconf.enable;
+ message = "ppp configuration needs resolvconf";
+ }
+ ];
+ environment.etc."ppp/ip-up".source = pkgs.writeDash "ppp.ip-up" ''
+ ${pkgs.openresolv}/bin/resolvconf -a "$IFNAME" < /etc/ppp/resolv.conf
+ '';
+ environment.etc."ppp/ip-down".source = pkgs.writeDash "ppp.ip-down" ''
+ ${pkgs.openresolv}/bin/resolvconf -fd "$IFNAME"
+ '';
+ environment.etc."ppp/peers/o2".text = /* sh */ ''
+ ${cfg.ttys.ppp}
921600
crtscts
defaultroute
@@ -16,17 +32,53 @@
passive
persist
usepeerdns
- connect "${pkgs.ppp}/bin/chat -f ${pkgs.writeText "default.chat" ''
+ connect "${pkgs.ppp}/bin/chat ''${DEBUG+-v} -Ss -f ${pkgs.writeText "o2.chat" /* sh */ ''
ABORT "BUSY"
ABORT "NO CARRIER"
REPORT CONNECT
- "" "ATDT*99#"
- CONNECT
+ "*EMRDY: 1"
+ ATZ OK
+ AT+CFUN=1 OK
+ ${cfg.pin} TIMEOUT 2 ERROR-AT-OK
+ AT+CGDCONT=1,\042IP\042,\042internet\042 OK
+ ATDT*99***1# CONNECT
''}"
'';
-
- environment.systemPackages = [
- pkgs.ppp
+ users.users.root.packages = [
+ (pkgs.writeDashBin "connect" ''
+ # usage:
+ # connect wlan
+ # connect wwan [PEERNAME]
+ set -efu
+ rfkill_wlan=/sys/class/rfkill/rfkill2
+ rfkill_wwan=/sys/class/rfkill/rfkill1
+ case $1 in
+ wlan)
+ ${pkgs.procps}/bin/pkill pppd || :
+ echo 0 > "$rfkill_wwan"/state
+ echo 1 > "$rfkill_wlan"/state
+ ;;
+ wwan)
+ name=''${2-o2}
+ echo 0 > "$rfkill_wlan"/state
+ echo 1 > "$rfkill_wwan"/state
+ ${pkgs.ppp}/bin/pppd call "$name" updetach
+ ;;
+ *)
+ echo "$0: error: bad arguments: $*" >&2
+ exit 1
+ esac
+ '')
+ (pkgs.writeDashBin "modem-send" ''
+ # usage: modem-send ATCOMMAND
+ set -efu
+ tty=${lib.shell.escape cfg.ttys.com}
+ exec <"$tty"
+ printf '%s\r\n' "$1" >"$tty"
+ ${pkgs.gnused}/bin/sed -E '
+ /^OK\r?$/q
+ /^ERROR\r?$/q
+ '
+ '')
];
-
}
diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix
index 4e9e30741..032df5d90 100644
--- a/tv/2configs/xserver/default.nix
+++ b/tv/2configs/xserver/default.nix
@@ -6,6 +6,19 @@ let
configDir = "/var/empty";
dataDir = "/run/xdg/${cfg.user.name}/xmonad";
user = config.krebs.build.user;
+ xmonad.pkg = pkgs.haskellPackages.xmonad-tv.overrideAttrs (_: {
+ au = {
+ XMONAD_BUILD_SCREEN_WIDTH = 1920;
+ XMONAD_BUILD_TERM_FONT_WIDTH = 10;
+ XMONAD_BUILD_TERM_FONT = "xft:Input Mono:size=12:style=Regular";
+ XMONAD_BUILD_TERM_PADDING = 2;
+ };
+ }.${config.krebs.build.host.name} or {
+ XMONAD_BUILD_SCREEN_WIDTH = 1366;
+ XMONAD_BUILD_TERM_FONT_WIDTH = 6;
+ XMONAD_BUILD_TERM_FONT = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1";
+ XMONAD_BUILD_TERM_PADDING = 2;
+ });
};
in {
@@ -51,7 +64,7 @@ in {
systemd.services.display-manager.enable = false;
systemd.services.xmonad = let
- xmonad = "${pkgs.haskellPackages.xmonad-tv}/bin/xmonad";
+ xmonad = "${cfg.xmonad.pkg}/bin/xmonad";
xmonad-start = pkgs.writeDash "xmonad-start" ''
${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR"
${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR"
diff --git a/tv/5pkgs/haskell/th-env/default.nix b/tv/5pkgs/haskell/th-env/default.nix
new file mode 100644
index 000000000..474a63b85
--- /dev/null
+++ b/tv/5pkgs/haskell/th-env/default.nix
@@ -0,0 +1,10 @@
+{ mkDerivation, base, stdenv, 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 = stdenv.lib.platforms.none;
+}
diff --git a/tv/5pkgs/haskell/th-env/src/THEnv.hs b/tv/5pkgs/haskell/th-env/src/THEnv.hs
new file mode 100644
index 000000000..b04f2ce0b
--- /dev/null
+++ b/tv/5pkgs/haskell/th-env/src/THEnv.hs
@@ -0,0 +1,49 @@
+{-# 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
new file mode 100644
index 000000000..b9a2cff39
--- /dev/null
+++ b/tv/5pkgs/haskell/th-env/th-env.cabal
@@ -0,0 +1,20 @@
+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
index 42eb13d41..36dffaa13 100644
--- a/tv/5pkgs/haskell/xmonad-tv/default.nix
+++ b/tv/5pkgs/haskell/xmonad-tv/default.nix
@@ -1,5 +1,6 @@
-{ mkDerivation, base, containers, directory, extra, stdenv, unix
-, X11, xmonad, xmonad-contrib, xmonad-stockholm
+{ mkDerivation, aeson, base, bytestring, containers, directory
+, extra, stdenv, template-haskell, th-env, unix, X11, xmonad
+, xmonad-contrib, xmonad-stockholm
}:
mkDerivation {
pname = "xmonad-tv";
@@ -8,8 +9,8 @@ mkDerivation {
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [
- base containers directory extra unix X11 xmonad xmonad-contrib
- xmonad-stockholm
+ aeson base bytestring containers directory extra template-haskell
+ th-env unix X11 xmonad xmonad-contrib xmonad-stockholm
];
license = stdenv.lib.licenses.mit;
}
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs b/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
new file mode 100644
index 000000000..2a3a0e523
--- /dev/null
+++ b/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module THEnv.JSON where
+
+import Data.Aeson (eitherDecode,FromJSON)
+import Data.ByteString.Lazy.Char8 (pack)
+import Language.Haskell.TH.Syntax (Exp,Lift(lift),Q)
+import THEnv (getCompileEnv)
+import Control.Monad
+
+getCompileEnvJSON :: (FromJSON a) => String -> Q a
+getCompileEnvJSON name =
+ either error (id :: a -> a) . eitherDecode . pack <$> getCompileEnv name
+
+getCompileEnvJSONExp ::
+ forall proxy a. (FromJSON a, Lift a) => proxy a -> String -> Q Exp
+getCompileEnvJSONExp _ =
+ (lift :: a -> Q Exp) <=< getCompileEnvJSON
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs
index c83b411bd..b8ddd27e8 100644
--- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs
+++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs
@@ -1,4 +1,6 @@
{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TypeApplications #-}
module Main (main) where
@@ -32,10 +34,23 @@ import XMonad.Stockholm.Pager
import XMonad.Stockholm.Shutdown
import qualified Paths
+import THEnv.JSON (getCompileEnvJSONExp)
+
myFont :: String
myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*"
+myScreenWidth :: Dimension
+myScreenWidth =
+ $(getCompileEnvJSONExp (id @Dimension) "XMONAD_BUILD_SCREEN_WIDTH")
+
+myTermFontWidth :: Dimension
+myTermFontWidth =
+ $(getCompileEnvJSONExp (id @Dimension) "XMONAD_BUILD_TERM_FONT_WIDTH")
+
+myTermPadding :: Dimension
+myTermPadding = 2
+
main :: IO ()
main = getArgs >>= \case
@@ -46,7 +61,6 @@ main = getArgs >>= \case
mainNoArgs :: IO ()
mainNoArgs = do
- let width = 1366
workspaces0 <- getWorkspaces0
handleShutdownEvent <- newShutdownEventHandler
launch
@@ -60,8 +74,9 @@ mainNoArgs = do
smartBorders $
ResizableTall
1
- (10 * 6 / width)
- ((80 * 6 + 2 * (1+1+1))/width) []
+ (fromIntegral (10 * myTermFontWidth) / fromIntegral myScreenWidth)
+ (fromIntegral (80 * myTermFontWidth + 2 * (myTermPadding + borderWidth def)) / fromIntegral myScreenWidth)
+ []
|||
Full
, manageHook =
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal
index f10bc4aeb..d07e2b159 100644
--- a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal
+++ b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal
@@ -9,10 +9,14 @@ cabal-version: >=1.10
executable xmonad
main-is: main.hs
build-depends:
+ aeson,
base,
+ bytestring,
containers,
directory,
extra,
+ template-haskell,
+ th-env,
unix,
X11,
xmonad,
@@ -20,6 +24,7 @@ executable xmonad
xmonad-stockholm
other-modules:
Helpers.Path,
- Paths
+ Paths,
+ THEnv.JSON
default-language: Haskell2010
ghc-options: -O2 -Wall -threaded
diff --git a/tv/5pkgs/simple/viljetic-pages/default.nix b/tv/5pkgs/simple/viljetic-pages/default.nix
index 1ae55cca7..ee07c9277 100644
--- a/tv/5pkgs/simple/viljetic-pages/default.nix
+++ b/tv/5pkgs/simple/viljetic-pages/default.nix
@@ -11,6 +11,7 @@ stdenv.mkDerivation {
installPhase = ''
mkdir -p $out
cp ${./index.html} $out/index.html
+ convert ${./logo.xpm} $out/favicon.ico
convert ${./logo.xpm} $out/favicon2.png
'';
}
diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix
index 4f3f83aaa..c121d815f 100644
--- a/tv/5pkgs/vim/nix.nix
+++ b/tv/5pkgs/vim/nix.nix
@@ -133,8 +133,9 @@ with import <stockholm/lib>;
(writer "Jq")
(writerExt "jq")
];
- javascript.extraStart = comment "jq";
+ javascript.extraStart = comment "js";
lua = {};
+ markdown.extraStart = writerExt "md";
#nginx = {};
python.extraStart = alts [
(comment "py")
diff --git a/tv/dummy_secrets/o2.pin b/tv/dummy_secrets/o2.pin
new file mode 100644
index 000000000..53a3137cd
--- /dev/null
+++ b/tv/dummy_secrets/o2.pin
@@ -0,0 +1 @@
+AT