indygreg / indygreg/PyOxidizer
Here's how to use PyOxidizer on NixOS
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
Hi, we've recently migrated a project to PyOxidizer 0.6 and I took this as an opportunity to fix the build setup on my NixOS machine. It was a bit tricky since this Linux distribution is build on the idea of very explicitly defining which libs and bins are visible at a time. Luckily, though, it's possible to define an "usual Linux" environment quite easily and add the required packages there.
The idea is to define a `shell.nix` in your project like this:
```nix
{ pkgs ? import {} }:
let
# picked a conservative python version because of errors regarding `cf_feature_version`
python_deps = with pkgs; [ openssl pkgconfig python36 ];
pyoxidizer = pkgs.rustPlatform.buildRustPackage rec {
pname = "pyoxidizer";
version = "0.6.0";
src = pkgs.fetchFromGitHub {
owner = "indygreg";
repo = "PyOxidizer";
rev = "v0.6.0";
sha256 = "1n4976wdcdpn4hwm8n7rwwx3pcvlkksad3y44n3q5mmh2lbr21g0";
};
cargoSha256 = "0fx0h9wlqbwlfmgz2kq6s3jhlyv32xxrhnmhipsmqb6vfpzm2pbq";
nativeBuildInputs = python_deps;
doCheck = false;
};
fhs = pkgs.buildFHSUserEnv {
name = "python-env";
targetPkgs = pkgs: with pkgs; [
cargo
rustc
pyoxidizer
] ++ python_deps;
runScript = "bash";
profile = ''
export CARGO_TARGET_DIR=target
'';
};
in pkgs.mkShell {
name = "python-env-shell";
buildInputs = with pkgs; [ fhs ];
shellHook = "exec python-env";
}
```
Running `nix-shell` will build pyoxidizer (this package might also be upstreamed if so desired) and then drop you into a bash following the usual Linux Filesystem Hierarchy Standard (FHS). Feel free to add packages to the `targetPkgs` list if your project needs more build dependencies!
- - -
I don't know where to put this information. But if anyone searches of this, I hope they can find this issue. And, who knows, maybe there's even a place in the docs for this.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the proposed shell.nix and the nix-shell entry point described in the issue. Review how the project currently organizes setup documentation, then determine where this NixOS workflow belongs. Done means the setup is documented in an appropriate location and the example can be followed to enter the described environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, nixos, python, rust
- Domain
- build-system, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100