Why is configuration.nix labeled read-only?

every time i try to install something, every source i can find tells me to edit /etc/nixos/configuration.nix, but when i go to the file, it says read-only and i, well, can only read it?

if anyone knows why this message is showing up, please help : (

1 Like

Regular users can’t edit it because of its location having certain default perms; use sudoedit or move it (along with hardware-configuration.nix) elsewhere and point nixos-rebuild at it (and you may want to chown it at that point to ensure the file is owned by a different user).

1 Like

i have solved the problem (hours trying to find it, when i actually try asking for help thats when i figure it out myself ):, turns out i just had to use nano.

thank you though that probably wouldve workd if i was smart enough to know what you were saying (:

Nano won’t magically let you edit a file you don’t have access to, idk what you meant.

1 Like

no idea, i was using a normal text editor and it didnt work, i use nano and it does… soooo…

Welcome to the nixos discourse.

It sounds like you by" “normal text editor” mean something like vscode, running as your own user, and that you now used nano as root in a terminal.

I wonder if you would maybe learn more if you tried being a bit less dismissive of the people who try to help you (and who are right in what they say).

im not dismissing it. if i hadnt already solved the problem i was struggling with, i would have tried any solution i could. im simply answering what little i know. now that my problem is solved i would like to not be pinged here any more.

Hello, I wanted to maybe try and preface why you were having difficulty editing your configuration.nix.

Nixos being a linux distribution it is pre-baked with all the traditional access level controls that the linux file system natively abides by. This means that certain files have protections against them (for reading, writing, or executing) based on the user / level of privilege that user has.

In Nixos the config file is by default only WRITABLE as a super user. (sudo nvim sudo nano etc..)

No matter the text editor, as long as the PID for that editor was spawned under the root user (that’s what the sudo command does) it should have permission to edit the configuration.nix

I hope this helps!

2 Likes