How to get the name from a nixpkgs derivation in a nix expression to be used by nix-shell? -
i'm writing .nix expression used nix-shell
. i'm not sure how that. note not on nixos, don't think relevant.
the particular example i'm looking @ want this version-dependent name looks like:
idea-ultimate = buildidea rec { name = "idea-ultimate-${version}"; version = "2017.2.2"; /* updated script */ description = "integrated development environment (ide) jetbrains, requires paid license"; license = stdenv.lib.licenses.unfree; src = fetchurl { url = "https://download.jetbrains.com/idea/ideaiu-${version}-no-jdk.tar.gz"; sha256 = "b8eb9d612800cc896eb6b6fbefbf9f49d92d2350ae1c3c4598e5e12bf93be401"; /* updated script */ }; wmclass = "jetbrains-idea"; update-channel = "idea_release"; };
my nix expression following:
let pkgs = import <nixpkgs> {}; stdenv = pkgs.stdenv; # idea_name = assert pkgs.jetbrains.idea-ultimate.name != ""; pkgs.jetbrains.idea-ultimate.name; in rec { scalaenv = stdenv.mkderivation rec { name = "scala-env"; builder = "./scala-build.sh"; shellhook = '' alias cls=clear ''; clang_path = pkgs.clang + "/bin/clang"; clangpp_path = pkgs.clang + "/bin/clang++"; # bug in nixpkgs openjdk (#29151) makes resort zulu openjdk idea: # idea_jdk = pkgs.openjdk + "/lib/openjdk"; # path = "${pkgs.jetbrains.idea-ultimate}/${idea_name}/bin:$path"; idea_jdk = /usr/lib/jvm/zulu-8-amd64; # idea_jdk = /opt/zulu8.23.0.3-jdk8.0.144-linux_x64; # idea_jdk = /usr/lib/jvm/java-8-openjdk-amd64; buildinputs = pkgs; [ ammonite boehmgc clang emacs jetbrains.idea-ultimate less libunwind openjdk re2 sbt stdenv unzip zlib ]; }; }
i have commented out setting path
depends on getting idea_name
in let
-clause. interesting side note, is, not fail if leave uncommented causes bizarre error when executing nix-shell
not being able execute bash
. i've tried more simple case of let
idea_name = pkgs.jetbrains.idea-ultimate.name;
fails later on when idea_name
used in setting path
since idea_name
ends being undefined.
update:
i began exploring nix-instantiate
, derivation of interest seems empty:
[nix-shell:/nix/store]$ nix-instantiate --eval --xml -e "((import <nixpkgs> {}).callpackage ./3hk87pqgl2qdqmskxbhy23cyr24q8g6s-nixpkgs-18.03pre114739.d0d905668c/nixpkgs/pkgs/applications/editors/jetbrains { }).idea-ultimate"; <?xml version='1.0' encoding='utf-8'?> <expr> <derivation> <repeated /> </derivation> </expr>
if intent idea-ultimate
nix-shell environment, include package buildinputs
. see it's included, should present in path
.
btw, can extend shellhook
, export path , other variables rather there, have full bash. why bash? less copying. when specify
idea_jdk = /usr/lib/jvm/zulu-8-amd64;
in nix, file /usr/lib/jvm/zulu-8-amd64 get's copied nix store , idea_jdk
set point file in /nix/store
. intent?
regarding nix-instantiate:
$ nix-instantiate --eval -e 'with import <nixpkgs>{}; idea.pycharm-community.outpath' "/nix/store/71jk0spr30rm4wsihjwbb1hcwwvzqr4k-pycharm-community-2017.1"
but still have remove doublequotes (https://gist.github.com/danbst/a9fc068ff26e31d88de9709965daa2bd)
also, nitpick, assert pkgs.jetbrains.idea-ultimate.name != "";
can dropped it's impossible have empty derivation name in nix.
and nitpick. you'll find incovenient launch ide shell every time. seems idea specify, package used development, nix-shell
doesn't work non-cli applications. not mention occasional problems nix gc , nix-shell
. you'd better install ide globally or per-user, better long-term solution.
[addendum]
you looking (dev-environment.nix
):
with import <nixpkgs> { }; buildenv { name = "my-super-dev-env"; paths = [ #emacs nano idea.pycharm-community ]; buildinputs = [ makewrapper ]; postbuild = '' f in $(ls -d $out/bin/*); wrapprogram $f \ --set idea_jdk "/path/to/zulu-jdk" \ --set clang_path ... \ --set clancpp_path ... done ''; }
which install using nix-env -if ./dev-environment.nix
. wrap programs env vars, without polluting workspace (you can pollute further using nix-shell
shell hook, if want).
Comments
Post a Comment