Hi All
I am new to nix. Here is what I want to do:
- Specify a list of packages for setting up environment for say Java (tools like gradle, JDK, maven etc).
- Then I want to do a
nix build
and get the symlink to the resulting nix store. - I want to use that link for later purpose whenever I want to do Java dev.
Here is what I have tried:
- Read about flakes. I understand nix flakes is the recommended way.
- Tried
devshells
within flake. It does provide me with a shell of the Java tools when I donix develop
- But I dont want a shell right away. Rather I want to keep the Java environment somewhere, and load it on demand (when I want to do Java dev). Likewise, I may want to switch to say a NodeJS env.
Below is the nix flake I wrote. Its pretty basic, but I get an error when I do a nix build
.
{
description = "Java dependencies";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
outputs = { self, nixpkgs }: {
packages.x86_64-linux.default =
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "java";
src = self;
buildInputs = [
git
temurin-bin-17
];
};
};
}
The error when I do a nix build
is:
builder for '/nix/store/6kqidjixlygm71sk84lg15bcrpgbxnm2-java.drv' failed to produce output path for output 'out' at '/nix/store/6kqidjixlygm71sk84lg15bcrpgbxnm2-java.drv.chroot/nix/store/cqss3a495m9ihs27yzh0gzvr878ixma5-java'
I have used devshells and it works - but I dont want a shell immediately. Rather I want to load the java env based on the symlink produced by nix build… Alternatively can I use nix profile
for this? I am thinking I can maybe have a separate profile for Java environment, and separate for Nodejs and so on…
Someone experienced with nixpkgs please help (I am on a NonNix OS)…
Thanks
Chetan