diff --git a/.aliases/verify-default-nix b/.aliases/verify-default-nix index ff573390..fc78da6a 100755 --- a/.aliases/verify-default-nix +++ b/.aliases/verify-default-nix @@ -9,16 +9,16 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$SCRIPTDIR/.." FLAKE_NIXPKGS_REV=$(nix flake metadata --json | jq -r .locks.nodes.nixpkgs.locked.rev) -FLAKE_NIXPKGS_UNSTABLE_REV=$(nix flake metadata --json | jq -r '.locks.nodes["nixpkgs-unstable"].locked.rev') +FLAKE_NIXPKGS_MASTER_REV=$(nix flake metadata --json | jq -r '.locks.nodes["nixpkgs-master"].locked.rev') echo "FLAKE_NIXPKGS_REV: $FLAKE_NIXPKGS_REV" -echo "FLAKE_NIXPKGS_UNSTABLE_REV: $FLAKE_NIXPKGS_UNSTABLE_REV" +echo "FLAKE_NIXPKGS_MASTER_REV: $FLAKE_NIXPKGS_MASTER_REV" DEFAULT_NIXPKGS_REV=$(cat default.nix | grep nixpkgs-rev | cut -d'"' -f2) -DEFAULT_NIXPKGS_UNSTABLE_REV=$(cat default.nix | grep nixpkgs-unstable-rev | cut -d'"' -f2) +DEFAULT_NIXPKGS_MASTER_REV=$(cat default.nix | grep nixpkgs-master-rev | cut -d'"' -f2) echo "DEFAULT_NIXPKGS_REV: $DEFAULT_NIXPKGS_REV" -echo "DEFAULT_NIXPKGS_UNSTABLE_REV: $DEFAULT_NIXPKGS_UNSTABLE_REV" +echo "DEFAULT_NIXPKGS_MASTER_REV: $DEFAULT_NIXPKGS_MASTER_REV" if [ "$FLAKE_NIXPKGS_REV" != "$DEFAULT_NIXPKGS_REV" ]; then @@ -26,7 +26,7 @@ if [ "$FLAKE_NIXPKGS_REV" != "$DEFAULT_NIXPKGS_REV" ]; then exit 1 fi -if [ "$FLAKE_NIXPKGS_UNSTABLE_REV" != "$DEFAULT_NIXPKGS_UNSTABLE_REV" ]; then - echo "nixpkgs-unstable rev differed between flake and default.nix" +if [ "$FLAKE_NIXPKGS_MASTER_REV" != "$DEFAULT_NIXPKGS_MASTER_REV" ]; then + echo "nixpkgs-master rev differed between flake and default.nix" exit 1 fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c1f1760..e7250444 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,28 @@ jobs: if: "!contains(github.event.head_commit.message, 'noci')" run: ./.aliases/verify-default-nix + build-ui-metadata: + runs-on: self-hosted + + steps: + - uses: actions/checkout@v4 + + - name: Build .#ui_metadata_farm + if: "!contains(github.event.head_commit.message, 'noci')" + run: | + nix build .#ui_metadata_farm + + build-sample-environments: + runs-on: self-hosted + + steps: + - uses: actions/checkout@v4 + + - name: Build .#sample_environments_farm + if: "!contains(github.event.head_commit.message, 'noci')" + run: | + nix build .#sample_environments_farm + test: name: ${{matrix.suite.name}} (${{matrix.suite.flags}}) runs-on: self-hosted @@ -37,13 +59,15 @@ jobs: - name: haskell flags: "-f haskell-ghc98" - name: julia + flags: "-f julia_19" + - name: julia + flags: "-f julia_110" - name: octave - name: postgres - name: python - name: r - name: ruby - name: rust - - name: sample-environments - name: searchers - name: zsh - name: spellchecker @@ -58,7 +82,7 @@ jobs: run: | cd tests - export NIX_PATH=nixpkgs=$(nix run .#nixpkgsUnstablePath) + export NIX_PATH=nixpkgs=$(nix run .#nixpkgsPath) export PATH=$(nix build --no-link .#stack.x86_64-linux --json | jq -r '.[0].outputs.out')/bin:$PATH echo "Got path: $PATH" @@ -74,7 +98,7 @@ jobs: echo "Got TEST_ROOT: $TEST_ROOT" echo TEST_ROOT="$TEST_ROOT" >> $GITHUB_ENV - export NIX_PATH=nixpkgs=$(nix run .#nixpkgsUnstablePath) + export NIX_PATH=nixpkgs=$(nix run .#nixpkgsPath) export PATH=$(nix build --no-link .#stack.x86_64-linux --json | jq -r '.[0].outputs.out')/bin:$PATH stack run --nix --no-nix-pure -- \ diff --git a/channels.nix b/channels.nix deleted file mode 100644 index 55e0683a..00000000 --- a/channels.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ lib -, fetchFromGitHub -, fetchgit -, overlays -}: - -let - - channelSpecToChannel = name: channel: - if (channel.tag == "fetch_from_github") then fetchFromGitHub ((removeAttrs channel ["tag" "name"])) - else if (channel.tag == "fetch_git") then fetchgit (removeAttrs channel ["tag" "name"]) - else if (channel.tag == "path") then channel.path else null; - -in - -rec { - channels = { - nixpkgs = { - tag = "fetch_from_github"; - owner = "NixOS"; - repo = "nixpkgs"; - rev = "973910f5c31b9ba6c171c33a8bd7199990b14c72"; - sha256 = "1n1kibmn1fcjazaxp8lydwdx646lknqksv5b2fm33fdq2dvafvj7"; - }; - - nixpkgs-unstable = { - tag = "fetch_from_github"; - owner = "NixOS"; - repo = "nixpkgs"; - rev = "ecaf3da9340231e5493eccc3db87604a3705da42"; - sha256 = "049dcpzklpjj0c7g172njfcqb9xvxkpyf7qjiwvaf8klgd5cippa"; - }; - }; - - importedOverlays = lib.mapAttrsToList (name: value: import (channelSpecToChannel name value)) overlays; - importedChannels = lib.mapAttrs (name: value: import (channelSpecToChannel name value) { overlays = importedOverlays; }) channels; -} diff --git a/codedown.nix b/codedown.nix index 64f23f23..b2f1f407 100644 --- a/codedown.nix +++ b/codedown.nix @@ -1,99 +1,68 @@ { pkgsStable -, pkgsUnstable , pkgsMaster , requiredPackages ? [] , system ? "x86_64-linux" }: let - common = pkgsStable.callPackage ./languages/common.nix {}; + common = pkgsStable.callPackage ./modules/languages/common.nix {}; callPackage = pkgsStable.callPackage; - # Languages - # First argument controls whether attributes get filtered to the valid ones. - # This can be expensive to evaluate for languages like Haskell where there are tons of - # Stackage snapshots and one nix file for each. So, we don't bother with that when evaluating - # the languages attrset normally--only when building the languagesSearcher. - languagesFn = filterToValid: pkgsStable.lib.zipAttrsWith (n: v: pkgsStable.lib.head v) [ - (callPackage ./languages/bash {}) - (callPackage ./languages/clojure {}) - (callPackage ./languages/coq {}) - (pkgsMaster.callPackage ./languages/cpp {}) - (callPackage ./languages/go {}) - (pkgsMaster.callPackage ./languages/haskell {}) - (callPackage ./languages/julia {}) - (callPackage ./languages/octave {}) - (callPackage ./languages/postgres {}) - (callPackage ./languages/python { - poetry2nix = import (pkgsStable.fetchFromGitHub { - owner = "nix-community"; - repo = "poetry2nix"; - rev = "78fc8882411c29c8eb5f162b09fcafe08b8b03a3"; - sha256 = "1dfgm286c48ac6yrk16xz41d0rsg6bv08122ngy420b0z88la9nj"; - }) { - pkgs = pkgsStable; - }; - }) - (callPackage ./languages/r {}) - (pkgsMaster.callPackage ./languages/ruby {}) - (pkgsMaster.callPackage ./languages/rust {}) - ]; - lib = pkgsStable.lib; in rec { - spellchecker = pkgsUnstable.callPackage ./language_servers/markdown-spellcheck-lsp {}; - - languages = languagesFn false; - - shells = { - zsh = callPackage ./shells/zsh {}; - fish = callPackage ./shells/fish {}; - bash = callPackage ./shells/bash {}; - }; - - exporters = { - nbconvert-small = pkgsMaster.callPackage ./exporters/nbconvert.nix { texliveScheme = pkgsStable.texlive.combined.scheme-small; }; - nbconvert-large = pkgsMaster.callPackage ./exporters/nbconvert.nix { texliveScheme = pkgsStable.texlive.combined.scheme-full; }; - }; + spellchecker = pkgsMaster.callPackage ./modules/language_servers/markdown-spellcheck-lsp {}; testing = { - builds-forever = pkgsMaster.callPackage ./misc/builds-forever.nix {}; + builds-forever = pkgsMaster.callPackage ./modules/testing/builds-forever.nix {}; }; # Exported so clients can build searchers for other package sets, like "codedown.searcher nixpkgs" searcher = common.searcher; - codedownSearcher = common.searcher' { - # Note that we deliberately don't include "testing" packages in the searcher - packages = languagesFn true - // (lib.mapAttrs' (n: v: lib.nameValuePair ("shells." + n) v) shells) - // (lib.mapAttrs' (n: v: lib.nameValuePair ("exporters." + n) v) exporters) - // { inherit spellchecker; }; - }; + settingsSchemas = lib.mapAttrs (attr: value: value.meta.settingsSchema or []) languages; - languagesIcons = common.searcherIcons' { - packages = languagesFn true; - packageMustBeDerivation = false; + evaluateConfig = callPackage ./nix/evaluate-config.nix { + inherit pkgsStable pkgsMaster; }; - settingsSchemas = lib.mapAttrs (attr: value: - common.safeEval (lib.attrByPath ["meta" "settingsSchema"] [] value) - ) languages; + everythingConfig = let + base = evaluateConfig {}; + kernelNames = builtins.attrNames base.options.kernels; + shellNames = builtins.attrNames base.options.shells; + exporterNames = builtins.attrNames base.options.exporters; + in + builtins.foldl' lib.recursiveUpdate {} ( + (map (n: { kernels.${n}.enable = true; }) kernelNames) + ++ (map (n: { shells.${n}.enable = true; }) shellNames) + ++ (map (n: { exporters.${n}.enable = true; }) exporterNames) + ); - mkCodeDownEnvironment = callPackage ./codedown/mkCodeDownEnvironment.nix { - inherit requiredPackages languages; + everythingEnv = evaluateConfig everythingConfig; + + codedownSearcher = common.searcher' { + # Note that we deliberately don't include "testing" packages in the searcher + packages = everythingEnv.config.builtKernels + // (lib.mapAttrs' (n: v: lib.nameValuePair ("shells." + n) v) everythingEnv.config.builtShells) + // (lib.mapAttrs' (n: v: lib.nameValuePair ("exporters." + n) v) everythingEnv.config.builtExporters) + // { "language-servers.spellchecker" = spellchecker; } + ; }; - makeEnvironment = callPackage ./codedown/makeEnvironment.nix { - inherit pkgsStable pkgsUnstable pkgsMaster; + languages = everythingEnv.config.builtKernels; + + makeEnvironment = callPackage ./nix/makeEnvironment.nix { + inherit pkgsStable pkgsMaster; }; - validateCodeDownEnvironment = callPackage ./codedown/validateCodeDownEnvironment.nix {}; + validateEnvironment = callPackage ./nix/validateEnvironment.nix {}; + + # Exposed for consumers to pin and use to gather metadata from other channels like Nixpkgs + inherit (callPackage ./nix/uiMetadata.nix {}) chooseInterestingMeta; # Exposed so it's easier to compute build dependencies in the presence of IFD - inherit pkgsStable pkgsUnstable requiredPackages; + inherit pkgsStable pkgsMaster requiredPackages; } diff --git a/codedown/makeEnvironment.nix b/codedown/makeEnvironment.nix deleted file mode 100644 index 326d3796..00000000 --- a/codedown/makeEnvironment.nix +++ /dev/null @@ -1,116 +0,0 @@ -{ callPackage -, lib -, fetchgit -, fetchFromGitHub -, symlinkJoin -, system -, writeTextDir -, writeText - -, pkgsStable -, pkgsUnstable -, pkgsMaster - -, name ? "codedown-environment" -}: - -config: - -with lib; - -let - evaluated = lib.evalModules { - specialArgs = { - nixosOptionsToSettingsSchema = pkgsStable.callPackage ../modules/base/nixos-options-to-settings-schema.nix {}; - }; - modules = [ - ../modules/base.nix - - ../exporters/module.nix - - ../languages/bash/module.nix - ../languages/clojure/module.nix - ../languages/coq/module.nix - ../languages/cpp/module.nix - ../languages/go/module.nix - ../languages/haskell/module.nix - ../languages/julia/module.nix - ../languages/octave/module.nix - ../languages/postgres/module.nix - ../languages/python/module.nix - ../languages/r/module.nix - ../languages/ruby/module.nix - ../languages/rust/module.nix - - ../language_servers/markdown-spellcheck-lsp/module.nix - - ../shells/bash/module.nix - ../shells/fish/module.nix - ../shells/zsh/module.nix - - { - config = { - pkgs = pkgsStable; - }; - } - { - inherit config; - } - ]; - }; - - builtKernels = mapAttrs (_: kernel: - kernel.overrideAttrs (old: { - passthru = old.passthru // { - name = kernel.name; - # channel = kernel.channel; - channel = "codedown"; - }; - })) evaluated.config.builtKernels; - builtShells = evaluated.config.builtShells; - builtExporters = evaluated.config.builtExporters; - - repls = let - shellToReplInfo = shell: { - name = shell.name; - display_name = shell.meta.displayName; - attr = shell.meta.attr; - args = shell.meta.args; - icon = shell.meta.icon; - }; - in - map shellToReplInfo (attrValues builtShells) - ++ concatMap (kernel: lib.mapAttrsToList (name: value: value // { inherit name; }) (if kernel.passthru ? "repls" then kernel.passthru.repls else {})) (attrValues builtKernels) - ; - - exporters = concatMap (exporter: exporter.meta.exporterInfos) (attrValues builtExporters); - - uiMetadata = callPackage ./uiMetadata.nix {}; - -in - -symlinkJoin { - inherit name; - paths = - attrValues (evaluated.config.builtKernels) - ++ lib.optionals (builtins.length repls > 0) [(writeTextDir "lib/codedown/repls.yaml" (lib.generators.toYAML {} repls))] - ++ lib.optionals (builtins.length exporters > 0) [(writeTextDir "lib/codedown/exporters.yaml" (lib.generators.toYAML {} exporters))] - ++ evaluated.config.packages - ; - - passthru = rec { - inherit evaluated; - - inherit channels; - - ui_metadata = { - # channels = lib.mapAttrsToList uiMetadata.mkChannelUiMetadata channels; - - kernels = map uiMetadata.mkKernelUiMetadata (attrValues builtKernels); - - # other_packages = map uiMetadata.mkOtherPackageUiMetadata otherPackages; - }; - - ui_metadata_yaml = writeText "ui-metadata.yaml" (lib.generators.toYAML {} ui_metadata); - }; -} diff --git a/codedown/mkCodeDownEnvironment.nix b/codedown/mkCodeDownEnvironment.nix deleted file mode 100644 index 7d3b7024..00000000 --- a/codedown/mkCodeDownEnvironment.nix +++ /dev/null @@ -1,76 +0,0 @@ -{ callPackage -, lib -, linkFarm -, symlinkJoin -, writeText -, writeTextDir - -, requiredPackages -, languages -}: - -args@{ - channels - , environmentName ? "codedown-environment" - , kernels ? [] - , otherPackages ? [] -}: - -with lib; - -let - languagesCommon = callPackage ../languages/common.nix {}; - shellsCommon = callPackage ../shells/common.nix {}; - - builtKernels = map (x: let kernel = (getAttr x.name languages).override x.args; in - kernel.overrideAttrs (old: { - passthru = old.passthru // { - name = x.name; - channel = x.channel; - }; - })) kernels; - - shells = filter (x: lib.hasPrefix "shells." x.attr) otherPackages; - - exporters = filter (x: lib.hasPrefix "exporters." x.attr) otherPackages; - exporterInfos = concatMap (exporter: exporter.contents.meta.exporterInfos) exporters; - - repls = let - shellToReplInfo = shell: { - name = shell.contents.name; - display_name = shell.contents.displayName; - attr = shell.contents.attr; - args = ["${shell.contents}/lib/codedown/shell"]; - icon = shell.contents.icon; - }; - in - map shellToReplInfo shells - ++ concatMap (kernel: lib.mapAttrsToList (name: value: value // { inherit name; }) (if kernel.passthru ? "repls" then kernel.passthru.repls else {})) builtKernels - ; - - uiMetadata = callPackage ./uiMetadata.nix {}; - -in - -symlinkJoin { - name = environmentName; - paths = builtKernels - ++ [(shellsCommon.wrapShells shells)] - ++ (map (x: x.contents) otherPackages) - ++ requiredPackages - ++ [(writeTextDir "lib/codedown/repls.yaml" (lib.generators.toYAML {} repls))] - ++ [(writeTextDir "lib/codedown/exporters.yaml" (lib.generators.toYAML {} exporterInfos))] - ; - - passthru = rec { - ui_metadata = { - # channels = lib.mapAttrsToList uiMetadata.mkChannelUiMetadata channels; - - kernels = map uiMetadata.mkKernelUiMetadata builtKernels; - - other_packages = map uiMetadata.mkOtherPackageUiMetadata otherPackages; - }; - - ui_metadata_yaml = writeText "ui-metadata.yaml" (lib.generators.toYAML {} ui_metadata); - }; -} diff --git a/default.nix b/default.nix index 10f3bb37..55db0e78 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,10 @@ { fetchFromGitHub +, isCodeDown ? true # For introspection using builtins.functionArgs , ... }: let - overlays = [(import ./overlays.nix)]; + overlays = []; pkgsStable = import (fetchFromGitHub { owner = "NixOS"; @@ -12,13 +13,6 @@ let hash = "sha256-D2YTs7K33zAzoQdAcVzePgDn6bdIEexGgHluoB07+Yw="; # nixpkgs-sha256 }) { inherit overlays; }; - pkgsUnstable = import (fetchFromGitHub { - owner = "NixOS"; - repo = "nixpkgs"; - rev = "ab82a9612aa45284d4adf69ee81871a389669a9e"; # nixpkgs-unstable-rev - hash = "sha256-5r0pInVo5d6Enti0YwUSQK4TebITypB42bWy5su3MrQ="; # nixpkgs-unstable-sha256 - }) { inherit overlays; }; - pkgsMaster = import (fetchFromGitHub { owner = "NixOS"; repo = "nixpkgs"; @@ -28,4 +22,4 @@ let in -pkgsStable.callPackage ./codedown.nix { inherit pkgsStable pkgsUnstable pkgsMaster; } +pkgsStable.callPackage ./codedown.nix { inherit pkgsStable pkgsMaster; } diff --git a/flake.lock b/flake.lock index 9d4906a2..1e83b647 100644 --- a/flake.lock +++ b/flake.lock @@ -47,28 +47,11 @@ "type": "github" } }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1720368505, - "narHash": "sha256-5r0pInVo5d6Enti0YwUSQK4TebITypB42bWy5su3MrQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ab82a9612aa45284d4adf69ee81871a389669a9e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "nixpkgs-master": "nixpkgs-master", - "nixpkgs-unstable": "nixpkgs-unstable" + "nixpkgs-master": "nixpkgs-master" } } }, diff --git a/flake.nix b/flake.nix index 603917e7..922c5594 100644 --- a/flake.nix +++ b/flake.nix @@ -2,26 +2,30 @@ description = "CodeDown languages"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-24.05"; - inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.nixpkgs-master.url = "github:NixOS/nixpkgs/master"; inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-master, flake-utils }@inputs: + outputs = { self, nixpkgs, nixpkgs-master, flake-utils }@inputs: flake-utils.lib.eachDefaultSystem (system: let - overlays = [(import ./overlays.nix)]; + overlays = []; pkgsStable = import nixpkgs { inherit system overlays; }; - pkgsUnstable = import nixpkgs-unstable { inherit system overlays; }; pkgsMaster = import nixpkgs-master { inherit system overlays; }; - codedown = import ./codedown.nix { inherit pkgsStable pkgsUnstable pkgsMaster; }; + codedown = import ./codedown.nix { inherit pkgsStable pkgsMaster; }; in rec { packages = { # For nix repl debugging - inherit codedown; + # inherit codedown; + + # Tests use flake to do packageSearch builds + inherit (codedown) languages; + + # For .envrc + nixpkgsPath = pkgsStable.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgsStable.path}"; jupyter-runner = pkgsMaster.callPackage ./nix/jupyter-runner.nix {}; diff --git a/languages/bash/default.nix b/languages/bash/default.nix deleted file mode 100644 index 4e35a386..00000000 --- a/languages/bash/default.nix +++ /dev/null @@ -1,76 +0,0 @@ -{ callPackage -, lib -, pkgs -, python3 -, nodePackages -, symlinkJoin -, writeTextDir -}: - -let - common = callPackage ../common.nix {}; - - baseCandidates = [ - "bash" - ]; - - settingsSchema = [ - { - target = "lsp.bash-language-server.enable"; - title = "Enable Bash language server"; - type = "boolean"; - defaultValue = true; - } - ]; - -in - -lib.listToAttrs (map (x: { - name = x; - value = - lib.makeOverridable ({ - packages ? [] - , attrs ? ["bash"] - , extensions ? ["sh" "bash"] - , settings ? {} - }@args: - let - bash = lib.getAttr x pkgs; - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - languageServers = lib.optionals (common.isTrue settings "lsp.bash-language-server.enable") [(callPackage ./language_server_bash { kernelName = x; })]; - in symlinkJoin { - name = "bash"; - - paths = [ - (callPackage ./kernel.nix { inherit attrs extensions; }) - (callPackage ./man-with-pages.nix {}) - ] - ++ languageServers - ; - - passthru = { - args = args // { baseName = x; }; - meta = bash.meta // { - baseName = x; - displayName = "Bash " + bash.version; - version = bash.version; - icon = ./bash-logo-128x128.png; - inherit settingsSchema; - }; - versions = { - bash = bash.version; - bash-language-server = nodePackages.bash-language-server.version; - bash_kernel = python3.pkgs.bash_kernel.version; - }; - packageOptions = {}; - packageSearch = common.searcher {}; - inherit settingsSchema settings; - modes = { - inherit attrs extensions; - code_mirror_mode = "shell"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {}; -}) (lib.filter (x: lib.hasAttr x pkgs) baseCandidates)) diff --git a/languages/clojure/default.nix b/languages/clojure/default.nix deleted file mode 100644 index 26e1a27c..00000000 --- a/languages/clojure/default.nix +++ /dev/null @@ -1,104 +0,0 @@ -{ lib -, pkgs -, callPackage -, stdenv -, writeTextDir -, symlinkJoin -}: - -let - common = callPackage ../common.nix {}; - - baseCandidates = [ - "clojure" - ]; - - packagesLookup = { - clojure = {}; - }; - - repls = clojure: { - clojure = { - display_name = "Clojure " + clojure.version; - attr = "clojure"; - args = ["${clojure}/bin/clojure"]; - icon = ./clojure-logo-64x64.png; - }; - }; - - settingsSchema = [ - { - target = "lsp.clojure-lsp.enable"; - title = "Enable clojure-lsp language server"; - type = "boolean"; - defaultValue = true; - } - ]; - - clojure-lsp = callPackage ./clojure-lsp.nix {}; - - chooseLanguageServers = settings: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.clojure-lsp.enable") [(callPackage ./language-server.nix { inherit clojure-lsp kernelName; })] - ; - -in - -with lib; - -listToAttrs (map (x: - let - clojure = getAttr x pkgs; - - meta = clojure.meta // { - baseName = x; - displayName = "Clojure"; - version = clojure.version; - icon = ./clojure-logo-64x64.png; - inherit settingsSchema; - }; - - packageOptions = getAttr x packagesLookup; - packageSearch = common.searcher packageOptions; - versions = { - clojure = clojure.version; - clojure-lsp = clojure-lsp.version; - }; - - in { - name = x; - value = lib.makeOverridable (args@{ - packages ? [] - , settings ? {} - , attrs ? ["clojure"] - , extensions ? ["clj"] - }: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - languageServers = chooseLanguageServers settingsToUse x; - in symlinkJoin { - name = "clojure"; - paths = [ - (callPackage ./kernel.nix { inherit attrs extensions version; }) - clojure - ] - ++ languageServers - ; - - passthru = { - inherit meta packageOptions packageSearch versions; - inherit settingsSchema settings; - args = args // { baseName = x; }; - repls = repls clojure; - modes = { - inherit attrs extensions; - code_mirror_mode = "clojure"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {} - ; - } - -) (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 deleted file mode 100644 index b60e1fa1..00000000 --- a/languages/coq/default.nix +++ /dev/null @@ -1,112 +0,0 @@ -{ pkgs -, lib -, callPackage -, symlinkJoin -, stdenv -}: - -let - common = callPackage ../common.nix {}; - - repls = coq: {}; - - coq_jupyter = callPackage ./coq_jupyter {}; - - baseCandidates = [ - "coqPackages" - "coqPackages_8_5" - "coqPackages_8_6" - "coqPackages_8_7" - "coqPackages_8_8" - "coqPackages_8_9" - "coqPackages_8_10" - "coqPackages_8_11" - "coqPackages_8_12" - "coqPackages_8_13" - "coqPackages_8_14" - "coqPackages_8_15" - "coqPackages_8_16" - "coqPackages_8_17" - "coqPackages_8_18" - "coqPackages_8_19" - "coqPackages_8_20" - "coqPackages_8_21" - "coqPackages_8_22" - "coqPackages_8_23" - "coqPackages_8_24" - "coqPackages_8_25" - ]; - - latestAvailable = lib.last (lib.filter (x: lib.hasAttr x pkgs) baseCandidates); - - isLessCommon = candidate: !(lib.elem candidate ["coqPackages" latestAvailable]); - - settingsSchema = []; - - 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; - }; - - packageOptions = coqPackages; - packageSearch = common.searcher packageOptions; - versions = { - coq = baseCoq.version; - }; - - in { - name = baseName; - 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 deleted file mode 100644 index 1b512dc0..00000000 --- a/languages/cpp/default.nix +++ /dev/null @@ -1,125 +0,0 @@ -{ lib -, callPackage -, writeTextDir -, symlinkJoin -, cling -, clang -, llvmPackages_13 -, xeus-cling -}: - -let - common = callPackage ../common.nix {}; - - # Fix for https://github.com/NixOS/nixpkgs/issues/306782 - clingToUse = cling.override { - llvmPackages_13 = llvmPackages_13.override { enableSharedLibraries = false; }; - }; - xeusClingToUse = xeus-cling.override { - cling = clingToUse; - }; - - baseCandidates = [ - # "cpp98" - "cpp11" - "cpp14" - "cpp17" - "cpp20" - "cpp23" - ]; - - icons = { - # cpp98 = ./cpp11-logo-64x64.png; # TODO - cpp11 = ./cpp11-logo-64x64.png; - cpp14 = ./cpp14-logo-64x64.png; - cpp17 = ./cpp17-logo-64x64.png; - cpp20 = ./cpp2a-logo-64x64.png; # TODO - cpp23 = ./cpp2a-logo-64x64.png; # TODO - }; - - stds = { - # cpp98 = "c++98"; - cpp11 = "c++11"; - cpp14 = "c++14"; - cpp17 = "c++17"; - cpp20 = "c++20"; - cpp23 = "c++23"; - }; - - settingsSchema = []; - - repls = icon: { - cling = { - display_name = "Cling " + clingToUse.unwrapped.version; - attr = "cling"; - args = ["${clingToUse}/bin/cling"]; - icon = icon; - }; - }; - -in - -with lib; - -listToAttrs (map (x: - let - std = getAttr x stds; - - displayName = "C++"; - - meta = clang.meta // { - baseName = x; - inherit displayName; - version = clang.version; - icon = getAttr x icons; - inherit settingsSchema; - }; - - packageOptions = {}; - packageSearch = common.searcher packageOptions; - versions = { - clang = clang.version; - cling = cling.unwrapped.version; - xeus-cling = xeus-cling.version; - std = std; - }; - - in { - name = x; - 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 { - cling = clingToUse; - xeus-cling = xeusClingToUse; - 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"; - }; - languageServerNames = []; - }; - } - ) {}; - } -) baseCandidates) diff --git a/languages/go/default.nix b/languages/go/default.nix deleted file mode 100644 index 88605cb4..00000000 --- a/languages/go/default.nix +++ /dev/null @@ -1,101 +0,0 @@ -{ callPackage -, gopls -, lib -, pkgs -, symlinkJoin -}: - -let - common = callPackage ../common.nix {}; - - baseCandidates = [ - "go" - "go_1_17" - "go_1_18" - "go_1_19" - ]; - - settingsSchema = [ - { - target = "lsp.gopls.enable"; - title = "Enable gopls language server"; - type = "boolean"; - defaultValue = true; - } - - { - target = "go.gocache"; - title = "Value of GOCACHE environment variable"; - type = "string"; - defaultValue = "/home/.gocache"; - } - ]; - - chooseLanguageServers = settings: go: attrs: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.gopls.enable") [(callPackage ./language-server-gopls.nix { inherit go attrs; inherit kernelName; })] - ; - - repls = go: {}; - -in - -with lib; - -listToAttrs (map (x: - let - go = getAttr x pkgs; - - meta = go.meta // { - baseName = x; - displayName = "Go"; - version = go.version; - icon = ./go-logo-64x64.png; - inherit settingsSchema; - }; - - packageOptions = {}; - packageSearch = common.searcher packageOptions; - versions = { - go = go.version; - gopls = gopls.version; - }; - - in { - name = x; - value = lib.makeOverridable ({ - packages ? [] - , settings ? {} - , attrs ? ["go"] - , extensions ? ["go"] - }@args: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - languageServers = chooseLanguageServers settingsToUse go attrs x; - in symlinkJoin { - name = "go"; - paths = [ - (callPackage ./kernel.nix { - inherit attrs extensions; - version = go.version; - }) - go - ] - ++ languageServers - ; - - passthru = { - inherit meta packageOptions packageSearch versions; - inherit settingsSchema settings; - args = args // { baseName = x; }; - repls = repls go; - modes = { - inherit attrs extensions; - code_mirror_mode = "go"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {}; - } -) (lib.filter (x: lib.hasAttr x pkgs) baseCandidates)) diff --git a/languages/haskell/default.nix b/languages/haskell/default.nix deleted file mode 100644 index 4c460837..00000000 --- a/languages/haskell/default.nix +++ /dev/null @@ -1,127 +0,0 @@ -{ lib -, callPackage -, runCommand -, fetchFromGitHub -, stdenv -, symlinkJoin -, makeWrapper - -, haskell -, ltsOnly ? true -}: - -with lib; - -let - common = callPackage ../common.nix {}; - - hasHlsSupport = version: builtins.compareVersions version "9.0" >= 0; - - chooseLanguageServers = settings: snapshot: ghc: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.haskell-language-server.enable" && hasHlsSupport ghc.version) - [((callPackage ./language-server-hls {}) snapshot ghc kernelName (common.focusSettings "lsp.haskell-language-server." settings))] - ; - - compilers = callPackage ./compilers.nix { - ihaskell-source = fetchFromGitHub { - owner = "codedownio"; - repo = "IHaskell"; - rev = "72e663bcc1af12fc136d19941cf21efdf7341379"; - sha256 = "WSXrx+/iAiGa8qIJc7Wt6VxL9adw5KFt6FfaiOH/mjg="; - }; - }; - - repls = ghc: { - ghci = { - display_name = "GHCi " + ghc.version; - attr = "ghci"; - args = ["${ghc}/bin/ghci"]; - icon = ./haskell-logo-64x64.png; - }; - }; - -in - -listToAttrs (mapAttrsToList (compilerName: snapshot: - let - version = snapshot.ghc.version; - displayName = "Haskell"; - - settingsSchema = callPackage ./settings_schema.nix { inherit version; }; - - meta = { - baseName = "haskell-" + compilerName; - name = "haskell-" + compilerName; - description = "An advanced, purely functional programming language (GHC ${version})"; - inherit version displayName settingsSchema; - 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 = 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 []) - ); - languageServers = chooseLanguageServers settingsToUse snapshot ghc meta.baseName; - - 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 - ] - ++ languageServers - ; - - 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"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {} - ; - } -) (lib.filterAttrs (k: _: !(hasPrefix "override") k) compilers)) diff --git a/languages/julia/default.nix b/languages/julia/default.nix deleted file mode 100644 index 4c27a73b..00000000 --- a/languages/julia/default.nix +++ /dev/null @@ -1,175 +0,0 @@ -{ lib -, julia_16-bin -, julia_18 -, julia_19 -, julia_110 -, python3 -, callPackage -, fetchFromGitHub -, writeTextDir -, stdenv -, runCommand -, symlinkJoin -}: - -let - common = callPackage ../common.nix {}; - - juliaWithPackages = callPackage ./julia-modules {}; - - settingsSchema = [ - { - target = "precompile"; - title = "Precompile environment"; - description = "Whether to precompile Julia code when building the environment for faster imports. In some cases, precompilation can make the build fail, so turning this off can help."; - type = "boolean"; - defaultValue = true; - } - { - target = "lsp.LanguageServer.enable"; - title = "Enable LanguageServer language server"; - type = "boolean"; - defaultValue = true; - } - { - target = "lsp.LanguageServer.index"; - title = "LanguageServer: auto-index packages when building environment"; - description = "Automatically build SymbolServer.jl indices when realizing environment (may increase build time)."; - type = "boolean"; - defaultValue = true; - } - { - target = "lsp.LanguageServer.debug"; - title = "LanguageServer: stderr debugging"; - description = "Log debug messages to stderr."; - type = "boolean"; - defaultValue = false; - } - ]; - - 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; - })] - ; - - packageOverrides = { - "LanguageServer" = fetchFromGitHub { - owner = "julia-vscode"; - repo = "LanguageServer.jl"; - rev = "3a000de8d80b2d374d46517a813882ff1aeb895c"; - sha256 = "0pjwmz6g7fvkqhr4axh4bl7lkpk8fgv7193m7ql8pw9lif8mqx37"; - }; - "StaticLint" = fetchFromGitHub { - owner = "julia-vscode"; - repo = "StaticLint.jl"; - rev = "8334959b9fe1a7f3169621a250eb8ff98db64775"; - sha256 = "0sxn05b3m1fqcsyp28zddslh7dy4wsrkvhc57nx6y89j30ldbpw1"; - }; - "SymbolServer" = fetchFromGitHub { - owner = "codedownio"; - repo = "SymbolServer.jl"; - rev = "1badb724cebef0ae867c8c1f73cb08efe5b6e291"; - sha256 = "0j4cjj50mp0cm6aq684kasijk11pwagp3v9d1mf39isk6afa7inn"; - }; - - # "LanguageServer" = /home/tom/tools/LanguageServer.jl; - # "StaticLint" = /home/tom/tools/StaticLint.jl; - # "SymbolServer" = /home/tom/tools/SymbolServer.jl; - }; - - baseCandidates = rec { - julia = julia110; - - julia16 = juliaWithPackages.override { inherit packageOverrides; julia = julia_16-bin; }; - - # Removed as EOL in release 24.05 - # julia18 = juliaWithPackages.override { inherit packageOverrides; julia = julia_18; }; - - julia19 = juliaWithPackages.override { inherit packageOverrides; julia = julia_19; }; - - julia110 = juliaWithPackages.override { inherit packageOverrides; julia = julia_110; }; - }; - - packageSet = lib.listToAttrs (map (x: { - name = x; - value = { - meta = { - name = x; - displayName = x; - }; - }; - }) (import ./julia-modules/package-names.nix)); - -in - -with lib; - -mapAttrs (attr: value: - let - baseJulia = (value []).julia; - - displayName = "Julia"; - - meta = baseJulia.meta // { - baseName = attr; - inherit displayName settingsSchema; - version = baseJulia.version; - icon = ./julia-logo-64x64.png; - }; - - python = python3; - - packageOptions = {}; - packageSearch = common.searcher' { - packages = packageSet; - packageMustBeDerivation = false; - }; - versions = { - julia = baseJulia.version; - }; - - in - lib.makeOverridable ({ - packages ? [] - , attrs ? [attr "julia"] - , extensions ? ["jl"] - , settings ? {} - }@args: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - - julia = (value.override { inherit (settingsToUse) precompile; }) ( - ["IJulia"] - ++ packages - ++ lib.optionals (common.isTrue settingsToUse "lsp.LanguageServer.enable") ["LanguageServer" "SymbolServer"] - ); - - languageServers = chooseLanguageServers settingsToUse attrs attr julia; - in - symlinkJoin { - name = attr; - - paths = [ - (callPackage ./kernel.nix { inherit julia python attrs extensions displayName; }) - julia - ] - ++ languageServers - ; - - passthru = { - args = args // { baseName = attr; }; - inherit meta packageOptions packageSearch versions; - inherit settingsSchema settings; - modes = { - inherit attrs extensions; - code_mirror_mode = "julia"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {} -) baseCandidates diff --git a/languages/octave/default.nix b/languages/octave/default.nix deleted file mode 100644 index 68a11c4b..00000000 --- a/languages/octave/default.nix +++ /dev/null @@ -1,121 +0,0 @@ -{ lib -, pkgs - -, callPackage -, jupyter-kernel -, python3 -, runCommand -, symlinkJoin -, writeTextDir -}: - -let - common = callPackage ../common.nix {}; - - baseCandidates = [ - "octave" - ]; - - settingsSchema = []; - - repls = octave: version: { - octave = { - display_name = "Octave " + version; - attr = "octave"; - args = ["${octave}/bin/octave"]; - icon = ./octave-logo-64x64.png; - }; - }; - -in - -with lib; - -listToAttrs (map (x: - let - baseOctave = getAttr x pkgs; - - meta = baseOctave.meta // { - baseName = x; - displayName = "Octave " + baseOctave.version; - version = baseOctave.version; - icon = ./octave-logo-64x64.png; - inherit settingsSchema; - }; - - packageOptions = baseOctave.pkgs; - packageSearch = common.searcher packageOptions; - versions = { - octave = baseOctave.version; - }; - - in { - name = x; - value = lib.makeOverridable ({ - packages ? [] - , settings ? {} - , extraJupyterConfig ? null - , attrs ? ["octave"] - , extensions ? ["m"] - }@args: - let - octaveComplete = baseOctave.override { - python3 = 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 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) -) - - # extraGitIgnoreLines = [ - # ".octaverc" - # ".octave_hist" - # ]; - - - # Solution for problem that was arising when Octave calls makeinfo from the texinfo - # package, for example when running the command help('magic'). We were getting a perl - # warning about failing to set the locale. - # https://github.com/NixOS/nixpkgs/issues/38991 - # Env = [ - # ''LOCALE_ARCHIVE_2_11=${glibcLocales}/lib/locale/locale-archive'' - # ''LOCALE_ARCHIVE_2_27=${glibcLocales}/lib/locale/locale-archive'' - # ''LOCALE_ARCHIVE=/usr/bin/locale'' - # ]; diff --git a/languages/postgres/default.nix b/languages/postgres/default.nix deleted file mode 100644 index e741442e..00000000 --- a/languages/postgres/default.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ pkgs -, lib -, callPackage -, writeTextDir -, symlinkJoin -}: - -let - common = callPackage ../common.nix {}; - - packageOptions = {}; - packageSearch = common.searcher packageOptions; - - settingsSchema = []; - - chooseLanguageServers = settings: - [] - ; - - meta = { - name = "postgres"; - baseName = "postgres"; - displayName = "PostgreSQL"; - description = "A simple Jupyter kernel for PostgreSQL"; - icon = ./postgres-logo-64x64.png; - version = "0.1"; - inherit settingsSchema; - }; - - versions = { - postgres-kernel = meta.version; - }; - -in - -{ - postgres = lib.makeOverridable ({ - packages ? [] - , settings ? [] - , attrs ? ["postgres"] - , extensions ? ["sql"] - }@args: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - in symlinkJoin { - name = "postgres"; - - paths = [ - (callPackage ./kernel.nix { inherit attrs extensions; }) - ] - ++ (chooseLanguageServers settingsToUse) - ; - - 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 deleted file mode 100644 index 2a637df1..00000000 --- a/languages/python/default.nix +++ /dev/null @@ -1,232 +0,0 @@ -{ callPackage -, lib -, pkgs -, poetry2nix -, python-language-server -, pyright -, symlinkJoin -, stdenv -}: - -let - common = callPackage ../common.nix {}; - - hasPythonLspServer = python: (lib.hasAttr "python-lsp-server" python.pkgs) && (lib.versionAtLeast python.pythonVersion "3.7"); - hasPythonLanguageServer = python: lib.hasAttr "python-language-server" python.pkgs; - - chooseLanguageServers = settings: pythonWithPackages: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.jedi.enable") [(callPackage ./language_servers/language_server_jedi/config.nix { inherit pythonWithPackages kernelName; })] - ++ lib.optionals (common.isTrue settings "lsp.pyright.enable") [(callPackage ./language_servers/language_server_pyright/config.nix { inherit pythonWithPackages kernelName; })] - ++ lib.optionals (common.isTrue settings "lsp.pylint.enable") [(callPackage ./language_servers/language_server_pylint/config.nix { inherit pythonWithPackages kernelName; })] - ++ lib.optionals (common.isTrue settings "lsp.flake8.enable") [(callPackage ./language_servers/language_server_flake8/config.nix { inherit pythonWithPackages kernelName; })] - ++ lib.optionals (common.isTrue settings "lsp.pycodestyle.enable") [(callPackage ./language_servers/language_server_pycodestyle/config.nix { inherit pythonWithPackages kernelName; })] - ++ 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 = { - display_name = "IPython " + python.pkgs.ipython.version; - attr = "ipython"; - args = ["${python}/bin/ipython"]; - icon = ./python-logo-64x64.png; - }; - }; - - # Fine-grained candidates - # These don't work for now because Nixpkgs only keeps one set of Python packages, - # aimed at the currently supported Python. - # baseCandidates = [ - # "python" - # "python2" "python27" - # "python3" "python36" "python37" "python38" "python39" "python310" "python311" "python312" "python313" "python314" "python315" - - # "pypy" - # "pypy2" "pypy27" - # "pypy3" "pypy36" "pypy37" "pypy38" "pypy39" "pypy310" "pypy311" "pypy312" "pypy313" "pypy314" "pypy315" - # ]; - - baseCandidates = [ - "python" - "python3" - - # Reached EOL: Nixpkgs won't build without complaints - # "python2" - - # Currently pypy3 nose marked as broken - # "pypy" - # "pypy2" - # "pypy3" - ]; - - # Pythons that don't work with the ipykernel, ipywidgets, etc. of the Nixpkgs Python package set, - # so we have a special package checked in under ./envs - specialEnvPythons = { - "python38" = pkgs.python38; - "python39" = pkgs.python39; - "python312" = pkgs.python312; - }; - -in - -lib.listToAttrs (map (x: - let - basePython = - if lib.hasAttr x specialEnvPythons then (poetry2nix.mkPoetryEnv { - projectDir = ./envs/${x}; - python = specialEnvPythons.${x}; - overrides = import ./envs/${x}/poetry-overrides.nix { inherit poetry2nix; }; - }).overrideAttrs (_: { version = specialEnvPythons.${x}.version; }) - else lib.getAttr x pkgs; - - displayName = "Python " + basePython.version; - - settingsSchema = [ - { - title = "Language servers"; - level = 1; - type = "heading"; - } - { - target = "lsp.jedi.enable"; - title = "Enable Jedi language server"; - type = "boolean"; - defaultValue = true; - } - { - target = "lsp.pyright.enable"; - title = "Enable Pyright language server"; - type = "boolean"; - defaultValue = false; - } - { - target = "lsp.pylint.enable"; - title = "Enable Pylint language server"; - type = "boolean"; - defaultValue = false; - } - { - target = "lsp.flake8.enable"; - title = "Enable Flake8 language server"; - type = "boolean"; - defaultValue = false; - } - { - target = "lsp.pycodestyle.enable"; - title = "Enable pycodestyle language server"; - type = "boolean"; - defaultValue = false; - } - ] ++ lib.optionals (lib.hasAttr "python-language-server" pkgs) [ - { - target = "lsp.microsoft.enable"; - title = "Enable Microsoft Python language server"; - type = "boolean"; - defaultValue = false; - } - ] ++ lib.optionals (hasPythonLspServer basePython) [ - { - target = "lsp.python-lsp-server.enable"; - title = "Enable python-lsp-server language server"; - type = "boolean"; - defaultValue = false; - } - ] ++ lib.optionals (hasPythonLanguageServer basePython) [ - { - target = "lsp.python-language-server.enable"; - title = "Enable python-language-server language server"; - type = "boolean"; - defaultValue = false; - } - ] ++ [ - { - title = "Miscellaneous"; - level = 1; - type = "heading"; - } - { - target = "permitUserSite"; - title = "Permit user site-packages"; - description = "Skip setting the PYTHONNOUSERSITE variable. This will allow your Python code to import local packages (e.g. from ~/.local/lib). This is useful if you want to use pip to install Python packages independently of Nix."; - type = "boolean"; - defaultValue = false; - } - { - target = "enableVariableInspector"; - title = "Enable variable inspector"; - description = "Enable the variable inspector, which will fetch runtime values of variables to show in the variables list."; - type = "boolean"; - defaultValue = true; - } - ]; - - meta = basePython.meta // { - baseName = x; - inherit displayName settingsSchema; - version = basePython.version; - 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 = 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) (map common.packageName packages); - allPackages = [ps.ipykernel ps.ipywidgets] ++ chosenPackages; - python = basePython.withPackages (_: allPackages); - pythonWithPackages = f: basePython.withPackages (_: allPackages ++ f ps); - languageServers = chooseLanguageServers settingsToUse pythonWithPackages x; - - in symlinkJoin { - name = x; - - paths = [ - (callPackage ./kernel.nix { - inherit python displayName attrs extensions; - enableVariableInspector = settingsToUse.enableVariableInspector; - }) - - python - ps.ipython - ] - ++ languageServers - ; - - passthru = { - inherit meta packageOptions packageSearch versions; - inherit settingsSchema settings; - args = args // { baseName = x; }; - repls = repls python; - modes = { - inherit attrs extensions; - code_mirror_mode = "python"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {}; - } -) (lib.filter (x: lib.hasAttr x pkgs) baseCandidates)) diff --git a/languages/r/default.nix b/languages/r/default.nix deleted file mode 100644 index f62c0584..00000000 --- a/languages/r/default.nix +++ /dev/null @@ -1,107 +0,0 @@ -{pkgs -, lib -, callPackage -, symlinkJoin -, R -, rPackages -, rWrapper -}: - -let - common = callPackage ../common.nix {}; - - settingsSchema = [ - { - target = "lsp.languageserver.enable"; - title = "Enable languageserver"; - type = "boolean"; - defaultValue = true; - } - ]; - - chooseLanguageServers = settings: rPackages: rWrapper: basePackages: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.languageserver.enable") [( - let - languageserver = callPackage ./language-server-languageserver/languageserver.nix { inherit rPackages rWrapper; }; - in - (callPackage ./language-server-languageserver { - inherit rPackages rWrapper basePackages kernelName; - inherit languageserver; - }) - )] - ; - - meta = R.meta // { - baseName = "R"; - displayName = "R"; - version = R.version; - icon = ./r-logo-64x64.png; - }; - - repls = rWithPackages: version: { - r = { - display_name = "R"; - attr = "r"; - args = ["${rWithPackages}/bin/R"]; - icon = ./r-logo-64x64.png; - }; - }; - - 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 = 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) (map common.packageName packages)); - - rWithPackages = rWrapper.override { - packages = basePackages; - }; - - languageServers = chooseLanguageServers settingsToUse rPackages rWrapper basePackages "R"; - in - symlinkJoin { - name = "r"; - - paths = [ - (callPackage ./kernel.nix { - inherit rWithPackages attrs extensions; - version = R.version; - }) - rWithPackages - ] - ++ languageServers - ; - - 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"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {}; -}] diff --git a/languages/ruby/default.nix b/languages/ruby/default.nix deleted file mode 100644 index 4b5683aa..00000000 --- a/languages/ruby/default.nix +++ /dev/null @@ -1,117 +0,0 @@ -{ lib -, pkgs -, callPackage -, stdenv -, writeTextDir -, symlinkJoin -}: - -let - common = callPackage ../common.nix {}; - - filterFn = x: (common.hasAttrSafe x pkgs) && !(lib.attrByPath [x "meta" "broken"] false pkgs); - - baseCandidates = lib.filter filterFn [ - # "ruby_2_4" - # "ruby_2_4_3" - # "ruby_2_5" - # "ruby_2_5_0" - # "ruby_2_6" - # "ruby_2_7" - - "ruby" - "ruby_3_0" - "ruby_3_1" - "ruby_3_2" - "ruby_3_3" - ]; - - packagesLookup = lib.filterAttrs (k: v: filterFn k) { - # ruby_2_4 = pkgs.rubyPackages_2_4; - # ruby_2_4_3 = pkgs.rubyPackages_2_4; - # ruby_2_5 = pkgs.rubyPackages_2_5; - # ruby_2_5_0 = pkgs.rubyPackages_2_5; - # ruby_2_6 = pkgs.rubyPackages_2_6; - # ruby_2_7 = pkgs.rubyPackages_2_7; - - ruby = pkgs.rubyPackages; - ruby_3_0 = pkgs.rubyPackages_3_0; - ruby_3_1 = pkgs.rubyPackages_3_1; - ruby_3_2 = pkgs.rubyPackages_3_2; - ruby_3_3 = pkgs.rubyPackages_3_3; - }; - - settingsSchema = [ - { - target = "lsp.solargraph.enable"; - title = "Enable Solargraph language server"; - type = "boolean"; - defaultValue = true; - } - ]; - - chooseLanguageServers = settings: packageOptions: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.solargraph.enable") [(callPackage ./solargraph.nix { rubyPackages = packageOptions; inherit kernelName; })] - ; - -in - -with lib; - -listToAttrs (map (x: - let - ruby = getAttr x pkgs; - - meta = ruby.meta // { - baseName = x; - displayName = "Ruby"; - version = ruby.version; - icon = ./iruby-64x64.png; - inherit settingsSchema; - }; - - packageOptions = getAttr x packagesLookup; - packageSearch = common.searcher packageOptions; - versions = { - ruby = builtins.toString ruby.version; - solargraph = packageOptions.solargraph.version; - }; - - in { - name = x; - value = lib.makeOverridable ({ - packages ? [] - , settings ? {} - , attrs ? [x "ruby"] - , extensions ? ["rb"] - }@args: - let - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - languageServers = chooseLanguageServers settingsToUse packageOptions x; - in symlinkJoin { - name = x; - paths = [ - (callPackage ./kernel.nix { - iruby = (callPackage ./iruby { inherit ruby; }).iruby; - inherit attrs extensions version; - }) - ruby - ] - ++ languageServers - ; - passthru = { - inherit meta packageOptions packageSearch versions; - inherit settingsSchema settings; - args = args // { baseName = x; }; - modes = { - inherit attrs extensions; - code_mirror_mode = "ruby"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {}; - } - -) baseCandidates) diff --git a/languages/rust/default.nix b/languages/rust/default.nix deleted file mode 100644 index c7fb66e3..00000000 --- a/languages/rust/default.nix +++ /dev/null @@ -1,149 +0,0 @@ -{ lib -, pkgs -, callPackage -, writeTextDir -, symlinkJoin - -, darwin -, rust-analyzer -}: - -with lib; - -let - common = callPackage ../common.nix {}; - - settingsSchema = [ - { - target = "lsp.rust-analyzer.enable"; - title = "Enable rust-analyzer"; - type = "boolean"; - defaultValue = true; - } - { - target = "lsp.rust-analyzer.debug"; - title = "Rust-analyzer: enable debug output"; - description = "Print verbose debug output."; - type = "boolean"; - defaultValue = false; - } - ]; - - chooseLanguageServers = settings: rust: cargoHome: kernelName: - [] - ++ lib.optionals (common.isTrue settings "lsp.rust-analyzer.enable") [(callPackage ./language_server_rust_analyzer/config.nix { - inherit rust cargoHome kernelName; - settings = common.focusSettings "lsp.rust-analyzer." settings; - })] - ; - - allPackageNames = import ./all_package_names.nix; - - # Note: update this when the base Nixpkgs is bumped - baseCandidates = [ - "rust" - "rust_1_70" - "rust_1_71" - "rust_1_72" - "rust_1_73" - "rust_1_74" - "rust_1_75" - "rust_1_76" - "rust_1_77" - "rust_1_78" - "rust_1_79" - "rust_1_80" - "rust_1_81" - "rust_1_82" - ]; - -in - -with lib; - -listToAttrs (map (x: - let - rust = getAttr x pkgs; - rustPackages = rust.packages.stable; - - displayName = "Rust"; - - meta = rustPackages.rustc.meta // { - baseName = x; - inherit displayName; - icon = ./rust-logo-64x64.png; - inherit settingsSchema; - }; - - evcxrBase = callPackage ./evcxr { - inherit (darwin.apple_sdk.frameworks) CoreServices Security; - }; - - packageOptions = listToAttrs (map (x: { - name = x; - value = { - meta = { - name = x; - }; - }; - }) allPackageNames); - - packageSearch = common.searcher' { - packageMustBeDerivation = false; - packages = packageOptions; - }; - - versions = { - cargo = rustPackages.cargo.version; - evcxr = evcxrBase.version; - rust = rustPackages.rustc.version; - rust-analyzer = rust-analyzer.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 packages; - - settingsToUse = (common.makeDefaultSettings settingsSchema) // settings; - languageServers = chooseLanguageServers settingsToUse rust evcxr.cargoHome x; - in symlinkJoin { - name = "rust"; - - paths = [ - (callPackage ./kernel.nix { - inherit evcxr; - inherit displayName attrs extensions; - version = rustPackages.rustc.version; - }) - - rustPackages.rustc - rustPackages.cargo - pkgs.gcc - ] - ++ languageServers - ; - - passthru = { - args = args // { baseName = x; }; - inherit meta packageOptions packageSearch versions; - inherit settingsSchema settings; - inherit (evcxr) cratesIndex; - modes = { - inherit attrs extensions; - code_mirror_mode = "rust"; - }; - languageServerNames = map (x: x.languageServerName) languageServers; - }; - } - ) {}; - } -) (filter (x: hasAttr x pkgs) baseCandidates)) diff --git a/modules/base.nix b/modules/base.nix index ca17bcd5..179fca3b 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -4,34 +4,75 @@ with lib; { options = { - pkgs = lib.mkOption { - type = lib.types.attrs; + pkgs = mkOption { + type = types.attrs; default = pkgs; }; - builtExporters = lib.mkOption { + pkgsMaster = mkOption { + type = types.attrs; + default = pkgs; + }; + + builtExporters = mkOption { type = types.attrsOf types.package; default = {}; }; - builtKernels = lib.mkOption { + builtKernels = mkOption { type = types.attrsOf types.package; default = {}; }; - builtShells = lib.mkOption { + builtLanguageServers = mkOption { type = types.attrsOf types.package; default = {}; }; - packages = lib.mkOption { - type = lib.types.listOf lib.types.package; + builtShells = mkOption { + type = types.attrsOf types.package; + default = {}; + }; + + packages = mkOption { + type = types.listOf types.package; default = []; - example = lib.literalExpression "[ pkgs.firefox pkgs.thunderbird ]"; + example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]"; description = '' The set of packages that are symlinked into the environment. ''; }; + + channels = mkOption { + type = types.attrs; + default = {}; + description = '' + Channels, passed through to UI metadata. + ''; + }; + + labeledPackages = mkOption { + type = types.listOf (types.submodule { + options = { + channel = mkOption rec { + type = types.str; + description = "Channel name"; + }; + attr = mkOption rec { + type = types.str; + description = "Attr name"; + }; + contents = mkOption rec { + type = types.package; + description = "Package"; + }; + }; + }); + default = []; + description = '' + Packages that are labeled with channels and attributes. Used to generate UI metadata. + ''; + }; }; config = { diff --git a/modules/base/convert-type.nix b/modules/base/convert-type.nix new file mode 100644 index 00000000..28b1635c --- /dev/null +++ b/modules/base/convert-type.nix @@ -0,0 +1,36 @@ +{ config, lib, ... }: + +let + convertType = target: type: + if (type.name == "str") then "string" + else if (type.name == "anything") then "any" + else if (type.name == "bool") then "boolean" + else if (type.name == "attrs") then { + tag = "attrs"; + } + else if (type.name == "listOf") then { + tag = "list"; + value = convertType target type.nestedTypes.elemType; + } + else if (type.name == "enum") then { + tag = "enum"; + values = type.functor.payload; + } + else if (type.name == "either") then { + tag = "either"; + left = convertType target type.nestedTypes.left; + right = convertType target type.nestedTypes.right; + } + else if (type.name == "submodule") then { + tag = "submodule"; + keys = lib.mapAttrsRecursiveCond + (x: !(x ? _type)) + (path: value: convertType target value.type) + (lib.removeAttrs (type.getSubOptions {}) ["_module"]); + } + else builtins.throw "Can't convert type for '${target}': ${toString type.name}" + ; + +in + +convertType diff --git a/modules/base/nixos-options-to-settings-schema.nix b/modules/base/nixos-options-to-settings-schema.nix index 38032663..90b8c342 100644 --- a/modules/base/nixos-options-to-settings-schema.nix +++ b/modules/base/nixos-options-to-settings-schema.nix @@ -1,17 +1,26 @@ -{ config, lib, ... }: +{ config, lib, ... }@args: + +{ + componentsToDrop ? 0 +}: options: let + convertType = import ./convert-type.nix args; + flattened = lib.optionAttrSetToDocList options; - convert = v: { - target = v.name; - type = v.type; - loc = v.loc; - } - // lib.optionalAttrs (lib.hasAttr "default" v) { defaultValue = convertDefaultValue v.default; } - // lib.optionalAttrs (lib.hasAttr "description" v && builtins.typeOf v.description == "string") { description = v.description; } + convert = v: let + defaultItem = { type = { name = "unknown"; }; }; + in + { + target = v.name; + type = convertType v.name (lib.attrByPath (lib.drop componentsToDrop v.loc) defaultItem options).type; + loc = v.loc; + } + // lib.optionalAttrs (lib.hasAttr "default" v) { defaultValue = convertDefaultValue v.default; } + // lib.optionalAttrs (lib.hasAttr "description" v && builtins.typeOf v.description == "string") { inherit (v) description; } ; evalString = str: builtins.scopedImport {} (builtins.toFile "expr.nix" str); diff --git a/exporters/fix-asciidoc.patch b/modules/exporters/fix-asciidoc.patch similarity index 100% rename from exporters/fix-asciidoc.patch rename to modules/exporters/fix-asciidoc.patch diff --git a/exporters/module.nix b/modules/exporters/module.nix similarity index 75% rename from exporters/module.nix rename to modules/exporters/module.nix index f2663518..f1a32d83 100644 --- a/exporters/module.nix +++ b/modules/exporters/module.nix @@ -4,7 +4,7 @@ with lib; { options = { - exporters.nbconvert-exporters = { + exporters.nbconvert = { enable = mkOption { type = types.bool; default = false; @@ -27,9 +27,9 @@ with lib; }; }; - config = mkIf config.exporters.nbconvert-exporters.enable { - builtExporters.nbconvert-exporters = config.pkgs.callPackage ./nbconvert.nix { - texliveScheme = config.pkgs.texlive.combined.${config.exporters.nbconvert-exporters.texliveScheme}; + config = mkIf config.exporters.nbconvert.enable { + builtExporters.nbconvert = config.pkgs.callPackage ./nbconvert.nix { + texliveScheme = config.pkgs.texlive.combined.${config.exporters.nbconvert.texliveScheme}; }; }; } diff --git a/exporters/nbconvert.nix b/modules/exporters/nbconvert.nix similarity index 98% rename from exporters/nbconvert.nix rename to modules/exporters/nbconvert.nix index 8645a71c..e78e7fca 100644 --- a/exporters/nbconvert.nix +++ b/modules/exporters/nbconvert.nix @@ -52,7 +52,7 @@ symlinkJoin { name = "nbconvert-exporters"; description = "CodeDown exporters for PDF, HTML, LaTeX, slides, etc."; - icon = ../codedown-icon.png; + icon = ../../codedown-icon.png; # To separate these out in search results category = "Exporters"; diff --git a/exporters/nbconvert/beamer.nix b/modules/exporters/nbconvert/beamer.nix similarity index 100% rename from exporters/nbconvert/beamer.nix rename to modules/exporters/nbconvert/beamer.nix diff --git a/exporters/nbconvert/slidy.nix b/modules/exporters/nbconvert/slidy.nix similarity index 100% rename from exporters/nbconvert/slidy.nix rename to modules/exporters/nbconvert/slidy.nix diff --git a/language_servers/diagnostic-languageserver/default.nix b/modules/language_servers/diagnostic-languageserver/default.nix similarity index 100% rename from language_servers/diagnostic-languageserver/default.nix rename to modules/language_servers/diagnostic-languageserver/default.nix diff --git a/language_servers/diagnostic-languageserver/generate.sh b/modules/language_servers/diagnostic-languageserver/generate.sh similarity index 100% rename from language_servers/diagnostic-languageserver/generate.sh rename to modules/language_servers/diagnostic-languageserver/generate.sh diff --git a/language_servers/diagnostic-languageserver/node-env.nix b/modules/language_servers/diagnostic-languageserver/node-env.nix similarity index 100% rename from language_servers/diagnostic-languageserver/node-env.nix rename to modules/language_servers/diagnostic-languageserver/node-env.nix diff --git a/language_servers/diagnostic-languageserver/node-packages.json b/modules/language_servers/diagnostic-languageserver/node-packages.json similarity index 100% rename from language_servers/diagnostic-languageserver/node-packages.json rename to modules/language_servers/diagnostic-languageserver/node-packages.json diff --git a/language_servers/diagnostic-languageserver/node-packages.nix b/modules/language_servers/diagnostic-languageserver/node-packages.nix similarity index 100% rename from language_servers/diagnostic-languageserver/node-packages.nix rename to modules/language_servers/diagnostic-languageserver/node-packages.nix diff --git a/language_servers/markdown-spellcheck-lsp/default.nix b/modules/language_servers/markdown-spellcheck-lsp/default.nix similarity index 100% rename from language_servers/markdown-spellcheck-lsp/default.nix rename to modules/language_servers/markdown-spellcheck-lsp/default.nix diff --git a/language_servers/markdown-spellcheck-lsp/module.nix b/modules/language_servers/markdown-spellcheck-lsp/module.nix similarity index 79% rename from language_servers/markdown-spellcheck-lsp/module.nix rename to modules/language_servers/markdown-spellcheck-lsp/module.nix index f1983a86..d379552b 100644 --- a/language_servers/markdown-spellcheck-lsp/module.nix +++ b/modules/language_servers/markdown-spellcheck-lsp/module.nix @@ -14,8 +14,6 @@ with lib; }; config = mkIf config.language-servers.spellchecker.enable { - packages = [ - (config.pkgs.callPackage ./default.nix {}) - ]; + builtLanguageServers.spellchecker = config.pkgs.callPackage ./default.nix {}; }; } diff --git a/language_servers/markdown-spellcheck-lsp/pen-alt.png b/modules/language_servers/markdown-spellcheck-lsp/pen-alt.png similarity index 100% rename from language_servers/markdown-spellcheck-lsp/pen-alt.png rename to modules/language_servers/markdown-spellcheck-lsp/pen-alt.png diff --git a/language_servers/markdown-spellcheck-lsp/pen-alt.svg b/modules/language_servers/markdown-spellcheck-lsp/pen-alt.svg similarity index 100% rename from language_servers/markdown-spellcheck-lsp/pen-alt.svg rename to modules/language_servers/markdown-spellcheck-lsp/pen-alt.svg diff --git a/languages/.gitignore b/modules/languages/.gitignore similarity index 100% rename from languages/.gitignore rename to modules/languages/.gitignore diff --git a/languages/bash/bash-logo-128x128.png b/modules/languages/bash/bash-logo-128x128.png similarity index 100% rename from languages/bash/bash-logo-128x128.png rename to modules/languages/bash/bash-logo-128x128.png diff --git a/languages/bash/full.nix b/modules/languages/bash/default.nix similarity index 100% rename from languages/bash/full.nix rename to modules/languages/bash/default.nix diff --git a/languages/bash/kernel.nix b/modules/languages/bash/kernel.nix similarity index 100% rename from languages/bash/kernel.nix rename to modules/languages/bash/kernel.nix diff --git a/languages/bash/language_server_bash/default.nix b/modules/languages/bash/language_server_bash/default.nix similarity index 100% rename from languages/bash/language_server_bash/default.nix rename to modules/languages/bash/language_server_bash/default.nix diff --git a/languages/bash/man-with-pages.nix b/modules/languages/bash/man-with-pages.nix similarity index 100% rename from languages/bash/man-with-pages.nix rename to modules/languages/bash/man-with-pages.nix diff --git a/languages/bash/metadata.nix b/modules/languages/bash/metadata.nix similarity index 100% rename from languages/bash/metadata.nix rename to modules/languages/bash/metadata.nix diff --git a/languages/bash/module.nix b/modules/languages/bash/module.nix similarity index 83% rename from languages/bash/module.nix rename to modules/languages/bash/module.nix index 97a1d718..2864f75a 100644 --- a/languages/bash/module.nix +++ b/modules/languages/bash/module.nix @@ -29,10 +29,10 @@ with lib; }; config = mkIf config.kernels.bash.enable { - builtKernels.bash = config.pkgs.callPackage ./full.nix { + builtKernels.bash = config.pkgs.callPackage ./. { bash = config.pkgs.bash; inherit (config.kernels.bash) attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.bash; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.bash; }; }; } diff --git a/languages/clojure/clojure-logo-32x32.png b/modules/languages/clojure/clojure-logo-32x32.png similarity index 100% rename from languages/clojure/clojure-logo-32x32.png rename to modules/languages/clojure/clojure-logo-32x32.png diff --git a/languages/clojure/clojure-logo-64x64.png b/modules/languages/clojure/clojure-logo-64x64.png similarity index 100% rename from languages/clojure/clojure-logo-64x64.png rename to modules/languages/clojure/clojure-logo-64x64.png diff --git a/languages/clojure/clojure-lsp.nix b/modules/languages/clojure/clojure-lsp.nix similarity index 100% rename from languages/clojure/clojure-lsp.nix rename to modules/languages/clojure/clojure-lsp.nix diff --git a/languages/clojure/full.nix b/modules/languages/clojure/default.nix similarity index 100% rename from languages/clojure/full.nix rename to modules/languages/clojure/default.nix diff --git a/languages/clojure/home_folder/.config/clojupyter.edn b/modules/languages/clojure/home_folder/.config/clojupyter.edn similarity index 100% rename from languages/clojure/home_folder/.config/clojupyter.edn rename to modules/languages/clojure/home_folder/.config/clojupyter.edn diff --git a/languages/clojure/home_folder/project.clj b/modules/languages/clojure/home_folder/project.clj similarity index 100% rename from languages/clojure/home_folder/project.clj rename to modules/languages/clojure/home_folder/project.clj diff --git a/languages/clojure/home_folder/src/project/core.clj b/modules/languages/clojure/home_folder/src/project/core.clj similarity index 100% rename from languages/clojure/home_folder/src/project/core.clj rename to modules/languages/clojure/home_folder/src/project/core.clj diff --git a/languages/clojure/home_folder/test/project/core_test.clj b/modules/languages/clojure/home_folder/test/project/core_test.clj similarity index 100% rename from languages/clojure/home_folder/test/project/core_test.clj rename to modules/languages/clojure/home_folder/test/project/core_test.clj diff --git a/languages/clojure/kernel.nix b/modules/languages/clojure/kernel.nix similarity index 100% rename from languages/clojure/kernel.nix rename to modules/languages/clojure/kernel.nix diff --git a/languages/clojure/language-server.nix b/modules/languages/clojure/language-server.nix similarity index 100% rename from languages/clojure/language-server.nix rename to modules/languages/clojure/language-server.nix diff --git a/languages/clojure/module.nix b/modules/languages/clojure/module.nix similarity index 82% rename from languages/clojure/module.nix rename to modules/languages/clojure/module.nix index db38715c..e1929522 100644 --- a/languages/clojure/module.nix +++ b/modules/languages/clojure/module.nix @@ -29,10 +29,10 @@ with lib; }; config = mkIf config.kernels.clojure.enable { - builtKernels.clojure = config.pkgs.callPackage ./full.nix { + builtKernels.clojure = config.pkgs.callPackage ./. { clojure = config.pkgs.clojure; inherit (config.kernels.clojure) attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.clojure; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.clojure; }; }; } diff --git a/languages/common.nix b/modules/languages/common.nix similarity index 75% rename from languages/common.nix rename to modules/languages/common.nix index c5512773..12504782 100644 --- a/languages/common.nix +++ b/modules/languages/common.nix @@ -51,10 +51,6 @@ rec { inherit meta passthru; }); - writeShellScriptBinWithMeta = meta: path: text: (writeTextDir path text).overrideAttrs (old: { - inherit meta; - }); - writeShellScriptBinWithAttrs = attrs: path: text: (writeShellScriptBin path text).overrideAttrs (old: attrs); searcher = packages: (callPackage ../tools/sqlite-indexer { inherit packages; }).searcher; @@ -75,31 +71,5 @@ rec { in concatStrings withMaxComponents; - hasAttrSafe = x: set: hasAttr x set && (let - evaluated = builtins.tryEval (getAttr x set); - in - if evaluated.success then true else false); - - safeEval = safeEval' ""; - safeEval' = default: e: let - evaluated = builtins.tryEval e; - in - if evaluated.success then evaluated.value else default; - - isTrue = settings: name: hasAttr name settings && getAttr name settings == true; - - focusSettings = prefix: settings: with lib; let - filtered = lib.filterAttrs (n: _: hasPrefix prefix n) settings; - in - listToAttrs (mapAttrsToList (n: v: { - name = removePrefix prefix n; - value = v; - }) filtered); - - makeDefaultSettings = settingsSchema: listToAttrs (map (item: { - name = item.target; - value = item.defaultValue; - }) (filter (hasAttr "target") settingsSchema)); - packageName = p: if lib.isString p then p else p.name; } diff --git a/languages/coq/coq_jupyter/default.nix b/modules/languages/coq/coq_jupyter/default.nix similarity index 100% rename from languages/coq/coq_jupyter/default.nix rename to modules/languages/coq/coq_jupyter/default.nix diff --git a/languages/coq/coq_jupyter/kernel.nix b/modules/languages/coq/coq_jupyter/kernel.nix similarity index 100% rename from languages/coq/coq_jupyter/kernel.nix rename to modules/languages/coq/coq_jupyter/kernel.nix diff --git a/languages/coq/full.nix b/modules/languages/coq/default.nix similarity index 100% rename from languages/coq/full.nix rename to modules/languages/coq/default.nix diff --git a/languages/coq/kernel.nix b/modules/languages/coq/kernel.nix similarity index 100% rename from languages/coq/kernel.nix rename to modules/languages/coq/kernel.nix diff --git a/languages/coq/module.nix b/modules/languages/coq/module.nix similarity index 87% rename from languages/coq/module.nix rename to modules/languages/coq/module.nix index 390a8c0a..72d5ed72 100644 --- a/languages/coq/module.nix +++ b/modules/languages/coq/module.nix @@ -37,12 +37,12 @@ with lib; }; config = mkIf config.kernels.coq.enable { - builtKernels.coq = config.pkgs.callPackage ./full.nix { + builtKernels.coq = config.pkgs.callPackage ./. { coqPackages = getAttr config.kernels.coq.coqPackages config.pkgs; inherit (config.kernels.coq) packages attrs extensions; settings = {}; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.coq; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.coq; }; }; } diff --git a/languages/cpp/ccls.nix b/modules/languages/cpp/ccls.nix similarity index 100% rename from languages/cpp/ccls.nix rename to modules/languages/cpp/ccls.nix diff --git a/languages/cpp/cpp11-logo-64x64.png b/modules/languages/cpp/cpp11-logo-64x64.png similarity index 100% rename from languages/cpp/cpp11-logo-64x64.png rename to modules/languages/cpp/cpp11-logo-64x64.png diff --git a/languages/cpp/cpp14-logo-64x64.png b/modules/languages/cpp/cpp14-logo-64x64.png similarity index 100% rename from languages/cpp/cpp14-logo-64x64.png rename to modules/languages/cpp/cpp14-logo-64x64.png diff --git a/languages/cpp/cpp17-logo-64x64.png b/modules/languages/cpp/cpp17-logo-64x64.png similarity index 100% rename from languages/cpp/cpp17-logo-64x64.png rename to modules/languages/cpp/cpp17-logo-64x64.png diff --git a/languages/cpp/cpp2a-logo-64x64.png b/modules/languages/cpp/cpp2a-logo-64x64.png similarity index 100% rename from languages/cpp/cpp2a-logo-64x64.png rename to modules/languages/cpp/cpp2a-logo-64x64.png diff --git a/languages/cpp/full.nix b/modules/languages/cpp/default.nix similarity index 95% rename from languages/cpp/full.nix rename to modules/languages/cpp/default.nix index b3fda081..28db8d7a 100644 --- a/languages/cpp/full.nix +++ b/modules/languages/cpp/default.nix @@ -52,7 +52,7 @@ symlinkJoin { xeus-cling = xeusClingToUse; inherit attrs displayName extensions; std = flavor; - attrName = head attrs; + kernelName = "cpp"; }) cling ] @@ -60,10 +60,10 @@ symlinkJoin { passthru = { meta = clang.meta // { - baseName = x; + baseName = "cpp"; inherit displayName; version = clang.version; - icon = getAttr x icons; + icon = getAttr flavor icons; inherit settingsSchema; }; inherit packageOptions packageSearch; diff --git a/languages/cpp/kernel_xeus.nix b/modules/languages/cpp/kernel_xeus.nix similarity index 95% rename from languages/cpp/kernel_xeus.nix rename to modules/languages/cpp/kernel_xeus.nix index 982ed4c9..c12d261b 100644 --- a/languages/cpp/kernel_xeus.nix +++ b/modules/languages/cpp/kernel_xeus.nix @@ -9,7 +9,7 @@ , cling , xeus-cling -, attrName +, kernelName , attrs , displayName , extensions @@ -25,7 +25,7 @@ in common.makeJupyterKernel ( listToAttrs [{ - name = attrName; + name = kernelName; value = { displayName = displayName; argv = [ @@ -40,7 +40,7 @@ common.makeJupyterKernel ( # "-v" "-f" "{connection_file}" ]; - language = attrName; + language = kernelName; logo32 = fetchurl { url = https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/ISO_C%2B%2B_Logo.svg/32px-ISO_C%2B%2B_Logo.svg.png; hash = "sha256-cr0TB8/j2mkcFhfCkz9F7ZANOuTlWA2OcWtDcXyOjHw="; diff --git a/languages/cpp/module.nix b/modules/languages/cpp/module.nix similarity index 75% rename from languages/cpp/module.nix rename to modules/languages/cpp/module.nix index 75f5f52c..61bf6e04 100644 --- a/languages/cpp/module.nix +++ b/modules/languages/cpp/module.nix @@ -22,13 +22,20 @@ with lib; "c++17" "c++20" "c++23" + + "gnu++11" + "gnu++14" + "gnu++17" + "gnu++20" + "gnu++23" ]; + default = "c++20"; }; attrs = mkOption { type = types.listOf types.str; - default = ["c++"]; + default = ["cpp"]; }; extensions = mkOption { @@ -36,19 +43,17 @@ with lib; default = ["cpp" "hpp" "cxx" "hxx" "c" "h"]; }; - settings = { - - }; + settings = {}; }; }; config = mkIf config.kernels.cpp.enable { - builtKernels.cpp = config.pkgs.callPackage ./full.nix { + builtKernels.cpp = config.pkgs.callPackage ./. { inherit (config.kernels.cpp) flavor packages extensions settings; attrs = [config.kernels.cpp.flavor] ++ config.kernels.cpp.attrs; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.cpp; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.cpp; }; }; } diff --git a/languages/cpp/old/kernel_cling.nix b/modules/languages/cpp/old/kernel_cling.nix similarity index 100% rename from languages/cpp/old/kernel_cling.nix rename to modules/languages/cpp/old/kernel_cling.nix diff --git a/languages/cpp/xeus-cling.svg b/modules/languages/cpp/xeus-cling.svg similarity index 100% rename from languages/cpp/xeus-cling.svg rename to modules/languages/cpp/xeus-cling.svg diff --git a/languages/cpp/xeus-cling/0001-Fix-bug-in-extract_filename.patch b/modules/languages/cpp/xeus-cling/0001-Fix-bug-in-extract_filename.patch similarity index 100% rename from languages/cpp/xeus-cling/0001-Fix-bug-in-extract_filename.patch rename to modules/languages/cpp/xeus-cling/0001-Fix-bug-in-extract_filename.patch diff --git a/languages/cpp/xeus-cling/0002-Don-t-pass-extra-includes-configure-this-with-flags.patch b/modules/languages/cpp/xeus-cling/0002-Don-t-pass-extra-includes-configure-this-with-flags.patch similarity index 100% rename from languages/cpp/xeus-cling/0002-Don-t-pass-extra-includes-configure-this-with-flags.patch rename to modules/languages/cpp/xeus-cling/0002-Don-t-pass-extra-includes-configure-this-with-flags.patch diff --git a/languages/cpp/xeus-cling/xeus-cling.nix b/modules/languages/cpp/xeus-cling/xeus-cling.nix similarity index 100% rename from languages/cpp/xeus-cling/xeus-cling.nix rename to modules/languages/cpp/xeus-cling/xeus-cling.nix diff --git a/languages/cpp/xeusMisc.nix b/modules/languages/cpp/xeusMisc.nix similarity index 100% rename from languages/cpp/xeusMisc.nix rename to modules/languages/cpp/xeusMisc.nix diff --git a/languages/go/full.nix b/modules/languages/go/default.nix similarity index 98% rename from languages/go/full.nix rename to modules/languages/go/default.nix index 2e2989ef..3d20e335 100644 --- a/languages/go/full.nix +++ b/modules/languages/go/default.nix @@ -44,7 +44,7 @@ symlinkJoin { passthru = { meta = go.meta // { - baseName = x; + baseName = "go"; displayName = "Go"; version = go.version; icon = ./go-logo-64x64.png; diff --git a/languages/go/go-logo-32x32.png b/modules/languages/go/go-logo-32x32.png similarity index 100% rename from languages/go/go-logo-32x32.png rename to modules/languages/go/go-logo-32x32.png diff --git a/languages/go/go-logo-64x64.png b/modules/languages/go/go-logo-64x64.png similarity index 100% rename from languages/go/go-logo-64x64.png rename to modules/languages/go/go-logo-64x64.png diff --git a/languages/go/kernel.nix b/modules/languages/go/kernel.nix similarity index 100% rename from languages/go/kernel.nix rename to modules/languages/go/kernel.nix diff --git a/languages/go/language-server-gopls.nix b/modules/languages/go/language-server-gopls.nix similarity index 100% rename from languages/go/language-server-gopls.nix rename to modules/languages/go/language-server-gopls.nix diff --git a/languages/go/module.nix b/modules/languages/go/module.nix similarity index 90% rename from languages/go/module.nix rename to modules/languages/go/module.nix index 47ada00d..3005d581 100644 --- a/languages/go/module.nix +++ b/modules/languages/go/module.nix @@ -51,11 +51,11 @@ with lib; }; config = mkIf config.kernels.go.enable { - builtKernels.go = config.pkgs.callPackage ./full.nix { + builtKernels.go = config.pkgs.callPackage ./. { go = getAttr config.kernels.go.goPackage config.pkgs; inherit (config.kernels.go) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.go; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.go; }; }; } diff --git a/languages/haskell/compilers.nix b/modules/languages/haskell/compilers.nix similarity index 100% rename from languages/haskell/compilers.nix rename to modules/languages/haskell/compilers.nix diff --git a/languages/haskell/full.nix b/modules/languages/haskell/default.nix similarity index 97% rename from languages/haskell/full.nix rename to modules/languages/haskell/default.nix index f79d3701..7494289c 100644 --- a/languages/haskell/full.nix +++ b/modules/languages/haskell/default.nix @@ -75,6 +75,9 @@ symlinkJoin { ; passthru = { + args = { + inherit attrs extensions settings packages; + }; meta = { baseName = "haskell-" + compilerName; name = "haskell-" + compilerName; diff --git a/languages/haskell/haskell-logo-32x32.png b/modules/languages/haskell/haskell-logo-32x32.png similarity index 100% rename from languages/haskell/haskell-logo-32x32.png rename to modules/languages/haskell/haskell-logo-32x32.png diff --git a/languages/haskell/haskell-logo-64x64.png b/modules/languages/haskell/haskell-logo-64x64.png similarity index 100% rename from languages/haskell/haskell-logo-64x64.png rename to modules/languages/haskell/haskell-logo-64x64.png diff --git a/languages/haskell/kernel.nix b/modules/languages/haskell/kernel.nix similarity index 100% rename from languages/haskell/kernel.nix rename to modules/languages/haskell/kernel.nix diff --git a/languages/haskell/language-server-hls/config.nix b/modules/languages/haskell/language-server-hls/config.nix similarity index 100% rename from languages/haskell/language-server-hls/config.nix rename to modules/languages/haskell/language-server-hls/config.nix diff --git a/languages/haskell/language-server-hls/default.nix b/modules/languages/haskell/language-server-hls/default.nix similarity index 100% rename from languages/haskell/language-server-hls/default.nix rename to modules/languages/haskell/language-server-hls/default.nix diff --git a/languages/haskell/language-server-hls/hls-icon-64x64.png b/modules/languages/haskell/language-server-hls/hls-icon-64x64.png similarity index 100% rename from languages/haskell/language-server-hls/hls-icon-64x64.png rename to modules/languages/haskell/language-server-hls/hls-icon-64x64.png diff --git a/languages/haskell/language-server-hls/hls-logo.png b/modules/languages/haskell/language-server-hls/hls-logo.png similarity index 100% rename from languages/haskell/language-server-hls/hls-logo.png rename to modules/languages/haskell/language-server-hls/hls-logo.png diff --git a/languages/haskell/language-server-hls/hnls-version.nix b/modules/languages/haskell/language-server-hls/hnls-version.nix similarity index 100% rename from languages/haskell/language-server-hls/hnls-version.nix rename to modules/languages/haskell/language-server-hls/hnls-version.nix diff --git a/languages/haskell/language-server-hls/hnls.nix b/modules/languages/haskell/language-server-hls/hnls.nix similarity index 100% rename from languages/haskell/language-server-hls/hnls.nix rename to modules/languages/haskell/language-server-hls/hnls.nix diff --git a/languages/haskell/language-server-hls/hnls_update.sh b/modules/languages/haskell/language-server-hls/hnls_update.sh similarity index 100% rename from languages/haskell/language-server-hls/hnls_update.sh rename to modules/languages/haskell/language-server-hls/hnls_update.sh diff --git a/languages/haskell/language-server-hls/icon_64x64.xcf b/modules/languages/haskell/language-server-hls/icon_64x64.xcf similarity index 100% rename from languages/haskell/language-server-hls/icon_64x64.xcf rename to modules/languages/haskell/language-server-hls/icon_64x64.xcf diff --git a/languages/haskell/language-server-hls/lsp-types.nix b/modules/languages/haskell/language-server-hls/lsp-types.nix similarity index 100% rename from languages/haskell/language-server-hls/lsp-types.nix rename to modules/languages/haskell/language-server-hls/lsp-types.nix diff --git a/languages/haskell/language-server-hls/myers-diff.nix b/modules/languages/haskell/language-server-hls/myers-diff.nix similarity index 100% rename from languages/haskell/language-server-hls/myers-diff.nix rename to modules/languages/haskell/language-server-hls/myers-diff.nix diff --git a/languages/haskell/module.nix b/modules/languages/haskell/module.nix similarity index 94% rename from languages/haskell/module.nix rename to modules/languages/haskell/module.nix index f68bd542..568f6b9f 100644 --- a/languages/haskell/module.nix +++ b/modules/languages/haskell/module.nix @@ -70,12 +70,12 @@ with lib; in - pkgs.callPackage ./full.nix { + pkgs.callPackage ./. { compilerName = config.kernels.haskell.ghcPackage; snapshot = getAttr config.kernels.haskell.ghcPackage compilers; inherit (config.kernels.haskell) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.haskell; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.haskell; }; }; } diff --git a/languages/haskell/old/compilers.nix b/modules/languages/haskell/old/compilers.nix similarity index 100% rename from languages/haskell/old/compilers.nix rename to modules/languages/haskell/old/compilers.nix diff --git a/languages/haskell/old/default_haskellnix.nix b/modules/languages/haskell/old/default_haskellnix.nix similarity index 100% rename from languages/haskell/old/default_haskellnix.nix rename to modules/languages/haskell/old/default_haskellnix.nix diff --git a/languages/haskell/old/generate.nix b/modules/languages/haskell/old/generate.nix similarity index 100% rename from languages/haskell/old/generate.nix rename to modules/languages/haskell/old/generate.nix diff --git a/languages/haskell/old/ihaskell.nix b/modules/languages/haskell/old/ihaskell.nix similarity index 100% rename from languages/haskell/old/ihaskell.nix rename to modules/languages/haskell/old/ihaskell.nix diff --git a/languages/haskell/old/util.nix b/modules/languages/haskell/old/util.nix similarity index 100% rename from languages/haskell/old/util.nix rename to modules/languages/haskell/old/util.nix diff --git a/languages/haskell/settings_schema.nix b/modules/languages/haskell/settings_schema.nix similarity index 100% rename from languages/haskell/settings_schema.nix rename to modules/languages/haskell/settings_schema.nix diff --git a/languages/haskell/util.nix b/modules/languages/haskell/util.nix similarity index 100% rename from languages/haskell/util.nix rename to modules/languages/haskell/util.nix diff --git a/languages/julia/full.nix b/modules/languages/julia/default.nix similarity index 99% rename from languages/julia/full.nix rename to modules/languages/julia/default.nix index 3526ef27..a09d8b13 100644 --- a/languages/julia/full.nix +++ b/modules/languages/julia/default.nix @@ -98,7 +98,7 @@ symlinkJoin { passthru = { meta = julia.meta // { - baseName = attr; + baseName = "julia"; inherit displayName settingsSchema; version = julia.version; icon = ./julia-logo-64x64.png; diff --git a/languages/julia/julia-logo-32x32.png b/modules/languages/julia/julia-logo-32x32.png similarity index 100% rename from languages/julia/julia-logo-32x32.png rename to modules/languages/julia/julia-logo-32x32.png diff --git a/languages/julia/julia-logo-64x64.png b/modules/languages/julia/julia-logo-64x64.png similarity index 100% rename from languages/julia/julia-logo-64x64.png rename to modules/languages/julia/julia-logo-64x64.png diff --git a/languages/julia/julia-modules/default.nix b/modules/languages/julia/julia-modules/default.nix similarity index 100% rename from languages/julia/julia-modules/default.nix rename to modules/languages/julia/julia-modules/default.nix diff --git a/languages/julia/julia-modules/depot.nix b/modules/languages/julia/julia-modules/depot.nix similarity index 100% rename from languages/julia/julia-modules/depot.nix rename to modules/languages/julia/julia-modules/depot.nix diff --git a/languages/julia/julia-modules/extra-libs.nix b/modules/languages/julia/julia-modules/extra-libs.nix similarity index 100% rename from languages/julia/julia-modules/extra-libs.nix rename to modules/languages/julia/julia-modules/extra-libs.nix diff --git a/languages/julia/julia-modules/extra-python-packages.nix b/modules/languages/julia/julia-modules/extra-python-packages.nix similarity index 100% rename from languages/julia/julia-modules/extra-python-packages.nix rename to modules/languages/julia/julia-modules/extra-python-packages.nix diff --git a/languages/julia/julia-modules/extract_artifacts.jl b/modules/languages/julia/julia-modules/extract_artifacts.jl similarity index 100% rename from languages/julia/julia-modules/extract_artifacts.jl rename to modules/languages/julia/julia-modules/extract_artifacts.jl diff --git a/languages/julia/julia-modules/extract_artifacts_16.jl b/modules/languages/julia/julia-modules/extract_artifacts_16.jl similarity index 100% rename from languages/julia/julia-modules/extract_artifacts_16.jl rename to modules/languages/julia/julia-modules/extract_artifacts_16.jl diff --git a/languages/julia/julia-modules/generate-package-names.nix b/modules/languages/julia/julia-modules/generate-package-names.nix similarity index 100% rename from languages/julia/julia-modules/generate-package-names.nix rename to modules/languages/julia/julia-modules/generate-package-names.nix diff --git a/languages/julia/julia-modules/generate_packages_names.sh b/modules/languages/julia/julia-modules/generate_packages_names.sh similarity index 100% rename from languages/julia/julia-modules/generate_packages_names.sh rename to modules/languages/julia/julia-modules/generate_packages_names.sh diff --git a/languages/julia/julia-modules/indexing/combine_indices.py b/modules/languages/julia/julia-modules/indexing/combine_indices.py similarity index 100% rename from languages/julia/julia-modules/indexing/combine_indices.py rename to modules/languages/julia/julia-modules/indexing/combine_indices.py diff --git a/languages/julia/julia-modules/indexing/default.nix b/modules/languages/julia/julia-modules/indexing/default.nix similarity index 100% rename from languages/julia/julia-modules/indexing/default.nix rename to modules/languages/julia/julia-modules/indexing/default.nix diff --git a/languages/julia/julia-modules/indexing/index-stdlib.jl b/modules/languages/julia/julia-modules/indexing/index-stdlib.jl similarity index 100% rename from languages/julia/julia-modules/indexing/index-stdlib.jl rename to modules/languages/julia/julia-modules/indexing/index-stdlib.jl diff --git a/languages/julia/julia-modules/indexing/index_packages.py b/modules/languages/julia/julia-modules/indexing/index_packages.py similarity index 100% rename from languages/julia/julia-modules/indexing/index_packages.py rename to modules/languages/julia/julia-modules/indexing/index_packages.py diff --git a/languages/julia/julia-modules/indexing/indexpackage.jl b/modules/languages/julia/julia-modules/indexing/indexpackage.jl similarity index 100% rename from languages/julia/julia-modules/indexing/indexpackage.jl rename to modules/languages/julia/julia-modules/indexing/indexpackage.jl diff --git a/languages/julia/julia-modules/package-closure.nix b/modules/languages/julia/julia-modules/package-closure.nix similarity index 100% rename from languages/julia/julia-modules/package-closure.nix rename to modules/languages/julia/julia-modules/package-closure.nix diff --git a/languages/julia/julia-modules/package-names.nix b/modules/languages/julia/julia-modules/package-names.nix similarity index 100% rename from languages/julia/julia-modules/package-names.nix rename to modules/languages/julia/julia-modules/package-names.nix diff --git a/languages/julia/julia-modules/python/dag.py b/modules/languages/julia/julia-modules/python/dag.py similarity index 100% rename from languages/julia/julia-modules/python/dag.py rename to modules/languages/julia/julia-modules/python/dag.py diff --git a/languages/julia/julia-modules/python/dedup_overrides.py b/modules/languages/julia/julia-modules/python/dedup_overrides.py similarity index 100% rename from languages/julia/julia-modules/python/dedup_overrides.py rename to modules/languages/julia/julia-modules/python/dedup_overrides.py diff --git a/languages/julia/julia-modules/python/extract_artifacts.py b/modules/languages/julia/julia-modules/python/extract_artifacts.py similarity index 100% rename from languages/julia/julia-modules/python/extract_artifacts.py rename to modules/languages/julia/julia-modules/python/extract_artifacts.py diff --git a/languages/julia/julia-modules/python/find_package_implications.py b/modules/languages/julia/julia-modules/python/find_package_implications.py similarity index 100% rename from languages/julia/julia-modules/python/find_package_implications.py rename to modules/languages/julia/julia-modules/python/find_package_implications.py diff --git a/languages/julia/julia-modules/python/format_overrides.py b/modules/languages/julia/julia-modules/python/format_overrides.py similarity index 100% rename from languages/julia/julia-modules/python/format_overrides.py rename to modules/languages/julia/julia-modules/python/format_overrides.py diff --git a/languages/julia/julia-modules/python/minimal_registry.py b/modules/languages/julia/julia-modules/python/minimal_registry.py similarity index 100% rename from languages/julia/julia-modules/python/minimal_registry.py rename to modules/languages/julia/julia-modules/python/minimal_registry.py diff --git a/languages/julia/julia-modules/python/sources_nix.py b/modules/languages/julia/julia-modules/python/sources_nix.py similarity index 100% rename from languages/julia/julia-modules/python/sources_nix.py rename to modules/languages/julia/julia-modules/python/sources_nix.py diff --git a/languages/julia/julia-modules/python/util.py b/modules/languages/julia/julia-modules/python/util.py similarity index 100% rename from languages/julia/julia-modules/python/util.py rename to modules/languages/julia/julia-modules/python/util.py diff --git a/languages/julia/julia-modules/registry.nix b/modules/languages/julia/julia-modules/registry.nix similarity index 100% rename from languages/julia/julia-modules/registry.nix rename to modules/languages/julia/julia-modules/registry.nix diff --git a/languages/julia/julia-modules/tests/.gitignore b/modules/languages/julia/julia-modules/tests/.gitignore similarity index 100% rename from languages/julia/julia-modules/tests/.gitignore rename to modules/languages/julia/julia-modules/tests/.gitignore diff --git a/languages/julia/julia-modules/tests/README.md b/modules/languages/julia/julia-modules/tests/README.md similarity index 100% rename from languages/julia/julia-modules/tests/README.md rename to modules/languages/julia/julia-modules/tests/README.md diff --git a/languages/julia/julia-modules/tests/julia-top-n/app/Main.hs b/modules/languages/julia/julia-modules/tests/julia-top-n/app/Main.hs similarity index 100% rename from languages/julia/julia-modules/tests/julia-top-n/app/Main.hs rename to modules/languages/julia/julia-modules/tests/julia-top-n/app/Main.hs diff --git a/languages/julia/julia-modules/tests/julia-top-n/default.nix b/modules/languages/julia/julia-modules/tests/julia-top-n/default.nix similarity index 100% rename from languages/julia/julia-modules/tests/julia-top-n/default.nix rename to modules/languages/julia/julia-modules/tests/julia-top-n/default.nix diff --git a/languages/julia/julia-modules/tests/julia-top-n/julia-top-n.cabal b/modules/languages/julia/julia-modules/tests/julia-top-n/julia-top-n.cabal similarity index 100% rename from languages/julia/julia-modules/tests/julia-top-n/julia-top-n.cabal rename to modules/languages/julia/julia-modules/tests/julia-top-n/julia-top-n.cabal diff --git a/languages/julia/julia-modules/tests/julia-top-n/package.yaml b/modules/languages/julia/julia-modules/tests/julia-top-n/package.yaml similarity index 100% rename from languages/julia/julia-modules/tests/julia-top-n/package.yaml rename to modules/languages/julia/julia-modules/tests/julia-top-n/package.yaml diff --git a/languages/julia/julia-modules/tests/julia-top-n/stack.yaml b/modules/languages/julia/julia-modules/tests/julia-top-n/stack.yaml similarity index 100% rename from languages/julia/julia-modules/tests/julia-top-n/stack.yaml rename to modules/languages/julia/julia-modules/tests/julia-top-n/stack.yaml diff --git a/languages/julia/julia-modules/tests/julia-top-n/stack.yaml.lock b/modules/languages/julia/julia-modules/tests/julia-top-n/stack.yaml.lock similarity index 100% rename from languages/julia/julia-modules/tests/julia-top-n/stack.yaml.lock rename to modules/languages/julia/julia-modules/tests/julia-top-n/stack.yaml.lock diff --git a/languages/julia/julia-modules/tests/process_top_n.py b/modules/languages/julia/julia-modules/tests/process_top_n.py similarity index 100% rename from languages/julia/julia-modules/tests/process_top_n.py rename to modules/languages/julia/julia-modules/tests/process_top_n.py diff --git a/languages/julia/julia-modules/tests/run_tests.sh b/modules/languages/julia/julia-modules/tests/run_tests.sh similarity index 100% rename from languages/julia/julia-modules/tests/run_tests.sh rename to modules/languages/julia/julia-modules/tests/run_tests.sh diff --git a/languages/julia/julia-modules/tests/top-julia-packages.nix b/modules/languages/julia/julia-modules/tests/top-julia-packages.nix similarity index 100% rename from languages/julia/julia-modules/tests/top-julia-packages.nix rename to modules/languages/julia/julia-modules/tests/top-julia-packages.nix diff --git a/languages/julia/julia-modules/util.nix b/modules/languages/julia/julia-modules/util.nix similarity index 100% rename from languages/julia/julia-modules/util.nix rename to modules/languages/julia/julia-modules/util.nix diff --git a/languages/julia/kernel.nix b/modules/languages/julia/kernel.nix similarity index 100% rename from languages/julia/kernel.nix rename to modules/languages/julia/kernel.nix diff --git a/languages/julia/language-server-LanguageServer.nix b/modules/languages/julia/language-server-LanguageServer.nix similarity index 100% rename from languages/julia/language-server-LanguageServer.nix rename to modules/languages/julia/language-server-LanguageServer.nix diff --git a/languages/julia/module.nix b/modules/languages/julia/module.nix similarity index 92% rename from languages/julia/module.nix rename to modules/languages/julia/module.nix index fe8d2789..595de281 100644 --- a/languages/julia/module.nix +++ b/modules/languages/julia/module.nix @@ -63,11 +63,11 @@ with lib; }; config = mkIf config.kernels.julia.enable { - builtKernels.julia = config.pkgs.callPackage ./full.nix { + builtKernels.julia = config.pkgs.callPackage ./. { julia = getAttr config.kernels.julia.juliaPackage config.pkgs; inherit (config.kernels.julia) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.julia; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.julia; }; }; } diff --git a/languages/octave/full.nix b/modules/languages/octave/default.nix similarity index 98% rename from languages/octave/full.nix rename to modules/languages/octave/default.nix index bb940b44..189e51e9 100644 --- a/languages/octave/full.nix +++ b/modules/languages/octave/default.nix @@ -61,7 +61,7 @@ symlinkJoin { packages = []; }; meta = octave.meta // { - baseName = x; + baseName = "octave"; displayName = "Octave " + octave.version; version = octave.version; icon = ./octave-logo-64x64.png; diff --git a/languages/octave/kernel.nix b/modules/languages/octave/kernel.nix similarity index 100% rename from languages/octave/kernel.nix rename to modules/languages/octave/kernel.nix diff --git a/languages/octave/metadata.nix b/modules/languages/octave/metadata.nix similarity index 100% rename from languages/octave/metadata.nix rename to modules/languages/octave/metadata.nix diff --git a/languages/octave/module.nix b/modules/languages/octave/module.nix similarity index 84% rename from languages/octave/module.nix rename to modules/languages/octave/module.nix index 9adc8f3c..8f46404e 100644 --- a/languages/octave/module.nix +++ b/modules/languages/octave/module.nix @@ -34,10 +34,10 @@ with lib; }; config = mkIf config.kernels.octave.enable { - builtKernels.octave = config.pkgs.callPackage ./full.nix { + builtKernels.octave = config.pkgs.callPackage ./. { octave = config.pkgs.octave; inherit (config.kernels.octave) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.octave; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.octave; }; }; } diff --git a/languages/octave/octave-logo-32x32.png b/modules/languages/octave/octave-logo-32x32.png similarity index 100% rename from languages/octave/octave-logo-32x32.png rename to modules/languages/octave/octave-logo-32x32.png diff --git a/languages/octave/octave-logo-64x64.png b/modules/languages/octave/octave-logo-64x64.png similarity index 100% rename from languages/octave/octave-logo-64x64.png rename to modules/languages/octave/octave-logo-64x64.png diff --git a/languages/octave/octave.nix b/modules/languages/octave/octave.nix similarity index 100% rename from languages/octave/octave.nix rename to modules/languages/octave/octave.nix diff --git a/languages/postgres/full.nix b/modules/languages/postgres/default.nix similarity index 100% rename from languages/postgres/full.nix rename to modules/languages/postgres/default.nix diff --git a/languages/postgres/kernel.nix b/modules/languages/postgres/kernel.nix similarity index 100% rename from languages/postgres/kernel.nix rename to modules/languages/postgres/kernel.nix diff --git a/languages/postgres/logo.svg b/modules/languages/postgres/logo.svg similarity index 100% rename from languages/postgres/logo.svg rename to modules/languages/postgres/logo.svg diff --git a/languages/postgres/module.nix b/modules/languages/postgres/module.nix similarity index 81% rename from languages/postgres/module.nix rename to modules/languages/postgres/module.nix index fb37778e..3515cc0a 100644 --- a/languages/postgres/module.nix +++ b/modules/languages/postgres/module.nix @@ -30,9 +30,9 @@ with lib; }; config = mkIf config.kernels.postgres.enable { - builtKernels.postgres = config.pkgs.callPackage ./full.nix { + builtKernels.postgres = config.pkgs.callPackage ./. { inherit (config.kernels.postgres) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.postgres; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.postgres; }; }; } diff --git a/languages/postgres/postgres-logo-32x32.png b/modules/languages/postgres/postgres-logo-32x32.png similarity index 100% rename from languages/postgres/postgres-logo-32x32.png rename to modules/languages/postgres/postgres-logo-32x32.png diff --git a/languages/postgres/postgres-logo-64x64.png b/modules/languages/postgres/postgres-logo-64x64.png similarity index 100% rename from languages/postgres/postgres-logo-64x64.png rename to modules/languages/postgres/postgres-logo-64x64.png diff --git a/languages/python/full.nix b/modules/languages/python/default.nix similarity index 98% rename from languages/python/full.nix rename to modules/languages/python/default.nix index 52781f5e..c7853841 100644 --- a/languages/python/full.nix +++ b/modules/languages/python/default.nix @@ -56,7 +56,7 @@ symlinkJoin { paths = [ (callPackage ./kernel.nix { python = pythonToUse; - inherit displayName attrs extensions; + inherit displayName kernelName attrs extensions; enableVariableInspector = settings.enableVariableInspector; }) diff --git a/languages/python/envs/.gitignore b/modules/languages/python/envs/.gitignore similarity index 100% rename from languages/python/envs/.gitignore rename to modules/languages/python/envs/.gitignore diff --git a/languages/python/envs/python311/poetry.lock b/modules/languages/python/envs/python311/poetry.lock similarity index 100% rename from languages/python/envs/python311/poetry.lock rename to modules/languages/python/envs/python311/poetry.lock diff --git a/languages/python/envs/python311/pyproject.toml b/modules/languages/python/envs/python311/pyproject.toml similarity index 100% rename from languages/python/envs/python311/pyproject.toml rename to modules/languages/python/envs/python311/pyproject.toml diff --git a/languages/python/envs/python311/python311/__init__.py b/modules/languages/python/envs/python311/python311/__init__.py similarity index 100% rename from languages/python/envs/python311/python311/__init__.py rename to modules/languages/python/envs/python311/python311/__init__.py diff --git a/languages/python/envs/python38/poetry-overrides.nix b/modules/languages/python/envs/python38/poetry-overrides.nix similarity index 100% rename from languages/python/envs/python38/poetry-overrides.nix rename to modules/languages/python/envs/python38/poetry-overrides.nix diff --git a/languages/python/envs/python38/poetry.lock b/modules/languages/python/envs/python38/poetry.lock similarity index 100% rename from languages/python/envs/python38/poetry.lock rename to modules/languages/python/envs/python38/poetry.lock diff --git a/languages/python/envs/python38/pyproject.toml b/modules/languages/python/envs/python38/pyproject.toml similarity index 100% rename from languages/python/envs/python38/pyproject.toml rename to modules/languages/python/envs/python38/pyproject.toml diff --git a/languages/python/envs/python38/python38/__init__.py b/modules/languages/python/envs/python38/python38/__init__.py similarity index 100% rename from languages/python/envs/python38/python38/__init__.py rename to modules/languages/python/envs/python38/python38/__init__.py diff --git a/languages/python/envs/python38/shell.nix b/modules/languages/python/envs/python38/shell.nix similarity index 100% rename from languages/python/envs/python38/shell.nix rename to modules/languages/python/envs/python38/shell.nix diff --git a/languages/python/envs/python39/poetry.lock b/modules/languages/python/envs/python39/poetry.lock similarity index 100% rename from languages/python/envs/python39/poetry.lock rename to modules/languages/python/envs/python39/poetry.lock diff --git a/languages/python/envs/python39/pyproject.toml b/modules/languages/python/envs/python39/pyproject.toml similarity index 100% rename from languages/python/envs/python39/pyproject.toml rename to modules/languages/python/envs/python39/pyproject.toml diff --git a/languages/python/envs/python39/python39/__init__.py b/modules/languages/python/envs/python39/python39/__init__.py similarity index 100% rename from languages/python/envs/python39/python39/__init__.py rename to modules/languages/python/envs/python39/python39/__init__.py diff --git a/languages/python/home_folder/.config/pycodestyle b/modules/languages/python/home_folder/.config/pycodestyle similarity index 100% rename from languages/python/home_folder/.config/pycodestyle rename to modules/languages/python/home_folder/.config/pycodestyle diff --git a/languages/python/home_folder/.ipython/profile_default/ipython_config.py b/modules/languages/python/home_folder/.ipython/profile_default/ipython_config.py similarity index 100% rename from languages/python/home_folder/.ipython/profile_default/ipython_config.py rename to modules/languages/python/home_folder/.ipython/profile_default/ipython_config.py diff --git a/languages/python/home_folder/ipython_config.py b/modules/languages/python/home_folder/ipython_config.py similarity index 100% rename from languages/python/home_folder/ipython_config.py rename to modules/languages/python/home_folder/ipython_config.py diff --git a/languages/python/home_folder/pycodestyle b/modules/languages/python/home_folder/pycodestyle similarity index 100% rename from languages/python/home_folder/pycodestyle rename to modules/languages/python/home_folder/pycodestyle diff --git a/languages/python/kernel.nix b/modules/languages/python/kernel.nix similarity index 93% rename from languages/python/kernel.nix rename to modules/languages/python/kernel.nix index 05b3718b..2b126c2b 100644 --- a/languages/python/kernel.nix +++ b/modules/languages/python/kernel.nix @@ -1,6 +1,8 @@ { lib , callPackage , python + +, kernelName , displayName , enableVariableInspector @@ -24,10 +26,10 @@ in common.makeJupyterKernel ( listToAttrs [{ - name = head attrs; + name = kernelName; value = { displayName = displayName; - language = head attrs; + language = kernelName; argv = [ "${python}/bin/python" "-m" diff --git a/languages/python/language_servers/language_server_flake8/config.nix b/modules/languages/python/language_servers/language_server_flake8/config.nix similarity index 100% rename from languages/python/language_servers/language_server_flake8/config.nix rename to modules/languages/python/language_servers/language_server_flake8/config.nix diff --git a/languages/python/language_servers/language_server_jedi/config.nix b/modules/languages/python/language_servers/language_server_jedi/config.nix similarity index 100% rename from languages/python/language_servers/language_server_jedi/config.nix rename to modules/languages/python/language_servers/language_server_jedi/config.nix diff --git a/languages/python/language_servers/language_server_jedi/jedi-logo.png b/modules/languages/python/language_servers/language_server_jedi/jedi-logo.png similarity index 100% rename from languages/python/language_servers/language_server_jedi/jedi-logo.png rename to modules/languages/python/language_servers/language_server_jedi/jedi-logo.png diff --git a/languages/python/language_servers/language_server_microsoft/config.nix b/modules/languages/python/language_servers/language_server_microsoft/config.nix similarity index 100% rename from languages/python/language_servers/language_server_microsoft/config.nix rename to modules/languages/python/language_servers/language_server_microsoft/config.nix diff --git a/languages/python/language_servers/language_server_microsoft/generate_cache.py b/modules/languages/python/language_servers/language_server_microsoft/generate_cache.py similarity index 100% rename from languages/python/language_servers/language_server_microsoft/generate_cache.py rename to modules/languages/python/language_servers/language_server_microsoft/generate_cache.py diff --git a/languages/python/language_servers/language_server_palantir/config.nix b/modules/languages/python/language_servers/language_server_palantir/config.nix similarity index 100% rename from languages/python/language_servers/language_server_palantir/config.nix rename to modules/languages/python/language_servers/language_server_palantir/config.nix diff --git a/languages/python/language_servers/language_server_pycodestyle/config.nix b/modules/languages/python/language_servers/language_server_pycodestyle/config.nix similarity index 100% rename from languages/python/language_servers/language_server_pycodestyle/config.nix rename to modules/languages/python/language_servers/language_server_pycodestyle/config.nix diff --git a/languages/python/language_servers/language_server_pylint/config.nix b/modules/languages/python/language_servers/language_server_pylint/config.nix similarity index 100% rename from languages/python/language_servers/language_server_pylint/config.nix rename to modules/languages/python/language_servers/language_server_pylint/config.nix diff --git a/languages/python/language_servers/language_server_pylint/pylint-logo.png b/modules/languages/python/language_servers/language_server_pylint/pylint-logo.png similarity index 100% rename from languages/python/language_servers/language_server_pylint/pylint-logo.png rename to modules/languages/python/language_servers/language_server_pylint/pylint-logo.png diff --git a/languages/python/language_servers/language_server_pyright/config.nix b/modules/languages/python/language_servers/language_server_pyright/config.nix similarity index 100% rename from languages/python/language_servers/language_server_pyright/config.nix rename to modules/languages/python/language_servers/language_server_pyright/config.nix diff --git a/languages/python/language_servers/language_server_pyright/icon.png b/modules/languages/python/language_servers/language_server_pyright/icon.png similarity index 100% rename from languages/python/language_servers/language_server_pyright/icon.png rename to modules/languages/python/language_servers/language_server_pyright/icon.png diff --git a/languages/python/language_servers/language_server_pyright/icon_scaled.xcf b/modules/languages/python/language_servers/language_server_pyright/icon_scaled.xcf similarity index 100% rename from languages/python/language_servers/language_server_pyright/icon_scaled.xcf rename to modules/languages/python/language_servers/language_server_pyright/icon_scaled.xcf diff --git a/languages/python/language_servers/language_server_pyright/icon_scaled_64x64.png b/modules/languages/python/language_servers/language_server_pyright/icon_scaled_64x64.png similarity index 100% rename from languages/python/language_servers/language_server_pyright/icon_scaled_64x64.png rename to modules/languages/python/language_servers/language_server_pyright/icon_scaled_64x64.png diff --git a/languages/python/language_servers/language_server_pyright/icon_scaled_64x64.xcf b/modules/languages/python/language_servers/language_server_pyright/icon_scaled_64x64.xcf similarity index 100% rename from languages/python/language_servers/language_server_pyright/icon_scaled_64x64.xcf rename to modules/languages/python/language_servers/language_server_pyright/icon_scaled_64x64.xcf diff --git a/languages/python/language_servers/language_server_pythonlsp/config.nix b/modules/languages/python/language_servers/language_server_pythonlsp/config.nix similarity index 100% rename from languages/python/language_servers/language_server_pythonlsp/config.nix rename to modules/languages/python/language_servers/language_server_pythonlsp/config.nix diff --git a/languages/python/language_servers/pylsp_initialization_options.nix b/modules/languages/python/language_servers/pylsp_initialization_options.nix similarity index 100% rename from languages/python/language_servers/pylsp_initialization_options.nix rename to modules/languages/python/language_servers/pylsp_initialization_options.nix diff --git a/languages/python/manylinux1.nix b/modules/languages/python/manylinux1.nix similarity index 100% rename from languages/python/manylinux1.nix rename to modules/languages/python/manylinux1.nix diff --git a/languages/python/module.nix b/modules/languages/python/module.nix similarity index 93% rename from languages/python/module.nix rename to modules/languages/python/module.nix index 9a1a67c0..efac61c2 100644 --- a/languages/python/module.nix +++ b/modules/languages/python/module.nix @@ -122,21 +122,21 @@ in }).overrideAttrs (_: { version = specialEnvPythons.${x}.version; }) else lib.getAttr x config.pkgs; in - config.pkgs.callPackage ./full.nix { + config.pkgs.callPackage ./. { python3 = basePython; inherit (config.kernels.python3) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.python3; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.python3; }; }) (mkIf config.kernels.pypy3.enable { builtKernels.pypy3 = - config.pkgs.callPackage ./full.nix { + config.pkgs.callPackage ./. { python3 = lib.getAttr config.kernels.pypy3.python3Package config.pkgs; inherit (config.kernels.pypy3) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.pypy3; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.pypy3; }; }) ]; diff --git a/languages/python/python-logo-32x32.png b/modules/languages/python/python-logo-32x32.png similarity index 100% rename from languages/python/python-logo-32x32.png rename to modules/languages/python/python-logo-32x32.png diff --git a/languages/python/python-logo-64x64.png b/modules/languages/python/python-logo-64x64.png similarity index 100% rename from languages/python/python-logo-64x64.png rename to modules/languages/python/python-logo-64x64.png diff --git a/languages/python/variable_inspector.py b/modules/languages/python/variable_inspector.py similarity index 100% rename from languages/python/variable_inspector.py rename to modules/languages/python/variable_inspector.py diff --git a/languages/r/full.nix b/modules/languages/r/default.nix similarity index 100% rename from languages/r/full.nix rename to modules/languages/r/default.nix diff --git a/languages/r/kernel.nix b/modules/languages/r/kernel.nix similarity index 100% rename from languages/r/kernel.nix rename to modules/languages/r/kernel.nix diff --git a/languages/r/language-server-languageserver/default.nix b/modules/languages/r/language-server-languageserver/default.nix similarity index 100% rename from languages/r/language-server-languageserver/default.nix rename to modules/languages/r/language-server-languageserver/default.nix diff --git a/languages/r/language-server-languageserver/languageserver.nix b/modules/languages/r/language-server-languageserver/languageserver.nix similarity index 100% rename from languages/r/language-server-languageserver/languageserver.nix rename to modules/languages/r/language-server-languageserver/languageserver.nix diff --git a/languages/r/module.nix b/modules/languages/r/module.nix similarity index 85% rename from languages/r/module.nix rename to modules/languages/r/module.nix index 66e42224..5c9af485 100644 --- a/languages/r/module.nix +++ b/modules/languages/r/module.nix @@ -34,10 +34,10 @@ with lib; }; config = mkIf config.kernels.R.enable { - builtKernels.R = config.pkgs.callPackage ./full.nix { + builtKernels.R = config.pkgs.callPackage ./. { R = config.pkgs.R; inherit (config.kernels.R) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.R; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.R; }; }; } diff --git a/languages/r/r-logo-64x64.png b/modules/languages/r/r-logo-64x64.png similarity index 100% rename from languages/r/r-logo-64x64.png rename to modules/languages/r/r-logo-64x64.png diff --git a/languages/ruby/full.nix b/modules/languages/ruby/default.nix similarity index 98% rename from languages/ruby/full.nix rename to modules/languages/ruby/default.nix index c24de1b9..d586759e 100644 --- a/languages/ruby/full.nix +++ b/modules/languages/ruby/default.nix @@ -24,14 +24,14 @@ let rubyPackages = recurseIntoAttrs ruby.gems; + packageOptions = rubyPackages; + packageSearch = common.searcher packageOptions; + languageServers = [] ++ lib.optionals settings.lsp.solargraph.enable [(callPackage ./solargraph.nix { rubyPackages = packageOptions; inherit kernelName; })] ; - packageOptions = rubyPackages; - packageSearch = common.searcher packageOptions; - in symlinkJoin { @@ -47,7 +47,7 @@ symlinkJoin { ; passthru = { meta = ruby.meta // { - baseName = x; + baseName = "ruby"; displayName = "Ruby"; version = ruby.version; icon = ./iruby-64x64.png; diff --git a/languages/ruby/iruby-32x32.png b/modules/languages/ruby/iruby-32x32.png similarity index 100% rename from languages/ruby/iruby-32x32.png rename to modules/languages/ruby/iruby-32x32.png diff --git a/languages/ruby/iruby-64x64.png b/modules/languages/ruby/iruby-64x64.png similarity index 100% rename from languages/ruby/iruby-64x64.png rename to modules/languages/ruby/iruby-64x64.png diff --git a/languages/ruby/iruby/Gemfile b/modules/languages/ruby/iruby/Gemfile similarity index 100% rename from languages/ruby/iruby/Gemfile rename to modules/languages/ruby/iruby/Gemfile diff --git a/languages/ruby/iruby/Gemfile.lock b/modules/languages/ruby/iruby/Gemfile.lock similarity index 100% rename from languages/ruby/iruby/Gemfile.lock rename to modules/languages/ruby/iruby/Gemfile.lock diff --git a/languages/ruby/iruby/default.nix b/modules/languages/ruby/iruby/default.nix similarity index 100% rename from languages/ruby/iruby/default.nix rename to modules/languages/ruby/iruby/default.nix diff --git a/languages/ruby/iruby/gemset.nix b/modules/languages/ruby/iruby/gemset.nix similarity index 100% rename from languages/ruby/iruby/gemset.nix rename to modules/languages/ruby/iruby/gemset.nix diff --git a/languages/ruby/iruby/shell.nix b/modules/languages/ruby/iruby/shell.nix similarity index 100% rename from languages/ruby/iruby/shell.nix rename to modules/languages/ruby/iruby/shell.nix diff --git a/languages/ruby/kernel.nix b/modules/languages/ruby/kernel.nix similarity index 100% rename from languages/ruby/kernel.nix rename to modules/languages/ruby/kernel.nix diff --git a/languages/ruby/module.nix b/modules/languages/ruby/module.nix similarity index 73% rename from languages/ruby/module.nix rename to modules/languages/ruby/module.nix index e87d57c8..759ff332 100644 --- a/languages/ruby/module.nix +++ b/modules/languages/ruby/module.nix @@ -1,7 +1,12 @@ -{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, ... }: +{ config, options, lib, nixosOptionsToSettingsSchema, ... }: with lib; +let + pkgs = config.pkgsMaster; + +in + { options = { kernels.ruby = { @@ -19,7 +24,7 @@ with lib; type = types.enum ( ["ruby"] ++ (builtins.filter (name: builtins.substring 0 (builtins.stringLength "ruby_") name == "ruby_") - (builtins.attrNames config.pkgs)) + (builtins.attrNames pkgs)) ); default = "ruby"; }; @@ -43,11 +48,11 @@ with lib; }; config = mkIf config.kernels.ruby.enable { - builtKernels.ruby = config.pkgs.callPackage ./full.nix { - ruby = getAttr config.kernels.ruby.rubyPackage config.pkgs; + builtKernels.ruby = pkgs.callPackage ./. { + ruby = getAttr config.kernels.ruby.rubyPackage pkgs; inherit (config.kernels.ruby) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.ruby; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.ruby; }; }; } diff --git a/languages/ruby/solargraph.nix b/modules/languages/ruby/solargraph.nix similarity index 94% rename from languages/ruby/solargraph.nix rename to modules/languages/ruby/solargraph.nix index 68f18559..c5f80c4d 100644 --- a/languages/ruby/solargraph.nix +++ b/modules/languages/ruby/solargraph.nix @@ -2,7 +2,6 @@ , lib , rubyPackages -, solargraph ? rubyPackages.solargraph , kernelName }: @@ -11,6 +10,8 @@ let languageServerName = "solargraph"; + solargraph = rubyPackages.solargraph; + passthru = { inherit languageServerName; }; diff --git a/languages/rust/all_package_names.nix b/modules/languages/rust/all_package_names.nix similarity index 100% rename from languages/rust/all_package_names.nix rename to modules/languages/rust/all_package_names.nix diff --git a/languages/rust/full.nix b/modules/languages/rust/default.nix similarity index 98% rename from languages/rust/full.nix rename to modules/languages/rust/default.nix index 254102b1..876deded 100644 --- a/languages/rust/full.nix +++ b/modules/languages/rust/default.nix @@ -80,7 +80,7 @@ symlinkJoin { passthru = { meta = rustPackages.rustc.meta // { - baseName = x; + baseName = "rust"; inherit displayName; icon = ./rust-logo-64x64.png; inherit settingsSchema; diff --git a/languages/rust/evcxr/default.nix b/modules/languages/rust/evcxr/default.nix similarity index 100% rename from languages/rust/evcxr/default.nix rename to modules/languages/rust/evcxr/default.nix diff --git a/languages/rust/evcxr/python/build_init_evcxr.py b/modules/languages/rust/evcxr/python/build_init_evcxr.py similarity index 85% rename from languages/rust/evcxr/python/build_init_evcxr.py rename to modules/languages/rust/evcxr/python/build_init_evcxr.py index 61821044..1ec1134b 100644 --- a/languages/rust/evcxr/python/build_init_evcxr.py +++ b/modules/languages/rust/evcxr/python/build_init_evcxr.py @@ -31,11 +31,11 @@ with open(out, "a") as f: for package in packages: package_name = package if isinstance(package, str) else package["name"] - settings = {} if isinstance(package, str) else package.get("settings", {}) + features = {} if isinstance(package, str) else package.get("features", {}) if package_name in name_to_dir: clauses = [f"""version = \"{name_to_version.get(package_name, "*")}\""""] - if "features" in settings: - clauses.append(f"""features = {json.dumps(settings["features"])}""") + if features: + clauses.append(f"""features = {json.dumps(features)}""") clauses_joined = ", ".join(clauses) diff --git a/languages/rust/evcxr/withPackages.nix b/modules/languages/rust/evcxr/withPackages.nix similarity index 92% rename from languages/rust/evcxr/withPackages.nix rename to modules/languages/rust/evcxr/withPackages.nix index 860b83fa..d7056bf5 100644 --- a/languages/rust/evcxr/withPackages.nix +++ b/modules/languages/rust/evcxr/withPackages.nix @@ -30,8 +30,8 @@ let renderPackage = pn: if builtins.isString pn then ''${pn} = "*"'' - else if builtins.isAttrs pn && lib.hasAttrByPath ["settings" "features"] pn - then ''${pn.name} = { version = "*", features = [${lib.concatStringsSep ", " (map (feat: ''"'' + feat + ''"'') pn.settings.features)}] }'' + else if builtins.isAttrs pn && lib.hasAttrByPath ["features"] pn + then ''${pn.name} = { version = "*", features = [${lib.concatStringsSep ", " (map (feat: ''"'' + feat + ''"'') pn.features)}] }'' else ''${pn.name} = { version = "*" }''; cargoToml = packages: writeTextFile { diff --git a/languages/rust/generate_all_package_names.sh b/modules/languages/rust/generate_all_package_names.sh similarity index 100% rename from languages/rust/generate_all_package_names.sh rename to modules/languages/rust/generate_all_package_names.sh diff --git a/languages/rust/kernel.nix b/modules/languages/rust/kernel.nix similarity index 100% rename from languages/rust/kernel.nix rename to modules/languages/rust/kernel.nix diff --git a/languages/rust/language_server_rust_analyzer/Cargo.toml b/modules/languages/rust/language_server_rust_analyzer/Cargo.toml similarity index 100% rename from languages/rust/language_server_rust_analyzer/Cargo.toml rename to modules/languages/rust/language_server_rust_analyzer/Cargo.toml diff --git a/languages/rust/language_server_rust_analyzer/config.nix b/modules/languages/rust/language_server_rust_analyzer/config.nix similarity index 100% rename from languages/rust/language_server_rust_analyzer/config.nix rename to modules/languages/rust/language_server_rust_analyzer/config.nix diff --git a/languages/rust/language_server_rust_analyzer/logo-square.svg b/modules/languages/rust/language_server_rust_analyzer/logo-square.svg similarity index 100% rename from languages/rust/language_server_rust_analyzer/logo-square.svg rename to modules/languages/rust/language_server_rust_analyzer/logo-square.svg diff --git a/languages/rust/language_server_rust_analyzer/lsp-types.nix b/modules/languages/rust/language_server_rust_analyzer/lsp-types.nix similarity index 100% rename from languages/rust/language_server_rust_analyzer/lsp-types.nix rename to modules/languages/rust/language_server_rust_analyzer/lsp-types.nix diff --git a/languages/rust/language_server_rust_analyzer/myers-diff.nix b/modules/languages/rust/language_server_rust_analyzer/myers-diff.nix similarity index 100% rename from languages/rust/language_server_rust_analyzer/myers-diff.nix rename to modules/languages/rust/language_server_rust_analyzer/myers-diff.nix diff --git a/languages/rust/language_server_rust_analyzer/rnls.nix b/modules/languages/rust/language_server_rust_analyzer/rnls.nix similarity index 100% rename from languages/rust/language_server_rust_analyzer/rnls.nix rename to modules/languages/rust/language_server_rust_analyzer/rnls.nix diff --git a/languages/rust/language_server_rust_analyzer/rust-analyzer-logo-64x64.png b/modules/languages/rust/language_server_rust_analyzer/rust-analyzer-logo-64x64.png similarity index 100% rename from languages/rust/language_server_rust_analyzer/rust-analyzer-logo-64x64.png rename to modules/languages/rust/language_server_rust_analyzer/rust-analyzer-logo-64x64.png diff --git a/languages/rust/logo-LICENSE.md b/modules/languages/rust/logo-LICENSE.md similarity index 100% rename from languages/rust/logo-LICENSE.md rename to modules/languages/rust/logo-LICENSE.md diff --git a/languages/rust/module.nix b/modules/languages/rust/module.nix similarity index 70% rename from languages/rust/module.nix rename to modules/languages/rust/module.nix index 2a59efd7..7414b4c7 100644 --- a/languages/rust/module.nix +++ b/modules/languages/rust/module.nix @@ -11,7 +11,18 @@ with lib; }; packages = mkOption { - type = types.listOf (types.either types.str types.attrs); + type = types.listOf (types.either types.str (types.submodule { + options = { + name = mkOption rec { + type = types.str; + description = "Package name"; + }; + features = mkOption rec { + type = types.listOf types.str; + description = "Features to enable for the package"; + }; + }; + })); default = []; }; @@ -51,11 +62,11 @@ with lib; }; config = mkIf config.kernels.rust.enable { - builtKernels.rust = config.pkgs.callPackage ./full.nix { + builtKernels.rust = config.pkgs.callPackage ./. { rust = getAttr config.kernels.rust.rustPackage config.pkgs; inherit (config.kernels.rust) packages attrs extensions settings; - settingsSchema = nixosOptionsToSettingsSchema options.kernels.rust; + settingsSchema = nixosOptionsToSettingsSchema { componentsToDrop = 2; } options.kernels.rust; }; }; } diff --git a/languages/rust/rust-logo-32x32.png b/modules/languages/rust/rust-logo-32x32.png similarity index 100% rename from languages/rust/rust-logo-32x32.png rename to modules/languages/rust/rust-logo-32x32.png diff --git a/languages/rust/rust-logo-64x64.png b/modules/languages/rust/rust-logo-64x64.png similarity index 100% rename from languages/rust/rust-logo-64x64.png rename to modules/languages/rust/rust-logo-64x64.png diff --git a/shells/ICON_LICENSE.txt b/modules/shells/ICON_LICENSE.txt similarity index 100% rename from shells/ICON_LICENSE.txt rename to modules/shells/ICON_LICENSE.txt diff --git a/shells/bash/default.nix b/modules/shells/bash/default.nix similarity index 100% rename from shells/bash/default.nix rename to modules/shells/bash/default.nix diff --git a/shells/bash/module.nix b/modules/shells/bash/module.nix similarity index 100% rename from shells/bash/module.nix rename to modules/shells/bash/module.nix diff --git a/shells/common.nix b/modules/shells/common.nix similarity index 100% rename from shells/common.nix rename to modules/shells/common.nix diff --git a/shells/default_icon.png b/modules/shells/default_icon.png similarity index 100% rename from shells/default_icon.png rename to modules/shells/default_icon.png diff --git a/shells/default_icon.xcf b/modules/shells/default_icon.xcf similarity index 100% rename from shells/default_icon.xcf rename to modules/shells/default_icon.xcf diff --git a/shells/default_icon_64x64.png b/modules/shells/default_icon_64x64.png similarity index 100% rename from shells/default_icon_64x64.png rename to modules/shells/default_icon_64x64.png diff --git a/shells/default_icon_64x64.xcf b/modules/shells/default_icon_64x64.xcf similarity index 100% rename from shells/default_icon_64x64.xcf rename to modules/shells/default_icon_64x64.xcf diff --git a/shells/fish/color.sh b/modules/shells/fish/color.sh similarity index 100% rename from shells/fish/color.sh rename to modules/shells/fish/color.sh diff --git a/shells/fish/default.nix b/modules/shells/fish/default.nix similarity index 100% rename from shells/fish/default.nix rename to modules/shells/fish/default.nix diff --git a/shells/fish/fish.nix b/modules/shells/fish/fish.nix similarity index 100% rename from shells/fish/fish.nix rename to modules/shells/fish/fish.nix diff --git a/shells/fish/icon-64x64.png b/modules/shells/fish/icon-64x64.png similarity index 100% rename from shells/fish/icon-64x64.png rename to modules/shells/fish/icon-64x64.png diff --git a/shells/fish/icon-64x64.xcf b/modules/shells/fish/icon-64x64.xcf similarity index 100% rename from shells/fish/icon-64x64.xcf rename to modules/shells/fish/icon-64x64.xcf diff --git a/shells/fish/icon.xcf b/modules/shells/fish/icon.xcf similarity index 100% rename from shells/fish/icon.xcf rename to modules/shells/fish/icon.xcf diff --git a/shells/fish/module.nix b/modules/shells/fish/module.nix similarity index 100% rename from shells/fish/module.nix rename to modules/shells/fish/module.nix diff --git a/shells/zsh/default.nix b/modules/shells/zsh/default.nix similarity index 100% rename from shells/zsh/default.nix rename to modules/shells/zsh/default.nix diff --git a/shells/zsh/module.nix b/modules/shells/zsh/module.nix similarity index 100% rename from shells/zsh/module.nix rename to modules/shells/zsh/module.nix diff --git a/shells/zsh/zsh-with-theme/color.sh b/modules/shells/zsh/zsh-with-theme/color.sh similarity index 100% rename from shells/zsh/zsh-with-theme/color.sh rename to modules/shells/zsh/zsh-with-theme/color.sh diff --git a/shells/zsh/zsh-with-theme/default.nix b/modules/shells/zsh/zsh-with-theme/default.nix similarity index 100% rename from shells/zsh/zsh-with-theme/default.nix rename to modules/shells/zsh/zsh-with-theme/default.nix diff --git a/misc/builds-forever.nix b/modules/testing/builds-forever.nix similarity index 100% rename from misc/builds-forever.nix rename to modules/testing/builds-forever.nix diff --git a/tools/fuse-indexer/default.nix b/modules/tools/fuse-indexer/default.nix similarity index 100% rename from tools/fuse-indexer/default.nix rename to modules/tools/fuse-indexer/default.nix diff --git a/tools/powerline/config/colors.json b/modules/tools/powerline/config/colors.json similarity index 100% rename from tools/powerline/config/colors.json rename to modules/tools/powerline/config/colors.json diff --git a/tools/powerline/config/colorschemes/default.json b/modules/tools/powerline/config/colorschemes/default.json similarity index 100% rename from tools/powerline/config/colorschemes/default.json rename to modules/tools/powerline/config/colorschemes/default.json diff --git a/tools/powerline/config/colorschemes/ipython/__main__.json b/modules/tools/powerline/config/colorschemes/ipython/__main__.json similarity index 100% rename from tools/powerline/config/colorschemes/ipython/__main__.json rename to modules/tools/powerline/config/colorschemes/ipython/__main__.json diff --git a/tools/powerline/config/colorschemes/pdb/__main__.json b/modules/tools/powerline/config/colorschemes/pdb/__main__.json similarity index 100% rename from tools/powerline/config/colorschemes/pdb/__main__.json rename to modules/tools/powerline/config/colorschemes/pdb/__main__.json diff --git a/tools/powerline/config/colorschemes/pdb/default.json b/modules/tools/powerline/config/colorschemes/pdb/default.json similarity index 100% rename from tools/powerline/config/colorschemes/pdb/default.json rename to modules/tools/powerline/config/colorschemes/pdb/default.json diff --git a/tools/powerline/config/colorschemes/pdb/solarized.json b/modules/tools/powerline/config/colorschemes/pdb/solarized.json similarity index 100% rename from tools/powerline/config/colorschemes/pdb/solarized.json rename to modules/tools/powerline/config/colorschemes/pdb/solarized.json diff --git a/tools/powerline/config/colorschemes/shell/__main__.json b/modules/tools/powerline/config/colorschemes/shell/__main__.json similarity index 100% rename from tools/powerline/config/colorschemes/shell/__main__.json rename to modules/tools/powerline/config/colorschemes/shell/__main__.json diff --git a/tools/powerline/config/colorschemes/shell/default.json b/modules/tools/powerline/config/colorschemes/shell/default.json similarity index 100% rename from tools/powerline/config/colorschemes/shell/default.json rename to modules/tools/powerline/config/colorschemes/shell/default.json diff --git a/tools/powerline/config/colorschemes/shell/solarized.json b/modules/tools/powerline/config/colorschemes/shell/solarized.json similarity index 100% rename from tools/powerline/config/colorschemes/shell/solarized.json rename to modules/tools/powerline/config/colorschemes/shell/solarized.json diff --git a/tools/powerline/config/colorschemes/solarized.json b/modules/tools/powerline/config/colorschemes/solarized.json similarity index 100% rename from tools/powerline/config/colorschemes/solarized.json rename to modules/tools/powerline/config/colorschemes/solarized.json diff --git a/tools/powerline/config/colorschemes/tmux/default.json b/modules/tools/powerline/config/colorschemes/tmux/default.json similarity index 100% rename from tools/powerline/config/colorschemes/tmux/default.json rename to modules/tools/powerline/config/colorschemes/tmux/default.json diff --git a/tools/powerline/config/colorschemes/tmux/solarized.json b/modules/tools/powerline/config/colorschemes/tmux/solarized.json similarity index 100% rename from tools/powerline/config/colorschemes/tmux/solarized.json rename to modules/tools/powerline/config/colorschemes/tmux/solarized.json diff --git a/tools/powerline/config/colorschemes/vim/__main__.json b/modules/tools/powerline/config/colorschemes/vim/__main__.json similarity index 100% rename from tools/powerline/config/colorschemes/vim/__main__.json rename to modules/tools/powerline/config/colorschemes/vim/__main__.json diff --git a/tools/powerline/config/colorschemes/vim/default.json b/modules/tools/powerline/config/colorschemes/vim/default.json similarity index 100% rename from tools/powerline/config/colorschemes/vim/default.json rename to modules/tools/powerline/config/colorschemes/vim/default.json diff --git a/tools/powerline/config/colorschemes/vim/solarized.json b/modules/tools/powerline/config/colorschemes/vim/solarized.json similarity index 100% rename from tools/powerline/config/colorschemes/vim/solarized.json rename to modules/tools/powerline/config/colorschemes/vim/solarized.json diff --git a/tools/powerline/config/colorschemes/vim/solarizedlight.json b/modules/tools/powerline/config/colorschemes/vim/solarizedlight.json similarity index 100% rename from tools/powerline/config/colorschemes/vim/solarizedlight.json rename to modules/tools/powerline/config/colorschemes/vim/solarizedlight.json diff --git a/tools/powerline/config/config.json b/modules/tools/powerline/config/config.json similarity index 100% rename from tools/powerline/config/config.json rename to modules/tools/powerline/config/config.json diff --git a/tools/powerline/config/themes/ascii.json b/modules/tools/powerline/config/themes/ascii.json similarity index 100% rename from tools/powerline/config/themes/ascii.json rename to modules/tools/powerline/config/themes/ascii.json diff --git a/tools/powerline/config/themes/ipython/in.json b/modules/tools/powerline/config/themes/ipython/in.json similarity index 100% rename from tools/powerline/config/themes/ipython/in.json rename to modules/tools/powerline/config/themes/ipython/in.json diff --git a/tools/powerline/config/themes/ipython/in2.json b/modules/tools/powerline/config/themes/ipython/in2.json similarity index 100% rename from tools/powerline/config/themes/ipython/in2.json rename to modules/tools/powerline/config/themes/ipython/in2.json diff --git a/tools/powerline/config/themes/ipython/out.json b/modules/tools/powerline/config/themes/ipython/out.json similarity index 100% rename from tools/powerline/config/themes/ipython/out.json rename to modules/tools/powerline/config/themes/ipython/out.json diff --git a/tools/powerline/config/themes/ipython/rewrite.json b/modules/tools/powerline/config/themes/ipython/rewrite.json similarity index 100% rename from tools/powerline/config/themes/ipython/rewrite.json rename to modules/tools/powerline/config/themes/ipython/rewrite.json diff --git a/tools/powerline/config/themes/pdb/default.json b/modules/tools/powerline/config/themes/pdb/default.json similarity index 100% rename from tools/powerline/config/themes/pdb/default.json rename to modules/tools/powerline/config/themes/pdb/default.json diff --git a/tools/powerline/config/themes/powerline.json b/modules/tools/powerline/config/themes/powerline.json similarity index 100% rename from tools/powerline/config/themes/powerline.json rename to modules/tools/powerline/config/themes/powerline.json diff --git a/tools/powerline/config/themes/powerline_terminus.json b/modules/tools/powerline/config/themes/powerline_terminus.json similarity index 100% rename from tools/powerline/config/themes/powerline_terminus.json rename to modules/tools/powerline/config/themes/powerline_terminus.json diff --git a/tools/powerline/config/themes/powerline_unicode7.json b/modules/tools/powerline/config/themes/powerline_unicode7.json similarity index 100% rename from tools/powerline/config/themes/powerline_unicode7.json rename to modules/tools/powerline/config/themes/powerline_unicode7.json diff --git a/tools/powerline/config/themes/shell/__main__.json b/modules/tools/powerline/config/themes/shell/__main__.json similarity index 100% rename from tools/powerline/config/themes/shell/__main__.json rename to modules/tools/powerline/config/themes/shell/__main__.json diff --git a/tools/powerline/config/themes/shell/continuation.json b/modules/tools/powerline/config/themes/shell/continuation.json similarity index 100% rename from tools/powerline/config/themes/shell/continuation.json rename to modules/tools/powerline/config/themes/shell/continuation.json diff --git a/tools/powerline/config/themes/shell/default.json b/modules/tools/powerline/config/themes/shell/default.json similarity index 100% rename from tools/powerline/config/themes/shell/default.json rename to modules/tools/powerline/config/themes/shell/default.json diff --git a/tools/powerline/config/themes/shell/default_leftonly.json b/modules/tools/powerline/config/themes/shell/default_leftonly.json similarity index 100% rename from tools/powerline/config/themes/shell/default_leftonly.json rename to modules/tools/powerline/config/themes/shell/default_leftonly.json diff --git a/tools/powerline/config/themes/shell/select.json b/modules/tools/powerline/config/themes/shell/select.json similarity index 100% rename from tools/powerline/config/themes/shell/select.json rename to modules/tools/powerline/config/themes/shell/select.json diff --git a/tools/powerline/config/themes/tmux/default.json b/modules/tools/powerline/config/themes/tmux/default.json similarity index 100% rename from tools/powerline/config/themes/tmux/default.json rename to modules/tools/powerline/config/themes/tmux/default.json diff --git a/tools/powerline/config/themes/unicode.json b/modules/tools/powerline/config/themes/unicode.json similarity index 100% rename from tools/powerline/config/themes/unicode.json rename to modules/tools/powerline/config/themes/unicode.json diff --git a/tools/powerline/config/themes/unicode_terminus.json b/modules/tools/powerline/config/themes/unicode_terminus.json similarity index 100% rename from tools/powerline/config/themes/unicode_terminus.json rename to modules/tools/powerline/config/themes/unicode_terminus.json diff --git a/tools/powerline/config/themes/unicode_terminus_condensed.json b/modules/tools/powerline/config/themes/unicode_terminus_condensed.json similarity index 100% rename from tools/powerline/config/themes/unicode_terminus_condensed.json rename to modules/tools/powerline/config/themes/unicode_terminus_condensed.json diff --git a/tools/powerline/config/themes/vim/__main__.json b/modules/tools/powerline/config/themes/vim/__main__.json similarity index 100% rename from tools/powerline/config/themes/vim/__main__.json rename to modules/tools/powerline/config/themes/vim/__main__.json diff --git a/tools/powerline/config/themes/vim/cmdwin.json b/modules/tools/powerline/config/themes/vim/cmdwin.json similarity index 100% rename from tools/powerline/config/themes/vim/cmdwin.json rename to modules/tools/powerline/config/themes/vim/cmdwin.json diff --git a/tools/powerline/config/themes/vim/default.json b/modules/tools/powerline/config/themes/vim/default.json similarity index 100% rename from tools/powerline/config/themes/vim/default.json rename to modules/tools/powerline/config/themes/vim/default.json diff --git a/tools/powerline/config/themes/vim/help.json b/modules/tools/powerline/config/themes/vim/help.json similarity index 100% rename from tools/powerline/config/themes/vim/help.json rename to modules/tools/powerline/config/themes/vim/help.json diff --git a/tools/powerline/config/themes/vim/plugin_commandt.json b/modules/tools/powerline/config/themes/vim/plugin_commandt.json similarity index 100% rename from tools/powerline/config/themes/vim/plugin_commandt.json rename to modules/tools/powerline/config/themes/vim/plugin_commandt.json diff --git a/tools/powerline/config/themes/vim/plugin_gundo-preview.json b/modules/tools/powerline/config/themes/vim/plugin_gundo-preview.json similarity index 100% rename from tools/powerline/config/themes/vim/plugin_gundo-preview.json rename to modules/tools/powerline/config/themes/vim/plugin_gundo-preview.json diff --git a/tools/powerline/config/themes/vim/plugin_gundo.json b/modules/tools/powerline/config/themes/vim/plugin_gundo.json similarity index 100% rename from tools/powerline/config/themes/vim/plugin_gundo.json rename to modules/tools/powerline/config/themes/vim/plugin_gundo.json diff --git a/tools/powerline/config/themes/vim/plugin_nerdtree.json b/modules/tools/powerline/config/themes/vim/plugin_nerdtree.json similarity index 100% rename from tools/powerline/config/themes/vim/plugin_nerdtree.json rename to modules/tools/powerline/config/themes/vim/plugin_nerdtree.json diff --git a/tools/powerline/config/themes/vim/quickfix.json b/modules/tools/powerline/config/themes/vim/quickfix.json similarity index 100% rename from tools/powerline/config/themes/vim/quickfix.json rename to modules/tools/powerline/config/themes/vim/quickfix.json diff --git a/tools/powerline/config/themes/vim/tabline.json b/modules/tools/powerline/config/themes/vim/tabline.json similarity index 100% rename from tools/powerline/config/themes/vim/tabline.json rename to modules/tools/powerline/config/themes/vim/tabline.json diff --git a/tools/powerline/config/themes/wm/default.json b/modules/tools/powerline/config/themes/wm/default.json similarity index 100% rename from tools/powerline/config/themes/wm/default.json rename to modules/tools/powerline/config/themes/wm/default.json diff --git a/tools/powerline/default.nix b/modules/tools/powerline/default.nix similarity index 100% rename from tools/powerline/default.nix rename to modules/tools/powerline/default.nix diff --git a/tools/powerline/tmux-mem-cpu-load.nix b/modules/tools/powerline/tmux-mem-cpu-load.nix similarity index 100% rename from tools/powerline/tmux-mem-cpu-load.nix rename to modules/tools/powerline/tmux-mem-cpu-load.nix diff --git a/tools/sqlite-indexer/default.nix b/modules/tools/sqlite-indexer/default.nix similarity index 85% rename from tools/sqlite-indexer/default.nix rename to modules/tools/sqlite-indexer/default.nix index 552cdb54..40aabf20 100644 --- a/tools/sqlite-indexer/default.nix +++ b/modules/tools/sqlite-indexer/default.nix @@ -22,21 +22,26 @@ let common = callPackage ../../languages/common.nix {}; - uiMetadata = callPackage ../../codedown/uiMetadata.nix {}; + uiMetadata = callPackage ../../../nix/uiMetadata.nix {}; numVersionComponents = 5; componentPadLength = 3; - filteredPackages = with lib; filterAttrs (name: value: common.safeEval' false ( - (!packageMustBeDerivation || isDerivation(value)) + safeEval' = default: e: let + evaluated = builtins.tryEval e; + in + if evaluated.success then evaluated.value else default; + + filteredPackages = with lib; filterAttrs (name: value: safeEval' false ( + (!packageMustBeDerivation || isDerivation value) && - (!packageMustHaveName || (lib.attrByPath ["meta" "name"] "" value != "")) + (!packageMustHaveName || ((value.meta.name or "") != "")) )) packages; json = writeText "packages-index-yaml.json" (lib.generators.toJSON {} (lib.mapAttrsToList (k: v: { attr = attrPrefix + k; - name = common.safeEval (lib.attrByPath ["meta" "name"] "" v); - version = common.safeEval (common.lexicographyVersionNumber' numVersionComponents componentPadLength (lib.attrByPath ["meta" "version"] "" v)); + name = v.meta.name or ""; + version = common.lexicographyVersionNumber' numVersionComponents componentPadLength (v.meta.version or ""); meta = uiMetadata.chooseInterestingMeta v; }) filteredPackages)); @@ -61,7 +66,7 @@ rec { ''; allIcons = let - uniquePaths = lib.mapAttrsToList (k: v: common.safeEval (lib.attrByPath ["meta" "icon"] null v)) filteredPackages; + uniquePaths = lib.mapAttrsToList (k: v: v.meta.icon or null) filteredPackages; in linkFarm "all-searcher-icons" (map (path: { name = builtins.hashString "md5" (toString path); diff --git a/nix/evaluate-config.nix b/nix/evaluate-config.nix new file mode 100644 index 00000000..c7b8ae58 --- /dev/null +++ b/nix/evaluate-config.nix @@ -0,0 +1,47 @@ +{ lib +, pkgsStable +, pkgsMaster +}: + +config: + +lib.evalModules { + specialArgs = { + nixosOptionsToSettingsSchema = pkgsStable.callPackage ../modules/base/nixos-options-to-settings-schema.nix {}; + }; + modules = [ + ../modules/base.nix + + ../modules/exporters/module.nix + + ../modules/languages/bash/module.nix + ../modules/languages/clojure/module.nix + ../modules/languages/coq/module.nix + ../modules/languages/cpp/module.nix + ../modules/languages/go/module.nix + ../modules/languages/haskell/module.nix + ../modules/languages/julia/module.nix + ../modules/languages/octave/module.nix + ../modules/languages/postgres/module.nix + ../modules/languages/python/module.nix + ../modules/languages/r/module.nix + ../modules/languages/ruby/module.nix + ../modules/languages/rust/module.nix + + ../modules/language_servers/markdown-spellcheck-lsp/module.nix + + ../modules/shells/bash/module.nix + ../modules/shells/fish/module.nix + ../modules/shells/zsh/module.nix + + { + config = { + pkgs = pkgsStable; + inherit pkgsMaster; + }; + } + { + inherit config; + } + ]; +} diff --git a/nix/makeEnvironment.nix b/nix/makeEnvironment.nix new file mode 100644 index 00000000..32160eca --- /dev/null +++ b/nix/makeEnvironment.nix @@ -0,0 +1,112 @@ +{ callPackage +, lib +, fetchgit +, fetchFromGitHub +, symlinkJoin +, system +, writeTextDir +, writeText + +, pkgsStable +, pkgsMaster + +, name ? "codedown-environment" +}: + +config: + +with lib; + +let + evaluated = (callPackage ./evaluate-config.nix { inherit pkgsStable pkgsMaster; }) config; + + builtExporters = evaluated.config.builtExporters; + builtKernels = mapAttrs (_: kernel: + kernel.overrideAttrs (old: { + passthru = old.passthru // { + name = "kernels." + kernel.name; + # channel = kernel.channel; + channel = "codedown"; + }; + })) evaluated.config.builtKernels; + builtLanguageServers = evaluated.config.builtLanguageServers; + builtShells = evaluated.config.builtShells; + + repls = let + shellToReplInfo = shell: { + name = shell.name; + display_name = shell.meta.displayName; + inherit (shell.meta) attr args icon; + }; + in + map shellToReplInfo (attrValues builtShells) + ++ concatMap (kernel: lib.mapAttrsToList (name: value: value // { inherit name; }) (kernel.repls or {})) (attrValues builtKernels) + ; + + exporters = concatMap (exporter: exporter.meta.exporterInfos) (attrValues builtExporters); + + uiMetadata = callPackage ./uiMetadata.nix {}; + + mkPackageUiMetadata = let + # This is duplicated from languages/common.nix, which we'd rather not import here + packageName = p: if lib.isString p then p else p.name; + + mkSubPackageMetadata = pkg: p: { + name = packageName p; + meta = if lib.hasAttrByPath ["packageOptions" (packageName p)] pkg then uiMetadata.chooseInterestingMeta (pkg.packageOptions.${packageName p}) else {}; + } // (lib.optionalAttrs (lib.isAttrs p && p ? "settings") { + inherit (p) settings; + }); + in + pkg: { + # Dry + name = pkg.name; + settings = if pkg ? "settings" then pkg.settings else {}; + + # Different for hydrated + packages = map (p: mkSubPackageMetadata pkg p) (pkg.args.packages or []); + + # Hydrated + meta = uiMetadata.chooseInterestingMeta pkg; + }; + +in + +symlinkJoin { + inherit name; + paths = + attrValues (evaluated.config.builtKernels) + ++ attrValues (evaluated.config.builtLanguageServers) + ++ lib.optionals (builtins.length repls > 0) [(writeTextDir "lib/codedown/repls.yaml" (lib.generators.toYAML {} repls))] + ++ lib.optionals (builtins.length exporters > 0) [(writeTextDir "lib/codedown/exporters.yaml" (lib.generators.toYAML {} exporters))] + ++ evaluated.config.packages + ++ map (x: x.contents) evaluated.config.labeledPackages + ; + + passthru = rec { + inherit evaluated; + + inherit channels; + + ui_metadata = { + channels = lib.mapAttrsToList (name: channel: channel // { + name = name; + }) evaluated.config.channels; + + packages = + (mapAttrs' (n: v: nameValuePair "exporters.${n}" (mkPackageUiMetadata v)) builtExporters) + // (mapAttrs' (n: v: nameValuePair "kernels.${n}" (mkPackageUiMetadata v)) builtKernels) + // (mapAttrs' (n: v: nameValuePair "language-servers.${n}" (mkPackageUiMetadata v)) builtLanguageServers) + // (mapAttrs' (n: v: nameValuePair "shells.${n}" (mkPackageUiMetadata v)) builtShells) + ; + + other_packages = map (p: { + channel = p.channel; + attr = p.attr; + meta = if p.contents ? "meta" then uiMetadata.chooseInterestingMeta p.contents else {}; + }) evaluated.config.labeledPackages; + }; + + ui_metadata_yaml = writeText "ui-metadata.yaml" (lib.generators.toYAML {} ui_metadata); + }; +} diff --git a/nix/sample-outputs.nix b/nix/sample-outputs.nix index e0ab8884..65bce148 100644 --- a/nix/sample-outputs.nix +++ b/nix/sample-outputs.nix @@ -30,10 +30,18 @@ in sample_environments ); + all_settings_schemas = writeTextFile { + name = "all_settings_schemas.json"; + text = builtins.toJSON ( + lib.mapAttrs (n: v: lib.listToAttrs (map (x: lib.nameValuePair x.name x.meta.settings_schema) v.ui_metadata.kernels)) + sample_environments + ); + }; + printVersions = let versionsMap = with lib; - mapAttrs (lang: value: if (hasAttr "versions" value) then (value.versions) else {}) - (filterAttrs (k: _: !(hasPrefix "override") k) languages); + mapAttrs (lang: value: if (hasAttr "versions" value) then value.versions else {}) + (filterAttrs (k: _: !(hasPrefix "override") k) codedown.languages); file = writeTextFile { name = "versions.yaml"; diff --git a/codedown/uiMetadata.nix b/nix/uiMetadata.nix similarity index 56% rename from codedown/uiMetadata.nix rename to nix/uiMetadata.nix index 21c0df77..3b83fc28 100644 --- a/codedown/uiMetadata.nix +++ b/nix/uiMetadata.nix @@ -37,38 +37,4 @@ rec { }) // (lib.optionalAttrs (contents ? "languageServerNames") { language_server_names = contents.languageServerNames; }); - - mkChannelUiMetadata = name: channel: channel // { - name = name; - }; - - # This is duplicated from languages/common.nix, which we'd rather not import here - packageName = p: if lib.isString p then p else p.name; - - mkKernelPackageMetadata = kernel: p: { - name = packageName p; - meta = if lib.hasAttrByPath ["packageOptions" (packageName p)] kernel then chooseInterestingMeta (kernel.packageOptions.${packageName p}) else {}; - } // (lib.optionalAttrs (lib.isAttrs p && p ? "settings") { - inherit (p) settings; - }); - - mkKernelUiMetadata = kernel: { - # Dry - channel = kernel.channel; - name = kernel.name; - settings = if kernel ? "settings" then kernel.settings else {}; - - # Different for hydrated - packages = map (p: mkKernelPackageMetadata kernel p) kernel.args.packages; - - # Hydrated - modes = kernel.modes; - meta = chooseInterestingMeta kernel; - }; - - mkOtherPackageUiMetadata = package: { - channel = package.channel; - attr = package.attr; - meta = if package.contents ? "meta" then chooseInterestingMeta package.contents else {}; - }; } diff --git a/codedown/validateCodeDownEnvironment.nix b/nix/validateEnvironment.nix similarity index 100% rename from codedown/validateCodeDownEnvironment.nix rename to nix/validateEnvironment.nix diff --git a/overlays.nix b/overlays.nix deleted file mode 100644 index 478c7b68..00000000 --- a/overlays.nix +++ /dev/null @@ -1,3 +0,0 @@ -self: super: { - -} diff --git a/sample_environments/exporters-full.nix b/sample_environments/exporters-full.nix index f71b9f64..0260fa87 100644 --- a/sample_environments/exporters-full.nix +++ b/sample_environments/exporters-full.nix @@ -4,6 +4,6 @@ }: codedown.makeEnvironment { - exporters.nbconvert-exporters.enable = true; - exporters.nbconvert-exporters.texliveScheme = "scheme-full"; + exporters.nbconvert.enable = true; + exporters.nbconvert.texliveScheme = "scheme-full"; } diff --git a/sample_environments/exporters-small.nix b/sample_environments/exporters-small.nix index 3b8ab21e..70dbe023 100644 --- a/sample_environments/exporters-small.nix +++ b/sample_environments/exporters-small.nix @@ -4,5 +4,5 @@ }: codedown.makeEnvironment { - exporters.nbconvert-exporters.enable = true; + exporters.nbconvert.enable = true; } diff --git a/sample_environments/mega.nix b/sample_environments/mega.nix index 253208f8..f79504db 100644 --- a/sample_environments/mega.nix +++ b/sample_environments/mega.nix @@ -6,6 +6,13 @@ codedown.makeEnvironment { + ### Exporters ### + + exporters.nbconvert.enable = true; + exporters.nbconvert.texliveScheme = "scheme-full"; + + ### Kernels ### + kernels.bash.enable = true; kernels.clojure.enable = true; @@ -56,16 +63,13 @@ codedown.makeEnvironment { kernels.coq.enable = true; - shells.bash.enable = true; - shells.fish.enable = true; - shells.zsh.enable = true; + ### Language servers ### - exporters.nbconvert-exporters.enable = true; - exporters.nbconvert-exporters.texliveScheme = "scheme-full"; + language-servers.spellchecker.enable = true; - # otherPackages = [ - # { channel = "codedown"; attr = "spellchecker"; contents = codedown.spellchecker; } + ### Shells ### - # { channel = "nixpkgs"; attr = "htop"; contents = pkgsStable.htop; } - # ]; + shells.bash.enable = true; + shells.fish.enable = true; + shells.zsh.enable = true; } diff --git a/sample_environments/rust.nix b/sample_environments/rust.nix index 234ad3b5..0b88fafe 100644 --- a/sample_environments/rust.nix +++ b/sample_environments/rust.nix @@ -9,9 +9,7 @@ codedown.makeEnvironment { "rand" { name = "serde"; - settings = { - features = ["derive"]; - }; + features = ["derive"]; } "serde_json" ]; diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 21896b36..00000000 --- a/shell.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ pkgs -, environment -}: - -with pkgs; - -mkShell { - JUPYTER_PATH = "${environment}/lib/codedown"; - - buildInputs = [ - environment - (python3.withPackages (ps: with ps; [jupyter ipython])) - ]; -} diff --git a/tests/.envrc b/tests/.envrc index 7e2a130e..8243ab19 100644 --- a/tests/.envrc +++ b/tests/.envrc @@ -1,2 +1,2 @@ -export NIX_PATH=nixpkgs=$(nix run .#nixpkgsUnstablePath) +export NIX_PATH=nixpkgs=$(nix run .#nixpkgsPath) diff --git a/tests/app/Spec/Tests/Haskell.hs b/tests/app/Spec/Tests/Haskell.hs index 298ba5b4..699ed179 100644 --- a/tests/app/Spec/Tests/Haskell.hs +++ b/tests/app/Spec/Tests/Haskell.hs @@ -30,44 +30,47 @@ tests = do -- haskellCommonTests "haskell-ghc810" -- haskellCommonTests "haskell-ghc90" - haskellCommonTests "haskell-ghc92" - haskellCommonTests "haskell-ghc94" - haskellCommonTests "haskell-ghc96" - haskellCommonTests "haskell-ghc98" + haskellCommonTests "ghc92" + haskellCommonTests "ghc94" + haskellCommonTests "ghc96" + haskellCommonTests "ghc98" +kernelName :: Text -> Text +kernelName _ghcPackage = "haskell" haskellCommonTests :: Text -> LanguageSpec -haskellCommonTests lang = do - describe [i|Haskell #{lang} with hlint output|] $ introduceNixEnvironment [kernelSpecWithHlintOutput lang] [] "Haskell" $ do +haskellCommonTests ghcPackage = do + describe [i|Haskell #{ghcPackage} with hlint output|] $ introduceNixEnvironment [kernelSpecWithHlintOutput ghcPackage] [] "Haskell" $ do describe "Kernel" $ do -- With the setting turned on, we should get hlint output - itHasDisplayTexts lang etaExpandCode [Just (A.Array $ V.fromList [ - String "Line 7: Eta reduce\n" - , String "Found:\n" - , String "baz2 x = baz x\n" - , String "Why not:\n" - , String "baz2 = baz" - ])] + itHasDisplayTexts (kernelName ghcPackage) etaExpandCode [ + Just (A.Array $ V.fromList [ + String "Line 7: Eta reduce\n" + , String "Found:\n" + , String "baz2 x = baz x\n" + , String "Why not:\n" + , String "baz2 = baz" + ])] - describe [i|Haskell #{lang}|] $ introduceNixEnvironment [kernelSpec lang] [] "Haskell" $ do + describe [i|Haskell #{ghcPackage}|] $ introduceNixEnvironment [kernelSpec ghcPackage] [] "Haskell" $ do introduceJupyterRunner $ do - testKernelSearchersNonempty lang - testHasExpectedFields lang + testKernelSearchersNonempty (kernelName ghcPackage) + testHasExpectedFields (kernelName ghcPackage) describe "Kernel" $ do - itHasDisplayDatas lang [__i|putStrLn "hi"|] [M.fromList [(MimeType "text/plain", A.Array (V.fromList [A.String "hi"]))]] + itHasDisplayDatas (kernelName ghcPackage) [__i|putStrLn "hi"|] [M.fromList [(MimeType "text/plain", A.Array (V.fromList [A.String "hi"]))]] - itHasDisplayDatas lang [__i|:info String|] [stringInfo] + itHasDisplayDatas (kernelName ghcPackage) [__i|:info String|] [stringInfo] -- We shouldn't get hlint output by default - itHasDisplayDatas lang etaExpandCode [] + itHasDisplayDatas (kernelName ghcPackage) etaExpandCode [] describe "LSP" $ do codeActionsTests - diagnosticsTests lang lsName + diagnosticsTests ghcPackage lsName documentHighlightTests hoverTests - statementsTests lang + statementsTests ghcPackage symbolsTests diff --git a/tests/app/Spec/Tests/Haskell/Common.hs b/tests/app/Spec/Tests/Haskell/Common.hs index 46ba5136..4aa5871d 100644 --- a/tests/app/Spec/Tests/Haskell/Common.hs +++ b/tests/app/Spec/Tests/Haskell/Common.hs @@ -11,21 +11,22 @@ lsName :: Text lsName = "haskell-language-server" kernelSpec :: Text -> NixKernelSpec -kernelSpec lang = NixKernelSpec { - nixKernelName = lang +kernelSpec ghcPackage = NixKernelSpec { + nixKernelName = "haskell" , nixKernelChannel = "codedown" - , nixKernelDisplayName = Just [i|Haskell (#{lang})|] + , nixKernelDisplayName = Just [i|Haskell (#{ghcPackage})|] , nixKernelPackages = [nameOnly "aeson", nameOnly "bytestring"] , nixKernelMeta = Nothing , nixKernelIcon = Nothing , nixKernelExtraConfig = Just [ - "settings.lsp.haskell-language-server.debug = true" + [i|ghcPackage = "#{ghcPackage}"|] + , "settings.lsp.haskell-language-server.debug = true" -- , "settings.lsp.haskell-language-server.super-debug = true" ] } kernelSpecWithHlintOutput :: Text -> NixKernelSpec -kernelSpecWithHlintOutput lang = (kernelSpec lang) { +kernelSpecWithHlintOutput ghcPackage = (kernelSpec ghcPackage) { nixKernelExtraConfig = Just [ "settings.enableHlintOutput = true" ] diff --git a/tests/app/Spec/Tests/Haskell/Diagnostics.hs b/tests/app/Spec/Tests/Haskell/Diagnostics.hs index ee76d554..5ec8f91f 100644 --- a/tests/app/Spec/Tests/Haskell/Diagnostics.hs +++ b/tests/app/Spec/Tests/Haskell/Diagnostics.hs @@ -19,14 +19,14 @@ import TestLib.NixEnvironmentContext diagnosticsTests :: (LspContext context m) => Text -> Text -> SpecFree context m () -diagnosticsTests lang lsName = describe "Diagnostics" $ do +diagnosticsTests ghcPackage lsName = describe "Diagnostics" $ do describe "Foo.hs" $ do testDiagnosticsLabel "Out of scope variable" lsName "Foo.hs" Nothing [__i|module Foo where foo = bar |] $ \diagnostics -> do assertDiagnosticRanges diagnostics [(Range (Position 1 6) (Position 1 9), Just (InR "-Wdeferred-out-of-scope-variables"))] - when (lang /= "haskell-ghc98") $ -- TODO: re-enable hlint test with haskell-language-server 2.8.0.0 + when (ghcPackage /= "haskell-ghc98") $ -- TODO: re-enable hlint test with haskell-language-server 2.8.0.0 testDiagnosticsLabel "Eta reduce" lsName "Foo.hs" Nothing etaExpandCode $ \diagnostics -> do assertDiagnosticRanges diagnostics [(Range (Position 6 0) (Position 6 14), Just (InR "refact:Eta reduce"))] @@ -77,8 +77,8 @@ etaExpandCode = [__i|module Foo where main :: IO () main = runSandwichWithCommandLineArgs Sandwich.defaultOptions $ - introduceNixEnvironment [kernelSpec lang] [] "Haskell" $ + introduceNixEnvironment [kernelSpec ghcPackage] [] "Haskell" $ introduceJustBubblewrap $ - diagnosticsTests lang HaskellCommon.lsName + diagnosticsTests ghcPackage HaskellCommon.lsName where - lang = "haskell-ghc92" + ghcPackage = "ghc92" diff --git a/tests/app/Spec/Tests/Haskell/DocumentHighlight.hs b/tests/app/Spec/Tests/Haskell/DocumentHighlight.hs index 478d89ec..40a92197 100644 --- a/tests/app/Spec/Tests/Haskell/DocumentHighlight.hs +++ b/tests/app/Spec/Tests/Haskell/DocumentHighlight.hs @@ -49,5 +49,5 @@ documentHighlightCodeRegular = [__i|foo = "hello" -- main :: IO () -- main = runSandwichWithCommandLineArgs Sandwich.defaultOptions $ do --- introduceNixEnvironment [kernelSpec "haskell-ghc92"] [] "Haskell" $ do +-- introduceNixEnvironment [kernelSpec "ghc92"] [] "Haskell" $ do -- documentHighlightTests diff --git a/tests/app/Spec/Tests/Haskell/Statements.hs b/tests/app/Spec/Tests/Haskell/Statements.hs index b796f742..5cc40d2d 100644 --- a/tests/app/Spec/Tests/Haskell/Statements.hs +++ b/tests/app/Spec/Tests/Haskell/Statements.hs @@ -14,13 +14,13 @@ import UnliftIO.Timeout statementsTests :: (LspContext context m) => Text -> SpecFree context m () -statementsTests lang = describe "Statements" $ do +statementsTests ghcPackage = describe "Statements" $ do describe "Single-line" $ do it "doesn't choke" $ doNotebookSession lsName statementsCode $ \filename -> do ident <- openDoc filename "haskell" timeout 120_000_000 (getHighlights ident (Position 0 1)) >>= (`shouldBe` (Just documentHighlightResults)) - when (lang /= "haskell-ghc98") $ -- TODO: re-enable hlint test with haskell-language-server 2.8.0.0 + when (ghcPackage /= "ghc98") $ -- TODO: re-enable hlint test with haskell-language-server 2.8.0.0 testDiagnosticsLabel "Empty diagnostics" lsName "main.ipynb" Nothing statementsCode $ \diagnostics -> do -- Note: normally the server wouldn't send empty diagnostics. But the statement inserts "= unsafePerformIO $ ", -- which causes it to emit a "redundant bracket" diagnostic, which then gets filtered out by untransformPosition @@ -31,7 +31,7 @@ statementsTests lang = describe "Statements" $ do ident <- openDoc filename "haskell" timeout 120_000_000 (getHighlights ident (Position 0 1)) >>= (`shouldBe` (Just documentHighlightResults)) - when (lang /= "haskell-ghc98") $ -- TODO: re-enable hlint test with haskell-language-server 2.8.0.0 + when (ghcPackage /= "ghc98") $ -- TODO: re-enable hlint test with haskell-language-server 2.8.0.0 testDiagnosticsLabel "Redundant bracket" lsName "main.ipynb" Nothing statementsCodeMultiline $ \diagnostics -> do info [i|Got diagnostics: #{diagnostics}|] assertDiagnosticRanges diagnostics [(Range (Position 1 9) (Position 1 14), Just (InR "refact:Redundant bracket"))] diff --git a/tests/app/Spec/Tests/Julia.hs b/tests/app/Spec/Tests/Julia.hs index 7a1e4abf..7e618b5e 100644 --- a/tests/app/Spec/Tests/Julia.hs +++ b/tests/app/Spec/Tests/Julia.hs @@ -22,20 +22,21 @@ import TestLib.Types tests :: LanguageSpec tests = do - juliaTests "julia16" - -- juliaTests "julia18" -- EOL - juliaTests "julia19" - juliaTests "julia110" + juliaTests "julia_19" + juliaTests "julia_110" + +kernelName :: Text -> Text +kernelName _juliaPackage = "julia" juliaTests :: Text -> LanguageSpec -juliaTests lang = describe [i|Julia (#{lang})|] $ introduceNixEnvironment [kernelSpec lang] [] [i|Julia (#{lang})|] $ introduceJupyterRunner $ do - testKernelSearchersNonempty lang - testHasExpectedFields lang +juliaTests juliaPackage = describe [i|Julia (#{juliaPackage})|] $ introduceNixEnvironment [kernelSpec juliaPackage] [] [i|Julia (#{juliaPackage})|] $ introduceJupyterRunner $ do + testKernelSearchersNonempty (kernelName juliaPackage) + testHasExpectedFields (kernelName juliaPackage) - testKernelStdout lang [i|println("hi")|] "hi\n" + testKernelStdout (kernelName juliaPackage) [i|println("hi")|] "hi\n" describe "LSP" $ do - diagnosticsTests lang lsName + diagnosticsTests (kernelName juliaPackage) lsName itHasHoverSatisfying lsName "test.jl" Nothing [__i|print("hi")|] (Position 0 2) $ \hover -> do let InL (MarkupContent MarkupKind_Markdown text) = hover ^. contents @@ -60,10 +61,10 @@ lsName :: Text lsName = "LanguageServer" kernelSpec :: Text -> NixKernelSpec -kernelSpec lang = NixKernelSpec { - nixKernelName = lang +kernelSpec juliaPackage = NixKernelSpec { + nixKernelName = kernelName juliaPackage , nixKernelChannel = "codedown" - , nixKernelDisplayName = Just [i|Julia (#{lang})|] + , nixKernelDisplayName = Just [i|Julia (#{juliaPackage})|] , nixKernelPackages = [ nameOnly "JSON3" , nameOnly "Plots" @@ -75,6 +76,7 @@ kernelSpec lang = NixKernelSpec { "settings.lsp.LanguageServer.enable = true" , "settings.lsp.LanguageServer.debug = true" , "settings.lsp.LanguageServer.index = true" + , [i|juliaPackage = "#{juliaPackage}"|] ] } diff --git a/tests/app/Spec/Tests/Postgres.hs b/tests/app/Spec/Tests/Postgres.hs index 8b1f81a6..074ec82b 100644 --- a/tests/app/Spec/Tests/Postgres.hs +++ b/tests/app/Spec/Tests/Postgres.hs @@ -4,12 +4,16 @@ module Spec.Tests.Postgres (tests) where import Data.Aeson as A +import Data.Function import qualified Data.Map as M import Data.String.Interpolate +import qualified Data.Text as T import qualified Data.Vector as V import Test.Sandwich as Sandwich +import Test.Sandwich.Contexts.Nix (introduceNixContext, nixpkgsReleaseDefault) +import Test.Sandwich.Contexts.PostgreSQL import TestLib.Contexts.PostgresqlData -import TestLib.Contexts.PostgresqlDatabase +import TestLib.Contexts.PostgresqlData () import TestLib.JupyterRunnerContext import TestLib.JupyterTypes import TestLib.NixEnvironmentContext @@ -34,10 +38,11 @@ tests = describe "Postgres tests" $ introduceNixEnvironment [kernelSpec] [] "Pos testKernelSearchersBuild "postgres" testHasExpectedFields "postgres" - introducePostgres Nothing $ introducePostgresData $ do + introduceNixContext nixpkgsReleaseDefault $ introducePostgresViaNix defaultPostgresNixOptions $ introducePostgresData $ do it "selects from test_table" $ do - (_, ctx) <- getContext postgresDb - let connStr = postgresConnString ctx + PostgresContext {..} <- getContext postgres + let connStr = postgresConnString + & T.replace "localhost" "127.0.0.1" info [i|Connection string: #{connStr}|] displayDatasShouldSatisfy "postgres" [__i|-- connection: #{connStr} SELECT * FROM test_table diff --git a/tests/app/Spec/Tests/Ruby.hs b/tests/app/Spec/Tests/Ruby.hs index e20894cd..b10c412d 100644 --- a/tests/app/Spec/Tests/Ruby.hs +++ b/tests/app/Spec/Tests/Ruby.hs @@ -27,20 +27,23 @@ tests = describe "Ruby" $ do kernelTests "ruby_3_3" +kernelName :: Text -> Text +kernelName _rubyPackage = "ruby" + kernelTests :: Text -> LanguageSpec -kernelTests lang = do - describe (T.unpack lang) $ introduceNixEnvironment [kernelSpec lang] [] [i|Ruby (#{lang})|] $ introduceJupyterRunner $ do - testKernelSearchersNonempty lang - testHasExpectedFields lang +kernelTests rubyPackage = do + describe (T.unpack rubyPackage) $ introduceNixEnvironment [kernelSpec rubyPackage] [] [i|Ruby (#{rubyPackage})|] $ introduceJupyterRunner $ do + testKernelSearchersNonempty (kernelName rubyPackage) + testHasExpectedFields (kernelName rubyPackage) - testKernelStdout lang [__i|puts "hi"|] "hi\n" + testKernelStdout (kernelName rubyPackage) [__i|puts "hi"|] "hi\n" - when ("_" `T.isInfixOf` lang) $ do - let versionString = lang + when ("_" `T.isInfixOf` rubyPackage) $ do + let versionString = rubyPackage & T.drop 5 & T.replace "_" "." it [i|The Ruby version contains the string '#{versionString}'|] $ do - testKernelStdout'' lang [__i|puts RUBY_VERSION|] $ \case + testKernelStdout'' (kernelName rubyPackage) [__i|puts RUBY_VERSION|] $ \case Nothing -> expectationFailure [i|Got no stdout|] Just t -> do info [i|RUBY_VERSION result: #{t}|] @@ -52,15 +55,16 @@ kernelTests lang = do text `textShouldContain` "$stdout.puts(obj" kernelSpec :: Text -> NixKernelSpec -kernelSpec lang = NixKernelSpec { - nixKernelName = lang +kernelSpec rubyPackage = NixKernelSpec { + nixKernelName = kernelName rubyPackage , nixKernelChannel = "codedown" - , nixKernelDisplayName = Just [i|Ruby (#{lang})|] + , nixKernelDisplayName = Just [i|Ruby (#{rubyPackage})|] , nixKernelPackages = [] , nixKernelMeta = Nothing , nixKernelIcon = Nothing , nixKernelExtraConfig = Just [ "settings.lsp.solargraph.enable = true" + , [i|rubyPackage = "#{rubyPackage}"|] ] } diff --git a/tests/app/Spec/Tests/Rust.hs b/tests/app/Spec/Tests/Rust.hs index dd4920d8..7cec8b94 100644 --- a/tests/app/Spec/Tests/Rust.hs +++ b/tests/app/Spec/Tests/Rust.hs @@ -17,6 +17,7 @@ import TestLib.NixEnvironmentContext import TestLib.NixTypes import TestLib.TestSearchers import TestLib.Types +import TestLib.Util tests :: LanguageSpec @@ -68,7 +69,7 @@ kernelSpec = NixKernelSpec { , nixKernelPackages = [ nameOnly "rand" - , NameAndSettings "serde" (Just (A.object [("features", A.Array (V.fromList ["derive"]))])) + , NameAndSettings "serde" (Just (aesonFromList [("features", A.Array (V.fromList ["derive"]))])) , nameOnly "serde_json" , nameOnly "serde_derive" ] diff --git a/tests/app/Spec/Tests/SampleEnvironments.hs b/tests/app/Spec/Tests/SampleEnvironments.hs deleted file mode 100644 index 5f9dbf08..00000000 --- a/tests/app/Spec/Tests/SampleEnvironments.hs +++ /dev/null @@ -1,17 +0,0 @@ -{-# OPTIONS_GHC -fno-warn-unused-top-binds #-} - -module Spec.Tests.SampleEnvironments (tests) where - -import Control.Monad.Logger -import Data.String.Interpolate -import Test.Sandwich as Sandwich -import TestLib.TestBuilding - - -tests :: TopSpec -tests = describe "Sample environments farm" $ do - it "builds the sample environments farm" $ do - testBuild' LevelInfo [i|.\#sample_environments_farm|] - -main :: IO () -main = runSandwichWithCommandLineArgs Sandwich.defaultOptions tests diff --git a/tests/app/Spec/Tests/Searchers.hs b/tests/app/Spec/Tests/Searchers.hs index 71b069ac..4a3f633f 100644 --- a/tests/app/Spec/Tests/Searchers.hs +++ b/tests/app/Spec/Tests/Searchers.hs @@ -8,7 +8,7 @@ import TestLib.TestSearchers tests :: TopSpec tests = describe "Searchers" $ do - it "searcher has some results" $ testSearcherHasNonemptyResults ".#codedownSearcher" + it "searcher has some results" $ testSearcherHasNonemptyResults ".#codedown.codedownSearcher" main :: IO () main = runSandwichWithCommandLineArgs Sandwich.defaultOptions tests diff --git a/tests/app/Spec/Tests/Shells/Zsh.hs b/tests/app/Spec/Tests/Shells/Zsh.hs index 918313cd..56b93f73 100644 --- a/tests/app/Spec/Tests/Shells/Zsh.hs +++ b/tests/app/Spec/Tests/Shells/Zsh.hs @@ -3,19 +3,19 @@ module Spec.Tests.Shells.Zsh (tests) where import Data.String.Interpolate +import Data.Text import Test.Sandwich as Sandwich import TestLib.NixEnvironmentContext -import TestLib.NixTypes import TestLib.Types -otherPackages :: [ChannelAndAttr] -otherPackages = [ - channelAndAttr "codedown" "shells.zsh" +otherConfig :: [Text] +otherConfig = [ + "shells.zsh.enable = true;" ] tests :: TopSpec -tests = describe "ZSH" $ introduceNixEnvironment [] otherPackages "ZSH environment" $ do +tests = describe "ZSH" $ introduceNixEnvironment [] otherConfig "ZSH environment" $ do it "can run a command" $ do nixEnv <- getContext nixEnvironment info [i|Got nixEnv: #{nixEnv}|] diff --git a/tests/app/Spec/Tests/Spellchecker.hs b/tests/app/Spec/Tests/Spellchecker.hs index d51e36c7..6f558abc 100644 --- a/tests/app/Spec/Tests/Spellchecker.hs +++ b/tests/app/Spec/Tests/Spellchecker.hs @@ -18,17 +18,16 @@ import Test.Sandwich.Contexts.Waits (waitUntil) import TestLib.JupyterRunnerContext import TestLib.LSP import TestLib.NixEnvironmentContext -import TestLib.NixTypes import UnliftIO.Directory -otherPackages :: [ChannelAndAttr] -otherPackages = [ - channelAndAttr "codedown" "spellchecker" +otherConfig :: [Text] +otherConfig = [ + "language-servers.spellchecker.enable = true;" ] tests :: TopSpec -tests = describe "Spellchecker" $ introduceNixEnvironment [] otherPackages "Spellchecker env" $ introduceJustBubblewrap $ do +tests = describe "Spellchecker" $ introduceNixEnvironment [] otherConfig "Spellchecker env" $ introduceJustBubblewrap $ do it "Gets diagnostics and a working code action" $ do withLspSession' id "spellchecker" "test.md" [i|\# This is mispelled|] [] $ \lspHomeDir -> do ident <- openDoc "test.md" "spellchecker" diff --git a/tests/flake.lock b/tests/flake.lock index 4cfc1c12..364e470e 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -31,27 +31,10 @@ "type": "github" } }, - "nixpkgsUnstable": { - "locked": { - "lastModified": 1721080040, - "narHash": "sha256-USDsS90/88RJibP3gEcH1AaVt+JpnX4XCUD9bAJP5I4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b2c1f10bfbb3f617ea8e8669ac13f3f56ceb2ea2", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "nixpkgsUnstable": "nixpkgsUnstable" + "nixpkgs": "nixpkgs" } } }, diff --git a/tests/flake.nix b/tests/flake.nix index 77797955..0a3f270f 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -1,15 +1,13 @@ { inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-24.05"; - inputs.nixpkgsUnstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, nixpkgsUnstable, flake-utils }@inputs: + outputs = { self, nixpkgs, flake-utils }@inputs: # flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachSystem ["x86_64-linux"] (system: let pkgs = import nixpkgs { inherit system; }; - pkgsUnstable = import nixpkgsUnstable { inherit system; }; tests = pkgs.haskell.packages.ghc965.callPackage ./tests.nix {}; in rec { @@ -18,7 +16,6 @@ inherit (pkgs) cabal2nix; nixpkgsPath = pkgs.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgs.path}"; - nixpkgsUnstablePath = pkgsUnstable.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgsUnstable.path}"; # Print a trivial PATH that we can use to run kernel and LSP tests, to ensure # they aren't depending on anything on the test machine's PATH. diff --git a/tests/package.yaml b/tests/package.yaml index 6fb00729..8838bb68 100644 --- a/tests/package.yaml +++ b/tests/package.yaml @@ -40,7 +40,6 @@ dependencies: - monad-control - mtl - optparse-applicative -- safe - sandwich - sandwich-contexts - string-interpolate @@ -57,22 +56,15 @@ library: - conduit-aeson - data-default - directory - - ex-pool - monad-logger - - network - - postgresql-libpq - postgresql-simple - - process - - random - - retry - row-types - - safe - temporary - unliftio - unliftio-core executables: - tests-exe: + tests: main: Main.hs source-dirs: app ghc-options: @@ -83,6 +75,7 @@ executables: dependencies: - monad-logger - row-types + - safe - tests - unliftio - unliftio-core diff --git a/tests/src/TestLib/Contexts/PostgresqlData.hs b/tests/src/TestLib/Contexts/PostgresqlData.hs index d9bfa668..a98ecb5e 100644 --- a/tests/src/TestLib/Contexts/PostgresqlData.hs +++ b/tests/src/TestLib/Contexts/PostgresqlData.hs @@ -7,20 +7,22 @@ module TestLib.Contexts.PostgresqlData ( import Control.Monad.Catch (MonadMask) import Control.Monad.IO.Unlift import Control.Monad.Trans.Control (MonadBaseControl) -import Data.Pool import Data.String.Interpolate import Data.Text as T +import Data.Text.Encoding import Database.PostgreSQL.Simple import Test.Sandwich -import TestLib.Contexts.PostgresqlDatabase +import Test.Sandwich.Contexts.PostgreSQL +import UnliftIO.Exception introducePostgresData :: ( - HasBaseContext context, MonadMask m, MonadBaseControl IO m, MonadUnliftIO m, HasPostgresDb context + MonadMask m, MonadBaseControl IO m, MonadUnliftIO m + , HasBaseContext context, HasLabel context "postgres" PostgresContext ) => SpecFree context m () -> SpecFree context m () introducePostgresData = before "Postgres data" $ do - (pool, PostgresDatabaseTestContext {}) <- getContext postgresDb - withResource pool $ \conn -> liftIO $ do + PostgresContext {..} <- getContext postgres + liftIO $ bracket (connectPostgreSQL (encodeUtf8 postgresConnString)) close $ \conn -> do _ <- execute_ conn [i|create table test_table (name varchar(40), num smallint)|] affected <- executeMany conn "insert into test_table (name, num) values (?, ?)" [ diff --git a/tests/src/TestLib/Contexts/PostgresqlDatabase.hs b/tests/src/TestLib/Contexts/PostgresqlDatabase.hs deleted file mode 100644 index 00fa21a9..00000000 --- a/tests/src/TestLib/Contexts/PostgresqlDatabase.hs +++ /dev/null @@ -1,218 +0,0 @@ -{-# LANGUAGE GADTs #-} - -module TestLib.Contexts.PostgresqlDatabase ( - introducePostgres - , introducePostgres' - , postgresDb - , HasPostgresDb - - , PostgresDatabaseTestContext (..) - , withPostgresDatabase - - , createPostgresDatabase - , waitForPostgresDatabase - - , postgresConnString - ) where - -import Control.Monad -import Control.Monad.Catch (MonadMask, MonadThrow) -import Control.Monad.IO.Unlift -import Control.Monad.Logger -import Control.Monad.Reader -import Control.Monad.Trans.Control (MonadBaseControl) -import Control.Retry -import Data.Function -import Data.List as L -import Data.Map as M -import Data.Maybe -import Data.Pool -import Data.String.Interpolate -import Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Database.PostgreSQL.LibPQ as LPQ -import qualified Database.PostgreSQL.Simple as PGS -import qualified Database.PostgreSQL.Simple.Internal as PGS -import GHC.Stack -import Network.Socket (PortNumber) -import Safe -import System.Exit -import System.Process -import qualified System.Random as R -import Test.Sandwich -import UnliftIO.Async -import UnliftIO.Concurrent -import UnliftIO.Exception - - --- * Labels - -postgresDb :: Label "postgresDb" (Pool PGS.Connection, PostgresDatabaseTestContext) -postgresDb = Label - -type HasPostgresDb context = HasLabel context "postgresDb" (Pool PGS.Connection, PostgresDatabaseTestContext) - --- * Introduce functions - -introducePostgres :: ( - HasBaseContext context, MonadMask m, MonadBaseControl IO m, MonadUnliftIO m - ) => Maybe Text -> SpecFree (LabelValue "postgresDb" (Pool PGS.Connection, PostgresDatabaseTestContext) :> context) m () -> SpecFree context m () -introducePostgres = introducePostgres' mempty - -introducePostgres' :: (MonadMask m, MonadBaseControl IO m, MonadUnliftIO m, HasBaseContext context) - => Map Text Text -> Maybe Text -> SpecFree (LabelValue "postgresDb" (Pool PGS.Connection, PostgresDatabaseTestContext) :> context) m () -> SpecFree context m () -introducePostgres' labels maybeContainerName = introduceWith "Postgres database" postgresDb $ \cb -> - withPostgresDatabase labels maybeContainerName $ \ctx@(PostgresDatabaseTestContext {..}) -> do - let databaseConfig = PostgresDatabaseConfig { - databaseHostname = postgresDatabaseLocalHostname - , databasePort = postgresDatabaseLocalPort - , databaseUsername = postgresDatabaseUsername - , databasePassword = postgresDatabasePassword - , databaseDatabase = postgresDatabaseDatabase - } - - -- Retry until we connect successfully, since apparently the Docker healthcheck using pg_isready isn't enough - let policy = constantDelay 50000 <> limitRetries 50 - _ <- recoverAll policy (\_ -> liftIO $ PGS.connectPostgreSQL (T.encodeUtf8 $ postgresConnString ctx)) - - withSqlPool 5 databaseConfig $ \(pool, _) -> - void $ cb (pool, ctx) - --- * Implementation - -withPostgresDatabase :: ( - HasCallStack, MonadUnliftIO m, MonadBaseControl IO m, MonadLoggerIO m, MonadMask m, MonadReader context m, HasBaseContext context - ) => Map Text Text -> Maybe Text -> (PostgresDatabaseTestContext -> m a) -> m a -withPostgresDatabase labels maybeContainerName action = do - -- ds <- getDockerState False - - bracket (createPostgresDatabase labels maybeContainerName) - (\(_, _, _, _, _, _containerID, containerName, _networkName) -> timeAction "cleanup Postgres database" $ do - info [i|Doing docker rm -f #{containerName}|] - void $ liftIO $ readCreateProcess (shell [i|docker rm -f #{containerName}|]) "" - -- void $ removeNetwork ds networkName - ) - (\args@(_, _, _, _, _, _, _, _networkName) -> do - ctx <- waitForPostgresDatabase args - -- testInContainer <- liftIO isInContainer - -- let wrapper = if testInContainer then withJoinOwnContainerToNetwork ds networkName else id - -- flip finally (removeNetwork ds networkName) $ - id (action ctx) - ) - -createPostgresDatabase :: ( - HasCallStack, MonadLoggerIO m, MonadUnliftIO m, MonadBaseControl IO m, MonadThrow m, MonadMask m, MonadReader context m, HasBaseContext context - ) => Map Text Text -> Maybe Text -> m (Text, PortNumber, Text, Text, Text, Text, Text, Text) -createPostgresDatabase labels maybeContainerName = timeAction "create Postgres database" $ do - containerName <- maybe (("postgres-" <>) <$> makeUUID' 8) return maybeContainerName - - let localHostname = "127.0.0.1" - let networkName = containerName <> "-network" - liftIO $ void $ readCreateProcess (proc "docker" ["network", "create", T.unpack networkName]) "" - - let password = "foo" - let database = "test" - let username = "test" - -- TODO: use shell escape on this - let labelArgs = [[i|-l #{k}=#{v}|] | (k, v) <- M.toList labels] - let cmd = [iii|docker run -e POSTGRES_PASSWORD=#{password} - -e POSTGRES_USER=#{username} - -p 5432 - #{T.unwords labelArgs} - --network #{networkName} - --health-cmd='pg_isready -U #{username}' - --health-interval=100ms - --name #{containerName} - -d postgres:13|] - - info [i|cmd: #{cmd}|] - (exitCode, sout, serr) <- liftIO $ readCreateProcessWithExitCode (shell $ T.unpack $ replace "\n" " " cmd) "" - - containerID <- case exitCode of - ExitSuccess -> return $ strip $ T.pack sout - _ -> expectationFailure [i|Failed to start Postgres container. Stdout: '#{sout}'. Stderr: '#{serr}'|] - - return (localHostname, 5432, username, password, database, containerID, containerName, networkName) - -waitForPostgresDatabase :: ( - MonadUnliftIO m, MonadBaseControl IO m, MonadLoggerIO m, MonadThrow m - ) => (Text, PortNumber, Text, Text, Text, Text, Text, Text) -> m PostgresDatabaseTestContext -waitForPostgresDatabase (localHostname, dockerPort, username, password, database, containerID, containerName, networkName) = do - rawPort <- (strip . T.pack) <$> (liftIO $ readCreateProcess (shell [i|docker inspect --format='{{index .NetworkSettings.Ports "5432/tcp" 0 "HostPort"}}' #{containerName}|]) "") - let localPort = fromMaybe (error [i|Couldn't read Docker port number: '#{rawPort}'|]) (readMay $ T.unpack rawPort) - - waitForHealth containerID - - let pdtc = PostgresDatabaseTestContext { - postgresDatabaseLocalHostname = localHostname - , postgresDatabaseLocalPort = localPort - , postgresDatabaseUsername = username - , postgresDatabasePassword = password - , postgresDatabaseDatabase = database - , postgresDatabaseDockerPort = dockerPort - , postgresDatabaseDockerNetwork = networkName - , postgresDatabaseContainerName = containerName - } - - -- waitForSimpleQuery pdtc - - return pdtc - - -data PostgresDatabaseTestContext = PostgresDatabaseTestContext { - postgresDatabaseLocalHostname :: Text - , postgresDatabaseLocalPort :: PortNumber - , postgresDatabaseUsername :: Text - , postgresDatabasePassword :: Text - , postgresDatabaseDatabase :: Text - , postgresDatabaseDockerPort :: PortNumber - , postgresDatabaseDockerNetwork :: Text - , postgresDatabaseContainerName :: Text } - deriving (Show, Eq) - -data PostgresDatabaseConfig = PostgresDatabaseConfig { - databaseHostname :: Text - , databasePort :: PortNumber - , databaseUsername :: Text - , databasePassword :: Text - , databaseDatabase :: Text - } deriving (Show, Eq) - -waitForHealth :: forall m. (HasCallStack, MonadLoggerIO m, MonadUnliftIO m, MonadBaseControl IO m, MonadThrow m) => Text -> m () -waitForHealth containerID = race (liftIO $ threadDelay 60_000_000) waitForHealthLoop >>= \case - Left () -> do - info [i|Failed to wait for container #{containerID} to be ready|] - expectationFailure [i|Failed to wait for container to be ready|] - Right () -> return () - where - waitForHealthLoop :: m () - waitForHealthLoop = fix $ \loop -> do - health <- (strip . T.pack) <$> (liftIO $ readCreateProcess (shell [i|docker inspect --format "{{json .State.Health.Status }}" #{containerID}|]) "") - case health of - "\"healthy\"" -> return () - _ -> liftIO (threadDelay 100_000) >> loop - -postgresConnString :: PostgresDatabaseTestContext -> Text -postgresConnString (PostgresDatabaseTestContext {..}) = [i|postgresql://#{postgresDatabaseUsername}:#{postgresDatabasePassword}@#{postgresDatabaseLocalHostname}:#{postgresDatabaseLocalPort}/#{postgresDatabaseDatabase}|] - -uuidLetters :: [Char] -uuidLetters = ['a'..'z'] ++ ['0'..'9'] - -numUUIDLetters :: Int -numUUIDLetters = L.length uuidLetters - -makeUUID' :: MonadIO m => Int -> m Text -makeUUID' n = T.pack <$> (replicateM n ((uuidLetters L.!!) <$> R.randomRIO (0, numUUIDLetters - 1))) - -withSqlPool :: forall m a. (MonadMask m, MonadIO m, MonadUnliftIO m) => Int -> PostgresDatabaseConfig -> ((Pool PGS.Connection, PostgresDatabaseConfig) -> m a) -> m a -withSqlPool n config action = do - bracket (liftIO $ createPool (connectPostgres config) PGS.close 1 30 (fromIntegral n)) - (liftIO . purgePool) - (\pool -> action (pool, config)) - -connectPostgres :: PostgresDatabaseConfig -> IO PGS.Connection -connectPostgres (PostgresDatabaseConfig {..}) = do - let connString = [i|postgresql://#{databaseUsername}:#{unpack databasePassword}@#{databaseHostname}:#{databasePort}/#{databaseDatabase}|] - conn <- PGS.connectPostgreSQL connString - withMVar (PGS.connectionHandle conn) LPQ.disableNoticeReporting - return conn diff --git a/tests/src/TestLib/NixEnvironmentContext.hs b/tests/src/TestLib/NixEnvironmentContext.hs index 13dff8ce..9f15b3ac 100644 --- a/tests/src/TestLib/NixEnvironmentContext.hs +++ b/tests/src/TestLib/NixEnvironmentContext.hs @@ -25,8 +25,13 @@ import UnliftIO.Temporary introduceNixEnvironment :: ( HasBaseContext context, MonadIO m, MonadMask m, MonadUnliftIO m, MonadBaseControl IO m - ) => [NixKernelSpec] -> [ChannelAndAttr] -> Text -> SpecFree (LabelValue "nixEnvironment" FilePath :> context) m () -> SpecFree context m () -introduceNixEnvironment kernels otherPackages label = introduceWith [i|#{label} Nix|] nixEnvironment $ \action -> do + ) + => [NixKernelSpec] + -> [Text] + -> Text + -> SpecFree (LabelValue "nixEnvironment" FilePath :> context) m () + -> SpecFree context m () +introduceNixEnvironment kernels otherConfig label = introduceWith [i|#{label} Nix|] nixEnvironment $ \action -> do rootDir <- findFirstParentMatching (\x -> doesPathExist (x ".git")) metadata :: A.Object <- withFile "/dev/null" WriteMode $ \devNullHandle -> do @@ -49,7 +54,7 @@ introduceNixEnvironment kernels otherPackages label = introduceWith [i|#{label} , lockedToNixSrcSpec "nixpkgs" nixpkgsLocked ] , nixEnvironmentKernels = kernels - , nixEnvironmentOtherPackages = otherPackages + , nixEnvironmentOtherConfig = otherConfig } let rendered = renderNixEnvironment "" nixEnv diff --git a/tests/src/TestLib/NixRendering.hs b/tests/src/TestLib/NixRendering.hs index 59b6e880..b0f31676 100644 --- a/tests/src/TestLib/NixRendering.hs +++ b/tests/src/TestLib/NixRendering.hs @@ -14,9 +14,9 @@ import qualified Data.Vector as V import TestLib.NixTypes #if MIN_VERSION_aeson(2,0,0) -import qualified Data.Aeson.KeyMap as HM +import qualified Data.Aeson.KeyMap as HM #else -import qualified Data.HashMap.Strict as HM +import qualified Data.HashMap.Strict as HM #endif @@ -43,6 +43,8 @@ in (import channels.codedown { inherit fetchFromGitHub; }).makeEnvironment { #{T.intercalate "\n\n" [renderKernel x | x <- nixEnvironmentKernels]} + +#{T.intercalate "\n" [t | t <- nixEnvironmentOtherConfig]} } |] @@ -85,7 +87,7 @@ renderKernel (NixKernelSpec {..}) = xs -> [i|kernels.#{nixKernelName}.packages = [#{T.unwords $ fmap renderKernelPackage xs}];|] renderKernelPackage (NameAndSettings name Nothing) = quote name - renderKernelPackage (NameAndSettings name (Just settings)) = aesonToNix (A.object [("name", A.String name), ("settings", settings)]) + renderKernelPackage (NameAndSettings name (Just settings)) = aesonToNix (A.object (("name", A.String name) : HM.toList settings)) & parenQuote parenQuote x = "(" <> x <> ")" diff --git a/tests/src/TestLib/NixTypes.hs b/tests/src/TestLib/NixTypes.hs index d40c3331..877b5f38 100644 --- a/tests/src/TestLib/NixTypes.hs +++ b/tests/src/TestLib/NixTypes.hs @@ -31,7 +31,7 @@ deriveJSON toSnakeBoth2 ''NixSrcSpec data NameAndSettings = NameAndSettings { nameAndSettingsName :: Text - , nameAndSettingsSettings :: Maybe Value + , nameAndSettingsSettings :: Maybe A.Object } deriving (Show, Eq, Ord) deriveJSON toSnake3 ''NameAndSettings @@ -63,6 +63,6 @@ deriveJSON toSnake2 ''NixKernelSpec data NixEnvironment = NixEnvironment { nixEnvironmentChannels :: [NixSrcSpec] , nixEnvironmentKernels :: [NixKernelSpec] - , nixEnvironmentOtherPackages :: [ChannelAndAttr] + , nixEnvironmentOtherConfig :: [Text] } deriving (Show, Eq, Ord) deriveJSON toSnake2 ''NixEnvironment diff --git a/tests/src/TestLib/Util.hs b/tests/src/TestLib/Util.hs index 486c4a38..e069bb28 100644 --- a/tests/src/TestLib/Util.hs +++ b/tests/src/TestLib/Util.hs @@ -44,3 +44,11 @@ aesonFromList xs = HM.fromList [(A.fromText k, v) | (k, v) <- xs] aesonFromList :: (Eq k, Hashable k) => [(Text, Value)] -> HM.HashMap A.Key v aesonFromList = HM.fromList #endif + +#if MIN_VERSION_aeson(2,0,0) +aesonToList :: HM.KeyMap Value -> [(Text, Value)] +aesonToList m = [(A.toText k, v) | (k, v) <- HM.toList m] +#else +aesonToList :: (Eq k, Hashable k) => HM.HashMap A.Key v -> [(Text, Value)] +aesonToList = HM.toList +#endif diff --git a/tests/tests.cabal b/tests/tests.cabal index 9d35352c..05797461 100644 --- a/tests/tests.cabal +++ b/tests/tests.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0. +-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack @@ -20,7 +20,6 @@ library exposed-modules: TestLib.Aeson TestLib.Contexts.PostgresqlData - TestLib.Contexts.PostgresqlDatabase TestLib.JupyterRunnerContext TestLib.JupyterTypes TestLib.LSP @@ -60,7 +59,6 @@ library , containers , data-default , directory - , ex-pool , exceptions , filepath , lens @@ -69,15 +67,9 @@ library , monad-control , monad-logger , mtl - , network , optparse-applicative - , postgresql-libpq , postgresql-simple - , process - , random - , retry , row-types - , safe , sandwich , sandwich-contexts , string-interpolate @@ -88,7 +80,7 @@ library , vector default-language: Haskell2010 -executable tests-exe +executable tests main-is: Main.hs other-modules: Spec.Tests @@ -118,7 +110,6 @@ executable tests-exe Spec.Tests.Rust.Completion Spec.Tests.Rust.Diagnostics Spec.Tests.Rust.Hovers - Spec.Tests.SampleEnvironments Spec.Tests.Searchers Spec.Tests.Shells.Zsh Spec.Tests.Spellchecker diff --git a/tests/tests.nix b/tests/tests.nix index dc1dadb6..a1820f5e 100644 --- a/tests/tests.nix +++ b/tests/tests.nix @@ -1,10 +1,9 @@ { mkDerivation, aeson, base, bytestring, conduit, conduit-aeson -, containers, data-default, directory, ex-pool, exceptions -, filepath, lens, lib, lsp-test, lsp-types, monad-control -, monad-logger, mtl, network, optparse-applicative -, postgresql-libpq, postgresql-simple, process, random, retry -, row-types, safe, sandwich, string-interpolate, temporary, text -, time, unliftio, unliftio-core, vector +, containers, data-default, directory, exceptions, filepath, lens +, lib, lsp-test, lsp-types, monad-control, monad-logger, mtl +, optparse-applicative, postgresql-simple, row-types, safe +, sandwich, sandwich-contexts, string-interpolate, temporary, text +, unliftio, unliftio-core, vector }: mkDerivation { pname = "tests"; @@ -14,18 +13,18 @@ mkDerivation { isExecutable = true; libraryHaskellDepends = [ aeson base bytestring conduit conduit-aeson containers data-default - directory ex-pool exceptions filepath lens lsp-test lsp-types - monad-control monad-logger mtl network postgresql-libpq - postgresql-simple process random retry row-types safe sandwich - string-interpolate temporary text time unliftio unliftio-core - vector + directory exceptions filepath lens lsp-test lsp-types monad-control + monad-logger mtl optparse-applicative postgresql-simple row-types + sandwich sandwich-contexts string-interpolate temporary text + unliftio unliftio-core vector ]; executableHaskellDepends = [ - aeson base containers exceptions lens lsp-test lsp-types - monad-control monad-logger optparse-applicative safe sandwich - string-interpolate text vector + aeson base containers exceptions filepath lens lsp-test lsp-types + monad-control monad-logger mtl optparse-applicative row-types safe + sandwich sandwich-contexts string-interpolate text unliftio + unliftio-core vector ]; executableToolDepends = [ sandwich ]; license = lib.licenses.bsd3; - mainProgram = "tests-exe"; + mainProgram = "tests"; }