# nixos integration inshellah provides a nixos module that indexes nushell completions for every installed package at system build time, and a wrapped binary that knows where to find the result. ## enabling ```nix # flake.nix outputs: { nixosConfigurations.myhost = nixpkgs.lib.nixosSystem { modules = [ inshellah.nixosModules.default { programs.inshellah.enable = true; } ]; }; } ``` or importing directly: ```nix # configuration.nix { pkgs, ... }: { imports = [ ./path/to/inshellah-rs/nix/module.nix ]; programs.inshellah.enable = true; } ``` after rebuilding, completions are immediately available — no extra nushell config needed if you paste in the snippet (see below). ## what the module does - installs the inshellah binary, wrapped so the system completion path is found automatically. - runs `inshellah index "$out"` during the system profile build, producing one file per command under `$out/share/inshellah/`. - drops a nushell autoload shim into `/share/nushell/vendor/autoload/` that overrides nushell's hard-coded sudo/doas bypass so completions fire through inshellah even for elevated commands. - exposes a `snippet` option carrying the full external-completer config — see "using the completer" below. ## module options ```nix programs.inshellah = { enable = true; # the inshellah package (set automatically by the flake module) package = pkgs.inshellah; # subdirectory of the system profile holding the index files # default: "/share/inshellah" completionsPath = "/share/inshellah"; # additional read-only completion directories to search extraDirs = [ "/etc/profiles/per-user/alice/share/inshellah" ]; # commands to skip entirely during indexing ignoreCommands = [ "problematic-tool" ]; # commands to skip manpage parsing for (uses --help instead) helpOnlyCommands = [ "nix" ]; # per-subprocess timeout in ms during indexing (null = built-in # default of 200ms) timeoutMs = null; # worker-thread count for the parallel scrape workers = null; }; ``` ## using the completer the module's `snippet` option holds a complete external-completer config. drop it into nushell: ```nix # generate a config file from the snippet environment.etc."nushell/inshellah.nu".text = config.programs.inshellah.snippet; ``` then in your nushell config: ```nu source /etc/nushell/inshellah.nu ``` or copy the snippet directly into `~/.config/nushell/config.nu` if you prefer to manage it by hand: ```nu # (the snippet is many lines — copy it from `nix eval` of the option, # or use the environment.etc approach above) $env.config.completions.external = { ... } ``` the snippet provides both static lookups against the system index and runtime fallbacks for cases the static index can't cover: | command | dynamic source | |---|---| | `nix` | flake refs via `NIX_GET_COMPLETIONS`, with optional `meta.description` | | `systemctl` / `journalctl` | unit names from `list-units` | | `coredumpctl` | units + pids | | `loginctl` | users / sessions | | `machinectl` / `networkctl` | machines / links | | `ssh` / `scp` / `sftp` | hostnames from ssh config + known_hosts | | `docker` / `podman` | containers + image refs by subcommand | | `kubectl` | resource names from the live cluster | | `git` | refs + worktree paths | | `npm` / `pnpm` / `yarn` | scripts from package.json | | `make` / `just` | targets / recipes | | `cargo` | workspace targets behind `--bin` / `--example` / etc. | | `kill` / `pkill` | pid+comm pairs | ## home manager and user-level package managers the system module only indexes packages installed system-wide. for home-manager or per-user nix profiles, run `inshellah index` against those prefixes separately: ```sh # home-manager / per-user profile inshellah index /etc/profiles/per-user/$USER # classic nix-env profile inshellah index ~/.nix-profile ``` this indexes into `$XDG_CACHE_HOME/inshellah`, which the completer searches automatically. to automate via home-manager: ```nix home.activation.inshellah-index = lib.hm.dag.entryAfter [ "writeBoundary" ] '' ${pkgs.inshellah}/bin/inshellah index /etc/profiles/per-user/$USER 2>/dev/null || true ''; ``` ## troubleshooting **completions not appearing**: check that the system index exists (`ls /run/current-system/sw/share/inshellah/`) and that the completer is configured. **missing completions for a specific command**: check if it's a nushell built-in (`help commands | where name == "thecommand"`) — built-ins are excluded. **stale completions after update**: the index regenerates on every `nixos-rebuild`. if a command changed its flags, rebuild. **build-time errors**: indexing failures are non-fatal. check `journalctl` for the build log if completions are missing for a specific command.