mirror of
https://codeberg.org/icewind/log-archiver.git
synced 2026-06-03 09:34:09 +02:00
flake reorg
This commit is contained in:
parent
a650f7f970
commit
db5cef6fb7
10 changed files with 109 additions and 85 deletions
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
|
|
@ -3,7 +3,7 @@ name: docker-build
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- "master"
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@
|
|||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
"Jsonb"
|
||||
]
|
||||
"Left": ["Int4", "Jsonb"]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@
|
|||
"parameters": {
|
||||
"Left": []
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
"nullable": [null]
|
||||
},
|
||||
"hash": "e4dfb1fbca2c91ac837d11aff64e035ccce38867e3503653ec2ef28eeeb8907d"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ authors = ["Robin Appelman <robin@icewind.nl>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
sqlx = { version = "0.7.3", default_features = false, features = ["macros", "postgres", "json", "runtime-tokio-rustls"] }
|
||||
sqlx = { version = "0.7.3", default-features = false, features = ["macros", "postgres", "json", "runtime-tokio-rustls"] }
|
||||
dotenvy = "0.15.7"
|
||||
main_error = "0.1.2"
|
||||
tokio = { version = "1.36.0", features = ["macros", "time", "rt-multi-thread"] }
|
||||
|
|
|
|||
95
flake.lock
generated
95
flake.lock
generated
|
|
@ -1,56 +1,103 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1705309234,
|
||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
||||
"lastModified": 1742394900,
|
||||
"narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flakelight": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1748263617,
|
||||
"narHash": "sha256-O1xypYFWzYlfiyO3fUZuzRhYac5DGptP+ZhocY9L5tQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flakelight",
|
||||
"rev": "65c783ba2b85910df5a053cb1451e9eb13794c12",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "flakelight",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mill-scale": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flakelight": [
|
||||
"flakelight"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1748205441,
|
||||
"narHash": "sha256-W+UUBT/l1DSTZo5G43494mRNNspJ2i9jW2QELC9JuMQ=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "dac3b74a89cebbeb21cc6602e4a346604adbee8b",
|
||||
"revCount": 49,
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/icewind/mill-scale.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/icewind/mill-scale.git"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1707650010,
|
||||
"narHash": "sha256-dOhphIA4MGrH4ElNCy/OlwmN24MsnEqFjRR6+RY7jZw=",
|
||||
"lastModified": 1748638332,
|
||||
"narHash": "sha256-s2U9GJgLUohD4sK0w+H/NT+B+m50jxURZNkGXwEbZ4M=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "809cca784b9f72a5ad4b991e0e7bcf8890f9c3a6",
|
||||
"rev": "a627748de5a6aa694e9a143df95655b7b52f242c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "release-23.11",
|
||||
"ref": "release-25.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"flakelight": "flakelight",
|
||||
"mill-scale": "mill-scale",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"mill-scale",
|
||||
"flakelight",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"lastModified": 1742697269,
|
||||
"narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "01973c84732f9275c50c5f075dd1f54cc04b3316",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
61
flake.nix
61
flake.nix
|
|
@ -1,55 +1,38 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/release-23.11";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "nixpkgs/release-25.05";
|
||||
flakelight = {
|
||||
url = "github:nix-community/flakelight";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
mill-scale = {
|
||||
url = "git+https://codeberg.org/icewind/mill-scale.git";
|
||||
inputs.flakelight.follows = "flakelight";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
overlays = [
|
||||
(import ./overlay.nix)
|
||||
outputs = {mill-scale, ...}:
|
||||
mill-scale ./. {
|
||||
withOverlays = [
|
||||
(import ./nix/overlay.nix)
|
||||
];
|
||||
extraPaths = [
|
||||
./.sqlx
|
||||
];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
in rec {
|
||||
packages = rec {
|
||||
inherit (pkgs) log-archiver;
|
||||
default = log-archiver;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
rustc
|
||||
cargo
|
||||
bacon
|
||||
clippy
|
||||
cargo-edit
|
||||
cargo-outdated
|
||||
cargo-insta
|
||||
sqlx-cli
|
||||
];
|
||||
};
|
||||
}
|
||||
)
|
||||
// {
|
||||
overlays.default = import ./overlay.nix;
|
||||
nixosModules.default = {
|
||||
nixosModules = {outputs, ...}: {
|
||||
default = {
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
imports = [./module.nix];
|
||||
config = lib.mkIf config.services.log-archiver.enable {
|
||||
nixpkgs.overlays = [self.overlays.default];
|
||||
imports = [./nix/module.nix];
|
||||
config = lib.mkIf config.services.dropstf.enable {
|
||||
nixpkgs.overlays = [outputs.overlays.default];
|
||||
services.log-archiver.package = lib.mkDefault pkgs.log-archiver;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ in {
|
|||
|
||||
databaseUrlFile = mkOption {
|
||||
type = types.str;
|
||||
description = "file containg DATABASE_URL variable";
|
||||
description = "file containing DATABASE_URL variable";
|
||||
};
|
||||
|
||||
baseUrl = mkOption {
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
{
|
||||
stdenv,
|
||||
rustPlatform,
|
||||
lib,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
src = sourceByRegex ./. ["Cargo.*" "(src|tests|.sqlx)(/.*)?"];
|
||||
src = sourceByRegex ../. ["Cargo.*" "(src|tests|.sqlx)(/.*)?"];
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "log-archiver";
|
||||
|
|
@ -15,6 +14,6 @@ in
|
|||
inherit src;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ async fn main() -> Result<(), MainError> {
|
|||
|
||||
async fn get_last_demo(client: &Client, api_host: &str) -> Result<i32, MainError> {
|
||||
let response: Response = client
|
||||
.get(&format!("{}/api/v1/log?limit=100", api_host))
|
||||
.get(format!("{}/api/v1/log?limit=100", api_host))
|
||||
.send()
|
||||
.await?;
|
||||
let listing: LogListing = serde_json::from_str(&response.text().await?)?;
|
||||
|
|
@ -85,7 +85,7 @@ async fn archive(database_url: &str, api_host: &str, log_target: &Path) -> Resul
|
|||
sleep(Duration::from_millis(500)).await;
|
||||
|
||||
let response: Response = client
|
||||
.get(&format!("{}/api/v1/log/{}", api_host, last_archived))
|
||||
.get(format!("{}/api/v1/log/{}", api_host, last_archived))
|
||||
.send()
|
||||
.await?;
|
||||
let body: Value = serde_json::from_str(&response.text().await?)?;
|
||||
|
|
@ -111,7 +111,7 @@ async fn download_log(
|
|||
id: i32,
|
||||
) -> Result<(), MainError> {
|
||||
let log_zip = client
|
||||
.get(&format!("{}/logs/log_{}.log.zip", api_host, id))
|
||||
.get(format!("{}/logs/log_{}.log.zip", api_host, id))
|
||||
.send()
|
||||
.await?
|
||||
.bytes()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue