mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-22 03:05:32 +02:00
nix: split cli and server packages
This commit is contained in:
parent
325358bc0f
commit
9872ad5444
2 changed files with 76 additions and 23 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use std::sync::Arc;
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use archivr_core::{archive, database};
|
use archivr_core::{archive, database};
|
||||||
use axum::{
|
use axum::{
|
||||||
|
|
@ -21,7 +21,7 @@ pub fn app(registry: ServerRegistry) -> Router {
|
||||||
let state = AppState {
|
let state = AppState {
|
||||||
registry: Arc::new(registry),
|
registry: Arc::new(registry),
|
||||||
};
|
};
|
||||||
let static_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("static");
|
let static_dir = static_dir();
|
||||||
|
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/health", get(|| async { "ok" }))
|
.route("/health", get(|| async { "ok" }))
|
||||||
|
|
@ -37,6 +37,12 @@ pub fn app(registry: ServerRegistry) -> Router {
|
||||||
.with_state(state)
|
.with_state(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn static_dir() -> PathBuf {
|
||||||
|
std::env::var_os("ARCHIVR_STATIC_DIR")
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("static"))
|
||||||
|
}
|
||||||
|
|
||||||
async fn list_archives(State(state): State<AppState>) -> Json<Vec<MountedArchive>> {
|
async fn list_archives(State(state): State<AppState>) -> Json<Vec<MountedArchive>> {
|
||||||
Json(state.registry.archives.clone())
|
Json(state.registry.archives.clone())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
89
flake.nix
89
flake.nix
|
|
@ -59,12 +59,45 @@
|
||||||
tweetPython = pkgs.python312.withPackages (ps: [
|
tweetPython = pkgs.python312.withPackages (ps: [
|
||||||
twitterApiClient
|
twitterApiClient
|
||||||
]);
|
]);
|
||||||
archivr_unwrapped = pkgs.rustPlatform.buildRustPackage {
|
version = "0.1.0";
|
||||||
pname = "archivr";
|
src = pkgs.lib.cleanSource ./.;
|
||||||
version = "0.1.0";
|
cargoLock = {
|
||||||
src = pkgs.lib.cleanSource ./.;
|
lockFile = ./Cargo.lock;
|
||||||
cargoHash = "";
|
};
|
||||||
nativeBuildInputs = [ pkgs.pkg-config ];
|
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||||
|
archivr_cli_unwrapped = pkgs.rustPlatform.buildRustPackage {
|
||||||
|
pname = "archivr-cli";
|
||||||
|
inherit
|
||||||
|
version
|
||||||
|
src
|
||||||
|
cargoLock
|
||||||
|
nativeBuildInputs
|
||||||
|
;
|
||||||
|
cargoBuildFlags = [
|
||||||
|
"-p"
|
||||||
|
"archivr-cli"
|
||||||
|
];
|
||||||
|
cargoTestFlags = [
|
||||||
|
"-p"
|
||||||
|
"archivr-cli"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
archivr_server_unwrapped = pkgs.rustPlatform.buildRustPackage {
|
||||||
|
pname = "archivr-server";
|
||||||
|
inherit
|
||||||
|
version
|
||||||
|
src
|
||||||
|
cargoLock
|
||||||
|
nativeBuildInputs
|
||||||
|
;
|
||||||
|
cargoBuildFlags = [
|
||||||
|
"-p"
|
||||||
|
"archivr-server"
|
||||||
|
];
|
||||||
|
cargoTestFlags = [
|
||||||
|
"-p"
|
||||||
|
"archivr-server"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
archivr = pkgs.stdenv.mkDerivation {
|
archivr = pkgs.stdenv.mkDerivation {
|
||||||
pname = "archivr-wrapped";
|
pname = "archivr-wrapped";
|
||||||
|
|
@ -77,29 +110,43 @@
|
||||||
phases = [ "installPhase" ];
|
phases = [ "installPhase" ];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin $out/libexec/archivr
|
mkdir -p $out/bin $out/libexec/archivr
|
||||||
cp -r ${archivr_unwrapped}/bin/* $out/bin/
|
cp ${archivr_cli_unwrapped}/bin/archivr $out/libexec/archivr/archivr
|
||||||
cp ${./vendor/twitter/scrape_user_tweet_contents.py} $out/libexec/archivr/scrape_user_tweet_contents.py
|
cp ${./vendor/twitter/scrape_user_tweet_contents.py} $out/libexec/archivr/scrape_user_tweet_contents.py
|
||||||
chmod +x $out/libexec/archivr/scrape_user_tweet_contents.py
|
chmod +x $out/libexec/archivr/scrape_user_tweet_contents.py
|
||||||
for f in $out/bin/*; do
|
makeWrapper $out/libexec/archivr/archivr $out/bin/archivr \
|
||||||
mv "$f" "$f.orig"
|
--set ARCHIVR_YT_DLP ${pkgs.yt-dlp}/bin/yt-dlp \
|
||||||
makeWrapper "$f.orig" "$f" \
|
--set ARCHIVR_TWEET_PYTHON ${tweetPython}/bin/python3 \
|
||||||
--set ARCHIVR_YT_DLP ${pkgs.yt-dlp}/bin/yt-dlp \
|
--set ARCHIVR_TWEET_SCRAPER $out/libexec/archivr/scrape_user_tweet_contents.py \
|
||||||
--set ARCHIVR_TWEET_PYTHON ${tweetPython}/bin/python3 \
|
--prefix PATH : ${
|
||||||
--set ARCHIVR_TWEET_SCRAPER $out/libexec/archivr/scrape_user_tweet_contents.py \
|
lib.makeBinPath [
|
||||||
--prefix PATH : ${
|
pkgs.yt-dlp
|
||||||
lib.makeBinPath [
|
tweetPython
|
||||||
pkgs.yt-dlp
|
]
|
||||||
tweetPython
|
}
|
||||||
]
|
'';
|
||||||
}
|
};
|
||||||
done
|
archivr_server = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "archivr-server-wrapped";
|
||||||
|
inherit version;
|
||||||
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
|
phases = [ "installPhase" ];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin $out/libexec/archivr-server $out/share/archivr-server/static
|
||||||
|
cp ${archivr_server_unwrapped}/bin/archivr-server $out/libexec/archivr-server/archivr-server
|
||||||
|
cp -r ${./crates/archivr-server/static}/* $out/share/archivr-server/static/
|
||||||
|
makeWrapper $out/libexec/archivr-server/archivr-server $out/bin/archivr-server \
|
||||||
|
--set ARCHIVR_STATIC_DIR $out/share/archivr-server/static
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
default = archivr;
|
default = archivr;
|
||||||
archivr = archivr;
|
archivr = archivr;
|
||||||
archivr-unwrapped = archivr_unwrapped;
|
archivr-cli = archivr;
|
||||||
|
archivr-cli-unwrapped = archivr_cli_unwrapped;
|
||||||
|
archivr-unwrapped = archivr_cli_unwrapped;
|
||||||
|
archivr-server = archivr_server;
|
||||||
|
archivr-server-unwrapped = archivr_server_unwrapped;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue