{ config, lib, pkgs, ... }: let inherit (lib) concatLists attrValues mapAttrs filterAttrs mkIf mkDefault mkEnableOption mkOption ; # Languages that only need some packages, ie the lang itself, linters, lsps simple-langs = with pkgs; { # TODO: nixlang c = [ gcc clang clang-tools # clangd cmake ]; # needs deno, which seems to be trying to build v8 # gleam = [ # gleam # erlang # rebar3 # ]; typst = [ typst d2 tinymist ]; # TODO: https://github.com/nushell/nu_scripts/blob/main/custom-completions/cargo/cargo-completions.nu rust = [ cargo clippy bacon rustfmt rust-analyzer rustc ]; zig = [ zig zls zig-shell-completions ]; }; in { # TODO: option for all dev stuff options.spoon.dev = { all = mkEnableOption "all dev stuff"; all-simple-langs = config.lib.spoon.mkDevEnOpt "all simple languages (with `mkDefault` priority)"; simple-langs = mapAttrs (name: _: mkEnableOption "`${name}`") simple-langs; }; # This is to appease the manual generation code. If we don't have it, we can't # use `config.lib.spoon.mkDevEnOpt` to define options. I cannot fathom why # this is the case. options.lib = mkOption { }; config = { # TODO: replace this with `dev-all` option that sets all boolean options under `dev`? lib.spoon.mkDevEnOpt = x: (mkEnableOption x // { default = config.spoon.dev.all; }); spoon.dev.simple-langs = mkIf config.spoon.dev.all-simple-langs <| mapAttrs (_: _: mkDefault true) simple-langs; environment.systemPackages = config.spoon.dev.simple-langs |> filterAttrs (_: en: en) |> mapAttrs (name: _: simple-langs.${name}) |> attrValues |> concatLists; }; } # TODO: persist stuff? # - jj repo config? # - cargo, cabal, npm package caches?