Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awesome: refactor LUA_PATH env var and don't expose it at runtime #60329

Merged
merged 1 commit into from Apr 28, 2019
Merged

awesome: refactor LUA_PATH env var and don't expose it at runtime #60329

merged 1 commit into from Apr 28, 2019

Conversation

stefano-m
Copy link
Contributor

Cc: @dtzWill

This commit partly reinstates changes from 5465d6f that had been somehow
reverted in 17d3eb2. Also, a comment has been added in the hope that future
changes won't do the same.

Additionally, refactor the LUA_PATH env var to ensure that the internal lgi lua
files can't be required explicitly and to avoid possible name clashes (this
fixes issue #60232).

Finally, rather than using prepending ?.lua append ;; to LUA_PATH. Quoting
@psychon:

This is interpreted by Lua as "add the default search path here" (which does
indeed contain ?.lua, but also contains more).

Testing done:

  • Build with nix-build -I /path/to/repo -A awesome
  • Start an X session with xterm only
  • Start xephyr, e.g. Xephyr :1 -name xephyr -screen 512x384 -ac -br -noreset &
  • Run awesome like DISPLAY=:1.0 ./result/bin/awesome. Additionally, add
    --search options to expose lua modules that have a name clash with lgi's
    internal ones (see NixOS 19.03: Awesome Window Manager exposes lgi incorrectly in its LUA_PATH (regression) #60232 for more details) and require them in rc.lua to
    prove that they are loaded correctly
Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This commit partly reinstates changes from 5465d6f that had been somehow
reverted in 17d3eb2.  Also, a comment has been added in the hope that future
changes won't do the same.

Additionally, refactor the LUA_PATH env var to ensure that the internal lgi lua
files can't be required explicitly and to avoid possible name clashes (this
fixes issue #60232).

Finally, rather than using prepending `?.lua` append `;;` to LUA_PATH. Quoting
@psychon:

> This is interpreted by Lua as "add the default search path here" (which does
> indeed contain ?.lua, but also contains more).

Testing done:

- Build with `nix-build -I /path/to/repo -A awesome`
- Start an X session with xterm only
- Start xephyr, e.g. `Xephyr :1 -name xephyr -screen 512x384 -ac -br -noreset &`
- Run awesome like `DISPLAY=:1.0 ./result/bin/awesome`. Additionally, add
  `--search` options to expose lua modules that have a name clash with lgi's
  internal ones (see #60232 for more details) and `require` them in `rc.lua` to
  prove that they are loaded correctly
@stefano-m
Copy link
Contributor Author

nix-shell -p nix-review --run "nix-review pr 60329"
$ git fetch --force https://github.com/NixOS/nixpkgs master:refs/nix-review/0 pull/60329/head:refs/nix-review/1
From https://github.com/NixOS/nixpkgs
 * [new ref]             refs/pull/60329/head -> refs/nix-review/1
$ git worktree add /home/stefano/.cache/nix-review/pr-60329/nixpkgs 028119189dbebef0563afa73352ac96e75232c3b
Preparing worktree (detached HEAD 028119189)
Checking out files: 100% (18946/18946), done.
HEAD is now at 028119189 vimPlugins: update (#60325)
$ nix-env -f /home/stefano/.cache/nix-review/pr-60329/nixpkgs -qaP --xml --out-path --show-trace
$ git merge --no-commit c973e15fb6f54f5d1bc783dddfeddd59ba664226
Automatic merge went well; stopped before committing as requested
$ nix-env -f /home/stefano/.cache/nix-review/pr-60329/nixpkgs -qaP --xml --out-path --show-trace --meta
$ nix build --no-link --keep-going --max-jobs 4 --option build-use-sandbox true -f /home/stefano/.cache/nix-review/pr-60329/build.nix
[1 built, 0.0 MiB DL]
https://github.com/NixOS/nixpkgs/pull/60329
1 package were build:
awesome

[0.0 MiB DL]
$ nix-shell /home/stefano/.cache/nix-review/pr-60329/shell.nix
these paths will be fetched (1.50 MiB download, 8.26 MiB unpacked):
  /nix/store/1gw1mzd1dgxv9jl9292cy89agkn6igcw-bash-interactive-4.4-p23-dev
  /nix/store/379yd8pmrr4c6i6gsacyds8k46n0p047-bash-interactive-4.4-p23-info
  /nix/store/bv1fz2naz0byqy8j6d8bfjxiybq36d20-bash-interactive-4.4-p23-doc
  /nix/store/ds68m7w92kxc16x5xskndx8g53jc0iqs-readline-7.0p5
  /nix/store/jx8g6cjv2y5rs69ym08b0pj3ngxvnhhg-bash-interactive-4.4-p23
  /nix/store/ybq0y45n1ksgv5wiqmb9823jjbwa8a9y-bash-interactive-4.4-p23-man
copying path '/nix/store/bv1fz2naz0byqy8j6d8bfjxiybq36d20-bash-interactive-4.4-p23-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/379yd8pmrr4c6i6gsacyds8k46n0p047-bash-interactive-4.4-p23-info' from 'https://cache.nixos.org'...
copying path '/nix/store/ybq0y45n1ksgv5wiqmb9823jjbwa8a9y-bash-interactive-4.4-p23-man' from 'https://cache.nixos.org'...
copying path '/nix/store/ds68m7w92kxc16x5xskndx8g53jc0iqs-readline-7.0p5' from 'https://cache.nixos.org'...
copying path '/nix/store/jx8g6cjv2y5rs69ym08b0pj3ngxvnhhg-bash-interactive-4.4-p23' from 'https://cache.nixos.org'...
copying path '/nix/store/1gw1mzd1dgxv9jl9292cy89agkn6igcw-bash-interactive-4.4-p23-dev' from 'https://cache.nixos.org'...

[nix-shell:~/.cache/nix-review/pr-60329]$

@dtzWill
Copy link
Member

dtzWill commented Apr 28, 2019

LGTM, thanks!

@dtzWill dtzWill merged commit 5f7f4e3 into NixOS:master Apr 28, 2019
@stefano-m
Copy link
Contributor Author

Thanks @dtzWill. Is there anything I can do to port this to the 19.03 branch?

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

Successfully merging this pull request may close these issues.

None yet

2 participants