Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make configuration.nix writeable by root #384

Open
nzbr opened this issue Jan 5, 2024 · 6 comments
Open

Make configuration.nix writeable by root #384

nzbr opened this issue Jan 5, 2024 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@nzbr
Copy link
Member

nzbr commented Jan 5, 2024

When importing a fresh tarball, /etc/nixos/configuration.nix is set to read-only. We should make the file writeable by root in the tarball builder

@nzbr nzbr added enhancement New feature or request good first issue Good for newcomers labels Jan 5, 2024
@aikooo7
Copy link

aikooo7 commented Jan 6, 2024

Hello, I will try to implement this, I will keep you updated if I need anything

@aikooo7
Copy link

aikooo7 commented Jan 6, 2024

Hello again @nzbr , I got a few issue so I want to know how should I try to debug it further, the three changes I tried:

--- a/modules/build-tarball.nix
+++ b/modules/build-tarball.nix
@@ -85,6 +85,7 @@ in
           mkdir -p "$root/etc/nixos"
           cp -R ${lib.cleanSource cfg.configPath}/. "$root/etc/nixos"
           chmod -R u+w "$root/etc/nixos"
+          chown -R 1000 /etc/nixos
         ''}

         echo "[NixOS-WSL] Compressing..."

AND

--- a/modules/build-tarball.nix
+++ b/modules/build-tarball.nix
@@ -85,6 +85,7 @@ in
           mkdir -p "$root/etc/nixos"
           cp -R ${lib.cleanSource cfg.configPath}/. "$root/etc/nixos"
           chmod -R u+w "$root/etc/nixos"
+          chown -R 1000 "$root/etc/nixos"
         ''}

         echo "[NixOS-WSL] Compressing..."

AND

--- a/modules/build-tarball.nix
+++ b/modules/build-tarball.nix
@@ -85,6 +85,7 @@ in
           mkdir -p "$root/etc/nixos"
           cp -R ${lib.cleanSource cfg.configPath}/. "$root/etc/nixos"
           chmod -R u+w "$root/etc/nixos"
+          chown -R nixos /etc/nixos
         ''}

         echo "[NixOS-WSL] Compressing..."

@nzbr
Copy link
Member Author

nzbr commented Jan 8, 2024

Changing the owner to the default user shouldn't be necessary. It's fine if the file can only be edited by root. Given that the needed chmod call is already there, I suspect that the permissions get lost when creating the tar file for some reason

@aikooo7
Copy link

aikooo7 commented Jan 10, 2024

I suspect that the permissions get lost when creating the tar file for some reason

That is what I was thinking too, so maybe we could do it in the first time the system is runned like the welcome message?

@nzbr
Copy link
Member Author

nzbr commented Jan 11, 2024

Good idea. I like it. It's probably best to put it in an activation script

@aikooo7
Copy link

aikooo7 commented Jan 12, 2024

Good idea. I like it. It's probably best to put it in an activation script

I don't like the idea of a activation script since I still want give the user a way to change the permissions for whatever they want, Which is impossible if the permissions are changed everytime the system is rebuilt

@nix-community nix-community deleted a comment from 1nv0k32 Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants