Skip to content
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

Document minimal config files #1310

Merged
merged 4 commits into from
Mar 26, 2024
Merged

Document minimal config files #1310

merged 4 commits into from
Mar 26, 2024

Conversation

texastoland
Copy link
Contributor

@texastoland texastoland commented Mar 23, 2024

3 New "Tips"

  • Minimal configs vs starting from defaults
  • std path add to simplify editing the system path
  • set-env from nu_scripts to simplify editing nested configs

Additional Amendments:

  • Explained more concretely why env.nu vs config.nu
  • Explained why upsert is necessary
  • Reworded the editors section and removed parts about old Nu versions
  • Brief note about config.nu not loading non-interactively
  • Simplify nuopen command to alias
  • Reformatted $env.PATH snippet more conventionally
  • Changed 2 heading levels to improve TOC
  • Extra links in general

@fdncred
Copy link
Collaborator

fdncred commented Mar 23, 2024

I'm not sure I'd recommend set-env in our official docs when it's not officially a part of nushell yet.

@texastoland
Copy link
Contributor Author

texastoland commented Mar 23, 2024

Yeah that's why I didn't imply it's standard in any way. Just makes a day 1 tricky task easier. I have no reservation about removing that block regardless!

Pasting here in case we ever add it back:

::: tip
Try downloading the [`set-env`](https://github.com/nushell/nu_scripts/blob/main/stdlib-candidate/std-rfc/set-env.nu) command in order to _merge_ nested `$env` values at any depth:

```nu
set-env config.<field name> <field value>
```

You can optionally `--append` list settings such as [hooks](/book/hooks.md).
:::

@fdncred
Copy link
Collaborator

fdncred commented Mar 23, 2024

I'm fine with path add since it's in the stdlib, just not set-env since it's not there yet. Maybe you just deleted the wrong one?

@texastoland
Copy link
Contributor Author

My bad fixed 🙉

@texastoland
Copy link
Contributor Author

texastoland commented Mar 23, 2024

@fdncred I added 2 infra lines to enable my live preview in the description:

+const [ciUser, ciRepo] = process.env.GITHUB_REPOSITORY?.split('/') ?? []

 export default defineUserConfig({
+  base: ciRepo && ciUser !== 'nushell' ? `/${ciRepo}/` : '/',
  1. Get the user and repo from the GitHub action (or else undefined)
  2. If there's a fork it changes the base URL otherwise (nushell org and local build) it uses the default

@fdncred
Copy link
Collaborator

fdncred commented Mar 23, 2024

to enable my live preview in the description

I'd guess this isn't a good idea because it's specific to your environment and no one else's.

@texastoland
Copy link
Contributor Author

You can try it in your own fork by enabling actions there 💯

@fdncred
Copy link
Collaborator

fdncred commented Mar 23, 2024

Are you saying this is a github thing or something specific to your env vars?

@texastoland
Copy link
Contributor Author

texastoland commented Mar 24, 2024

Added comments for maintenance:

+// default env from the deploy GitHub action
+// e.g. ciUser = nushell and ciRepo = nushell.github.io
+// both default to undefined if the env is undefined
 const [ciUser, ciRepo] = process.env.GITHUB_REPOSITORY?.split('/') ?? []

 export default defineUserConfig({
+  // set the base URL to ciRepo dir if it's a fork
+  // keep the default root if not
   base: ciRepo && ciUser !== 'nushell' ? `/${ciRepo}/` : '/',

Also in CONTRIBUTING.md:

## Enabling a Preview URL From Your Fork

Just enable GitHub actions in your repo settings. That's all! It will start deploying the next time you push to `main`.

@fdncred fdncred merged commit 959847c into nushell:main Mar 26, 2024
2 checks passed
@fdncred
Copy link
Collaborator

fdncred commented Mar 26, 2024

ok, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants