{"action":"created","issue":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/7936","labels_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/7936/labels{/name}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/7936/comments","events_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/7936/events","html_url":"https://github.com/NixOS/nixpkgs/pull/7936","id":79283207,"number":7936,"title":"Adding documentation to wrap.sh, added ability to retain env vars","user":{"login":"thinkpad20","id":2681817,"avatar_url":"https://avatars.githubusercontent.com/u/2681817?v=3","gravatar_id":"","url":"https://api.github.com/users/thinkpad20","html_url":"https://github.com/thinkpad20","followers_url":"https://api.github.com/users/thinkpad20/followers","following_url":"https://api.github.com/users/thinkpad20/following{/other_user}","gists_url":"https://api.github.com/users/thinkpad20/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkpad20/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkpad20/subscriptions","organizations_url":"https://api.github.com/users/thinkpad20/orgs","repos_url":"https://api.github.com/users/thinkpad20/repos","events_url":"https://api.github.com/users/thinkpad20/events{/privacy}","received_events_url":"https://api.github.com/users/thinkpad20/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NixOS/nixpkgs/labels/documentation","name":"documentation","color":"fef2c0"},{"url":"https://api.github.com/repos/NixOS/nixpkgs/labels/python","name":"python","color":"0b02e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-22T04:43:15Z","updated_at":"2015-05-24T09:08:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/7936","html_url":"https://github.com/NixOS/nixpkgs/pull/7936","diff_url":"https://github.com/NixOS/nixpkgs/pull/7936.diff","patch_url":"https://github.com/NixOS/nixpkgs/pull/7936.patch"},"body":"This does two primary things:\r\n\r\n1. Better documentation of `wrap.sh`. Hopefully as nix moves forward these bash incantations will start to get documented so that contributors aren't as confused as I was :grimacing: \r\n\r\n2. Adds ability to add arbitrary environment variables to be stored in the wrapping script. Rather than just `PATH` and `PYTHONPATH`, you can specify any environment variable. This is especially useful when a package will read some environment variables (e.g. configuration) at runtime, and you want to be sure it will read the right ones.\r\n\r\nExample:\r\n\r\n```nix\r\nwith import <nixpkgs> {};\r\n\r\nbuildPythonPackage {\r\n  name = \"foo-0.1.0\";\r\n  src = ./.;\r\n  setEnvVars = [\"NUM_WORKERS\" \"CONFIG_FILE_PATH\"];\r\n  NUM_WORKERS = \"4\";\r\n  CONFIG_FILE_PATH = \"./config/cfg.json\";\r\n}\r\n```\r\n\r\nThen assuming that the setup.py for `foo` builds some executable, the derivation will produce a wrapped executable with something like\r\n\r\n```bash\r\nexport PYTHONPATH=/nix/store/....\r\nexport PATH=/nix/store/.....\r\nexport NUM_WORKERS=4\r\nexport CONFIG_FILE_PATH=./config/cfg.json\r\nexec /nix/store/.../bin/.foo-wrapped \"${extraFlagsArray[@]}\" \"$@\"\r\n```\r\n\r\n@domenkozar @chaoflow "},"comment":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/comments/104995736","html_url":"https://github.com/NixOS/nixpkgs/pull/7936#issuecomment-104995736","issue_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/7936","id":104995736,"user":{"login":"domenkozar","id":126339,"avatar_url":"https://avatars.githubusercontent.com/u/126339?v=3","gravatar_id":"","url":"https://api.github.com/users/domenkozar","html_url":"https://github.com/domenkozar","followers_url":"https://api.github.com/users/domenkozar/followers","following_url":"https://api.github.com/users/domenkozar/following{/other_user}","gists_url":"https://api.github.com/users/domenkozar/gists{/gist_id}","starred_url":"https://api.github.com/users/domenkozar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenkozar/subscriptions","organizations_url":"https://api.github.com/users/domenkozar/orgs","repos_url":"https://api.github.com/users/domenkozar/repos","events_url":"https://api.github.com/users/domenkozar/events{/privacy}","received_events_url":"https://api.github.com/users/domenkozar/received_events","type":"User","site_admin":false},"created_at":"2015-05-24T09:08:36Z","updated_at":"2015-05-24T09:08:36Z","body":"@adnelson but `wrapPython` is using `makeWrapper`, hiding that away does more trouble than good. I'd really be happy to see docs about `makeWrapper` arguments"}}