Add build command argument

This commit is contained in:
Elnu 2025-03-26 14:55:39 -07:00
parent d3f2d25a0f
commit a589bcb799
4 changed files with 13 additions and 2 deletions

View file

@ -3,4 +3,5 @@ DISCORD_TOKEN=
PREFIX="-h "
HUGO=/path/to/hugo
GUILD_DATA=/path/to/guilds.json
BUILD=hugo
LEADERBOARD=/path/to/leaderboard.html

View file

@ -98,6 +98,13 @@ Some utility commands:
Path to Hugo project where site rebuilds
'';
};
build = lib.mkOption {
type = lib.types.str;
default = "${pkgs.hugo}";
description = lib.mdDoc ''
Build command
'';
};
guildData = lib.mkOption {
type = lib.types.package;
description = lib.mdDoc ''
@ -113,7 +120,7 @@ Some utility commands:
after = [ "network.target" ];
wantedBy = [ "network.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/ji-chan --domain ${cfg.domain} --token ${cfg.token} --prefix \"${builtins.replaceStrings ["\""] ["\\\""] cfg.prefix}\" --hugo ${cfg.hugo} --guilds ${cfg.guildData}";
ExecStart = "${cfg.package}/bin/ji-chan --domain ${cfg.domain} --token ${cfg.token} --prefix \"${builtins.replaceStrings ["\""] ["\\\""] cfg.prefix}\" --hugo ${cfg.hugo} --build \"${builtins.replaceStrings ["\""] ["\\\""] cfg.build}\" --guilds ${cfg.guildData}";
Restart = "always";
User = cfg.user;
DynamicUser = true;

View file

@ -33,6 +33,8 @@ struct Arguments {
pub prefix: String,
#[clap(long, help = "Path to Hugo project where site rebuilds")]
pub hugo: String,
#[clap(long, help = "Build command", default_value = "hugo")]
pub build: String,
#[clap(long = "guilds", help = "Path to guild data JSON file", default_value = "guilds.json")]
pub guild_data: String,
}
@ -44,6 +46,7 @@ impl Arguments {
discord_token: env::var("DISCORD_TOKEN")?,
prefix: env::var("PREFIX")?,
hugo: env::var("HUGO")?.into(),
build: env::var("BUILD")?,
guild_data: env::var("GUILD_DATA")?.into(),
})
}

View file

@ -145,7 +145,7 @@ pub fn to_fullwidth(string: &str) -> String {
}
pub fn rebuild_site() {
Command::new("./build.sh")
Command::new(&ARGS.build)
.current_dir(&ARGS.hugo)
.status()
.expect("Failed to rebuild site");