aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate/program.nix
blob: 06cfa078fe7dd5a9235185c61752e6915f9ad7c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# The program delivering sources, built from the crate in this directory.
{ rustPlatform }:

let
  cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in

rustPlatform.buildRustPackage {
  pname = cargoToml.package.name;
  inherit (cargoToml.package) version;
  # Only what cargo builds from, so changes to the Nix files or the docs
  # don't rebuild the program.
  src = builtins.path {
    name = "populate-src";
    path = ./.;
    filter = path: type: let
      relative = builtins.substring
        (builtins.stringLength (toString ./.) + 1) (-1) (toString path);
    in
      builtins.elem relative [ "Cargo.toml" "Cargo.lock" "src" ] ||
      builtins.substring 0 4 relative == "src/";
  };
  cargoLock.lockFile = ./Cargo.lock;
}