about summary refs log tree commit diff
path: root/pkgs/profpatsch
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-11-13 00:36:50 +0100
committerProfpatsch <mail@profpatsch.de>2021-11-13 00:36:50 +0100
commit0dd3e1d830daa95ee45994c49e3818a0491056f9 (patch)
tree9df0fc01ccec4e03e064124f55e12e8e3c383114 /pkgs/profpatsch
parent81b028afd3d62e36da0924accdbe9b6db5a4eef1 (diff)
pkgs/Profpatsch/xdg-open: add libreoffice mimetype
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 …).
Diffstat (limited to 'pkgs/profpatsch')
-rw-r--r--pkgs/profpatsch/xdg-open/config.dhall13
-rw-r--r--pkgs/profpatsch/xdg-open/default.nix9
-rw-r--r--pkgs/profpatsch/xdg-open/types.dhall7
-rw-r--r--pkgs/profpatsch/xdg-open/xdg-open.dhall3
4 files changed, 30 insertions, 2 deletions
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"