Compare commits

..

104 Commits

Author SHA1 Message Date
Emery Hemingway bf7152b25b syndicate_utils: 20240530 -> 20240610 2024-06-10 19:31:59 +03:00
Emery Hemingway 65f7505360 Build syndicate_utils for aarch64-linux 2024-06-03 22:50:34 +03:00
Emery Hemingway 0dd89af084 syndicate_utils: 20240407 -> 20240603 2024-06-03 18:54:32 +03:00
Emery Hemingway 3aab8d1323 Add buildNimSbom 2024-06-03 18:46:48 +03:00
Emery Hemingway 6f203e3181 Update flake input 2024-06-03 18:46:44 +03:00
Emery Hemingway 749a73d921 Apply latest nixfmt 2024-06-03 18:20:28 +03:00
Emery Hemingway c69eb46dc8 syndicate-server: 0.42.0 -> 0.45.0 2024-04-20 19:32:30 +02:00
Emery Hemingway 168b7a265d syndicate_utils: 20231130 -> 20240407 2024-04-07 18:38:47 +01:00
Emery Hemingway a09684a3ba Update nixpkgs input 2024-04-07 16:00:07 +01:00
Emery Hemingway 0b18f18b76 syndicate-server: 0.41.0 -> 0.42.0 2024-03-23 11:31:09 +00:00
Emery Hemingway ef18eedcca syndicate-server: 0.39.0 -> 0.41.0 2024-03-08 10:28:38 +00:00
Emery Hemingway be6bcb2d98 syndicate-server: 0.36.1 -> 0.39.0 2024-03-07 11:42:48 +00:00
Emery Hemingway 2f51b2f5fb synit-pid1: unstable-2023-02-07 -> -2023-11-01 2024-03-07 11:42:48 +00:00
Emery Hemingway 46dfdc0b4d Update inputs and some packages 2023-11-30 12:23:20 +02:00
Emery Hemingway 42e809cf9e Remove "with lib" from NixOS module 2023-11-30 12:22:49 +02:00
Emery Hemingway 6797aa595a python3Packages.synit-daemons: init at 2023-11-01 2023-11-29 10:47:53 +02:00
Emery Hemingway d58ddd7e9c python3Packages.syndicate-py: 0.13.0 -> 0.15.0 2023-11-29 10:25:38 +02:00
Emery Hemingway 5774d5a060 python3Packages.preserves: 0.17.0 -> 0.992.2 2023-11-29 10:25:10 +02:00
Emery Hemingway e28f71ba88 syndicate-server: 0.33.2 -> 0.36.1 2023-11-28 11:12:45 +02:00
Emery Hemingway 35f8f78b9e Add channel instructions to README 2023-11-26 18:10:56 +02:00
Emery Hemingway 34795431e5 Move toPreserves into nixprocessmgmt 2023-11-25 14:37:52 +02:00
Emery Hemingway e3f57d5006 syndicate-server: 0.33.1 -> 0.33.2 2023-10-19 14:46:00 +01:00
Emery Hemingway 7c4a693dfb syndicate-server: 0.31.0 -> 0.33.1 2023-10-18 15:48:21 +01:00
Emery Hemingway 8c727296c0 Deflakification 2023-10-10 13:54:11 +01:00
Emery Hemingway a581bce64c Update preserves-nim and syndicate-nim for Nim-2.0.0 2023-08-16 09:48:45 +01:00
Emery Hemingway 124911f948 Override nimPackages and nim2Packages 2023-08-10 11:46:11 +01:00
Emery Hemingway c9faca6bf9 syndicate_utils: 20230518 -> 20230801 2023-08-10 11:42:01 +01:00
Emery Hemingway ee76236c3d syndicated-open-20230630 <- xdg_open_ng-20230518 2023-07-10 21:24:02 +01:00
Emery Hemingway 622d374b54 xapian_actor: init at 20230610 2023-06-17 10:47:20 +01:00
Emery Hemingway 1476b69370 Update flake inputs 2023-06-01 10:30:37 +01:00
Emery Hemingway c9365bb9e8 nix_actor: init at 20230530 2023-05-30 13:42:29 +01:00
Emery Hemingway d9f276cba1 preserves-nim, syndicate-nim: update to 20230530 2023-05-30 13:21:31 +01:00
Emery Hemingway f8d23e9b8f sqlite_actor: init at 20230527 2023-05-27 23:15:14 +01:00
Emery Hemingway e5ad8cd019 overlay python3Packages in a composable way 2023-05-24 08:59:06 +01:00
Emery Hemingway 33784421aa nixos/syndicate-server: remove runInDbusSession option
DBus is a mess that we shouldn't get involved in. If you need DBus then use a
tool that can start DBus as it might be expected and then extract the
communication endpoints with the preserve_process_environment utility.

https://git.syndicate-lang.org/ehmry/syndicate_utils#preserve_process_environment
2023-05-24 08:46:32 +01:00
Emery Hemingway 847ed4ef13 nixos/syndicate-server: use a static configuration
Configure the server with a configuration path that points into
the Nix store rather than a file that is generated at start-up.
2023-05-24 08:43:29 +01:00
Emery Hemingway 9b06320ec9 preserves: 20230517 -> 20230520 2023-05-20 14:07:01 +01:00
Emery Hemingway 72ada7f789 syndicate_utils: 20230507 -> 20230518 2023-05-18 12:43:59 +01:00
Emery Hemingway 956473d5ac xdg_open_ng: 20220625 -> 20230518 2023-05-18 12:30:11 +01:00
Emery Hemingway d913e7b884 syndicate-nim: 20230506 -> 20230518 2023-05-18 12:27:35 +01:00
Emery Hemingway 1e2cb5e402 preserves-nim: 20230504 -> 20230517 2023-05-18 10:53:53 +01:00
Emery Hemingway 1b7e36f819 nimPackages.noiseprotocol: add placeholder 2023-05-15 22:39:57 +01:00
Emery Hemingway ab58a4a2dd noise-c: init at 20230309 2023-05-15 22:39:57 +01:00
Emery Hemingway 16712976b4 syndicate_utils: 20230410 -> 20230507 2023-05-15 22:39:57 +01:00
Emery Hemingway 573c005e73 acpi_actor: init at 20230506 2023-05-15 22:39:57 +01:00
Emery Hemingway 3f0fae629f libnotify_actor: 20230405 -> 20230506 2023-05-15 22:39:57 +01:00
Emery Hemingway 011f16989d fontconfig_actor: 20230330 -> 20230506 2023-05-15 22:39:57 +01:00
Emery Hemingway f1938f1a59 syndicate-nim: 20230410 -> 20230506 2023-05-15 22:39:57 +01:00
Emery Hemingway c9481a530f preserves-nim: 20230329 -> 20230504 2023-05-15 22:39:57 +01:00
Emery Hemingway ec9eba6a49 synit-pid1: init at unstable-2023-02-07 2023-05-15 22:39:57 +01:00
Emery Hemingway d41f771641 Update flake inputs 2023-05-15 22:39:56 +01:00
Emery Hemingway ab04c0c3ad syndicate-py: unstable-2022-02-04 -> 0.13.0 2023-05-15 22:39:25 +01:00
Emery Hemingway 09b24fd4c7 preserves-py: unstable-2022-03-08 -> 0.17.0 2023-05-15 22:39:25 +01:00
Emery Hemingway 84f0497e53 Move packages to /packages 2023-05-15 22:39:25 +01:00
Emery Hemingway 1a4e8de70f nixos/syndicate-server: do not restart or reload
Do not restart or reload a syndicate server service if anything
changes. The server should handle this on its own and spurious
restarts should be prevented if possible.
2023-05-15 22:39:25 +01:00
Emery Hemingway 30b8b5f0af Update nixpkgs 2023-05-15 22:39:24 +01:00
Emery Hemingway 89b9459a9b syndicate_utils: 20220628 -> 20230410 2023-05-15 22:39:01 +01:00
Emery Hemingway bfb320c524 syndiate-nim: 20230405 -> 20230410 2023-05-15 22:39:01 +01:00
Emery Hemingway 59975d0421 Add fontconfig_ and libnotify_actor to packages output 2023-05-15 22:39:01 +01:00
Emery Hemingway b7f303bebc Remove outdated http test 2023-05-15 22:39:00 +01:00
Emery Hemingway 0cd9e024f7 fontconfig_actor: init at 20230330 2023-05-15 22:37:53 +01:00
Emery Hemingway c670b9bbdb libnotify_actor: init at 20230405 2023-05-15 22:37:53 +01:00
Emery Hemingway be24eb9426 syndicate-server: 0.30.0 -> 0.31.0 2023-05-15 22:37:49 +01:00
Emery Hemingway 17c123cf35 nimPackages.syndicate: 20220627 -> 20230405 2023-05-15 22:36:11 +01:00
Emery Hemingway 6b870be460 syndicate-server: 0.24.0 -> 0.30.0 2023-05-15 22:35:09 +01:00
Emery Hemingway f9dd589c03 preserves-nim: 20220625 -> 20221020 2023-05-15 21:07:48 +01:00
Emery Hemingway 78b00b622d squeak: 22101 -> 22104 2023-05-15 21:07:48 +01:00
Emery Hemingway 15fdbe7884 Only one nixpkgs input 2023-05-15 21:07:47 +01:00
Emery Hemingway 0d0db67594 xdg-open: sure, mozilla whatever 2023-05-15 21:07:23 +01:00
Emery Hemingway 95f5ebe1ae squeak: 6.0rc1-22081-202206021410 -> 6.0-22101-202206021410 2023-05-15 21:07:23 +01:00
Emery Hemingway 12df19d07c squeak: 6.0beta-22058 -> 6.0rc1-22081 2023-05-15 21:07:23 +01:00
Emery Hemingway 2f10d1a32b Syndicate server test 2023-05-15 21:07:23 +01:00
Emery Hemingway 432acda322 syndicate_utils: 20220627 -> 20220628 2023-05-15 21:07:23 +01:00
Emery Hemingway 6ac58483dd nixos: optionally wrap syndicate-server with dbus-run-session 2023-05-15 21:07:23 +01:00
Emery Hemingway 66dc4883b5 syndicate_utils: init at 20220627 2023-05-15 21:07:23 +01:00
Emery Hemingway 2cfb731c4f nixos: improve config loading for syndicate-server
Use an intermediary configuration file to allow configuration
reloading.
2023-05-15 21:07:23 +01:00
Emery Hemingway 6048be2e90 preserves-nim, xdg_open_ng: update to 20220625 2023-05-15 21:07:23 +01:00
Emery Hemingway d7aadda36f nixos: add enabled dataspace servers to systemd wants 2023-05-15 21:07:23 +01:00
Emery Hemingway cc09df4d35 nixos: enable TTY dataspace server when enabled 2023-05-15 21:07:23 +01:00
Emery Hemingway 6e93921528 squeak: 6.0alpha-21540-202112201228 > 6.0beta-22058-202206021410 2023-05-15 21:07:23 +01:00
Emery Hemingway b3b2b3e614 nixos: refactor dataspace server for TTYs 2023-05-15 21:07:23 +01:00
Emery Hemingway 7687be15a6 xdg_open_ng: 0.3.2 -> 0.4.0 2023-05-15 21:07:23 +01:00
Emery Hemingway cd206c61a0 preserves-nim: 0.3.0 -> 0.3.1 2023-05-15 21:07:23 +01:00
Emery Hemingway b99a7c2404 xdg_open_ng: 0.3.1 -> 0.3.2 2023-05-15 21:07:23 +01:00
Emery Hemingway 3377c82cd4 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
2023-05-15 21:07:23 +01:00
Emery Hemingway 683e3e4613 xdg_open_ng: 0.1.0 -> 0.3.0 2023-05-15 21:07:23 +01:00
Emery Hemingway bc51123bb3 xdg_open_ng: add DesktopItem 2023-05-15 21:07:23 +01:00
Emery Hemingway 55c28835a5 squeak: 6.0alpha-21485-… -> 6.0alpha-21540-…
Add 32bit build as well.
2023-05-15 21:07:23 +01:00
Emery Hemingway c93c4bd2ba Add Squeak and Squeaker 2023-05-15 21:07:23 +01:00
Emery Hemingway 4f72148912 Add xdg_open_ng 2023-05-15 21:07:23 +01:00
Emery Hemingway 98e81b98e9 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"; } ]``.
2023-05-15 21:07:23 +01:00
Emery Hemingway 9c0ef4db5d More platforms 2023-05-15 21:07:23 +01:00
Emery Hemingway ad977e6318 syndicate-nim: 1.1.0 -> 1.2.0 2023-05-15 21:07:23 +01:00
Emery Hemingway d39ef52980 Remove NixOS module from README, not ready 2023-05-15 21:07:23 +01:00
Emery Hemingway 815d2d4d42 Add syndicate-nim 2023-05-15 21:07:23 +01:00
Emery Hemingway bf4fe90317 preserves-nim: 3.0.0 -> 3.2.0 2023-05-15 21:07:23 +01:00
Emery Hemingway 6ec736f4fa Add Python packages 2023-05-15 21:07:23 +01:00
Emery Hemingway 2e58706000 Refactor flake, update inputs 2023-05-15 21:07:22 +01:00
Emery Hemingway 51480849e2 Use a "master" branch for the sake of Nix tools 2023-05-15 21:06:38 +01:00
Emery Hemingway 392e335620 syndicate-rs-0.15.1 -> syndicate-server-0.24.0 2023-05-15 21:06:37 +01:00
Emery Hemingway abd2ba6f60 Refactor NixOS configuration of Syndicate server 2023-05-15 21:04:13 +01:00
Emery Hemingway 2a44a15be1 lib.generators.toPreserves: quote keys of attrsets 2023-05-15 21:04:13 +01:00
Emery Hemingway 3543097ce7 preserves-tools: 1.0.0 -> 2.3.0 2023-05-15 21:04:13 +01:00
Emery Hemingway ebac12fa2c syndicate-rs: 2021-09-01 -> 0.14.0 2023-05-15 21:03:57 +01:00
40 changed files with 1575 additions and 2082 deletions

View File

@ -1,81 +1,11 @@
# Syndicate Nix flake
Add as a Nix channel.
```sh
$ doas nix-channel --add https://git.syndicate-lang.org/ehmry/syndicate-flake/archive/trunk.tar.gz syndicate
```
To add to your local flake registry:
```sh
nix registry add syndicate "git+https://git.syndicate-lang.org/ehmry/syndicate-flake"
```
## Synit
``` nix
{
description = "Personal NixOS configurations";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
syndicate = {
url =
"git+https://git.syndicate-lang.org/ehmry/syndicate-flake?ref=synit";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, syndicate }:
let
inherit (nixpkgs) lib;
overlays = [ syndicate.overlays.default ];
in {
legacyPackages =
lib.attrsets.mapAttrs (system: pkgs: pkgs.appendOverlays overlays)
nixpkgs.legacyPackages;
nixosConfigurations = {
yourhost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
# A common bootloader
{
boot.loader = {
efi.canTouchEfiVariables = false;
grub = {
enable = true;
efiSupport = true;
devices = [ "nodev" ];
efiInstallAsRemovable = true;
forceInstall = true;
};
systemd-boot.enable = false; # obviously not
};
}
# A normal NixOS system, the default boot profile.
./your-normal-host-config/default.nix
# A Synit system nested inside and an alternative boot profile.
{
specialisation.synit = {
inheritParentConfig = false; # keep it simple for now
configuration = { config, ... }: {
imports = [
syndicate.nixosModules.synit
./your-normal-host-config/hardware-configuration.nix
];
nixpkgs.pkgs = self.legacyPackages.${config.nixpkgs.system};
};
};
}
];
};
};
};
}
$ nix registry add syndicate "git+https://git.syndicate-lang.org/ehmry/syndicate-flake"
```

196
build-nim-sbom.nix Normal file
View File

@ -0,0 +1,196 @@
{
lib,
stdenv,
fetchgit,
fetchzip,
runCommand,
xorg,
nim,
nimOverrides,
}:
let
fetchers = {
fetchzip =
{ url, sha256, ... }:
fetchzip {
name = "source";
inherit url sha256;
};
fetchgit =
{
fetchSubmodules ? false,
leaveDotGit ? false,
rev,
sha256,
url,
...
}:
fetchgit {
inherit
fetchSubmodules
leaveDotGit
rev
sha256
url
;
};
};
filterPropertiesToAttrs =
prefix: properties:
lib.pipe properties [
(builtins.filter ({ name, ... }: (lib.strings.hasPrefix prefix name)))
(map (
{ name, value }:
{
name = lib.strings.removePrefix prefix name;
inherit value;
}
))
builtins.listToAttrs
];
buildNimCfg =
{ backend, components, ... }:
let
componentSrcDirs = map (
{ properties, ... }:
let
fodProps = filterPropertiesToAttrs "nix:fod:" properties;
fod = fetchers.${fodProps.method} fodProps;
srcDir = fodProps.srcDir or "";
in
if srcDir == "" then fod else "${fod}/${srcDir}"
) components;
in
runCommand "nim.cfg"
{
outputs = [
"out"
"src"
];
nativeBuildInputs = [ xorg.lndir ];
}
''
pkgDir=$src/pkg
cat << EOF >> $out
backend:${backend}
path:"$src"
path:"$pkgDir"
EOF
mkdir -p "$pkgDir"
${lib.strings.concatMapStrings (d: ''
lndir "${d}" "$pkgDir"
'') componentSrcDirs}
'';
buildCommands = lib.attrsets.mapAttrsToList (
output: input: ''
nim compile $nimFlags --out:${output} ${input}
''
);
installCommands = lib.attrsets.mapAttrsToList (
output: input: ''
install -Dt $out/bin ${output}
''
);
in
callerArg: sbomArg:
let
applySbom =
{
passthru ? { },
...
}@prevAttrs:
let
sbom = lib.attrsets.recursiveUpdate (
if builtins.isAttrs sbomArg then sbomArg else builtins.fromJSON (builtins.readFile sbomArg)
) passthru.sbom or { };
properties = # SBOM metadata.component.properties as an attrset.
lib.attrsets.recursiveUpdate (builtins.listToAttrs sbom.metadata.component.properties)
passthru.properties or { };
nimBin = # A mapping of Nim module file paths to names of programs.
lib.attrsets.recursiveUpdate (lib.pipe properties [
(lib.attrsets.filterAttrs (name: value: lib.strings.hasPrefix "nim:bin:" name))
(lib.attrsets.mapAttrs' (
name: value: {
name = lib.strings.removePrefix "nim:bin:" name;
value = "${properties."nim:binDir" or (properties."nim:srcDir" or ".")}/${value}";
}
))
]) passthru.nimBin or { };
in
{
strictDeps = true;
pname = prevAttrs.pname or sbom.metadata.component.name;
version = prevAttrs.version or sbom.metadata.component.version or null;
configurePhase =
prevAttrs.configurePhase or ''
runHook preConfigure
echo "nim.cfg << $nimCfg"
cat $nimCfg >> nim.cfg
cat << EOF >> nim.cfg
nimcache:"$NIX_BUILD_TOP/nimcache"
parallelBuild:$NIX_BUILD_CORES
EOF
runHook postConfigure
'';
buildPhase =
prevAttrs.buildPhase or ''
runHook preBuild
${lib.strings.concatLines (buildCommands nimBin)}
runHook postBuild
'';
installPhase =
prevAttrs.installPhase or ''
runHook preInstall
${lib.strings.concatLines (installCommands nimBin)}
runHook postInstall
'';
nativeBuildInputs = (prevAttrs.nativeBuildInputs or [ ]) ++ [ nim ];
nimCfg =
prevAttrs.nimCfg or (buildNimCfg {
backend = prevAttrs.nimBackend or properties."nim:backend" or "c";
inherit (sbom) components;
});
passthru = {
inherit sbom properties nimBin;
};
};
applyOverrides =
prevAttrs:
builtins.foldl' (
prevAttrs:
{ name, ... }@component:
if (builtins.hasAttr name nimOverrides) then
prevAttrs // (nimOverrides.${name} component prevAttrs)
else
prevAttrs
) prevAttrs prevAttrs.passthru.sbom.components;
composition =
finalAttrs:
let
callerAttrs = if builtins.isAttrs callerArg then callerArg else callerArg finalAttrs;
sbomAttrs = callerAttrs // (applySbom callerAttrs);
overrideAttrs = sbomAttrs // (applyOverrides sbomAttrs);
in
overrideAttrs;
in
stdenv.mkDerivation composition
# TODO: Add an overrideSbom function into the result..

8
default.nix Normal file
View File

@ -0,0 +1,8 @@
{
pkgs ? null,
}:
let
overlay = import ./overlay.nix;
pkgs' = if pkgs == null then import <nixpkgs> { overlays = [ overlay ]; } else pkgs.extend overlay;
in
builtins.intersectAttrs (overlay { } { }) pkgs'

View File

@ -1,61 +1,23 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1663157994,
"narHash": "sha256-aHtdu/HuYImL59u1JbCLcHt26nMYsHRAuwHjlon2GVY=",
"lastModified": 1717196966,
"narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a083302d81557103200fd6f15ae4aba2ea0bafaa",
"rev": "57610d2f8f0937f39dbd72251e9614b1561942d8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "release-22.05",
"repo": "nixpkgs",
"type": "github"
"id": "nixpkgs",
"ref": "57610d2f8f09",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust": "rust"
}
},
"rust": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1663038100,
"narHash": "sha256-DpqF/1FYpUo3Fm54oBaXzdqIG7BuRkHHFOgLM0uVVF0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "dbd08f5b5469e1e24f00de45ddc73c26290a2bcb",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
"nixpkgs": "nixpkgs"
}
}
},

198
flake.nix
View File

@ -1,152 +1,88 @@
{
description = "Syndicate utilities";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-22.05";
inputs.rust = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nixpkgs.url = "nixpkgs/57610d2f8f09";
outputs = { self, nixpkgs, rust }: {
lib = nixpkgs.lib.extend (import ./lib.nix);
outputs =
{ self, nixpkgs }:
{
lib = nixpkgs.lib.extend (import ./lib.nix);
overlays.default = final: prev:
let
rust' =
(prev.extend rust.overlays.default).rust-bin.nightly.latest.default;
in {
inherit (self) lib;
overlays.default = import ./overlay.nix;
nimPackages = prev.nimPackages.overrideScope' (final': prev': {
preserves = final'.callPackage ./packages/preserves-nim { };
syndicate = final'.callPackage ./packages/syndicate-nim { };
syndicate_utils =
final'.callPackage ./packages/syndicate_utils-nim { };
xdg_open_ng = final'.callPackage ./packages/xdg_open_ng { };
});
python3Packages = prev.python3Packages.override {
overrides = final': prev': {
preserves = final'.callPackage ./packages/preserves-py { };
syndicate = final'.callPackage ./packages/syndicate-py { };
synit-daemons = final'.callPackage ./packages/synit-daemons { };
};
};
preserves-tools =
final.callPackage ./packages/preserves-tools { rust = rust'; };
squeak = final.callPackage ./packages/squeak { };
squeaker = final.python3Packages.callPackage ./packages/squeaker { };
syndicate-server =
final.callPackage ./packages/syndicate-server { rust = rust'; };
synit-pid1 = final.callPackage ./packages/synit-pid1 { rust = rust'; };
legacyPackages = self.lib.mapAttrs (system: pkgs: pkgs.extend self.overlays.default) {
inherit (nixpkgs.legacyPackages) aarch64-linux x86_64-linux;
};
legacyPackages =
self.lib.mapAttrs (system: pkgs: pkgs.extend self.overlays.default) {
inherit (nixpkgs.legacyPackages) i686-linux x86_64-linux;
};
packages = self.lib.mapAttrs (
system: pkgs: with pkgs; {
inherit
# fontconfig_actor
libnotify_actor
noise-c
preserves-tools
squeak
squeaker
syndicate-server
syndicated-open
syndicate_utils
;
preserves-py = python3Packages.preserves;
syndicate-py = python3Packages.syndicate-py;
}
) self.legacyPackages;
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;
syndicate-server =
nixosModules.default = self.nixosModules.syndicate-server;
nixosModules.syndicate-server =
# A little hack to apply our overlay to this module only.
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
(import ./nixos/syndicate-server.nix) {
inherit config lib;
pkgs = pkgs.extend self.overlays.default;
};
synit.imports = [
./nixos/modules/system/boot/stage-1.nix
./nixos/modules/system/boot/stage-2.nix
./nixos/modules/system/boot/synit.nix
];
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';
}; {
simple = simpleTest {
name = "http";
nodes.machine =
{ config, pkgs, ... }:
{
imports = [ self.nixosModules.syndicate-server ];
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>
]
'')
];
};
nixpkgs.pkgs = pkgs';
services.syndicate.tty1 = {
enable = true;
user = "loser";
config = [ ];
};
users.users.loser.isNormalUser = true;
};
testScript = ''
machine.wait_for_job("syndicate-tty1")
'';
};
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; };
synit = simpleTest {
nodes.machine = {
imports = [
self.nixosModules.synit
];
nixpkgs.pkgs = pkgs';
};
testScript = ''
start_all()
machine.wait_for_unit("foo.service")
'';
};
}) { inherit (self.legacyPackages) x86_64-linux; };
};
hydraJobs.packages.aarch64-linux = {
inherit (self.packages.aarch64-linux) syndicate_utils;
};
};
}

64
lib.nix
View File

@ -1,58 +1,14 @@
final: prev:
let lib = final;
in with lib; {
let
lib = final;
in
with lib;
{
generators = with final.generators;
prev.generators // {
/* 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
"{ ${
concatItems (lib.attrsets.mapAttrsToList
(key: val: "${key}: ${toPreserves' val}") v)
} }"
else if isList v then
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
abort "generators.toPreserves: cannot convert a function to Preserves"
else if isNull v then
"null"
else
builtins.toJSON v;
generators =
with final.generators;
prev.generators
// {
toPreserves = throw "moved to https://git.syndicate-lang.org/ehmry/nix-processmgmt/src/branch/synit/nixproc/backends/synit";
};
}

View File

@ -1,626 +0,0 @@
#! @shell@
targetRoot=/mnt-root
console=tty1
verbose="@verbose@"
info() {
if [[ -n "$verbose" ]]; then
echo "$@"
fi
}
extraUtils="@extraUtils@"
export LD_LIBRARY_PATH=@extraUtils@/lib
export PATH=@extraUtils@/bin
ln -s @extraUtils@/bin /bin
# Copy the secrets to their needed location
if [ -d "@extraUtils@/secrets" ]; then
for secret in $(cd "@extraUtils@/secrets"; find . -type f); do
mkdir -p $(dirname "/$secret")
ln -s "@extraUtils@/secrets/$secret" "$secret"
done
fi
fail() {
if [ -n "$panicOnFail" ]; then exit 1; fi
@preFailCommands@
# If starting stage 2 failed, allow the user to repair the problem
# in an interactive shell.
cat <<EOF
An error occurred in stage 1 of the boot process, which must mount the
root filesystem on \`$targetRoot' and then start stage 2. Press one
of the following keys:
EOF
if [ -n "$allowShell" ]; then cat <<EOF
i) to launch an interactive shell
f) to start an interactive shell having pid 1 (needed if you want to
start stage 2's init manually)
EOF
fi
cat <<EOF
r) to reboot immediately
*) to ignore the error and continue
EOF
read -n 1 reply
if [ -n "$allowShell" -a "$reply" = f ]; then
exec setsid @shell@ -c "exec @shell@ < /dev/$console >/dev/$console 2>/dev/$console"
elif [ -n "$allowShell" -a "$reply" = i ]; then
echo "Starting interactive shell..."
setsid @shell@ -c "exec @shell@ < /dev/$console >/dev/$console 2>/dev/$console" || fail
elif [ "$reply" = r ]; then
echo "Rebooting..."
reboot -f
else
info "Continuing..."
fi
}
trap 'fail' 0
# Print a greeting.
info
info "<<< NixOS Stage 1 >>>"
info
# Make several required directories.
mkdir -p /etc/udev
touch /etc/fstab # to shut up mount
ln -s /proc/mounts /etc/mtab # to shut up mke2fs
touch /etc/udev/hwdb.bin # to shut up udev
touch /etc/initrd-release
# Function for waiting for device(s) to appear.
waitDevice() {
local device="$1"
# Split device string using ':' as a delimiter as bcachefs
# uses this for multi-device filesystems, i.e. /dev/sda1:/dev/sda2:/dev/sda3
local IFS=':'
# USB storage devices tend to appear with some delay. It would be
# great if we had a way to synchronously wait for them, but
# alas... So just wait for a few seconds for the device to
# appear.
for dev in $device; do
if test ! -e $dev; then
echo -n "waiting for device $dev to appear..."
try=20
while [ $try -gt 0 ]; do
sleep 1
udevadm trigger --action=add
if test -e $dev; then break; fi
echo -n "."
try=$((try - 1))
done
echo
[ $try -ne 0 ]
fi
done
}
# Mount special file systems.
specialMount() {
local device="$1"
local mountPoint="$2"
local options="$3"
local fsType="$4"
mkdir -m 0755 -p "$mountPoint"
mount -n -t "$fsType" -o "$options" "$device" "$mountPoint"
}
source @earlyMountScript@
# Copy initrd secrets from /.initrd-secrets to their actual destinations
if [ -d "/.initrd-secrets" ]; then
#
# Secrets are named by their full destination pathname and stored
# under /.initrd-secrets/
#
for secret in $(cd "/.initrd-secrets"; find . -type f); do
mkdir -p $(dirname "/$secret")
cp "/.initrd-secrets/$secret" "$secret"
done
fi
# Log the script output to /dev/kmsg or /run/log/stage-1-init.log.
mkdir -p /tmp
mkfifo /tmp/stage-1-init.log.fifo
logOutFd=8 && logErrFd=9
eval "exec $logOutFd>&1 $logErrFd>&2"
if test -w /dev/kmsg; then
tee -i < /tmp/stage-1-init.log.fifo /proc/self/fd/"$logOutFd" | while read -r line; do
if test -n "$line"; then
echo "<7>stage-1-init: [$(date)] $line" > /dev/kmsg
fi
done &
else
mkdir -p /run/log
tee -i < /tmp/stage-1-init.log.fifo /run/log/stage-1-init.log &
fi
exec > /tmp/stage-1-init.log.fifo 2>&1
# Process the kernel command line.
export stage2Init=/init
for o in $(cat /proc/cmdline); do
case $o in
console=*)
set -- $(IFS==; echo $o)
params=$2
set -- $(IFS=,; echo $params)
console=$1
;;
init=*)
set -- $(IFS==; echo $o)
stage2Init=$2
;;
boot.persistence=*)
set -- $(IFS==; echo $o)
persistence=$2
;;
boot.persistence.opt=*)
set -- $(IFS==; echo $o)
persistence_opt=$2
;;
boot.trace|debugtrace)
# Show each command.
set -x
;;
boot.shell_on_fail)
allowShell=1
;;
boot.debug1|debug1) # stop right away
allowShell=1
fail
;;
boot.debug1devices) # stop after loading modules and creating device nodes
allowShell=1
debug1devices=1
;;
boot.debug1mounts) # stop after mounting file systems
allowShell=1
debug1mounts=1
;;
boot.panic_on_fail|stage1panic=1)
panicOnFail=1
;;
root=*)
# If a root device is specified on the kernel command
# line, make it available through the symlink /dev/root.
# Recognise LABEL= and UUID= to support UNetbootin.
set -- $(IFS==; echo $o)
if [ $2 = "LABEL" ]; then
root="/dev/disk/by-label/$3"
elif [ $2 = "UUID" ]; then
root="/dev/disk/by-uuid/$3"
else
root=$2
fi
ln -s "$root" /dev/root
;;
copytoram)
copytoram=1
;;
findiso=*)
# if an iso name is supplied, try to find the device where
# the iso resides on
set -- $(IFS==; echo $o)
isoPath=$2
;;
esac
done
# Set hostid before modules are loaded.
# This is needed by the spl/zfs modules.
@setHostId@
# Load the required kernel modules.
mkdir -p /lib
ln -s @modulesClosure@/lib/modules /lib/modules
ln -s @modulesClosure@/lib/firmware /lib/firmware
# see comment in stage-1.nix for explanation
echo @extraUtils@/bin/modprobe-kernel > /proc/sys/kernel/modprobe
for i in @kernelModules@; do
info "loading module $(basename $i)..."
modprobe $i
done
# Create device nodes in /dev.
@preDeviceCommands@
info "running udev..."
ln -sfn /proc/self/fd /dev/fd
ln -sfn /proc/self/fd/0 /dev/stdin
ln -sfn /proc/self/fd/1 /dev/stdout
ln -sfn /proc/self/fd/2 /dev/stderr
mkdir -p /etc/udev
ln -sfn @udevRules@ /etc/udev/rules.d
mkdir -p /dev/.mdadm
udevd --daemon
udevadm trigger --action=add
udevadm settle
if test -n "$debug1devices"; then fail; fi
@postDeviceCommands@
# Check the specified file system, if appropriate.
checkFS() {
local device="$1"
local fsType="$2"
# Only check block devices.
if [ ! -b "$device" ]; then return 0; fi
# Don't check ROM filesystems.
if [ "$fsType" = iso9660 -o "$fsType" = udf ]; then return 0; fi
# Don't check resilient COWs as they validate the fs structures at mount time
if [ "$fsType" = btrfs -o "$fsType" = zfs -o "$fsType" = bcachefs ]; then return 0; fi
# Skip fsck for apfs as the fsck utility does not support repairing the filesystem (no -a option)
if [ "$fsType" = apfs ]; then return 0; fi
# Skip fsck for nilfs2 - not needed by design and no fsck tool for this filesystem.
if [ "$fsType" = nilfs2 ]; then return 0; fi
# Skip fsck for inherently readonly filesystems.
if [ "$fsType" = squashfs ]; then return 0; fi
# If we couldn't figure out the FS type, then skip fsck.
if [ "$fsType" = auto ]; then
echo 'cannot check filesystem with type "auto"!'
return 0
fi
# Device might be already mounted manually
# e.g. NBD-device or the host filesystem of the file which contains encrypted root fs
if mount | grep -q "^$device on "; then
echo "skip checking already mounted $device"
return 0
fi
# Optionally, skip fsck on journaling filesystems. This option is
# a hack - it's mostly because e2fsck on ext3 takes much longer to
# recover the journal than the ext3 implementation in the kernel
# does (minutes versus seconds).
if test -z "@checkJournalingFS@" -a \
\( "$fsType" = ext3 -o "$fsType" = ext4 -o "$fsType" = reiserfs \
-o "$fsType" = xfs -o "$fsType" = jfs -o "$fsType" = f2fs \)
then
return 0
fi
echo "checking $device..."
fsck -V -a "$device"
fsckResult=$?
if test $(($fsckResult | 2)) = $fsckResult; then
echo "fsck finished, rebooting..."
sleep 3
reboot -f
fi
if test $(($fsckResult | 4)) = $fsckResult; then
echo "$device has unrepaired errors, please fix them manually."
fail
fi
if test $fsckResult -ge 8; then
echo "fsck on $device failed."
fail
fi
return 0
}
# Function for mounting a file system.
mountFS() {
local device="$1"
local mountPoint="$2"
local options="$3"
local fsType="$4"
if [ "$fsType" = auto ]; then
fsType=$(blkid -o value -s TYPE "$device")
if [ -z "$fsType" ]; then fsType=auto; fi
fi
# Filter out x- options, which busybox doesn't do yet.
local optionsFiltered="$(IFS=,; for i in $options; do if [ "${i:0:2}" != "x-" ]; then echo -n $i,; fi; done)"
# Prefix (lower|upper|work)dir with /mnt-root (overlayfs)
local optionsPrefixed="$( echo "$optionsFiltered" | sed -E 's#\<(lowerdir|upperdir|workdir)=#\1=/mnt-root#g' )"
echo "$device /mnt-root$mountPoint $fsType $optionsPrefixed" >> /etc/fstab
checkFS "$device" "$fsType"
# Optionally resize the filesystem.
case $options in
*x-nixos.autoresize*)
if [ "$fsType" = ext2 -o "$fsType" = ext3 -o "$fsType" = ext4 ]; then
modprobe "$fsType"
echo "resizing $device..."
e2fsck -fp "$device"
resize2fs "$device"
elif [ "$fsType" = f2fs ]; then
echo "resizing $device..."
fsck.f2fs -fp "$device"
resize.f2fs "$device"
fi
;;
esac
# Create backing directories for overlayfs
if [ "$fsType" = overlay ]; then
for i in upper work; do
dir="$( echo "$optionsPrefixed" | grep -o "${i}dir=[^,]*" )"
mkdir -m 0700 -p "${dir##*=}"
done
fi
info "mounting $device on $mountPoint..."
mkdir -p "/mnt-root$mountPoint"
# For ZFS and CIFS mounts, retry a few times before giving up.
# We do this for ZFS as a workaround for issue NixOS/nixpkgs#25383.
local n=0
while true; do
mount "/mnt-root$mountPoint" && break
if [ \( "$fsType" != cifs -a "$fsType" != zfs \) -o "$n" -ge 10 ]; then fail; break; fi
echo "retrying..."
sleep 1
n=$((n + 1))
done
[ "$mountPoint" == "/" ] &&
[ -f "/mnt-root/etc/NIXOS_LUSTRATE" ] &&
lustrateRoot "/mnt-root"
true
}
lustrateRoot () {
local root="$1"
echo
echo -e "\e[1;33m<<< NixOS is now lustrating the root filesystem (cruft goes to /old-root) >>>\e[0m"
echo
mkdir -m 0755 -p "$root/old-root.tmp"
echo
echo "Moving impurities out of the way:"
for d in "$root"/*
do
[ "$d" == "$root/nix" ] && continue
[ "$d" == "$root/boot" ] && continue # Don't render the system unbootable
[ "$d" == "$root/old-root.tmp" ] && continue
mv -v "$d" "$root/old-root.tmp"
done
# Use .tmp to make sure subsequent invokations don't clash
mv -v "$root/old-root.tmp" "$root/old-root"
mkdir -m 0755 -p "$root/etc"
touch "$root/etc/NIXOS"
exec 4< "$root/old-root/etc/NIXOS_LUSTRATE"
echo
echo "Restoring selected impurities:"
while read -u 4 keeper; do
dirname="$(dirname "$keeper")"
mkdir -m 0755 -p "$root/$dirname"
cp -av "$root/old-root/$keeper" "$root/$keeper"
done
exec 4>&-
}
if test -e /sys/power/resume -a -e /sys/power/disk; then
if test -n "@resumeDevice@" && waitDevice "@resumeDevice@"; then
resumeDev="@resumeDevice@"
resumeInfo="$(udevadm info -q property "$resumeDev" )"
else
for sd in @resumeDevices@; do
# Try to detect resume device. According to Ubuntu bug:
# https://bugs.launchpad.net/ubuntu/+source/pm-utils/+bug/923326/comments/1
# when there are multiple swap devices, we can't know where the hibernate
# image will reside. We can check all of them for swsuspend blkid.
if waitDevice "$sd"; then
resumeInfo="$(udevadm info -q property "$sd")"
if [ "$(echo "$resumeInfo" | sed -n 's/^ID_FS_TYPE=//p')" = "swsuspend" ]; then
resumeDev="$sd"
break
fi
fi
done
fi
if test -n "$resumeDev"; then
resumeMajor="$(echo "$resumeInfo" | sed -n 's/^MAJOR=//p')"
resumeMinor="$(echo "$resumeInfo" | sed -n 's/^MINOR=//p')"
echo "$resumeMajor:$resumeMinor" > /sys/power/resume 2> /dev/null || echo "failed to resume..."
fi
fi
# If we have a path to an iso file, find the iso and link it to /dev/root
if [ -n "$isoPath" ]; then
mkdir -p /findiso
for delay in 5 10; do
blkid | while read -r line; do
device=$(echo "$line" | sed 's/:.*//')
type=$(echo "$line" | sed 's/.*TYPE="\([^"]*\)".*/\1/')
mount -t "$type" "$device" /findiso
if [ -e "/findiso$isoPath" ]; then
ln -sf "/findiso$isoPath" /dev/root
break 2
else
umount /findiso
fi
done
sleep "$delay"
done
fi
# Try to find and mount the root device.
mkdir -p $targetRoot
exec 3< @fsInfo@
while read -u 3 mountPoint; do
read -u 3 device
read -u 3 fsType
read -u 3 options
# !!! Really quick hack to support bind mounts, i.e., where the
# "device" should be taken relative to /mnt-root, not /. Assume
# that every device that starts with / but doesn't start with /dev
# is a bind mount.
pseudoDevice=
case $device in
/dev/*)
;;
//*)
# Don't touch SMB/CIFS paths.
pseudoDevice=1
;;
/*)
device=/mnt-root$device
;;
*)
# Not an absolute path; assume that it's a pseudo-device
# like an NFS path (e.g. "server:/path").
pseudoDevice=1
;;
esac
if test -z "$pseudoDevice" && ! waitDevice "$device"; then
# If it doesn't appear, try to mount it anyway (and
# probably fail). This is a fallback for non-device "devices"
# that we don't properly recognise.
echo "Timed out waiting for device $device, trying to mount anyway."
fi
# Wait once more for the udev queue to empty, just in case it's
# doing something with $device right now.
udevadm settle
# If copytoram is enabled: skip mounting the ISO and copy its content to a tmpfs.
if [ -n "$copytoram" ] && [ "$device" = /dev/root ] && [ "$mountPoint" = /iso ]; then
fsType=$(blkid -o value -s TYPE "$device")
fsSize=$(blockdev --getsize64 "$device" || stat -Lc '%s' "$device")
mkdir -p /tmp-iso
mount -t "$fsType" /dev/root /tmp-iso
mountFS tmpfs /iso size="$fsSize" tmpfs
cp -r /tmp-iso/* /mnt-root/iso/
umount /tmp-iso
rmdir /tmp-iso
continue
fi
if [ "$mountPoint" = / ] && [ "$device" = tmpfs ] && [ ! -z "$persistence" ]; then
echo persistence...
waitDevice "$persistence"
echo enabling persistence...
mountFS "$persistence" "$mountPoint" "$persistence_opt" "auto"
continue
fi
mountFS "$device" "$mountPoint" "$options" "$fsType"
done
exec 3>&-
@postMountCommands@
# Emit a udev rule for /dev/root to prevent systemd from complaining.
if [ -e /mnt-root/iso ]; then
eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/mnt-root/iso)
else
eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=$targetRoot)
fi
if [ "$ROOT_MAJOR" -a "$ROOT_MINOR" -a "$ROOT_MAJOR" != 0 ]; then
mkdir -p /run/udev/rules.d
echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > /run/udev/rules.d/61-dev-root-link.rules
fi
# Stop udevd.
udevadm control --exit
# Reset the logging file descriptors.
# Do this just before pkill, which will kill the tee process.
exec 1>&$logOutFd 2>&$logErrFd
eval "exec $logOutFd>&- $logErrFd>&-"
# Kill any remaining processes, just to be sure we're not taking any
# with us into stage 2. But keep storage daemons like unionfs-fuse.
#
# Storage daemons are distinguished by an @ in front of their command line:
# https://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/
for pid in $(pgrep -v -f '^@'); do
# Make sure we don't kill kernel processes, see #15226 and:
# http://stackoverflow.com/questions/12213445/identifying-kernel-threads
readlink "/proc/$pid/exe" &> /dev/null || continue
# Try to avoid killing ourselves.
[ $pid -eq $$ ] && continue
kill -9 "$pid"
done
if test -n "$debug1mounts"; then fail; fi
# Restore /proc/sys/kernel/modprobe to its original value.
echo /sbin/modprobe > /proc/sys/kernel/modprobe
# Start stage 2. `switch_root' deletes all files in the ramfs on the
# current root. The path has to be valid in the chroot not outside.
if [ ! -e "$targetRoot/$stage2Init" ]; then
stage2Check=${stage2Init}
while [ "$stage2Check" != "${stage2Check%/*}" ] && [ ! -L "$targetRoot/$stage2Check" ]; do
stage2Check=${stage2Check%/*}
done
if [ ! -L "$targetRoot/$stage2Check" ]; then
echo "stage 2 init script ($targetRoot/$stage2Init) not found"
fail
fi
fi
mkdir -m 0755 -p $targetRoot/proc $targetRoot/sys $targetRoot/dev $targetRoot/run
mount --move /proc $targetRoot/proc
mount --move /sys $targetRoot/sys
mount --move /dev $targetRoot/dev
mount --move /run $targetRoot/run
exec env -i $(type -P switch_root) "$targetRoot" "$stage2Init"
fail # should never be reached

View File

@ -1,427 +0,0 @@
# This module builds the initial ramdisk, which contains an init
# script that performs the first stage of booting the system: it loads
# the modules necessary to mount the root file system, then calls the
# init in the root file system to start the second boot stage.
{ config, lib, utils, pkgs, ... }:
with lib;
let
udev = pkgs.eudev;
kernel-name = config.boot.kernelPackages.kernel.name or "kernel";
modulesTree = config.system.modulesTree.override { name = kernel-name + "-modules"; };
firmware = config.hardware.firmware;
# Determine the set of modules that we need to mount the root FS.
modulesClosure = pkgs.makeModulesClosure {
rootModules = config.boot.initrd.availableKernelModules ++ config.boot.initrd.kernelModules;
kernel = modulesTree;
firmware = firmware;
allowMissing = false;
};
# The initrd only has to mount `/` or any FS marked as necessary for
# booting (such as the FS containing `/nix/store`, or an FS needed for
# mounting `/`, like `/` on a loopback).
fileSystems = filter utils.fsNeededForBoot config.system.build.fileSystems;
# A utility for enumerating the shared-library dependencies of a program
findLibs = pkgs.buildPackages.writeShellScriptBin "find-libs" ''
set -euo pipefail
declare -A seen
left=()
patchelf="${pkgs.buildPackages.patchelf}/bin/patchelf"
function add_needed {
rpath="$($patchelf --print-rpath $1)"
dir="$(dirname $1)"
for lib in $($patchelf --print-needed $1); do
left+=("$lib" "$rpath" "$dir")
done
}
add_needed "$1"
while [ ''${#left[@]} -ne 0 ]; do
next=''${left[0]}
rpath=''${left[1]}
ORIGIN=''${left[2]}
left=("''${left[@]:3}")
if [ -z ''${seen[$next]+x} ]; then
seen[$next]=1
# Ignore the dynamic linker which for some reason appears as a DT_NEEDED of glibc but isn't in glibc's RPATH.
case "$next" in
ld*.so.?) continue;;
esac
IFS=: read -ra paths <<< $rpath
res=
for path in "''${paths[@]}"; do
path=$(eval "echo $path")
if [ -f "$path/$next" ]; then
res="$path/$next"
echo "$res"
add_needed "$res"
break
fi
done
if [ -z "$res" ]; then
echo "Couldn't satisfy dependency $next" >&2
exit 1
fi
fi
done
'';
# Some additional utilities needed in stage 1, like mount, fsck
# etc. We don't want to bring in all of those packages, so we just
# copy what we need. Instead of using statically linked binaries,
# we just copy what we need from Glibc and use patchelf to make it
# work.
extraUtils = pkgs.runCommandCC "extra-utils"
{ nativeBuildInputs = [pkgs.buildPackages.nukeReferences];
allowedReferences = [ "out" ]; # prevent accidents like glibc being included in the initrd
}
''
set +o pipefail
mkdir -p $out/bin $out/lib
ln -s $out/bin $out/sbin
copy_bin_and_libs () {
[ -f "$out/bin/$(basename $1)" ] && rm "$out/bin/$(basename $1)"
cp -pdv $1 $out/bin
}
# Copy BusyBox.
for BIN in ${pkgs.busybox}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
# Copy some util-linux stuff.
copy_bin_and_libs ${pkgs.util-linux}/sbin/blkid
# Add RAID mdadm tool.
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdadm
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdmon
# Copy udev.
copy_bin_and_libs ${udev}/bin/udevd
copy_bin_and_libs ${udev}/bin/udevadm
for BIN in ${udev}/lib/udev/*_id; do
copy_bin_and_libs $BIN
done
# Copy modprobe.
copy_bin_and_libs ${pkgs.kmod}/bin/kmod
ln -sf kmod $out/bin/modprobe
# Dirty hack to make sure the kernel properly loads modules
# such as ext4 on demand (e.g. on a `mount(2)` syscall). This is necessary
# because `kmod` isn't linked against `libpthread.so.0` anymore (since
# it was merged into `libc.so.6` since version `2.34`), but still needs
# to access it for some reason. This is not an issue in stage-1 itself
# because of the `LD_LIBRARY_PATH`-variable and anytime later because the rpath of
# kmod/modprobe points to glibc's `$out/lib` where `libpthread.so.6` exists.
# However, this is a problem when the kernel calls `modprobe` inside
# the initial ramdisk because it doesn't know about the
# `LD_LIBRARY_PATH` and the rpath was nuked.
#
# Also, we can't use `makeWrapper` here because `kmod` only does
# `modprobe` functionality if `argv[0] == "modprobe"`.
cat >$out/bin/modprobe-kernel <<EOF
#!$out/bin/ash
export LD_LIBRARY_PATH=$out/lib
exec $out/bin/modprobe "\$@"
EOF
chmod +x $out/bin/modprobe-kernel
# Copy resize2fs if any ext* filesystems are to be resized
${optionalString (any (fs: fs.autoResize && (lib.hasPrefix "ext" fs.fsType)) fileSystems) ''
# We need mke2fs in the initrd.
copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs
''}
# Copy multipath.
${optionalString config.services.multipath.enable ''
copy_bin_and_libs ${config.services.multipath.package}/bin/multipath
copy_bin_and_libs ${config.services.multipath.package}/bin/multipathd
# Copy lib/multipath manually.
cp -rpv ${config.services.multipath.package}/lib/multipath $out/lib
''}
# Copy secrets if needed.
#
# TODO: move out to a separate script; see #85000.
${optionalString (!config.boot.loader.supportsInitrdSecrets)
(concatStringsSep "\n" (mapAttrsToList (dest: source:
let source' = if source == null then dest else source; in
''
mkdir -p $(dirname "$out/secrets/${dest}")
# Some programs (e.g. ssh) doesn't like secrets to be
# symlinks, so we use `cp -L` here to match the
# behaviour when secrets are natively supported.
cp -Lr ${source'} "$out/secrets/${dest}"
''
) config.boot.initrd.secrets))
}
${config.boot.initrd.extraUtilsCommands}
# Copy ld manually since it isn't detected correctly
cp -pv ${pkgs.stdenv.cc.libc.out}/lib/ld*.so.? $out/lib
# Copy all of the needed libraries
find $out/bin $out/lib -type f | while read BIN; do
echo "Copying libs for executable $BIN"
for LIB in $(${findLibs}/bin/find-libs $BIN); do
TGT="$out/lib/$(basename $LIB)"
if [ ! -f "$TGT" ]; then
SRC="$(readlink -e $LIB)"
cp -pdv "$SRC" "$TGT"
fi
done
done
# Strip binaries further than normal.
chmod -R u+w $out
stripDirs "$STRIP" "lib bin" "-s"
# Run patchelf to make the programs refer to the copied libraries.
find $out/bin $out/lib -type f | while read i; do
if ! test -L $i; then
nuke-refs -e $out $i
fi
done
find $out/bin -type f | while read i; do
if ! test -L $i; then
echo "patching $i..."
patchelf --set-interpreter $out/lib/ld*.so.? --set-rpath $out/lib $i || true
fi
done
if [ -z "${toString (pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform)}" ]; then
# Make sure that the patchelf'ed binaries still work.
echo "testing patched programs..."
$out/bin/ash -c 'echo hello world' | grep "hello world"
export LD_LIBRARY_PATH=$out/lib
$out/bin/mount --help 2>&1 | grep -q "BusyBox"
$out/bin/blkid -V 2>&1 | grep -q 'libblkid'
$out/bin/udevadm --version
$out/bin/mdadm --version
${optionalString config.services.multipath.enable ''
($out/bin/multipath || true) 2>&1 | grep -q 'need to be root'
($out/bin/multipathd || true) 2>&1 | grep -q 'need to be root'
''}
${config.boot.initrd.extraUtilsCommandsTest}
fi
''; # */
udevRules = pkgs.runCommand "udev-rules" {
allowedReferences = [ extraUtils ];
preferLocalBuild = true;
} ''
mkdir -p $out
echo 'ENV{LD_LIBRARY_PATH}="${extraUtils}/lib"' > $out/00-env.rules
cp -v ${udev}/var/lib/udev/rules.d/60-cdrom_id.rules $out/
cp -v ${udev}/var/lib/udev/rules.d/60-persistent-storage.rules $out/
cp -v ${udev}/var/lib/udev/rules.d/75-net-description.rules $out/
cp -v ${udev}/var/lib/udev/rules.d/80-drivers.rules $out/
cp -v ${udev}/var/lib/udev/rules.d/80-net-name-slot.rules $out/
${config.boot.initrd.extraUdevRulesCommands}
for i in $out/*.rules; do
substituteInPlace $i \
--replace ata_id ${extraUtils}/bin/ata_id \
--replace scsi_id ${extraUtils}/bin/scsi_id \
--replace cdrom_id ${extraUtils}/bin/cdrom_id \
--replace ${pkgs.coreutils}/bin/basename ${extraUtils}/bin/basename \
--replace ${pkgs.util-linux}/bin/blkid ${extraUtils}/bin/blkid \
--replace ${pkgs.mdadm}/sbin ${extraUtils}/sbin \
--replace ${pkgs.bash}/bin/sh ${extraUtils}/bin/sh \
--replace ${udev} ${extraUtils}
done
# Work around a bug in QEMU, which doesn't implement the "READ
# DISC INFORMATION" SCSI command:
# https://bugzilla.redhat.com/show_bug.cgi?id=609049
# As a result, `cdrom_id' doesn't print
# ID_CDROM_MEDIA_TRACK_COUNT_DATA, which in turn prevents the
# /dev/disk/by-label symlinks from being created. We need these
# in the NixOS installation CD, so use ID_CDROM_MEDIA in the
# corresponding udev rules for now. This was the behaviour in
# udev <= 154. See also
# http://www.spinics.net/lists/hotplug/msg03935.html
substituteInPlace $out/60-persistent-storage.rules \
--replace ID_CDROM_MEDIA_TRACK_COUNT_DATA ID_CDROM_MEDIA
''; # */
# The init script of boot stage 1 (loading kernel modules for
# mounting the root FS).
bootStage1 = pkgs.substituteAll {
src = ./stage-1-init.sh;
shell = "${extraUtils}/bin/ash";
isExecutable = true;
postInstall = ''
echo checking syntax
# check both with bash
${pkgs.buildPackages.bash}/bin/sh -n $target
# and with ash shell, just in case
${pkgs.buildPackages.busybox}/bin/ash -n $target
'';
inherit udevRules extraUtils modulesClosure;
inherit (config.boot) resumeDevice;
inherit (config.system.build) earlyMountScript;
inherit (config.boot.initrd) checkJournalingFS verbose
preDeviceCommands postDeviceCommands postMountCommands preFailCommands kernelModules;
resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
(filter (sd: hasPrefix "/dev/" sd.device && !sd.randomEncryption.enable
# Don't include zram devices
&& !(hasPrefix "/dev/zram" sd.device)
) config.swapDevices);
fsInfo =
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType (builtins.concatStringsSep "," fs.options) ];
in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
setHostId = optionalString (config.networking.hostId != null) ''
hi="${config.networking.hostId}"
${if pkgs.stdenv.isBigEndian then ''
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > /etc/hostid
'' else ''
echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > /etc/hostid
''}
'';
};
# The closure of the init script of boot stage 1 is what we put in
# the initial RAM disk.
initialRamdisk = pkgs.makeInitrd {
name = "initrd-${kernel-name}";
inherit (config.boot.initrd) compressor compressorArgs prepend;
contents =
[ { object = bootStage1;
symlink = "/init";
}
{ object = pkgs.writeText "mdadm.conf" config.boot.initrd.services.swraid.mdadmConf;
symlink = "/etc/mdadm.conf";
}
{ object = pkgs.runCommand "initrd-kmod-blacklist-ubuntu" {
src = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf";
preferLocalBuild = true;
} ''
target=$out
${pkgs.buildPackages.perl}/bin/perl -0pe 's/## file: iwlwifi.conf(.+?)##/##/s;' $src > $out
'';
symlink = "/etc/modprobe.d/ubuntu.conf";
}
{ object = config.environment.etc."modprobe.d/nixos.conf".source;
symlink = "/etc/modprobe.d/nixos.conf";
}
{ object = pkgs.kmod-debian-aliases;
symlink = "/etc/modprobe.d/debian.conf";
}
] ++ lib.optionals config.services.multipath.enable [
{ object = pkgs.runCommand "multipath.conf" {
src = config.environment.etc."multipath.conf".text;
preferLocalBuild = true;
} ''
target=$out
printf "$src" > $out
substituteInPlace $out \
--replace ${config.services.multipath.package}/lib ${extraUtils}/lib
'';
symlink = "/etc/multipath.conf";
}
] ++ (lib.mapAttrsToList
(symlink: options:
{
inherit symlink;
object = options.source;
}
)
config.boot.initrd.extraFiles);
};
# Script to add secret files to the initrd at bootloader update time
initialRamdiskSecretAppender =
let
compressorExe = initialRamdisk.compressorExecutableFunction pkgs;
in pkgs.writeScriptBin "append-initrd-secrets"
''
#!${pkgs.bash}/bin/bash -e
function usage {
echo "USAGE: $0 INITRD_FILE" >&2
echo "Appends this configuration's secrets to INITRD_FILE" >&2
}
if [ $# -ne 1 ]; then
usage
exit 1
fi
if [ "$1"x = "--helpx" ]; then
usage
exit 0
fi
${lib.optionalString (config.boot.initrd.secrets == {})
"exit 0"}
export PATH=${pkgs.coreutils}/bin:${pkgs.libarchive}/bin:${pkgs.gzip}/bin:${pkgs.findutils}/bin
function cleanup {
if [ -n "$tmp" -a -d "$tmp" ]; then
rm -fR "$tmp"
fi
}
trap cleanup EXIT
tmp=$(mktemp -d ''${TMPDIR:-/tmp}/initrd-secrets.XXXXXXXXXX)
${lib.concatStringsSep "\n" (mapAttrsToList (dest: source:
let source' = if source == null then dest else toString source; in
''
mkdir -p $(dirname "$tmp/.initrd-secrets/${dest}")
cp -a ${source'} "$tmp/.initrd-secrets/${dest}"
''
) config.boot.initrd.secrets)
}
(cd "$tmp" && find . -print0 | sort -z | bsdtar --uid 0 --gid 0 -cnf - -T - | bsdtar --null -cf - --format=newc @-) | \
${compressorExe} ${lib.escapeShellArgs initialRamdisk.compressorArgs} >> "$1"
'';
in
{
config = mkIf config.boot.initrd.enable {
system.build = lib.mapAttrs (_: lib.mkForce) { inherit bootStage1 initialRamdisk initialRamdiskSecretAppender extraUtils; };
};
}

View File

@ -1,131 +0,0 @@
#! @shell@
systemConfig=@systemConfig@
export HOME=/root PATH="@path@"
if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" != true ]; then
# Process the kernel command line.
for o in $(</proc/cmdline); do
case $o in
boot.debugtrace)
# Show each command.
set -x
;;
esac
done
# Print a greeting.
echo
echo -e "\e[1;32m<<< NixOS Stage 2 >>>\e[0m"
echo
# Normally, stage 1 mounts the root filesystem read/writable.
# However, in some environments, stage 2 is executed directly, and the
# root is read-only. So make it writable here.
if [ -z "$container" ]; then
mount -n -o remount,rw none /
fi
fi
# Likewise, stage 1 mounts /proc, /dev and /sys, so if we don't have a
# stage 1, we need to do that here.
if [ ! -e /proc/1 ]; then
specialMount() {
local device="$1"
local mountPoint="$2"
local options="$3"
local fsType="$4"
# We must not overwrite this mount because it's bind-mounted
# from stage 1's /run
if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" = true ] && [ "${mountPoint}" = /run ]; then
return
fi
install -m 0755 -d "$mountPoint"
mount -n -t "$fsType" -o "$options" "$device" "$mountPoint"
}
source @earlyMountScript@
fi
if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" = true ]; then
echo "booting system configuration ${systemConfig}"
else
echo "booting system configuration $systemConfig" > /dev/kmsg
fi
# Make /nix/store a read-only bind mount to enforce immutability of
# the Nix store. Note that we can't use "chown root:nixbld" here
# because users/groups might not exist yet.
# Silence chown/chmod to fail gracefully on a readonly filesystem
# like squashfs.
chown -f 0:30000 /nix/store
chmod -f 1775 /nix/store
if [ -n "@readOnlyStore@" ]; then
if ! [[ "$(findmnt --noheadings --output OPTIONS /nix/store)" =~ ro(,|$) ]]; then
if [ -z "$container" ]; then
mount --bind /nix/store /nix/store
else
mount --rbind /nix/store /nix/store
fi
mount -o remount,ro,bind /nix/store
fi
fi
# Log the script output to /dev/kmsg or /run/log/stage-2-init.log.
# Only at this point are all the necessary prerequisites ready for these commands.
exec {logOutFd}>&1 {logErrFd}>&2
if test -w /dev/kmsg; then
exec > >(tee -i /proc/self/fd/"$logOutFd" | while read -r line; do
if test -n "$line"; then
echo "<7>stage-2-init: $line" > /dev/kmsg
fi
done) 2>&1
else
mkdir -p /run/log
exec > >(tee -i /run/log/stage-2-init.log) 2>&1
fi
# Required by the activation script
install -m 0755 -d /etc /etc/nixos
install -m 01777 -d /tmp
# Run the script that performs all configuration activation that does
# not have to be done at boot time.
echo "running activation script..."
$systemConfig/activate
# Record the boot configuration.
ln -sfn "$systemConfig" /run/booted-system
# copy eudev rules over to /var
cp -ru @eudev@/var/lib/udev /var/lib/
# Run any user-specified commands.
@shell@ @postBootCommands@
# Reset the logging file descriptors.
exec 1>&$logOutFd 2>&$logErrFd
exec {logOutFd}>&- {logErrFd}>&-
mkdir -p \
/run/etc/syndicate/core \
/run/etc/syndicate/services
# Start Synit.
echo "starting Synit..."
exec synit-pid1

View File

@ -1,27 +0,0 @@
{ config, lib, pkgs, ... }:
{
config = {
system.build.bootStage2 = lib.mkForce (pkgs.substituteAll {
src = ./stage-2-init.sh;
shellDebug = "${pkgs.bashInteractive}/bin/bash";
shell = "${pkgs.bash}/bin/bash";
isExecutable = true;
inherit (config.nix) readOnlyStore;
inherit (config.system.build) earlyMountScript;
path = lib.makeBinPath [
pkgs.coreutils
pkgs.utillinux
pkgs.synit-pid1
];
inherit (pkgs) eudev;
postBootCommands = pkgs.writeText "local-cmds" ''
${config.boot.postBootCommands}
${config.powerManagement.powerUpCommands}
'';
});
};
}

View File

@ -1 +0,0 @@
<require-service <config-watcher "/run/etc/syndicate/services" $.>>

View File

@ -1,51 +0,0 @@
<require-service <daemon interface-monitor>>
<require-service <milestone network>>
<depends-on <milestone network> <service-state <daemon interface-monitor> ready>>
<configure-interface "lo" <static "127.0.0.1/8">>
? <configure-interface ?ifname <static ?ipaddr>> [
! <exec ["@ip@" "address" "add" "dev" $ifname $ipaddr]>
?- ! <exec ["@ip@" "address" "del" "dev" $ifname $ipaddr] never>
]
? <configure-interface ?ifname <dhcp>> [
<require-service <daemon <udhcpc $ifname>>>
]
? <run-service <daemon <udhcpc ?ifname>>> [
<daemon <udhcpc $ifname> ["@udhcpc@" "-i" $ifname "-fR"]>
]
<daemon interface-monitor {
argv: "@interfaceMonitor@"
protocol: application/syndicate
}>
? <machine-dataspace ?machine> [
? <service-object <daemon interface-monitor> ?cap> [
$cap {
machine: $machine
}
]
$machine ? <interface ?ifname _ _ _ _ _ _> [
$log ! <log "-" { saw-machine-interface: $ifname }>
$config [
! <exec ["@ip@" "link" "set" $ifname "up"]>
?- ! <exec ["@ip@" "link" "set" $ifname "down"] never>
]
]
$machine ? <interface ?ifname _ normal up up carrier _> [
$config <configure-interface $ifname <dhcp>>
]
$machine ? <interface ?ifname _ normal up unknown carrier _> [
$config <configure-interface $ifname <dhcp>>
]
$machine ? <route ?addressFamily default _ _ _ _> [
$config <default-route $addressFamily>
]
]

View File

@ -1,3 +0,0 @@
<require-service <daemon ntpd>>
<depends-on <daemon ntpd> <default-route ipv4>>
<daemon ntpd "@ntpd@ -d -n -p pool.ntp.org">

View File

@ -1,5 +0,0 @@
<require-service <daemon sshd>>
<depends-on <daemon sshd> <service-state <milestone network> up>>
<depends-on <daemon sshd> <service-state <daemon ssh-host-keys> complete>>
<daemon sshd "@sshd@ -D -f /etc/ssh/sshd_config">
<daemon ssh-host-keys <one-shot "@ssh-keygen@ -A">>

View File

@ -1,20 +0,0 @@
let ?settingsDir = "/etc/syndicate/user-settings"
let ?settings = <* $config [
<rewrite ?item <user-setting $item>>
]>
<require-service <config-watcher $settingsDir { config: $settings }>>
<require-service <daemon user-settings-daemon>>
<daemon user-settings-daemon {
argv: "@user-settings-daemon@"
protocol: application/syndicate
}>
? <service-object <daemon user-settings-daemon> ?cap> [
$cap {
config: $config
settingsDir: $settingsDir
}
]

View File

@ -1,177 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
boot.initrd = {
enable = true;
network.enable = false;
systemd.enable = false;
verbose = true;
};
environment.etc = {
"syndicate/boot/001-console-getty.pr".text = ''
<require-service <daemon console-getty>>
<daemon console-getty [
"${lib.getBin pkgs.util-linux}/bin/agetty"
"--login-program"
"${config.services.getty.loginProgram}"
"--noclear"
"--keep-baud"
"console"
"115200,38400,9600"
"linux"
]>
'';
"syndicate/boot/020-load-core-layer.pr".text = ''
; Attenuate `$config` by rewriting plain `require-service` assertions to `require-core-service`
; assertions. Allow all other assertions through.
;
let ?sys = <* $config [
<rewrite <require-service ?s> <require-core-service $s>>
<filter _>
]>
; Give meaning to `require-core-service`: it is an ordinary `require-service`, plus a
; declaration that the `core` milestone depends on the service.
;
? <require-core-service ?s> [
<depends-on <milestone core> <service-state $s up>>
<require-service $s>
]
; Load config in the `core` directory, using the wrapped `config` so that all plain services
; required are changed to be *core* services.
;
<require-service <config-watcher "/run/current-system/etc/syndicate/core" {
config: $sys
gatekeeper: $gatekeeper
log: $log
}>>
; In addition, require the `core` milestone explicitly.
;
<require-service <milestone core>>
'';
"syndicate/boot/030-load-services.pr".text = ''
; Attenuate `$config` by rewriting plain `require-service` assertions to
; `require-basic-service` assertions. Allow all other assertions through.
;
let ?basic = <* $config [
<rewrite <require-service ?s> <require-basic-service $s>>
<filter _>
]>
; Give meaning to `require-basic-service`: it is an ordinary `require-service`, plus a
; declaration that the service depends on the `core` milestone.
;
? <require-basic-service ?s> [
<depends-on $s <service-state <milestone core> up>>
<require-service $s>
]
; Once we see that the `core` milestone is ready, start processing the `services`
; directory.
;
? <service-state <milestone core> up> [
<require-service <config-watcher "/run/current-system/etc/syndicate/services" {
config: $basic
gatekeeper: $gatekeeper
log: $log
}>>
]
'';
"syndicate/core/configdirs.pr".text = ''
<require-service <config-watcher "/run/etc/syndicate/core" $.>>
<require-service <config-watcher "/etc/syndicate/core" $.>>
'';
"syndicate/core/hostname.pr".text = ''
<require-service <daemon hostname>>
<daemon hostname <one-shot ["${pkgs.nettools}/bin/hostname" "${config.networking.hostName}"]>>
'';
"syndicate/core/eudev.pr".text = let
initialScanScript = pkgs.writeScript "eudev-initial-scan.sh" ''
#!${pkgs.runtimeShell}
set -e
export PATH=${lib.makeBinPath [ pkgs.eudev ]}
echo "" > /proc/sys/kernel/hotplug
udevadm trigger --type=subsystems --action=add
udevadm trigger --type=devices --action=add
udevadm settle --timeout=30
'';
in ''
<require-service <daemon eudev>>
<daemon eudev ["${pkgs.eudev}/bin/udevd" "--children-max=5"]>
<require-service <daemon eudev-initial-scan>>
<depends-on <daemon eudev-initial-scan> <service-state <daemon eudev> up>>
<daemon eudev-initial-scan <one-shot ${initialScanScript}>>
'';
"syndicate/core/machine-dataspace.pr".text = ''
let ?ds = dataspace
<machine-dataspace $ds>
$ds ? ?r [
$log ! <log "-" { line: "machine" |+++|: $r }>
?- $log ! <log "-" { line: "machine" |---|: $r }>
]
'';
"syndicate/services/configdirs.pr".source =
./syndicate/services/configdirs.pr;
"syndicate/services/network.pr".source = pkgs.substituteAll {
src = ./syndicate/services/network.pr;
interfaceMonitor =
"${pkgs.python3Packages.synit-daemons}/bin/interface-monitor";
ip = "${pkgs.iproute2}/bin/ip";
udhcpc = "${pkgs.busybox}/bin/udhcpc";
};
"syndicate/services/ntpd.pr".source = pkgs.substituteAll {
src = ./syndicate/services/ntpd.pr;
ntpd = "${pkgs.busybox}/bin/ntpd";
};
"syndicate/services/sshd.pr".source = pkgs.substituteAll {
src = ./syndicate/services/sshd.pr;
sshd = "${pkgs.openssh}/bin/sshd";
ssh-keygen = "${pkgs.openssh}/bin/ssh-keygen";
};
"syndicate/services/userSettings.pr".source = pkgs.substituteAll {
src = ./syndicate/services/userSettings.pr;
user-settings-daemon =
"${pkgs.python3Packages.synit-daemons}/bin/user-settings-daemon";
};
} // (builtins.listToAttrs (map (file: {
name = "syndicate/boot/${file}";
value.source =
"${pkgs.synit-pid1.src}/packaging/packages/synit-config/files/etc/syndicate/boot/${file}";
}) [ "010-exec.pr" "010-milestone.pr" "010-service-state-up.pr" ]));
environment.systemPackages = with pkgs; [
synit-pid1
syndicate-server
(writeScriptBin "synit-log" ''
#! ${lib.getBin bash}/bin/bash
${lib.getBin coreutils}/bin/mkdir -p /var/log/synit
exec ${lib.getBin s6}/bin/s6-log t /var/log/synit
'')
];
systemd.package = pkgs.systemd // { meta.broken = true; };
};
}

View File

@ -1,8 +1,12 @@
{ config, lib, pkgs, ... }:
with lib;
{
config,
lib,
pkgs,
...
}:
{
options.services.syndicate = mkOption {
options.services.syndicate = lib.mkOption {
default = { };
example = {
tty1 = {
@ -16,104 +20,110 @@ with lib;
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";
type = lib.types.attrsOf (
lib.types.submodule {
options = {
enable = lib.mkEnableOption "this Syndicate dataspace server instance";
runInDbusSession = mkEnableOption "dbus-run-session wrapper";
user = lib.mkOption {
type = lib.types.str;
example = "jane";
description = "User account under which the Syndicate server runs.";
};
user = mkOption {
type = types.str;
example = "jane";
description = "User account under which the Syndicate server runs.";
package = lib.mkOption {
default = pkgs.syndicate-server;
defaultText = "pkgs.syndicate-server";
type = lib.types.package;
description = "The package to use for the Syndicate dataspace server.";
};
config = lib.mkOption {
type = lib.types.listOf lib.types.path;
description = "Configurations to load.";
example = [ "/etc/syndicate" ];
};
};
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"
systemd.services =
let
configure =
name: cfg:
let
configFile = lib.pipe cfg.config [
(lib.strings.concatMapStrings (dir: ''
<require-service <config-watcher "${dir}" $.>>
''))
(pkgs.writeText "syndicate-nixos-config.pr")
];
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);
in
[
{
name = "syndicate-${name}";
value =
let
serviceConfig = {
RuntimeDirectory = name;
ExecStart = "${cfg.package}/bin/syndicate-server --no-banner --config ${configFile}";
User = cfg.user;
};
in
{
description = "Syndicate dataspace server";
restartIfChanged = false;
reloadIfChanged = false;
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 = "~";
};
}
);
}
];
serverCfgs = lib.attrsets.filterAttrs (_: cfg: cfg.enable) config.services.syndicate;
in
lib.pipe serverCfgs [
(lib.attrsets.mapAttrsToList configure)
lib.lists.flatten
builtins.listToAttrs
];
systemd.targets.multi-user.wants = lib.lists.flatten (
lib.attrsets.mapAttrsToList (
name: cfg: lib.optional cfg.enable "syndicate-${name}.service"
) config.services.syndicate
);
};
}

59
overlay.nix Normal file
View File

@ -0,0 +1,59 @@
final: prev:
let
rustPkgs =
let
overlay = import (
prev.fetchFromGitHub {
owner = "oxalica";
repo = "rust-overlay";
rev = "a2ccfb2134622b28668a274e403ba6f075ae1223";
hash = "sha256-9honwiIeMbBKi7FzfEy89f1ShUiXz/gVxZSS048pKyc=";
}
);
in
final.extend overlay;
rust' = rustPkgs.rust-bin.nightly.latest.default;
in
{
lib = prev.lib.extend (import ./lib.nix);
acpi_actor = final.callPackage ./packages/acpi_actor { };
buildNimSbom = prev.buildNimSbom or final.callPackage ./build-nim-sbom.nix { };
fontconfig_actor = final.callPackage ./packages/fontconfig_actor { };
libnotify_actor = final.callPackage ./packages/libnotify_actor { };
nix_actor = final.callPackage ./packages/nix_actor { };
noiseprotocol = final.callPackage ./packages/nim/noiseprotocol { };
syndicate_utils = final.callPackage ./packages/syndicate_utils-nim { };
syndicated-open = final.callPackage ./packages/syndicated-open { };
noise-c = final.callPackage ./packages/noise-c { };
preserves-tools = final.callPackage ./packages/preserves-tools { };
python3Packages = prev.python3Packages.overrideScope (
final': prev': {
preserves = final'.callPackage ./packages/preserves-py { };
syndicate-py = final'.callPackage ./packages/syndicate-py { };
synit-daemons = final'.callPackage ./packages/synit-daemons-py { };
}
);
sqlite_actor = final.callPackage ./packages/sqlite_actor { };
squeak = final.callPackage ./packages/squeak { };
squeaker = final.python3Packages.callPackage ./packages/squeaker { };
syndicate-server = final.callPackage ./packages/syndicate-server { rust = rust'; };
synit-pid1 = final.callPackage ./packages/synit-pid1 { };
xapian_actor = final.callPackage ./packages/xapian_actor { };
}

View File

@ -0,0 +1,25 @@
{
lib,
buildNimPackage,
fetchFromGitea,
}:
buildNimPackage (finalAttrs: {
pname = "acpi_actor";
version = "20231010";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = finalAttrs.version;
hash = "sha256-eN3VC2yL6UvjeIGvzx0PAujR/Xd6Rc1e9Ftf6fKKk2E=";
};
lockFile = "${src}/lock.json";
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
})

View File

@ -0,0 +1,31 @@
{
lib,
buildNimPackage,
fetchFromGitea,
fontconfig,
pkg-config,
}:
buildNimPackage rec {
pname = "fontconfig_actor";
version = "20231021";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-3LRIsZ6NA+E799/z6PGb4wH3CgJ6lx2CgKH/CzEuSzQ=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ fontconfig ];
lockFile = "${src}/lock.json";
meta = src.meta // {
description = "Syndicate actor for asserting Fontconfig information";
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

View File

@ -0,0 +1,30 @@
{
lib,
buildNimPackage,
fetchFromGitea,
libnotify,
pkg-config,
}:
buildNimPackage rec {
pname = "libnotify_actor";
version = "20231130";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-PNRscNm3axhEr1O2QGLs9JBH35err34y3wc9arPxZ5c=";
};
propagatedNativeBuildInputs = [ pkg-config ];
propagatedBuildInputs = [ libnotify ];
lockFile = "${src}/lock.json";
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

View File

@ -0,0 +1,19 @@
{
lib,
buildNimPackage,
noise-c,
}:
buildNimPackage rec {
pname = "noise";
version = "20230509";
src = null;
propagatedBuildInputs = [ noise-c ];
meta = {
inherit (noise-c.meta) license;
maintainers = [ lib.maintainers.ehmry ];
};
}

View File

@ -0,0 +1,47 @@
{
lib,
buildNimPackage,
fetchFromGitea,
fetchFromGitHub,
boost,
nix,
pkg-config,
}:
let
nix' = nix.overrideAttrs (
final: prev: {
src = fetchFromGitHub {
owner = "NixOS";
repo = "nix";
rev = "2.13.3";
hash = "sha256-jUc2ccTR8f6MGY2pUKgujm+lxSPNGm/ZAP+toX+nMNc=";
};
}
);
in
buildNimPackage rec {
pname = "nix_actor";
version = "20231009";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-+wMhpmC1233Ze4+xnd5sNnIfsXkGEx67bZN3oMYu2EQ=";
};
lockFile = "${src}/lock.json";
propagatedNativeBuildInputs = [ pkg-config ];
propagatedBuildInputs = [
boost
nix'
];
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

View File

@ -0,0 +1,35 @@
{
lib,
stdenv,
fetchFromGitHub,
autoreconfHook,
}:
stdenv.mkDerivation rec {
pname = "noise-c";
version = "20230309";
outputs = [
"bin"
"out"
];
src = fetchFromGitHub {
owner = "rweather";
repo = pname;
rev = "ffa626bddd1f8182e47c634af686108ca5049e56";
hash = "sha256-HkcyV/WT4UNFWczbZZIDW2fWRliQb8IEykv2d7bZM7w=";
};
nativeBuildInputs = [ autoreconfHook ];
# excise protobuf bloat
prePatch = ''
substituteInPlace tools/Makefile.am \
--replace 'SUBDIRS = keytool protoc' 'SUBDIRS = keytool'
'';
meta = src.meta // {
description = "Plain C implementation of the Noise Protocol";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ ehmry ];
};
}

View File

@ -1,47 +0,0 @@
{ lib, stdenv, buildNimPackage, fetchFromGitea, fetchFromGitHub, runCommand
, nim-unwrapped, preserves }:
let
compiler = runCommand "compiler.nimble" { inherit (nim-unwrapped) src; } ''
mkdir -p $out
tar xf $src --strip-components=1 -C $out
'';
npeg = fetchFromGitHub {
owner = "zevv";
repo = "npeg";
rev = "0.25.0";
hash = "sha256-E/0hCz0XsoAb/bAksqrKTyi8/FwBdP8kT6uUUAdru68=";
};
in buildNimPackage rec {
pname = "preserves";
version = "20220625";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = "${pname}-nim";
rev = version;
sha256 = "sha256-ZNgBlIOKyWD0R5wZvGb/0K5tUpz5q5QpET4Qa/kxhkA=";
};
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;
do ln -s preserves_encode $link
done
popd
'';
doCheck = true;
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

View File

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

View File

@ -1,4 +1,9 @@
{ lib, rustPlatform, rust, fetchCrate }:
{
lib,
rustPlatform,
rustc,
fetchCrate,
}:
rustPlatform.buildRustPackage rec {
pname = "preserves-tool";
@ -12,11 +17,14 @@ rustPlatform.buildRustPackage rec {
sha256 = "sha256-I9dqY2pej/HRQg2VGkEoWKOlo4c9TYwk/jw23eN1nlU=";
};
cargoHash = "sha256-0UMGDoyfdEJQQDoUadbU6Ev6yA2k0sQHRvO/Z+4QF5g=";
nativeBuildInputs = [ rust ];
nativeBuildInputs = [ rustc ];
RUSTC_BOOTSTRAP = true;
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";
};
}

View File

@ -0,0 +1,30 @@
{
lib,
buildNimPackage,
fetchFromGitea,
pkg-config,
sqlcipher,
}:
buildNimPackage rec {
pname = "sqlite_actor";
version = "20231010";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-oKw5GUsK1F2RegOFiNYkLXT5CvtWcF/8H6QdE4DXa1A=";
};
propagatedNativeBuildInputs = [ pkg-config ];
propagatedBuildInputs = [ sqlcipher ];
lockFile = "${src}/lock.json";
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}

View File

@ -1,11 +1,27 @@
{ lib, stdenv, fetchurl, autoPatchelfHook, makeWrapper, unzip, alsa-lib, libGL
, libpulseaudio, libuuid, nas, openssl, pango, sndio, xorg }:
{
lib,
stdenv,
fetchurl,
autoPatchelfHook,
makeWrapper,
unzip,
alsa-lib,
libGL,
libpulseaudio,
libuuid,
nas,
openssl,
pango,
sndio,
xorg,
}:
let
versionA = "6.0";
versionB = "22101";
versionB = "22104";
versionC = "202206021410";
bits = with stdenv.hostPlatform;
bits =
with stdenv.hostPlatform;
if is32bit then
"32"
else if is64bit then
@ -14,23 +30,26 @@ let
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=";
url = "http://files.squeak.org/${versionA}/Squeak${versionA}-${versionB}-${bits}bit/Squeak${versionA}-${versionB}-${bits}bit-${versionC}-Linux-x86.tar.gz";
sha256 = "sha256-6o9GCeNsHV+OhHBUCqBmslgUEBrS3XPwsl/p8zgfJQs=";
};
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=";
url = "http://files.squeak.org/${versionA}/Squeak${versionA}-${versionB}-${bits}bit/Squeak${versionA}-${versionB}-${bits}bit-${versionC}-Linux-x64.tar.gz";
sha256 = "sha256-pgTdFyqAQo3K6Th2FXL8Op1hakjcL4rJ6wnKuIlFZ9g=";
};
};
in stdenv.mkDerivation rec {
in
stdenv.mkDerivation rec {
pname = "squeak";
version = "${versionA}-${versionB}-${versionC}";
src = sources.${stdenv.system};
nativeBuildInputs = [ autoPatchelfHook makeWrapper unzip ];
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
unzip
];
buildInputs = with xorg; [
alsa-lib
@ -54,9 +73,7 @@ in stdenv.mkDerivation rec {
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 ]
}" \
--prefix LD_LIBRARY_PATH ":" "$out/lib:${lib.makeLibraryPath [ openssl ]}" \
--set SQUEAK_IMAGE $out/lib/Squeak${versionA}-${versionB}-${bits}bit.image
'';
@ -65,10 +82,12 @@ in stdenv.mkDerivation rec {
--replace-needed libsndio.so.6.1 libsndio.so
'';
meta = {
broken = !(builtins.hasAttr stdenv.system sources);
description = "Squeak virtual machine and image";
homepage = "https://squeak.org/";
license = with lib.licenses; [ asl20 mit ];
license = with lib.licenses; [
asl20
mit
];
maintainers = with lib.maintainers; [ ehmry ];
platforms = builtins.attrNames sources;
};

View File

@ -1,4 +1,8 @@
{ lib, buildPythonApplication, fetchFromGitHub }:
{
lib,
buildPythonApplication,
fetchFromGitHub,
}:
buildPythonApplication rec {
pname = "squeaker";

View File

@ -1,29 +0,0 @@
{ 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;
};
}

View File

@ -1,27 +1,30 @@
{ lib, buildPythonPackage, python, fetchFromGitea, setuptools-scm, preserves
, websockets }:
{
lib,
buildPythonPackage,
fetchPypi,
setuptools-scm,
preserves,
websockets,
}:
buildPythonPackage rec {
pname = "syndicate";
version = "0.8.5";
pname = "syndicate-py";
version = "0.15.0";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "syndicate-lang";
repo = "${pname}-py";
rev = "v${version}";
sha256 = "sha256-OAvQxac06i8+R9zNWLjCtwOpVZ4t31q45ms6VuNyHGI=";
src = fetchPypi {
inherit pname version;
hash = "sha256-ePCjzy5ros4H3rp0EszjUiUMCbPmNLWlXCaYcqSui0k=";
};
buildInputs = [ setuptools-scm ];
propagatedBuildInputs = [ preserves websockets ];
postInstall =
"cp -rv syndicate/protocols $out/lib/${python.libPrefix}/site-packages/syndicate/";
propagatedBuildInputs = [
preserves
websockets
];
meta = src.meta // {
description = "Syndicated Actor model for Python";
homepage = "https://syndicate-lang.org";
description = "An implementation of Syndicated Actors for Python";
maintainers = with lib.maintainers; [ ehmry ];
};
}

View File

@ -1,22 +1,35 @@
# https://git.syndicate-lang.org/synit/synit/src/branch/main/packaging/packages/syndicate-server/APKBUILD
{ lib, rustPlatform, rust, fetchgit, pkg-config, openssl }:
{
lib,
rustPlatform,
rust,
fetchFromGitea,
pkg-config,
openssl,
}:
rustPlatform.buildRustPackage rec {
pname = "syndicate-server";
version = "0.24.0";
src = fetchgit {
url = "https://git.syndicate-lang.org/syndicate-lang/syndicate-rs.git";
version = "0.45.0";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "syndicate-lang";
repo = "syndicate-rs";
rev = "${pname}-v${version}";
sha256 = "sha256-91dGi7CyI/6XkbpWbFtnb6XACIExHX/6XYVkKlkDTzc=";
sha256 = "sha256-jyZlio+wo9YiaiIKCl6YC9Bym89fqUkJOqhBb0Nu/zQ=";
};
cargoHash = "sha256-MXchqX8wvMwnT2Js0YVIgOKsZuGglnKRg3HsuyOgBsI=";
nativeBuildInputs = [ rust pkg-config ];
cargoHash = "sha256-WMX1GPU9GyXNP5qng6PGX++5PLvdViECTr8KPNkF4ps=";
nativeBuildInputs = [
rust
pkg-config
];
buildInputs = [ openssl ];
meta = {
description = "Syndicate broker server";
homepage = "https://git.syndicate-lang.org/syndicate-lang/syndicate-rs/";
mainProgram = "syndicate-server";
maintainers = with lib.maintainers; [ ehmry ];
};
}

View File

@ -1,41 +1,35 @@
{ lib, buildNimPackage, fetchFromGitea, fetchFromGitHub, syndicate, libnotify }:
{
lib,
buildNimSbom,
fetchFromGitea,
postgresql,
sqlite,
libxml2,
libxslt,
openssl,
}:
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 {
buildNimSbom (finalAttrs: {
pname = "syndicate_utils";
version = "20220628";
version = "20240610";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-/HoPR/SFZzIzICvscse4s13EKvjXs6qr2puhkv5qBso=";
repo = "syndicate_utils";
rev = finalAttrs.version;
hash = "sha256-qDbPjwq5ECJ5wGRCofVnDkE8NuvchtzYbbzgQShysYs=";
};
propagatedBuildInputs = [ syndicate nim-libnotify ];
nimFlags =
[ "-p:${gtk2}/src/" ]; # everyone breaks the nimble rules, nim-lang included
meta = src.meta // {
buildInputs = [
postgresql.out
sqlite
libxml2
libxslt
openssl
];
meta = finalAttrs.src.meta // {
description = "Utilities for the Syndicated Actor Model";
homepage = "https://git.syndicate-lang.org/ehmry/syndicate_utils";
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}
}) ./sbom.json

View File

@ -0,0 +1,653 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"metadata": {
"component": {
"type": "application",
"bom-ref": "pkg:nim/syndicate_utils",
"name": "syndicate_utils",
"description": "Utilites for Syndicated Actors and Synit",
"version": "20240610",
"authors": [
{
"name": "Emery Hemingway"
}
],
"licenses": [
{
"license": {
"id": "Unlicense"
}
}
],
"properties": [
{
"name": "nim:skipExt",
"value": "nim"
},
{
"name": "nim:bin:postgre-actor",
"value": "postgre_actor"
},
{
"name": "nim:bin:xslt-actor",
"value": "xslt_actor"
},
{
"name": "nim:bin:preserve-process-environment",
"value": "preserve_process_environment"
},
{
"name": "nim:bin:mintsturdyref",
"value": "mintsturdyref"
},
{
"name": "nim:bin:esc-printer-driver",
"value": "esc_printer_driver"
},
{
"name": "nim:bin:msg",
"value": "msg"
},
{
"name": "nim:bin:rofi-script-actor",
"value": "rofi_script_actor"
},
{
"name": "nim:bin:syndesizer",
"value": "syndesizer"
},
{
"name": "nim:bin:http-client",
"value": "http_client"
},
{
"name": "nim:bin:mount-actor",
"value": "mount_actor"
},
{
"name": "nim:bin:syndump",
"value": "syndump"
},
{
"name": "nim:bin:sqlite-actor",
"value": "sqlite_actor"
},
{
"name": "nim:srcDir",
"value": "src"
},
{
"name": "nim:backend",
"value": "c"
}
]
}
},
"components": [
{
"type": "library",
"bom-ref": "pkg:nim/syndicate",
"name": "syndicate",
"version": "20240610",
"externalReferences": [
{
"url": "https://git.syndicate-lang.org/ehmry/syndicate-nim/archive/7bbcdb7e7705c2ab54ba0165565813d67aea48b0.tar.gz",
"type": "source-distribution"
},
{
"url": "https://git.syndicate-lang.org/ehmry/syndicate-nim.git",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/mldff990wpr0v9v5qh6ggqjmc2mn3n8g-source"
},
{
"name": "nix:fod:rev",
"value": "7bbcdb7e7705c2ab54ba0165565813d67aea48b0"
},
{
"name": "nix:fod:sha256",
"value": "0mb3mrj5dkkqm0xp5hg84c5naaci4mi6mv2jjznfi6i7swp3f7vs"
},
{
"name": "nix:fod:url",
"value": "https://git.syndicate-lang.org/ehmry/syndicate-nim/archive/7bbcdb7e7705c2ab54ba0165565813d67aea48b0.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "20240610"
},
{
"name": "nix:fod:srcDir",
"value": "src"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/preserves",
"name": "preserves",
"version": "20240610",
"externalReferences": [
{
"url": "https://git.syndicate-lang.org/ehmry/preserves-nim/archive/560a6417a30a2dff63f24b62498e9fcac2de8354.tar.gz",
"type": "source-distribution"
},
{
"url": "https://git.syndicate-lang.org/ehmry/preserves-nim.git",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/0sszsmz84ppwqsgda8cmli4lfh2mjmin-source"
},
{
"name": "nix:fod:rev",
"value": "560a6417a30a2dff63f24b62498e9fcac2de8354"
},
{
"name": "nix:fod:sha256",
"value": "19r983fy7m54mlaj0adxdp8pxi1x8dp6phkcnr8rz5y5cwndfjx2"
},
{
"name": "nix:fod:url",
"value": "https://git.syndicate-lang.org/ehmry/preserves-nim/archive/560a6417a30a2dff63f24b62498e9fcac2de8354.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "20240610"
},
{
"name": "nix:fod:srcDir",
"value": "src"
},
{
"name": "nix:fod:date",
"value": "2024-05-23T15:58:40+03:00"
},
{
"name": "nix:fod:hash",
"value": "sha256-JvdvLdPajDgIPbLblO0LbOm0wEp530fs8LYmgH885sk="
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/sys",
"name": "sys",
"version": "4ef3b624db86e331ba334e705c1aa235d55b05e1",
"externalReferences": [
{
"url": "https://github.com/ehmry/nim-sys/archive/4ef3b624db86e331ba334e705c1aa235d55b05e1.tar.gz",
"type": "source-distribution"
},
{
"url": "https://github.com/ehmry/nim-sys.git",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/syhxsjlsdqfap0hk4qp3s6kayk8cqknd-source"
},
{
"name": "nix:fod:rev",
"value": "4ef3b624db86e331ba334e705c1aa235d55b05e1"
},
{
"name": "nix:fod:sha256",
"value": "1q4qgw4an4mmmcbx48l6xk1jig1vc8p9cq9dbx39kpnb0890j32q"
},
{
"name": "nix:fod:url",
"value": "https://github.com/ehmry/nim-sys/archive/4ef3b624db86e331ba334e705c1aa235d55b05e1.tar.gz"
},
{
"name": "nix:fod:srcDir",
"value": "src"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/taps",
"name": "taps",
"version": "20240405",
"externalReferences": [
{
"url": "https://git.sr.ht/~ehmry/nim_taps/archive/8c8572cd971d1283e6621006b310993c632da247.tar.gz",
"type": "source-distribution"
},
{
"url": "https://git.sr.ht/~ehmry/nim_taps",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/6y14ia52kr7jyaa0izx37mlablmq9s65-source"
},
{
"name": "nix:fod:rev",
"value": "8c8572cd971d1283e6621006b310993c632da247"
},
{
"name": "nix:fod:sha256",
"value": "1dp166bv9x773jmfqppg5i3v3rilgff013vb11yzwcid9l7s3iy8"
},
{
"name": "nix:fod:url",
"value": "https://git.sr.ht/~ehmry/nim_taps/archive/8c8572cd971d1283e6621006b310993c632da247.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "20240405"
},
{
"name": "nix:fod:srcDir",
"value": "src"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/nimcrypto",
"name": "nimcrypto",
"version": "traditional-api",
"externalReferences": [
{
"url": "https://github.com/cheatfate/nimcrypto/archive/602c5d20c69c76137201b5d41f788f72afb95aa8.tar.gz",
"type": "source-distribution"
},
{
"url": "https://github.com/cheatfate/nimcrypto",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/zyr8zwh7vaiycn1s4r8cxwc71f2k5l0h-source"
},
{
"name": "nix:fod:rev",
"value": "602c5d20c69c76137201b5d41f788f72afb95aa8"
},
{
"name": "nix:fod:sha256",
"value": "1dmdmgb6b9m5f8dyxk781nnd61dsk3hdxqks7idk9ncnpj9fng65"
},
{
"name": "nix:fod:url",
"value": "https://github.com/cheatfate/nimcrypto/archive/602c5d20c69c76137201b5d41f788f72afb95aa8.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "traditional-api"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/npeg",
"name": "npeg",
"version": "1.2.2",
"externalReferences": [
{
"url": "https://github.com/zevv/npeg/archive/ec0cc6e64ea4c62d2aa382b176a4838474238f8d.tar.gz",
"type": "source-distribution"
},
{
"url": "https://github.com/zevv/npeg.git",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/xpn694ibgipj8xak3j4bky6b3k0vp7hh-source"
},
{
"name": "nix:fod:rev",
"value": "ec0cc6e64ea4c62d2aa382b176a4838474238f8d"
},
{
"name": "nix:fod:sha256",
"value": "1fi9ls3xl20bmv1ikillxywl96i9al6zmmxrbffx448gbrxs86kg"
},
{
"name": "nix:fod:url",
"value": "https://github.com/zevv/npeg/archive/ec0cc6e64ea4c62d2aa382b176a4838474238f8d.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "1.2.2"
},
{
"name": "nix:fod:srcDir",
"value": "src"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/bigints",
"name": "bigints",
"version": "20231006",
"externalReferences": [
{
"url": "https://github.com/ehmry/nim-bigints/archive/86ea14d31eea9275e1408ca34e6bfe9c99989a96.tar.gz",
"type": "source-distribution"
},
{
"url": "https://github.com/ehmry/nim-bigints.git",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/jvrm392g8adfsgf36prgwkbyd7vh5jsw-source"
},
{
"name": "nix:fod:rev",
"value": "86ea14d31eea9275e1408ca34e6bfe9c99989a96"
},
{
"name": "nix:fod:sha256",
"value": "15pcpmnk1bnw3k8769rjzcpg00nahyrypwbxs88jnwr4aczp99j4"
},
{
"name": "nix:fod:url",
"value": "https://github.com/ehmry/nim-bigints/archive/86ea14d31eea9275e1408ca34e6bfe9c99989a96.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "20231006"
},
{
"name": "nix:fod:srcDir",
"value": "src"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/cps",
"name": "cps",
"version": "0.10.4",
"externalReferences": [
{
"url": "https://github.com/nim-works/cps/archive/2a4d771a715ba45cfba3a82fa625ae7ad6591c8b.tar.gz",
"type": "source-distribution"
},
{
"url": "https://github.com/nim-works/cps",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/m9vpcf3dq6z2h1xpi1vlw0ycxp91s5p7-source"
},
{
"name": "nix:fod:rev",
"value": "2a4d771a715ba45cfba3a82fa625ae7ad6591c8b"
},
{
"name": "nix:fod:sha256",
"value": "0c62k5wpq9z9mn8cd4rm8jjc4z0xmnak4piyj5dsfbyj6sbdw2bf"
},
{
"name": "nix:fod:url",
"value": "https://github.com/nim-works/cps/archive/2a4d771a715ba45cfba3a82fa625ae7ad6591c8b.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "0.10.4"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/stew",
"name": "stew",
"version": "3c91b8694e15137a81ec7db37c6c58194ec94a6a",
"externalReferences": [
{
"url": "https://github.com/status-im/nim-stew/archive/3c91b8694e15137a81ec7db37c6c58194ec94a6a.tar.gz",
"type": "source-distribution"
},
{
"url": "https://github.com/status-im/nim-stew",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/mqg8qzsbcc8xqabq2yzvlhvcyqypk72c-source"
},
{
"name": "nix:fod:rev",
"value": "3c91b8694e15137a81ec7db37c6c58194ec94a6a"
},
{
"name": "nix:fod:sha256",
"value": "17lfhfxp5nxvld78xa83p258y80ks5jb4n53152cdr57xk86y07w"
},
{
"name": "nix:fod:url",
"value": "https://github.com/status-im/nim-stew/archive/3c91b8694e15137a81ec7db37c6c58194ec94a6a.tar.gz"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/getdns",
"name": "getdns",
"version": "20230806",
"externalReferences": [
{
"url": "https://git.sr.ht/~ehmry/getdns-nim/archive/e4ae0992ed7c5540e6d498f3074d06c8f454a0b6.tar.gz",
"type": "source-distribution"
},
{
"url": "https://git.sr.ht/~ehmry/getdns-nim",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/j8i20k9aarzppg4p234449140nnnaycq-source"
},
{
"name": "nix:fod:rev",
"value": "e4ae0992ed7c5540e6d498f3074d06c8f454a0b6"
},
{
"name": "nix:fod:sha256",
"value": "1dp53gndr6d9s9601dd5ipkiq94j53hlx46mxv8gpr8nd98bqysg"
},
{
"name": "nix:fod:url",
"value": "https://git.sr.ht/~ehmry/getdns-nim/archive/e4ae0992ed7c5540e6d498f3074d06c8f454a0b6.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "20230806"
},
{
"name": "nix:fod:srcDir",
"value": "src"
}
]
},
{
"type": "library",
"bom-ref": "pkg:nim/solo5_dispatcher",
"name": "solo5_dispatcher",
"version": "20240522",
"externalReferences": [
{
"url": "https://git.sr.ht/~ehmry/solo5_dispatcher/archive/cc64ef99416b22b12e4a076d33de9e25a163e57d.tar.gz",
"type": "source-distribution"
},
{
"url": "https://git.sr.ht/~ehmry/solo5_dispatcher",
"type": "vcs"
}
],
"properties": [
{
"name": "nix:fod:method",
"value": "fetchzip"
},
{
"name": "nix:fod:path",
"value": "/nix/store/4jj467pg4hs6warhksb8nsxn9ykz8c7c-source"
},
{
"name": "nix:fod:rev",
"value": "cc64ef99416b22b12e4a076d33de9e25a163e57d"
},
{
"name": "nix:fod:sha256",
"value": "1v9i9fqgx1g76yrmz2xwj9mxfwbjfpar6dsyygr68fv9031cqxq7"
},
{
"name": "nix:fod:url",
"value": "https://git.sr.ht/~ehmry/solo5_dispatcher/archive/cc64ef99416b22b12e4a076d33de9e25a163e57d.tar.gz"
},
{
"name": "nix:fod:ref",
"value": "20240522"
},
{
"name": "nix:fod:srcDir",
"value": "pkg"
}
]
}
],
"dependencies": [
{
"ref": "pkg:nim/syndicate_utils",
"dependsOn": [
"pkg:nim/syndicate"
]
},
{
"ref": "pkg:nim/syndicate",
"dependsOn": [
"pkg:nim/nimcrypto",
"pkg:nim/preserves",
"pkg:nim/sys",
"pkg:nim/taps"
]
},
{
"ref": "pkg:nim/preserves",
"dependsOn": [
"pkg:nim/npeg",
"pkg:nim/bigints"
]
},
{
"ref": "pkg:nim/sys",
"dependsOn": [
"pkg:nim/cps",
"pkg:nim/stew"
]
},
{
"ref": "pkg:nim/taps",
"dependsOn": [
"pkg:nim/getdns",
"pkg:nim/sys",
"pkg:nim/cps",
"pkg:nim/solo5_dispatcher"
]
},
{
"ref": "pkg:nim/nimcrypto",
"dependsOn": []
},
{
"ref": "pkg:nim/npeg",
"dependsOn": []
},
{
"ref": "pkg:nim/bigints",
"dependsOn": []
},
{
"ref": "pkg:nim/cps",
"dependsOn": []
},
{
"ref": "pkg:nim/stew",
"dependsOn": []
},
{
"ref": "pkg:nim/getdns",
"dependsOn": []
},
{
"ref": "pkg:nim/solo5_dispatcher",
"dependsOn": [
"pkg:nim/cps"
]
}
]
}

View File

@ -1,23 +1,32 @@
{ lib, buildNimPackage, fetchFromGitea, makeDesktopItem, syndicate }:
{
lib,
buildNimPackage,
fetchFromGitea,
makeDesktopItem,
pkg-config,
pcre,
}:
buildNimPackage rec {
pname = "xdg_open_ng";
version = "20220625";
nimBinOnly = true;
pname = "syndicated-open";
version = "20231010";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-yOuR4KYAMxlRc4AIr3ud0HzidHDQPeIiN3dzlnphLug=";
hash = "sha256-DVBSsnN59XKV7Pc1spBxcLwyOIif3xMHXHID9khVJck=";
};
propagatedBuildInputs = [ syndicate ];
nativeBuildInputs = [ pkg-config ];
propagatedBuildInputs = [ pcre ];
lockFile = "${src}/lock.json";
desktopItem = makeDesktopItem rec {
name = "xdg-open";
desktopName = "Syndicate URI dispatcher (xdg-open)";
name = "open";
desktopName = "Syndicated URI open";
exec = "${name} %U";
mimeTypes = [
"application/vnd.mozilla.xul+xml"
@ -30,12 +39,12 @@ buildNimPackage rec {
};
postInstall = ''
mv $out/bin/xdg_open $out/bin/xdg-open
ln -s open $out/bin/xdg-open
cp -a $desktopItem/* $out/
'';
meta = src.meta // {
description = "Replacement for xdg-open that uses Syndicate for messaging.";
description = "Syndicated open command";
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};

View File

@ -0,0 +1,54 @@
{
lib,
python3Packages,
fetchFromGitea,
}:
python3Packages.buildPythonApplication rec {
pname = "synit-python-daemons";
version = "2023-11-01";
format = "other";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "synit";
repo = "synit";
rev = "a2ecd8a4e441f8622a57a99987cb0aa5be9e1dcd";
hash = "sha256-M79AJ8/Synzm4CYkt3+GYViJLJcuYBW+x32Vfy+oFUM=";
};
sourceRoot = "${src.name}/packaging/packages/synit-config/files/usr/lib/synit/python/synit/daemon";
propagatedBuildInputs = with python3Packages; [
pyroute2
syndicate-py
];
postPatch = ''
for f in *.py; do
substituteInPlace $f --replace \
"/home/tonyg/src/synit/protocols" \
"$out/share/syndicate-protocols"
done
'';
buildPhase = ''
runHook preBuild
for f in *.py; do
sed -i '1i #!/bin/python' $f
done
runHook postBuild
'';
installPhase = ''
runHook preInstall
for f in *.py; do
bin_name=$f
bin_name=''${bin_name/.py}
bin_name=''${bin_name//_/-}
install --mode 0555 -D $f $out/bin/$bin_name
done
install -D -t $out/share/syndicate-protocols $src/protocols/schema-bundle.bin
runHook postInstall
'';
}

View File

@ -1,33 +0,0 @@
{ lib, buildPythonApplication, python, pyroute2, syndicate, synit-pid1 }:
buildPythonApplication rec {
pname = "interface-monitor";
inherit (synit-pid1) version src;
propagatedBuildInputs = [ pyroute2 syndicate ];
format = "other";
installPhase = ''
runHook preInstall
mkdir -p \
$out/bin \
$out/lib/${python.libPrefix}/site-packages/synit/daemon \
$out/protocols \
cp -r protocols/schema-bundle.bin $out/protocols
pushd packaging/packages/synit-config/files/usr/lib/synit
for f in *; do
[ -f $f ] && cp $f $out/bin
done
pushd python/synit/daemon
for f in *; do
substitute $f $out/lib/${python.libPrefix}/site-packages/synit/daemon/$f \
--replace "/home/tonyg/src/synit/protocols" "$out/protocols"
done
popd
popd
runHook postInstall
'';
}

View File

@ -1,16 +1,21 @@
# https://git.syndicate-lang.org/synit/synit/src/branch/main/packaging/packages/synit-pid1/APKBUILD
{ lib, rustPlatform, rust, fetchFromGitea }:
{
lib,
rustPlatform,
rustc,
fetchFromGitea,
}:
rustPlatform.buildRustPackage rec {
pname = "synit-pid1";
version = "unstable-2022-07-25";
version = "unstable-2023-11-01";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "synit";
repo = "synit";
rev = "f91214d1b0c5de0ba6ef3debf39e2632adae9ec5";
hash = "sha256-T+GzvanVTuHvazMQIPVxq02ANtVPM0yma43G3+UoI5c=";
rev = "a2ecd8a4e441f8622a57a99987cb0aa5be9e1dcd";
hash = "sha256-M79AJ8/Synzm4CYkt3+GYViJLJcuYBW+x32Vfy+oFUM=";
};
patchPhase =
@ -26,10 +31,12 @@ rustPlatform.buildRustPackage rec {
'';
sourceRoot = "source/${pname}";
cargoHash = "sha256-0py5bOFwCvZL1SBVx4bo0/jFvt8S5ef8AGGRHZFWsgQ=";
nativeBuildInputs = [ rust ];
cargoHash = "sha256-mO1gMtXEc34v9zBst1by1Ed8l/kvuJ9n4/6vJ1LhijM=";
nativeBuildInputs = [ rustc ];
meta = {
RUSTC_BOOTSTRAP = true;
meta = src.meta // {
description = "Synit pid 1 program (patched for NixOS)";
homepage = "https://synit.org/";
maintainers = with lib.maintainers; [ ehmry ];

View File

@ -0,0 +1,32 @@
{
lib,
buildNimPackage,
fetchFromGitea,
pkg-config,
syndicate,
xapian,
}:
buildNimPackage rec {
pname = "xapian_actor";
version = "20230610";
src = fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = pname;
rev = version;
hash = "sha256-f/+l+c6SCvHH8zDz3/9ndrT77ck5gfk5zESKL74IfNg=";
};
propagatedNativeBuildInputs = [ pkg-config ];
propagatedBuildInputs = [
syndicate
xapian
];
meta = src.meta // {
maintainers = [ lib.maintainers.ehmry ];
license = lib.licenses.unlicense;
};
}