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

crawl: use static config for data files #65494

Merged
merged 1 commit into from Aug 4, 2019

Conversation

virusdave
Copy link
Contributor

@virusdave virusdave commented Jul 28, 2019

This allows the game to be executed from anywhere, not just from the package /bin

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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jul 28, 2019
@ofborg ofborg bot requested a review from abbradar July 28, 2019 07:48
@worldofpeace
Copy link
Contributor

Hi @virusdave.

Would or is DATADIR not being set causing issues on linux?

This allows the game to be executed from anywhere, not just from the package /bin

Does that mean the program looks for datafiles relative to where it was executed?

@worldofpeace worldofpeace changed the title games/crawl: use static config for data files on darwin crawl: use static config for data files on darwin Jul 29, 2019
@worldofpeace
Copy link
Contributor

worldofpeace commented Jul 29, 2019

Can you also change the commit msg to what I edited the PR title to?

@virusdave
Copy link
Contributor Author

Hi @virusdave.

Would or is DATADIR not being set causing issues on linux?

Not sure. I can don't have a linux box, but i can re-read the code tonight perhaps. The program has a hardcoded set of absolute and relative paths to look for its data files. On OSX, these are "normal" locations you'd expect installed programs to live, not the nix store. The relative paths in the list are based on where the CWD was when the program was executed, not where the program actually lives on the FS.

This allows the game to be executed from anywhere, not just from the package /bin

Does that mean the program looks for datafiles relative to where it was executed?

Yes, relative to the CWD when it was executed (not where the binary itself lives, which would have also solved the problem).

@virusdave
Copy link
Contributor Author

Can you also change the commit msg to what I edited the PR title to?

Sure, i'll do this tonight and update the PR.

@virusdave
Copy link
Contributor Author

@worldofpeace I've updated the commit title.

@worldofpeace
Copy link
Contributor

Hi @virusdave.
Would or is DATADIR not being set causing issues on linux?

Not sure. I can don't have a linux box, but i can re-read the code tonight perhaps. The program has a hardcoded set of absolute and relative paths to look for its data files. On OSX, these are "normal" locations you'd expect installed programs to live, not the nix store. The relative paths in the list are based on where the CWD was when the program was executed, not where the program actually lives on the FS.

This allows the game to be executed from anywhere, not just from the package /bin

Does that mean the program looks for datafiles relative to where it was executed?

Yes, relative to the CWD when it was executed (not where the binary itself lives, which would have also solved the problem).

So I guess it would be okay to do this for linux also?

@virusdave
Copy link
Contributor Author

Yes, relative to the CWD when it was executed (not where the binary itself lives, which would have also solved the problem).

So I guess it would be okay to do this for linux also?

Ok, i've removed the conditional check for darwin on this as well. I don't have a great way to check this on linux (no linux box), but perhaps i can grab a docker image or something to test it.

@worldofpeace
Copy link
Contributor

Yes, relative to the CWD when it was executed (not where the binary itself lives, which would have also solved the problem).

So I guess it would be okay to do this for linux also?

Ok, i've removed the conditional check for darwin on this as well. I don't have a great way to check this on linux (no linux box), but perhaps i can grab a docker image or something to test it.

I'm using NixOS so I can test for you 👍

Copy link
Contributor

@worldofpeace worldofpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@virusdave This worked for me. Please squash and rephrase your commit msg.

@worldofpeace
Copy link
Contributor

worldofpeace commented Aug 4, 2019

Actually, what is the expected directory of DATADIR?
Would that be $out/share or $out/dat or is it inferred from the parent directory?

@virusdave
Copy link
Contributor Author

Tested on a nixos docker container and this works still.

@virusdave
Copy link
Contributor Author

Actually, what is the expected directory of DATADIR?
Would that be $out/share or $out/dat or is it inferred from the parent directory?

./share and ./dat (and friends) are tried relative to DATADIR.

This allows the game to be executed from anywhere, not just
the install directory in the nix store.
@virusdave
Copy link
Contributor Author

@virusdave This worked for me. Please squash and rephrase your commit msg.

Done.

@virusdave virusdave changed the title crawl: use static config for data files on darwin crawl: use static config for data files Aug 4, 2019
@worldofpeace
Copy link
Contributor

@virusdave Thanks. I'm confident we can merge this.

@worldofpeace worldofpeace merged commit df58d37 into NixOS:master Aug 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants