-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] RFC 3: languages #28
base: main
Are you sure you want to change the base?
Changes from all commits
1d4305f
3664ced
7849464
d8a296e
8828615
b51b332
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,192 @@ | ||||||
--- | ||||||
feature: tools-and-programming-languages | ||||||
start-date: 2021-04-30 | ||||||
author: Shahrukh Khan | ||||||
related-issues: None | ||||||
--- | ||||||
|
||||||
# Summary | ||||||
[summary]: #summary | ||||||
|
||||||
This RFC describes how tools and programming languages support is to be | ||||||
implemented in Soxin. This breaks down in two areas: | ||||||
|
||||||
* How languages are defined, i-e how to define the language and its properties | ||||||
i-e its compiler, tools, editor plugins etc. How the user can define the | ||||||
default plugins for a language in their editor(s). | ||||||
* How the user can select default set of languages and its required tools in | ||||||
their editor, and how to override default settings per-editor. | ||||||
|
||||||
# Motivation | ||||||
[motivation]: #motivation | ||||||
|
||||||
As Soxin is aimed at providing its users with easy-to-configure software, while | ||||||
allowing for great customization, an RFC describing how such an important | ||||||
feature integrates with the project was needed. | ||||||
|
||||||
# Detailed design | ||||||
[design]: #detailed-design | ||||||
|
||||||
## Language definition | ||||||
|
||||||
Languages would be defined in a module named `soxin.programmingLanguagesModules`. | ||||||
Each language, would be an attribute set in this module: | ||||||
|
||||||
``` | ||||||
soxin.programmingLanguagesModules = { | ||||||
go = { /* ... */ }; | ||||||
java = { /* ... */ }; | ||||||
python = { /* ... */ }; | ||||||
Comment on lines
+37
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would these attribute contain? |
||||||
} | ||||||
``` | ||||||
## Tools defination | ||||||
|
||||||
Programming tools will be defined in a module named `soxin.toolsModules`. | ||||||
Each tool will be an attribute set in this module. | ||||||
|
||||||
``` | ||||||
soxin.toolsModules = { | ||||||
git = { /* ... */ }; | ||||||
tmux = { /* ... */ }; | ||||||
Comment on lines
+49
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would these attribute contain? |
||||||
} | ||||||
``` | ||||||
This allows Soxin to define its own support for languages and tools, while | ||||||
allowing room for user customization as well. | ||||||
|
||||||
Similar to RFC 2, each programming language must include a key for each editor | ||||||
which will support that language. For instance, it could be a plugin for that | ||||||
editor that installs support for that language, plus some extra configuration | ||||||
to configure that plugin. | ||||||
|
||||||
## User interaction | ||||||
|
||||||
### Globally | ||||||
|
||||||
Similar to RFC 2, a `soxin.settings.programmingLanguages` and | ||||||
`soxin.settings.tools` option would be introduced to allow the user | ||||||
to choose their programming stack. The only permitted values here shall be the | ||||||
defined in `config.soxin.<programmingLanguages/tools>`. This option shall be of type | ||||||
`Array` of `str`, with apply function which iterate over the array and find | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
appropriate languages or tools. | ||||||
|
||||||
### Per-program | ||||||
|
||||||
Each program that supports a language must provide a | ||||||
`soxin.programs.<program-name>.programmingLanguages` and | ||||||
`soxin.programs.<program-name>.tools` option to allow the user to | ||||||
override the programming language stack and tools settings per program. These options will default | ||||||
to `config.soxin.settings.<programmingLanguages/tools>`, and thus will be of type `listOf` | ||||||
`attrs`. Similar to RFC 2, they will also have will also allow `str` and have | ||||||
an `apply` function that will lookup the programmingLanguage/tools config from `config.soxin.<programmingLanguages/tools>` | ||||||
for each option. | ||||||
|
||||||
# Examples and Interactions | ||||||
[examples-and-interactions]: #examples-and-interactions | ||||||
|
||||||
Here's how one could define a language and a tool implementing only the `neovim` | ||||||
editor: | ||||||
|
||||||
``` | ||||||
# ProgrammingLanguages | ||||||
|
||||||
{ mode, config, pkgs, lib, soxin, ... }: | ||||||
|
||||||
with lib; | ||||||
{ | ||||||
config.soxin.programmingLanguagesModules.go = (mkMerge [ | ||||||
{ | ||||||
neovim = { | ||||||
plugins = [ pkgs.neovim.go ]; | ||||||
extraRC = '' | ||||||
''; | ||||||
}; | ||||||
} | ||||||
|
||||||
/*(optionalAttrs (mode == "home-manager") { | ||||||
programs.go = { | ||||||
enable = true; | ||||||
}; | ||||||
})*/ | ||||||
]); | ||||||
} | ||||||
|
||||||
#tools | ||||||
{ mode, config, pkgs, lib, soxin, ... }: | ||||||
|
||||||
with lib; | ||||||
{ | ||||||
config.soxin.toolsModules.git = (mkMerge [ | ||||||
{ | ||||||
neovim = { | ||||||
plugins = [ pkgs.neovim.fugitive ]; | ||||||
extraRc = '' | ||||||
''; | ||||||
}; | ||||||
} | ||||||
|
||||||
/*(optionalAttrs (mode == "home-manager") { | ||||||
programs.go = { | ||||||
enable = true; | ||||||
}; | ||||||
})*/ | ||||||
]); | ||||||
} | ||||||
``` | ||||||
|
||||||
Here's how this would be implemented on the editor side: | ||||||
|
||||||
``` | ||||||
{ mode, config, pkgs, lib, soxin, ... }: | ||||||
|
||||||
with lib; | ||||||
let | ||||||
cfg = config.soxin.programs.neovim; | ||||||
in | ||||||
{ | ||||||
options = { | ||||||
soxin.programs.neovim = soxin.lib.mkSoxinModule { | ||||||
inherit config; | ||||||
name = "neovim"; | ||||||
includeProgrammingLanguages = true; | ||||||
includeTools = true; | ||||||
}; | ||||||
}; | ||||||
|
||||||
config = mkIf cfg.enable (mkMerge [ | ||||||
(optionalAttrs (mode == "home-manager") { | ||||||
programs.neovim = mkMerge [ | ||||||
{ inherit (cfg) enable; } | ||||||
|
||||||
{ | ||||||
plugins = flatten (map | ||||||
(v: | ||||||
v.extensions | ||||||
) | ||||||
cfg.programmingLanguages ++ cfg.tools); | ||||||
} | ||||||
|
||||||
]; | ||||||
}) | ||||||
]); | ||||||
} | ||||||
``` | ||||||
|
||||||
The options of the `programs.neovim` have been modified for simplicity's sake. | ||||||
|
||||||
|
||||||
# Drawbacks | ||||||
[drawbacks]: #drawbacks | ||||||
Comment on lines
+177
to
+178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One drawback I might add, is that we might not make the difference between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a definition section at the top of the RFC to explain this? My 2cents: go is a language but gorename is not, it's a tool. Go like any other language may also enable one or more tools. |
||||||
|
||||||
Adds additional layer of segregation between `soxin.programs` and | ||||||
`soxin.tools`. Which will require Soxin developers to be cognizant | ||||||
about where to add a new language or a tool, thus adding additional layer of | ||||||
complexity. | ||||||
|
||||||
# Alternatives | ||||||
[alternatives]: #alternatives | ||||||
|
||||||
|
||||||
# Unresolved questions | ||||||
[unresolved]: #unresolved-questions | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples are more appropriate in the
Example
section of the RFC.