From a957b48cd8e22f85909f8200cdcc1377c41d5d55 Mon Sep 17 00:00:00 2001 From: fdnt7 <43757589+fdnt7@users.noreply.github.com> Date: Wed, 8 May 2024 16:25:26 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9D=84=EF=B8=8F=20Add=20`shell.nix`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + lyra/Cargo.lock | 59 +++++++++++++++++++++++++++--------------------- lyra/Cargo.toml | 8 +++---- scripts/db | 4 ++-- scripts/lavalink | 4 ++-- shell.nix | 35 ++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 34 deletions(-) create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index c0d464b..000d55a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .env .vscode +.tmp config.yml lyra/target diff --git a/lyra/Cargo.lock b/lyra/Cargo.lock index 9179e6e..f707698 100644 --- a/lyra/Cargo.lock +++ b/lyra/Cargo.lock @@ -215,6 +215,12 @@ version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" +[[package]] +name = "by_address" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" + [[package]] name = "bytemuck" version = "1.14.3" @@ -279,9 +285,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -543,9 +549,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -1351,16 +1357,16 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.11", + "http 0.2.12", "indexmap", "slab", "tokio", @@ -1462,9 +1468,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -1489,7 +1495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http 0.2.11", + "http 0.2.12", "pin-project-lite", ] @@ -1538,8 +1544,8 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.24", - "http 0.2.11", + "h2 0.3.26", + "http 0.2.12", "http-body 0.4.6", "httparse", "httpdate", @@ -1579,7 +1585,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http 0.2.11", + "http 0.2.12", "hyper 0.14.28", "rustls 0.21.10", "tokio", @@ -1863,7 +1869,7 @@ dependencies = [ [[package]] name = "lyra" -version = "0.5.0" +version = "0.5.1" dependencies = [ "aho-corasick", "bitflags 2.5.0", @@ -2150,9 +2156,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "palette" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebfc23a4b76642983d57e4ad00bb4504eb30a8ce3c70f4aee1f725610e36d97a" +checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6" dependencies = [ "approx", "fast-srgb8", @@ -2161,10 +2167,11 @@ dependencies = [ [[package]] name = "palette_derive" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8890702dbec0bad9116041ae586f84805b13eecd1d8b1df27c29998a9969d6d" +checksum = "f5030daf005bface118c096f510ffb781fc28f9ab6a32ab224d8631be6851d30" dependencies = [ + "by_address", "proc-macro2", "quote", "syn 2.0.58", @@ -2433,17 +2440,17 @@ checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" [[package]] name = "reqwest" -version = "0.11.24" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.3.24", - "http 0.2.11", + "h2 0.3.26", + "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", "hyper-rustls 0.24.2", @@ -3238,18 +3245,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", diff --git a/lyra/Cargo.toml b/lyra/Cargo.toml index 3b0db50..79a309a 100644 --- a/lyra/Cargo.toml +++ b/lyra/Cargo.toml @@ -2,7 +2,7 @@ name = "lyra" readme = "../README.md" description = "A featureful, self-hostable Discord music bot." -version = "0.5.0" +version = "0.5.1" edition = "2021" license = "GPL-3.0" repository = "https://github.com/lyra-music/lyra" @@ -46,7 +46,7 @@ unicode-segmentation = "1.11.0" dashmap = "5.5.3" dotenvy = "0.15.7" dotenvy_macro = "0.15.7" -thiserror = "1.0.58" +thiserror = "1.0.60" color-eyre = "0.6.3" rstest = "0.19.0" futures = "0.3.30" @@ -66,7 +66,7 @@ rand = "0.8.5" itertools = "0.12.1" rayon = "1.10.0" lazy_static = "1.4.0" -chrono = "0.4.37" +chrono = "0.4.38" sqlx = { version = "0.7.4", features = ["postgres", "runtime-tokio-rustls"] } mixbox = "2.0.0" lavalink-rs = { version = "0.11.0", features = ["twilight16"] } @@ -99,7 +99,7 @@ features = ["jpeg", "png", "gif", "tiff"] default-features = false [dependencies.palette] -version = "0.7.5" +version = "0.7.6" features = ["std"] default-features = false diff --git a/scripts/db b/scripts/db index 105d853..64a1623 100755 --- a/scripts/db +++ b/scripts/db @@ -1,2 +1,2 @@ -#!/bin/sh -cd ./db && cargo sqlx database setup \ No newline at end of file +#!/usr/bin/env sh +cd ./db && cargo sqlx database setup diff --git a/scripts/lavalink b/scripts/lavalink index df0b7d7..af8150e 100755 --- a/scripts/lavalink +++ b/scripts/lavalink @@ -1,8 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash # For starting the lavalink server (Linux) set -a # automatically export all variables source .env set +a -(cd lavalink && ./java -jar Lavalink.jar) \ No newline at end of file +(cd lavalink && java -jar Lavalink.jar) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..f1e7852 --- /dev/null +++ b/shell.nix @@ -0,0 +1,35 @@ +{ pkgs ? import { } }: +pkgs.mkShell { + name = "dev"; + + nativeBuildInputs = with pkgs; [ + clang + mold + pgcli + sqlx-cli + postgresql + zulu + ]; + + LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib"; + + shellHook = '' + TMPD="$PWD/.tmp" + export PGDATA="$TMPD/mydb" + export SOCKET_DIRECTORIES="$TMPD/socket" + + mkdir -p $SOCKET_DIRECTORIES + + initdb + echo "unix_socket_directories = '$SOCKET_DIRECTORIES'" >> $PGDATA/postgresql.conf + pg_ctl -l $PGDATA/logfile start + createuser postgres --createdb -h localhost + ./scripts/db + + function end { + pg_ctl stop + rm -rf $TMPD + } + trap end EXIT + ''; +}