hyprwm / contrib

Community scripts and utilities for Hypr projects
MIT License
294 stars 39 forks source link

Revisit Makefiles #34

Closed Schievel1 closed 1 year ago

Schievel1 commented 1 year ago

According to the GNU Make manual [1] destdir should be used as the variable for the staging directory. (not prefix) While at it I also revisited all the other variables and how they are generated from destdir to stick to the GNU stardards suggestion [2].

I also added uninstall targets to the makefiles that did not have one.

I tested all the Makefiles if they install and uninstall properly. However, I adapted the .nix package recipes as well, but could not test them. This is just a guess how it should be done. So please test this thoroughly on your Nixos System before merging.

[1] https://www.gnu.org/software/make/manual/html_node/DESTDIR.html [2] https://www.gnu.org/prep/standards/html_node/Directory-Variables.html

Schievel1 commented 1 year ago

Good work on these, but in Nix, we also need PREFIX=$(out). There's no /usr or /usr/local being used in Nix, everything is at the root of the package. For example, this is the grimblast package's dir structure.

/nix/store/ynhxi9msb8a934zncvz62ns0m1n55x83-grimblast-0.1
├── bin
│   └── grimblast
└── share
    └── man
        └── man1
            └── grimblast.1.gz

Can you change those PREFIXes or should I do it?

I did not know Nix is going into the opposite direction from most other distros and their usrmerge. Where everything is in /usr/ now and /bin is just a symlink to /usr/bin.

I will change it real quick, but let me understand this first. I want learn a bit from this at least. :)

The Makefile sets PREFIX to DESTDIR/usr/local by default. (this is by convention. Those makefiles are thought of to be manually run by users. And manually installed packages go into /usr/local. For GNU make, package managers and distros are just a second thought.) I assume Nix sets out to /, so I assume DESTDIR should be set to $(out) and PREFIX as well? So PREFIX would be // and therefore DATAROOTDIR would be ///share. I think that is not the problem, since linux just ignores that extra slashes. But it would be cleaner to set DESTDIR to "" and PREFIX to "" in the Nix recipe, what do you think?

fufexan commented 1 year ago

You're absolutely right, good catch! You explaining it out loud made me see my previous comment isn't the best approach :)

Schievel1 commented 1 year ago

But I don't know how to set those variables to empty string in that .nix file.

fufexan commented 1 year ago

@Schievel1 after some testing I found out the Nix files didn't even need changing. PREFIX being set to the out path of the package is enough for it to put everything in the right place.