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 = ''
mkdir -p $out/bin
ln -s ${tron}/bin/tron $out/bin/tron
ln -s ${./regexes.dhall} $out/regexes.dhall
cp ${tron}/bin/tron $out/bin/tron
cp ${./regexes.dhall} $out/regexes.dhall
'';
}

View File

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

View File

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

View File

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

View File

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