From 5691537512d24aa542c7ae2d9225c46712e1e811 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 May 2016 22:46:41 +0200 Subject: l 2 websites fritz: prefix www. everywhere --- lass/2configs/websites/fritz.nix | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lass/2configs/websites/fritz.nix b/lass/2configs/websites/fritz.nix index e35615040..4b539bc10 100644 --- a/lass/2configs/websites/fritz.nix +++ b/lass/2configs/websites/fritz.nix @@ -13,26 +13,26 @@ in { ( manageCerts [ "biostase.de" "www.biostase.de" ]) #( serveWordpress [ "biostase.de" "www.biostase.de" ]) - ( manageCerts [ "radical-dreamers.de" ]) - ( serveWordpress [ "radical-dreamers.de" ]) + ( manageCerts [ "radical-dreamers.de" "www.radical-dreamers.de" ]) + ( serveWordpress [ "radical-dreamers.de" "www.radical-dreamers.de" ]) - ( manageCerts [ "gs-maubach.de" ]) - ( serveWordpress [ "gs-maubach.de" ]) + ( manageCerts [ "gs-maubach.de" "www.gs-maubach.de" ]) + ( serveWordpress [ "gs-maubach.de" "www.gs-maubach.de" ]) - ( manageCerts [ "spielwaren-kern.de" ]) - ( serveWordpress [ "spielwaren-kern.de" ]) + ( manageCerts [ "spielwaren-kern.de" "www.spielwaren-kern.de" ]) + ( serveWordpress [ "spielwaren-kern.de" "www.spielwaren-kern.de" ]) - ( manageCerts [ "familienpraxis-korntal.de" ]) - ( servePage [ "familienpraxis-korntal.de" ]) + ( manageCerts [ "familienpraxis-korntal.de" "www.familienpraxis-korntal.de" ]) + ( servePage [ "familienpraxis-korntal.de" "www.familienpraxis-korntal.de" ]) - ( manageCerts [ "ttf-kleinaspach.de" ]) - ( serveWordpress [ "ttf-kleinaspach.de" ]) + ( manageCerts [ "ttf-kleinaspach.de" "www.ttf-kleinaspach.de" ]) + ( serveWordpress [ "ttf-kleinaspach.de" "www.ttf-kleinaspach.de" ]) - ( ssl [ "eastuttgart.de" ]) - ( serveWordpress [ "eastuttgart.de" ]) + ( ssl [ "eastuttgart.de" "www.eastuttgart.de" ]) + ( serveWordpress [ "eastuttgart.de" "www.eastuttgart.de" ]) - ( ssl [ "habsys.de" "habsys.eu" ]) - ( servePage [ "habsys.de" "habsys.eu" ]) + ( ssl [ "www.habsys.de" "habsys.de" "www.habsys.eu" "habsys.eu" ]) + ( servePage [ "www.habsys.de" "habsys.de" "www.habsys.eu" "habsys.eu" ]) ]; services.mysql = { -- cgit v1.2.3 From 48502fb07e2f3c1adfe098179172d3d43fed3cba Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 May 2016 23:19:43 +0200 Subject: k 3 l: add fritz pubkey --- krebs/3modules/lass/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 03e067f35..65da85ac4 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -311,5 +311,8 @@ with config.krebs.lib; pubkey = builtins.readFile ./ssh/shodan.rsa; pgp.pubkeys.default = builtins.readFile ./pgp/shodan.pgp; }; + fritz = { + pubkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCz34435NSXgj72YAOL4cIlRq/4yInKEyL9no+gymURoW5x1nkYpP0EK331e7UyQQSOdWOogRo6d7YHcFqNlYWv5xlYcHucIhgJwC4Zda1liVA+v7tSOJz2BjmFvOT3/qlcPS69f3zdLHZooz2C33uHX1FgGRXlxiA8dpqGnSr8o76QLZjuQkuDqr8reOspjO/RHCo2Moq0Xm5q9OgN1WLAZzupqt9A5lx567mRzYsRAr23pUxVN8T/tSCgDlPe4ktEjYX9CXLKfMyh9WuBVi+AuH4GFEWBT+AMpsHeF45w+w956x56mz0F5nYOQNK87gFr+Jr+mh2AF1ot2CxzrfTb fritz@scriptkiddiT540"; + }; }; } -- cgit v1.2.3 From f1cbe54717e4f8f1b648e22f644a32f1b9abf82a Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 May 2016 23:20:11 +0200 Subject: l 2 websites fritz: serve biostase.de --- lass/2configs/websites/fritz.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lass/2configs/websites/fritz.nix b/lass/2configs/websites/fritz.nix index 4b539bc10..5ce2887c4 100644 --- a/lass/2configs/websites/fritz.nix +++ b/lass/2configs/websites/fritz.nix @@ -11,7 +11,7 @@ let in { imports = [ ( manageCerts [ "biostase.de" "www.biostase.de" ]) - #( serveWordpress [ "biostase.de" "www.biostase.de" ]) + ( serveWordpress [ "biostase.de" "www.biostase.de" ]) ( manageCerts [ "radical-dreamers.de" "www.radical-dreamers.de" ]) ( serveWordpress [ "radical-dreamers.de" "www.radical-dreamers.de" ]) -- cgit v1.2.3 From 5b4333f2a72b167d7640f15c68e3bbb0aab7809d Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 May 2016 23:21:43 +0200 Subject: l 2 websites fritz: add fritz root authorizedKeys --- lass/2configs/websites/fritz.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lass/2configs/websites/fritz.nix b/lass/2configs/websites/fritz.nix index 5ce2887c4..b0473c2ff 100644 --- a/lass/2configs/websites/fritz.nix +++ b/lass/2configs/websites/fritz.nix @@ -54,4 +54,7 @@ in { ]; }; }; + users.users.root.openssh.authorizedKeys.keys = [ + config.krebs.users.fritz.pubkey + ]; } -- cgit v1.2.3 From 3ae4e25a1b2af518df6ccaab18703163bd37f51f Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 May 2016 23:54:36 +0200 Subject: l 1 mors: dont import texlive --- lass/1systems/mors.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index e2ab562fa..27548c9b7 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -14,7 +14,7 @@ ../2configs/elster.nix ../2configs/steam.nix ../2configs/wine.nix - ../2configs/texlive.nix + #../2configs/texlive.nix ../2configs/binary-caches.nix #../2configs/ircd.nix ../2configs/chromium-patched.nix -- cgit v1.2.3 From ac4f86e40f99f4e39c538cef2641b99663774bfd Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 May 2016 23:54:55 +0200 Subject: l 1 mors: reactivate sna --- lass/1systems/mors.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index 27548c9b7..776bc54c9 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -175,14 +175,14 @@ emulateWheel = true; }; - #services.xserver = { - # videoDriver = "intel"; - # vaapiDrivers = [ pkgs.vaapiIntel ]; - # deviceSection = '' - # Option "AccelMethod" "sna" - # BusID "PCI:0:2:0" - # ''; - #}; + services.xserver = { + videoDriver = "intel"; + vaapiDrivers = [ pkgs.vaapiIntel ]; + deviceSection = '' + Option "AccelMethod" "sna" + BusID "PCI:0:2:0" + ''; + }; environment.systemPackages = with pkgs; [ acronym -- cgit v1.2.3 From 0f2fc7c4a6a9bb41b965c905949aefebbb6c3f49 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 May 2016 23:55:11 +0200 Subject: l 1 prism: serve wallpaper.png under lassul.us --- lass/1systems/prism.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lass/1systems/prism.nix b/lass/1systems/prism.nix index aa524720d..b9542bc8e 100644 --- a/lass/1systems/prism.nix +++ b/lass/1systems/prism.nix @@ -196,6 +196,16 @@ in { { predicate = "-p tcp --dport xmpp-server"; target = "ACCEPT"; } ]; } + { + imports = [ + ../2configs/realwallpaper-server.nix + ]; + krebs.nginx.servers."lassul.us".locations = [ + (lib.nameValuePair "/wallpaper.png" '' + alias /tmp/wallpaper.png; + '') + ]; + } ]; krebs.build.host = config.krebs.hosts.prism; -- cgit v1.2.3 From 0d8a0ed71d370455f192efea903e96b01ab86e25 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:08:34 +0200 Subject: writeHaskellBin: init --- krebs/5pkgs/builders.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix index 19169b186..8506801bb 100644 --- a/krebs/5pkgs/builders.nix +++ b/krebs/5pkgs/builders.nix @@ -66,6 +66,46 @@ rec { mv "$textPath" $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 = name: path: pkgs.runCommand name {} '' ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out ''; -- cgit v1.2.3 From 2b71d7f72865215717a2c604cb391f87af73c0a9 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:28:09 +0200 Subject: writeNixFromCabal: deprecate --- krebs/5pkgs/builders.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix index 8506801bb..39b91d144 100644 --- a/krebs/5pkgs/builders.nix +++ b/krebs/5pkgs/builders.nix @@ -106,7 +106,12 @@ rec { ''; }; - writeNixFromCabal = name: path: pkgs.runCommand name {} '' - ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out - ''; + writeNixFromCabal = + trace (toString [ + "The function `writeNixFromCabal` has been deprecated in favour of" + "`writeHaskellBin'." + ]) + (name: path: pkgs.runCommand name {} '' + ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out + ''); } -- cgit v1.2.3 From 37ee40759f1e6feda51fb36dd3c951b4f3045944 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:31:49 +0200 Subject: xmonad-tv: convert to writeHaskellBin --- tv/2configs/xserver/default.nix | 4 +- tv/5pkgs/default.nix | 4 +- tv/5pkgs/xmonad-tv.nix | 292 ++++++++++++++++++++++++++++++++++++++++ tv/5pkgs/xmonad-tv/.gitignore | 1 - tv/5pkgs/xmonad-tv/Main.hs | 280 -------------------------------------- tv/5pkgs/xmonad-tv/Makefile | 6 - tv/5pkgs/xmonad-tv/xmonad.cabal | 18 --- 7 files changed, 295 insertions(+), 310 deletions(-) create mode 100644 tv/5pkgs/xmonad-tv.nix delete mode 100644 tv/5pkgs/xmonad-tv/.gitignore delete mode 100644 tv/5pkgs/xmonad-tv/Main.hs delete mode 100644 tv/5pkgs/xmonad-tv/Makefile delete mode 100644 tv/5pkgs/xmonad-tv/xmonad.cabal diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 4b936f473..08b69067c 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -116,12 +116,12 @@ let 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 + exec ${pkgs.xmonad-tv}/bin/xmonad-tv ''; xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' #! /bin/sh - exec ${pkgs.xmonad-tv}/bin/xmonad --shutdown + exec ${pkgs.xmonad-tv}/bin/xmonad-tv --shutdown ''; xserver-environment = { 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.nix b/tv/5pkgs/xmonad-tv.nix new file mode 100644 index 000000000..086fd911e --- /dev/null +++ b/tv/5pkgs/xmonad-tv.nix @@ -0,0 +1,292 @@ +{ pkgs, ... }: +pkgs.writeHaskellBin "xmonad-tv" { + depends = [ + "containers" + "unix" + "X11" + "xmonad" + "xmonad-contrib" + "xmonad-stockholm" + ]; +} '' +{-# LANGUAGE DeriveDataTypeable #-} -- for XS +{-# LANGUAGE FlexibleContexts #-} -- for xmonad' +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE ScopedTypeVariables #-} + + +module Main where + +import Control.Exception +import Graphics.X11.ExtraTypes.XF86 +import Text.Read (readEither) +import XMonad +import System.IO (hPutStrLn, stderr) +import System.Environment (getArgs, withArgs, getEnv, getEnvironment) +import System.Posix.Process (executeFile) +import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace + , removeEmptyWorkspace) +import XMonad.Actions.GridSelect +import XMonad.Actions.CycleWS (toggleWS) +--import XMonad.Actions.CopyWindow ( copy ) +import XMonad.Layout.NoBorders ( smartBorders ) +import qualified XMonad.StackSet as W +import Data.Map (Map) +import qualified Data.Map as Map +-- TODO import XMonad.Layout.WorkspaceDir +import XMonad.Hooks.UrgencyHook (SpawnUrgencyHook(..), withUrgencyHook) +-- import XMonad.Layout.Tabbed +--import XMonad.Layout.MouseResizableTile +import XMonad.Layout.Reflect (reflectVert) +import XMonad.Layout.FixedColumn (FixedColumn(..)) +import XMonad.Hooks.Place (placeHook, smart) +import XMonad.Hooks.FloatNext (floatNextHook) +import XMonad.Actions.PerWorkspaceKeys (chooseAction) +import XMonad.Layout.PerWorkspace (onWorkspace) +--import XMonad.Layout.BinarySpacePartition + +--import XMonad.Actions.Submap +import XMonad.Stockholm.Pager +import XMonad.Stockholm.Rhombus +import XMonad.Stockholm.Shutdown + + +myTerm :: String +myTerm = "urxvtc" + +myRootTerm :: String +myRootTerm = "urxvtc -name root-urxvt -e su -" + +myFont :: String +myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" + +main :: IO () +main = getArgs >>= \case + ["--shutdown"] -> sendShutdownEvent + _ -> mainNoArgs + +mainNoArgs :: IO () +mainNoArgs = do + workspaces0 <- getWorkspaces0 + xmonad' + -- $ withUrgencyHookC dzenUrgencyHook { args = ["-bg", "magenta", "-fg", "magenta", "-h", "2"], duration = 500000 } + -- urgencyConfig { remindWhen = Every 1 } + -- $ withUrgencyHook borderUrgencyHook "magenta" + -- $ withUrgencyHookC BorderUrgencyHook { urgencyBorderColor = "magenta" } urgencyConfig { suppressWhen = Never } + $ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ") + $ def + { terminal = myTerm + , modMask = mod4Mask + , keys = myKeys + , workspaces = workspaces0 + , layoutHook = smartBorders $ myLayout + -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent + --, handleEventHook = handleTimerEvent + , manageHook = placeHook (smart (1,0)) <+> floatNextHook + , startupHook = spawn "echo emit XMonadStartup" + , normalBorderColor = "#1c1c1c" + , focusedBorderColor = "#f000b0" + , handleEventHook = handleShutdownEvent + } + where + myLayout = + (onWorkspace "im" $ reflectVert $ Mirror $ Tall 1 (3/100) (12/13)) + (FixedColumn 1 20 80 10 ||| Full) + + +xmonad' :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO () +xmonad' conf = do + path <- getEnv "XMONAD_STATE" + try (readFile path) >>= \case + Right content -> do + hPutStrLn stderr ("resuming from " ++ path) + withArgs ("--resume" : lines content) (xmonad conf) + Left e -> do + hPutStrLn stderr (displaySomeException e) + xmonad conf + +getWorkspaces0 :: IO [String] +getWorkspaces0 = + try (getEnv "XMONAD_WORKSPACES0_FILE") >>= \case + Left e -> warn (displaySomeException e) + Right p -> try (readFile p) >>= \case + Left e -> warn (displaySomeException e) + Right x -> case readEither x of + Left e -> warn e + Right y -> return y + where + warn msg = hPutStrLn stderr ("getWorkspaces0: " ++ msg) >> return [] + +displaySomeException :: SomeException -> String +displaySomeException = displayException + + +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 () + +myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) +myKeys conf = Map.fromList $ + [ ((_4 , xK_Escape ), spawn "/var/setuid-wrappers/slock") + , ((_4S , xK_c ), kill) + + , ((_4 , xK_x ), chooseAction spawnTermAt) + , ((_4C , xK_x ), spawn myRootTerm) + --, ((_4M , xK_x ), spawn "xterm") + --, ((_4M , xK_x ), mySpawn "xterm") + + --, ((_4 , xK_F1 ), withFocused jojo) + --, ((_4 , xK_F1 ), printAllGeometries) + + , ((0 , xK_Menu ), gets windowset >>= allWorkspaceNames >>= pager pagerConfig (windows . W.view) ) + , ((_S , xK_Menu ), gets windowset >>= allWorkspaceNames >>= pager pagerConfig (windows . W.shift) ) + , ((_C , xK_Menu ), toggleWS) + , ((_4 , xK_Menu ), rhombus horseConfig (liftIO . hPutStrLn stderr) ["Correct", "Horse", "Battery", "Staple", "Stuhl", "Tisch"] ) + + -- %! Rotate through the available layout algorithms + , ((_4 , xK_space ), sendMessage NextLayout) + , ((_4S , xK_space ), setLayout $ XMonad.layoutHook conf) -- reset layout + + ---- BinarySpacePartition + --, ((_4 , xK_l), sendMessage $ ExpandTowards R) + --, ((_4 , xK_h), sendMessage $ ExpandTowards L) + --, ((_4 , xK_j), sendMessage $ ExpandTowards D) + --, ((_4 , xK_k), sendMessage $ ExpandTowards U) + --, ((_4S , xK_l), sendMessage $ ShrinkFrom R) + --, ((_4S , xK_h), sendMessage $ ShrinkFrom L) + --, ((_4S , xK_j), sendMessage $ ShrinkFrom D) + --, ((_4S , xK_k), sendMessage $ ShrinkFrom U) + --, ((_4 , xK_n), sendMessage Rotate) + --, ((_4S , xK_n), sendMessage Swap) + + ---- mouseResizableTile + --, ((_4 , xK_u), sendMessage ShrinkSlave) + --, ((_4 , xK_i), sendMessage ExpandSlave) + + -- move focus up or down the window stack + --, ((_4 , xK_m ), windows W.focusMaster) + , ((_4 , xK_j ), windows W.focusDown) + , ((_4 , xK_k ), windows W.focusUp) + + -- modifying the window order + , ((_4S , xK_m ), windows W.swapMaster) + , ((_4S , xK_j ), windows W.swapDown) + , ((_4S , xK_k ), windows W.swapUp) + + -- resizing the master/slave ratio + , ((_4 , xK_h ), sendMessage Shrink) -- %! Shrink the master area + , ((_4 , xK_l ), sendMessage Expand) -- %! Expand the master area + + -- floating layer support + , ((_4 , xK_t ), withFocused $ windows . W.sink) -- make tiling + + -- increase or decrease number of windows in the master area + , ((_4 , xK_comma ), sendMessage $ IncMasterN 1) + , ((_4 , xK_period ), sendMessage $ IncMasterN (-1)) + + , ((_4 , xK_a ), addWorkspacePrompt def) + , ((_4 , xK_r ), renameWorkspace def) + , ((_4 , xK_Delete ), removeEmptyWorkspace) + + , ((_4 , xK_Return ), toggleWS) + --, (0 , xK_Menu ) & \k -> (k, gridselectWorkspace wsGSConfig { gs_navigate = makeGSNav k } W.view) + --, (_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") + ] + where + _4 = mod4Mask + _C = controlMask + _S = shiftMask + _M = mod1Mask + _4C = _4 .|. _C + _4S = _4 .|. _S + _4M = _4 .|. _M + _4CM = _4 .|. _C .|. _M + _4SM = _4 .|. _S .|. _M + + +pagerConfig :: PagerConfig +pagerConfig = def + { pc_font = myFont + , pc_cellwidth = 64 + --, pc_cellheight = 36 -- TODO automatically keep screen aspect + --, pc_borderwidth = 1 + --, pc_matchcolor = "#f0b000" + , pc_matchmethod = MatchPrefix + --, pc_colors = pagerWorkspaceColors + , pc_windowColors = windowColors + } + where + windowColors _ _ _ True _ = ("#ef4242","#ff2323") + windowColors wsf m c u wf = do + let y = defaultWindowColors wsf m c u wf + if m == False && wf == True + then ("#402020", snd y) + else y + +horseConfig :: RhombusConfig +horseConfig = def + { rc_font = myFont + , rc_cellwidth = 64 + --, rc_cellheight = 36 -- TODO automatically keep screen aspect + --, rc_borderwidth = 1 + --, rc_matchcolor = "#f0b000" + , rc_matchmethod = MatchPrefix + --, rc_colors = pagerWorkspaceColors + --, rc_paint = myPaint + } + +wGSConfig :: GSConfig Window +wGSConfig = def + { gs_cellheight = 20 + , gs_cellwidth = 192 + , gs_cellpadding = 5 + , gs_font = myFont + , gs_navigate = navNSearch + } + +-- wsGSConfig = def +-- { gs_cellheight = 20 +-- , gs_cellwidth = 64 +-- , gs_cellpadding = 5 +-- , gs_font = myFont +-- , gs_navigate = navNSearch +-- } + +-- custom navNSearch +--makeGSNav :: (KeyMask, KeySym) -> TwoD a (Maybe a) +--makeGSNav esc = nav +-- where +-- nav = makeXEventhandler $ shadowWithKeymap keyMap navNSearchDefaultHandler +-- keyMap = Map.fromList +-- [ (esc , cancel) +-- , ((0,xK_Escape) , cancel) +-- , ((0,xK_Return) , select) +-- , ((0,xK_Left) , move (-1, 0) >> nav) +-- , ((0,xK_Right) , move ( 1, 0) >> nav) +-- , ((0,xK_Down) , move ( 0, 1) >> nav) +-- , ((0,xK_Up) , move ( 0,-1) >> nav) +-- , ((0,xK_BackSpace) , transformSearchString (\s -> if (s == "") then "" else init s) >> nav) +-- ] +-- -- The navigation handler ignores unknown key symbols, therefore we const +-- navNSearchDefaultHandler (_,s,_) = do +-- transformSearchString (++ s) +-- nav + + +(&) :: a -> (a -> c) -> c +(&) = flip ($) + +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/Main.hs b/tv/5pkgs/xmonad-tv/Main.hs deleted file mode 100644 index 817d0092e..000000000 --- a/tv/5pkgs/xmonad-tv/Main.hs +++ /dev/null @@ -1,280 +0,0 @@ -{-# LANGUAGE DeriveDataTypeable #-} -- for XS -{-# LANGUAGE FlexibleContexts #-} -- for xmonad' -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE ScopedTypeVariables #-} - - -module Main where - -import Control.Exception -import Graphics.X11.ExtraTypes.XF86 -import Text.Read (readEither) -import XMonad -import System.IO (hPutStrLn, stderr) -import System.Environment (getArgs, withArgs, getEnv, getEnvironment) -import System.Posix.Process (executeFile) -import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace - , removeEmptyWorkspace) -import XMonad.Actions.GridSelect -import XMonad.Actions.CycleWS (toggleWS) ---import XMonad.Actions.CopyWindow ( copy ) -import XMonad.Layout.NoBorders ( smartBorders ) -import qualified XMonad.StackSet as W -import Data.Map (Map) -import qualified Data.Map as Map --- TODO import XMonad.Layout.WorkspaceDir -import XMonad.Hooks.UrgencyHook (SpawnUrgencyHook(..), withUrgencyHook) --- import XMonad.Layout.Tabbed ---import XMonad.Layout.MouseResizableTile -import XMonad.Layout.Reflect (reflectVert) -import XMonad.Layout.FixedColumn (FixedColumn(..)) -import XMonad.Hooks.Place (placeHook, smart) -import XMonad.Hooks.FloatNext (floatNextHook) -import XMonad.Actions.PerWorkspaceKeys (chooseAction) -import XMonad.Layout.PerWorkspace (onWorkspace) ---import XMonad.Layout.BinarySpacePartition - ---import XMonad.Actions.Submap -import XMonad.Stockholm.Pager -import XMonad.Stockholm.Rhombus -import XMonad.Stockholm.Shutdown - - -myTerm :: String -myTerm = "urxvtc" - -myRootTerm :: String -myRootTerm = "urxvtc -name root-urxvt -e su -" - -myFont :: String -myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" - -main :: IO () -main = getArgs >>= \case - ["--shutdown"] -> sendShutdownEvent - _ -> mainNoArgs - -mainNoArgs :: IO () -mainNoArgs = do - workspaces0 <- getWorkspaces0 - xmonad' - -- $ withUrgencyHookC dzenUrgencyHook { args = ["-bg", "magenta", "-fg", "magenta", "-h", "2"], duration = 500000 } - -- urgencyConfig { remindWhen = Every 1 } - -- $ withUrgencyHook borderUrgencyHook "magenta" - -- $ withUrgencyHookC BorderUrgencyHook { urgencyBorderColor = "magenta" } urgencyConfig { suppressWhen = Never } - $ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ") - $ def - { terminal = myTerm - , modMask = mod4Mask - , keys = myKeys - , workspaces = workspaces0 - , layoutHook = smartBorders $ myLayout - -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent - --, handleEventHook = handleTimerEvent - , manageHook = placeHook (smart (1,0)) <+> floatNextHook - , startupHook = spawn "echo emit XMonadStartup" - , normalBorderColor = "#1c1c1c" - , focusedBorderColor = "#f000b0" - , handleEventHook = handleShutdownEvent - } - where - myLayout = - (onWorkspace "im" $ reflectVert $ Mirror $ Tall 1 (3/100) (12/13)) - (FixedColumn 1 20 80 10 ||| Full) - - -xmonad' :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO () -xmonad' conf = do - path <- getEnv "XMONAD_STATE" - try (readFile path) >>= \case - Right content -> do - hPutStrLn stderr ("resuming from " ++ path) - withArgs ("--resume" : lines content) (xmonad conf) - Left e -> do - hPutStrLn stderr (displaySomeException e) - xmonad conf - -getWorkspaces0 :: IO [String] -getWorkspaces0 = - try (getEnv "XMONAD_WORKSPACES0_FILE") >>= \case - Left e -> warn (displaySomeException e) - Right p -> try (readFile p) >>= \case - Left e -> warn (displaySomeException e) - Right x -> case readEither x of - Left e -> warn e - Right y -> return y - where - warn msg = hPutStrLn stderr ("getWorkspaces0: " ++ msg) >> return [] - -displaySomeException :: SomeException -> String -displaySomeException = displayException - - -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 () - -myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) -myKeys conf = Map.fromList $ - [ ((_4 , xK_Escape ), spawn "/var/setuid-wrappers/slock") - , ((_4S , xK_c ), kill) - - , ((_4 , xK_x ), chooseAction spawnTermAt) - , ((_4C , xK_x ), spawn myRootTerm) - --, ((_4M , xK_x ), spawn "xterm") - --, ((_4M , xK_x ), mySpawn "xterm") - - --, ((_4 , xK_F1 ), withFocused jojo) - --, ((_4 , xK_F1 ), printAllGeometries) - - , ((0 , xK_Menu ), gets windowset >>= allWorkspaceNames >>= pager pagerConfig (windows . W.view) ) - , ((_S , xK_Menu ), gets windowset >>= allWorkspaceNames >>= pager pagerConfig (windows . W.shift) ) - , ((_C , xK_Menu ), toggleWS) - , ((_4 , xK_Menu ), rhombus horseConfig (liftIO . hPutStrLn stderr) ["Correct", "Horse", "Battery", "Staple", "Stuhl", "Tisch"] ) - - -- %! Rotate through the available layout algorithms - , ((_4 , xK_space ), sendMessage NextLayout) - , ((_4S , xK_space ), setLayout $ XMonad.layoutHook conf) -- reset layout - - ---- BinarySpacePartition - --, ((_4 , xK_l), sendMessage $ ExpandTowards R) - --, ((_4 , xK_h), sendMessage $ ExpandTowards L) - --, ((_4 , xK_j), sendMessage $ ExpandTowards D) - --, ((_4 , xK_k), sendMessage $ ExpandTowards U) - --, ((_4S , xK_l), sendMessage $ ShrinkFrom R) - --, ((_4S , xK_h), sendMessage $ ShrinkFrom L) - --, ((_4S , xK_j), sendMessage $ ShrinkFrom D) - --, ((_4S , xK_k), sendMessage $ ShrinkFrom U) - --, ((_4 , xK_n), sendMessage Rotate) - --, ((_4S , xK_n), sendMessage Swap) - - ---- mouseResizableTile - --, ((_4 , xK_u), sendMessage ShrinkSlave) - --, ((_4 , xK_i), sendMessage ExpandSlave) - - -- move focus up or down the window stack - --, ((_4 , xK_m ), windows W.focusMaster) - , ((_4 , xK_j ), windows W.focusDown) - , ((_4 , xK_k ), windows W.focusUp) - - -- modifying the window order - , ((_4S , xK_m ), windows W.swapMaster) - , ((_4S , xK_j ), windows W.swapDown) - , ((_4S , xK_k ), windows W.swapUp) - - -- resizing the master/slave ratio - , ((_4 , xK_h ), sendMessage Shrink) -- %! Shrink the master area - , ((_4 , xK_l ), sendMessage Expand) -- %! Expand the master area - - -- floating layer support - , ((_4 , xK_t ), withFocused $ windows . W.sink) -- make tiling - - -- increase or decrease number of windows in the master area - , ((_4 , xK_comma ), sendMessage $ IncMasterN 1) - , ((_4 , xK_period ), sendMessage $ IncMasterN (-1)) - - , ((_4 , xK_a ), addWorkspacePrompt def) - , ((_4 , xK_r ), renameWorkspace def) - , ((_4 , xK_Delete ), removeEmptyWorkspace) - - , ((_4 , xK_Return ), toggleWS) - --, (0 , xK_Menu ) & \k -> (k, gridselectWorkspace wsGSConfig { gs_navigate = makeGSNav k } W.view) - --, (_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") - ] - where - _4 = mod4Mask - _C = controlMask - _S = shiftMask - _M = mod1Mask - _4C = _4 .|. _C - _4S = _4 .|. _S - _4M = _4 .|. _M - _4CM = _4 .|. _C .|. _M - _4SM = _4 .|. _S .|. _M - - -pagerConfig :: PagerConfig -pagerConfig = def - { pc_font = myFont - , pc_cellwidth = 64 - --, pc_cellheight = 36 -- TODO automatically keep screen aspect - --, pc_borderwidth = 1 - --, pc_matchcolor = "#f0b000" - , pc_matchmethod = MatchPrefix - --, pc_colors = pagerWorkspaceColors - , pc_windowColors = windowColors - } - where - windowColors _ _ _ True _ = ("#ef4242","#ff2323") - windowColors wsf m c u wf = do - let y = defaultWindowColors wsf m c u wf - if m == False && wf == True - then ("#402020", snd y) - else y - -horseConfig :: RhombusConfig -horseConfig = def - { rc_font = myFont - , rc_cellwidth = 64 - --, rc_cellheight = 36 -- TODO automatically keep screen aspect - --, rc_borderwidth = 1 - --, rc_matchcolor = "#f0b000" - , rc_matchmethod = MatchPrefix - --, rc_colors = pagerWorkspaceColors - --, rc_paint = myPaint - } - -wGSConfig :: GSConfig Window -wGSConfig = def - { gs_cellheight = 20 - , gs_cellwidth = 192 - , gs_cellpadding = 5 - , gs_font = myFont - , gs_navigate = navNSearch - } - --- wsGSConfig = def --- { gs_cellheight = 20 --- , gs_cellwidth = 64 --- , gs_cellpadding = 5 --- , gs_font = myFont --- , gs_navigate = navNSearch --- } - --- custom navNSearch ---makeGSNav :: (KeyMask, KeySym) -> TwoD a (Maybe a) ---makeGSNav esc = nav --- where --- nav = makeXEventhandler $ shadowWithKeymap keyMap navNSearchDefaultHandler --- keyMap = Map.fromList --- [ (esc , cancel) --- , ((0,xK_Escape) , cancel) --- , ((0,xK_Return) , select) --- , ((0,xK_Left) , move (-1, 0) >> nav) --- , ((0,xK_Right) , move ( 1, 0) >> nav) --- , ((0,xK_Down) , move ( 0, 1) >> nav) --- , ((0,xK_Up) , move ( 0,-1) >> nav) --- , ((0,xK_BackSpace) , transformSearchString (\s -> if (s == "") then "" else init s) >> nav) --- ] --- -- The navigation handler ignores unknown key symbols, therefore we const --- navNSearchDefaultHandler (_,s,_) = do --- transformSearchString (++ s) --- nav - - -(&) :: a -> (a -> c) -> c -(&) = flip ($) - -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/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 -- cgit v1.2.3 From bd64bc1eb05cc95a32165288481d9ff9be4f33c8 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:39:17 +0200 Subject: tv nix.vim: admit Haskell comments --- tv/2configs/vim.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 6e2059484..6eefca307 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -111,6 +111,10 @@ let syn match String /"\([^\\"]\|\\.\)*"/ syn match Comment /\(^\|\s\)#.*/ + " Haskell comments + syn region Comment start=/\(^\|\s\){-#/ end=/#-}/ + syn match Comment /\(^\|\s\)--.*/ + let b:current_syntax = "nix" ''} -- cgit v1.2.3 From 00d4320545eba17227983eaa8c7578cfc5afc1e4 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:47:22 +0200 Subject: tv nix.vim: admit Vim comments --- tv/2configs/vim.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 6eefca307..10e5aab52 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -115,6 +115,9 @@ let syn region Comment start=/\(^\|\s\){-#/ end=/#-}/ syn match Comment /\(^\|\s\)--.*/ + " Vim comments + syn match Comment /\(^\|\s\)"[^"]*$/ + let b:current_syntax = "nix" ''} -- cgit v1.2.3 From 9172da3aa08672ad178128663afa4331059475ad Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 01:26:25 +0200 Subject: xmonad-tv: don't use PATH --- tv/2configs/xserver/default.nix | 5 ----- tv/5pkgs/xmonad-tv.nix | 42 ++++++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 08b69067c..51e243284 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -99,11 +99,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##*/} diff --git a/tv/5pkgs/xmonad-tv.nix b/tv/5pkgs/xmonad-tv.nix index 086fd911e..794d90688 100644 --- a/tv/5pkgs/xmonad-tv.nix +++ b/tv/5pkgs/xmonad-tv.nix @@ -51,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-*" @@ -75,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 @@ -83,7 +83,7 @@ mainNoArgs = do -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent --, handleEventHook = handleTimerEvent , manageHook = placeHook (smart (1,0)) <+> floatNextHook - , startupHook = spawn "echo emit XMonadStartup" + , startupHook = liftIO (putStrLn "emit XMonadStartup") , normalBorderColor = "#1c1c1c" , focusedBorderColor = "#f000b0" , handleEventHook = handleShutdownEvent @@ -121,24 +121,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) @@ -198,9 +204,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 @@ -213,6 +219,8 @@ myKeys conf = Map.fromList $ _4CM = _4 .|. _C .|. _M _4SM = _4 .|. _S .|. _M + amixer args = forkFile amixerPath args Nothing + pagerConfig :: PagerConfig pagerConfig = def -- cgit v1.2.3 From 73a63312255821f2b3b0315232cdd5b8ea1b994d Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 01:37:52 +0200 Subject: xmonad-tv: startupHook = $XMONAD_STARTUP_HOOK & --- tv/2configs/xserver/default.nix | 35 ++++++++++------------------------- tv/5pkgs/xmonad-tv.nix | 4 +++- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 51e243284..efc06be14 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -56,8 +56,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; }; @@ -80,6 +80,14 @@ let xmonad-environment = { DISPLAY = ":${toString config.services.xserver.display}"; + + XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-startup-hook" '' + ${pkgs.xorg.xhost}/bin/xhost +LOCAL: & + ${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,29 +104,6 @@ let ]); }; - xmonad-start = pkgs.writeScriptBin "xmonad" '' - #! ${pkgs.bash}/bin/bash - set -efu - 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-tv - ''; - - xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' - #! /bin/sh - exec ${pkgs.xmonad-tv}/bin/xmonad-tv --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. diff --git a/tv/5pkgs/xmonad-tv.nix b/tv/5pkgs/xmonad-tv.nix index 794d90688..74e43dc79 100644 --- a/tv/5pkgs/xmonad-tv.nix +++ b/tv/5pkgs/xmonad-tv.nix @@ -83,7 +83,9 @@ mainNoArgs = do -- , handleEventHook = myHandleEventHooks <+> handleTimerEvent --, handleEventHook = handleTimerEvent , manageHook = placeHook (smart (1,0)) <+> floatNextHook - , startupHook = liftIO (putStrLn "emit XMonadStartup") + , startupHook = do + path <- liftIO (getEnv "XMONAD_STARTUP_HOOK") + forkFile path [] Nothing , normalBorderColor = "#1c1c1c" , focusedBorderColor = "#f000b0" , handleEventHook = handleShutdownEvent -- cgit v1.2.3 From f48cd0f2a3b9970fee3f4100c9656e6b6b4fd6d8 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 01:50:06 +0200 Subject: tv xserver: drop wrapper --- tv/2configs/xserver/default.nix | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index efc06be14..802542020 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -73,7 +73,15 @@ 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" + ]; }; }; }; @@ -112,18 +120,6 @@ 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 -- cgit v1.2.3 From 5903c47cffee90824256994470e92d2956185e8c Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 02:36:24 +0200 Subject: tv xmodmap: init --- tv/2configs/xserver/Xmodmap.nix | 27 +++++++++++++++++++++++++++ tv/2configs/xserver/default.nix | 1 + 2 files changed, 28 insertions(+) create mode 100644 tv/2configs/xserver/Xmodmap.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 802542020..e85c07fad 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -91,6 +91,7 @@ let 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 -- cgit v1.2.3 From 82a8e7eca896c94e35de22a734d538f25e028faf Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 02:41:55 +0200 Subject: tv xserver: compress need-reload --- tv/2configs/xserver/default.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index e85c07fad..a6a820507 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -121,11 +121,9 @@ let ++ concatLists (catAttrs "libPath" config.services.xserver.drivers)); }; - 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 -- cgit v1.2.3 From 36c5834c288b56b6955e35d95708ae7f65f199f9 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 03:03:21 +0200 Subject: tv slock: user krebs.setuid --- tv/2configs/xserver/default.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index a6a820507..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; -- cgit v1.2.3 From a8691101c61969736f227cd54b7c7bbf3514f1a0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:21:38 +0200 Subject: l 2: use nixos-16.03 with new ts3 server --- lass/2configs/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lass/2configs/default.nix b/lass/2configs/default.nix index ee320b9c9..4f03748e6 100644 --- a/lass/2configs/default.nix +++ b/lass/2configs/default.nix @@ -55,8 +55,8 @@ with config.krebs.lib; #secrets-common = "/home/lass/secrets/common"; stockholm = "/home/lass/stockholm"; nixpkgs = { - url = https://github.com/NixOS/nixpkgs; - rev = "d541e0dc1c05f5514bf30f8039e687adddb45616"; + url = https://github.com/lassulus/nixpkgs; + rev = "e781dae17e5478426cc97a4ac3e520be2dd0cddd"; dev = "/home/lass/src/nixpkgs"; }; } // optionalAttrs config.krebs.build.host.secure { -- cgit v1.2.3 From 7f889eba6b086a95fc48afb56d9b09880122c74a Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:22:05 +0200 Subject: l 2 git: add the_playlist without announcement --- lass/2configs/git.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lass/2configs/git.nix b/lass/2configs/git.nix index 5cbe46351..aac3f6e02 100644 --- a/lass/2configs/git.nix +++ b/lass/2configs/git.nix @@ -37,6 +37,8 @@ let realwallpaper = {}; xmonad-stockholm = {}; the_playlist = {}; + } // mapAttrs make-public-repo-silent { + the_playlist = {}; }; restricted-repos = mapAttrs make-restricted-repo ( @@ -64,6 +66,11 @@ let }; }; + make-public-repo-silent = name: { desc ? null, ... }: { + inherit name desc; + public = true; + }; + make-restricted-repo = name: { collaborators ? [], desc ? null, ... }: { inherit name collaborators desc; public = false; -- cgit v1.2.3 From db98837af5aef7687b12ca7a8ab336a7ed2b80ed Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:22:48 +0200 Subject: l 2 radio: add and use utils --- lass/2configs/radio.nix | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 8cc2a2be7..518ab8fa5 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -1,4 +1,7 @@ { config, pkgs, ... }: + +with config.krebs.lib; + let name = "radio"; mainUser = config.users.extraUsers.mainUser; @@ -7,6 +10,20 @@ let admin-password = import ; source-password = import ; + add_random = pkgs.writeDashBin "add_random" '' + mpc add "$(mpc ls | shuf -n1)" + ''; + + skip_track = pkgs.writeDashBin "skip_track" '' + ${add_random}/bin/add_random + echo skipping: "$(${print_current}/bin/print_current)" + ${pkgs.mpc_cli}/bin/mpc -q next + ''; + + print_current = pkgs.writeDashBin "print_current" '' + ${pkgs.mpc_cli}/bin/mpc current -f %file% + ''; + in { users.users = { "${name}" = rec { @@ -28,6 +45,9 @@ in { }; krebs.per-user.${name}.packages = with pkgs; [ + add_random + skip_track + print_current ncmpcpp mpc_cli tmux @@ -100,10 +120,6 @@ in { autoAdd = pkgs.writeDash "autoAdd" '' LIMIT=$1 #in secconds - addRandom () { - mpc add "$(mpc ls | shuf -n1)" - } - timeLeft () { playlistDuration=$(mpc --format '%time%' playlist | awk -F ':' 'BEGIN{t=0} {t+=$1*60+$2} END{print t}') currentTime=$(mpc status | awk '/^\[playing\]/ { sub(/\/.+/,"",$3); split($3,a,/:/); print a[1]*60+a[2] }') @@ -111,7 +127,7 @@ in { } if test $(timeLeft) -le $LIMIT; then - addRandom + ${add_random}/bin/add_random fi ''; in { -- cgit v1.2.3 From 9a8cfe0c2183242d53207e597e9bbb3a7ba91b0b Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:24:38 +0200 Subject: l 2 radio: add Reaktor config --- lass/2configs/radio.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 518ab8fa5..99a8c0859 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -146,4 +146,23 @@ in { ExecStart = "${autoAdd} 100"; }; }; + + krebs.Reaktor = { + enable = true; + nickname = "the_playlist|r"; + channels = [ "#the_playlist" ]; + extraEnviron = { + REAKTOR_HOST = "irc.freenode.org"; + }; + plugins = with pkgs.ReaktorPlugins; [ + (buildSimpleReaktorPlugin "skip" { + script = "${skip_track}/bin/skip_track"; + pattern = "^skip$"; + }) + (buildSimpleReaktorPlugin "current" { + script = "${print_current}/bin/print_current"; + pattern = "^current$"; + }) + ]; + }; } -- cgit v1.2.3 From e7f114ae090d6d2d0b9f11f03f58797feaef016a Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:25:06 +0200 Subject: l 2 radio: add config for lassul.us/the_playlist --- lass/2configs/radio.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 99a8c0859..2d1596e3d 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -165,4 +165,29 @@ in { }) ]; }; + krebs.nginx.servers."lassul.us".locations = let + html = pkgs.writeText "index.html" '' + + + + + lassulus playlist + + +
+ +
+
+ +
+ + + + ''; + in [ + (nameValuePair "/the_playlist" '' + default_type "text/html"; + alias ${html}; + '') + ]; } -- cgit v1.2.3 From 565d06608e7eb4a51693f769e239861f48e3bf37 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:32:32 +0200 Subject: l 2 websites domsen: use old phpIni again --- lass/2configs/websites/domsen.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lass/2configs/websites/domsen.nix b/lass/2configs/websites/domsen.nix index f31fccd51..43f9b3924 100644 --- a/lass/2configs/websites/domsen.nix +++ b/lass/2configs/websites/domsen.nix @@ -79,9 +79,18 @@ in { createHome = true; }; - services.phpfpm.phpOptions = '' - extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so - sendmail_path = ${sendmail} -t + #services.phpfpm.phpOptions = '' + # extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so + # sendmail_path = ${sendmail} -t + #''; + services.phpfpm.phpIni = pkgs.runCommand "php.ini" { + options = '' + extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so + sendmail_path = ${sendmail} -t -i" + ''; + } '' + cat ${pkgs.php}/etc/php-recommended.ini > $out + echo "$options" >> $out ''; } -- cgit v1.2.3 From b78cafa686a4e01f815f75d1c815996e54fa4597 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:32:59 +0200 Subject: l 2 websites fritz: use ssl everywhere --- lass/2configs/websites/fritz.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lass/2configs/websites/fritz.nix b/lass/2configs/websites/fritz.nix index b0473c2ff..b063504f0 100644 --- a/lass/2configs/websites/fritz.nix +++ b/lass/2configs/websites/fritz.nix @@ -10,28 +10,28 @@ let in { imports = [ - ( manageCerts [ "biostase.de" "www.biostase.de" ]) + ( ssl [ "biostase.de" "www.biostase.de" ]) ( serveWordpress [ "biostase.de" "www.biostase.de" ]) - ( manageCerts [ "radical-dreamers.de" "www.radical-dreamers.de" ]) + ( ssl [ "radical-dreamers.de" "www.radical-dreamers.de" ]) ( serveWordpress [ "radical-dreamers.de" "www.radical-dreamers.de" ]) - ( manageCerts [ "gs-maubach.de" "www.gs-maubach.de" ]) + ( ssl [ "gs-maubach.de" "www.gs-maubach.de" ]) ( serveWordpress [ "gs-maubach.de" "www.gs-maubach.de" ]) - ( manageCerts [ "spielwaren-kern.de" "www.spielwaren-kern.de" ]) + ( ssl [ "spielwaren-kern.de" "www.spielwaren-kern.de" ]) ( serveWordpress [ "spielwaren-kern.de" "www.spielwaren-kern.de" ]) - ( manageCerts [ "familienpraxis-korntal.de" "www.familienpraxis-korntal.de" ]) + ( ssl [ "familienpraxis-korntal.de" "www.familienpraxis-korntal.de" ]) ( servePage [ "familienpraxis-korntal.de" "www.familienpraxis-korntal.de" ]) - ( manageCerts [ "ttf-kleinaspach.de" "www.ttf-kleinaspach.de" ]) + ( ssl [ "ttf-kleinaspach.de" "www.ttf-kleinaspach.de" ]) ( serveWordpress [ "ttf-kleinaspach.de" "www.ttf-kleinaspach.de" ]) ( ssl [ "eastuttgart.de" "www.eastuttgart.de" ]) ( serveWordpress [ "eastuttgart.de" "www.eastuttgart.de" ]) - ( ssl [ "www.habsys.de" "habsys.de" "www.habsys.eu" "habsys.eu" ]) + #( ssl [ "www.habsys.de" "habsys.de" "www.habsys.eu" "habsys.eu" ]) ( servePage [ "www.habsys.de" "habsys.de" "www.habsys.eu" "habsys.eu" ]) ]; -- cgit v1.2.3 From 39be633cf42aaaa4f8a6a992fd3af4e139ab8917 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 20:57:08 +0200 Subject: l 2 radio print_current: show youtube link --- lass/2configs/radio.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 2d1596e3d..17be327b9 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -21,7 +21,9 @@ let ''; print_current = pkgs.writeDashBin "print_current" '' - ${pkgs.mpc_cli}/bin/mpc current -f %file% + echo "$(${pkgs.mpc_cli}/bin/mpc current -f %file%) \ + $(${pkgs.mpc_cli}/bin/mpc current -f %file% \ + | ${pkgs.gnused}/bin/sed 's@.*\(.\{11\}\)\.ogg@http://www.youtube.com/watch?v=\1@')" ''; in { -- cgit v1.2.3 From cc938e61f8d86b2554509a748fc455f0157f9cf7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 29 May 2016 00:32:55 +0200 Subject: k 3 iptables: allow DNAT rules --- krebs/3modules/iptables.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/3modules/iptables.nix b/krebs/3modules/iptables.nix index 4b99873a1..bb06a9388 100644 --- a/krebs/3modules/iptables.nix +++ b/krebs/3modules/iptables.nix @@ -124,7 +124,7 @@ let buildRule = tn: cn: rule: #target validation test: - assert (elem rule.target ([ "ACCEPT" "REJECT" "DROP" "QUEUE" "LOG" "RETURN" ] ++ (attrNames ts."${tn}"))) || hasPrefix "REDIRECT" rule.target; + assert (elem rule.target ([ "ACCEPT" "REJECT" "DROP" "QUEUE" "LOG" "RETURN" ] ++ (attrNames ts."${tn}"))) || hasPrefix "REDIRECT" rule.target || hasPrefix "DNAT" rule.target; #predicate validation test: #maybe use iptables-test -- cgit v1.2.3 From 80e50fd8a05192faaf0e6f87faa3ea9c0313aa32 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 31 May 2016 23:26:35 +0200 Subject: l: move websites libs to 2/websites/util --- lass/1systems/prism.nix | 5 +- lass/2configs/websites/domsen.nix | 8 +- lass/2configs/websites/fritz.nix | 12 +- lass/2configs/websites/util.nix | 228 ++++++++++++++++++++++++++ lass/2configs/websites/wohnprojekt-rhh.de.nix | 10 +- lass/4lib/default.nix | 223 +------------------------ 6 files changed, 248 insertions(+), 238 deletions(-) create mode 100644 lass/2configs/websites/util.nix diff --git a/lass/1systems/prism.nix b/lass/1systems/prism.nix index b9542bc8e..c83f198cb 100644 --- a/lass/1systems/prism.nix +++ b/lass/1systems/prism.nix @@ -3,8 +3,9 @@ let ip = config.krebs.build.host.nets.internet.ip4.addr; - inherit (import ../../4lib { inherit lib pkgs; }) - manageCerts; + inherit (import {inherit lib pkgs;}) + manageCerts + ; in { imports = [ diff --git a/lass/2configs/websites/domsen.nix b/lass/2configs/websites/domsen.nix index 43f9b3924..35a391d1b 100644 --- a/lass/2configs/websites/domsen.nix +++ b/lass/2configs/websites/domsen.nix @@ -1,14 +1,10 @@ { config, pkgs, lib, ... }: let - inherit (config.krebs.lib) + inherit (import { config = {}; inherit lib; }) genid - readFile ; - inherit (import ../../4lib { inherit lib pkgs; }) - manageCert - manageCerts - activateACME + inherit (import {inherit lib pkgs;}) ssl servePage serveOwncloud diff --git a/lass/2configs/websites/fritz.nix b/lass/2configs/websites/fritz.nix index b063504f0..487c4644e 100644 --- a/lass/2configs/websites/fritz.nix +++ b/lass/2configs/websites/fritz.nix @@ -1,12 +1,16 @@ { config, pkgs, lib, ... }: let - inherit (import ../../4lib { inherit lib pkgs; }) - manageCerts - activateACME + inherit (import { config = {}; inherit lib; }) + genid + head + nameValuePair + ; + inherit (import {inherit lib pkgs;}) ssl servePage - serveWordpress; + serveWordpress + ; in { imports = [ diff --git a/lass/2configs/websites/util.nix b/lass/2configs/websites/util.nix new file mode 100644 index 000000000..84a20c711 --- /dev/null +++ b/lass/2configs/websites/util.nix @@ -0,0 +1,228 @@ +{ lib, pkgs, ... }: + +with lib; + +rec { + + manageCerts = domains: + let + domain = head domains; + in { + security.acme = { + certs."${domain}" = { + email = "lassulus@gmail.com"; + webroot = "/var/lib/acme/challenges/${domain}"; + plugins = [ + "account_key.json" + "key.pem" + "fullchain.pem" + ]; + group = "nginx"; + allowKeysForGroup = true; + extraDomains = genAttrs domains (_: null); + }; + }; + + krebs.nginx.servers."${domain}" = { + locations = [ + (nameValuePair "/.well-known/acme-challenge" '' + root /var/lib/acme/challenges/${domain}/; + '') + ]; + }; + }; + + ssl = domains: + { + imports = [ + ( manageCerts domains ) +