85 lines
2.2 KiB
Nix
85 lines
2.2 KiB
Nix
# This is based on viper's article https://ayats.org/blog/nix-rustup
|
|
|
|
{
|
|
description = "Minimal starting project for nix-based maturin package development";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
|
};
|
|
|
|
outputs = { self, flake-parts, rust-overlay, ... }@inputs:
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
|
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
|
|
imports = [ ./nix/development.nix ];
|
|
|
|
perSystem = { system, config, pkgs-dev, ... }: {
|
|
formatter = pkgs-dev.nixfmt-classic;
|
|
};
|
|
};
|
|
|
|
# The main development environment
|
|
devShells.default =
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
|
|
overlays = [
|
|
devshell.overlays.default
|
|
rust-overlay.overlays.default
|
|
];
|
|
};
|
|
|
|
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml;
|
|
|
|
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
|
|
numpy
|
|
]);
|
|
|
|
in
|
|
pkgs.devshell.mkShell {
|
|
name = "maturin-basics";
|
|
|
|
commands = with pkgs; [
|
|
{ name = "maturin"; package = maturin; }
|
|
{ name = "python"; package = pythonEnv; }
|
|
];
|
|
|
|
packages = [
|
|
toolchain
|
|
pkgs.rust-analyzer-unwrapped
|
|
];
|
|
|
|
env = [
|
|
{
|
|
name = "RUST_SRC_PATH";
|
|
value = "${toolchain}/lib/rustlib/src/rust/library";
|
|
}
|
|
];
|
|
};
|
|
|
|
# The development environment for testing the resulting python package.
|
|
devShells.test =
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ devshell.overlays.default self.overlays.default ];
|
|
};
|
|
in
|
|
pkgs.devshell.mkShell {
|
|
name = "maturin-basics-test";
|
|
|
|
commands = with pkgs; [
|
|
{
|
|
name = "python";
|
|
package = pkgs.python3.withPackages (ps: with ps; [
|
|
maturin-basics
|
|
]);
|
|
}
|
|
];
|
|
};
|
|
});
|
|
}
|