I’m trying to use following shell.nix
to simulate a develop environment to run some ELF provided by others.
{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
name = "devbox";
targetPkgs = pkgs: (with pkgs; [
python39
python39Packages.pip
python39Packages.virtualenv
openssl
zlib
stdenv.cc.cc.lib
]);
runScript = "zsh";
}).env
But it core dumped.
And it is known that everything works well on Ubuntu 20.04, so is it possible for me to simulate an Ubuntu-like env use a shell.nix ?
Maybe it’s different with buildFHSUserEnv, but normally you would do (python39.withPackages (ps: with ps; [ pip virtualenv ]))
. If the program doesn’t output useful crash information, I have had luck running it with strace to see what else might be missing.
Oh nevermind, I guess that works fine if you are just using them on the command line separately, not as modules.
vcunat
December 31, 2021, 6:10pm
4
I don’t know… but I wouldn’t try to enter a FHS UE by nix-shell. It’s a thing that you build and then enter by running the result. (Though my experience with FHS is basically just for games.)
I find it finally working like this:
#!/usr/bin/env nix-shell
{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
name = "devbox";
targetPkgs = pkgs: (with pkgs; [
python38
python38Packages.pip
python38Packages.virtualenv
openssl
zlib
stdenv.cc.cc.lib
pythonManylinuxPackages.manylinux2014Package
]);
runScript = "zsh";
}).env
The key is add pythonManylinuxPackages.manylinux2014Package
and make sure the python version correct
3 Likes
I put my latest version here : Nix Script to simulate FHS environment with python3 & pip & venv · GitHub
Purpose of above script is to simulate an environment for python (pip) users. But it still have many limitations.
Hoping for a better solution to simulate an Ubuntu environment so that we can run more softwares.