package up the regexes better

This commit is contained in:
Cadey Ratio 2020-07-03 21:33:06 -04:00
parent 2a1d80d820
commit 18d6842f95
5 changed files with 10 additions and 9 deletions

View File

@ -18,7 +18,7 @@ in pkgs.stdenv.mkDerivation {
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
ln -s ${tron}/bin/tron $out/bin/tron cp ${tron}/bin/tron $out/bin/tron
ln -s ${./regexes.dhall} $out/regexes.dhall cp ${./regexes.dhall} $out/regexes.dhall
''; '';
} }

View File

@ -9,12 +9,13 @@ let
dockerImage = pkg: dockerImage = pkg:
pkgs.dockerTools.buildLayeredImage { pkgs.dockerTools.buildLayeredImage {
name = "xena/tron"; name = "xena/tron";
tag = pkg.version; tag = tron.version;
contents = [ pkgs.cacert pkg ]; contents = [ pkgs.cacert ];
config = { config = {
Cmd = [ "/bin/tron" ]; Cmd = [ "${tron}/bin/tron" ];
Env = [ "REGEXES=${tron}/regexes.dhall" ];
WorkingDir = "/"; WorkingDir = "/";
}; };
}; };

View File

@ -3,6 +3,4 @@ let Rule =
, default = { regex = "", why = "" } , default = { regex = "", why = "" }
} }
in [ Rule::{ regex = "(n|z)igg(er|a)", why = "racism" } in [ Rule::{ regex = "(n|z)igg(er|a)", why = "racism" } ]
, Rule::{ regex = "(hot|cute)", why = "Cadey is testing" }
]

View File

@ -9,6 +9,7 @@ pkgs.mkShell {
rustc rustc
rustfmt rustfmt
# dhall
dhall.dhall-simple dhall.dhall-simple
# system # system

View File

@ -99,9 +99,10 @@ impl FirehoseAdaptor for Rules {
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
kankyo::init()?; let _ = kankyo::init();
pretty_env_logger::init(); pretty_env_logger::init();
let cfg: Config = envy::from_env()?; let cfg: Config = envy::from_env()?;
log::debug!("cfg: {:?}", cfg);
let rexes: Vec<Rule> = serde_dhall::from_file(cfg.regexes.clone()).parse()?; let rexes: Vec<Rule> = serde_dhall::from_file(cfg.regexes.clone()).parse()?;
let mut compiled_rules: Vec<CompiledRule> = Vec::new(); let mut compiled_rules: Vec<CompiledRule> = Vec::new();