Compare commits

...

37 Commits

Author SHA1 Message Date
Emery Hemingway 03374806ab Update Rust stuff (broken because the language is unstable) 2022-09-06 12:08:01 -05:00
Emery Hemingway 3f4c5ae37e Only one nixpkgs input 2022-09-06 11:18:29 -05:00
Emery Hemingway a85b1cb618 xdg-open: sure, mozilla whatever 2022-07-11 07:31:18 -05:00
Emery Hemingway e30bffdc72 squeak: 6.0rc1-22081-202206021410 -> 6.0-22101-202206021410 2022-07-05 07:00:28 -05:00
Emery Hemingway a3ffae7da3 squeak: 6.0beta-22058 -> 6.0rc1-22081 2022-07-01 06:26:47 -05:00
Emery Hemingway 53a6380759 Syndicate server test 2022-06-29 09:08:59 -05:00
Emery Hemingway 3d65eb0987 syndicate_utils: 20220627 -> 20220628 2022-06-29 08:51:22 -05:00
Emery Hemingway f75b35090e nixos: optionally wrap syndicate-server with dbus-run-session 2022-06-29 08:51:22 -05:00
Emery Hemingway e905aada34 syndicate_utils: init at 20220627 2022-06-27 10:45:32 -05:00
Emery Hemingway 327de24ea7 nixos: improve config loading for syndicate-server
Use an intermediary configuration file to allow configuration
reloading.
2022-06-26 18:39:15 -05:00
Emery Hemingway b7bf10234d preserves-nim, xdg_open_ng: update to 20220625 2022-06-26 08:39:44 -05:00
Emery Hemingway 48d979dbe4 nixos: add enabled dataspace servers to systemd wants 2022-06-24 09:19:36 -05:00
Emery Hemingway c8a9f38817 nixos: enable TTY dataspace server when enabled 2022-06-22 13:53:03 -05:00
Emery Hemingway effbe05d2b squeak: 6.0alpha-21540-202112201228 > 6.0beta-22058-202206021410 2022-06-22 08:25:21 -05:00
Emery Hemingway b355f98b60 nixos: refactor dataspace server for TTYs 2022-06-11 15:42:16 -05:00
Emery Hemingway 513ca8420e xdg_open_ng: 0.3.2 -> 0.4.0 2022-05-19 12:22:38 -05:00
Emery Hemingway 379840bea9 preserves-nim: 0.3.0 -> 0.3.1 2022-05-18 14:27:22 -05:00
Emery Hemingway 50876967b1 xdg_open_ng: 0.3.1 -> 0.3.2 2022-05-17 08:03:31 -05:00
Emery Hemingway b7af32fc66 xdg_open_ng: 0.3.0 -> 0.3.1
preserves-nim: 3.2.0 -> 3.3.0
syndicate-nim: 1.2.0 -> 1.3.0
2022-04-25 12:05:43 -05:00
Emery Hemingway 0ad63218fe xdg_open_ng: 0.1.0 -> 0.3.0 2022-04-15 18:19:13 -05:00
Emery Hemingway 18c63d8619 xdg_open_ng: add DesktopItem 2022-04-10 21:53:02 -05:00
Emery Hemingway 596580748f squeak: 6.0alpha-21485-… -> 6.0alpha-21540-…
Add 32bit build as well.
2022-04-03 02:38:33 +00:00
Emery Hemingway cecebbc118 Add Squeak and Squeaker 2022-03-25 09:37:32 -05:00
Emery Hemingway 7fee5e35fe Add xdg_open_ng 2022-03-17 14:41:42 -05:00
Emery Hemingway d243e63e9a Improve lib.generators.toPreserves
- Generate dictionaries with symbol keys. This breaks lossless
  JSON conversion but is consistent with Preserves in the wild.
- New record pattern: ``[ 1 2 3 { record = "foo"; } ]``.
2022-03-16 22:24:42 -05:00
Emery Hemingway a216ae43c4 More platforms 2022-03-16 15:56:53 -05:00
Emery Hemingway 2dfd2ac52b syndicate-nim: 1.1.0 -> 1.2.0 2022-03-16 15:56:53 -05:00
Emery Hemingway e5ecb0ac26 Remove NixOS module from README, not ready 2022-03-14 21:44:32 -05:00
Emery Hemingway 0e7ec9bb8a Add syndicate-nim 2022-03-14 15:09:52 -05:00
Emery Hemingway 51935e24db preserves-nim: 3.0.0 -> 3.2.0 2022-03-14 15:09:52 -05:00
Emery Hemingway 2ad8fed971 Add Python packages 2022-03-14 15:09:33 -05:00
Emery Hemingway ef8123e1a0 Refactor flake, update inputs 2022-03-14 15:09:00 -05:00
Emery Hemingway 666e30a8b1 Use a "master" branch for the sake of Nix tools 2022-03-01 17:37:59 -06:00
Emery Hemingway 07893891ea syndicate-rs-0.15.1 -> syndicate-server-0.24.0 2022-03-01 17:36:55 -06:00
Emery Hemingway 9d2342f5c1 Refactor NixOS configuration of Syndicate server 2022-03-01 17:36:55 -06:00
Emery Hemingway 0f6d38dfa1 lib.generators.toPreserves: quote keys of attrsets 2022-02-26 16:59:01 -06:00
Emery Hemingway 2ea129e1a1 preserves-tools: 1.0.0 -> 2.3.0 2021-12-05 12:05:22 +00:00
16 changed files with 587 additions and 279 deletions

View File

@ -2,57 +2,5 @@
To add to your local flake registry:
```sh
nix registry add syndicate "git+https://git.syndicate-lang.org/ehmry/syndicate-flake?ref=trunk"
```
## NixOS service
### Importing
To import the NixOS module:
```nix
{
# /etc/nixos/flake.nix
inputs.syndicate.url = "git+https://git.syndicate-lang.org/ehmry/syndicate-flake?ref=trunk";
outputs = { self, nixpkgs, syndicate }: {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
syndicate.nixosModules.syndicate-server
];
};
};
}
```
If `/etc/nixos` is not a flake then you may be able to use the `getFlake` builtin
to retrieve the module.
```nix
{ config, lib, pkgs, ... }:
{
imports = [ (builtins.getFlake "syndicate").nixosModules.syndicate-server ];
}
```
## Configuration
```nix
{ config, lib, pkgs, ... }:
{
services.syndicate-server = {
enable = true;
# A socket at /run/syndicate/ds is enable by default.
tcpListeners = [{
address = "127.0.0.1";
port = 3232;
}];
};
}
nix registry add syndicate "git+https://git.syndicate-lang.org/ehmry/syndicate-flake"
```

View File

@ -1,74 +1,44 @@
{
"nodes": {
"flake-utils": {
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1623875721,
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
"lastModified": 1662220400,
"narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=",
"owner": "nix-community",
"repo": "naersk",
"rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1636723036,
"narHash": "sha256-zFuu3TTj/NLq3NPJ8pprlmkOpjAoW3AWQNac3UFkCG8=",
"owner": "nixos",
"lastModified": 1662096612,
"narHash": "sha256-R+Q8l5JuyJryRPdiIaYpO5O3A55rT+/pItBrKcy7LM4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "50a1ef0f59752623af884f5085e3d5e8bd806c77",
"rev": "21de2b973f9fee595a7a1ac4693efff791245c34",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"rev": "50a1ef0f59752623af884f5085e3d5e8bd806c77",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1628186154,
"narHash": "sha256-r2d0wvywFnL9z4iptztdFMhaUIAaGzrSs7kSok0PgmE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "06552b72346632b6943c8032e57e702ea12413bf",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust": "rust"
}
},
"rust": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1630548746,
"narHash": "sha256-SLzeWhEN0kRDTzL+AHfDxwbYEZm09UEcdIcPDdOIZew=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "00f6332f8c690480c7b7137fb8b1f069e7b2e18a",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
"naersk": "naersk",
"nixpkgs": [
"naersk",
"nixpkgs"
]
}
}
},

134
flake.nix
View File

@ -1,38 +1,120 @@
{
description = "Syndicate utilities";
inputs.rust.url = "github:oxalica/rust-overlay";
inputs.naersk.url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "naersk/nixpkgs";
inputs.nixpkgs.url = "github:nixos/nixpkgs/50a1ef0f59752623af884f5085e3d5e8bd806c77";
outputs = { self, naersk, nixpkgs, }: {
lib = nixpkgs.lib.extend (import ./lib.nix);
outputs = { self, nixpkgs, rust }:
let
forEachSystem = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
libOverlay = import ./lib.nix;
in {
lib = nixpkgs.lib.extend libOverlay;
overlays.default = final: prev: {
inherit (self) lib;
overlay = final: prev:
let rust' = (prev.extend rust.overlay).rust-bin.nightly.latest.default;
in {
lib = prev.lib.extend libOverlay;
preserves-nim = final.callPackage ./preserves-nim { };
preserves-tools =
final.callPackage ./preserves-tools { rust = rust'; };
syndicate-rs = final.callPackage ./syndicate-rs { rust = rust'; };
fetchFromSyndicateLang =
{ owner ? "syndicate-lang", repo, rev, hash ? prev.lib.fakeHash }:
prev.fetchFromGitea {
domain = "git.syndicate-lang.org";
inherit owner repo rev hash;
};
packages = forEachSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}.extend self.overlay;
in with pkgs; { inherit preserves-nim preserves-tools syndicate-rs; });
naersk = prev.callPackage naersk { };
nixosModules.syndicate-server =
# A little hack to apply our overlay to this module only.
let f = import ./nixos/syndicate-server.nix;
in { config, lib, pkgs, ... }:
f {
inherit config lib;
pkgs = pkgs.extend self.overlay;
nimPackages = prev.nimPackages.overrideScope' (final': prev': {
preserves = final'.callPackage ./preserves-nim { };
syndicate = final'.callPackage ./syndicate-nim { };
syndicate_utils = final'.callPackage ./syndicate_utils-nim { };
xdg_open_ng = final'.callPackage ./xdg_open_ng { };
});
python3Packages = prev.python3Packages.override {
overrides = final': prev': {
preserves = final'.callPackage ./preserves-py { };
syndicate = final'.callPackage ./syndicate-py { };
};
};
preserves-tools = final.callPackage ./preserves-tools { };
squeak = final.callPackage ./squeak { };
squeaker = final.python3Packages.callPackage ./squeaker { };
syndicate-server = final.callPackage ./syndicate-server { };
};
legacyPackages =
self.lib.mapAttrs (system: pkgs: pkgs.extend self.overlays.default)
(builtins.removeAttrs nixpkgs.legacyPackages [ "mipsel-linux" ]);
packages = self.lib.mapAttrs (system: pkgs:
with pkgs; {
inherit preserves-tools squeak squeaker syndicate-server;
inherit (nimPackages) syndicate_utils xdg_open_ng;
preserves-nim = nimPackages.preserves;
preserves-py = python3Packages.preserves;
syndicate-nim = nimPackages.syndicate;
syndicate-py = python3Packages.syndicate;
}) self.legacyPackages;
nixosModules.default = self.nixosModules.syndicate-server;
nixosModules.syndicate-server =
# A little hack to apply our overlay to this module only.
{ config, lib, pkgs, ... }:
(import ./nixos/syndicate-server.nix) {
inherit config lib;
pkgs = pkgs.extend self.overlays.default;
};
devShells = self.lib.mapAttrs (system: pkgs:
with pkgs; {
default =
mkShell { packages = builtins.attrValues self.packages.${system}; };
}) self.legacyPackages;
checks = self.lib.mapAttrs (system: pkgs':
with import (nixpkgs + "/nixos/lib/testing-python.nix") {
inherit system;
pkgs = pkgs';
}; {
http = simpleTest {
nodes.machine = { config, pkgs, ... }: {
imports = [ self.nixosModules.syndicate-server ];
nixpkgs.pkgs = pkgs';
services.syndicate.http = {
enable = true;
user = "nobody";
config = [
(pkgs.writeText "http.pr" ''
<require-service <daemon http_translator>>
<daemon http_translator {
argv: [ "${pkgs.nimPackages.syndicate_utils}/bin/http_translator" ]
protocol: text/syndicate
}>
let ?other = dataspace
$other [
? <http ?handle GET ?headers ?path ?body> [
<http $handle 200 {} "Hello world!">
]
]
? <service-object <daemon http_translator> ?cap> $cap [
<listen 8888>
<handler #{GET} [ "greeting" ] $other>
]
'')
];
};
};
testScript = ''
machine.wait_for_job("syndicate-http")
machine.wait_for_open_port(8888)
machine.succeed("curl --fail http://localhost:8888/greeting")
'';
};
}) { inherit (self.legacyPackages) x86_64-linux; };
};
}

41
lib.nix
View File

@ -5,14 +5,32 @@ in with lib; {
generators = with final.generators;
prev.generators // {
# Generates Preserves from an arbitrary value.
# Records are generated for functions that take
# a single formal argument `toRecord` and return
# a list of values.
/* Generates text-encoded Preserves from an arbitrary value.
Records are generated for lists with a final element in
the form of `{ record = «label»; }`.
Type: toPreserves :: a -> string
Example:
toPreserves { } [{ a = 0; b = 1; } "c" [ true false ] { record = "foo"; }]
=> "<foo { a: 0 b: 1 } \"c\" [ #t #f ]>"
*/
toPreserves = { }@args:
let
toPreserves' = toPreserves args;
concatItems = toString;
recordLabel = list:
with builtins;
let len = length list;
in if len == 0 then
null
else
let end = elemAt list (len - 1);
in if (isAttrs end) && (attrNames end) == [ "record" ] then
end
else
null;
in v:
if isAttrs v then
"{ ${
@ -20,16 +38,17 @@ in with lib; {
(key: val: "${key}: ${toPreserves' val}") v)
} }"
else if isList v then
"[ ${concatItems (map toPreserves' v)} ]"
let label = recordLabel v;
in if label == null then
"[ ${concatItems (map toPreserves' v)} ]"
else
"<${label.record} ${
concatItems (map toPreserves' (lib.lists.init v))
}>"
else if isBool v then
(if v then "#t" else "#f")
else if isFunction v then
(if (lib.functionArgs v) == { toRecord = false; } then
let items = v { toRecord = null; };
in "<${head items} ${toString (map toPreserves' (tail items))}>"
else
abort
"generators.toPreserves: cannot convert a function to Preserves")
abort "generators.toPreserves: cannot convert a function to Preserves"
else if isNull v then
"null"
else

View File

@ -2,101 +2,118 @@
with lib;
{
options.services.syndicate-server = {
enable = mkEnableOption "the Syndicate dataspace server";
group = mkOption {
type = types.str;
default = "wheel";
example = "users";
description = "Group account under which the Syndicate server runs.";
options.services.syndicate = mkOption {
default = { };
example = {
tty1 = {
enable = true;
user = "jane";
config = [ "/etc/syndicate" ];
};
};
description = ''
Syndicate dataspace server instances.
If the key is in the form of "tty''${N}" it will
be attached to the appropriate teletypewriter.
'';
type = types.attrsOf (types.submodule {
options = {
enable = mkEnableOption "this Syndicate dataspace server instance";
package = mkOption {
default = pkgs.syndicate-rs;
defaultText = "pkgs.syndicate-rs";
type = types.package;
description = "The package to use for the Syndicate dataspace server.";
};
runInDbusSession = mkEnableOption "dbus-run-session wrapper";
tcpListeners = mkOption {
default = [ ];
example = [{
address = "0.0.0.0";
port = 8001;
}];
type = with types;
listOf (submodule {
options = {
address = mkOption { type = str; };
port = mkOption { type = port; };
};
});
description = "TCP ports to listen for connections on.";
};
user = mkOption {
type = types.str;
example = "jane";
description = "User account under which the Syndicate server runs.";
};
unixListeners = mkOption {
default = [ "/run/syndicate/ds" ];
type = types.listOf types.path;
description = "Sockets to listen for connections on.";
};
package = mkOption {
default = pkgs.syndicate-server;
defaultText = "pkgs.syndicate-server";
type = types.package;
description =
"The package to use for the Syndicate dataspace server.";
};
config = mkOption {
type = types.listOf types.path;
description = "Configurations to load.";
example = [ "/etc/syndicate" ];
};
};
});
};
config = {
systemd.services = let
serverCfgs =
lib.attrsets.filterAttrs (_: cfg: cfg.enable) config.services.syndicate;
in builtins.listToAttrs (lib.lists.flatten (lib.attrsets.mapAttrsToList
(name: cfg:
let
configFileName = "syndicate-nixos-config.pr";
runtimeConfig = "\${RUNTIME_DIRECTORY}/${configFileName}";
configFile = pkgs.writeText configFileName
(lib.strings.concatMapStrings (dir: ''
<require-service <config-watcher "${dir}" $.>>
'') cfg.config);
in [{
name = "syndicate-${name}";
value = let
serviceConfig = let
loadConfig =
"${pkgs.coreutils}/bin/cp ${configFile} ${runtimeConfig}";
in {
RuntimeDirectory = name;
ExecStartPre = loadConfig;
ExecStart = "${
lib.optionalString cfg.runInDbusSession
"${pkgs.dbus}/bin/dbus-run-session "
}${cfg.package}/bin/syndicate-server --no-banner --config ${runtimeConfig}";
ExecReload = loadConfig;
User = cfg.user;
};
in {
description = "Syndicate dataspace server";
restartIfChanged = false;
reloadTriggers = [ configFile ];
wantedBy = [ "multi-user.target" ];
} // (if builtins.match "tty[0-9]" name == null then {
inherit serviceConfig;
} else {
after = [
"systemd-user-sessions.service"
"systemd-logind.service"
"getty@${name}.service"
];
wants = [ "dbus.socket" "systemd-logind.service" ];
conflicts = [ "getty@${name}.service" ];
unitConfig.ConditionPathExists = "/dev/${name}";
serviceConfig = serviceConfig // {
PAMName = "login";
StandardError = "journal";
StandardInput = "tty-fail";
StandardOutput = "journal";
TTYPath = "/dev/${name}";
TTYReset = "yes";
TTYVHangup = "yes";
TTYVTDisallocate = "yes";
UtmpIdentifier = "%n";
UtmpMode = "user";
WorkingDirectory = "~";
};
});
}]) (lib.attrsets.filterAttrs (_: cfg: cfg.enable)
config.services.syndicate)));
systemd.targets.multi-user.wants = lib.lists.flatten
(lib.attrsets.mapAttrsToList
(name: cfg: lib.optional cfg.enable "syndicate-${name}.service")
config.services.syndicate);
};
config = let
cfg = config.services.syndicate-server;
configDir = "/run/syndicate/config";
requireServiceRelayListener = spec:
"<require-service <relay-listener ${spec}>>";
in mkIf cfg.enable {
systemd.services.syndicate-server = {
description = "Syndicate dataspace server";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${configDir}";
ExecStart = "${cfg.package}/bin/syndicate-server --config ${configDir}";
Group = cfg.group;
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
DynamicUser = true;
Restart = "always";
RuntimeDirectory = "syndicate";
};
};
systemd.services.syndicate-server-unix-listeners = {
description = "Configure Syndicate unix listeners";
after = [ "syndicate-server.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = let
prsFile = builtins.toFile "unix-listeners.pr"
(lib.strings.concatMapStrings
(path: requireServiceRelayListener ''<unix "${path}">'')
cfg.unixListeners);
in "${pkgs.coreutils}/bin/cp ${prsFile} ${configDir}/nixos-unix-listeners.pr";
ExecStop =
"${pkgs.coreutils}/bin/rm ${configDir}/nixos-unix-listeners.pr";
RemainAfterExit = true;
};
};
systemd.services.syndicate-server-tcp-listeners = {
description = "Configure Syndicate TCP listeners";
after = [ "syndicate-server.service" "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = let
prsFile = builtins.toFile "tcp-listeners.pr"
(lib.strings.concatMapStrings ({ address, port }:
requireServiceRelayListener
''<tcp "${address}" ${toString port}>'') cfg.tcpListeners);
in "${pkgs.coreutils}/bin/cp ${prsFile} ${configDir}/nixos-tcp-listeners.pr";
ExecStop =
"${pkgs.coreutils}/bin/rm ${configDir}/nixos-tcp-listeners.pr";
RemainAfterExit = true;
};
};
};
}

View File

@ -1,13 +1,11 @@
{ lib, nimPackages, fetchFromGitea, fetchFromGitHub }:
with nimPackages;
{ lib, stdenv, buildNimPackage, fetchFromGitea, fetchFromGitHub, runCommand
, nim-unwrapped, preserves }:
let
compiler = fetchFromGitHub {
owner = "nim-lang";
repo = "nim";
rev = "v1.6.0";
hash = "sha256-C9oveXIufv0HqMQw6eNmLbku4Sd7r28PKcRILvKYzn0=";
};
compiler = runCommand "compiler.nimble" { inherit (nim-unwrapped) src; } ''
mkdir -p $out
tar xf $src --strip-components=1 -C $out
'';
npeg = fetchFromGitHub {
owner = "zevv";
@ -17,18 +15,22 @@ let
};
in buildNimPackage rec {
outputs = [ "out" "dev" ];
pname = "preserves";
version = "3.0.0";
version = "20220625";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = "preserves-nim";
rev = "v${version}";
sha256 = "sha256-YcWJkDJIo1UcXyqQTv82ebDeT03f5LqnuIKVtkvBClA=";
repo = "${pname}-nim";
rev = version;
sha256 = "sha256-ZNgBlIOKyWD0R5wZvGb/0K5tUpz5q5QpET4Qa/kxhkA=";
};
buildInputs = [ compiler npeg ];
propagatedBuildInputs = [ compiler npeg ];
propagatedNativeBuildInputs =
lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) preserves;
# propagate the utilities of this package for this build platform
preConfigure = "substituteInPlace preserves.nimble --replace '# bin ' 'bin '";
postInstall = ''
pushd $out/bin
for link in preserves_decode preserves_from_json preserves_to_json;
@ -37,4 +39,9 @@ in buildNimPackage rec {
popd
'';
doCheck = true;
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

26
preserves-py/default.nix Normal file
View File

@ -0,0 +1,26 @@
{ lib, buildPythonPackage, fetchFromGitea, python, setuptools-scm }:
buildPythonPackage rec {
pname = "preserves";
version = "unstable-2022-03-08";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "syndicate-lang";
repo = pname;
rev = "197359ff22fa701d8b497860e8eb84dba209e00e";
sha256 = "sha256-1nlyqcNIDGuNzo5/ObjF4YIWbpD8lxgVFXcKM+Dv6PY=";
};
sourceRoot = "source/implementations/python";
buildInputs = [ setuptools-scm ];
postInstall =
"install -t $out/lib/${python.libPrefix}/site-packages/preserves preserves/*.prb ";
meta = src.meta // {
homepage = "https://syndicate-lang.org";
maintainers = with lib.maintainers; [ ehmry ];
};
}

View File

@ -1,22 +1,18 @@
{ lib, rustPlatform, rust, fetchCrate }:
{ lib, naersk, fetchCrate }:
rustPlatform.buildRustPackage rec {
pname = "preserves-tool";
# use the name of the actual utility so that
# nix run …#preserves-tools works as expected.
naersk.buildPackage rec {
pname = "preserves-tools";
version = "1.0.0";
version = "2.5.0";
src = fetchCrate {
pname = "preserves-tools"; # name of the crate
inherit version;
sha256 = "10vy7pmdbxkcwbr1qwqqv1lfi622pk8ncbp1hn5jrddxrv92q4ph";
inherit pname version;
sha256 = "sha256-OFL56fJQdv04QxfIPqDS1WO+H9ApcLgCZtpKq9cMlSs=";
};
cargoHash = "sha256-h6ulvjTDTj8/fmzEn1YgZKmze4jwpmGjcSq78hmq2cU=";
nativeBuildInputs = [ rust ];
meta = {
description = "Swiss army knife for working with Preserves documents";
homepage = "https://preserves.gitlab.io/preserves/doc/preserves-tool.html";
maintainers = with lib.maintainers; [ ehmry ];
mainProgram = "preserves-tool";
};
}

74
squeak/default.nix Normal file
View File

@ -0,0 +1,74 @@
{ lib, stdenv, fetchurl, autoPatchelfHook, makeWrapper, unzip, alsa-lib, libGL
, libpulseaudio, libuuid, nas, openssl, pango, sndio, xorg }:
let
versionA = "6.0";
versionB = "22101";
versionC = "202206021410";
bits = with stdenv.hostPlatform;
if is32bit then
"32"
else if is64bit then
"64"
else
throw "too many addressing bits";
sources = {
i686-linux = fetchurl {
url =
"http://files.squeak.org/${versionA}/Squeak${versionA}-${versionB}-32bit/Squeak${versionA}-${versionB}-${bits}bit-${versionC}-Linux-x86.tar.gz";
sha256 = "sha256-z7o3R/KwqfYPMtjk93aCNrM2tHt+pDmYSLn3Sd53hVg=";
};
x86_64-linux = fetchurl {
url =
"http://files.squeak.org/${versionA}/Squeak${versionA}-${versionB}-${bits}bit/Squeak${versionA}-${versionB}-${bits}bit-${versionC}-Linux-x64.tar.gz";
sha256 = "sha256-+HnISzA2LxgJTvAjXrpP6/jmo3w0ABzJdy3pPWceIcg=";
};
};
in stdenv.mkDerivation rec {
pname = "squeak";
version = "${versionA}-${versionB}-${versionC}";
src = sources.${stdenv.system};
nativeBuildInputs = [ autoPatchelfHook makeWrapper unzip ];
buildInputs = with xorg; [
alsa-lib
libGL
libICE
libSM
libX11
libXext
libXrender
libpulseaudio
libuuid
nas
pango
sndio
];
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
cp -a bin $out/lib
cp -a shared/* $out/lib
makeWrapper $out/lib/squeak $out/bin/squeak \
--prefix LD_LIBRARY_PATH ":" "$out/lib:${
lib.makeLibraryPath [ openssl ]
}" \
--set SQUEAK_IMAGE $out/lib/Squeak${versionA}-${versionB}-${bits}bit.image
'';
preFixup = ''
patchelf $out/lib/vm-sound-sndio.so \
--replace-needed libsndio.so.6.1 libsndio.so
'';
meta = {
description = "Squeak virtual machine and image";
homepage = "https://squeak.org/";
license = with lib.licenses; [ asl20 mit ];
maintainers = with lib.maintainers; [ ehmry ];
platforms = builtins.attrNames sources;
};
}

32
squeaker/default.nix Normal file
View File

@ -0,0 +1,32 @@
{ lib, buildPythonApplication, fetchFromGitHub }:
buildPythonApplication rec {
pname = "squeaker";
version = "unstable-2022-03-04";
src = fetchFromGitHub {
owner = "tonyg";
repo = pname;
rev = "caf2ef0b6d5c3cd211b966d3933d4baa885676b5";
hash = "sha256-DXYKT3buaQ0WfebNwdGT3s2eAAKpndmZ3TczCD/alH0=";
};
# TODO: could inject squeak into the wrapper,
# but for now let the environment pick the VM
# propagatedBuildInputs = [ squeak ];
dontBuild = true;
doCheck = false;
installPhase = ''
runHook preInstall
install -Dt $out/bin squeaker
runHook postInstall
'';
meta = src.meta // {
description = "Like Docker, but for Squeak";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ ehmry ];
};
}

29
syndicate-nim/default.nix Normal file
View File

@ -0,0 +1,29 @@
{ lib, buildNimPackage, fetchFromGitea, fetchFromGitHub, preserves }:
let
nimSHA2 = fetchFromGitHub {
owner = "jangko";
repo = "nimSHA2";
rev = "b8f666069dff1ed0c5142dd1ca692f0e71434716";
hash = "sha256-Wqb3mQ7638UOTze71mf6WMyGiw9qTwhbJiGGb+9OR2k=";
};
in buildNimPackage rec {
pname = "syndicate";
version = "20220627";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = "${pname}-nim";
rev = version;
hash = "sha256-o9RvXLsGK1sJzA2eshAxxD2/PznIqmBrSTh8NmZdIJU=";
};
propagatedBuildInputs = [ nimSHA2 preserves ];
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

24
syndicate-py/default.nix Normal file
View File

@ -0,0 +1,24 @@
{ lib, buildPythonPackage, fetchFromGitea, setuptools-scm, preserves, websockets
}:
buildPythonPackage rec {
pname = "syndicate";
version = "unstable-2022-02-04";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "syndicate-lang";
repo = "${pname}-py";
rev = "3187c4642bd3816382c9c9d86d28ef35dc206f0d";
sha256 = "sha256-ilRoNtOV21naB5pJRM4DXEYAShGzFodwB5jAl94yIuo=";
};
buildInputs = [ setuptools-scm ];
propagatedBuildInputs = [ preserves websockets ];
meta = src.meta // {
homepage = "https://syndicate-lang.org";
description = "An implementation of Syndicated Actors for Python";
maintainers = with lib.maintainers; [ ehmry ];
};
}

View File

@ -1,21 +0,0 @@
{ lib, rustPlatform, rust, fetchgit, pkg-config, openssl }:
rustPlatform.buildRustPackage rec {
pname = "syndicate-rs";
version = "2021-09-01";
src = fetchgit {
url = "https://git.syndicate-lang.org/syndicate-lang/syndicate-rs.git";
rev = "622115e13c69397dfa0beb433fdaf382949252b3";
sha256 = "sha256-7XcCiDlUntLRB0MLYk+57RSe4f6NyqRa/Jc42xrPOnQ=";
};
cargoHash = "sha256-sagyE3yCmSNwqgZrgnw1ar7S37iZhVYYpn3WtIoBIU8=";
nativeBuildInputs = [ rust pkg-config ];
buildInputs = [ openssl ];
meta = {
description =
"Rust implementation of Dataspaces, Syndicate, and a high-speed networked dataspace broker.";
homepage = "https://git.syndicate-lang.org/syndicate-lang/syndicate-rs/";
maintainers = with lib.maintainers; [ ehmry ];
};
}

View File

@ -0,0 +1,22 @@
# https://git.syndicate-lang.org/synit/synit/src/branch/main/packaging/packages/syndicate-server/APKBUILD
{ lib, naersk, fetchFromSyndicateLang, pkg-config, openssl }:
naersk.buildPackage rec {
pname = "syndicate-rs";
version = "0.26.0";
src = fetchFromSyndicateLang {
repo = pname;
rev = "${pname}-v${version}";
hash = "sha256-6zCfvvaDfOUWbKjLhJ9xMpQnajxt1sQObrdhnm06Zuc=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ];
meta = {
description = "Syndicate broker server";
homepage = "https://git.syndicate-lang.org/syndicate-lang/syndicate-rs/";
maintainers = with lib.maintainers; [ ehmry ];
mainProgram = "syndicate-server";
};
}

View File

@ -0,0 +1,41 @@
{ lib, buildNimPackage, fetchFromGitea, fetchFromGitHub, syndicate, libnotify }:
let
gtk2 = fetchFromGitHub {
owner = "nim-lang";
repo = "gtk2";
rev = "v1.3";
hash = "sha256-KPHMF2gHIwjRuslJOhbf7KU0VUwp4Oe0+63YKKOBCPk=";
};
nim-libnotify = buildNimPackage rec {
pname = "libnotify";
version = "HEAD";
src = fetchFromGitHub {
owner = "FedericoCeratto";
repo = "nim-${pname}";
rev = "c715ca5b23377a9bceba93529339526fbca11517";
hash = "sha256-Ifp7cV+Jxa7ZotggIkR6OT6I/f4LZ7ZBtSdfkjVtg7w=";
};
propagatedBuildInputs = [ libnotify gtk2 ];
};
in buildNimPackage rec {
pname = "syndicate_utils";
version = "20220628";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-/HoPR/SFZzIzICvscse4s13EKvjXs6qr2puhkv5qBso=";
};
propagatedBuildInputs = [ syndicate nim-libnotify ];
nimFlags =
[ "-p:${gtk2}/src/" ]; # everyone breaks the nimble rules, nim-lang included
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

42
xdg_open_ng/default.nix Normal file
View File

@ -0,0 +1,42 @@
{ lib, buildNimPackage, fetchFromGitea, makeDesktopItem, syndicate }:
buildNimPackage rec {
pname = "xdg_open_ng";
version = "20220625";
nimBinOnly = true;
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-yOuR4KYAMxlRc4AIr3ud0HzidHDQPeIiN3dzlnphLug=";
};
propagatedBuildInputs = [ syndicate ];
desktopItem = makeDesktopItem rec {
name = "xdg-open";
desktopName = "Syndicate URI dispatcher (xdg-open)";
exec = "${name} %U";
mimeTypes = [
"application/vnd.mozilla.xul+xml"
"application/xhtml+xml"
"text/html"
"text/xml"
"x-scheme-handler/http"
"x-scheme-handler/https"
];
};
postInstall = ''
mv $out/bin/xdg_open $out/bin/xdg-open
cp -a $desktopItem/* $out/
'';
meta = src.meta // {
description = "Replacement for xdg-open that uses Syndicate for messaging.";
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}