Skip to content

Conversation

@blaggacao
Copy link
Contributor

@blaggacao blaggacao commented Jun 8, 2021

exec -a NAME-calls to interpreted shebang scripts are substituted
as execve(shbangbin, [<evtl only shebang arg>, <scriptfile>]). As you
can see, NAME is lost. man execve makes it clear (w.r.t. interpreted
scripts):

Note that there is
no way to get the argv[0] that was passed to the execve() call.

This commit adds a promise / contract to the make wrapper, so that
scripts can have at least a chance of knowing what their author
has originally had intended for argv[0] to be in the first place.

Motivation for this change
  • Make scripts report the truth (my-script) instead of an "UX lie" (.my-script-wrapped).
  • The alternative for those scripts to use @name@ substitution is unclean: it rebuilds (the script) for arbitrary wrappers however thin they are
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

"exec -a NAME" calls to interpreted shebang scripts are substituted

as execve(shbangbin, [<evtl only shebang arg>, <scriptfile>]). As you
can see, NAME is lost. `man execve` makes it clear (w.r.t. interpreted
scripts):

> Note that there is
> no way to get the argv[0] that was passed to the execve() call.

This commit adds a promise / contract to the make wrapper, so that
scripts can have **at least a chance** of knowing what their author
has originally had intended for argv[0] to be in the first place.
@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Jun 8, 2021
@r-rmcgibbo
Copy link

r-rmcgibbo commented Jun 9, 2021

Result of nixpkgs-review pr 126248 at 9be8fe4 run on aarch64-linux 1

295 packages marked as broken and skipped:
  • Literate
  • OVMF-CSM
  • _389-ds-base
  • acl2
  • adoptopenjdk-hotspot-bin-13
  • adoptopenjdk-hotspot-bin-14
  • adoptopenjdk-jre-hotspot-bin-13
  • adoptopenjdk-jre-hotspot-bin-14
  • airtame
  • ams-lv2
  • apfelgrid
  • applgrid
  • artyFX
  • asymptote
  • attract-mode
  • autotrace
  • avy
  • beignet
  • betaflight-configurator
  • blastem
  • bless
  • bootiso
  • bud
  • cargo-rr
  • cassandra_2_1
  • cassandra_2_2
  • chefdk
  • chez
  • clang-sierraHack
  • clang-sierraHack-stdenv
  • clickhouse
  • clmagma
  • colmapWithCuda
  • coreboot-utils
  • cura_stable
  • dcraw
  • deeptools
  • devede
  • displaycal
  • dtools
  • dust
  • dvd-slideshow
  • efitools
  • electron_3
  • electron_4
  • electron_5
  • embree
  • embree2
  • eterm
  • evilvte
  • exodus
  • facter
  • ffmpeg_2
  • ffmpeg_2_8
  • ffmpeg_3
  • ffmpeg_3_4
  • firestarter
  • forge
  • fsharp41
  • gb-backup
  • git-dit
  • gitin
  • globalplatform
  • globulation2
  • gmtk
  • gnome_mplayer
  • gnuradio3_7
  • gnuradio3_7Packages.ais
  • gnuradio3_7Packages.gnuradio
  • gnuradio3_7Packages.gsm
  • gnuradio3_7Packages.limesdr
  • gnuradio3_7Packages.nacl
  • gnuradio3_7Packages.osmosdr
  • gnuradio3_7Packages.rds
  • go_1_14
  • gogoclient
  • gopro
  • gppcscconnectionplugin
  • gpshell
  • grass
  • green-pdfviewer
  • gtkd
  • gtmess
  • hplipWithPlugin_3_16_11
  • hplipWithPlugin_3_18_5
  • hplip_3_16_11
  • hplip_3_18_5
  • idris2
  • impressive
  • intecture-cli
  • intel-compute-runtime
  • intel-media-driver
  • invoice2data
  • isabelle
  • jboss
  • jfbpdf
  • jfbview
  • julia
  • julia-lts
  • julia_10
  • k2pdfopt
  • k3d
  • keyfinder
  • libav
  • libav_0_8
  • libav_11
  • libav_12
  • libgroove
  • libnats-c
  • libvirt_5_9_0
  • libvmi
  • linuxPackages_hardkernel_4_14.akvcam
  • linuxPackages_hardkernel_4_14.bcc
  • linuxPackages_hardkernel_4_14.dpdk
  • linuxPackages_hardkernel_4_14.evdi
  • linuxPackages_hardkernel_4_14.openrazer
  • linuxPackages_hardkernel_4_14.systemtap
  • linuxPackages_hardkernel_4_14.xpadneo
  • linuxPackages_hardkernel_4_14.zfs
  • linuxPackages_hardkernel_4_14.zfsStable
  • linuxPackages_hardkernel_4_14.zfsUnstable
  • linuxPackages_hardkernel_latest.akvcam
  • linuxPackages_hardkernel_latest.bcc
  • linuxPackages_hardkernel_latest.dpdk
  • linuxPackages_hardkernel_latest.evdi
  • linuxPackages_hardkernel_latest.openrazer
  • linuxPackages_hardkernel_latest.systemtap
  • linuxPackages_hardkernel_latest.xpadneo
  • linuxPackages_hardkernel_latest.zfs
  • linuxPackages_hardkernel_latest.zfsStable
  • linuxPackages_hardkernel_latest.zfsUnstable
  • linuxPackages_testing_bcachefs.akvcam
  • linuxPackages_testing_bcachefs.bcc
  • linuxPackages_testing_bcachefs.dpdk
  • linuxPackages_testing_bcachefs.evdi
  • linuxPackages_testing_bcachefs.oci-seccomp-bpf-hook
  • linuxPackages_testing_bcachefs.openrazer
  • linuxPackages_testing_bcachefs.systemtap
  • linuxPackages_testing_bcachefs.xpadneo
  • linuxPackages_testing_bcachefs.zfs
  • linuxPackages_testing_bcachefs.zfsStable
  • linuxPackages_testing_bcachefs.zfsUnstable
  • loxodo
  • lucenepp
  • luxcorerender
  • magma
  • mame
  • meo
  • metamorphose2
  • microcodeIntel
  • mpich
  • mrxvt
  • mupdf_1_17
  • mvapich
  • natron
  • nixui
  • nomad_0_12
  • nrpl
  • nvtop
  • obs-ndi
  • ocropus
  • odpdown
  • odroid-xu3-bootloader
  • onedrive
  • openems
  • openimagedenoise
  • openimagedenoise_1_2_x
  • openrw
  • openssh_gssapi
  • openssh_hpn
  • opentsdb
  • ovftool
  • pcsxr
  • pdfdiff
  • pgadmin
  • photoflow
  • pig
  • plover.stable
  • poedit
  • polymake
  • pony-stable
  • processing
  • pulseeffects-legacy
  • pulseeffects-pw
  • python38Packages.HTSeq
  • python38Packages.bwapy
  • python38Packages.caffe
  • python38Packages.cnvkit
  • python38Packages.dask-gateway
  • python38Packages.dask-jobqueue
  • python38Packages.dask-ml
  • python38Packages.dask-mpi
  • python38Packages.dask-xgboost
  • python38Packages.datashader
  • python38Packages.fipy
  • python38Packages.foundationdb51
  • python38Packages.foundationdb52
  • python38Packages.foundationdb60
  • python38Packages.foundationdb61
  • python38Packages.foxdot
  • python38Packages.ignite
  • python38Packages.mkl-service
  • python38Packages.pycuda
  • python38Packages.pygmt
  • python38Packages.pymystem3
  • python38Packages.pynvml
  • python38Packages.python-csxcad
  • python38Packages.python-openems
  • python38Packages.pythonnet
  • python38Packages.pytorchWithCuda
  • python38Packages.spacy
  • python38Packages.spacy-transformers
  • python38Packages.streamz
  • python38Packages.stumpy
  • python38Packages.tensorflowWithCuda
  • python38Packages.textacy
  • python38Packages.thinc
  • python39Packages.HTSeq
  • python39Packages.bwapy
  • python39Packages.caffe
  • python39Packages.cnvkit
  • python39Packages.dask-gateway
  • python39Packages.dask-jobqueue
  • python39Packages.dask-mpi
  • python39Packages.dask-xgboost
  • python39Packages.fipy
  • python39Packages.foundationdb51
  • python39Packages.foundationdb52
  • python39Packages.foundationdb60
  • python39Packages.foundationdb61
  • python39Packages.foxdot
  • python39Packages.ignite
  • python39Packages.mkl-service
  • python39Packages.pycuda
  • python39Packages.pygmt
  • python39Packages.pymystem3
  • python39Packages.pynvml
  • python39Packages.python-csxcad
  • python39Packages.python-openems
  • python39Packages.pythonnet
  • python39Packages.pytorchWithCuda
  • python39Packages.streamz
  • python39Packages.tensorflowWithCuda
  • python39Packages.thinc
  • qemu_xen
  • qemu_xen-light
  • qemu_xen_4_10
  • qemu_xen_4_10-light
  • qlandkartegt
  • qubes-core-vchan-xen
  • rainbowstream
  • ring-daemon
  • rocm-opencl-icd
  • rocm-opencl-runtime
  • root5
  • rund
  • rxvt
  • scribus
  • secretscanner
  • shellinabox
  • shotgun
  • sipwitch
  • sonic-pi
  • spark
  • split2flac
  • spotifywm
  • spring
  • springLobby
  • stepmania
  • swftools
  • swift
  • termplay
  • thrift-0_10
  • tilix
  • tlaps
  • torchat
  • truvari
  • tvheadend
  • twinkle
  • unetbootin
  • unicap
  • vbam
  • vcs
  • vp
  • wimlib
  • winpdb
  • woeusb
  • xfitter
  • xorg.libAppleWM
  • xpdf
  • xsw
  • yaxg
  • yosys-bluespec
  • zandronum
  • zgv
