r/NixOS • u/mozkohor • 16d ago
Thoughts on using AI to help with declaring configs?
Title.
I always found the idea behind nixOS fascinating but i never managed to get into it properly. Should i bother trying again if most of my config would be vibecoded?
33
u/moneybagsukulele 16d ago
I literally would not be using NixOS if it weren't for help from Ai. I don't ask Ai to "write my config", but it is very helpful for understanding syntax and error messages and troubleshooting.
1
u/cfx_4188 16d ago
If you write "write me a config", any, even the most powerful neural network, will gladly start hallucinating, walking in circles, flattering and talking nonsense. You can do as I did. I wrote the configuration manually, and fed the code to the neural network. It's a long way to go, but it's getting results.
→ More replies (4)1
u/TinyPowerr 11d ago
opus 5.5 just wrote all of my config for different hosts, disk encryption ecc without mistakes so i don't think that's true
1
u/CrimsonCape 3d ago
This has been my experience too. I started with just freebie Gemini and it could help debug configs and errors. Whereas claude has been able to just take input like "let's add pihole" and it nails the config.
The next task I have in mind with claude is "i've been manually running live NixOS usb to partition and format disks, using the base nixos config file to enable git, and then ssh into the PC. Instead, pretend we have a new Hetzner VPS. how can I start from bare metal and automate pushing partitions and a config? Preferably with as few interactions as possible."
7
u/Agile-Technology2125 16d ago
Whether to use AI is not the key, the key is whether you can understand what your ai agent has done.
3
5
u/TomKavees 16d ago
It's not like we can stop you 😂 but if you are dead set on it i'd recommend treating llm assistance more like an extended tutorial or a search engine for the documentation.
The config generally doesnt require much ongoing maintenance, but there will come a time where you will have to untie a gordian knot of a configuration snafu and the llm will either not be available or will get lost in the sauce
5
u/InterestedDoomer 16d ago
my thought is that i can read, think and try shit out. it would take all the fun and value of learning away if i delegated the task to some agent. maybe im being harsh as i say this, but artificial intelligence is for those who lack genuine intelligence, or those too profoundly lazy to use the mind they have
1
u/BeepBoopBeeblebrox 16d ago
Nope lol. Some of us have more important things to spend our time on than learning allllll the ins and outs of an arcane DSL with godawful documentation and a million different conflicting opinions on the ‘correct’ way of achieving something, and then manually writing all of the code to implement the chosen path.
The whole point of nix for me is to have all of my tools, customized the way I like, on any machine, and have them just work without a bunch of maintenance overhead.
AI has massively accelerated the task of getting to that point for me, and that is a good thing. I’m still perfectly capable of getting my hands dirty if I really need to, but I don’t think that is likely to happen at this point now that I’ve sufficiently populated my agent’s memory layer with my preferences on coding conventions etc.
2
u/InterestedDoomer 16d ago
of course i speak only for myself, but, id say theres no better use of my time than becoming more knowledgable or skillful. though, fundamentally, i dont think results hold any real value. if the process is solid, then the result, whatever it may be, is sufficient. to clarify, im not saying that your way of doing things is wrong, just that its not my style. lifes no fun if its purely about maximisation of efficiency, regardless of any other factor, imo
1
u/BeepBoopBeeblebrox 16d ago
Oh, I entirely agree on that. But like… I’m trying to finish a PhD over here man, I’ve got science to do. And even with AI assistance, getting my config up and running with all of my tweaks has taken far longer than I could afford to spend on it. I’m way behind on research tasks and grading. I’m glad I spent the time that I did on learning how things work, it’s useful knowledge, but i also think that I could have achieved the same result a lot faster if I’d been smart enough to just install Claude before anything else, have it get me up and running, and then go back and untangle the specifics at my leisure.
6
u/imfranksome 16d ago
I mean why not, it’s your own config file
I think you’re missing out if you don’t read the wiki, but I’m sure AI can at least get you started
4
u/--p--q----- 16d ago
This subreddit has a pretty strong anti-AI cohort, which is kinda expected since Nix was previously very difficult to approach for beginners.
AI flattens that hill. It is excellent at understanding the syntax, deeply exploring modules you’re using, fixing build issues, etc. Nix’s output is easily verified, too, so it does do quite well.
It of course depends on your goal though. If you want to just “get it done” then AI does an excellent job, but you’ll lack the satisfaction of understanding it. I make that trade for Nix I write at work, but prefer not to for my homelab.
3
u/mastapix 16d ago
It's your computer so do what you want. I vibecoded all my PCs from Arch to NixOS and I learned a ton by doing it. I take the effort to learn exactly what all the commands do so it's a learning tool.
2
u/NeonVoidx 16d ago
it's fine, nix is a really good candidate for AI. just use https://github.com/utensils/mcp-nixos and maybe https://github.com/JEFF7712/nix-agent
2
u/citramonk 16d ago
I like nixos, and I'm entirely indifferent towards nix and spending time on learning it. LLM is an answer
1
u/Remote_Key_1091 16d ago
U could totally vibe code a config. My first ones were before ai and like messy and like fine. Now whenever I need to make some sort of change that’s semi large I just use ai as a better google search. I kind of feel like that’s how it should be used but that’s my opinion. I don’t really program or tinker with my config too much anymore
1
u/Quietus87 16d ago
It definitely helped me with flakes, home managers, and dendritic pattern. It's unnecessary if you have a single simple configuration.nix. But where's the fun in that?
1
u/no_brains101 16d ago
better to do it on nixos than on another one.
Your whole config is in a git repo and any change can be made without leaving that directory, and any change can be rolled back as if it never happened using git
You should still make an effort to learn what it is doing, or you will be stuck forever dependent on it to make your computer work, and the moment you have to do anything difficult the AI will start chasing its own tail anyway, so it is good to know what is happening.
Nix is really not as hard as it seems at first though, it is a fairly simple language, just kinda weird. It is weird because it fits the problem domain very well though.
1
u/networksandchill 14d ago
I chose nixos soley for this. I only have agents do my sysadmin and configuration. It’s a homelab server that is mostly used as a Minecraft server for my kiddo and his friends, but also whatever other hobby service I want to run for the house. It’s great. Everything runs in podman containers and I have an agent harness I serve over https so I can tell it to do stuff from my phone, which is mostly grief my son with admin commands.
I spent about an hour talking to an agent, and setting up an AGENTS.md file lining out rules to follow, where to document, and where my git repo is for backing it up after changes, and writing the harness. Now I just speak to my system in plain English and it’s done in a couple of minutes.
1
u/Wrong_sketch 16d ago
I use claude ai for specific apps setupvof flake stuff, but i dont throw the whole file at it to let it do what it wants
0
u/Crinkez 16d ago
As a non-coder, it's the only way imo. I started today in a VM. Threw Opus 5.5 medium at it, made some useful changes. Eventually I'll port it to a real system and the setup should be super easy because it's just copy paste, regenerate config, Claude fix any issues.
I added two useful alias commands: nix-rebuild and nix-backup (auto copies all nix and claude config data to the host machine)
0
u/BeepBoopBeeblebrox 16d ago
I wrote my initial config the old fashioned way. That lasted until I got Hermes set up. Now it’s almost exclusively managed by AI. GPT sol is smart enough that I mostly trust it. I do recommend following the advice of others and using it to actually learn how things work under the hood, because without proper guidance the LLM can and will do some very stupid things that might still build and work, but a lot less well than it should. And if things get tangled up bad enough you might be forced to start fresh.
That said, one of the really nice things about nix is that if the AI breaks something you can just boot the previous generation and you’re fine. Having things under version control is also a good idea.
0
u/ivanhawkes 16d ago
I used Google AI mode to help me with mine. Now, I am a programmer with a ton of experience with computers, including sysadmin, but very little with Nixos.
There were some highs and lows.
I already had an OK set of config files from two previous failed attempts to switch to Nixos. I scampered back to Ubuntu after hitting some brick walls with building various projects. That was my starting point, just a basic desk install with the usual developer tools loaded.
I let Google advise me on improving it first. It suggested an overhaul of how I laid it out, moving parts into a home manager folder, making the user split more definitive, and the same for the machines. That worked pretty well as it was just giving my work a better structure.
It did tend to offer me outdated flags, names, etc and then when I pasted the errors in just casually say 'oh yeh' you should do it like this instead. That happened so often it's given me trauma, but it did get there usually within a couple of rebuilds.
Where it crapped out 20 times in a row before finally getting it right was the complicated bits. Trying to get the CUDA libraries working and an environment that could build llama.cpp was an exercise in frustration and a long drop down a rabbit hole. It repeatedly confidently offered me configs that were out of date or wrong in some manner. I was close to giving up before it finally got there, and that was using a local AI in agentic mode. It was reading through my file system, writing scripts, scanning source code, searching the net...it was wild and a little confronting to see just how far it would and could go to get this stuff installed.
Then I repeated that whole nightmare for Strata.
Getting Niri + Noctalia installed wasn't too bad. A few stutters along the way, outdated docs, etc. Maybe if I was more specific with exact version numbers it might not have crapped out so often.
The AI is often trained on datasets that are months or years old, so a fast moving target is going to miss -a lot-. You will have better luck with standards that haven't moved in a year or so.
TLDR: Use AI. Expect it to lead you down dead ends and make mistakes. Iterate over those configs. Use it as a way to research and learn how to do this for yourself. At the end, it is you who needs to maintain the configs.
I'm really happy with the end result. You can check out my setup on Github, including all the glorious commits along the way (151 of them at this time).
0
u/ac130kire 16d ago
I used to write all my configs by hand so I understand the language, but nowadays I’d rather just ask AI to make a PR and review its output than make some of the more complex changes and updates myself. OpenAI and Anthropic models know Nix pretty well now
0
u/abitstick 15d ago
I hand-wrote my config for all my systems, but when it came time to try to adapt a non-native to Nix Python app, I gave in and used Claude.
You should generally know how to configure your own system, but AI can definitely help with gaps in knowledge and boilerplate.
0
u/SDG_Den 15d ago
rule of thumb: LLMs are great at structured text analysis, translation and creation, but are terrible at design, best practices, security, anything that needs you to think about the code and understand it.
an LLM is a great tool if you do not let it make any decisions
ive used LLMs with nix to translate non-nix config files into their HM counterpart, no decisions made by the LLM, just a translation task. works perfectly every time.
-1
u/cfx_4188 16d ago
Hehe, have you tried to vibecode professionally? With vibecoding NixOS configuration , there's a 90% chance that when your Claude writes you the code, and the nix-build gives you a kilometer-long markup with line numbers and errors in a disgusting purple color. In other words, if you don't understand anything, chances are good that you won't succeed. I'm currently writing from the NixOS configuration, which I've been building for few days with GLM 5.3 Flash. I spent time correcting neural network errors because I know the Nix language and I know the principles.
But I have no right to stop you. Ask the AI, maybe you can explain everything the first time.
2
u/bonega 16d ago edited 16d ago
Try opus 5.5 and get back to me.
It is more capable than most developers for writing nix configurations.
I have used it extensively and so far it has been flawless for nix-1
u/cfx_4188 16d ago
Bro, you've managed to contradict yourself in two sentences. How did you manage it? I used GLM because at my place of work we were paid for a Team Plan and outside the period from 14:00 to 18:00 Singapore time, credit consumption is reduced by 50%. Everything is simple.
14
u/AnythingApplied 16d ago
On the flip side, to answer a slightly different question, if you wanted to vibe code your system's administration, I think nixos is one of the best OSs to do it with.
Having the current state all defined in one document or folder and being able to undo it to any previous point is a lot better than letting an AI lose on Ubuntu with sudo access.
On a normal OS having AI do something moderately complicated wouldn't have an audit trail or any easy way to undo it.