Merge remote-tracking branch 'ni/master' into 22.11

This commit is contained in:
lassulus 2022-12-05 21:32:08 +01:00
commit 0447cf6a5f
19 changed files with 228 additions and 105 deletions

View File

@ -74,7 +74,7 @@ in {
60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr} 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr}
60 IN AAAA ${config.krebs.hosts.prism.nets.internet.ip6.addr} 60 IN AAAA ${config.krebs.hosts.prism.nets.internet.ip6.addr}
IN MX 5 mail.lassul.us. IN MX 5 mail.lassul.us.
60 IN TXT v=spf1 mx a:lassul.us -all 60 IN TXT "v=spf1 mx -all"
60 IN TXT ( "v=DKIM1; k=rsa; t=s; s=*; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUv3DMndFellqu208feABEzT/PskOfTSdJCOF/HELBR0PHnbBeRoeHEm9XAcOe/Mz2t/ysgZ6JFXeFxCtoM5fG20brUMRzsVRxb9Ur5cEvOYuuRrbChYcKa+fopu8pYrlrqXD3miHISoy6ErukIYCRpXWUJHi1TlNQhLWFYqAaywIDAQAB" ) 60 IN TXT ( "v=DKIM1; k=rsa; t=s; s=*; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUv3DMndFellqu208feABEzT/PskOfTSdJCOF/HELBR0PHnbBeRoeHEm9XAcOe/Mz2t/ysgZ6JFXeFxCtoM5fG20brUMRzsVRxb9Ur5cEvOYuuRrbChYcKa+fopu8pYrlrqXD3miHISoy6ErukIYCRpXWUJHi1TlNQhLWFYqAaywIDAQAB" )
default._domainkey 60 IN TXT "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUv3DMndFellqu208feABEzT/PskOfTSdJCOF/HELBR0PHnbBeRoeHEm9XAcOe/Mz2t/ysgZ6JFXeFxCtoM5fG20brUMRzsVRxb9Ur5cEvOYuuRrbChYcKa+fopu8pYrlrqXD3miHISoy6ErukIYCRpXWUJHi1TlNQhLWFYqAaywIDAQAB" default._domainkey 60 IN TXT "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUv3DMndFellqu208feABEzT/PskOfTSdJCOF/HELBR0PHnbBeRoeHEm9XAcOe/Mz2t/ysgZ6JFXeFxCtoM5fG20brUMRzsVRxb9Ur5cEvOYuuRrbChYcKa+fopu8pYrlrqXD3miHISoy6ErukIYCRpXWUJHi1TlNQhLWFYqAaywIDAQAB"
cache 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr} cache 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr}

View File

@ -172,7 +172,7 @@ in {
search.ni 60 IN A ${config.krebs.hosts.ni.nets.internet.ip4.addr} search.ni 60 IN A ${config.krebs.hosts.ni.nets.internet.ip4.addr}
search.ni 60 IN AAAA ${config.krebs.hosts.ni.nets.internet.ip6.addr} search.ni 60 IN AAAA ${config.krebs.hosts.ni.nets.internet.ip6.addr}
krebsco.de. 60 IN MX 5 ni krebsco.de. 60 IN MX 5 ni
krebsco.de. 60 IN TXT v=spf1 mx -all krebsco.de. 60 IN TXT "v=spf1 mx -all"
tv 300 IN NS ni tv 300 IN NS ni
''; '';
}; };

View File

@ -46,14 +46,15 @@ with import <stockholm/lib>;
} }
{ {
nix.extraOptions = ''
auto-optimise-store = true
'';
# TODO check if both are required: # TODO check if both are required:
nix.sandboxPaths = [ "/etc/protocols" pkgs.iana-etc.outPath ]; nix.settings.extra-sandbox-paths = [
"/etc/protocols"
nix.requireSignedBinaryCaches = true; pkgs.iana-etc.outPath
];
nix.binaryCaches = ["https://cache.nixos.org"];
nix.useSandbox = true;
} }
{ {
nixpkgs.config.allowUnfree = false; nixpkgs.config.allowUnfree = false;

View File

@ -134,7 +134,6 @@ let {
web-routes-wai-custom = {}; web-routes-wai-custom = {};
xintmap = {}; xintmap = {};
xmonad-aeson = {}; xmonad-aeson = {};
xmonad-stockholm = {};
xmonad-web = {}; xmonad-web = {};
} // mapAttrs (_: recursiveUpdate { cgit.section = "4. museum"; }) { } // mapAttrs (_: recursiveUpdate { cgit.section = "4. museum"; }) {
cac-api = { cac-api = {
@ -165,6 +164,7 @@ let {
soundcloud = { soundcloud = {
cgit.desc = "SoundCloud command line interface"; cgit.desc = "SoundCloud command line interface";
}; };
xmonad-stockholm = {};
}); });
restricted-repos = mapAttrs make-restricted-repo ( restricted-repos = mapAttrs make-restricted-repo (

View File

@ -28,8 +28,8 @@ in
} }
{ {
nix.buildCores = 2; nix.settings.cores = 2;
nix.maxJobs = 2; nix.settings.max-jobs = 2;
} }
(if lib.versionAtLeast (lib.versions.majorMinor lib.version) "21.11" then { (if lib.versionAtLeast (lib.versions.majorMinor lib.version) "21.11" then {
nix.daemonCPUSchedPolicy = "batch"; nix.daemonCPUSchedPolicy = "batch";

View File

@ -13,7 +13,7 @@ let {
environment.variables.VIMINIT = ":so /etc/vimrc"; environment.variables.VIMINIT = ":so /etc/vimrc";
}; };
extra-runtimepath = concatMapStringsSep "," (pkg: "${pkg.rtp}") [ extra-runtimepath = pkgs.tv.vim.makeRuntimePath [
pkgs.tv.vimPlugins.elixir pkgs.tv.vimPlugins.elixir
pkgs.tv.vimPlugins.file-line pkgs.tv.vimPlugins.file-line
pkgs.tv.vimPlugins.fzf pkgs.tv.vimPlugins.fzf

View File

@ -1,6 +1,6 @@
{ mkDerivation, aeson, base, bytestring, containers, directory { mkDerivation, aeson, base, bytestring, containers, directory
, extra, lib, template-haskell, th-env, unix, X11, xmonad , extra, filepath, lib, systemd, template-haskell, th-env
, xmonad-contrib, xmonad-stockholm , transformers, unix, X11, xmonad, xmonad-contrib
}: }:
mkDerivation { mkDerivation {
pname = "xmonad-tv"; pname = "xmonad-tv";
@ -9,8 +9,8 @@ mkDerivation {
isLibrary = false; isLibrary = false;
isExecutable = true; isExecutable = true;
executableHaskellDepends = [ executableHaskellDepends = [
aeson base bytestring containers directory extra template-haskell aeson base bytestring containers directory extra filepath systemd
th-env unix X11 xmonad xmonad-contrib xmonad-stockholm template-haskell th-env transformers unix X11 xmonad xmonad-contrib
]; ];
license = lib.licenses.mit; license = lib.licenses.mit;
} }

View File

@ -0,0 +1,24 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
module Build where
import XMonad (Dimension)
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

View File

@ -0,0 +1,113 @@
{-# 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
readProcessIDFromFile = do
pidFileName <- getProcessIDFileName
read <$> readFile pidFileName

View File

@ -1,6 +1,4 @@
{-# LANGUAGE LambdaCase #-} {-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
module Main (main) where module Main (main) where
@ -32,25 +30,9 @@ import Data.Ratio
import XMonad.Hooks.Place (placeHook, smart) import XMonad.Hooks.Place (placeHook, smart)
import XMonad.Actions.PerWorkspaceKeys (chooseAction) import XMonad.Actions.PerWorkspaceKeys (chooseAction)
import XMonad.Stockholm.Pager import Shutdown (shutdown, newShutdownEventHandler)
import XMonad.Stockholm.Shutdown
import THEnv.JSON (getCompileEnvJSONExp) import Build (myFont, myScreenWidth, myTermFontWidth, myTermPadding)
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 :: IO ()
@ -154,8 +136,6 @@ myKeys conf = Map.fromList $
, ((_4 , xK_x ), chooseAction spawnTermAt) , ((_4 , xK_x ), chooseAction spawnTermAt)
, ((_4C , xK_x ), spawnRootTerm) , ((_4C , xK_x ), spawnRootTerm)
, ((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) , ((_C , xK_Menu ), toggleWS)
, ((_4 , xK_space ), withFocused $ \w -> ifM (isFloatingX w) xdeny $ sendMessage NextLayout) , ((_4 , xK_space ), withFocused $ \w -> ifM (isFloatingX w) xdeny $ sendMessage NextLayout)
@ -233,23 +213,3 @@ xdeny =
, "-e", "sleep", "0.05" , "-e", "sleep", "0.05"
] ]
Nothing Nothing
pagerConfig :: PagerConfig
pagerConfig = def
{ pc_font = myFont
, pc_cellwidth = 64
, pc_matchmethod = MatchPrefix
, 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
allWorkspaceNames :: W.StackSet i l a sid sd -> X [i]
allWorkspaceNames = return . map W.tag . W.workspaces

View File

@ -15,14 +15,15 @@ executable xmonad
containers, containers,
directory, directory,
extra, extra,
filepath,
template-haskell, template-haskell,
th-env, th-env,
unix, unix,
X11, X11,
xmonad, xmonad,
xmonad-contrib, xmonad-contrib
xmonad-stockholm
other-modules: other-modules:
Shutdown,
THEnv.JSON THEnv.JSON
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -O2 -Wall -threaded ghc-options: -O2 -Wall -threaded

View File

@ -1,50 +1,72 @@
commit 57cbd76c068121b685399fdb4649e7ba537983d6
Author: tv <tv@krebsco.de>
Date: Mon Dec 5 15:24:30 2022 +0100
Add --complete-1 option
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index 79e7291..3b8a753 100644
--- a/man/man1/fzf.1
+++ b/man/man1/fzf.1
@@ -685,6 +685,9 @@ interactive finder and automatically select the only match
If there is no match for the initial query (\fB--query\fR), do not start
interactive finder and exit immediately
.TP
+.B "--complete-1"
+Exit interactive finder when there's exactly one match
+.TP
.BI "-f, --filter=" "STR"
Filter mode. Do not start interactive finder. When used with \fB--no-sort\fR,
fzf becomes a fuzzy-version of grep.
diff --git a/src/core.go b/src/core.go diff --git a/src/core.go b/src/core.go
index a18c3a1..a3d92a4 100644 index 2ddddc3..09afff2 100644
--- a/src/core.go --- a/src/core.go
+++ b/src/core.go +++ b/src/core.go
@@ -331,6 +331,13 @@ func Run(opts *Options, version string, revision string) { @@ -337,8 +337,14 @@ func Run(opts *Options, version string, revision string) {
}
determine(val.final)
} }
} + } else {
terminal.UpdateList(val, clearSelection()) + if opts.Complete1 && val.Length() == 1 {
+ if (opts.Complete1) {
+ count := val.Length()
+ if count == 1 {
+ opts.Printer(val.Get(0).item.AsString(opts.Ansi)) + opts.Printer(val.Get(0).item.AsString(opts.Ansi))
+ terminal.reqBox.Set(reqClose, nil) + terminal.reqBox.Set(reqClose, nil)
+ } else {
+ terminal.UpdateList(val, clearSelection())
+ } + }
+ } }
- terminal.UpdateList(val, clearSelection())
} }
} }
} }
diff --git a/src/options.go b/src/options.go diff --git a/src/options.go b/src/options.go
index a55dc34..7f121cd 100644 index 5400311..1e38fe4 100644
--- a/src/options.go --- a/src/options.go
+++ b/src/options.go +++ b/src/options.go
@@ -92,6 +92,7 @@ const usage = `usage: fzf [options] @@ -108,6 +108,7 @@ const usage = `usage: fzf [options]
-1, --select-1 Automatically select the only match -1, --select-1 Automatically select the only match
-0, --exit-0 Exit immediately when there's no match -0, --exit-0 Exit immediately when there's no match
-f, --filter=STR Filter mode. Do not start interactive finder. -f, --filter=STR Filter mode. Do not start interactive finder.
+ --complete-1 Exit interactive finder when there's exactly one match + --complete-1 Exit interactive finder when there's exactly one match
--print-query Print query as the first line --print-query Print query as the first line
--expect=KEYS Comma-separated list of keys to complete fzf --expect=KEYS Comma-separated list of keys to complete fzf
--read0 Read input delimited by ASCII NUL characters --read0 Read input delimited by ASCII NUL characters
@@ -208,6 +209,7 @@ type Options struct { @@ -274,6 +275,7 @@ type Options struct {
Query string Query string
Select1 bool Select1 bool
Exit0 bool Exit0 bool
+ Complete1 bool + Complete1 bool
Filter *string Filter *string
ToggleSort bool ToggleSort bool
Expect map[tui.Event]string Expect map[tui.Event]string
@@ -269,6 +271,7 @@ func defaultOptions() *Options { @@ -342,6 +344,7 @@ func defaultOptions() *Options {
Query: "", Query: "",
Select1: false, Select1: false,
Exit0: false, Exit0: false,
+ Complete1: false, + Complete1: false,
Filter: nil, Filter: nil,
ToggleSort: false, ToggleSort: false,
Expect: make(map[tui.Event]string), Expect: make(map[tui.Event]string),
@@ -1311,6 +1314,8 @@ func parseOptions(opts *Options, allArgs []string) { @@ -1546,6 +1549,8 @@ func parseOptions(opts *Options, allArgs []string) {
opts.Exit0 = true opts.Exit0 = true
case "+0", "--no-exit-0": case "+0", "--no-exit-0":
opts.Exit0 = false opts.Exit0 = false

View File

@ -1,9 +1,7 @@
self: super: self: super:
super.fzf.overrideAttrs (old: { super.fzf.overrideAttrs (old: {
# XXX cannot use `patches` because fzf has a custom patchPhase patches = old.patches or [] ++ [
patchPhase = '' ./complete1.patch
patch -Np1 < ${./complete1.patch} ];
${old.patchPhase or ""}
'';
}) })

View File

@ -2,6 +2,10 @@ with import <stockholm/lib>;
self: super: { self: super: {
tv = super.tv // { tv = super.tv // {
vim = {
makePlugin = outPath: outPath // { inherit outPath; };
makeRuntimePath = concatMapStringsSep "," (getAttr "outPath");
};
vimPlugins = mapNixDir (path: self.callPackage path {}) ./.; vimPlugins = mapNixDir (path: self.callPackage path {}) ./.;
}; };
} }

View File

@ -1,7 +1,7 @@
with import <stockholm/lib>; with import <stockholm/lib>;
{ pkgs }: { pkgs }:
(rtp: rtp // { inherit rtp; }) (pkgs.writeTextFile (let pkgs.tv.vim.makePlugin (pkgs.writeTextFile (let
name = "hack"; name = "hack";
in { in {
name = "vim-color-${name}-1.0.2"; name = "vim-color-${name}-1.0.2";

View File

@ -1,7 +1,7 @@
with import <stockholm/lib>; with import <stockholm/lib>;
{ pkgs }: { pkgs }:
(rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { pkgs.tv.vim.makePlugin (pkgs.write "vim-syntax-nix-nested" {
"/syntax/haskell.vim".text = '' "/syntax/haskell.vim".text = ''
syn region String start=+\[[[:alnum:]]*|+ end=+|]+ syn region String start=+\[[[:alnum:]]*|+ end=+|]+

View File

@ -1,6 +1,6 @@
{ pkgs }: { pkgs }:
(rtp: rtp // { inherit rtp; }) (pkgs.writeTextFile (let pkgs.tv.vim.makePlugin (pkgs.writeTextFile (let
name = "showsyntax"; name = "showsyntax";
in { in {
name = "vim-plugin-${name}-1.0.0"; name = "vim-plugin-${name}-1.0.0";

View File

@ -1,6 +1,6 @@
{ pkgs }: { pkgs }:
(rtp: rtp // { inherit rtp; }) (pkgs.write "vim-tv" { pkgs.tv.vim.makePlugin (pkgs.write "vim-tv" {
# #
# Haskell # Haskell
# #

View File

@ -1,7 +1,7 @@
with import <stockholm/lib>; with import <stockholm/lib>;
{ pkgs }: { pkgs }:
(rtp: rtp // { inherit rtp; }) (pkgs.writeTextFile (let pkgs.tv.vim.makePlugin (pkgs.writeTextFile (let
name = "vim"; name = "vim";
in { in {
name = "vim-syntax-${name}-1.0.0"; name = "vim-syntax-${name}-1.0.0";