nix-darwin icon indicating copy to clipboard operation
nix-darwin copied to clipboard

Can't install JDK on macOS

Open gentcys opened this issue 3 years ago • 4 comments

~/.nixpkgs/darwin-configuration.nix:

{ config, pkgs, ... }:

{
  # List packages installed in system profile. To search by name, run:
  # $ nix-env -qaP | grep wget
  nix.package = pkgs.nix;
  nixpkgs.config.allowUnfree = true;
  environment.systemPackages = with pkgs; [
    curl
    vim
    aria2
    ccls
    cmake
    cunit
    dbus
#    e2fsprogs
    exiftool
    gcc
    git
    git-lfs
    gnused
    gnupg

    # Go
    go
#    graphicsmagick
#    graphviz
#    helm
#    heroku
#    apacheHttpd
#    imagemagick
    jansson
    jq
#    gitAndTools.lefthook
    nodejs
    lua
    mailutils
#    maven
    mbedtls
    mcrypt
    minio
    yarn
#    jdk11
    jdk
    openssl
#    pinentry_mac
#    postgresql_12
    ripgrep
    runit
    sqlite
#    firefox
#    iterm2
#    google-chrome
#    jetbrains.idea-community
  ];

  # Use a custom configuration.nix location.
  # $ darwin-rebuild switch -I ddarwin-systemarwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
  # environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
  environment.variables = {
    # General
    EDITOR = "vim";
  };

  # Auto upgrade nix package and the daemon service.
  services.nix-daemon.enable = true;
  # nix.package = pkgs.nix;

  environment.shells = ["/run/current-system/sw/bin/zsh"];
  # Create /etc/bashrc that loads the nix-darwin environment.
  # default shell on catalina
  programs.zsh = {
    enable = true;
    enableCompletion = true;
    enableBashCompletion = true;
    enableFzfHistory = true;
    enableSyntaxHighlighting = true;
    promptInit = "autoload -Uz promptinit && promptinit";
  };

  programs.tmux = {
    enable = true;
    enableVim = true;
    extraConfig = "~/.tmux.conf";
  };

  # Used for backwards compatibility, please read the changelog before changing.
  # $ darwin-rebuild changelog
  system.stateVersion = 4;
}

failed log:

➜  ~ darwin-rebuild switch                                                                                                                                                                                                            ~
building the system configuration...
these derivations will be built:
  /nix/store/rwxb5ppcl4dgv46xknnmg4cj38dcfqp9-system-path.drv
  /nix/store/i3yc4fm613gjg9yfhmmvf1l6vrhcqz39-darwin-system-21.05pre281670.842f900e73c+darwin4.0000000.drv
building '/nix/store/rwxb5ppcl4dgv46xknnmg4cj38dcfqp9-system-path.drv'...
Use of uninitialized value $stat2 in numeric ne (!=) at /nix/store/vg1f180bvkk5ijmcfwflp8cwnf59al1r-builder.pl line 94.
Use of uninitialized value $stat1 in numeric ne (!=) at /nix/store/vg1f180bvkk5ijmcfwflp8cwnf59al1r-builder.pl line 94.
collision between `/nix/store/m2b1pdx0wf00sv01xw1shy5nscmk8fyl-zulu15.28.51-ca-jdk-15.0.1/share/man' and `'
builder for '/nix/store/rwxb5ppcl4dgv46xknnmg4cj38dcfqp9-system-path.drv' failed with exit code 2
cannot build derivation '/nix/store/i3yc4fm613gjg9yfhmmvf1l6vrhcqz39-darwin-system-21.05pre281670.842f900e73c+darwin4.0000000.drv': 1 dependencies couldn't be built
error: build of '/nix/store/i3yc4fm613gjg9yfhmmvf1l6vrhcqz39-darwin-system-21.05pre281670.842f900e73c+darwin4.0000000.drv' failed

gentcys avatar Apr 19 '21 07:04 gentcys

I have the exact same issue (m1 here).

rubas avatar Apr 29 '21 18:04 rubas

Same issue here. Didn't work with different version of jdk.

winston0410 avatar Aug 03 '21 11:08 winston0410

Suspiciously, the builder complains of a collision with an empty target. I think this might have to do with the fact that in jdk's sourceman is a symlink itself. Maybe the symlinks are not followed deeply by builder.pl?

ggPeti avatar Aug 15 '21 02:08 ggPeti

@gentcys I believe this can be closed, as the issue is with the package, not nix-darwin. The error messages are indeed confusing, but that has been fixed in nixpkgs - see https://github.com/NixOS/nixpkgs/pull/134215.

A workaround is to use (jdk.overrideAttrs (_: { postPatch = "rm man; ln -s ../zulu-15.jdk/Contents/Home/man man"; })) instead of jdk.

A similar problem was fixed for the jdk11 package: https://github.com/NixOS/nixpkgs/pull/133806

ggPeti avatar Aug 16 '21 10:08 ggPeti