Discussion:
nixos-rebuild without Internet
(too old to reply)
Maximilian Bosch
2017-06-24 22:52:52 UTC
Permalink
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
James Cook
2017-06-25 01:20:07 UTC
Permalink
Post by Maximilian Bosch
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
Hi Maximilian,

If you only make a configuration change like reconfiguring a network
interface, I'd expect nixos-rebuild to work without a network.

If you update your nixpkgs version (e.g. nix-channel --update or git
pull or passing --upgrade to nixos-rebuild) that could mean the next
build requires a network connection. Could that be it?

Or is it trying to access the binary cache? If so, there's surely some
way to disable that so it builds everything locally.

James
Danylo Hlynskyi
2017-06-25 03:02:09 UTC
Permalink
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.
Post by Maximilian Bosch
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
https://mailman.science.uu.nl/mailman/listinfo/nix-dev
Maximilian Bosch
2017-06-25 21:18:43 UTC
Permalink
Hi,

at first thanks for your answers :-)
Post by James Cook
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.
Post by James Cook
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.
Post by James Cook
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
Post by James Cook
In general, no, there isn't "partial" rebuild, because Nix itself doesn't
support "partial" builds (and NixOS is
just another derivation)
- 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.
Post by Maximilian Bosch
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
https://mailman.science.uu.nl/mailman/listinfo/nix-dev
Loading...