Something went wrong. Try again.
Personal bot that I use for running ttrpg games
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192{ # Build Pyo3 package inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; flake-utils.url = "github:numtide/flake-utils"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; }; };
outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: let pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.rust-overlay.overlays.default ]; }; lib = pkgs.lib;
# Get a custom rust toolchain customRustToolchain = pkgs.rust-bin.stable."1.95.0".default; craneLib = (inputs.crane.mkLib pkgs).overrideToolchain customRustToolchain;
daveySrc = pkgs.fetchFromGitHub { owner = "Snazzah"; repo = "davey"; tag = "py-0.1.6"; hash = "sha256-FG6crkGb/huYvBDW4vj5B2fvr3WhM0sffaCxSeDnkcw="; };
projectName = "davey"; projectVersion = "0.1.6";
pythonVersion = pkgs.python312; wheelTail = "cp312-cp312-linux_x86_64"; # Change if pythonVersion changes wheelName = "${projectName}-${projectVersion}-${wheelTail}.whl";
crateCfg = { pname = "${projectName}"; version = "${projectVersion}"; src = daveySrc; nativeBuildInputs = [ pythonVersion ]; };
cargoArtifacts = craneLib.buildDepsOnly crateCfg;
# Build the library, then re-use the target dir to generate the wheel file with maturin crateWheel = (craneLib.buildPackage (crateCfg // { cargoExtraArgs = "-p davey-python"; cargoArtifacts = cargoArtifacts; })).overrideAttrs (old: { nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.maturin ]; buildPhase = old.buildPhase + '' maturin build --offline --target-dir ./target -m ./davey-python/Cargo.toml ''; installPhase = old.installPhase + '' cp target/wheels/${wheelName} $out/ ''; }); in rec { packages = rec { default = pkgs.python312Packages.callPackage ./package.nix {pythonPackage = lib.pythonPackage;}; wheel = crateWheel; # The wheel itself
# A python version with the library installed pythonEnv = pythonVersion.withPackages (ps: [ (lib.pythonPackage ps.buildPythonPackage) ] ++ (with ps; [ ipython ])); };
lib = { # To use in other builds with the "withPackages" call pythonPackage = buildPythonPackage: buildPythonPackage rec { pname = projectName; format = "wheel"; version = projectVersion; src = "${crateWheel}/${wheelName}"; doCheck = false; pythonImportsCheck = [ ]; }; }; });}