Allow specifying the default source
This commit is contained in:
		
					parent
					
						
							
								2670e35fdd
							
						
					
				
			
			
				commit
				
					
						9b13eaf23d
					
				
			
		
					 9 changed files with 909 additions and 607 deletions
				
			
		
							
								
								
									
										1419
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										1419
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										54
									
								
								flake.nix
									
										
									
									
									
								
							
							
						
						
									
										54
									
								
								flake.nix
									
										
									
									
									
								
							|  | @ -9,47 +9,21 @@ | ||||||
| 
 | 
 | ||||||
|   outputs = |   outputs = | ||||||
|     inputs: |     inputs: | ||||||
|     inputs.flake-utils.lib.eachSystem (with inputs.flake-utils.lib.system; [ x86_64-linux ]) ( |     { | ||||||
|  |       overlays.default = (import ./nix/overlay.nix { inherit inputs; }); | ||||||
|  |     } | ||||||
|  |     // inputs.flake-utils.lib.eachSystem (with inputs.flake-utils.lib.system; [ x86_64-linux ]) ( | ||||||
|       system: |       system: | ||||||
|       let |       let | ||||||
|         pkgs = inputs.nixpkgs.legacyPackages.${system}; |         pkgs = import inputs.nixpkgs { | ||||||
|         spkgs = inputs.self.packages.${system}; |           inherit system; | ||||||
|         inherit (pkgs) lib; |           overlays = [ inputs.self.overlays.default ]; | ||||||
|  |         }; | ||||||
|       in |       in | ||||||
|       { |       { | ||||||
|         packages = { |         packages = { | ||||||
|           # {{{ Private config |           inherit (pkgs) shimmeringmoon; | ||||||
|           shimmeringdarkness = inputs.shimmeringdarkness.outPath; |           default = pkgs.shimmeringmoon; | ||||||
|           glass-bundler = pkgs.callPackage ./nix/glass-bundler.nix { }; |  | ||||||
|           debundled-darkness = pkgs.callPackage ./nix/debundled-darkness.nix { |  | ||||||
|             inherit (spkgs) shimmeringdarkness glass-bundler; |  | ||||||
|           }; |  | ||||||
| 
 |  | ||||||
|           private-config = pkgs.callPackage ./nix/private-config.nix { |  | ||||||
|             inherit (spkgs) shimmeringdarkness debundled-darkness; |  | ||||||
|           }; |  | ||||||
|           # }}} |  | ||||||
|           # {{{ Fonts |  | ||||||
|           kazesawa = pkgs.callPackage ./nix/kazesawa.nix { }; |  | ||||||
|           exo = pkgs.callPackage ./nix/exo.nix { }; |  | ||||||
|           geosans-light = pkgs.callPackage ./nix/geosans-light.nix { }; |  | ||||||
| 
 |  | ||||||
|           shimmering-fonts = pkgs.callPackage ./nix/fonts.nix { |  | ||||||
|             # Pass custom-packaged fonts |  | ||||||
|             inherit (spkgs) exo kazesawa geosans-light; |  | ||||||
|           }; |  | ||||||
|           # }}} |  | ||||||
|           # {{{ Shimmeringmoon |  | ||||||
|           cc-data = pkgs.callPackage ./nix/cc-data.nix { }; |  | ||||||
|           default = spkgs.shimmeringmoon; |  | ||||||
|           shimmeringmoon = pkgs.callPackage ./nix/shimmeringmoon.nix { |  | ||||||
|             inherit (spkgs) |  | ||||||
|               shimmering-fonts |  | ||||||
|               cc-data |  | ||||||
|               private-config |  | ||||||
|               ; |  | ||||||
|           }; |  | ||||||
|           # }}} |  | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         #  {{{ Devshell |         #  {{{ Devshell | ||||||
|  | @ -74,10 +48,10 @@ | ||||||
|             openssl |             openssl | ||||||
|           ]; |           ]; | ||||||
| 
 | 
 | ||||||
|           LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs; |           LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; | ||||||
|           SHIMMERING_FONT_DIR = spkgs.shimmering-fonts; |           SHIMMERING_FONT_DIR = pkgs.shimmering-fonts; | ||||||
|           SHIMMERING_CC_DIR = spkgs.cc-data; |           SHIMMERING_CC_DIR = pkgs.cc-data; | ||||||
|           SHIMMERING_PRIVATE_CONFIG_DIR = spkgs.private-config; |           SHIMMERING_PRIVATE_CONFIG_DIR = pkgs.private-config; | ||||||
|         }; |         }; | ||||||
|         #  }}} |         #  }}} | ||||||
|       } |       } | ||||||
|  |  | ||||||
							
								
								
									
										15
									
								
								nix/overlay.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								nix/overlay.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | { inputs }: | ||||||
