# Nushell Config System ideas ## Introduction The `config.nu` file is located in the normal place but it behaves differently and has different contents. The common thread in the first two examples is that the `config.nu` file is a json file that gets loaded by the json routines. This way, we don't require nushell to parse everything all at once. Essentially, we load a file that has a list of files to then have nushell load. Then we iterate through those files and do the normal nushell parsing, one file at a time. This allows files to be dependent on each of the other files that were loaded before the current file. ### Option 1 The config.nu is really a json file so we could load it with our json routines. Now that we have it in memory, we can iterate through the config entries and parse/load them one at a time. config.nu file contents ```json { "personal_login_nu": '/some/fully/qualified/path/to/some_login.nu', "personal_env_nu": '/some/fully/qualified/path/to/some_env.nu', "personal_config_nu": '/some/fully/qualified/path/to/some_config.nu', } ``` I'm not really sure if the key/value scenario here is helpful. The "personal_blah_nu" don't really server a purpose at the moment. ### Option 2 Same thing different format. The config.nu is really a json file so we could load it with our json routines. Now that we have it in memory, we can iterate through the config entries and parse/load them one at a time. If we use the hjson stuff, the json file can have comments. config.nu file contents ```json { // This idea isn't fully formed but the thought is that login.nu, env.nu, and config.nu locations are read-only, just as they are today. They get loaded as they are today. So, these could just be the defaul_config.nu and default_env.nu. Then the files under it, in this file, get loaded based on the index // login.nu gets loaded first // env.nu gets loaded second // config.nu gets loaded third "1": '/path/to/file/to/load/first/file.nu', "2": '/path/to/file/to/load/first/some_file.nu', "3": '/path/to/file/to/load/first/another_file.nu', "4": '/path/to/file/to/load/first/a_file.nu', "5": '/path/to/a/folder/', // When a folder is found, all the *.nu files get loaded in filesystem io order } ``` ### Option 3 The config.nu file is really just a text file. File can have comments like `//` or `#` or whatever we want the comment to be. config.txt file contents ```text // login.nu gets loaded first // env.nu gets loaded second // config.nu gets loaded third // can have file and folders in this file /path/to/filea.nu // folder expects files inside of it to be named with a numerical sequence and underscore like 1_file.nu in order to load files in a particular order. /path/to/folder1/', ``` folder1 contents ``` /path/to/folder1 1_file.nu 2_file.nu 3_file.nu 4_file.nu ``` ### Option 4 Similar to Option 1, but: * use nuon (similar to json, not much of a difference...) * files are in a list => explicit ordering * this might be a bit similar to the config.toml we used to have before but using nuon ### Option 5 Using Nu language, building on top of the current approach. WIP ideas: https://hackmd.io/@nucore/BJpziLNsj Requires language additions, but * we enable patterns that can be used in other Nu projects (e.g., if a user want a config system in their application, they can use the Nushell's pattern). * the language additions will be useful in maby other scenarios (e.g., module as a directory) ## Voting Just a strawman vote of which direction you'd like to see. Other options are definitely options, feel free to write in and edit this doc. 1 = option 1 2 = option 2 3 = option 3 4 = option 4 5 = option 5 -1 = combination -2 = something different than these ___ Andres ___ Fernando (elferherrera) _3_ Darren (fdncred) ___ Justin (hustcer) ___ JT _5(4)_ Jakub (kubouch) _3_ Michael (stormasm) ___ Reilly (rgwood) ___ Stefan (sholderbach) ___ Keith (windsoilder) _3_ Devyn (devyn) _5 or 3_ Ian (IanManske) ## Reference Open Issues * [Split up default config.nu file #4662](https://github.com/nushell/nushell/issues/4662) * [Refactor the default configuration #7371](https://github.com/nushell/nushell/issues/7371)