[Nix-dev] How do you work on big packages?

Volth volth at volth.com
Sat Mar 18 01:20:58 CET 2017


nix-shell on its installPhase has no rights to write to /nix/store,
installPhase always fails.


I am thinking about something like converting a derivation (a .drv
file) into two files:

1. a .sh file, which would do unpackPhase, patchPhase, configurePhase,
buildPhase using the current directory, not something in /tmp.
nix-shell fits very well here.
Ideally, this script just launches nix-shell to perform these phases.

2. a .nix file with src= pointing to the build directory made by the
previous script and performs buildPhase, checkPhase, installPhase,
fixupPhase. this .nix file could be used substitute a .nix file in
all-packages.nix during troubleshooting.

So buildPhase is performed twice (we assume it is to be idempotent,
isn't it?), second time quickly because all .o files are already
compiled. And it would automatically recompile only changed sources.

In practice, it is not so beautiful. For example, kernel derivation
sets environment variables in preUnpack then uses in buildPhase so it
would be a trouble to simply skip all the phases before buildPhase.

On 3/17/17, Profpatsch <mail at profpatsch.de> wrote:
> On 17-03-17 06:04pm, Volth wrote:
>> "nix-shell" would be a super option here if it could handle
>> "installPhase" (this seems easy to fix) and .nix files less trivial
>> than "hello.nix" (this seems not easy to fix; for example "nix-shell
>> '<nixpkgs>' -A linux_4_4" has no "configurePhase", and there are
>> similar problems with almost every of the big projects; nix-shell
>> launches "make" when "nix-build" launches "cmake" or vice-versa, etc)
>
> That’s a pretty common stumbling block.
>
> If someone defines his own `installPhase` for example,
> the `installPhase` shell function is just the standard
> stdenv `installPhase`. What you want to call is rather
> the contents of `$installPhase` (the variable), since
> that contains the phase you defined in `mkDerivation`.
>
> nix-shell
> $ unpackPhase
> unpacking …
> $ configurePhase
> configuring …
> $ buildPhase
>> $ $installPhase
> running your installPhase
>
>
> There is not much abstraction. Every nix attribute within
> `derivation` (and by extension `mkDerivation`) will end up
> as a bash shell variable in your shell (and your build env).
>
> --
> Proudly written in Mutt with Vim on NixOS.
> Q: Why is this email five sentences or less?
> A: http://five.sentenc.es
> May take up to five days to read your message. If it’s urgent, call me.
>


More information about the nix-dev mailing list