I am sure this information is somewhere but I guess I just don’t know the terminology well enough to find it, so my apologies for asking again. My current configuration is NixOS v24.1 w/ Home-Manager. I want to use version 7+ of PMD which is currently only at version 6.5 in the nixos repository. I have tried many ways to make this happen but I either get an error building from the source code, or version 6.5 still ends up getting installed. This is the latest attempt. I don’t get an error but it isn’t installed either. After running nixos-rebuild switch with this configuration, there is no problem with the rebuild. Trying to run pmd from the command line states it is not in the current path so run nix-shell -p pmd.So, if I run that command, I get PMD but version 6.5. This is giving me nixos hair…
Are you sure you have not mentioned the original pkgs.pmd anywhere else in your configuration? Maybe hidden behind other options?
PS: Please used markdown indended or fenced codeblocks for easier to copy and easier to read code. Fenced code can even provide code highlighting (in theory, it seems the relevant plugins and highlighters are not aactive in this forum):
Sorry, yes, it is NixOS 24.11 not 24.1.
So, I have removed the previous code and just added the package to configuration.nix. Pmd is only present in the file in this location. I have run the following commands to clean things out.
nix-store --gc
I removed all references to pmd from configuration.nix and ran nixos-rebuild switch.
I confirmed that pmd is no longer accessible by running it from the command line.
I added pmd back to configuration.nix. It now looks like this:
environment.systemPackages = with pkgs; [
maven
vim
pkgs.docker
pkgs.docker-compose
nodePackages.node2nix
pkgs.pmd
];
ran nixos-rebuild switch and then ran pmd --version from the command line which returned
PMD 6.5.5.0
Looking at search.nixos.org for PMD only shows 6.5.5. So how are you getting 7+ for a version?
It should return 6.55.0 not 6.5.5.0, but anyway, that’s tangential to your actual question.
You’ll have to override the src:
This is a good start, unfortunately pmd in nixpkgs isn’t built from source, so this won’t work as-is.
Instead of fetchFromGitHub, try using fetchurl as the pmd expression in nixpkgs does:
install: cannot stat 'bin/run.sh': No such file or directory
error: builder for '/nix/store/nayjw1w4wn41fn263pz6g6118wwgg8ii-pmd-6.55.0.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/0r9knn8djs66ij2y5sjxjxpc3b84vx79-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3wb9mgz0jiqgdx3aqld1sdrrk92wi07c-nixos-system-nixos-24.11.710315.b681065d0919.drv' failed to build
In that case I’ve no idea, I’m not familiar with the package. If you can’t figure it out, feel free to post an update request on the nixpkgs repo and tag the maintainers.
If you pull that package down and poke a bit you’ll see it looks like they renamed run.sh to just pmd:
❯ unzip -t pmd-dist-7.10.0-bin.zip pmd-bin-7.10.0/bin/*
Archive: pmd-dist-7.10.0-bin.zip
testing: pmd-bin-7.10.0/bin/ OK
testing: pmd-bin-7.10.0/bin/pmd.bat OK
testing: pmd-bin-7.10.0/bin/pmd OK
No errors detected in pmd-dist-7.10.0-bin.zip for the 3 files tested.
❯ file pmd
pmd: Bourne-Again shell script, ASCII text executable
So the installPhase of the nixpkg needs to copy this file instead of run.sh:
Thanks. I just actually figured this out this morning. Too bad that NixOS doesn’t really have good information on situations like this which details how packages are installed. Basically, the PMD package is already in a standard format suitable for use in the NixOS store. Understanding what NixOS did with the files from a zip or a tar file was fundamental to understanding how to solve this problem. This is how I understand NixOS handles packages:
NixOS creates a store.
The store contains a typical Linux file structure for any application or project with a bin, a lib and a conf.
NixOS when it installs a package, it opens up the archive and moves the files into a directory that it manages but expects the structure to match what is expected.
NixOS automatically adds the path to the users environment to correspond to the bin directory for this store depending on the choosen configuration.
NixOS configuration.nix file provides a method to override the installation, build and unpackaging phases with script commands that can be used when the package does not conform to the expected norm.