[Nix-dev] nixos-rebuild without Internet
Maximilian Bosch
maximilian at mbosch.me
Sun Jun 25 23:18:43 CEST 2017
Hi,
at first thanks for your answers :-)
> If you only make a configuration change like reconfiguring a network
> interface, I'd expect nixos-rebuild to work without a network.
the last time(s) I ran into this I avoided GCs or Channel updates before as
I feared such issues.
> Or is it trying to access the binary cache?
yes I think that describes the problem way better. Last time it attempted
to download several items from the binary cache (unfortunately I don't
remeber which).
I think that avoiding downloads from the binary cache here might help,
however I'm wondering if Nix is (or should in future versions be) able to
skip such downloads in cases like no (appropriate) connection
automateically.
> if you do know, what possible NixOS configurations may help you in
future, use the `nesting.clone` option.
That example looks quite interestng, thanks for the hint! I hope that I'll
find some time next week to play around with this :-)
Have a nice evening,
Maximilian
On Sun, Jun 25, 2017 at 5:02 AM, Danylo Hlynskyi <abcz2.uprola at gmail.com>
wrote:
> In general, no, there isn't "partial" rebuild, because Nix itself doesn't
> support "partial" builds (and NixOS is
> just another derivation)
>
> There are workarounds, however:
> - don't setup network via NixOS modules, do it with direct imperative
> commands
> - often some commands are hidden. For example, when network-manager is
> enabled, dhcpcd is disabled.
> And the only way to run dhcpcd is to find the binary in /nix/store/...
> hoping GC didn't remove it.
> - don't do channel updates and GCs, if you know you may experience
> internet problems.
> - if you do channel updates, don't GC channel profiles at least (so you
> can nix-channel --rollback)
> I've done this several times, updated a channel to setup some package,
> but didn't do nixos-rebuild...
> - if you do know, what possible NixOS configurations may help you in
> future, use the `nesting.clone` option.
> Let me show you an example.
>
> # configuration.nix
> { lib, ...}: {
>
> networking.networkmanager.enable = true;
>
> nesting.clone = [
> {
> networking.networkmanager.enable = lib.mkForce false;
> networking.dhcpcd.enable = lib.mkForce true;
> }
> ];
>
> }
>
> This defines a default configuration with NM enabled, and alternative
> with NM disabled and DHCPcd enabled
> You can activate the alternative configuration with
> $ sudo /run/current-system/fine-tune/child-1/bin/switch-to-configuration
> test
>
> To revert back either reboot, or
> $ sudo /run/booted-system/bin/switch-to-configuration test
>
> By using nesting.clone, you can declaratively control which parts of
> configuration should
> be retained by GC collector without polluting your current environment.
> The activation of configuration shouldn't require internet connection.
>
> 2017-06-25 1:52 GMT+03:00 Maximilian Bosch <maximilian at mbosch.me>:
>
>> Hey guys,
>>
>> I'm using a NixOS setup on my developer machine. For WLAN networks I use
>> the `networking.wireless` option as it allows me a declarative/reproducible
>> setup of the networks I use on a daily basis.
>>
>> Unfortunately I'm facing from time to time the following issue: whenever
>> I try to add a new network (and no connection is available ATM) I have a
>> problem running `nixos-rebuild` as the rebuild usually causes a lot of
>> other operations and some of them require a connection to the internet
>> (e.g. for [re]downloads).
>>
>> However this is quite bad when I need a new network, but the rebuild
>> fails. I currently solve it using several tricks, but in the end I'd like
>> to now if there's some kind of tool to do a "partial-rebuild" on a NixOS
>> machine (although it might break the reproducability as the expressions
>> wouln'dt be 100%-deterministic anymore) or if I have to live with this
>> issue.
>>
>> Thanks and have a nice Sunday,
>>
>> Maximilian
>>
>> _______________________________________________
>> nix-dev mailing list
>> nix-dev at lists.science.uu.nl
>> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170625/5fa7f5e8/attachment.html>
More information about the nix-dev
mailing list