flake reorg

This commit is contained in:
Robin Appelman 2025-05-30 23:01:05 +02:00
commit db5cef6fb7
10 changed files with 109 additions and 85 deletions

View file

@ -3,7 +3,7 @@ name: docker-build
on: on:
push: push:
branches: branches:
- 'master' - "master"
jobs: jobs:
docker: docker:

View file

@ -4,10 +4,7 @@
"describe": { "describe": {
"columns": [], "columns": [],
"parameters": { "parameters": {
"Left": [ "Left": ["Int4", "Jsonb"]
"Int4",
"Jsonb"
]
}, },
"nullable": [] "nullable": []
}, },

View file

@ -12,9 +12,7 @@
"parameters": { "parameters": {
"Left": [] "Left": []
}, },
"nullable": [ "nullable": [null]
null
]
}, },
"hash": "e4dfb1fbca2c91ac837d11aff64e035ccce38867e3503653ec2ef28eeeb8907d" "hash": "e4dfb1fbca2c91ac837d11aff64e035ccce38867e3503653ec2ef28eeeb8907d"
} }

View file

@ -5,7 +5,7 @@ authors = ["Robin Appelman <robin@icewind.nl>"]
edition = "2018" edition = "2018"
[dependencies] [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" dotenvy = "0.15.7"
main_error = "0.1.2" main_error = "0.1.2"
tokio = { version = "1.36.0", features = ["macros", "time", "rt-multi-thread"] } tokio = { version = "1.36.0", features = ["macros", "time", "rt-multi-thread"] }

95
flake.lock generated
View file

@ -1,56 +1,103 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "crane": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1705309234, "lastModified": 1742394900,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=",
"owner": "numtide", "owner": "ipetkov",
"repo": "flake-utils", "repo": "crane",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "ipetkov",
"repo": "flake-utils", "repo": "crane",
"type": "github" "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707650010, "lastModified": 1748638332,
"narHash": "sha256-dOhphIA4MGrH4ElNCy/OlwmN24MsnEqFjRR6+RY7jZw=", "narHash": "sha256-s2U9GJgLUohD4sK0w+H/NT+B+m50jxURZNkGXwEbZ4M=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "809cca784b9f72a5ad4b991e0e7bcf8890f9c3a6", "rev": "a627748de5a6aa694e9a143df95655b7b52f242c",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "release-23.11", "ref": "release-25.05",
"type": "indirect" "type": "indirect"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flakelight": "flakelight",
"mill-scale": "mill-scale",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
}, },
"systems": { "rust-overlay": {
"inputs": {
"nixpkgs": [
"mill-scale",
"flakelight",
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1681028828, "lastModified": 1742697269,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=",
"owner": "nix-systems", "owner": "oxalica",
"repo": "default", "repo": "rust-overlay",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "rev": "01973c84732f9275c50c5f075dd1f54cc04b3316",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-systems", "owner": "oxalica",
"repo": "default", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
} }

View file

@ -1,55 +1,38 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/release-23.11"; nixpkgs.url = "nixpkgs/release-25.05";
flake-utils.url = "github:numtide/flake-utils"; 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 = { outputs = {mill-scale, ...}:
self, mill-scale ./. {
nixpkgs, withOverlays = [
flake-utils, (import ./nix/overlay.nix)
}: ];
flake-utils.lib.eachDefaultSystem ( extraPaths = [
system: let ./.sqlx
overlays = [
(import ./overlay.nix)
]; ];
pkgs = import nixpkgs {
inherit system overlays;
};
in rec {
packages = rec {
inherit (pkgs) log-archiver;
default = log-archiver;
};
devShells.default = pkgs.mkShell { nixosModules = {outputs, ...}: {
nativeBuildInputs = with pkgs; [ default = {
rustc
cargo
bacon
clippy
cargo-edit
cargo-outdated
cargo-insta
sqlx-cli
];
};
}
)
// {
overlays.default = import ./overlay.nix;
nixosModules.default = {
pkgs, pkgs,
config, config,
lib, lib,
... ...
}: { }: {
imports = [./module.nix]; imports = [./nix/module.nix];
config = lib.mkIf config.services.log-archiver.enable { config = lib.mkIf config.services.dropstf.enable {
nixpkgs.overlays = [self.overlays.default]; nixpkgs.overlays = [outputs.overlays.default];
services.log-archiver.package = lib.mkDefault pkgs.log-archiver; services.log-archiver.package = lib.mkDefault pkgs.log-archiver;
}; };
}; };
}; };
};
} }

View file

@ -17,7 +17,7 @@ in {
databaseUrlFile = mkOption { databaseUrlFile = mkOption {
type = types.str; type = types.str;
description = "file containg DATABASE_URL variable"; description = "file containing DATABASE_URL variable";
}; };
baseUrl = mkOption { baseUrl = mkOption {

View file

@ -1,10 +1,9 @@
{ {
stdenv,
rustPlatform, rustPlatform,
lib, lib,
}: let }: let
inherit (lib.sources) sourceByRegex; inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src|tests|.sqlx)(/.*)?"]; src = sourceByRegex ../. ["Cargo.*" "(src|tests|.sqlx)(/.*)?"];
in in
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "log-archiver"; pname = "log-archiver";
@ -15,6 +14,6 @@ in
inherit src; inherit src;
cargoLock = { cargoLock = {
lockFile = ./Cargo.lock; lockFile = ../Cargo.lock;
}; };
} }

View file

@ -44,7 +44,7 @@ async fn main() -> Result<(), MainError> {
async fn get_last_demo(client: &Client, api_host: &str) -> Result<i32, MainError> { async fn get_last_demo(client: &Client, api_host: &str) -> Result<i32, MainError> {
let response: Response = client let response: Response = client
.get(&format!("{}/api/v1/log?limit=100", api_host)) .get(format!("{}/api/v1/log?limit=100", api_host))
.send() .send()
.await?; .await?;
let listing: LogListing = serde_json::from_str(&response.text().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; sleep(Duration::from_millis(500)).await;
let response: Response = client let response: Response = client
.get(&format!("{}/api/v1/log/{}", api_host, last_archived)) .get(format!("{}/api/v1/log/{}", api_host, last_archived))
.send() .send()
.await?; .await?;
let body: Value = serde_json::from_str(&response.text().await?)?; let body: Value = serde_json::from_str(&response.text().await?)?;
@ -111,7 +111,7 @@ async fn download_log(
id: i32, id: i32,
) -> Result<(), MainError> { ) -> Result<(), MainError> {
let log_zip = client let log_zip = client
.get(&format!("{}/logs/log_{}.log.zip", api_host, id)) .get(format!("{}/logs/log_{}.log.zip", api_host, id))
.send() .send()
.await? .await?
.bytes() .bytes()