Skip to content

nushell: add autoload scripts option - #9739

Open
gamemaster2b wants to merge 1 commit into
nix-community:masterfrom
gamemaster2b:nushell-autoload
Open

nushell: add autoload scripts option#9739
gamemaster2b wants to merge 1 commit into
nix-community:masterfrom
gamemaster2b:nushell-autoload

Conversation

@gamemaster2b

@gamemaster2b gamemaster2b commented Jul 29, 2026

Copy link
Copy Markdown

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 fmt or
    nix-shell -A dev --run treefmt.

  • Code tested through nix run .#tests -- test-nushell.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

Copilot AI review requested due to automatic review settings July 29, 2026 14:37
@github-actions github-actions Bot added the shell label Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.autoload as a list accepting either relative .nu paths or { name, content } script objects.
  • Extends home.file generation to populate ${cfg.configDir}/autoload/ with the configured scripts.
Comments suppressed due to low confidence (1)

modules/programs/nushell.nix:372

  • The assert expression is syntactically invalid in Nix (assert <cond>; <expr>), so this module will fail to evaluate. Also, reading the script files with builtins.readFile contradicts the option doc claiming symlinking, and forces evaluation-time reads that can be avoided by using home.file.<name>.source for 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
'';
Comment thread modules/programs/nushell.nix Outdated
types.submodule {
options = {
name = lib.mkOption {
type = types.strMatching "^[^/\\]+\\.nu$";
@gamemaster2b
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
gamemaster2b marked this pull request as ready for review July 29, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants