A while ago I wrote a wrapper around nix-shell that helps with running
the build steps in correct manner and order (among with other niceties
like automatically creating a temporary build directory and making
$out point to a path in /tmp/):
https://github.com/dezgeg/nix-debug-shell

I mainly wrote it for debugging build steps for existing packages, but
I guess the same ideas/code could be used for local development as
well.

It is rigorously undocumented, so here's a short primer: in a nixpkgs
tree, run /path/to/nix-debug-shell -A hello. That places you under
/tmp/nds-build-hello/hello-2.10 with the sources unpacked. Run
'nd-step' as many times you want to step through the build phases
(it's named after the 'step' command in GDB). When installPhase is
done, it installs to /tmp/, e.g. /tmp/nds-install-hello/bin/hello.

Hope anyone finds this useful.

2017-03-17 21:26 GMT+02:00 Profpatsch <m...@profpatsch.de>:
> 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.
> _______________________________________________
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
_______________________________________________
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev

Reply via email to