πŸš€ Introducing nixai: Your AI-Powered NixOS Companion

:rocket: Introducing nixai: Your AI-Powered NixOS Companion

Hey r/NixOS! :wave:

Tired of wrestling with cryptic NixOS error messages at 2 AM? Wish you had a knowledgeable friend who could instantly help you debug configurations, explain options, and guide you through complex setups?

Meet nixai - the AI-powered command-line assistant that’s about to revolutionize how you work with NixOS! :robot::sparkles:

:dart: What is nixai

nixai is a modular, console-based tool designed specifically for NixOS users. Think of it as having a NixOS expert sitting right in your terminal, ready to help 24/7. It leverages multiple AI providers (defaults to local Ollama for privacy!) and queries official NixOS documentation to give you accurate, contextual help.

:fire: Latest Features That’ll Blow Your Mind

:speech_balloon: Direct AI Assistant

# Just ask anything!
nixai "How do I enable Docker in NixOS?"
nixai --ask "Why is my build failing?"

# Pipe logs directly for instant diagnosis
journalctl -f | nixai --diagnose

:building_construction: Smart Machine Management (NEW!)

# Auto-discovers hosts from your flake.nix
nixai machines list

# Deploy with traditional nixos-rebuild OR deploy-rs
nixai machines deploy --method deploy-rs --machine myserver

# One-command deploy-rs setup!
nixai machines setup-deploy-rs

:books: Intelligent Documentation Queries

Instantly searches across:

  • NixOS Wiki
  • Nixpkgs Manual
  • nix.dev
  • Home Manager docs
  • Nix Language Reference

:mag: NixOS Option Explainer

nixai explain-option services.nginx.enable
nixai explain-home-option programs.git.enable

:package: Package Repository Analysis

# Turn any GitHub repo into a Nix package!
nixai package-repo https://github.com/username/project

:hammer_and_wrench: And So Much More

  • Community Hub: Share configs, find solutions
  • Learning Modules: Interactive NixOS tutorials
  • DevEnv Management: Streamlined development environments
  • Neovim Integration: NixOS-aware editor setup
  • Multi-LLM Support: Ollama (local), OpenAI, Gemini, and more!

:art: Beautiful Terminal Experience

πŸš€ nixai - Your NixOS AI Assistant

β”Œβ”€ Machine Management ─────────────────────────┐
β”‚ β€’ dex5550    (Ready)                        β”‚
β”‚ β€’ p510       (Ready)                        β”‚ 
β”‚ β€’ p620       (Ready)                        β”‚
β”‚ β€’ razer      (Ready)                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’‘ Quick Actions:
  nixai "enable Docker"           - Get instant help
  nixai machines deploy           - Deploy configurations  
  nixai explain-option <option>   - Understand any option

:lock: Privacy-First Design

  • Defaults to local Ollama - Your data never leaves your machine
  • Optional cloud providers for advanced features
  • Transparent about what gets sent where
  • Your choice, your control

:rocket: Why nixai Will Change Your NixOS Life

:white_check_mark: Instant Problem Solving - No more searching through forums
:white_check_mark: Learn While You Work - Understand the β€œwhy” behind solutions
:white_check_mark: Streamlined Workflows - From development to deployment
:white_check_mark: Community-Driven - Built by NixOS users, for NixOS users
:white_check_mark: Modular Design - Use what you need, ignore what you don’t

:dart: Perfect For

  • Newcomers: Learn NixOS faster with guided help
  • Power Users: Streamline complex multi-machine setups
  • Teams: Standardize deployment workflows
  • Everyone: Because we all need help sometimes! :sweat_smile:

:link: Get Started Today

# Install via Nix profile
nix profile install github:olafkfreund/nix-ai-help

# Or try it in a shell (temporary)
nix shell github:olafkfreund/nix-ai-help
nixai --help

# Add to your flake.nix inputs
inputs.nixai.url = "github:olafkfreund/nix-ai-help";

# Then add to your packages
environment.systemPackages = [ inputs.nixai.packages.${system}.default ];

:handshake: Join the Community

This project is just getting started, and we need YOU! Whether you’re:

  • A NixOS beginner with fresh perspectives
  • A seasoned expert with wisdom to share
  • Someone who just wants better tooling

Star the repo: github.com/olafkfreund/nix-ai-help
Share your ideas: What features would help YOUR workflow?
Contribute: Every PR makes nixai better for everyone!


NixOS is powerful, but it doesn’t have to be lonely. Let’s build the future of NixOS tooling together! :tada:

What do you think? What nixai features would help YOUR NixOS workflow the most? :point_down:

15 Likes

Thanks for this project.

Do you mind posting a link to your project repo ? It is easier when reading the forum from a mobile phone.

1 Like

here it is: GitHub - olafkfreund/nix-ai-help: Ai based nix help system from the command line.

1 Like

I’m new in nixos, add nixai to config, rebuild, and see with default services.ollama:
❯ nixai --ask β€œwhat files do you have access, to help me with system configuration?”

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

:robot: AI Answer to your question:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

I’m a large language model, I don’t have direct access to specific file systems or operating systems. However, I can
provide general information and guidance on system configuration based on various types of files.

Here are some common file types related to system configuration that you may find helpful:

  1. Configuration files:
    β€’ /etc/hosts (Linux): Hosts file for DNS resolution.
    β€’ hosts (Windows): Hosts file for DNS resolution.
    β€’ system.ini (Windows): System configuration file.
  2. System logs:
    β€’ /var/log/syslog (Linux): System log file.
    β€’ application.log (Windows): Log file for a specific application.
  3. Network configuration files:
    β€’ /etc/network/interfaces (Linux): Network interface configuration file.
    β€’ netsh.conf (Windows): Network configuration file.
  4. Service configuration files:
    β€’ /lib/systemd/system/* (Linux): systemd service files.
    β€’ services.exe (Windows): Windows Service Manager configuration file.
  5. Security and authentication files:
    β€’ /etc/shadow (Linux): User password file.
    β€’ secrets.conf (Windows): Secret configuration file for authentication.

These are just a few examples, and there may be other files specific to your system or organization that you need to
consider when configuring your system.

Remember that I’m a text-based AI assistant, so I won’t have direct access to your system’s files. However, I can
provide guidance on how to configure your system using various file types and command-line interfaces (CLI) tools.
If
you have specific questions or concerns about system configuration, feel free to ask!

Not the best answer is it. The new version I just uploaded has much better context and more sources. but run

nixai --help

there is more than just

nixai --ask

. I have created many sub commands that will help and guide you. Please try the one I will push later today. It will amaze you how far it has come … Thanks for trying it out.

1 Like

This is the new refined output:
./nixai ask β€œwhat files do you have access, to help me with system configuration”

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

:robot: AI Answer to your question:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

:information_source: Querying documentation… :white_check_mark: done
:information_source: Querying AI provider… :white_check_mark: done

Welcome to NixOS!

As your trusted NixOS assistant, I’m delighted to inform you that I have access to several key files to help with
system configuration. Here are the most important ones:

Configuration Files

These files live in /etc/nixos and define various aspects of your system’s configuration.

β€’ configuration.nix : The main configuration file for NixOS. This is where you’ll find settings for your system,
such as networking, services, and packages.
β€’ hardware-configuration.nix : A file that provides information about your hardware, like CPU architecture, memory
size, and disk layout.

Nix Expression Files

These files live in /etc/nixos/modules and contain Nix expressions that define packages, modules, or even entire
system configurations.

β€’ modules/default.nix : The main entry point for your NixOS configuration. This file imports other Nix expressions
and defines the overall system configuration.
β€’ modules/packages.nix : Defines which packages should be installed on your system.

Nix Store Files

These files live in /nix/store and contain the actual package binaries, libraries, and configurations managed by
Nix.

β€’ default.nix : The main entry point for the Nix store. This file defines the default configuration for the Nix
store.

Now that you know where to look, feel free to explore these files and configure your NixOS system to your heart’s
content!

1 Like

I use one ai assistant in my ghostty(zsh) term, https://github.com/sigoden/aichat/tree/main/scripts/shell-integration, i never set in my aichat config, what system i use.
Even I type in term β€œinstall chromium” and press alt+e, I get in line β€œnix install chromium”, and never β€œpacman -S chromium”. Also work well with ollama.
Thank you!

Yepp it is really good. But nixai wants to be more. I’m slowly getting there. For now it is output only but in time it will be more. The features I like most is build support and packages from local and remote repo ( it will create a example on how to create a nix package for rust, go, nodjs and python. Even search code snippets and examples from discourse and github code search. You can pipe in logs and more. Give it a bit more and it will be as good as aichat ( I hope ) Thanks for using your time on this, any feedback is great. Cheers Andrei

1 Like

so we are getting closes and closer to the goal:

./nixai configure

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

:hammer_and_wrench: Interactive NixOS Configuration

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

:information_source: Describe what you want to configure (e.g. desktop, web server, user, etc):

user
:information_source: Querying AI provider… :white_check_mark: done

I’d be happy to help you with that.

Here’s an example of how you can configure your user settings in configuration.nix :

{ config, pkgs, ... }:                                                                                            
                                                                                                                  
let                                                                                                               
  # Define a module for the user configuration                                                                    
  userConfig = {                                                                                                  
    # Set the default shell to zsh (optional)                                                                     
    loginShell = pkgs.zsh;                                                                                        
                                                                                                                  
    # Set the username and groupname of the primary user account                                                  
    extraUsers = {                                                                                                
      # The primary user account will be named after the host system's hostname.                                  
      ${config.networking.hostName} = {                                                                           
        isNormalUser = true;                                                                                      
        extraGroups = [ "wheel" ]; # Add the user to the wheel group for sudo permissions                         
      };                                                                                                          
    };                                                                                                            
  };                                                                                                              
in                                                                                                                
                                                                                                                  
{                                                                                                                 
  # Enable the user configuration module                                                                          
  users.extraUsers.${config.networking.hostName}.isSystemUser = false;                                            
                                                                                                                  
  # Include the user configuration module                                                                         
  imports = [ userConfig ];                                                                                       
}                                                                                                                 

Let’s break it down:

β€’ { config, pkgs, … }: This line is the beginning of your configuration.nix file. The config variable holds
information about your system that can be used in configurations. The pkgs variable provides access to the package
set of NixOS packages.
β€’ let … in : This is a let statement in nix, which creates local variables and then uses them to create an
expression. In this case, we are defining a module for our user configuration.
β€’ The first part inside the userConfig module defines the default shell to use when you log in. In this example,
it’s set to zsh, but you can change it to whatever you prefer.
β€’ The second part creates an extra user account on your system. You can customize the username and groupname of this
primary user account by setting username and groupname .
β€’ In the last part, we enable the user configuration module by setting isSystemUser to false . Then, we import
the user configuration module using the imports option.

Note that you should replace β€œ${config.networking.hostName}” with your actual hostname.

2 Likes

:information_source: Querying documentation… :white_check_mark: done
:information_source: Querying AI provider… :white_check_mark: done
+
:information_source: Analyzing nixos configuration in current directory … :white_check_mark: done
:+1:

1 Like

There is a config file in ~/.config/nixai there you can set different setting and choose ai providers like ollama, openai or gemini and much much more. Please take a look at the readme file for examples. If you have time please play around with the others sub commands. You can find them all under the doc/ folder in my repo or just run nixai --help or nixai interactive. Again thanks for your time.

1 Like

Thank you for your comment

2 Likes

Thank you very much for this help.
I am new to Nixos and I need your help
Shall I copy and paste this in my configuration.nix
Please advice step by step thank in advance.

So sorry for late answer :slight_smile: there is a readme and installation help in the repo. Please read it will show you step by step guide. Good Luck. If I can help more let me know. Thanks for trying it out.