diff --git a/codedown.nix b/codedown.nix index b9d37470..ed9c6fcc 100644 --- a/codedown.nix +++ b/codedown.nix @@ -74,10 +74,7 @@ rec { languages = languagesFn false; languagesSearcher = common.searcher' { - packages = let - filterOverrideKeys = lib.filterAttrs (k: _: !(lib.hasPrefix "override") k); - in - filterOverrideKeys (lib.mapAttrs (n: v: v.build {}) (languagesFn true)); + packages = languagesFn true; }; languagesIcons = common.searcherIcons' { packages = languagesFn true; diff --git a/codedown/mkCodeDownEnvironment.nix b/codedown/mkCodeDownEnvironment.nix index 4ecf8cdd..cc80d361 100644 --- a/codedown/mkCodeDownEnvironment.nix +++ b/codedown/mkCodeDownEnvironment.nix @@ -22,7 +22,7 @@ let languagesCommon = callPackage ../languages/common.nix {}; shellsCommon = callPackage ../shells/common.nix {}; - builtKernels = map (x: let kernel = (getAttr x.name languages).build x.args; in + builtKernels = map (x: let kernel = (getAttr x.name languages).override x.args; in kernel.overrideAttrs (old: { passthru = old.passthru // { name = x.name; diff --git a/languages/bash/default.nix b/languages/bash/default.nix index 0c31b9c1..c37a13a7 100644 --- a/languages/bash/default.nix +++ b/languages/bash/default.nix @@ -19,7 +19,7 @@ let chooseLanguageServers = settings: kernelName: [] ++ lib.optionals (common.isTrue settings "lsp.bash-language-server.enable") [(callPackage ./language_server_bash { inherit kernelName; })] - ; + ; settingsSchema = [ { @@ -42,22 +42,20 @@ lib.listToAttrs (map (x: icon = ./bash-logo-128x128.png; inherit settingsSchema; }; + versions = { + bash = bash.version; + bash-language-server = nodePackages.bash-language-server.version; + }; in { name = x; - value = rec { - inherit packageOptions packageSearch; - versions = { - bash = bash.version; - bash-language-server = nodePackages.bash-language-server.version; - }; - - build = args@{ + value = + lib.makeOverridable ({ packages ? [] , attrs ? ["bash"] , extensions ? ["sh" "bash"] , settings ? {} - }: + }@args: let settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; in symlinkJoin { @@ -72,14 +70,14 @@ lib.listToAttrs (map (x: passthru = { args = args // { baseName = x; }; - inherit meta packageOptions; + inherit meta packageOptions packageSearch versions; inherit settingsSchema settings; modes = { inherit attrs extensions; code_mirror_mode = "shell"; }; }; - }; - }; + } + ) {}; } ) (lib.filter (x: lib.hasAttr x pkgs) baseCandidates)) diff --git a/languages/clojure/default.nix b/languages/clojure/default.nix index 718dd8f3..8d610a8d 100644 --- a/languages/clojure/default.nix +++ b/languages/clojure/default.nix @@ -38,8 +38,8 @@ let clojure-lsp = (builtins.getFlake "github:clojure-lsp/clojure-lsp/5e3584014f2ac9c13a877dfd7984383346d81609").packages.x86_64-linux.default; chooseLanguageServers = settings: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.clojure-lsp.enable") [(callPackage ./language-server.nix { inherit clojure-lsp kernelName; })] + [] + ++ lib.optionals (common.isTrue settings "lsp.clojure-lsp.enable") [(callPackage ./language-server.nix { inherit clojure-lsp kernelName; })] ; in @@ -58,45 +58,45 @@ listToAttrs (map (x: inherit settingsSchema; }; + packageOptions = getAttr x packagesLookup; + packageSearch = common.searcher packageOptions; + versions = { + clojure = clojure.version; + clojure-lsp = clojure-lsp.version; + }; + in { name = x; - value = rec { - packageOptions = getAttr x packagesLookup; - packageSearch = common.searcher packageOptions; - versions = { - clojure = clojure.version; - clojure-lsp = clojure-lsp.version; - }; + value = lib.makeOverridable (args@{ + packages ? [] + , settings ? {} + , attrs ? ["clojure"] + , extensions ? ["clj"] + }: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + in symlinkJoin { + name = "clojure"; + paths = [ + (callPackage ./kernel.nix { inherit attrs extensions version; }) + clojure + ] + ++ (chooseLanguageServers settingsToUse x) + ; - build = args@{ - packages ? [] - , settings ? {} - , attrs ? ["clojure"] - , extensions ? ["clj"] - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - in symlinkJoin { - name = "clojure"; - paths = [ - (callPackage ./kernel.nix { inherit attrs extensions version; }) - clojure - ] - ++ (chooseLanguageServers settingsToUse x) - ; - - passthru = { - inherit meta packageOptions settingsSchema; - inherit settings; - args = args // { baseName = x; }; - repls = repls clojure; - modes = { - inherit attrs extensions; - code_mirror_mode = "clojure"; - }; + passthru = { + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + args = args // { baseName = x; }; + repls = repls clojure; + modes = { + inherit attrs extensions; + code_mirror_mode = "clojure"; }; }; - }; + } + ) {} + ; } ) (filter (x: (common.hasAttrSafe x pkgs) && !(attrByPath [x "meta" "broken"] false pkgs)) baseCandidates)) diff --git a/languages/coq/default.nix b/languages/coq/default.nix index 28ae8396..0b82a3ff 100644 --- a/languages/coq/default.nix +++ b/languages/coq/default.nix @@ -38,68 +38,68 @@ let chooseLanguageServers = settings: coq: kernelName: [] - ; + ; in lib.listToAttrs (map (x: - let coqPackages = lib.getAttr x pkgs; - baseCoq = coqPackages.coq; - baseName = with builtins; (substring 0 3 x) + (substring 11 (stringLength x - 11) x); - displayName = "Coq"; - meta = baseCoq.meta // { - inherit baseName displayName settingsSchema; - version = baseCoq.version; - icon = coq_jupyter.sizedLogo "64"; - lessCommon = isLessCommon x; - }; + let + coqPackages = lib.getAttr x pkgs; + baseCoq = coqPackages.coq; + baseName = with builtins; (substring 0 3 x) + (substring 11 (stringLength x - 11) x); + displayName = "Coq"; + meta = baseCoq.meta // { + inherit baseName displayName settingsSchema; + version = baseCoq.version; + icon = coq_jupyter.sizedLogo "64"; + lessCommon = isLessCommon x; + }; + + packageOptions = coqPackages; + packageSearch = common.searcher packageOptions; + versions = { + coq = baseCoq.version; + }; in { name = baseName; - value = rec { - packageOptions = coqPackages; - packageSearch = common.searcher packageOptions; - versions = { - coq = baseCoq.version; - }; - - build = args@{ - packages ? [] - , attrs ? [baseName "coq"] - , extensions ? ["v"] - , settings ? {} - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - - coq = baseCoq; - - in symlinkJoin { - name = baseName; - - paths = [ - (callPackage ./kernel.nix { - inherit coq displayName attrs extensions; - enableVariableInspector = settingsToUse.enableVariableInspector; - chosenPackages = map (x: builtins.getAttr x packageOptions) packages; - }) - - coq - ] - ++ (chooseLanguageServers settingsToUse coq baseName) - ; - - passthru = { - inherit meta packageOptions; - inherit settings settingsSchema; - args = args // { inherit baseName; }; - repls = repls coq; - modes = { - inherit attrs extensions; - code_mirror_mode = "coq"; - }; + value = lib.makeOverridable ({ + packages ? [] + , attrs ? [baseName "coq"] + , extensions ? ["v"] + , settings ? {} + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + + coq = baseCoq; + + in symlinkJoin { + name = baseName; + + paths = [ + (callPackage ./kernel.nix { + inherit coq displayName attrs extensions; + enableVariableInspector = settingsToUse.enableVariableInspector; + chosenPackages = map (x: builtins.getAttr x packageOptions) packages; + }) + + coq + ] + ++ (chooseLanguageServers settingsToUse coq baseName) + ; + + passthru = { + inherit meta packageOptions packageSearch versions; + inherit settings settingsSchema; + args = args // { inherit baseName; }; + repls = repls coq; + modes = { + inherit attrs extensions; + code_mirror_mode = "coq"; }; }; - }; + } + ) {}; } ) (lib.filter (x: lib.hasAttr x pkgs) baseCandidates)) diff --git a/languages/cpp/default.nix b/languages/cpp/default.nix index 8bf70c27..31708455 100644 --- a/languages/cpp/default.nix +++ b/languages/cpp/default.nix @@ -70,50 +70,49 @@ if cling == null then {} else xeus-cling = callPackage ./xeus-cling/xeus-cling.nix { inherit cling; }; + packageOptions = {}; + packageSearch = common.searcher packageOptions; + versions = { + clang = clang.version; + cling = cling.unwrapped.version; + xeus-cling = xeus-cling.version; + std = std; + }; + in { name = x; - value = rec { - packageOptions = {}; - packageSearch = common.searcher packageOptions; - versions = { - clang = clang.version; - cling = cling.unwrapped.version; - xeus-cling = xeus-cling.version; - std = std; - }; - - build = args@{ - packages ? [] - , settings ? {} - , attrs ? [x "cpp"] - , extensions ? ["cpp" "hpp" "cxx" "hxx" "c" "h"] - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - in symlinkJoin { - name = x; - paths = [ - ((callPackage ./kernel_xeus.nix { - inherit cling xeus-cling; - inherit attrs displayName extensions std; - attrName = x; - })) - cling - ] - ; - - passthru = { - inherit meta packageOptions; - inherit settings settingsSchema; - args = args // { baseName = x; }; - repls = repls (getAttr x icons); - modes = { - inherit attrs extensions; - code_mirror_mode = "clike"; - code_mirror_mime_type = "text/x-c++src"; - }; + value = lib.makeOverridable ({ + packages ? [] + , settings ? {} + , attrs ? [x "cpp"] + , extensions ? ["cpp" "hpp" "cxx" "hxx" "c" "h"] + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + in symlinkJoin { + name = x; + paths = [ + ((callPackage ./kernel_xeus.nix { + inherit cling xeus-cling; + inherit attrs displayName extensions std; + attrName = x; + })) + cling + ] + ; + + passthru = { + inherit meta packageOptions packageSearch versions; + inherit settings settingsSchema; + args = args // { baseName = x; }; + repls = repls (getAttr x icons); + modes = { + inherit attrs extensions; + code_mirror_mode = "clike"; + code_mirror_mime_type = "text/x-c++src"; }; }; - }; + } + ) {}; } ) baseCandidates) diff --git a/languages/go/default.nix b/languages/go/default.nix index ad09d119..129ed9b1 100644 --- a/languages/go/default.nix +++ b/languages/go/default.nix @@ -25,8 +25,8 @@ let ]; chooseLanguageServers = settings: go: attrs: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.gopls.enable") [(callPackage ./language-server-gopls.nix { inherit go attrs; inherit kernelName; })] + [] + ++ lib.optionals (common.isTrue settings "lsp.gopls.enable") [(callPackage ./language-server-gopls.nix { inherit go attrs; inherit kernelName; })] ; repls = go: {}; @@ -47,48 +47,46 @@ listToAttrs (map (x: inherit settingsSchema; }; + packageOptions = {}; + packageSearch = common.searcher packageOptions; + versions = { + go = go.version; + gopls = gopls.version; + }; + in { name = x; - value = rec { - packageOptions = {}; - packageSearch = common.searcher packageOptions; - versions = { - go = go.version; - gopls = gopls.version; - }; - - build = args@{ - packages ? [] - , settings ? {} - , attrs ? ["go"] - , extensions ? ["go"] - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - in symlinkJoin { - name = "go"; - paths = [ - (callPackage ./kernel.nix { - inherit attrs extensions; - version = go.version; - }) - go - ] - ++ (chooseLanguageServers settingsToUse go attrs x) - ; + value = lib.makeOverridable ({ + packages ? [] + , settings ? {} + , attrs ? ["go"] + , extensions ? ["go"] + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + in symlinkJoin { + name = "go"; + paths = [ + (callPackage ./kernel.nix { + inherit attrs extensions; + version = go.version; + }) + go + ] + ++ (chooseLanguageServers settingsToUse go attrs x) + ; - passthru = { - inherit meta packageOptions; - inherit settingsSchema settings; - args = args // { baseName = x; }; - repls = repls go; - modes = { - inherit attrs extensions; - code_mirror_mode = "go"; - }; + passthru = { + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + args = args // { baseName = x; }; + repls = repls go; + modes = { + inherit attrs extensions; + code_mirror_mode = "go"; }; }; - }; + } + ) {}; } - ) (lib.filter (x: lib.hasAttr x pkgs) baseCandidates)) diff --git a/languages/haskell/default.nix b/languages/haskell/default.nix index 595e6b60..55139c47 100644 --- a/languages/haskell/default.nix +++ b/languages/haskell/default.nix @@ -20,7 +20,7 @@ let chooseLanguageServers = settings: snapshot: ghc: kernelName: [] ++ lib.optionals (common.isTrue settings "lsp.haskell-language-server.enable" && hasHlsSupport ghc.version) - [((callPackage ./language-server-hls/hls.nix {}) snapshot ghc kernelName (common.focusSettings "lsp.haskell-language-server." settings))] + [((callPackage ./language-server-hls/hls.nix {}) snapshot ghc kernelName (common.focusSettings "lsp.haskell-language-server." settings))] ; compilers = callPackage ./compilers.nix { @@ -58,68 +58,68 @@ listToAttrs (mapAttrsToList (compilerName: snapshot: icon = ./haskell-logo-64x64.png; }; + packageOptions = snapshot; + versions = { + ghc = snapshot.ghc.version; + haskell-language-server = snapshot.haskell-language-server.version; + }; + + # Grab the meta from the library component + # Could also search over other components? + packageSearch = common.searcher (mapAttrs (name: value: + let meta = (attrByPath ["components" "library" "meta"] null value); in + if meta == null then value else value // { inherit meta; }) packageOptions); + in { name = meta.baseName; - value = rec { - packageOptions = snapshot; - versions = { - ghc = snapshot.ghc.version; - haskell-language-server = snapshot.haskell-language-server.version; - }; - - # Grab the meta from the library component - # Could also search over other components? - packageSearch = common.searcher (mapAttrs (name: value: - let meta = (attrByPath ["components" "library" "meta"] null value); in - if meta == null then value else value // { inherit meta; }) packageOptions); - - build = args@{ - packages ? [] - , attrs ? [meta.baseName "haskell"] - , extensions ? ["hs"] - , settings ? {} - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - ghc = snapshot.ghcWithPackages (ps: - [ps.directory] - ++ (map (x: builtins.getAttr x ps) packages) - ++ (if (common.isTrue settingsToUse "lsp.haskell-language-server.enable") then [ps.haskell-language-server] else []) - ); - - in symlinkJoin { - name = meta.baseName; - - paths = [ - (callPackage ./kernel.nix { - inherit displayName attrs extensions snapshot; - - language = "haskell"; - - ihaskell = if settingsToUse.enableHlintOutput then snapshot.ihaskell else snapshot.ihaskell.overrideAttrs (oldAttrs: { - configureFlags = ["-f" "-use-hlint"]; - }); - inherit ghc; - - # enableVariableInspector = settingsToUse.enableVariableInspector; - }) - - ghc - ] - ++ (chooseLanguageServers settingsToUse snapshot ghc meta.baseName) - ; - - passthru = { - args = args // { baseName = meta.baseName; }; - inherit settingsSchema settings; - inherit meta packageOptions; - repls = repls ghc; - modes = { - inherit attrs extensions; - code_mirror_mode = "haskell"; - }; + value = lib.makeOverridable ({ + packages ? [] + , attrs ? [meta.baseName "haskell"] + , extensions ? ["hs"] + , settings ? {} + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + ghc = snapshot.ghcWithPackages (ps: + [ps.directory] + ++ (map (x: builtins.getAttr x ps) packages) + ++ (if (common.isTrue settingsToUse "lsp.haskell-language-server.enable") then [ps.haskell-language-server] else []) + ); + + in symlinkJoin { + name = meta.baseName; + + paths = [ + (callPackage ./kernel.nix { + inherit displayName attrs extensions snapshot; + + language = "haskell"; + + ihaskell = if settingsToUse.enableHlintOutput then snapshot.ihaskell else snapshot.ihaskell.overrideAttrs (oldAttrs: { + configureFlags = ["-f" "-use-hlint"]; + }); + inherit ghc; + + # enableVariableInspector = settingsToUse.enableVariableInspector; + }) + + ghc + ] + ++ (chooseLanguageServers settingsToUse snapshot ghc meta.baseName) + ; + + passthru = { + args = args // { baseName = meta.baseName; }; + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + repls = repls ghc; + modes = { + inherit attrs extensions; + code_mirror_mode = "haskell"; }; }; - }; + } + ) {} + ; } ) (lib.filterAttrs (k: _: !(hasPrefix "override") k) compilers)) diff --git a/languages/julia/default.nix b/languages/julia/default.nix index 7a8b8a01..4697bc60 100644 --- a/languages/julia/default.nix +++ b/languages/julia/default.nix @@ -40,12 +40,12 @@ let ]; chooseLanguageServers = settings: attrs: attr: julia: - [] - ++ lib.optionals (common.isTrue settings "lsp.LanguageServer.enable") [(callPackage ./language-server-LanguageServer.nix { - inherit attrs julia; - kernelName = attr; - settings = common.focusSettings "lsp.LanguageServer." settings; - })] + [] + ++ lib.optionals (common.isTrue settings "lsp.LanguageServer.enable") [(callPackage ./language-server-LanguageServer.nix { + inherit attrs julia; + kernelName = attr; + settings = common.focusSettings "lsp.LanguageServer." settings; + })] ; packageOverrides = { @@ -112,7 +112,6 @@ mapAttrs (attr: value: python = python3; - in rec { packageOptions = {}; packageSearch = common.searcher' { packages = packageSet; @@ -122,12 +121,13 @@ mapAttrs (attr: value: julia = baseJulia.version; }; - build = args@{ + in + lib.makeOverridable ({ packages ? [] , attrs ? [attr "julia"] , extensions ? ["jl"] , settings ? {} - }: + }@args: let settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; @@ -149,13 +149,13 @@ mapAttrs (attr: value: passthru = { args = args // { baseName = attr; }; - inherit meta packageOptions; + inherit meta packageOptions packageSearch versions; inherit settingsSchema settings; modes = { inherit attrs extensions; code_mirror_mode = "julia"; }; }; - }; - } + } + ) {} ) baseCandidates diff --git a/languages/octave/default.nix b/languages/octave/default.nix index 707d59c4..6585c434 100644 --- a/languages/octave/default.nix +++ b/languages/octave/default.nix @@ -45,71 +45,71 @@ listToAttrs (map (x: inherit settingsSchema; }; + packageOptions = baseOctave.pkgs; + packageSearch = common.searcher packageOptions; + versions = { + octave = baseOctave.version; + }; + in { name = x; - value = rec { - packageOptions = baseOctave.pkgs; - packageSearch = common.searcher packageOptions; - versions = { - octave = baseOctave.version; - }; - - build = args@{ - packages ? [] - , settings ? {} - , extraJupyterConfig ? null - , attrs ? ["octave"] - , extensions ? ["m"] - }: - let - octaveComplete = baseOctave.override { - qscintilla = null; - overridePlatforms = ["x86_64-linux" "x86_64-darwin"]; - gnuplot = gnuplot; - ghostscript = ghostscript; - graphicsmagick = graphicsmagick; - python = python3; - }; + value = lib.makeOverridable ({ + packages ? [] + , settings ? {} + , extraJupyterConfig ? null + , attrs ? ["octave"] + , extensions ? ["m"] + }@args: + let + octaveComplete = baseOctave.override { + qscintilla = null; + overridePlatforms = ["x86_64-linux" "x86_64-darwin"]; + gnuplot = gnuplot; + ghostscript = ghostscript; + graphicsmagick = graphicsmagick; + python = python3; + }; - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - - octaveWithPackages = if lib.hasAttr "withPackages" octaveComplete - then - let chosenPackages = map (x: lib.getAttr x octaveComplete.pkgs) packages; in - if chosenPackages == [] then octaveComplete else octaveComplete.withPackages (ps: chosenPackages) - else octaveComplete; - - chosenPackages = if lib.hasAttr "pkgs" baseOctave - then baseOctave.pkgs - else []; - - # Wrapper derivation that only has "octave" and "octave-cli" binaries, - # perfect for including in binaries and passing to the kernel - octave = callPackage ./octave.nix { octaveComplete = octaveWithPackages; }; - - in symlinkJoin { - name = "octave"; - paths = [ - (callPackage ./kernel.nix { - inherit octave extraJupyterConfig attrs extensions; - version = baseOctave.version; - }) - octave - ]; - passthru = { - inherit meta packageOptions; - args = args // { baseName = x; }; - repls = repls octaveWithPackages baseOctave.version; - inherit settingsSchema settings; - modes = { - inherit attrs extensions; - code_mirror_mode = "octave"; - }; + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + + octaveWithPackages = if lib.hasAttr "withPackages" octaveComplete + then + let chosenPackages = map (x: lib.getAttr x octaveComplete.pkgs) packages; in + if chosenPackages == [] then octaveComplete else octaveComplete.withPackages (ps: chosenPackages) + else octaveComplete; + + chosenPackages = if lib.hasAttr "pkgs" baseOctave + then baseOctave.pkgs + else []; + + # Wrapper derivation that only has "octave" and "octave-cli" binaries, + # perfect for including in binaries and passing to the kernel + octave = callPackage ./octave.nix { octaveComplete = octaveWithPackages; }; + + in symlinkJoin { + name = "octave"; + paths = [ + (callPackage ./kernel.nix { + inherit octave extraJupyterConfig attrs extensions; + version = baseOctave.version; + }) + octave + ]; + passthru = { + inherit meta packageOptions packageSearch versions; + args = args // { baseName = x; }; + repls = repls octaveWithPackages baseOctave.version; + inherit settingsSchema settings; + modes = { + inherit attrs extensions; + code_mirror_mode = "octave"; }; }; - }; - } -) (filter (x: hasAttr x pkgs) baseCandidates)) + } + ) {}; + }) + (filter (x: hasAttr x pkgs) baseCandidates) +) # extraGitIgnoreLines = [ # ".octaverc" diff --git a/languages/postgres/default.nix b/languages/postgres/default.nix index c46c9691..e741442e 100644 --- a/languages/postgres/default.nix +++ b/languages/postgres/default.nix @@ -15,7 +15,7 @@ let chooseLanguageServers = settings: [] - ; + ; meta = { name = "postgres"; @@ -27,41 +27,39 @@ let inherit settingsSchema; }; + versions = { + postgres-kernel = meta.version; + }; + in { - postgres = { - inherit packageOptions packageSearch; - versions = { - postgres-kernel = meta.version; - }; + postgres = lib.makeOverridable ({ + packages ? [] + , settings ? [] + , attrs ? ["postgres"] + , extensions ? ["sql"] + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + in symlinkJoin { + name = "postgres"; - build = args@{ - packages ? [] - , settings ? [] - , attrs ? ["postgres"] - , extensions ? ["sql"] - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - in symlinkJoin { - name = "postgres"; + paths = [ + (callPackage ./kernel.nix { inherit attrs extensions; }) + ] + ++ (chooseLanguageServers settingsToUse) + ; - paths = [ - (callPackage ./kernel.nix { inherit attrs extensions; }) - ] - ++ (chooseLanguageServers settingsToUse) - ; - - passthru = { - args = args // { baseName = "postgres"; }; - inherit meta packageOptions; - inherit settingsSchema settings; - modes = { - inherit attrs extensions; - code_mirror_mode = "sql"; - }; + passthru = { + args = args // { baseName = "postgres"; }; + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + modes = { + inherit attrs extensions; + code_mirror_mode = "sql"; }; }; - }; + } + ) {}; } diff --git a/languages/python/default.nix b/languages/python/default.nix index c009046a..28e965c6 100644 --- a/languages/python/default.nix +++ b/languages/python/default.nix @@ -24,7 +24,7 @@ let ++ lib.optionals (common.isTrue settings "lsp.microsoft.enable") [(callPackage ./language_servers/language_server_microsoft/config.nix { inherit pythonWithPackages kernelName; })] ++ lib.optionals (common.isTrue settings "lsp.python-lsp-server.enable" && (hasPythonLspServer (pythonWithPackages (ps: [])))) [(callPackage ./language_servers/language_server_pythonlsp/config.nix { inherit pythonWithPackages kernelName; })] ++ lib.optionals (common.isTrue settings "lsp.python-language-server.enable" && (hasPythonLanguageServer (pythonWithPackages (ps: [])))) [(callPackage ./language_servers/language_server_palantir/config.nix { inherit pythonWithPackages kernelName; })] - ; + ; repls = python: { ipython = { @@ -169,63 +169,62 @@ lib.listToAttrs (map (x: icon = ./python-logo-64x64.png; }; + packageOptions = basePython.pkgs; + packageSearch = common.searcher packageOptions; + versions = { + python = basePython.version; + jedi-language-server = basePython.pkgs.jedi-language-server.version; + pyright = pyright.version; + pylint = basePython.pkgs.pylint.version; + flake8 = basePython.pkgs.flake8.version; + pycodestyle = basePython.pkgs.pycodestyle.version; + } + // lib.optionalAttrs (hasPythonLspServer basePython) { python-lsp-server = basePython.pkgs.python-lsp-server.version; } + ; + in { name = x; - value = rec { - packageOptions = basePython.pkgs; - packageSearch = common.searcher packageOptions; - versions = { - python = basePython.version; - jedi-language-server = basePython.pkgs.jedi-language-server.version; - pyright = pyright.version; - pylint = basePython.pkgs.pylint.version; - flake8 = basePython.pkgs.flake8.version; - pycodestyle = basePython.pkgs.pycodestyle.version; - } - // lib.optionalAttrs (hasPythonLspServer basePython) { python-lsp-server = basePython.pkgs.python-lsp-server.version; } - ; - - build = args@{ - packages ? [] - , attrs ? [x "python"] - , extensions ? ["py"] - , settings ? {} - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - ps = packageOptions; - chosenPackages = map (x: builtins.getAttr x ps) packages; - allPackages = [ps.ipykernel ps.ipywidgets] ++ chosenPackages; - python = basePython.withPackages (_: allPackages); - pythonWithPackages = f: basePython.withPackages (_: allPackages ++ f ps); - - in symlinkJoin { - name = x; - - paths = [ - (callPackage ./kernel.nix { - inherit python displayName attrs extensions; - enableVariableInspector = settingsToUse.enableVariableInspector; - }) - - python - ps.ipython - ] - ++ (chooseLanguageServers settingsToUse pythonWithPackages x) - ; - - passthru = { - inherit meta packageOptions; - inherit settingsSchema settings; - args = args // { baseName = x; }; - repls = repls python; - modes = { - inherit attrs extensions; - code_mirror_mode = "python"; - }; + value = lib.makeOverridable ({ + packages ? [] + , attrs ? [x "python"] + , extensions ? ["py"] + , settings ? {} + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + ps = packageOptions; + chosenPackages = map (x: builtins.getAttr x ps) packages; + allPackages = [ps.ipykernel ps.ipywidgets] ++ chosenPackages; + python = basePython.withPackages (_: allPackages); + pythonWithPackages = f: basePython.withPackages (_: allPackages ++ f ps); + + in symlinkJoin { + name = x; + + paths = [ + (callPackage ./kernel.nix { + inherit python displayName attrs extensions; + enableVariableInspector = settingsToUse.enableVariableInspector; + }) + + python + ps.ipython + ] + ++ (chooseLanguageServers settingsToUse pythonWithPackages x) + ; + + passthru = { + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + args = args // { baseName = x; }; + repls = repls python; + modes = { + inherit attrs extensions; + code_mirror_mode = "python"; }; }; - }; + } + ) {}; } ) (lib.filter (x: lib.hasAttr x pkgs) baseCandidates)) diff --git a/languages/r/default.nix b/languages/r/default.nix index 98fb31f7..b08709e6 100644 --- a/languages/r/default.nix +++ b/languages/r/default.nix @@ -48,58 +48,57 @@ let }; }; + packageOptions = rPackages; + packageSearch = common.searcher packageOptions; + versions = { + r = R.version; + languageserver = (callPackage ./language-server-languageserver/languageserver.nix {}).version; + }; + in with lib; listToAttrs [{ name = "R"; - value = rec { - packageOptions = rPackages; - packageSearch = common.searcher packageOptions; - versions = { - r = R.version; - languageserver = (callPackage ./language-server-languageserver/languageserver.nix {}).version; - }; - - build = args@{ - packages ? [] - , settings ? {} - , attrs ? ["r" "R"] - , extensions ? ["r"] - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + value = lib.makeOverridable ({ + packages ? [] + , settings ? {} + , attrs ? ["r" "R"] + , extensions ? ["r"] + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - basePackages = [rPackages.IRkernel] ++ (map (x: lib.getAttr x rPackages) packages); + basePackages = [rPackages.IRkernel] ++ (map (x: lib.getAttr x rPackages) packages); - rWithPackages = rWrapper.override { - packages = basePackages; - }; - in - symlinkJoin { - name = "r"; + rWithPackages = rWrapper.override { + packages = basePackages; + }; + in + symlinkJoin { + name = "r"; - paths = [ - (callPackage ./kernel.nix { - inherit rWithPackages attrs extensions; - version = R.version; - }) - rWithPackages - ] - ++ (chooseLanguageServers settingsToUse rPackages rWrapper basePackages "R") - ; + paths = [ + (callPackage ./kernel.nix { + inherit rWithPackages attrs extensions; + version = R.version; + }) + rWithPackages + ] + ++ (chooseLanguageServers settingsToUse rPackages rWrapper basePackages "R") + ; - passthru = { - inherit meta packageOptions; - inherit settingsSchema settings; - args = args // { baseName = "R"; }; - repls = repls rWithPackages R.version; - modes = { - inherit attrs extensions; - code_mirror_mode = "r"; - }; + passthru = { + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + args = args // { baseName = "R"; }; + repls = repls rWithPackages R.version; + modes = { + inherit attrs extensions; + code_mirror_mode = "r"; }; }; - }; + } + ) {}; }] diff --git a/languages/ruby/default.nix b/languages/ruby/default.nix index 9181256c..0c4e22af 100644 --- a/languages/ruby/default.nix +++ b/languages/ruby/default.nix @@ -53,7 +53,7 @@ let chooseLanguageServers = settings: packageOptions: kernelName: [] ++ lib.optionals (common.isTrue settings "lsp.solargraph.enable") [(callPackage ./solargraph.nix { rubyPackages = packageOptions; inherit kernelName; })] - ; + ; in @@ -71,46 +71,45 @@ listToAttrs (map (x: inherit settingsSchema; }; + packageOptions = getAttr x packagesLookup; + packageSearch = common.searcher packageOptions; + versions = { + ruby = builtins.toString ruby.version; + solargraph = packageOptions.solargraph.version; + }; + in { name = x; - value = rec { - packageOptions = getAttr x packagesLookup; - packageSearch = common.searcher packageOptions; - versions = { - ruby = builtins.toString ruby.version; - solargraph = packageOptions.solargraph.version; - }; - - build = args@{ - packages ? [] - , settings ? {} - , attrs ? [x "ruby"] - , extensions ? ["rb"] - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - in symlinkJoin { - name = x; - paths = [ - (callPackage ./kernel.nix { - iruby = (callPackage ./iruby { inherit ruby; }).iruby; - inherit attrs extensions version; - }) - ruby - ] - ++ (chooseLanguageServers settingsToUse packageOptions x) - ; - passthru = { - inherit meta packageOptions; - inherit settingsSchema settings; - args = args // { baseName = x; }; - modes = { - inherit attrs extensions; - code_mirror_mode = "ruby"; - }; + value = lib.makeOverridable ({ + packages ? [] + , settings ? {} + , attrs ? [x "ruby"] + , extensions ? ["rb"] + }@args: + let + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + in symlinkJoin { + name = x; + paths = [ + (callPackage ./kernel.nix { + iruby = (callPackage ./iruby { inherit ruby; }).iruby; + inherit attrs extensions version; + }) + ruby + ] + ++ (chooseLanguageServers settingsToUse packageOptions x) + ; + passthru = { + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + args = args // { baseName = x; }; + modes = { + inherit attrs extensions; + code_mirror_mode = "ruby"; }; }; - }; + } + ) {}; } ) baseCandidates) diff --git a/languages/rust/default.nix b/languages/rust/default.nix index 7a182632..6f527982 100644 --- a/languages/rust/default.nix +++ b/languages/rust/default.nix @@ -74,73 +74,68 @@ listToAttrs (map (x: inherit (darwin.apple_sdk.frameworks) CoreServices Security; }; - in { - name = x; - value = rec { - packageOptions = listToAttrs (map (x: { - name = x; - value = { - meta = { - name = x; - }; + packageOptions = listToAttrs (map (x: { + name = x; + value = { + meta = { + name = x; }; - }) allPackageNames); - - packageSearch = common.searcher' { - packageMustBeDerivation = false; - packages = packageOptions; }; + }) allPackageNames); - versions = { - rust = rustPackages.rustc.version; - rust-analyzer = rust-analyzer.version; - cargo = rustPackages.cargo.version; - }; + packageSearch = common.searcher' { + packageMustBeDerivation = false; + packages = packageOptions; + }; - passthru = { - inherit (evcxrBase) cratesIndex; - }; + versions = { + rust = rustPackages.rustc.version; + rust-analyzer = rust-analyzer.version; + cargo = rustPackages.cargo.version; + }; + + in { + name = x; + value = lib.makeOverridable ({ + packages ? [] + , attrs ? [x "rust"] + , extensions ? ["rs" "rlib"] + , settings ? {} + }@args: let + evcxr = (evcxrBase.override { + rustPlatform = rustPackages.rustPlatform; + cargo = rustPackages.cargo; + }).withPackages (map common.packageName packages); + + settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; + in symlinkJoin { + name = "rust"; + + paths = [ + (callPackage ./kernel.nix { + inherit evcxr; + inherit displayName attrs extensions; + version = rustPackages.rustc.version; + }) + + rustPackages.rustc + rustPackages.cargo + pkgs.gcc + ] + ++ (chooseLanguageServers settingsToUse rust evcxr.cargoHome x) + ; - build = args@{ - packages ? [] - , attrs ? [x "rust"] - , extensions ? ["rs" "rlib"] - , settings ? {} - }: let - evcxr = (evcxrBase.override { - rustPlatform = rustPackages.rustPlatform; - cargo = rustPackages.cargo; - }).withPackages (map common.packageName packages); - - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - in symlinkJoin { - name = "rust"; - - paths = [ - (callPackage ./kernel.nix { - inherit evcxr; - inherit displayName attrs extensions; - version = rustPackages.rustc.version; - }) - - rustPackages.rustc - rustPackages.cargo - pkgs.gcc - ] - ++ (chooseLanguageServers settingsToUse rust evcxr.cargoHome x) - ; - - passthru = { - args = args // { baseName = x; }; - inherit meta packageOptions; - inherit settingsSchema settings; - inherit (evcxr) cratesIndex; - modes = { - inherit attrs extensions; - code_mirror_mode = "rust"; - }; + passthru = { + args = args // { baseName = x; }; + inherit meta packageOptions packageSearch versions; + inherit settingsSchema settings; + inherit (evcxr) cratesIndex; + modes = { + inherit attrs extensions; + code_mirror_mode = "rust"; }; }; - }; + } + ) {}; } ) (filter (x: hasAttr x pkgs) baseCandidates)) diff --git a/tests/app/Spec/Tests/Bash.hs b/tests/app/Spec/Tests/Bash.hs index 54070380..5b472a79 100644 --- a/tests/app/Spec/Tests/Bash.hs +++ b/tests/app/Spec/Tests/Bash.hs @@ -32,6 +32,7 @@ kernelSpec = NixKernelSpec { tests :: LanguageSpec tests = describe "Bash" $ introduceNixEnvironment [kernelSpec] [] "Bash" $ introduceJupyterRunner $ do testKernelSearchersBuild "bash" + testHasExpectedFields "bash" testKernelStdout "bash" [i|echo hi|] "hi\n" diff --git a/tests/app/Spec/Tests/Clojure.hs b/tests/app/Spec/Tests/Clojure.hs index 34877550..2aa82312 100644 --- a/tests/app/Spec/Tests/Clojure.hs +++ b/tests/app/Spec/Tests/Clojure.hs @@ -28,6 +28,7 @@ kernelSpec = NixKernelSpec { tests :: LanguageSpec tests = describe "Clojure" $ introduceNixEnvironment [kernelSpec] [] "Clojure" $ introduceJupyterRunner $ do testKernelSearchersBuild "clojure" + testHasExpectedFields "clojure" testKernelStdout "clojure" [__i|(println "hi")|] "hi\n" diff --git a/tests/app/Spec/Tests/Coq.hs b/tests/app/Spec/Tests/Coq.hs index a3155e2d..ac4c0bf4 100644 --- a/tests/app/Spec/Tests/Coq.hs +++ b/tests/app/Spec/Tests/Coq.hs @@ -28,6 +28,7 @@ kernelSpec = NixKernelSpec { tests :: LanguageSpec tests = describe "Coq" $ introduceNixEnvironment [kernelSpec] [] "Coq" $ introduceJupyterRunner $ do testKernelSearchersBuild "coq" + testHasExpectedFields "coq" itHasExecuteTexts "coq" [__i|Require Import Bignums.BigN.BigN. Check (BigN.add_comm 1 2).|] [Just $ Array [ diff --git a/tests/app/Spec/Tests/Cpp.hs b/tests/app/Spec/Tests/Cpp.hs index d70fc0f5..5c9f0e25 100644 --- a/tests/app/Spec/Tests/Cpp.hs +++ b/tests/app/Spec/Tests/Cpp.hs @@ -25,6 +25,7 @@ tests = describe "C++" $ parallel $ do tests' :: Text -> LanguageSpec tests' kernelName = describe [i|C++ (#{kernelName})|] $ introduceNixEnvironment [kernelSpec kernelName] [] "C++" $ introduceJupyterRunner $ do testKernelSearchersBuild kernelName + testHasExpectedFields kernelName testKernelStdout kernelName [__i|\#include using namespace std; diff --git a/tests/app/Spec/Tests/Go.hs b/tests/app/Spec/Tests/Go.hs index b6daffc7..c5b192fe 100644 --- a/tests/app/Spec/Tests/Go.hs +++ b/tests/app/Spec/Tests/Go.hs @@ -28,6 +28,7 @@ kernelSpec = NixKernelSpec { tests :: LanguageSpec tests = describe "Go" $ introduceNixEnvironment [kernelSpec] [] "Go" $ introduceJupyterRunner $ do testKernelSearchersBuild "go" + testHasExpectedFields "go" testKernelStdout "go" [__i|import("fmt") fmt.Println("hi")|] "hi\n" diff --git a/tests/app/Spec/Tests/Haskell.hs b/tests/app/Spec/Tests/Haskell.hs index 1c2256c2..735abd3f 100644 --- a/tests/app/Spec/Tests/Haskell.hs +++ b/tests/app/Spec/Tests/Haskell.hs @@ -51,6 +51,7 @@ haskellCommonTests lang = do describe [i|Haskell #{lang}|] $ introduceNixEnvironment [kernelSpec lang] [] "Haskell" $ do introduceJupyterRunner $ do testKernelSearchersNonempty lang + testHasExpectedFields lang describe "Kernel" $ do itHasDisplayDatas lang [__i|putStrLn "hi"|] [M.fromList [(MimeType "text/plain", A.Array (V.fromList [A.String "hi"]))]] diff --git a/tests/app/Spec/Tests/Julia.hs b/tests/app/Spec/Tests/Julia.hs index cfdd232e..74007512 100644 --- a/tests/app/Spec/Tests/Julia.hs +++ b/tests/app/Spec/Tests/Julia.hs @@ -31,6 +31,7 @@ tests = do juliaTests :: Text -> LanguageSpec juliaTests lang = describe [i|Julia (#{lang})|] $ introduceNixEnvironment [kernelSpec lang] [] [i|Julia (#{lang})|] $ introduceJupyterRunner $ do testKernelSearchersNonempty lang + testHasExpectedFields lang testKernelStdout lang [i|println("hi")|] "hi\n" diff --git a/tests/app/Spec/Tests/Octave.hs b/tests/app/Spec/Tests/Octave.hs index 12451e00..734659cb 100644 --- a/tests/app/Spec/Tests/Octave.hs +++ b/tests/app/Spec/Tests/Octave.hs @@ -26,6 +26,7 @@ kernelSpec = NixKernelSpec { tests :: LanguageSpec tests = describe "Octave" $ introduceNixEnvironment [kernelSpec] [] "Octave" $ introduceJupyterRunner $ do testKernelSearchersBuild "octave" + testHasExpectedFields "octave" testKernelStdout "octave" [__i|printf('%s', 'hi')|] "hi" diff --git a/tests/app/Spec/Tests/Postgres.hs b/tests/app/Spec/Tests/Postgres.hs index 5f596534..ea527dfe 100644 --- a/tests/app/Spec/Tests/Postgres.hs +++ b/tests/app/Spec/Tests/Postgres.hs @@ -33,6 +33,7 @@ kernelSpec = NixKernelSpec { tests :: LanguageSpec tests = describe "Postgres tests" $ introduceNixEnvironment [kernelSpec] [] "Postgres" $ introduceJupyterRunner $ do testKernelSearchersBuild "postgres" + testHasExpectedFields "postgres" introducePostgres Nothing $ introducePostgresData $ do it "selects from test_table" $ do diff --git a/tests/app/Spec/Tests/Python.hs b/tests/app/Spec/Tests/Python.hs index 5019d84f..48717aeb 100644 --- a/tests/app/Spec/Tests/Python.hs +++ b/tests/app/Spec/Tests/Python.hs @@ -29,6 +29,7 @@ tests = describe "Python" $ parallel $ do tests' :: Text -> LanguageSpec tests' kernelName = describe [i|Python (#{kernelName})|] $ introduceNixEnvironment [kernelSpec kernelName] [] "Python 3" $ introduceJupyterRunner $ do testKernelSearchersNonempty kernelName + testHasExpectedFields kernelName testKernelStdout kernelName [i|print("hi")|] "hi\n" testKernelStdout kernelName [i|print(42)|] "42\n" diff --git a/tests/app/Spec/Tests/R.hs b/tests/app/Spec/Tests/R.hs index 5593e1ec..735e5e62 100644 --- a/tests/app/Spec/Tests/R.hs +++ b/tests/app/Spec/Tests/R.hs @@ -26,6 +26,7 @@ kernelSpec = NixKernelSpec { tests :: LanguageSpec tests = describe "R" $ introduceNixEnvironment [kernelSpec] [] "R" $ introduceJupyterRunner $ do testKernelSearchersNonempty "R" + testHasExpectedFields "R" testKernelStdout "R" [__i|cat("hi")|] "hi" testKernelStdout "R" [__i|print("hi")|] [i|[1] "hi"\n|] diff --git a/tests/app/Spec/Tests/Ruby.hs b/tests/app/Spec/Tests/Ruby.hs index 5c16a4cc..3cdd2488 100644 --- a/tests/app/Spec/Tests/Ruby.hs +++ b/tests/app/Spec/Tests/Ruby.hs @@ -34,6 +34,7 @@ kernelTests :: Text -> LanguageSpec kernelTests lang = do describe (T.unpack lang) $ introduceNixEnvironment [kernelSpec lang] [] [i|Ruby (#{lang})|] $ introduceJupyterRunner $ do testKernelSearchersNonempty lang + testHasExpectedFields lang testKernelStdout lang [__i|puts "hi"|] "hi\n" diff --git a/tests/app/Spec/Tests/Rust.hs b/tests/app/Spec/Tests/Rust.hs index 6a062965..f099efd3 100644 --- a/tests/app/Spec/Tests/Rust.hs +++ b/tests/app/Spec/Tests/Rust.hs @@ -22,6 +22,7 @@ import TestLib.Util tests :: LanguageSpec tests = describe "Rust" $ introduceNixEnvironment [kernelSpec] [] "Rust" $ introduceJupyterRunner $ do testKernelSearchersBuild "rust" + testHasExpectedFields "rust" testKernelStdout "rust" [__i|println!("hi")|] "hi\n" diff --git a/tests/src/TestLib/TestSearchers.hs b/tests/src/TestLib/TestSearchers.hs index 99c95b82..92278e5a 100644 --- a/tests/src/TestLib/TestSearchers.hs +++ b/tests/src/TestLib/TestSearchers.hs @@ -29,18 +29,20 @@ testKernelSearchersBuild :: ( HasBaseContext context, MonadIO m, MonadMask m, MonadUnliftIO m, MonadBaseControl IO m ) => Text -> SpecFree context m () testKernelSearchersBuild kernel = it [i|#{kernel}: package searchers build|] $ do - testPackageSearchBuild kernel - testHasSettingsSchema kernel + testBuild [i|.\#languages."#{kernel}".packageSearch|] -testPackageSearchBuild :: ( +testHasExpectedFields :: ( HasBaseContext context, MonadIO m, MonadMask m, MonadUnliftIO m, MonadBaseControl IO m - ) => Text -> ExampleT context m () -testPackageSearchBuild kernel = testBuild [i|.\#languages."#{kernel}".packageSearch|] - -testHasSettingsSchema :: ( - HasBaseContext context, MonadIO m, MonadMask m, MonadUnliftIO m, MonadBaseControl IO m - ) => Text -> ExampleT context m () -testHasSettingsSchema kernel = testEval [i|.\#languages."#{kernel}".meta.settingsSchema|] + ) => Text -> SpecFree context m () +testHasExpectedFields kernel = it [i|#{kernel}: has expected fields|] $ do + testEval [i|.\#languages."#{kernel}".settingsSchema|] + testEval [i|.\#languages."#{kernel}".modes|] + testEval [i|.\#languages."#{kernel}".settings|] + testEval [i|.\#languages."#{kernel}".args|] + testEval [i|.\#languages."#{kernel}".meta|] + + -- Used to view all versions in codedown-languages + testEval [i|.\#languages."#{kernel}".versions|] -- Testing for nonempty results