-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
117 lines (106 loc) · 3.34 KB
/
flake.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
description = "txp";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
rust-overlay,
}: let
emptyOverlay = final: prev: {};
txp-drv = pkgs:
pkgs.rustPlatform.buildRustPackage {
pname = "txp";
version = "v0.1.0";
src = ./.;
buildFeatures = [ "ddsfile " "image" "dcv-color-primitives" ];
cargoLock = {
# Why I yes, I would like not writing the hash of my Cargo.lock very much.
lockFile = ./Cargo.lock;
};
};
txp-python-drv = pkgs: isNew: pythonPackages:
pythonPackages.buildPythonPackage rec {
pname = "txp";
version = "v0.1.0";
src = ./.;
cargoDeps = pkgs.rustPlatform.importCargoLock {
# Why I yes, I would like not writing the hash of my Cargo.lock very much.
lockFile = ./Cargo.lock;
};
format = "pyproject";
# HACK: maturinBuildHook is dumb and doesn't read pyproject.toml for some reason
maturinBuildFlags = if isNew then ["--all-features"] else [''--cargo-extra-args="--all-features"''];
nativeBuildInputs = with pkgs.rustPlatform; [cargoSetupHook maturinBuildHook];
# needed for maturin
propagatedBuildInputs = with pythonPackages; [cffi];
};
pythonOverride = prev: isNew: (prevArgs: {
packageOverrides = let
ourOverlay = new: old: {
txp = txp-python-drv prev isNew old;
};
in
prev.lib.composeExtensions
prevArgs.packageOverrides or emptyOverlay
ourOverlay;
});
in
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {inherit system overlays;};
in rec {
packages = rec {
txp = txp-drv pkgs;
txp-python = txp-python-drv pkgs true pkgs.python310Packages;
default = txp;
};
devShells.default = pkgs.mkShell rec {
nativeBuildInputs = with pkgs; [
(pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-src" "cargo" "rustc"];
targets = [ "x86_64-pc-windows-gnu" ];
})
gcc
];
buildInputs = with pkgs; [
maturin
rust-analyzer
cargo-semver-checks
pkgsCross.mingwW64.stdenv.cc
(pkgs.python3.withPackages (p:
with p; [
cffi
]))
];
# RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [
# pkgs.pkgsCross.mingwW64.windows.pthreads
# ]);
};
devShells.python = pkgs.mkShell rec {
buildInputs = with pkgs; [
(pkgs.python310.withPackages (p:
with p; [
packages.txp-python
]))
];
};
}
)
// {
overlays.default = final: prev: rec {
txp = txp-drv prev;
python3 = prev.python3.override (pythonOverride prev true);
python310 = prev.python310.override (pythonOverride prev true);
python39 = prev.python39.override (pythonOverride prev false);
};
};
}