From 0dd3e1d830daa95ee45994c49e3818a0491056f9 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 13 Nov 2021 00:36:50 +0100 Subject: pkgs/Profpatsch/xdg-open: add libreoffice mimetype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also make sure libreoffice is only installed/pulled when clicking on the link (although there could be a popup of sorts if it has to do stuff …). --- pkgs/profpatsch/xdg-open/config.dhall | 13 +++++++++++++ pkgs/profpatsch/xdg-open/default.nix | 9 +++++++++ pkgs/profpatsch/xdg-open/types.dhall | 7 ++++++- pkgs/profpatsch/xdg-open/xdg-open.dhall | 3 ++- 4 files changed, 30 insertions(+), 2 deletions(-) (limited to 'pkgs/profpatsch') diff --git a/pkgs/profpatsch/xdg-open/config.dhall b/pkgs/profpatsch/xdg-open/config.dhall index 6e5bacfe..9febd1b7 100644 --- a/pkgs/profpatsch/xdg-open/config.dhall +++ b/pkgs/profpatsch/xdg-open/config.dhall @@ -15,6 +15,7 @@ let UriMimeGlob = types.UriMimeGlob let MimeMatch = types.MimeMatch in λ(pkgs : { package : Text, binary : Text } → Executable) → + λ(pkgsOnDemand : { package : Text, binary : Text } → Executable) → λ(special : Special) → let mime = let pkgSame = @@ -24,6 +25,13 @@ in λ(pkgs : { package : Text, binary : Text } → Executable) → , binary = packageAndBinaryName } + let pkgSameOnDemand = + λ(packageAndBinaryName : Text) → + pkgsOnDemand + { package = packageAndBinaryName + , binary = packageAndBinaryName + } + let wrapCommand = λ(wrapper : Command) → λ(cmd : Command) → @@ -111,6 +119,10 @@ in λ(pkgs : { package : Text, binary : Text } → Executable) → special.exec-in-terminal-emulator (oneArg (pkgSame "ranger")) } + , opendocument-any = + { mime = [ "application/vnd.oasis.opendocument.*" ] + , cmd = oneArg (pkgSameOnDemand "libreoffice") + } , any = { mime = [ "*" ], cmd = special.dmenu-list-binaries-and-exec } } @@ -130,6 +142,7 @@ in λ(pkgs : { package : Text, binary : Text } → Executable) → , mime.image.svg , mime.image.any , mime.pdf + , mime.opendocument-any , mime.pgp-key , mime.directory , mime.any diff --git a/pkgs/profpatsch/xdg-open/default.nix b/pkgs/profpatsch/xdg-open/default.nix index 30ff275e..28444a47 100644 --- a/pkgs/profpatsch/xdg-open/default.nix +++ b/pkgs/profpatsch/xdg-open/default.nix @@ -103,6 +103,10 @@ let ] ++ args file; }; + fetch-command-on-demand = cmd: pkgs.vuizvui.lazy-packages.mkWrapper { + package = cmd; + }; + fetch-http-url-mime = { exe = writeExecline "fetch-http-url-mime" { readNArgs = 1; } [ "pipeline" [ read-headers-and-follow-redirect "$1" ] @@ -130,6 +134,7 @@ let → ∀(write-dash : Text → Text → Text) → ∀(shellEscape : Text → Text) → ∀(pkgs : { binary : Text, package : Text } → Text) +→ ∀(pkgsOnDemand : { binary : Text, package : Text } → Text) → ∀ ( special : { compose-mail-to : Command , dmenu-list-binaries-and-exec : Command @@ -160,11 +165,15 @@ let pkgs.writers.writeDash pkgs.lib.escapeShellArg ({binary, package}: "${lib.getBin pkgs.${package}}/bin/${binary}") + ({binary, package}: "${pkgs.vuizvui.lazy-packages.mkWrapper { + package = (lib.getBin pkgs.${package}); + }}/bin/${binary}") { inherit compose-mail-to open-in-browser fetch-http-url-mime + fetch-command-on-demand open-in-editor dmenu-list-binaries-and-exec exec-in-terminal-emulator diff --git a/pkgs/profpatsch/xdg-open/types.dhall b/pkgs/profpatsch/xdg-open/types.dhall index 9b0456f1..8cc033b4 100644 --- a/pkgs/profpatsch/xdg-open/types.dhall +++ b/pkgs/profpatsch/xdg-open/types.dhall @@ -10,7 +10,12 @@ let Arg = < String : Text | Variable : Text > let CommandTemplate = λ(templates : Type) → { exe : Executable, args : templates → List Arg } -let Command = CommandTemplate Arg +let + -- Given an executable and args to pass to the executable, + -- which might be a bash variable or a simple command line string. + -- Should remove that indirection at some point and just generate execline strings/scripts instead. (?) + Command = + CommandTemplate Arg let Special = { open-in-editor : Command diff --git a/pkgs/profpatsch/xdg-open/xdg-open.dhall b/pkgs/profpatsch/xdg-open/xdg-open.dhall index 3edb31e5..3d412309 100644 --- a/pkgs/profpatsch/xdg-open/xdg-open.dhall +++ b/pkgs/profpatsch/xdg-open/xdg-open.dhall @@ -84,8 +84,9 @@ let xdg-open = λ(write-dash : Text → Text → Executable) → λ(shellEscape : Text → Text) → λ(pkgs : { package : Text, binary : Text } → Executable) → + λ(pkgsOnDemand : { package : Text, binary : Text } → Executable) → λ(special : types.Special) → - let config = ./config.dhall pkgs special + let config = ./config.dhall pkgs pkgsOnDemand special in write-dash "xdg-open" -- cgit 1.4.1