|  | final: prev: { | ||||||
|  |   shimmeringdarkness = inputs.shimmeringdarkness.outPath; | ||||||
|  |   glass-bundler = final.callPackage ./glass-bundler.nix { }; | ||||||
|  |   debundled-darkness = final.callPackage ./debundled-darkness.nix { }; | ||||||
|  |   private-config = final.callPackage ./private-config.nix { }; | ||||||
|  | 
 | ||||||
|  |   kazesawa = final.callPackage ./kazesawa.nix { }; | ||||||
|  |   exo = final.callPackage ./exo.nix { }; | ||||||
|  |   geosans-light = final.callPackage ./geosans-light.nix { }; | ||||||
|  |   shimmering-fonts = final.callPackage ./fonts.nix { }; | ||||||
|  | 
 | ||||||
|  |   arcaea-ptt-data = final.callPackage ./cc-data.nix { }; | ||||||
|  |   shimmeringmoon = final.callPackage ./shimmeringmoon.nix { }; | ||||||
|  | } | ||||||
|  | @ -10,7 +10,7 @@ | ||||||
|   rustPlatform, |   rustPlatform, | ||||||
| 
 | 
 | ||||||
|   shimmering-fonts, |   shimmering-fonts, | ||||||
|   cc-data, |   arcaea-ptt-data, | ||||||
|   private-config, |   private-config, | ||||||
| }: | }: | ||||||
| rustPlatform.buildRustPackage rec { | rustPlatform.buildRustPackage rec { | ||||||
|  | @ -27,7 +27,7 @@ rustPlatform.buildRustPackage rec { | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   SHIMMERING_FONT_DIR = shimmering-fonts; |   SHIMMERING_FONT_DIR = shimmering-fonts; | ||||||
|   SHIMMERING_CC_DIR = cc-data; |   SHIMMERING_CC_DIR = arcaea-ptt-data; | ||||||
|   SHIMMERING_PRIVATE_CONFIG_DIR = private-config; |   SHIMMERING_PRIVATE_CONFIG_DIR = private-config; | ||||||
| 
 | 
 | ||||||
|   nativeBuildInputs = [ |   nativeBuildInputs = [ | ||||||
|  | @ -58,7 +58,7 @@ rustPlatform.buildRustPackage rec { | ||||||
|   postFixup = '' |   postFixup = '' | ||||||
|     for file in $out/bin/*; do |     for file in $out/bin/*; do | ||||||
|       wrapProgram $file \ |       wrapProgram $file \ | ||||||
|         --set SHIMMERING_CC_DIR "${cc-data}" \ |         --set SHIMMERING_CC_DIR "${arcaea-ptt-data}" \ | ||||||
|         --set SHIMMERING_PRIVATE_CONFIG_DIR ${private-config} |         --set SHIMMERING_PRIVATE_CONFIG_DIR ${private-config} | ||||||
|     done |     done | ||||||
|   ''; |   ''; | ||||||
|  |  | ||||||
|  | @ -289,6 +289,7 @@ async fn best( | ||||||
| 	#[description = "Name of chart (difficulty at the end)"] | 	#[description = "Name of chart (difficulty at the end)"] | ||||||
| 	name: String, | 	name: String, | ||||||
| ) -> Result<(), Error> { | ) -> Result<(), Error> { | ||||||
|  | 	ctx.defer().await?; | ||||||
| 	let res = best_impl(&mut ctx, &name, source.unwrap_or(DataSource::Local)).await; | 	let res = best_impl(&mut ctx, &name, source.unwrap_or(DataSource::Local)).await; | ||||||
| 	ctx.handle_error(res).await?; | 	ctx.handle_error(res).await?; | ||||||
| 
 | 
 | ||||||
|  | @ -441,6 +442,7 @@ async fn plot( | ||||||
| 	#[description = "Name of chart (difficulty at the end)"] | 	#[description = "Name of chart (difficulty at the end)"] | ||||||
| 	name: String, | 	name: String, | ||||||
| ) -> Result<(), Error> { | ) -> Result<(), Error> { | ||||||
|  | 	ctx.defer().await?; | ||||||
| 	let res = plot_impl(&mut ctx, scoring_system, name).await; | 	let res = plot_impl(&mut ctx, scoring_system, name).await; | ||||||
| 	ctx.handle_error(res).await?; | 	ctx.handle_error(res).await?; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,13 +8,22 @@ pub mod stats; | ||||||
| pub mod user; | pub mod user; | ||||||
| pub mod utils; | pub mod utils; | ||||||
| 
 | 
 | ||||||
| #[derive(Clone, Copy, Default, poise::ChoiceParameter)] | #[derive(Clone, Copy, poise::ChoiceParameter)] | ||||||
| pub enum DataSource { | pub enum DataSource { | ||||||
| 	#[default] |  | ||||||
| 	Local, | 	Local, | ||||||
| 	Server, | 	Server, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Default for DataSource { | ||||||
|  | 	fn default() -> Self { | ||||||
|  | 		if std::env::var("SHIMMERING_DEFAULT_SOURCE").unwrap_or_default() == "server" { | ||||||
|  | 			Self::Server | ||||||
|  | 		} else { | ||||||
|  | 			Self::Local | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // {{{ Help
 | // {{{ Help
 | ||||||
| /// Show this help menu
 | /// Show this help menu
 | ||||||
| #[poise::command(prefix_command, slash_command, subcommands("scoring", "scoringz"))] | #[poise::command(prefix_command, slash_command, subcommands("scoring", "scoringz"))] | ||||||
|  |  | ||||||
|  | @ -221,6 +221,7 @@ pub async fn magic( | ||||||
| 	mut ctx: PoiseContext<'_>, | 	mut ctx: PoiseContext<'_>, | ||||||
| 	#[description = "Images containing scores"] files: Vec<serenity::Attachment>, | 	#[description = "Images containing scores"] files: Vec<serenity::Attachment>, | ||||||
| ) -> Result<(), Error> { | ) -> Result<(), Error> { | ||||||
|  | 	ctx.defer().await?; | ||||||
| 	let res = magic_impl(&mut ctx, &files).await; | 	let res = magic_impl(&mut ctx, &files).await; | ||||||
| 	ctx.handle_error(res).await?; | 	ctx.handle_error(res).await?; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -441,12 +441,13 @@ pub async fn b30_impl<C: MessageContext>( | ||||||
| // }}}
 | // }}}
 | ||||||
| // {{{ Discord wrapper
 | // {{{ Discord wrapper
 | ||||||
| /// Show the 30 best scores
 | /// Show the 30 best scores
 | ||||||
| #[poise::command(prefix_command, slash_command, user_cooldown = 30)] | #[poise::command(prefix_command, slash_command, user_cooldown = 10)] | ||||||
| pub async fn b30( | pub async fn b30( | ||||||
| 	mut ctx: PoiseContext<'_>, | 	mut ctx: PoiseContext<'_>, | ||||||
| 	source: Option<DataSource>, | 	source: Option<DataSource>, | ||||||
| 	scoring_system: Option<ScoringSystem>, | 	scoring_system: Option<ScoringSystem>, | ||||||
| ) -> Result<(), Error> { | ) -> Result<(), Error> { | ||||||
|  | 	ctx.defer().await?; | ||||||
| 	let res = b30_impl(&mut ctx, source, scoring_system).await; | 	let res = b30_impl(&mut ctx, source, scoring_system).await; | ||||||
| 	ctx.handle_error(res).await?; | 	ctx.handle_error(res).await?; | ||||||
| 	Ok(()) | 	Ok(()) | ||||||
|  | @ -486,6 +487,7 @@ pub async fn bany( | ||||||
| 	width: u32, | 	width: u32, | ||||||
| 	height: u32, | 	height: u32, | ||||||
| ) -> Result<(), Error> { | ) -> Result<(), Error> { | ||||||
|  | 	ctx.defer().await?; | ||||||
| 	let res = bany_impl(&mut ctx, source, scoring_system, width, height).await; | 	let res = bany_impl(&mut ctx, source, scoring_system, width, height).await; | ||||||
| 	ctx.handle_error(res).await?; | 	ctx.handle_error(res).await?; | ||||||
| 	Ok(()) | 	Ok(()) | ||||||
|  |  | ||||||
|  | @ -61,6 +61,7 @@ async fn register( | ||||||
| 	mut ctx: PoiseContext<'_>, | 	mut ctx: PoiseContext<'_>, | ||||||
| 	user: poise::serenity_prelude::User, | 	user: poise::serenity_prelude::User, | ||||||
| ) -> Result<(), Error> { | ) -> Result<(), Error> { | ||||||
|  |     ctx.defer().await?; | ||||||
| 	let res = register_impl(&mut ctx, user).await; | 	let res = register_impl(&mut ctx, user).await; | ||||||
| 	ctx.handle_error(res).await?; | 	ctx.handle_error(res).await?; | ||||||
| 	Ok(()) | 	Ok(()) | ||||||
|  | @ -103,6 +104,7 @@ pub async fn pookify( | ||||||
| 	mut ctx: PoiseContext<'_>, | 	mut ctx: PoiseContext<'_>, | ||||||
| 	user: poise::serenity_prelude::User, | 	user: poise::serenity_prelude::User, | ||||||
| ) -> Result<(), Error> { | ) -> Result<(), Error> { | ||||||
|  |     ctx.defer().await?; | ||||||
| 	let res = pookify_impl(&mut ctx, user).await; | 	let res = pookify_impl(&mut ctx, user).await; | ||||||
| 	ctx.handle_error(res).await?; | 	ctx.handle_error(res).await?; | ||||||
| 	Ok(()) | 	Ok(()) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue