forked from nix-community/crate2nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
77 lines (77 loc) · 2.41 KB
/
default.nix
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{ sources ? import ./nix/sources.nix
, nixpkgs ? sources.nixpkgs
, pkgs ? import nixpkgs { config = { }; }
, lib ? pkgs.lib
, cargo ? pkgs.cargo
, nix ? pkgs.nix
, makeWrapper ? pkgs.makeWrapper
, callPackage ? pkgs.callPackage
, darwin ? pkgs.darwin
, stdenv ? pkgs.stdenv
, defaultCrateOverrides ? pkgs.defaultCrateOverrides
, release ? true
}:
let
cargoNix = callPackage ./crate2nix/Cargo.nix { inherit release; };
withoutTemplates = name: type:
let
baseName = builtins.baseNameOf (builtins.toString name);
in
!(baseName == "templates" && type == "directory");
crate2nix = cargoNix.rootCrate.build.override {
testCrateFlags = [
"--skip nix_integration_tests"
];
crateOverrides = defaultCrateOverrides // {
crate2nix = { src, ... }: {
src =
if release
then src
else
lib.cleanSourceWith {
filter = withoutTemplates;
inherit src;
};
dontFixup = !release;
};
cssparser-macros = attrs: assert builtins.trace "cssparser" true;{
buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
};
};
};
set_templates = if release then "" else "--set TEMPLATES_DIR ${./crate2nix/templates}";
in
pkgs.symlinkJoin {
name = crate2nix.name;
paths = [ crate2nix ];
buildInputs = [ makeWrapper cargo ];
meta = {
description = "Nix build file generator for rust crates.";
longDescription = ''
Crate2nix generates nix files from Cargo.toml/lock files
so that you can build every crate individually in a nix sandbox.
'';
homepage = https://github.com/kolloch/crate2nix;
license = lib.licenses.asl20;
maintainers = [
{
github = "kolloch";
githubId = 339354;
name = "Peter Kolloch";
}
lib.maintainers.andir
];
platforms = lib.platforms.all;
};
postBuild = ''
# Fallback to built dependencies for cargo and nix-prefetch-url
wrapProgram $out/bin/crate2nix ${set_templates}\
--suffix PATH ":" ${lib.makeBinPath [ cargo nix pkgs.nix-prefetch-git ]}
rm -rf $out/lib $out/bin/crate2nix.d
mkdir -p \
$out/share/bash-completion/completions \
$out/share/zsh/vendor-completions
$out/bin/crate2nix completions -s 'bash' -o $out/share/bash-completion/completions
$out/bin/crate2nix completions -s 'zsh' -o $out/share/zsh/vendor-completions
'';
}