shell.nix 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Nix shell environment for mmgen-wallet
  2. { add_pkgs_path ? null }:
  3. let
  4. pkgs = import <nixpkgs> {};
  5. in
  6. pkgs.mkShellNoCC {
  7. packages = builtins.attrValues (import ./merged-packages.nix { add_pkgs_path = add_pkgs_path; });
  8. shellHook = ''
  9. do_sudo_override() {
  10. (
  11. rm -rf .bin-override
  12. mkdir .bin-override
  13. cd .bin-override
  14. if [ -x /bin/sudo ]; then
  15. ln -s /bin/sudo
  16. elif [ -x /run/wrappers/bin/sudo ]; then
  17. ln -s /run/wrappers/bin/sudo
  18. fi
  19. )
  20. }
  21. read _ _ name <<<$(grep ^name setup.cfg)
  22. [[ "$name" =~ ^mmgen-(wallet|node-tools)$ ]] || {
  23. echo "Error: this script must be executed in the mmgen-wallet or mmgen-node-tools repository root"
  24. exit 1
  25. }
  26. pwd=$(pwd)
  27. export PYTHONPATH=$pwd
  28. export PATH=$pwd/cmds:$pwd/.bin-override:$HOME/.local/bin:$PATH
  29. [ "$UID" == 0 ] || do_sudo_override
  30. '';
  31. }