Skip to content

Commit

Permalink
move nix
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed May 6, 2024
1 parent c2985d1 commit 4e6d6e4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
});
Expand Down
11 changes: 6 additions & 5 deletions codegen.nix → nix/codegen.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -18,9 +22,6 @@ in
doCheck = false;

cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"schemars-0.8.16" = "sha256-mQR56Ym76gSRulZrThmZHHw2JfhEgYhWXabwaYmyMYs=";
};
lockFile = ../Cargo.lock;
};
}
4 changes: 2 additions & 2 deletions overlay.nix → nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
}
7 changes: 2 additions & 5 deletions parser.nix → nix/parser.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
};
}
27 changes: 27 additions & 0 deletions nix/schema.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}

0 comments on commit 4e6d6e4

Please sign in to comment.