diff --git a/libraries/droplet/.envrc b/libraries/droplet/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/libraries/droplet/.envrc @@ -0,0 +1 @@ +use flake diff --git a/libraries/droplet/.gitignore b/libraries/droplet/.gitignore index d80b04ff..340991a0 100644 --- a/libraries/droplet/.gitignore +++ b/libraries/droplet/.gitignore @@ -22,4 +22,6 @@ target/ perf.data flamegraph.svg -*.json \ No newline at end of file +*.json + +.direnv \ No newline at end of file diff --git a/libraries/droplet/flake.lock b/libraries/droplet/flake.lock new file mode 100644 index 00000000..e0d2640d --- /dev/null +++ b/libraries/droplet/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1768886240, + "narHash": "sha256-C2TjvwYZ2VDxYWeqvvJ5XPPp6U7H66zeJlRaErJKoEM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "80e4adbcf8992d3fd27ad4964fbb84907f9478b0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1768963622, + "narHash": "sha256-n6VHiUgrYD9yjagzG6ncVVqFbVTsKCI54tR9PNAFCo0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "2ef5b3362af585a83bafd34e7fc9b1f388c2e5e2", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/libraries/droplet/flake.nix b/libraries/droplet/flake.nix new file mode 100644 index 00000000..7c806fd3 --- /dev/null +++ b/libraries/droplet/flake.nix @@ -0,0 +1,52 @@ +{ + description = "Drop-OSS app development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + rust-overlay, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + libraries = with pkgs; [ + glib + glibc + openssl + ]; + in + { + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + pkg-config + git + rust-bin.nightly.latest.default + rust-analyzer + cargo-expand + ]; + + + buildInputs = libraries; + + shellHook = '' + export LD_LIBRARY_PATH="${ + pkgs.lib.makeLibraryPath libraries + }:$LD_LIBRARY_PATH" + echo "Downpour development environment loaded" + ''; + }; + } + ); +} diff --git a/libraries/droplet/src/main.rs b/libraries/droplet/src/main.rs index 76036a45..baff5528 100644 --- a/libraries/droplet/src/main.rs +++ b/libraries/droplet/src/main.rs @@ -1,15 +1,16 @@ -use std::{os::unix::fs::MetadataExt, path::PathBuf}; +use std::{env, os::unix::fs::MetadataExt, path::PathBuf}; use droplet_rs::manifest::generate_manifest_rusty; -use serde_json::json; use tokio::runtime::Handle; #[tokio::main] pub async fn main() { - let target_dir = - PathBuf::from("/home/decduck/.local/share/Steam/steamapps/common/BloonsTD6"); + let mut args = env::args(); + let target_dir = PathBuf::from(args.nth(1).expect("Provide target directory")); + let metrics = Handle::current().metrics(); println!("using {} workers", metrics.num_workers()); + let manifest = generate_manifest_rusty( &target_dir, |progress| println!("PROGRESS: {}", progress),