Make nix build slightly less broken
|
@ -1,6 +1,4 @@
|
||||||
{
|
{
|
||||||
lib,
|
|
||||||
|
|
||||||
pkg-config,
|
pkg-config,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
|
|
||||||
|
@ -16,20 +14,18 @@
|
||||||
private-config,
|
private-config,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
src = lib.cleanSource ../.;
|
|
||||||
rustPlatform = makeRustPlatform {
|
rustPlatform = makeRustPlatform {
|
||||||
cargo = rust-toolchain;
|
cargo = rust-toolchain;
|
||||||
rustc = rust-toolchain;
|
rustc = rust-toolchain;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage {
|
rustPlatform.buildRustPackage {
|
||||||
inherit src;
|
|
||||||
pname = "shimmeringmoon";
|
pname = "shimmeringmoon";
|
||||||
version = "unstable-2025-02-11";
|
version = "unstable-2025-02-11";
|
||||||
|
src = ../.;
|
||||||
|
|
||||||
SHIMMERING_FONTS_DIR = shimmering-fonts;
|
SHIMMERING_FONT_DIR = shimmering-fonts;
|
||||||
SHIMMERING_CC_DIR = cc-data;
|
SHIMMERING_CC_DIR = cc-data;
|
||||||
SHIMMERING_PRIVATE_CONFIG_DIR = private-config;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
pkg-config
|
pkg-config
|
||||||
|
@ -37,20 +33,16 @@ rustPlatform.buildRustPackage {
|
||||||
makeWrapper
|
makeWrapper
|
||||||
];
|
];
|
||||||
|
|
||||||
preBuild = ''
|
|
||||||
export SHIMMERING_SOURCE_DIR="$src"
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO: is this supposed to be here???
|
|
||||||
# LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
freetype
|
freetype
|
||||||
fontconfig
|
fontconfig
|
||||||
sqlite
|
sqlite
|
||||||
openssl
|
openssl
|
||||||
src # Idk if putting this here is correct, but it is required at runtime...
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# TODO: do I need to add this
|
||||||
|
# LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
||||||
|
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ../Cargo.lock;
|
lockFile = ../Cargo.lock;
|
||||||
outputHashes = {
|
outputHashes = {
|
||||||
|
@ -63,6 +55,14 @@ rustPlatform.buildRustPackage {
|
||||||
# Disable all tests
|
# Disable all tests
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
|
postBuild = ''
|
||||||
|
for file in $out/bin/*; do
|
||||||
|
wrapProgram $file \
|
||||||
|
--set SHIMMERING_CC_DIR "${cc-data}" \
|
||||||
|
--set SHIMMERING_PRIVATE_CONFIG_DIR ${private-config}
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Arcaea score management toolchain";
|
description = "Arcaea score management toolchain";
|
||||||
homepage = "https://git.moonythm.dev/prescientmoon/shimmeringmoon";
|
homepage = "https://git.moonythm.dev/prescientmoon/shimmeringmoon";
|
||||||
|
|
|
@ -21,11 +21,11 @@ struct NotecountEntry {
|
||||||
notecount: u32,
|
notecount: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_notecount_records(paths: &ShimmeringPaths) -> anyhow::Result<Vec<NotecountEntry>> {
|
pub const NOTECOUNT_DATA: &[u8] = include_bytes!("notecounts.csv");
|
||||||
|
|
||||||
|
fn get_notecount_records() -> anyhow::Result<Vec<NotecountEntry>> {
|
||||||
let mut entries = Vec::new();
|
let mut entries = Vec::new();
|
||||||
let mut reader = csv::Reader::from_reader(std::io::BufReader::new(std::fs::File::open(
|
let mut reader = csv::Reader::from_reader(std::io::Cursor::new(NOTECOUNT_DATA));
|
||||||
paths.notecount_path(),
|
|
||||||
)?));
|
|
||||||
|
|
||||||
for result in reader.records() {
|
for result in reader.records() {
|
||||||
let record = result?;
|
let record = result?;
|
||||||
|
@ -167,8 +167,7 @@ pub fn import_songlist(
|
||||||
paths: &ShimmeringPaths,
|
paths: &ShimmeringPaths,
|
||||||
conn: &mut rusqlite::Connection,
|
conn: &mut rusqlite::Connection,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let notecount_records =
|
let notecount_records = get_notecount_records().context("Failed to read notecount records")?;
|
||||||
get_notecount_records(paths).context("Failed to read notecount records")?;
|
|
||||||
let ptt_entries = get_ptt_entries(paths).context("Failed to read ptt entries")?;
|
let ptt_entries = get_ptt_entries(paths).context("Failed to read ptt entries")?;
|
||||||
|
|
||||||
let transaction = conn.transaction()?;
|
let transaction = conn.transaction()?;
|
||||||
|
|
|
@ -45,12 +45,7 @@ pub static UNI_FONT: RefCell<Font> = get_font!("unifont.otf");
|
||||||
// {{{ Asset art helpers
|
// {{{ Asset art helpers
|
||||||
macro_rules! get_asset {
|
macro_rules! get_asset {
|
||||||
($name: ident, $file:expr) => {
|
($name: ident, $file:expr) => {
|
||||||
get_asset!(
|
get_asset!($name, $file, "assets", |d: DynamicImage| d);
|
||||||
$name,
|
|
||||||
$file,
|
|
||||||
concat!(env!("SHIMMERING_SOURCE_DIR"), "/assets"),
|
|
||||||
|d: DynamicImage| d
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
($name: ident, $file:expr, $dir: expr, $f:expr) => {
|
($name: ident, $file:expr, $dir: expr, $f:expr) => {
|
||||||
pub static $name: LazyLock<RgbaImage> = LazyLock::new(move || {
|
pub static $name: LazyLock<RgbaImage> = LazyLock::new(move || {
|
||||||
|
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 752 B After Width: | Height: | Size: 752 B |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 5 KiB After Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
@ -150,7 +150,7 @@ async fn friend_code_impl<C: MessageContext>(
|
||||||
ctx: &mut C,
|
ctx: &mut C,
|
||||||
target_user: poise::serenity_prelude::User,
|
target_user: poise::serenity_prelude::User,
|
||||||
) -> Result<(), TaggedError> {
|
) -> Result<(), TaggedError> {
|
||||||
let user = User::from_context(ctx)?;
|
User::from_context(ctx)?;
|
||||||
|
|
||||||
let target = User::by_discord_id(ctx.data(), target_user.id)?;
|
let target = User::by_discord_id(ctx.data(), target_user.id)?;
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ use r2d2_sqlite::SqliteConnectionManager;
|
||||||
use rusqlite_migration::Migrations;
|
use rusqlite_migration::Migrations;
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use crate::arcaea::import_charts::import_songlist;
|
use crate::arcaea::import_charts::{import_songlist, NOTECOUNT_DATA};
|
||||||
use crate::context::hash::hash_files;
|
use crate::context::hash::{hash_bytes, hash_files};
|
||||||
use crate::context::paths::ShimmeringPaths;
|
use crate::context::paths::ShimmeringPaths;
|
||||||
use crate::context::process_jackets::process_jackets;
|
use crate::context::process_jackets::process_jackets;
|
||||||
// }}}
|
// }}}
|
||||||
|
@ -35,7 +35,7 @@ pub fn connect_db(paths: &ShimmeringPaths) -> anyhow::Result<SqlitePool> {
|
||||||
let current_raw_jackets_hash = hash_files(&paths.raw_jackets_path())?;
|
let current_raw_jackets_hash = hash_files(&paths.raw_jackets_path())?;
|
||||||
let current_songlist_hash = hash_files(&paths.songlist_path())?;
|
let current_songlist_hash = hash_files(&paths.songlist_path())?;
|
||||||
let current_cc_data_hash = hash_files(&paths.cc_data_path())?;
|
let current_cc_data_hash = hash_files(&paths.cc_data_path())?;
|
||||||
let current_notecount_hash = hash_files(&paths.notecount_path())?;
|
let current_notecount_hash = hash_bytes(NOTECOUNT_DATA);
|
||||||
|
|
||||||
let (prev_raw_jackets_hash, prev_songlist_hash, prev_cc_data_hash, prev_notecount_hash) = conn
|
let (prev_raw_jackets_hash, prev_songlist_hash, prev_cc_data_hash, prev_notecount_hash) = conn
|
||||||
.query_row("SELECT * FROM metadata", (), |row| {
|
.query_row("SELECT * FROM metadata", (), |row| {
|
||||||
|
|
|
@ -22,3 +22,11 @@ pub fn hash_files(path: &std::path::Path) -> anyhow::Result<String> {
|
||||||
let string = base16ct::lower::encode_string(&res);
|
let string = base16ct::lower::encode_string(&res);
|
||||||
Ok(string)
|
Ok(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn hash_bytes(bytes: &[u8]) -> String {
|
||||||
|
let mut hasher = Sha256::default();
|
||||||
|
hasher.update(bytes);
|
||||||
|
let res = hasher.finalize();
|
||||||
|
let string = base16ct::lower::encode_string(&res);
|
||||||
|
string
|
||||||
|
}
|
||||||
|
|
|
@ -39,9 +39,6 @@ pub struct ShimmeringPaths {
|
||||||
|
|
||||||
/// This directory contains logs and other debugging info.
|
/// This directory contains logs and other debugging info.
|
||||||
log_dir: PathBuf,
|
log_dir: PathBuf,
|
||||||
|
|
||||||
/// This location the source-code resides at
|
|
||||||
source_dir: PathBuf,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShimmeringPaths {
|
impl ShimmeringPaths {
|
||||||
|
@ -52,7 +49,6 @@ impl ShimmeringPaths {
|
||||||
data_dir: get_env_dir_path("SHIMMERING_DATA_DIR", Some("STATE_DIRECTORY"))?,
|
data_dir: get_env_dir_path("SHIMMERING_DATA_DIR", Some("STATE_DIRECTORY"))?,
|
||||||
log_dir: get_env_dir_path("SHIMMERING_LOG_DIR", Some("LOGS_DIRECTORY"))?,
|
log_dir: get_env_dir_path("SHIMMERING_LOG_DIR", Some("LOGS_DIRECTORY"))?,
|
||||||
private_config_dir: get_env_dir_path("SHIMMERING_PRIVATE_CONFIG_DIR", None)?,
|
private_config_dir: get_env_dir_path("SHIMMERING_PRIVATE_CONFIG_DIR", None)?,
|
||||||
source_dir: PathBuf::from_str(env!("SHIMMERING_SOURCE_DIR")).unwrap(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
|
@ -86,18 +82,6 @@ impl ShimmeringPaths {
|
||||||
self.private_config_dir.join("songlist.json")
|
self.private_config_dir.join("songlist.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scripts_dir(&self) -> PathBuf {
|
|
||||||
self.source_dir.join("scripts")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn config_dir(&self) -> PathBuf {
|
|
||||||
self.source_dir.join("config")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn notecount_path(&self) -> PathBuf {
|
|
||||||
self.config_dir().join("notecounts.csv")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cc_data_path(&self) -> PathBuf {
|
pub fn cc_data_path(&self) -> PathBuf {
|
||||||
PathBuf::from_str(concat!(env!("SHIMMERING_CC_DIR"), "/ptt.json")).unwrap()
|
PathBuf::from_str(concat!(env!("SHIMMERING_CC_DIR"), "/ptt.json")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn should_save_debug_images() -> bool {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_log_dir() -> PathBuf {
|
fn get_log_dir() -> PathBuf {
|
||||||
get_env_dir_path("SHIMMERING_LOG_DIR", "LOGS_DIRECTORY").unwrap()
|
get_env_dir_path("SHIMMERING_LOG_DIR", Some("LOGS_DIRECTORY")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -100,8 +100,7 @@ impl UIMeasurements {
|
||||||
let mut measurements = Vec::new();
|
let mut measurements = Vec::new();
|
||||||
let mut measurement = UIMeasurement::default();
|
let mut measurement = UIMeasurement::default();
|
||||||
|
|
||||||
const CONTENTS: &str =
|
const CONTENTS: &str = include_str!("ui.txt");
|
||||||
include_str!(concat!(env!("SHIMMERING_SOURCE_DIR"), "/config/ui.txt"));
|
|
||||||
|
|
||||||
// {{{ Parse measurement file
|
// {{{ Parse measurement file
|
||||||
for (i, line) in CONTENTS.split('\n').enumerate() {
|
for (i, line) in CONTENTS.split('\n').enumerate() {
|
||||||
|
|