25208 packages skipped due to time constraints:
  • AusweisApp2
  • CHOWTapeModel
  • DisnixWebService
  • EBTKS
  • EmptyEpsilon
  • Fabric (python38Packages.Fabric)
  • LAStools
  • LASzip
  • LASzip2
  • MACS2
  • ...
145 packages built successfully:
  • dav1d
  • docbook2x
  • docutils (python38Packages.docutils)
  • freetype
  • fribidi
  • giflib
  • itstool
  • jpylyzer (python38Packages.jpylyzer)
  • libglvnd
  • libsysprof-capture
  • libvdpau
  • man (man-db)
  • meson
  • openresolv
  • opensp
  • python38Packages.Babel
  • python38Packages.alabaster
  • python38Packages.apipkg
  • python38Packages.appdirs
  • python38Packages.atomicwrites
  • python38Packages.attrs
  • python38Packages.brotli
  • python38Packages.certifi
  • python38Packages.click
  • python38Packages.cloudpickle
  • python38Packages.colorama
  • python38Packages.coverage
  • python38Packages.cppy
  • python38Packages.cycler
  • python38Packages.dateutil (python38Packages.python-dateutil)
  • python38Packages.decorator
  • python38Packages.distlib
  • python38Packages.django (python38Packages.django_2)
  • python38Packages.eradicate
  • python38Packages.execnet
  • python38Packages.filelock
  • python38Packages.flake8
  • python38Packages.flaky
  • python38Packages.flit-core
  • python38Packages.freezegun
  • python38Packages.gyp
  • python38Packages.idna
  • python38Packages.imagesize
  • python38Packages.importlib-metadata
  • python38Packages.iniconfig
  • python38Packages.intreehooks
  • python38Packages.iso8601
  • python38Packages.itsdangerous
  • python38Packages.jinja2
  • python38Packages.libevdev
  • python38Packages.linecache2
  • python38Packages.markupsafe
  • python38Packages.mccabe
  • python38Packages.mock
  • python38Packages.more-itertools
  • python38Packages.nose
  • python38Packages.olefile
  • python38Packages.packaging
  • python38Packages.pbr
  • python38Packages.pexpect
  • python38Packages.pip
  • python38Packages.pkgconfig
  • python38Packages.pluggy
  • python38Packages.pretend
  • python38Packages.psutil
  • python38Packages.ptyprocess
  • python38Packages.py
  • python38Packages.py-cpuinfo
  • python38Packages.pyasn1
  • python38Packages.pycodestyle
  • python38Packages.pycparser
  • python38Packages.pyflakes
  • python38Packages.pygments
  • python38Packages.pyparsing
  • python38Packages.pysocks
  • python38Packages.pytest (python38Packages.pytest_6)
  • python38Packages.pytest-asyncio
  • python38Packages.pytest-benchmark
  • python38Packages.pytestcov (python38Packages.pytest-cov)
  • python38Packages.pytest-expect
  • python38Packages.pytest-forked
  • python38Packages.pytest-freezegun
  • python38Packages.pytest-mock
  • python38Packages.pytestrunner (python38Packages.pytest-runner)
  • python38Packages.pytest-subtests
  • python38Packages.pytoml
  • python38Packages.pytz
  • python38Packages.ruamel-base (python38Packages.ruamel_base)
  • python38Packages.semantic-version
  • python38Packages.setuptools
  • python38Packages.setuptools-rust
  • python38Packages.setuptools-scm
  • python38Packages.six
  • python38Packages.smartypants
  • python38Packages.sortedcontainers
  • python38Packages.sphinxcontrib-applehelp
  • python38Packages.sphinxcontrib-devhelp
  • python38Packages.sphinxcontrib-htmlhelp
  • python38Packages.sphinxcontrib-jsmath
  • python38Packages.sphinxcontrib-qthelp
  • python38Packages.sphinxcontrib-serializinghtml
  • python38Packages.sphinxcontrib-websupport
  • python38Packages.sqlparse
  • python38Packages.tappy
  • python38Packages.testpath
  • python38Packages.text-unidecode
  • python38Packages.toml
  • python38Packages.tomlkit
  • python38Packages.tornado
  • python38Packages.traceback2
  • python38Packages.typogrify
  • python38Packages.u-msgpack-python
  • python38Packages.ukpostcodeparser
  • python38Packages.unittest2
  • python38Packages.urllib3
  • python38Packages.wcwidth
  • python38Packages.webencodings
  • python38Packages.wheel
  • python38Packages.zipp
  • python38Packages.zope_event
  • python38Packages.zope_interface
  • w3m-batch
  • xkeyboard_config (xorg.xkeyboardconfig)
  • xmlto
  • xorg.libICE
  • xorg.libX11
  • xorg.libXau
  • xorg.libXcomposite
  • xorg.libXcursor
  • xorg.libXdmcp
  • xorg.libXext
  • xorg.libXfixes
  • xorg.libXi
  • xorg.libXinerama
  • xorg.libXrandr
  • xorg.libXrender
  • xorg.libXtst
  • xorg.libXxf86vm
  • xorg.libxcb
  • xorg.xcbutil
  • xorg.xcbutilimage
  • xorg.xcbutilkeysyms
  • xorg.xcbutilrenderutil
  • xorg.xcbutilwm
  • xorg.xorgproto

