aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate/default.nix
blob: 0c98b284392028a081eecba818f7af0b499afce5 (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
25
26
27
28
# populate, built from the crate in this directory: nix-build here, or
# callPackage.
{ rustPlatform ? (import <nixpkgs> {}).rustPlatform }:

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

rustPlatform.buildRustPackage {
  pname = cargoToml.package.name;
  inherit (cargoToml.package) version;
  # Without what cargo doesn't build from, so changes to the Nix files, the
  # docs, or the tests don't rebuild the program.  By names, not by paths
  # relative to this directory: the paths the filter gets needn't start
  # with toString ./., e.g. if a symlink leads to this directory.
  src = builtins.path {
    name = "populate-src";
    path = ./.;
    filter = path: type: let
      name = baseNameOf path;
    in
      !(builtins.elem name [
        ".gitignore" "README.md" "docs" "lib" "target" "tests"
      ] ||
        builtins.match ".*\\.nix" name != null);
  };
  cargoLock.lockFile = ./Cargo.lock;
}