Python: Difference between revisions

Sdht0 (talk | contribs)
Add section
Sdht0 (talk | contribs)
Reorganize and add info about FHS
Line 101: Line 101:
</syntaxhighlight>This means that the library use compiled dynamically linked binaries that your NixOs environment fail to resolve.
</syntaxhighlight>This means that the library use compiled dynamically linked binaries that your NixOs environment fail to resolve.


On NixOS, installing packages that need to compile code or use C libraries from outside of the <code>nix</code> package manager may fail if dependencies are not found in the expected locations.
On NixOS, installing packages that need to compile code or use C libraries from outside of the <code>nix</code> package manager may fail if dependencies are not found in the expected locations. There are multiple ways to make it work:
There are multiple ways to make it work:
* Use [https://github.com/GuillaumeDesforges/fix-python/ fix-python], this is most suited for beginners.


* Create a FHS user env with <code>buildFHSUserEnv</code>.
==== Using `buildFHSEnv` in nix-shell ====
* Setup <code>nix-ld</code><ref name=":0">https://github.com/Mic92/nix-ld</ref> in your NixOS configuration.
<syntaxhighlight lang="nix">
* Prefix library paths using wrapProgram utility.
#!/usr/bin/env nix-shell


==== Using nix-ld ====
{ pkgs ? import <nixpkgs> { } }:
nix-ld<ref name=":0" /> allow you to run unpatched dynamic binaries on NixOS.


==== Using nix-shell ====
(
  let base = pkgs.appimageTools.defaultFhsEnvArgs; in
  pkgs.buildFHSEnv (base // {
    name = "FHS";
    targetPkgs = pkgs: (with pkgs; [
      gcc glibc zlib
    ]);
    runScript = "zsh";
    extraOutputsToInstall = [ "dev" ];
  })
).env
 
</syntaxhighlight>
 
==== Using 3rd party tools ====
 
* [https://github.com/Mic92/nix-ld nix-ld] allows you to run unpatched dynamic binaries on NixOS.
* [https://github.com/GuillaumeDesforges/fix-python/ fix-python]
 
==== Using a custom nix-shell ====


The following configuration automatically fix the dependencies:<syntaxhighlight lang="nixos" line="1">
The following configuration automatically fix the dependencies:<syntaxhighlight lang="nixos" line="1">