Result of nixpkgs-review pr 126248 at 9be8fe4 run on x86_64-linux 1

214 packages marked as broken and skipped:
  • _389-ds-base
  • adobe-reader
  • adoptopenjdk-hotspot-bin-13
  • adoptopenjdk-hotspot-bin-14
  • adoptopenjdk-jre-hotspot-bin-13
  • adoptopenjdk-jre-hotspot-bin-14
  • adoptopenjdk-jre-openj9-bin-13
  • adoptopenjdk-jre-openj9-bin-14
  • adoptopenjdk-openj9-bin-13
  • adoptopenjdk-openj9-bin-14
  • airtame
  • attract-mode
  • autotrace
  • blastem
  • cassandra_2_1
  • cassandra_2_2
  • clang-sierraHack
  • clang-sierraHack-stdenv
  • clickshare-csc1
  • curaByDagoma
  • cura_stable
  • darwin.CF
  • dcraw
  • displaycal
  • dotnetPackages.ExcelDnaRegistration
  • dotnetPackages.ExtCore
  • dotnetPackages.FSharpAutoComplete
  • dotnetPackages.FSharpCompilerCodeDom
  • dotnetPackages.FSharpCompilerService
  • dotnetPackages.FSharpCompilerTools
  • dotnetPackages.FSharpCore302
  • dotnetPackages.FSharpCore3125
  • dotnetPackages.FSharpCore4001
  • dotnetPackages.FSharpCore4117
  • dotnetPackages.FSharpData
  • dotnetPackages.FSharpData225
  • dotnetPackages.FSharpDataSQLProvider
  • dotnetPackages.FSharpFormatting
  • dotnetPackages.Fake
  • dotnetPackages.Fantomas
  • dotnetPackages.FsCheck
  • dotnetPackages.FsCheck262
  • dotnetPackages.FsCheckNunit
  • dotnetPackages.FsLexYacc
  • dotnetPackages.FsLexYacc706
  • dotnetPackages.FsLexYaccRuntime
  • dotnetPackages.FsPickler
  • dotnetPackages.FsUnit
  • dotnetPackages.MathNetNumerics
  • dotnetPackages.Projekt
  • dotnetPackages.Suave
  • dotnetPackages.UnionArgParser
  • dvd-slideshow
  • eagle7
  • electron_3
  • electron_4
  • electron_5
  • epsxe
  • erlang_basho_R16B02
  • eterm
  • evilvte
  • ffmpeg_2
  • ffmpeg_2_8
  • ffmpeg_3
  • ffmpeg_3_4
  • fsharp41
  • git-dit
  • gitin
  • globalplatform
  • gnash
  • gnuradio3_7
  • gnuradio3_7Packages.ais
  • gnuradio3_7Packages.gnuradio
  • gnuradio3_7Packages.gsm
  • gnuradio3_7Packages.limesdr
  • gnuradio3_7Packages.nacl
  • gnuradio3_7Packages.osmosdr
  • gnuradio3_7Packages.rds
  • go_1_14
  • gogoclient
  • googleearth-pro
  • gppcscconnectionplugin
  • gpshell
  • grass
  • green-pdfviewer
  • gtmess
  • hadoop
  • hadoop_2_7
  • hadoop_2_8
  • hadoop_2_9
  • hplipWithPlugin_3_16_11
  • hplipWithPlugin_3_18_5
  • hplip_3_16_11
  • hplip_3_18_5
  • impressive
  • intecture-cli
  • invoice2data
  • jboss
  • jfbpdf
  • jfbview
  • julia
  • julia-bin
  • julia-lts
  • julia-lts-bin
  • julia_10
  • julia_10-bin
  • k2pdfopt
  • keyfinder
  • libav
  • libav_0_8
  • libav_11
  • libav_12
  • libgit2_0_27
  • libgroove
  • libnats-c
  • libvirt_5_9_0
  • linuxPackages_hardkernel_4_14.akvcam
  • linuxPackages_hardkernel_4_14.amdgpu-pro
  • linuxPackages_hardkernel_4_14.bcc
  • linuxPackages_hardkernel_4_14.bpftrace
  • linuxPackages_hardkernel_4_14.chipsec
  • linuxPackages_hardkernel_4_14.dpdk
  • linuxPackages_hardkernel_4_14.evdi
  • linuxPackages_hardkernel_4_14.nvidia_x11
  • linuxPackages_hardkernel_4_14.nvidia_x11_beta
  • linuxPackages_hardkernel_4_14.nvidia_x11_legacy340
  • linuxPackages_hardkernel_4_14.nvidia_x11_legacy390
  • linuxPackages_hardkernel_4_14.nvidia_x11_vulkan_beta
  • linuxPackages_hardkernel_4_14.openrazer
  • linuxPackages_hardkernel_4_14.prl-tools
  • linuxPackages_hardkernel_4_14.sysdig
  • linuxPackages_hardkernel_4_14.systemtap
  • linuxPackages_hardkernel_4_14.virtualbox
  • linuxPackages_hardkernel_4_14.virtualboxGuestAdditions
  • linuxPackages_hardkernel_4_14.xpadneo
  • linuxPackages_hardkernel_4_14.zfs
  • linuxPackages_hardkernel_4_14.zfsStable
  • linuxPackages_hardkernel_4_14.zfsUnstable
  • linuxPackages_hardkernel_latest.akvcam
  • linuxPackages_hardkernel_latest.amdgpu-pro
  • linuxPackages_hardkernel_latest.bcc
  • linuxPackages_hardkernel_latest.bpftrace
  • linuxPackages_hardkernel_latest.chipsec
  • linuxPackages_hardkernel_latest.dpdk
  • linuxPackages_hardkernel_latest.evdi
  • linuxPackages_hardkernel_latest.nvidia_x11
  • linuxPackages_hardkernel_latest.nvidia_x11_beta
  • linuxPackages_hardkernel_latest.nvidia_x11_legacy340
  • linuxPackages_hardkernel_latest.nvidia_x11_legacy390
  • linuxPackages_hardkernel_latest.nvidia_x11_vulkan_beta
  • linuxPackages_hardkernel_latest.openrazer
  • linuxPackages_hardkernel_latest.prl-tools
  • linuxPackages_hardkernel_latest.sysdig
  • linuxPackages_hardkernel_latest.systemtap
  • linuxPackages_hardkernel_latest.virtualbox
  • linuxPackages_hardkernel_latest.virtualboxGuestAdditions
  • linuxPackages_hardkernel_latest.xpadneo
  • linuxPackages_hardkernel_latest.zfs
  • linuxPackages_hardkernel_latest.zfsStable
  • linuxPackages_hardkernel_latest.zfsUnstable
  • loxodo
  • metamorphose2
  • mfcl8690cdwcupswrapper
  • mrxvt
  • mupdf_1_17
  • natron
  • nomad_0_12
  • obinskit
  • ocropus
  • odpdown
  • odroid-xu3-bootloader
  • openrw
  • openssh_gssapi
  • openssh_hpn
  • opentsdb
  • oven-media-engine
  • ovftool
  • pbis-open
  • pcsxr
  • pdfdiff
  • pdfread
  • pgadmin
  • pig
  • plover.stable
  • rainbowstream
  • riak
  • ring-daemon
  • rxvt
  • scallion
  • scribus
  • scyther
  • shellinabox
  • sipwitch
  • spark
  • staruml
  • stepmania
  • swftools
  • swift
  • termplay
  • thrift-0_10
  • torchat
  • tvheadend
  • twinkle
  • unicap
  • vdrPlugins.markad
  • vdrPlugins.vaapidevice
  • vdrPlugins.xineliboutput
  • vp
  • winpdb
  • xorg.libAppleWM
  • xpdf
  • xsw
  • yaxg
  • zgv
