diff --git a/examples/julia/minimal/default.nix b/examples/julia/minimal/default.nix index 0396d1d8..0f768b2e 100644 --- a/examples/julia/minimal/default.nix +++ b/examples/julia/minimal/default.nix @@ -1,5 +1,8 @@ {pkgs, ...}: { kernel.julia.minimal-example = { enable = true; + extraJuliaPackages = [ + "Plots" + ]; }; } diff --git a/examples/julia/minimal/installDeps.jl b/examples/julia/minimal/installDeps.jl deleted file mode 100644 index 5932548f..00000000 --- a/examples/julia/minimal/installDeps.jl +++ /dev/null @@ -1,2 +0,0 @@ -using Pkg -Pkg.add("IJulia") diff --git a/examples/python/native/default.nix b/examples/python/native/default.nix index 5f4d6e1b..474c11e3 100644 --- a/examples/python/native/default.nix +++ b/examples/python/native/default.nix @@ -1,5 +1,5 @@ {pkgs, ...}: { - kernel.python.science-example = { + kernel.python.native-example = { enable = true; env = pkgs.python3.withPackages (ps: with ps; [ diff --git a/examples/python/native/test.py b/examples/python/native/test.py index dee85abe..952794b7 100644 --- a/examples/python/native/test.py +++ b/examples/python/native/test.py @@ -3,7 +3,7 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) -@testbook(f'{current_dir}/test.ipynb', execute=True, kernel_name="python-science-example") +@testbook(f'{current_dir}/test.ipynb', execute=True, kernel_name="python-native-example") def test_nb(tb): np_result = tb.cell_output_text(1) assert np_result == "[0 1 2 3 4]" diff --git a/flake.lock b/flake.lock index bd17fe60..57a520aa 100644 --- a/flake.lock +++ b/flake.lock @@ -244,6 +244,22 @@ "type": "github" } }, + "nixpkgs-julia": { + "locked": { + "lastModified": 1694073329, + "narHash": "sha256-F6+k1FSgtFSXaGSQqf00u/jBHhvUvrsTx9qjEWAk0E0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ddadf5f46ac96423efbd67228ffe84361743c253", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "refs/pull/225513/head", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1695825837, @@ -492,6 +508,7 @@ "ihaskell": "ihaskell", "nix-dart": "nix-dart", "nixpkgs": "nixpkgs_2", + "nixpkgs-julia": "nixpkgs-julia", "nixpkgs-stable": "nixpkgs-stable", "npmlock2nix": "npmlock2nix", "opam-nix": "opam-nix", diff --git a/flake.nix b/flake.nix index f3186c50..385aa576 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,7 @@ inputs.nixpkgs.url = "github:nixos/nixpkgs/2de8efefb6ce7f5e4e75bdf57376a96555986841"; inputs.nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05"; + inputs.nixpkgs-julia.url = "github:NixOS/nixpkgs/?ref=refs/pull/225513/head"; inputs.flake-compat.url = "github:edolstra/flake-compat"; inputs.flake-compat.flake = false; inputs.flake-utils.url = "github:numtide/flake-utils"; @@ -49,7 +50,8 @@ pre-commit-hooks, poetry2nix, rust-overlay, - }: let + ... + } @ inputs: let inherit (nixpkgs) lib; SYSTEMS = [ diff --git a/modules/kernels/julia/default.nix b/modules/kernels/julia/default.nix index 011de9e0..252652fb 100644 --- a/modules/kernels/julia/default.nix +++ b/modules/kernels/julia/default.nix @@ -20,28 +20,25 @@ self, system, # custom arguments - pkgs ? self.inputs.nixpkgs.legacyPackages.${system}, + pkgs, name ? "julia", displayName ? "Julia", requiredRuntimePackages ? [], runtimePackages ? [], julia ? pkgs.julia, - julia_depot_path ? "~/.julia", - activateDir ? "", - ijuliaRev ? "6TIq1", + ijuliaRev ? "Vo51o", + extraJuliaPackages ? [], + override ? {}, }: let inherit (pkgs) writeText; inherit (pkgs.lib) optionalString; - startupFile = writeText "startup.jl" '' - import Pkg - Pkg.activate("${activateDir}") - Pkg.instantiate() - ''; - allRuntimePackages = requiredRuntimePackages ++ runtimePackages; - env = julia; + env = (self.inputs.nixpkgs-julia.legacyPackages.${system}.julia_19.withPackages.override override) ([ + "IJulia" + ] + ++ extraJuliaPackages); wrappedEnv = pkgs.runCommand "wrapper-${env.name}" @@ -52,7 +49,7 @@ filename=$(basename $i) ln -s ${env}/bin/$filename $out/bin/$filename wrapProgram $out/bin/$filename \ - --set PATH "${pkgs.lib.makeSearchPath "bin" allRuntimePackages}" ${optionalString (activateDir != "") ''--add-flags "-L ${startupFile}"''} + --set PATH "${pkgs.lib.makeSearchPath "bin" allRuntimePackages}" done ''; in { @@ -63,7 +60,7 @@ "-i" "--startup-file=yes" "--color=yes" - "${julia_depot_path}/packages/IJulia/${ijuliaRev}/src/kernel.jl" + "${env.projectAndDepot}/depot/packages/IJulia/${ijuliaRev}/src/kernel.jl" "{connection_file}" ]; codemirrorMode = "julia"; @@ -72,37 +69,32 @@ in { options = { - julia_depot_path = lib.mkOption { + ijuliaRev = lib.mkOption { type = types.str; - default = "~/.julia"; - example = "~/.julia"; + default = "Vo51o"; description = lib.mdDoc '' - Julia path + IJulia revision ''; }; - - activateDir = lib.mkOption { - type = types.str; - default = ""; - example = ""; + julia = lib.mkOption { + type = types.package; + default = config.nixpkgs.julia; description = lib.mdDoc '' - Julia activate directory + Julia Version ''; }; - - ijuliaRev = lib.mkOption { - type = types.str; - default = "6TIq1"; - example = "6TIq1"; + extraJuliaPackages = lib.mkOption { + type = types.listOf types.str; + default = []; description = lib.mdDoc '' - iJulia revision + Extra Julia packages to install ''; }; - julia = lib.mkOption { - type = types.package; - default = config.nixpkgs.julia; + override = lib.mkOption { + type = types.attrs; + default = {}; description = lib.mdDoc '' - Julia Version + Override JuliaWithPackages ''; }; } @@ -112,7 +104,7 @@ build = mkKernel (kernelFunc config.kernelArgs); kernelArgs = { - inherit (config) julia_depot_path activateDir ijuliaRev julia; + inherit (config) override extraJuliaPackages ijuliaRev julia; } // kernelModule.kernelArgs; };