[Nix-dev] nixos-rebuild without Internet
Danylo Hlynskyi
abcz2.uprola at gmail.com
Sun Jun 25 05:02:09 CEST 2017
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/591be137/attachment-0001.html>
More information about the nix-dev
mailing list