forked from ehmry/syndicated-open
Compare commits
No commits in common. "trunk" and "cd8ae554bc6ad10aee5ea5fd9f2def6f5f4ffd91" have entirely different histories.
trunk
...
cd8ae554bc
|
@ -2,7 +2,7 @@
|
|||
|
||||
An `xdg-open` replacement that uses Syndicate and PCRE pattern matching to open URIs.
|
||||
|
||||
There are two utilites, `uri_runner` and `xdg-open`; both expect to be able to connect to a shared Syndicate dataspace via a UNIX socket at `$SYNDICATE_SOCK` otherwise `$XDG_RUNTIME_DIR/dataspace`. The `xdg-open` component has no other configuration. The `uri_runner` component is intended to be managed by the [Syndicate server](https://git.syndicate-lang.org/syndicate-lang/syndicate-rs) thru which it receives configuration, see [uri_runner.pr](./uri_runner.pr) as an example.
|
||||
There are two utilites, `uri_runner` and `xdg-open`; both expect to be able to connect to a shared Syndicate dataspace via a UNIX socket at `$SYNDICATE_SOCK` otherwise `$XDG_RUNTIME_DIR/dataspace`. The `xdg-open` component has no other configuration. The `uri_runner` component is intended to be managed by the [Syndicate server](https://git.syndicate-lang.org/syndicate-lang/syndicate-rs) thru which is receives configuration, see [uri_runnner.pr](./uri_runnner.pr) as an example.
|
||||
|
||||
## TODO
|
||||
- Pattern back-references in commands
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1623875721,
|
||||
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nimble": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1645925055,
|
||||
"narHash": "sha256-fbP0/1djwAtpNVkAe0OAZRU/0rfQswxn7Nr4ac7OiyY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flake-nimble",
|
||||
"rev": "5bbaa6321652cfa31c69dc5246bd407d12f75a5e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nimble",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1641555862,
|
||||
"narHash": "sha256-AJK1Q5djPXs/ba3K6gHsVAer9yDPVLic78ZIDsFSkHU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d1acd89e0116ff88eba80541027429fc922612e9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1636723036,
|
||||
"narHash": "sha256-zFuu3TTj/NLq3NPJ8pprlmkOpjAoW3AWQNac3UFkCG8=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "50a1ef0f59752623af884f5085e3d5e8bd806c77",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "50a1ef0f59752623af884f5085e3d5e8bd806c77",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1628186154,
|
||||
"narHash": "sha256-r2d0wvywFnL9z4iptztdFMhaUIAaGzrSs7kSok0PgmE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "06552b72346632b6943c8032e57e702ea12413bf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nimble": "nimble",
|
||||
"syndicate": "syndicate"
|
||||
}
|
||||
},
|
||||
"rust": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1630548746,
|
||||
"narHash": "sha256-SLzeWhEN0kRDTzL+AHfDxwbYEZm09UEcdIcPDdOIZew=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "00f6332f8c690480c7b7137fb8b1f069e7b2e18a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"syndicate": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust": "rust"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1645916341,
|
||||
"narHash": "sha256-vzGl+qKrVv1FaySUtb/eJGK7zPjIJT5/3Iv/xFhkkTs=",
|
||||
"ref": "trunk",
|
||||
"rev": "0f6d38dfa16c2250376c996f9b13e96bea92a45d",
|
||||
"revCount": 19,
|
||||
"type": "git",
|
||||
"url": "https://git.syndicate-lang.org/ehmry/syndicate-flake.git"
|
||||
},
|
||||
"original": {
|
||||
"id": "syndicate",
|
||||
"type": "indirect"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
description = "xdg-open-ng";
|
||||
|
||||
outputs = { self, nimble, syndicate }:
|
||||
let inherit (syndicate.inputs.nixpkgs) lib;
|
||||
in {
|
||||
|
||||
defaultPackage =
|
||||
lib.mapAttrs (system: pkgs: pkgs.xdg-open-ng) self.packages;
|
||||
packages = lib.mapAttrs (system: pkgs:
|
||||
let nimblePackages = nimble.packages.${system};
|
||||
in {
|
||||
xdg-open-ng = pkgs.nimPackages.buildNimPackage rec {
|
||||
pname = "xdg-open";
|
||||
version = self.lastModifiedDate;
|
||||
src = self;
|
||||
propagatedBuildInputs = [
|
||||
(nimblePackages.nimsha2.overrideAttrs (attrs: {
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "jangko";
|
||||
repo = "nimSHA2";
|
||||
rev = "b8f666069dff1ed0c5142dd1ca692f0e71434716";
|
||||
hash = "sha256-Wqb3mQ7638UOTze71mf6WMyGiw9qTwhbJiGGb+9OR2k=";
|
||||
};
|
||||
}))
|
||||
nimblePackages.preserves
|
||||
(nimblePackages.syndicate.overrideAttrs
|
||||
(attrs: { doCheck = false; }))
|
||||
];
|
||||
postInstall = "mv $out/bin/xdg_open $out/bin/xdg-open";
|
||||
};
|
||||
}) { inherit (nimble.legacyPackages) x86_64-linux; };
|
||||
|
||||
nixosModule = self.nixosModules.xdg-open-ng;
|
||||
nixosModules.xdg-open-ng = import ./nixos-module.nix;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
programCfg = config.programs.xdg-open-ng;
|
||||
settingsFormat = pkgs.formats.preserves { };
|
||||
prCfgFile = settingsFormat.generate "xdg-open.pr" programCfg.settings;
|
||||
pkg = programCfg.package;
|
||||
in {
|
||||
options.programs.xdg-open-ng = {
|
||||
|
||||
enable = mkEnableOption "xdg-open-ng";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.xdg-open-ng;
|
||||
defaultText = literalExpression "pkgs.xdg-open-ng";
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = settingsFormat.type;
|
||||
default = [ ];
|
||||
defaultText = literalExpression ''
|
||||
[ [ ".*mkv|.*mp4" [ "${pkgs.mpv}/bin/mpv" "$#" ] ]
|
||||
[ "gemini://.*|file:///.*.gmi" [ "${pkgs.kristall}/bin/kristall" "$#" ]; ]
|
||||
[ "tox:.*" [ "${pkgs.qtox}/bin/qtox" "$#" ] ]
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf programCfg.enable {
|
||||
|
||||
environment.systemPackages = [ pkg ];
|
||||
};
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ ehmry ];
|
||||
}
|
|
@ -23,6 +23,7 @@ bootDataspace("main") do (ds: Ref; turn: var Turn):
|
|||
connectUnix(turn, unixSocketPath(), mintCap()) do (turn: var Turn; a: Assertion) -> TurnAction:
|
||||
let ds = unembed a
|
||||
message(turn, ds, XdgOpen(args: commandLineParams()))
|
||||
stop(turn, mainFacet)
|
||||
|
||||
for i in 0..7: poll(20)
|
||||
# A hack to exit
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
let
|
||||
syndicate = builtins.getFlake "syndicate";
|
||||
nixpkgs = builtins.getFlake "nixpkgs";
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
|
||||
toPreserves = syndicate.lib.generators.toPreserves { };
|
||||
|
||||
kristall = "${pkgs.kristall}/bin/kristall";
|
||||
|
||||
cfg = { "gemini://.*|file:///.*.gmi'" = [ kristall ]; };
|
||||
|
||||
in pkgs.writeText "cfg.pr" (toPreserves cfg)
|
|
@ -1,13 +1,10 @@
|
|||
; Expose a dataspace over a unix socket
|
||||
let ?root_ds = dataspace
|
||||
<require-service <relay-listener <unix "/run/user/1000/dataspace"> $gatekeeper>>
|
||||
<bind "syndicate" #x"" $root_ds>
|
||||
|
||||
<require-service <daemon uri_runner>>
|
||||
|
||||
<daemon uri_runner {
|
||||
argv: "uri_runner"
|
||||
argv: ["/home/repo/syndicate/xdg_open_ng/src/uri_runner"]
|
||||
dir: "/tmp"
|
||||
protocol: text/syndicate
|
||||
clearEnv: #f
|
||||
}>
|
||||
|
||||
? <service-object <daemon uri_runner> ?cap> [
|
||||
|
@ -15,6 +12,6 @@ let ?root_ds = dataspace
|
|||
["gemini://.*|file:///.*.gmi", ["/run/current-system/sw/bin/kristall" "\\1"]]
|
||||
["http://.*|https://.*|.*html", ["/run/current-system/sw/bin/firefox" "\\1"]]
|
||||
["tox:.*|uri:tox:.*", ["/run/current-system/sw/bin/qtox" "\\1"]]
|
||||
[".*\\.avi|.*\\.mp4|.*mkv", ["/run/current-system/sw/bin/mpv" "\\1"]]
|
||||
[".*mkv", ["/run/current-system/sw/bin/mpv" "\\1"]]
|
||||
] } >
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue