0

我在尝试构建一个环境时遇到以下冲突错误,据我所知,该环境不应该发生冲突(在这种情况下,scala-env 依赖于ideaLocal,所以它不应该与它冲突):

...
idea-IU-172.4155.36/bin/libyjpagent-linux.so
idea-IU-172.4155.36/bin/libyjpagent-linux64.so
idea-IU-172.4155.36/help/ideahelp.jar
idea-IU-172.4155.36/lib/libpty/linux/x86/libpty.so
idea-IU-172.4155.36/lib/libpty/linux/x86_64/libpty.so
idea-IU-172.4155.36/bin/format.sh
idea-IU-172.4155.36/bin/fsnotifier
idea-IU-172.4155.36/bin/fsnotifier-arm
idea-IU-172.4155.36/bin/fsnotifier64
idea-IU-172.4155.36/bin/idea.sh
idea-IU-172.4155.36/bin/inspect.sh
idea-IU-172.4155.36/bin/printenv.py
idea-IU-172.4155.36/bin/restart.py
building path(s) ‘/nix/store/29g92lnpi0kywy9x7vcgl9yivwa2blm6-scala-env’
created 696 symlinks in user environment
building path(s) ‘/nix/store/qrnbff8nhpmxlzkmv508aymz5razbhgf-user-environment’
Wide character in die at /nix/store/64jc9gd2rkbgdb4yjx3nrgc91bpjj5ky-buildenv.pl line 79.
collision between ‘/nix/store/75sz9nklqmrmzxvf0faxmf6zamgaznfv-idea-local/bin/idea’ and ‘/nix/store/29g92lnpi0kywy9x7vcgl9yivwa2blm6-scala-env/bin/idea’; use ‘nix-env --set-flag priority NUMBER PKGNAME’ to change the priority of one of the conflicting packages
builder for ‘/nix/store/8hp5kdicxy9i02fa07vx85p1gvh4i1bq-user-environment.drv’ failed with exit code 255
error: build of ‘/nix/store/8hp5kdicxy9i02fa07vx85p1gvh4i1bq-user-environment.drv’ failed

这是 nix 表达式(大部分可以忽略,但不会太长,所以我会粘贴整个内容):

with import <nixpkgs> { };
let
  ideaLocal = stdenv.mkDerivation {
    name = "idea-local";
    buildInputs =  [ ];
    builder = builtins.toFile "builder.sh" ''
      source $stdenv/setup
      mkdir -p $out/bin
      tar zxvf $src -C $out/
      ln -sf $out/idea-IU* $out/idea
      ln -sf $out/idea/bin/idea.sh $out/bin/idea
    '';
    shellHook = ''
      IDEA_JDK=/usr/lib/jvm/zulu-8-amd64
    '';
    src = fetchurl {
      url = https://download.jetbrains.com/idea/ideaIU-2017.2.4-no-jdk.tar.gz;
      sha256 = "15a4799ffde294d0f2fce0b735bbfe370e3d0327380a0efc45905241729898e3";
    };
    priority = 5;
  };
in
buildEnv {
  name = "scala-env";                                                                                                                                                                                                                                                                                                                                                        
  paths = [                                                                                                                                                                                                                                                                                                                                                                  
    ammonite                                                                                                                                                                                                                                                                                                                                                                 
    boehmgc
    clang
    dbus # needed non-explicitly by vscode
    emacs
    git
    # idea.idea-ultimate # disabled temporarily
    ideaLocal
    less
    libunwind
    openjdk
    openssh
    re2
    rsync
    sbt
    stdenv
    syncthing # for syncrhonizing data between containers
    tmux
    unzip
    vscode
    zlib
  ];
  # builder = builtins.toFile "builder.sh" ''
  #   source $stdenv/setup
  #   mkdir -p $out
  #   echo "" > $out/Done
  #   echo "Done setting up Scala environment."
  # '';
  buildInputs = [ makeWrapper ];                                                                                                                                                                                                                                                                                                                                             
  # TODO: better filter, use ammonite script?:
  postBuild = ''
  for f in $(ls -d $out/bin/* | grep "idea"); do
    sed -i '/IDEA_JDK/d' $f
    wrapProgram $f \
      --set IDEA_JDK "/usr/lib/jvm/zulu-8-amd64" \
      --set CLANG_PATH "${clang}/bin/clang" \
      --set CLANCPP_PATH "${clang}/bin/clang++"
    done
  '';

}

编辑

(DevContainer)which idea
/home/brandon/.nix-profile/bin/idea
(DevContainer)ls -last /home/brandon/.nix-profile/bin/idea
4 lrwxrwxrwx 1 brandon brandon 63 Jan  1  1970 /home/brandon/.nix-profile/bin/idea -> /nix/store/75sz9nklqmrmzxvf0faxmf6zamgaznfv-idea-local/bin/idea

所以它看起来像是ideaLocal作为一个环境被导入 - 将它安装为依赖于的包的正确方法是scalaEnv什么?

4

1 回答 1

0

显然,解决方案是指定配置文件,我认为它是环境的名称,这样两个环境就不会同时安装:

nix-env -if scala-default.nix -p scala-env
于 2017-09-19T14:57:16.083 回答