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

Do not set DESTDIR in makeFlags #65718

Open
jtojnar opened this issue Aug 1, 2019 · 13 comments
Open

Do not set DESTDIR in makeFlags #65718

jtojnar opened this issue Aug 1, 2019 · 13 comments

Comments

@jtojnar
Copy link
Member

jtojnar commented Aug 1, 2019

DESTDIR is used by some package managers as a poor man’s sandbox, transparent to the package. Setting DESTDIR=$(out) PREFIX= in makeFlags
will place the files in the correct directory but the program itself will not be aware of the files’ location. For example, if the source code is hardcoding PREFIX "foo", it will try to open foo instead of $out/foo.

This is usually done when make install tries to create a $(DESTDIR)/var directory but as described above, it can have a negative side effect.

With autotools you can set installFlags = [ "localstatedir=${placeholder "out"}/var" ]; or installFlags = [ "sysconfdir=${placeholder "out"}/etc" ]; that should fix most instances of the issue. When the project using hand-written Makefiles, you need to check the files to see how to replace them. In the worst case, especially when the paths are hard-coded in the build files, you will need to patch the build files.

@matthewbauer
Copy link
Member

matthewbauer commented Aug 1, 2019

Some documentation on this could also go a long way. I've written up some basic docs:


The global configure policy of Nixpkgs (which should be set for you when using autotools, but not necessarily other build systems) is:

  • prefix: "$(out)"
  • destdir: ""
  • sysconfdir: "/etc"
  • localstatedir: "/var"
  • disable static, enable shared

It's a fairly common mistake to do DESTDIR=$(out) PREFIX=$(out), which is incorrect and ends up getting you a directory structure that looks like /nix/store/...-.../nix/store/...-.../....

To make sure installation happens correctly, you sometimes have to override make install flags like so:

installFlags = [ "sysconfdir=$(out)/etc" "localstatedir=$out/var" ];

@mmahut mmahut mentioned this issue Aug 27, 2019
10 tasks
@jtojnar jtojnar mentioned this issue Nov 28, 2019
10 tasks
jtojnar added a commit to jtojnar/nixpkgs that referenced this issue Dec 30, 2019
jtojnar added a commit to jtojnar/nixpkgs that referenced this issue Dec 30, 2019
@jtojnar jtojnar mentioned this issue Mar 30, 2020
10 tasks
@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@jtojnar
Copy link
Member Author

jtojnar commented Jun 2, 2020

This is a best practices issue, we still need to find a better place for it.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@jtojnar jtojnar mentioned this issue Oct 5, 2020
10 tasks
@stale
Copy link

stale bot commented Nov 29, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 29, 2020
@AndersonTorres
Copy link
Member

Is this sprintable?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 20, 2021
@jtojnar
Copy link
Member Author

jtojnar commented Feb 20, 2021

Yes. Each expression needs to be evaluated separately so the labour can be divided.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/creating-my-first-package-i3-gnome-in-nixos/10474/4

@jonringer
Copy link
Contributor

Can we update the nixpkgs manual to include this under the https://nixos.org/manual/nixpkgs/stable/#var-stdenv-makefile section and close this issue?

It would also be a lot more discoverable

@jtojnar jtojnar mentioned this issue Aug 30, 2021
12 tasks
@figsoda figsoda mentioned this issue Oct 4, 2021
12 tasks
@stale
Copy link

stale bot commented Apr 29, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 29, 2022
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/import-problems-creating-a-new-package-45drives-autotier/22035/6

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 28, 2022
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/import-problems-creating-a-new-package-45drives-autotier/22035/7

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/compile-openssl-with-nix-pkgs/37289/2

@NickCao NickCao mentioned this issue Dec 24, 2023
13 tasks
@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Dec 26, 2023

Can someone help me with waydroid/waydroid#1218 ?

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

No branches or pull requests

7 participants