Skip to content

Commit 68a6afe

Browse files
committed
build: Add packages+devShells+overlays to flake
1 parent 08d8990 commit 68a6afe

File tree

1 file changed

+77
-5
lines changed

1 file changed

+77
-5
lines changed

flake.nix

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,64 @@
1616
flake-utils,
1717
rust-overlay,
1818
}:
19+
let
20+
emptyOverlay = final: prev: {};
21+
objset-drv = pkgs: pkgs.rustPlatform.buildRustPackage {
22+
pname = "objset";
23+
version = "v0.1.0";
24+
25+
src = ./.;
26+
27+
cargoLock = {
28+
# Why I yes, I would like not writing the hash of my Cargo.lock very much.
29+
lockFile = ./Cargo.lock;
30+
};
31+
};
32+
objset-python-drv = pkgs: pythonPackages:
33+
pythonPackages.buildPythonPackage rec {
34+
pname = "objset";
35+
version = "v0.1.0";
36+
37+
src = ./.;
38+
39+
cargoDeps = pkgs.rustPlatform.importCargoLock {
40+
# Why I yes, I would like not writing the hash of my Cargo.lock very much.
41+
lockFile = ./Cargo.lock;
42+
};
43+
44+
format = "pyproject";
45+
46+
# HACK: maturinBuildHook is dumb and doesn't read pyproject.toml for some reason
47+
maturinBuildFlags = [ ''--cargo-extra-args="--all-features"'' ];
48+
49+
nativeBuildInputs = with pkgs.rustPlatform; [ cargoSetupHook maturinBuildHook ];
50+
51+
# needed for maturin
52+
propagatedBuildInputs = with pkgs.python3Packages; [ cffi ];
53+
};
54+
pythonOverride = prev: (prevArgs: {
55+
packageOverrides =
56+
let
57+
ourOverlay = new: old: {
58+
objset = objset-python-drv prev old;
59+
};
60+
in
61+
prev.lib.composeExtensions
62+
prevArgs.packageOverrides or emptyOverlay
63+
ourOverlay;
64+
});
65+
in
1966
flake-utils.lib.eachDefaultSystem (
2067
system: let
2168
overlays = [(import rust-overlay)];
2269
pkgs = import nixpkgs {inherit system overlays;};
23-
in {
24-
devShell = pkgs.mkShell rec {
70+
in rec {
71+
packages = rec {
72+
objset = objset-drv pkgs;
73+
objset-python = objset-python-drv pkgs pkgs.python3Packages;
74+
default = objset;
75+
};
76+
devShells.default = pkgs.mkShell rec {
2577
nativeBuildInputs = with pkgs; [
2678
(pkgs.rust-bin.nightly.latest.default.override {
2779
extensions = ["rust-src" "cargo" "rustc"];
@@ -32,12 +84,32 @@
3284
RUST_SRC_PATH = "${pkgs.rust-bin.nightly.latest.default.override {
3385
extensions = ["rust-src"];
3486
}}/lib/rustlib/src/rust/library";
35-
buildInputs = with pkgs; [
87+
buildNativeInputs = with pkgs; [
3688
rust-analyzer
3789
clippy
3890
];
39-
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
91+
buildInputs = with pkgs; [
92+
maturin
93+
(pkgs.python3.withPackages (p: with p; [
94+
cffi
95+
]))
96+
];
97+
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildNativeInputs;
98+
};
99+
devShells.python = pkgs.mkShell rec {
100+
buildInputs = with pkgs; [
101+
(pkgs.python3.withPackages (p: with p; [
102+
packages.objset-python
103+
]))
104+
];
40105
};
41106
}
42-
);
107+
) // {
108+
overlays.default = final: prev:
109+
rec {
110+
objset = objset-drv prev;
111+
python310 = prev.python310.override (pythonOverride prev);
112+
python39 = prev.python39.override (pythonOverride prev);
113+
};
114+
};
43115
}

0 commit comments

Comments
 (0)