codedownio / julia2nix

Generate Nix expressions for building a Julia depot with a set of packages
53 stars 6 forks source link

How does it work confusion #13

Closed idontgetoutmuch closed 3 years ago

idontgetoutmuch commented 3 years ago

I read the documentation but I don't know why I still need the toml files.

dom@MacBook-Pro depot1 % o$(nix-build -I nixpkgs=/Users/dom/nixpkgs . --no-out-link)/bin/julia
$(nix-build -I nixpkgs=/Users/dom/nixpkgs . --no-out-link)/bin/julia
error: getting attributes of path '/Users/dom/Dropbox/Tidy/depot1/Manifest.toml': No such file or directory
(use '--show-trace' to show detailed location information)
zsh: no such file or directory: /bin/julia
dom@MacBook-Pro depot1 % $(nix-build -I nixpkgs=/Users/dom/nixpkgs . --no-out-link)/bin/julia
$(nix-build -I nixpkgs=/Users/dom/nixpkgs . --no-out-link)/bin/julia
error: getting attributes of path '/Users/dom/Dropbox/Tidy/depot1/Project.toml': No such file or directory
(use '--show-trace' to show detailed location information)
zsh: no such file or directory: /bin/julia
dom@MacBook-Pro depot1 % $(nix-build -I nixpkgs=/Users/dom/nixpkgs . --no-out-link)/bin/julia
$(nix-build -I nixpkgs=/Users/dom/nixpkgs . --no-out-link)/bin/julia
trace: Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `lib` instead. For more information see https://github.com/NixOS/nixpkgs/issues/108938
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.3 (2020-11-09)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |
thomasjm commented 3 years ago

They are referenced by the generated Nix derivation, specifically in common.nix. Is it a problem to include them?

GTrunSec commented 3 years ago

Do I need to write a devShell for newbie users to julia2nix frendly?

idontgetoutmuch commented 3 years ago

I was a bit suspicious that I had done something wrong and that somehow julia was just using the toml and not using nix. Looking at the output below, it still feels like that is what is happening though.

julia> using Distributions
using Distributions
ERROR: ArgumentError: Package Distributions not found in current path:
- Run `import Pkg; Pkg.add("Distributions")` to install the Distributions package.

julia> pkg"status"
pkg"status"
Status `~/.julia/environments/v1.5/Project.toml` (empty project)

julia> pkg"activate ."
pkg"activate ."
 Activating environment at `~/Dropbox/Tidy/depot/Project.toml`

julia> using Distributions
using Distributions

julia> pkg"status"
pkg"status"
Status `~/Dropbox/Tidy/depot/Project.toml`
  [31c24e10] Distributions v0.24.14
idontgetoutmuch commented 3 years ago

Do I need to write a devShell for newbie users to julia2nix frendly?

@GTrunSec if you mean me, I am not sure. What would a devShell do?

One of my problems was that julia wasn't building in nix in macos and so I had to patch the derivation and use my local nixpkgs.

GTrunSec commented 3 years ago

first, modify { pkgs ? import <nixpkgs>) { } } to { pkgs ? import (import <your local-nixpkgs path>") { } }: in default.nix

second, make sure you have done to generated packages.nix with julia2nix

third, run $(nix-build . --no-out-link)/bin/julia to enter julia

please, check ENV first, make sure you got DEPOT_PATH as following:

"JULIA_DEPOT_PATH"       => "./.julia_depot:/nix/store/w7rzd4jvhcr60j3fgy9j148vmzbhjs5f-julia-depot"

finally, activate your packages.toml in julia repl:

using Pkg
Pkg.activate(".")
using <your package>
GTrunSec commented 3 years ago

the devShell just help your https://github.com/GTrunSec/my-julia2nix-env/blob/main/shell.nix to use direnv or some commands, envrs easily and simply.

idontgetoutmuch commented 3 years ago

first, modify { pkgs ? import <nixpkgs>) { } } to { pkgs ? import (import <your local-nixpkgs path>") { } }: in default.nix

second, make sure you have done to generated packages.nix with julia2nix

third, run $(nix-build . --no-out-link)/bin/julia to enter julia

I have $(nix-build -I nixpkgs=/Users/dom/nixpkgs . --no-out-link)/bin/julia which should do the same?

GTrunSec commented 3 years ago

to { pkgs ? import (import /Users/dom/nixpkgs") { } }: then run $(nix-build . --no-out-link)/bin/julia

idontgetoutmuch commented 3 years ago

please, check ENV first, make sure you got DEPOT_PATH as following:

"JULIA_DEPOT_PATH"       => "./.julia_depot:/nix/store/w7rzd4jvhcr60j3fgy9j148vmzbhjs5f-julia-depot"

I have "JULIA_DEPOT_PATH" => "/Users/dom/.julia:/nix/store/pcsy2x5wivay4fhzk2gm6qiggq29pds6-julia-depot" so it looks like it is working :-) thanks for your help

thomasjm commented 3 years ago

Cool, glad things are working. Is there anything else needed on this issue? I didn't totally understand the devShell suggestion so not sure if any action items are desired there.

idontgetoutmuch commented 3 years ago

I think we can close this.