diff --git a/flake.nix b/flake.nix index 9dd3aa8..0a56a7d 100644 --- a/flake.nix +++ b/flake.nix @@ -24,7 +24,7 @@ in (eachDefaultSystem (system: let overlays = [ (import rust-overlay) - (import ./overlay.nix) + (import ./nix/overlay.nix) ]; pkgs = (import nixpkgs) { inherit system overlays; @@ -156,7 +156,7 @@ }; }) // { - overlays.default = import ./overlay.nix; + overlays.default = import ./nix/overlay.nix; hydraJobs = eachSystem ["x86_64-linux" "aarch64-linux"] (system: { parser = self.packages.${system}.demostf-parser; }); diff --git a/codegen.nix b/nix/codegen.nix similarity index 60% rename from codegen.nix rename to nix/codegen.nix index 81562e9..ef3d41f 100644 --- a/codegen.nix +++ b/nix/codegen.nix @@ -4,12 +4,16 @@ lib, }: let inherit (lib.sources) sourceByRegex; - src = sourceByRegex ./. ["Cargo.*" "(src|benches)(/.*)?"]; + src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"]; in rustPlatform.buildRustPackage { pname = "demostf-parser-codegen"; version = "0.1.0"; + cargoBuildFlags = '' + --bin codegen + ''; + src = lib.traceVal src; buildType = "debug"; @@ -18,9 +22,6 @@ in doCheck = false; cargoLock = { - lockFile = ./Cargo.lock; - outputHashes = { - "schemars-0.8.16" = "sha256-mQR56Ym76gSRulZrThmZHHw2JfhEgYhWXabwaYmyMYs="; - }; + lockFile = ../Cargo.lock; }; } diff --git a/overlay.nix b/nix/overlay.nix similarity index 66% rename from overlay.nix rename to nix/overlay.nix index 915c97a..750be5d 100644 --- a/overlay.nix +++ b/nix/overlay.nix @@ -2,11 +2,11 @@ final: prev: { demostf-parser = final.callPackage ./parser.nix {}; demostf-parser-codegen = final.callPackage ./codegen.nix {}; demostf-parser-codegen-events = final.runCommand "gameevent_gen.rs" {} '' - ${final.demostf-parser-codegen}/bin/codegen ${./test_data/short-2024.dem} events > $out + ${final.demostf-parser-codegen}/bin/codegen ${../test_data/short-2024.dem} events > $out ${final.rustfmt}/bin/rustfmt $out ''; demostf-parser-codegen-props = final.runCommand "sendprop_gen.rs" {} '' - ${final.demostf-parser-codegen}/bin/codegen ${./test_data/short-2024.dem} props > $out + ${final.demostf-parser-codegen}/bin/codegen ${../test_data/short-2024.dem} props > $out ${final.rustfmt}/bin/rustfmt $out ''; } diff --git a/parser.nix b/nix/parser.nix similarity index 63% rename from parser.nix rename to nix/parser.nix index fbe910d..752c6d9 100644 --- a/parser.nix +++ b/nix/parser.nix @@ -4,7 +4,7 @@ lib, }: let inherit (lib.sources) sourceByRegex; - src = sourceByRegex ./. ["Cargo.*" "(src|benches|tests|test_data)(/.*)?"]; + src = sourceByRegex ../. ["Cargo.*" "(src|benches|tests|test_data)(/.*)?"]; in rustPlatform.buildRustPackage rec { pname = "demostf-parser"; @@ -19,9 +19,6 @@ in doCheck = stdenv.system == "x86_64-linux"; # building the tests takes +- forever on aarch64 for some reason cargoLock = { - lockFile = ./Cargo.lock; - outputHashes = { - "schemars-0.8.16" = "sha256-mQR56Ym76gSRulZrThmZHHw2JfhEgYhWXabwaYmyMYs="; - }; + lockFile = ../Cargo.lock; }; } diff --git a/nix/schema.nix b/nix/schema.nix new file mode 100644 index 0000000..6ee6834 --- /dev/null +++ b/nix/schema.nix @@ -0,0 +1,27 @@ +{ + stdenv, + rustPlatform, + lib, +}: let + inherit (lib.sources) sourceByRegex; + src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"]; +in + rustPlatform.buildRustPackage { + pname = "demostf-parser-schema"; + version = "0.1.0"; + + cargoBuildFlags = '' + --bin schema + ''; + + src = lib.traceVal src; + + buildType = "debug"; + buildFeatures = ["schema"]; + + doCheck = false; + + cargoLock = { + lockFile = ../Cargo.lock; + }; + }