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

Set /tmp as the CWD for activation #39

Closed
wants to merge 1 commit into from

Conversation

antifuchs
Copy link
Contributor

Due to a nixos bug (NixOS/nixpkgs#73404), the activation requires CWD to be writeable; one canonical writeable directory is /tmp, so I picked that. This fixes the issue for me, and I can install initrd secrets with the fix in place.

I guess it would be reasonable to let users choose their own, but I'm not sure how to properly do that - maybe via a custom activation script?

Due to some nixos
bugs (e.g. NixOS/nixpkgs#73404), the
activation requires CWD to be writeable; the canonical writeable
directory is /tmp, so let's use that.
@notgne2
Copy link
Contributor

notgne2 commented Dec 27, 2020

I think this would be better done in the activate.nixos function in flake.nix.

We have $PROFILE so having PWD point to the profile isn't needed, but I might have still relied on that functionality in a few deployments (and some others may have too) and there's no point creating incompatibilities without a good reason

@notgne2
Copy link
Contributor

notgne2 commented Dec 27, 2020

Also I'm against using /tmp without it being configurable, it's available in (most) NixOS configurations, though that's not all this tool should be able to work with

@0x4A6F
Copy link

0x4A6F commented Jan 3, 2021

This issue can probably be closed, when NixOS/nixpkgs#73780 is merged.

@antifuchs
Copy link
Contributor Author

NixOS/nixpkgs#73780 won't make it into 20.09, right? I think we might need some method to customize the cwd anyway if not.

@notgne2
Copy link
Contributor

notgne2 commented Jan 3, 2021

I think we might need some method to customize the cwd anyway if not

Why not just change the NixOS activation helper to nixos = base: custom base.config.system.build.toplevel "cd /tmp && $PROFILE/bin/switch-to-configuration switch"; in the flake.nix?

@antifuchs
Copy link
Contributor Author

Ah, I just found a case where your workaround is not quite optimal: When activation fails, the magic rollback will re-activate the previous generation, but if that's one that is built without this activation script, that generation can no longer properly be activated outside a writable directory.

@szlend
Copy link

szlend commented Jan 17, 2021

Ah, I just found a case where your workaround is not quite optimal: When activation fails, the magic rollback will re-activate the previous generation, but if that's one that is built without this activation script, that generation can no longer properly be activated outside a writable directory.

Even if the bug was fixed in nixpkgs that would still be the case when you'd be deploying the fix for the first time. I would just re-deploy the previous generation with this workaround applied before doing any other changes if you want to safely rollback to it.

@notgne2
Copy link
Contributor

notgne2 commented Feb 9, 2021

I'm closing this in favor of the now-merged #65

@notgne2 notgne2 closed this Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants