nushell: add autoload scripts option - #9739
Open
gamemaster2b wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Home Manager option to support Nushell autoload scripts, allowing users to include .nu files at startup either by referencing relative paths or by providing inline script content.
Changes:
- Introduces
programs.nushell.autoloadas a list accepting either relative.nupaths or{ name, content }script objects. - Extends
home.filegeneration to populate${cfg.configDir}/autoload/with the configured scripts.
Comments suppressed due to low confidence (1)
modules/programs/nushell.nix:372
- The
assertexpression is syntactically invalid in Nix (assert <cond>; <expr>), so this module will fail to evaluate. Also, reading the script files withbuiltins.readFilecontradicts the option doc claiming symlinking, and forces evaluation-time reads that can be avoided by usinghome.file.<name>.sourcefor path inputs.
assert (
builtins.match ".*\\.nu$" (toString fileName) != null
) "ensure the file name has the extension '.nu'; your current file name is ${fileName}";
{
"${cfg.configDir}/autoload/${fileName}".text = content;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+252
to
+256
| description = '' | ||
| This files are loaded by nushell at startup. | ||
|
|
||
| The files are symlinked onto the "${cfg.configDir}/autoload/" folder | ||
| ''; |
| types.submodule { | ||
| options = { | ||
| name = lib.mkOption { | ||
| type = types.strMatching "^[^/\\]+\\.nu$"; |
gamemaster2b
marked this pull request as draft
July 29, 2026 14:46
Add a new 'programs.nushell.autoload' option for loading '.nu' files at startup from relative paths or inline content.
gamemaster2b
force-pushed
the
nushell-autoload
branch
from
July 29, 2026 15:12
36129db to
744efad
Compare
gamemaster2b
marked this pull request as ready for review
July 29, 2026 15:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a new 'programs.nushell.autoload' option for loading '.nu' files at startup from relative paths or inline content.
This options should used by other modules for their nushell intergrations.
I thought to add this upon seeing this is how devenv@2.2.x recommends intergrating with nushell
Checklist
Change is backwards compatible.
Code formatted with
nix fmtornix-shell -A dev --run treefmt.Code tested through
nix run .#tests -- test-nushell.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
If this PR adds an exciting new feature or contains a breaking change.