Skip to content

Commit

Permalink
Merge pull request #3 from juspay/mono-repo
Browse files Browse the repository at this point in the history
Move Rust project to a sub directory
  • Loading branch information
srid authored May 29, 2023
2 parents 5b2136a + 08cd1b8 commit f3915c1
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 36 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
result
.direnv


# Added by cargo

/target
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Added by cargo
/target
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions backend/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
perSystem = { self', pkgs, lib, ... }:
let
src = lib.sourceFilesBySuffices ./. [ ".rs" ".toml" "Cargo.lock" ];
inherit (lib.importTOML (src + "/Cargo.toml")) package;
in
{
packages = {
${package.name} = pkgs.rustPlatform.buildRustPackage {
pname = package.name;
inherit (package) version;
inherit src;
cargoLock.lockFile = (src + "/Cargo.lock");
};
default = self'.packages.${package.name};
};

devShells.backend = pkgs.mkShell {
inherit (package) name;
inputsFrom = [ self'.packages.${package.name} ];
packages = with pkgs; [
rust-analyzer
nil
];
};
};
}
File renamed without changes.
47 changes: 16 additions & 31 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,24 @@
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [ inputs.treefmt-nix.flakeModule ];
imports = [
inputs.treefmt-nix.flakeModule
./backend
];

perSystem = { self', pkgs, lib, ... }:
let
src = lib.sourceFilesBySuffices inputs.self [ ".rs" ".toml" "Cargo.lock" ];
inherit (lib.importTOML (src + "/Cargo.toml")) package;
in
{
packages = {
${package.name} = pkgs.rustPlatform.buildRustPackage {
pname = package.name;
inherit (package) version;
inherit src;
cargoLock.lockFile = (src + "/Cargo.lock");
};
default = self'.packages.${package.name};
};

devShells.default = pkgs.mkShell {
inherit (package) name;
inputsFrom = [ self'.packages.${package.name} ];
packages = with pkgs; [
rust-analyzer
nil
];
};
perSystem = { self', pkgs, lib, ... }: {
devShells.default = pkgs.mkShell {
inputsFrom = [
self'.devShells.backend
];
};

# Run `nix fmt` to format the source tree.
treefmt = {
projectRootFile = "flake.nix";
programs.nixpkgs-fmt.enable = true;
programs.rustfmt.enable = true;
};
# Run `nix fmt` to format the source tree.
treefmt = {
projectRootFile = "flake.nix";
programs.nixpkgs-fmt.enable = true;
programs.rustfmt.enable = true;
};
};
};
}

0 comments on commit f3915c1

Please sign in to comment.