28445 packages skipped due to time constraints:
  • AusweisApp2
  • CHOWTapeModel
  • DisnixWebService
  • EBTKS
  • EmptyEpsilon
  • Fabric (python38Packages.Fabric)
  • LAStools
  • LASzip
  • LASzip2
  • Literate
  • ...
270 packages built successfully:
  • bundler
  • dav1d
  • docbook2x
  • docutils (python38Packages.docutils)
  • droopy
  • freetype
  • fribidi
  • giflib
  • itstool
  • jpylyzer (python38Packages.jpylyzer)
  • libGL
  • libglvnd
  • libsysprof-capture
  • libvdpau
  • lua51Packages.wrapLua
  • luaPackages.wrapLua (lua52Packages.wrapLua)
  • lua53Packages.wrapLua
  • luajitPackages.wrapLua
  • makeWrapper
  • man (man-db)
  • meson
  • openresolv
  • opensp
  • ophis
  • oysttyer
  • python38Packages.Babel
  • python38Packages.alabaster
  • python38Packages.apipkg
  • python38Packages.appdirs
  • python38Packages.async-timeout
  • python38Packages.async_generator
  • python38Packages.atomicwrites
  • python38Packages.attrs
  • python38Packages.automat
  • python38Packages.bootstrapped-pip
  • python38Packages.brotli
  • python38Packages.certifi
  • python38Packages.click
  • python38Packages.cloudpickle
  • python38Packages.colorama
  • python38Packages.constantly
  • python38Packages.coverage
  • python38Packages.cppy
  • python38Packages.cycler
  • python38Packages.dateutil (python38Packages.python-dateutil)
  • python38Packages.decorator
  • python38Packages.distlib
  • python38Packages.django (python38Packages.django_2)
  • python38Packages.eradicate
  • python38Packages.execnet
  • python38Packages.extras
  • python38Packages.filelock
  • python38Packages.flake8
  • python38Packages.flaky
  • python38Packages.flit-core
  • python38Packages.freezegun
  • python38Packages.gyp
  • python38Packages.idna
  • python38Packages.imagesize
  • python38Packages.importlib-metadata
  • python38Packages.iniconfig
  • python38Packages.intreehooks
  • python38Packages.iso8601
  • python38Packages.itsdangerous
  • python38Packages.jinja2
  • python38Packages.libevdev
  • python38Packages.linecache2
  • python38Packages.m2r
  • python38Packages.markupsafe
  • python38Packages.mccabe
  • python38Packages.mistune (python38Packages.mistune_0_8)
  • python38Packages.mock
  • python38Packages.more-itertools
  • python38Packages.nose
  • python38Packages.olefile
  • python38Packages.packaging
  • python38Packages.pbr
  • python38Packages.pexpect
  • python38Packages.pip
  • python38Packages.pipBuildHook
  • python38Packages.pipInstallHook
  • python38Packages.pkgconfig
  • python38Packages.pluggy
  • python38Packages.pretend
  • python38Packages.psutil
  • python38Packages.ptyprocess
  • python38Packages.py
  • python38Packages.py-cpuinfo
  • python38Packages.pyasn1
  • python38Packages.pycodestyle
  • python38Packages.pycparser
  • python38Packages.pyflakes
  • python38Packages.pygments
  • python38Packages.pyparsing
  • python38Packages.pysocks
  • python38Packages.pytest (python38Packages.pytest_6)
  • python38Packages.pytest-asyncio
  • python38Packages.pytest-benchmark
  • python38Packages.pytestcov (python38Packages.pytest-cov)
  • python38Packages.pytest-expect
  • python38Packages.pytest-forked
  • python38Packages.pytest-freezegun
  • python38Packages.pytest-mock
  • python38Packages.pytestrunner (python38Packages.pytest-runner)
  • python38Packages.pytest-subtests
  • python38Packages.pytestCheckHook
  • python38Packages.pythonCatchConflictsHook
  • python38Packages.python_mimeparse
  • python38Packages.pytoml
  • python38Packages.pytz
  • python38Packages.ruamel-base (python38Packages.ruamel_base)
  • python38Packages.semantic-version
  • python38Packages.setuptools
  • python38Packages.setuptools-rust
  • python38Packages.setuptools-scm
  • python38Packages.setuptoolsBuildHook
  • python38Packages.setuptoolsCheckHook
  • python38Packages.six
  • python38Packages.smartypants
  • python38Packages.sortedcontainers
  • python38Packages.soupsieve
  • python38Packages.sphinxcontrib-applehelp
  • python38Packages.sphinxcontrib-devhelp
  • python38Packages.sphinxcontrib-htmlhelp
  • python38Packages.sphinxcontrib-jsmath
  • python38Packages.sphinxcontrib-qthelp
  • python38Packages.sphinxcontrib-serializinghtml
  • python38Packages.sphinxcontrib-websupport
  • python38Packages.sqlparse
  • python38Packages.tappy
  • python38Packages.termstyle
  • python38Packages.testpath
  • python38Packages.text-unidecode
  • python38Packages.toml
  • python38Packages.tomlkit
  • python38Packages.tornado
  • python38Packages.traceback2
  • python38Packages.typing-extensions
  • python38Packages.typogrify
  • python38Packages.u-msgpack-python
  • python38Packages.ukpostcodeparser
  • python38Packages.unittest2
  • python38Packages.urllib3
  • python38Packages.vcversioner
  • python38Packages.wcwidth
  • python38Packages.webencodings
  • python38Packages.wheel
  • python38Packages.wheelUnpackHook
  • python38Packages.wrapPython
  • python38Packages.zipp
  • python38Packages.zope_event
  • python38Packages.zope_interface
  • python39Packages.alabaster
  • python39Packages.appdirs
  • python39Packages.atomicwrites
  • python39Packages.attrs
  • python39Packages.bootstrapped-pip
  • python39Packages.certifi
  • python39Packages.colorama
  • python39Packages.coverage
  • python39Packages.dateutil (python39Packages.python-dateutil)
  • python39Packages.distlib
  • python39Packages.docutils
  • python39Packages.filelock
  • python39Packages.importlib-metadata
  • python39Packages.iniconfig
  • python39Packages.linecache2
  • python39Packages.markupsafe
  • python39Packages.mock
  • python39Packages.more-itertools
  • python39Packages.nose
  • python39Packages.packaging
  • python39Packages.pbr
  • python39Packages.pexpect
  • python39Packages.pip
  • python39Packages.pipBuildHook
  • python39Packages.pipInstallHook
  • python39Packages.pluggy
  • python39Packages.pretend
  • python39Packages.psutil
  • python39Packages.ptyprocess
  • python39Packages.py
  • python39Packages.pycparser
  • python39Packages.pyflakes
  • python39Packages.pygments
  • python39Packages.pyparsing
  • python39Packages.pysocks
  • python39Packages.pythonCatchConflictsHook
  • python39Packages.pytz
  • python39Packages.semantic-version
  • python39Packages.setuptools
  • python39Packages.setuptools-rust
  • python39Packages.setuptools-scm
  • python39Packages.setuptoolsBuildHook
  • python39Packages.setuptoolsCheckHook
  • python39Packages.six
  • python39Packages.sortedcontainers
  • python39Packages.sphinxcontrib-jsmath
  • python39Packages.sphinxcontrib-serializinghtml
  • python39Packages.sphinxcontrib-websupport
  • python39Packages.testpath
  • python39Packages.toml
  • python39Packages.traceback2
  • python39Packages.typing-extensions
  • python39Packages.u-msgpack-python
  • python39Packages.unittest2
  • python39Packages.wcwidth
  • python39Packages.wheel
  • python39Packages.wheelUnpackHook
  • python39Packages.wrapPython
  • python39Packages.zipp
  • raspberrypi-eeprom
  • rubyPackages.addressable (rubyPackages_2_7.addressable)
  • rubyPackages.coderay (rubyPackages_2_7.coderay)
  • rubyPackages.colorator (rubyPackages_2_7.colorator)
  • rubyPackages.colored2 (rubyPackages_2_7.colored2)
  • rubyPackages.concurrent-ruby (rubyPackages_2_7.concurrent-ruby)
  • rubyPackages.diff-lcs (rubyPackages_2_7.diff-lcs)
  • rubyPackages.method_source (rubyPackages_2_7.method_source)
  • rubyPackages.mime-types (rubyPackages_2_7.mime-types)
  • rubyPackages.mime-types-data (rubyPackages_2_7.mime-types-data)
  • rubyPackages.mini_mime (rubyPackages_2_7.mini_mime)
  • rubyPackages.polyglot (rubyPackages_2_7.polyglot)
  • rubyPackages.public_suffix (rubyPackages_2_7.public_suffix)
  • rubyPackages.racc (rubyPackages_2_7.racc)
  • rubyPackages.rouge (rubyPackages_2_7.rouge)
  • rubyPackages.ruby-progressbar (rubyPackages_2_7.ruby-progressbar)
  • rubyPackages.rubyzip (rubyPackages_2_7.rubyzip)
  • rubyPackages.safe_yaml (rubyPackages_2_7.safe_yaml)
  • rubyPackages.treetop (rubyPackages_2_7.treetop)
  • rubyPackages_2_6.CFPropertyList
  • rubyPackages_2_6.ast
  • rubyPackages_2_6.cocoapods-deintegrate
  • rubyPackages_2_6.erubi
  • rubyPackages_2_6.ffi
  • rubyPackages_2_6.marcel
  • rubyPackages_2_6.mini_mime
  • rubyPackages_2_6.minitest
  • rubyPackages_2_6.molinillo
  • rubyPackages_2_6.mustermann
  • rubyPackages_2_6.parallel
  • rubyPackages_2_6.rack
  • rubyPackages_2_6.rack-protection
  • rubyPackages_2_6.ruby2_keywords
  • rubyPackages_3_0.thor
  • sbclBootstrap
  • w3m-batch
  • xkeyboard_config (xorg.xkeyboardconfig)
  • xmlto
  • xorg.libICE
  • xorg.libX11
  • xorg.libXau
  • xorg.libXcomposite
  • xorg.libXcursor
  • xorg.libXdmcp
  • xorg.libXext
  • xorg.libXfixes
  • xorg.libXi
  • xorg.libXinerama
  • xorg.libXrandr
  • xorg.libXrender
  • xorg.libXtst
  • xorg.libXxf86vm
  • xorg.libxcb
  • xorg.xcbutil
  • xorg.xcbutilimage
  • xorg.xcbutilkeysyms
  • xorg.xcbutilrenderutil
  • xorg.xcbutilwm
  • xorg.xorgproto

@Ericson2314
Copy link
Member

Ericson2314 commented Jun 11, 2021

@blaggacao talked about this for a while on Matrix, and (correct me if I am mistaken) we agreed to close it.

One one hand, it is a shame that make-wrapper causes the argv[0] provided by the client to be lost, because of the way Unix shebangs work. We could fix that by having make-wrapper produce a bonafied executable that does what the shell script would do, but that is a lot of work.

On the other hand, this PR wasn't about the above issue, but trying to provide an out-of-band way to get make-wrapper-set argv[0] to a nix-specific script. But I'd argue that is a bit of a layer violation. make-wrapper is supposed to work with arbitrary scripts, and if there is a nix-specific script intending to be wrapped with make-wrapper, well, why is it trying to use argv[0] anyways if we know that doesn't work! Rather than try to get it a make-wrapper-set argv[0] out of band, we ought to just pass that information in some other script-specific way, like a regular argument the wrapper script appends. This requires no change to make-wrapper.

@ncfavier
Copy link
Member

This requires no change to make-wrapper.

...unless the wrapped script is itself a wrapper script!

I am running into this problem because Thunar happens to be wrapped twice (once by wrapGAppsHook and then by thunar/wrapper.nix), which causes its argv0 to be set to .thunar-wrapped_ (and that breaks my window manager rules).

If we kept the proposed change and changed the bottom line of wrapProgram to something like

makeWrapper "$hidden" "$prog" --argv0 '${__NIX_ARGV0-$0}' "${@:2}"

it would at least fix this issue.

@blaggacao
Copy link
Contributor Author

blaggacao commented Jun 11, 2021

If we kept the proposed change and changed the bottom line of wrapProgram to something like

Bash scripts, themselves (being shebang script) suffer from the problem.

The correct way, here too, would be a C-wrapper that interpretes shebang scripts appropriately (as we would expect them to be interpreted for the purpose of our wild usage of wrappers).

However your use case might be a weight on the scale in favor of implementing such C wrapper.

@ncfavier
Copy link
Member

Bash scripts, themselves (being shebang script) suffer from the problem.

Yes, otherwise we wouldn't have this issue. __NIX_ARGV0 works around the problem by using the environment to pass information instead of argv[0] (which is destroyed by shebang scripts).

In my proposed solution, both wrappers would contain the lines

export __NIX_ARGV0="${__NIX_ARGV0-$0}"
exec -a "${__NIX_ARGV0-$0}" ...

so the first thunar wrapper sets __NIX_ARGV0 to thunar and calls .thunar-wrapped_, which then calls exec -a thunar .thunar-wrapped, which is what we want.

The correct way, here too, would be a C-wrapper that interpretes shebang scripts appropriately (as we would expect them to be interpreted for the purpose of our wild usage of wrappers).

However your use case might be a weight on the scale in favor of implementing such C wrapper.

Sure, but while we wait for that to happen, it might make sense to merge this 2-line fix.

@blaggacao
Copy link
Contributor Author

blaggacao commented Jun 11, 2021

I know there is a history of work around in nixpkgs, but I agree with @Ericson2314 that accepting this PR would be akin to a layer violation.

Maybe we can just take the unix implementation of execve and patch it and use that as our nixpkgs-specific C wrapper?

It it is only one argument that should be handled differently from the current unix implementation of execve.

@ncfavier
Copy link
Member

The problem is that bash foo will always set $0 to foo regardless of its argv[0]:

If bash is invoked with a file of commands, $0 is set to the name of that file.

@blaggacao
Copy link
Contributor Author

blaggacao commented Jun 12, 2021

It seems like bash behaves no different than python or any other script. The only difference I'm noticing is that I don't see the shebang substitution happening. It seems to be implicit.

➜  /tmp bat bash-test
───────┬────────────────────────────────────────────────────────────────────────────────────────────
       │ File: bash-test
───────┼────────────────────────────────────────────────────────────────────────────────────────────
   1   │ #! /bin/bash
   2   │
   3   │ echo I am $0
───────┴────────────────────────────────────────────────────────────────────────────────────────────
➜  /tmp ./bash-test
I am ./bash-test
➜  /tmp strace -s512 -e execve -f bash -c 'exec -a NAME ./bash-test'
execve("/usr/bin/bash", ["bash", "-c", "exec -a NAME ./bash-test"], 0x7ffed81a9710 /* 49 vars */) = 0
execve("/tmp/bash-test", ["NAME"], 0x5654fc755720 /* 49 vars */) = 0
I am /tmp/bash-test
+++ exited with 0 +++

Interestingly the zeroth arguments gets skipped by exeve (I assume to mimic the behavior of other interpreted scripts):

➜  /tmp bat bash-test
───────┬────────────────────────────────────────────────────────────────────────────────────────────
       │ File: bash-test
───────┼────────────────────────────────────────────────────────────────────────────────────────────
   1   │ #! /bin/sh
   2   │
   3   │ echo I am $1
───────┴────────────────────────────────────────────────────────────────────────────────────────────
➜  /tmp strace -s512 -e execve -f bash -c 'exec -a NAME ./bash-test 8'
execve("/usr/bin/bash", ["bash", "-c", "exec -a NAME ./bash-test 8"], 0x7ffd5f8c0b70 /* 49 vars */) = 0
execve("/tmp/bash-test", ["NAME", "8"], 0x55ebf403f720 /* 49 vars */) = 0
I am 8
+++ exited with 0 +++

@ncfavier
Copy link
Member

execve is a system call, so the shebang parsing and interpreter invocation happen in the kernel and you don't see another system call.

I'm not sure what you mean by "the zeroth argument gets skipped". In any case, the kernel certainly doesn't know about bash.

@blaggacao
Copy link
Contributor Author

blaggacao commented Jun 12, 2021

the zeroth argument gets skipped

$0 != NAME is the noticeable fact that I wanted to point out, above.

Regardless, $1 == 8 is the interesting bit that satisfies man execve cited in the PR message ("no way"). It is the same behaviour as if you where to see actual shebang substitution: try to do the same with a python script. The result is the same, but in distinction to bash, NAME is never passed as an argument.

The only reasoning that I have for this observation is that bash gets evaluated by the stdenv (of whatever, execve?) and does not need any interpreter invokation, while it seems to actively mimic the behaviour observed during interpreter invocation.

In conclusion, bash behaves no different, so the right solution (without "layer violation") shoudn't be any different. q.e.d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants