[Nix-dev] How can I stop python writing into the nix store?

Eelco Dolstra e.dolstra at tudelft.nl
Mon Apr 4 09:29:08 CEST 2011


Hi,

On 04/04/2011 08:19 AM, roconnor at theorem.ca wrote:

> Wicd runs as root. The demon is written in Python. When python runs it
> likes to write new .pyc and/or .pyo files into the store. Since wicd is
> running as root it obliges and modifies the store directory. Clearly
> this is bad.

This has been fixed in the modular-python branch with this patch:

https://svn.nixos.org/repos/nix/nixpkgs/branches/modular-python/pkgs/development/interpreters/python/2.7/nix-store-mtime.patch

The problem was that *.pyc files contain the timestamp of the 
corresponding .py file.  If the stored timestamp doesn't match the 
actual timestamp of the .py file, then the .pyc file is considered out 
of date and will be regenerated.  However in Nix we change the timestamp 
to 1 after the pyc files have been generated.  So the entire pyc 
mechanism was broken in Nixpkgs.  The patch fixes this by special-casing 
timestamps of 1.

On a more general note, it would be nice if we could prevent accidental 
changes to store paths by root.  On ext2/3/4 this can be done by setting 
the immutable bit on a file.  Unfortunately, it also prevents additional 
hard links to the file, so it breaks `nix-store --optimise'.

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/



More information about the nix-dev mailing list