mirror of
https://codeberg.org/demostf/sync.git
synced 2026-06-03 16:44:07 +02:00
flake rework
This commit is contained in:
parent
82e79ef01d
commit
b0ae2c7927
14 changed files with 577 additions and 531 deletions
65
.github/workflows/ci.yaml
vendored
65
.github/workflows/ci.yaml
vendored
|
|
@ -1,68 +1,17 @@
|
|||
on: [push, pull_request]
|
||||
|
||||
name: CI
|
||||
name: "CI"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
checks:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
machine:
|
||||
- platform: x86_64-linux
|
||||
- platform: aarch64-linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- if: matrix.machine.platform != 'x86_64-linux'
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- uses: cachix/install-nix-action@v26
|
||||
with:
|
||||
extra_nix_config: |
|
||||
extra-platforms = aarch64-linux
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build --option system ${{ matrix.machine.platform }}
|
||||
|
||||
|
||||
build-docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
strategy:
|
||||
matrix:
|
||||
machine:
|
||||
- platform: x86_64-linux
|
||||
- platform: aarch64-linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- if: matrix.machine.platform != 'x86_64-linux'
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- uses: cachix/install-nix-action@v26
|
||||
with:
|
||||
extra_nix_config: |
|
||||
extra-platforms = aarch64-linux
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build --option system ${{ matrix.machine.platform }} .#docker
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-docker]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v26
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
- run: nix run .#dockerManifest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
env:
|
||||
VERSION: "1.0.0"
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||
- run: nix flake check --keep-going
|
||||
|
|
|
|||
749
Cargo.lock
generated
749
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
Websocket api to sync playback of demos
|
||||
|
||||
By default the websocket server listens on port 80, this can be changed by settings the PORT environment variable.
|
||||
By default, the websocket server listens on port 80, this can be changed by settings the PORT environment variable.
|
||||
|
|
|
|||
146
flake.lock
generated
146
flake.lock
generated
|
|
@ -1,131 +1,103 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1701473968,
|
||||
"narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5",
|
||||
"lastModified": 1730060262,
|
||||
"narHash": "sha256-RMgSVkZ9H03sxC+Vh4jxtLTCzSjPq18UWpiM0gq6shQ=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "498d9f122c413ee1154e8131ace5a35a80d8fa76",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flocken": {
|
||||
"flakelight": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1704105102,
|
||||
"narHash": "sha256-c4VWO9plhINjQzYPHSKURWgQ2D2q24aI3OIN0MTPjz0=",
|
||||
"owner": "mirkolenz",
|
||||
"repo": "flocken",
|
||||
"rev": "3a846dfca17f989805d9f4177de85c96dc0f8542",
|
||||
"lastModified": 1731933812,
|
||||
"narHash": "sha256-PeuRDDq1DcHxbOmXWb3nWMp5PqWUn5PSKimNbUzWEaQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flakelight",
|
||||
"rev": "f4b26f683be5c9ac1ec05f968dbbcb35f4bb6346",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "mirkolenz",
|
||||
"ref": "v2",
|
||||
"repo": "flocken",
|
||||
"owner": "nix-community",
|
||||
"repo": "flakelight",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mill-scale": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flakelight": [
|
||||
"flakelight"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1732306573,
|
||||
"narHash": "sha256-wE12kIIE0qb9V9y0JiVm5RsRrMNX+KeeMwkzwefdHhY=",
|
||||
"owner": "icewind1991",
|
||||
"repo": "mill-scale",
|
||||
"rev": "8b4cbf174a9728d7e58bbfde5b5a6685dcbf1015",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "icewind1991",
|
||||
"repo": "mill-scale",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1710695816,
|
||||
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
|
||||
"lastModified": 1731797254,
|
||||
"narHash": "sha256-df3dJApLPhd11AlueuoN0Q4fHo/hagP75LlM5K1sz9g=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
|
||||
"rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "release-23.11",
|
||||
"ref": "nixos-24.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"lastModified": 1701253981,
|
||||
"narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"dir": "lib",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flocken": "flocken",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
"flakelight": "flakelight",
|
||||
"mill-scale": "mill-scale",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
"nixpkgs": [
|
||||
"mill-scale",
|
||||
"flakelight",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"lastModified": 1731897198,
|
||||
"narHash": "sha256-Ou7vLETSKwmE/HRQz4cImXXJBr/k9gp4J4z/PF8LzTE=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "0be641045af6d8666c11c2c40e45ffc9667839b5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
66
flake.nix
66
flake.nix
|
|
@ -1,64 +1,14 @@
|
|||
{
|
||||
inputs = {
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "nixpkgs/release-23.11";
|
||||
flocken = {
|
||||
url = "github:mirkolenz/flocken/v2";
|
||||
nixpkgs.url = "nixpkgs/nixos-24.05";
|
||||
flakelight = {
|
||||
url = "github:nix-community/flakelight";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
mill-scale = {
|
||||
url = "github:icewind1991/mill-scale";
|
||||
inputs.flakelight.follows = "flakelight";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
flocken,
|
||||
}:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
overlays = [
|
||||
(import ./overlay.nix)
|
||||
];
|
||||
pkgs = (import nixpkgs) {
|
||||
inherit system overlays;
|
||||
};
|
||||
inherit (flocken.legacyPackages.${system}) mkDockerManifest;
|
||||
inherit (builtins) fromTOML readFile;
|
||||
version = (fromTOML (readFile ./Cargo.toml)).package.version;
|
||||
in rec {
|
||||
packages = rec {
|
||||
sync = pkgs.demostf-sync;
|
||||
docker = pkgs.demostf-sync-docker;
|
||||
default = sync;
|
||||
|
||||
dockerManifest = mkDockerManifest {
|
||||
tags = ["latest"];
|
||||
registries = {
|
||||
"docker.io" = {
|
||||
enable = true;
|
||||
repo = "demostf/sync";
|
||||
username = "$DOCKERHUB_USERNAME";
|
||||
password = "$DOCKERHUB_TOKEN";
|
||||
};
|
||||
};
|
||||
inherit version;
|
||||
images = with self.packages; [x86_64-linux.docker aarch64-linux.docker];
|
||||
};
|
||||
};
|
||||
devShells.default = pkgs.mkShell {
|
||||
OPENSSL_NO_VENDOR = 1;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cargo
|
||||
rustc
|
||||
bacon
|
||||
cargo-edit
|
||||
cargo-outdated
|
||||
clippy
|
||||
cargo-audit
|
||||
cargo-watch
|
||||
pkg-config
|
||||
openssl
|
||||
];
|
||||
};
|
||||
});
|
||||
outputs = { mill-scale, ... }: mill-scale ./. { };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
dockerTools,
|
||||
demostf-sync,
|
||||
{ dockerTools
|
||||
, demostf-sync
|
||||
,
|
||||
}:
|
||||
dockerTools.buildLayeredImage {
|
||||
name = "demostf/sync";
|
||||
|
|
@ -11,9 +11,9 @@ dockerTools.buildLayeredImage {
|
|||
dockerTools.caCertificates
|
||||
];
|
||||
config = {
|
||||
Cmd = ["sync"];
|
||||
Cmd = [ "sync" ];
|
||||
ExposedPorts = {
|
||||
"80/tcp" = {};
|
||||
"80/tcp" = { };
|
||||
};
|
||||
};
|
||||
}
|
||||
4
nix/overlay.nix
Normal file
4
nix/overlay.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
prev: final: {
|
||||
demostf-sync = final.callPackage ./package.nix { };
|
||||
demostf-sync-docker = final.callPackage ./docker.nix { };
|
||||
}
|
||||
26
nix/package.nix
Normal file
26
nix/package.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ stdenv
|
||||
, rustPlatform
|
||||
, lib
|
||||
, pkg-config
|
||||
, openssl
|
||||
,
|
||||
}:
|
||||
let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
inherit (builtins) fromTOML readFile;
|
||||
src = sourceByRegex ../. [ "Cargo.*" "(src)(/.*)?" ];
|
||||
version = (fromTOML (readFile ../Cargo.toml)).package.version;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "demostf-sync";
|
||||
|
||||
inherit src version;
|
||||
|
||||
buildInputs = [ openssl ];
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
prev: final: {
|
||||
demostf-sync = final.callPackage ./package.nix {};
|
||||
demostf-sync-docker = final.callPackage ./docker.nix {};
|
||||
}
|
||||
25
package.nix
25
package.nix
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
stdenv,
|
||||
rustPlatform,
|
||||
lib,
|
||||
pkg-config,
|
||||
openssl,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
inherit (builtins) fromTOML readFile;
|
||||
src = sourceByRegex ./. ["Cargo.*" "(src|build|images|script|style|.sqlx)(/.*)?"];
|
||||
version = (fromTOML (readFile ./Cargo.toml)).package.version;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "demostf-sync";
|
||||
|
||||
inherit src version;
|
||||
|
||||
buildInputs = [openssl];
|
||||
|
||||
nativeBuildInputs = [pkg-config];
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ use parity_ws::{util::Token, Result, Sender};
|
|||
|
||||
#[enum_dispatch(Client)]
|
||||
pub(crate) trait ClientTrait {
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn send(&self, msg: &str) -> Result<()>;
|
||||
|
||||
fn token(&self) -> Token;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ fn integration_tests() {
|
|||
|
||||
fn send<T: std::io::Write>(client: &mut Client<T>, command: SyncCommand) {
|
||||
client
|
||||
.send(Message::text(&serde_json::to_string(&command).unwrap()))
|
||||
.send(Message::text(serde_json::to_string(&command).unwrap()))
|
||||
.unwrap();
|
||||
sleep(DELAY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ mod tests {
|
|||
let sessions: RefCell<HashMap<String, Session>> = RefCell::new(HashMap::new());
|
||||
let sender = Client::mock(1);
|
||||
let command = SyncCommand::Create {
|
||||
session: "test".into(),
|
||||
session: "test",
|
||||
token: "bar",
|
||||
};
|
||||
|
||||
|
|
|
|||
38
sync.iml
38
sync.iml
|
|
@ -1,38 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="RUST_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/benches" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/byteorder-541037c38e614382/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/getrandom-492d00fbd9dd584b/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/getrandom-dc67b657af42ab9a/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/httparse-58311939ec3ae3f7/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/httparse-ece31b0013b2fb06/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/libc-5efc7c4996b307a9/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/libc-afe168503a796e74/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/log-371e270675b3708b/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/log-453889d46ca1ed12/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/proc-macro2-9b7d167b077a86e8/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/proc-macro2-b61e1bb2d2a4c8bd/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/ryu-f99552c5fa0b2a9b/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde-9d4a021e2785a264/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde-e0316e7a5d134d58/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_derive-8532e376bf52852f/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_derive-e502cf3ccba3719a/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_json-5fdd038ccabd38f2/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_json-e0c813d629c16450/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/syn-96d1e304334fc1df/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/syn-bdd43f78a1e519ba/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/typenum-a845ac8e04079320/out" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/typenum-f6d195b3ffce7585/out" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Cargo <sync>" level="project" />
|
||||
<orderEntry type="library" name="Rust <sync>" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Loading…
Add table
Add a link
Reference in a new issue