From 1514c30e46768eb978996660ad46ca8e48cef5b7 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 15 May 2021 15:27:19 +0200 Subject: ... --- accounts/gkleen@sif/default.nix | 2 -- accounts/gkleen@sif/emacs.el | 25 +++++++++++++++++++++- accounts/gkleen@sif/ssh-hosts.nix | 16 ++++++++++++++ .../gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs | 5 ++++- accounts/gkleen@sif/xmonad/xmonad.hs | 14 +++++++----- 5 files changed, 53 insertions(+), 9 deletions(-) (limited to 'accounts/gkleen@sif') diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 5ee7845d..676c12a3 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -242,8 +242,6 @@ in { extraProfileCommands = '' export XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}''${XDG_DATA_DIRS:+:''${XDG_DATA_DIRS}}" ''; - - stateVersion = "20.03"; }; fonts.fontconfig.enable = true; diff --git a/accounts/gkleen@sif/emacs.el b/accounts/gkleen@sif/emacs.el index c8356bf2..b22c00f5 100644 --- a/accounts/gkleen@sif/emacs.el +++ b/accounts/gkleen@sif/emacs.el @@ -68,7 +68,7 @@ (setq undo-tree-auto-save-history t) -(defvar expand-file-name-custom-tilde-alist '()) +(defvar expand-file-name-custom-tilde-alist '(("u2w-dev1" . "/ssh:uni2work-dev1:/home/gkleen/projects/uni2work"))) (defun my/add-to-tilde-alist (hash) (let* ((tilde:dir (split-string hash "=")) (tilde (car tilde:dir)) @@ -128,6 +128,29 @@ (setq ido-everywhere t) (ido-mode 1) +(setq tramp-default-method "ssh") +(customize-set-variable 'tramp-use-ssh-controlmaster-options nil) + +(setq direnv-enabled-hosts '("uni2work-dev1")) + +(defun tramp-sh-handle-start-file-process@my-direnv (args) + "Enable Direnv for hosts in `direnv-enabled-hosts'." + (with-parsed-tramp-file-name (expand-file-name default-directory) nil + (if (member host direnv-enabled-hosts) + (pcase-let ((`(,name ,buffer ,program . ,args) args)) + `(,name + ,buffer + "direnv" + "exec" + ,localname + ,program + ,@args)) + args))) + +(with-eval-after-load "tramp-sh" + (advice-add 'tramp-sh-handle-start-file-process + :filter-args #'tramp-sh-handle-start-file-process@my-direnv)) + (setq mail-host-address "sif.midgard.yggdrasil") (setq user-full-name "Gregor Kleen") diff --git a/accounts/gkleen@sif/ssh-hosts.nix b/accounts/gkleen@sif/ssh-hosts.nix index 0db4e342..d47410f4 100644 --- a/accounts/gkleen@sif/ssh-hosts.nix +++ b/accounts/gkleen@sif/ssh-hosts.nix @@ -91,6 +91,11 @@ user = "root"; identityFile = "~/.ssh/uni2work"; }; + "jump.uniworx4" = + { hostname = "uniworx4.ifi.lmu.de"; + user = "sshjump"; + identityFile = "~/.ssh/sshjump.uni2work"; + }; "uni2workgw" = { hostname = "uni2workgw.ifi.lmu.de"; user = "root"; @@ -206,4 +211,15 @@ user = "git"; identityFile = "~/.ssh/gkleen@gitlab.lrz.de"; }; + "uni2work-dev1" = + { hostname = "uni2work-dev1.ifi.lmu.de"; + user = "gkleen"; + identityFile = "~/.ssh/uni2work"; + proxyJump = "jump.uniworx4"; + localForwards = [ + { bind = { address = "localhost"; port = 3940; }; + host = { address = "localhost"; port = 3940; }; + } + ]; + }; } diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs index c85d0f92..729941aa 100644 --- a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs +++ b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs @@ -80,9 +80,12 @@ moshCmd' p c = concat , " -- " , cCommand c ] -inTmux c +inTmux Nothing c | null $ cCommand c = c { cCommand = "tmux new-session" } | otherwise = c { cCommand = "tmux new-session \"" ++ (cCommand c) ++ "\"" } +inTmux (Just h) c + | null $ cCommand c = c { cCommand = "tmux new-session -As " <> h } + | otherwise = c { cCommand = "tmux new-session \"" ++ (cCommand c) ++ "\"" } withEnv :: [(String, String)] -> Conn -> Conn withEnv envs c = c { cCommand = "env" ++ (concat $ map (\(n, v) -> ' ' : (n ++ "=" ++ v)) envs) ++ " " ++ (cCommand c) } diff --git a/accounts/gkleen@sif/xmonad/xmonad.hs b/accounts/gkleen@sif/xmonad/xmonad.hs index 8282ed3f..3bf930c0 100644 --- a/accounts/gkleen@sif/xmonad/xmonad.hs +++ b/accounts/gkleen@sif/xmonad/xmonad.hs @@ -680,7 +680,7 @@ xPConfig = def , position = Top } -sshOverrides = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux } ) +sshOverrides host = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux host} ) [ "odin", "odin.asgard.yggdrasil" , "ymir", "ymir.yggdrasil.li", "ymir.niflheim.yggdrasil" @@ -691,13 +691,17 @@ sshOverrides = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux } , "testworx" ] ++ - map (\h -> mkOverride { oHost = h, oCommand = moshCmd' "/run/current-system/sw/bin/mosh-server" . withEnv [("TERM", "xterm")] . inTmux} ) + map (\h -> mkOverride { oHost = h, oCommand = moshCmd' "/run/current-system/sw/bin/mosh-server" . withEnv [("TERM", "xterm")] . inTmux host} ) [ "bragi", "bragi.asgard.yggdrasil" ] ++ - map (\h -> mkOverride { oHost = h, oCommand = sshCmd . withEnv [("TERM", "xterm")] . inTmux } ) + map (\h -> mkOverride { oHost = h, oCommand = sshCmd . inTmux host } ) + [ "uni2work-dev1" + ] + ++ + map (\h -> mkOverride { oHost = h, oCommand = sshCmd . withEnv [("TERM", "xterm")] . inTmux host } ) [ "remote.cip.ifi.lmu.de" - , "uniworx3", "uniworx4", "uniworxdb" + , "uniworx3", "uniworx4", "uniworx5", "uniworxdb2" ] backlight :: (Rational -> Rational) -> X () @@ -769,7 +773,7 @@ myKeys' conf host = Map.fromList $ --, ((modm, xK_d ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"") , ((modm, xK_d ), shellPrompt "Run: " xPConfig) , ((modm .|. shiftMask, xK_d ), prompt "Run in Terminal: " ("urxvtc" ++ " -e") xPConfig) - , ((modm, xK_at ), sshPrompt sshOverrides xPConfig) + , ((modm, xK_at ), sshPrompt (sshOverrides . Just $ hName host) xPConfig) -- close focused window , ((modm .|. shiftMask, xK_q ), kill) -- cgit v1.2.3