From ea833b39ec7da93eb3cc0129a568df6d2331d93c Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Thu, 26 Dec 2024 23:33:24 -0800 Subject: [PATCH] flake: nix packaged! --- .gitignore | 1 + ...a53d5a9096c06677c3f6089fbab52461781c.json} | 4 +-- flake.nix | 11 ++++--- package.nix | 31 +++++++++++++++++++ 4 files changed, 41 insertions(+), 6 deletions(-) rename .sqlx/{query-a2f3905f8f8e14c95404f88f2e60dcf13e7b7caf5307bd19240655621251f7c9.json => query-09bffef8e28906ad1827486e236aa53d5a9096c06677c3f6089fbab52461781c.json} (67%) create mode 100644 package.nix diff --git a/.gitignore b/.gitignore index fe0ce13..ec52bf6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .DS_Store /.cache /node_modules +result testing.db testing.db-shm testing.db-wal diff --git a/.sqlx/query-a2f3905f8f8e14c95404f88f2e60dcf13e7b7caf5307bd19240655621251f7c9.json b/.sqlx/query-09bffef8e28906ad1827486e236aa53d5a9096c06677c3f6089fbab52461781c.json similarity index 67% rename from .sqlx/query-a2f3905f8f8e14c95404f88f2e60dcf13e7b7caf5307bd19240655621251f7c9.json rename to .sqlx/query-09bffef8e28906ad1827486e236aa53d5a9096c06677c3f6089fbab52461781c.json index d056c57..45457c6 100644 --- a/.sqlx/query-a2f3905f8f8e14c95404f88f2e60dcf13e7b7caf5307bd19240655621251f7c9.json +++ b/.sqlx/query-09bffef8e28906ad1827486e236aa53d5a9096c06677c3f6089fbab52461781c.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "UPDATE records\nSET downloads = downloads + 1\nWHERE\n cache_name = ?\n AND downloads < max_downloads\n AND julianday('now') - julianday(uploaded) > 5;\n", + "query": "UPDATE records\nSET downloads = downloads + 1\nWHERE\n cache_name = ?\n AND downloads < max_downloads\n AND julianday('now') - julianday(uploaded) < 5;\n", "describe": { "columns": [], "parameters": { @@ -8,5 +8,5 @@ }, "nullable": [] }, - "hash": "a2f3905f8f8e14c95404f88f2e60dcf13e7b7caf5307bd19240655621251f7c9" + "hash": "09bffef8e28906ad1827486e236aa53d5a9096c06677c3f6089fbab52461781c" } diff --git a/flake.nix b/flake.nix index a29cebe..2038a1d 100644 --- a/flake.nix +++ b/flake.nix @@ -3,10 +3,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + flake-parts.url = "github:hercules-ci/flake-parts"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; @@ -33,6 +30,12 @@ })) ]; }; + packages.default = + let rust-bin = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal); + in pkgs.callPackage ./package.nix { + cargo = rust-bin; + rustc = rust-bin; + }; }; }; } diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..95bea43 --- /dev/null +++ b/package.nix @@ -0,0 +1,31 @@ +{ makeRustPlatform +, cargo +, rustc + + # Runtime Deps +, sqlite + + # Build Deps +, openssl +, pkg-config +}: + +let rustPlatform = makeRustPlatform { inherit cargo rustc; }; +in rustPlatform.buildRustPackage { + pname = "nyazoom"; + version = "0.1.0"; + + src = ./.; + + cargoHash = "sha256-lBMe1TvkTJgN+q/9o7KId6w3CSxGl94Zcz7nxDqu9N0="; + + nativeBuildInputs = [ + openssl + pkg-config + ]; + + buildInputs = [ + openssl + sqlite + ]; +}