Commit Graph

246 Commits

Author SHA1 Message Date
nikstur
f087e5c94b nixos/network-interfaces: add packages to corePackages
This allows users to override (i.e. exclude) these packages from their
system closure if they don't need them.
2025-08-10 22:48:26 +02:00
nikstur
d5ae87bdeb Revert "nixos: allow more things to be disabled" 2025-08-10 22:22:08 +02:00
Arian van Putten
1bb040fae8 nixos: allow more things to be disabled (#429695) 2025-08-10 19:49:52 +02:00
nikstur
bb954cddf5 nixos/network-interfaces: let networkd handle privacy extensions
This removes bash from the mandatory system closure.
2025-08-09 00:10:13 +02:00
nikstur
f5ffdbfeb0 nixos/network-interfaces: add packages to corePackages
This allows users to override (i.e. exclude) these packages from their
system closure if they don't need them.
2025-07-31 20:42:35 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Michele Guerini Rocco
6424dede0c nixos/network-interfaces: improve IPv6 support (#417150) 2025-07-23 16:51:24 +02:00
rnhmjoj
602006b0b6 nixos/networking-interfaces: add rnhmjoj as maintainer 2025-07-11 09:44:49 +02:00
rnhmjoj
4e5205a68a nixos/networking-interfaces: add IPIP tunnels 2025-07-11 09:44:49 +02:00
rnhmjoj
716634530e nixos/networking-interfaces: clean up networking.sits
This change rework a bit the documentation on networking.sits to explain
what they actually are. In fact, there are three different protocols
being collectively called "SIT", which itself is a nonstandard term.
2025-07-11 09:44:48 +02:00
rnhmjoj
1a8c90128b nixos/network-interfaces: add option to set source address 2025-07-11 09:44:48 +02:00
Martin Weinelt
8e70f11f88 networking: clarify search and domain option descriptions
There is no canonical way to set a system domain name any longer. The one
we previously used was the NIS/YP one, but that is pointless these days.

The hostname is set up through /etc/hostname, but hostname(5) states that
it should only contain 64 7-bit ASCII characters, so it cannot be used
to cover the domain name.

We still support setting the domain name to complete the `fqdn` option
and as a central option to reference the domain name from. If anyone
wants a NIS/YP domain name set, do it yourself..

We then clarify that the domain option has nothing to do with DNS
resolution anymore and search should be configured instead.

Finally explain the purpose of the ndots option in the context of search
domains, since they decide when we stop considering the search domains
when querying names with more than one dot.
2025-07-06 00:59:37 +02:00
Martin Weinelt
8a4536fdaf networking: stop configuring NIS domain name
The `domainname` utility uses setdomainname (see getdomainname(2)) to
configure the NIS[1] (also known as YP) domain name.

It provided a central directory for various objects that are resolved via
nsswitch in the late 1990s and early 2000s.

It is however not a safe nor common deployment scenario anymore.

[1] https://en.wikipedia.org/wiki/Network_Information_Service
2025-07-06 00:59:36 +02:00
Martin Weinelt
b84f8fdaa0 networking: provide hostname-debian by default
This is first and foremost to provide compat with scripts that call the
hostname executable to retrieve the hostname, an assumptions we probably
should not be breaking.
2025-07-06 00:59:36 +02:00
Martin Weinelt
bf1b4d35fb networking: don't install nettools by default
https://lwn.net/Articles/710533/ has been true in 2017 and still holds
today.
2025-07-06 00:59:36 +02:00
Michael Hoang
6c701a9573 nixos/networking: fix fqdnOrHostName when FQDN explictly set 2025-04-23 00:45:17 +10:00
Michael Hoang
4d537721f7 nixos/networking: allow users to override FQDN
This may be useful for users where `${cfg.hostname}.${cfg.domain}` isn't
actually the fully quantified domain name of the server.
2025-04-15 18:28:40 +02:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Peder Bergebakken Sundt
953f72e76e nixos/*: tag manpage references 2025-01-27 02:47:01 +01:00
misuzu
9c54c30f11 tasks/network-interfaces: Disable network-local-commands service if unnecessary (#338622) 2024-12-14 13:17:13 +02:00
Artturin
e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
tu-maurice
a7ef1254e6 tasks/network-interfaces: Disable network-local-commands service if unnecessary
If the localCommands variable is empty this service does nothing, but
runs anyway. We can disable it in these cases.
2024-08-31 15:22:14 +02:00
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
Niko
9e2cd6f872 nixos/network-interfaces: remove network-interfaces.target
Co-authored-by: Martin Weinelt <mweinelt@users.noreply.github.com>
2024-01-12 17:29:03 +01:00
nikstur
c9569af3e0 Merge pull request #271326 from philiptaron/shutdown.target
treewide: depend on `shutdown.target` if `DefaultDependencies=no` in almost every case
2023-12-27 08:33:26 +01:00
rnhmjoj
cdc24ab409 nixos/networking-interfaces: fix rootless ping
In 759ec111 the ping setuid wrapper was removed in favour of giving
permissions to perform ICMP echo requests to all users.
The problem is that the systemd file that was supposed to change the
`net.ipv4.ping_group_range` sysctl is not always installed, specifically
only if systemd.coredump.enable.
In that case the range is "0 1", which is effectively restricts ping to
only root.

This change explicitely sets the range to "0 2^31-1", as systemd does.
2023-12-11 13:22:26 +01:00
Philip Taron
54064109fb nixos/network-interfaces: ensure correct ordering w.r.t. shutdown.target
Also, mark this service as `oneshot`, since it is.
2023-11-30 15:39:01 -08:00
Gaurav Juvekar
5ab4ce5d33 nixos/network-interfaces: fix typo in networking.fqdn 2023-11-12 08:47:01 -08:00
Joseph Stahl
137a3c1303 systemd domainname service - fix missing domainname binary
needs nettools in path
2023-10-28 22:30:14 -04:00
nikstur
d300940637 nixos/network-interfaces: replace hostname and domain activationScript
The hostname is already set by systemd
https://www.freedesktop.org/software/systemd/man/latest/hostname.html#Hostname%20semantics

Create a separate service that registers the domainname.
2023-10-26 01:51:08 +02:00
Martin Weinelt
d042a29613 Merge pull request #253764 from linj-fork/fix-ping-wrapper
nixos/network-interfaces: stop wrapping ping with cap_net_raw
2023-10-20 00:57:55 +02:00
Maximilian Bosch
632cfff257 Merge pull request #259619 from Majiir/fix-networkd-dhcp
nixos/network-interfaces-systemd: fix DHCP setting
2023-10-14 20:47:36 +02:00
Majiir Paktu
c4228b6c8f nixos/network-interfaces-systemd: fix DHCP setting
The networkd backend logic for setting DHCP= on an interface is bugged
and inconsistent with the scripted logic. Consider this simple NixOS
configuration:

    {
      networking.useNetworkd = true;
      networking.interfaces.eth0.wakeOnLan.enable = true;
    }

The default value of networking.useDHCP is true, so we expect our eth0
interface to have DHCP enabled. With the scripted backend, this works.
But the networkd backend generates the following 40-eth0.network file:

    [Match]
    Name=eth0

    [Network]
    DHCP=no
    IPv6PrivacyExtensions=kernel

This is happening because the wakeOnLan configuration creates a key in
networking.interfaces, and the networkd backend erroneously checks that
instead of for explicitly configured IP addresses as in the scripted
backend. The documentation is also inconsistent across various options.

This change aligns the networkd backend and option documentation to the
actual behavior of the scripted backend, and updates a test to account
for this behavior for both backends.
2023-10-14 13:57:32 -04:00
Maximilian Bosch
6998695f5d Merge pull request #259658 from Majiir/fix-networkd-wakeonlan
nixos/network-interfaces-systemd: fix WakeOnLan
2023-10-14 14:48:22 +02:00
Maximilian Bosch
d664571660 Merge pull request #256598 from adamcstephens/net/warn-multiple-net
nixos/networking: warn when both networkd and dhcpcd can collide
2023-10-14 12:24:24 +02:00
Majiir Paktu
f5f1751b1f refactor: combine scripted and networkd WakeOnLan config 2023-10-07 21:02:46 -04:00
ign0tus
27d0a8a0cd network.interfaces: Add option to configure WakeOnLan policy
Adds an option to configure a custom WakeOnLan policy instead of the
hard-coded "magic" policy. To ensure compatibility with current
behavior, "magic" is kept as default.
2023-09-28 20:14:02 +02:00
Adam Stephens
b4e162a109 nixos/networking: warn when both networkd and dhcpcd can collide 2023-09-21 20:05:25 -04:00
Lin Jian
759ec1113d nixos/network-interfaces: stop wrapping ping with cap_net_raw
From systemd 243 release note[1]:

This release enables unprivileged programs (i.e. requiring neither
setuid nor file capabilities) to send ICMP Echo (i.e. ping) requests
by turning on the "net.ipv4.ping_group_range" sysctl of the Linux
kernel for the whole UNIX group range, i.e. all processes.

So this wrapper is not needed any more.

See also [2] and [3].

This patch also removes:
- apparmor profiles in NixOS for ping itself and the wrapped one
- other references for the wrapped ping

[1]: 8e2d9d40b3/NEWS (L6457-L6464)
[2]: https://github.com/systemd/systemd/pull/13141
[3]: https://fedoraproject.org/wiki/Changes/EnableSysctlPingGroupRange
2023-09-21 16:52:16 +08:00
Robert Obryk
44fde723be nixos/security/wrappers: generate a separate and more complete apparmor policy fragment for each wrapper
This change includes some stuff (e.g. reading of the `.real` file,
execution of the wrapper's target) that belongs to the apparmor policy
of the wrapper. This necessitates making them distinct for each wrapper.
The main reason for this change is as a preparation for making each
wrapper be a distinct binary.
2023-08-27 14:10:07 +02:00
Molly Miller
3e96fd980d nixos/network-interfaces: restrict IPv6 privacy address overrides to interface
Only trigger the privacy address override for a given interface when
that interface is added. Without restricting the rule to the
interface, this command would be run when any interface is added.
2023-06-27 16:15:02 +02:00
Victor Fuentes
d3528cdc3d nixos/version: add config.system.nixos.distroName and config.system.nixos.distroId 2023-01-14 16:19:06 -05:00
Artturin
05a2dfd674 lib.replaceChars: warn about being a deprecated alias
replaceStrings has been in nix since 2015(nix 1.10)

so it is safe to remove the fallback

d6d5885c15
2022-12-15 22:25:51 +02:00
Ryan Lahfa
bc7c15825b Merge pull request #117371 from grahamc/sysctl-hostname
network-interfaces: set hostname from sysctl if defined
2022-12-01 16:03:04 +01:00
Robert Hensing
93a905ec4f Merge pull request #194759 from hercules-ci/fqdn-or-hostname
nixos: Add `networking.fqdnOrHostName`
2022-11-09 13:53:57 +01:00
Naïm Favier
8f571534c9 Merge pull request #194766 from ncfavier/proxy-arp 2022-10-31 09:59:56 +01:00
Robert Hensing
18e3f431e1 networking.fqdnOrHostName: Elaborate and format the descriptions 2022-10-15 11:57:58 +02:00
Naïm Favier
52c58c8bbe nixos/network-interfaces: reflect negative settings of proxyARP
Currently, setting `proxyARP` to true enables `proxy_arp`, but setting
it to false doesn't disable it. This is surprising and stateful.
2022-10-06 16:46:17 +02:00
Robert Hensing
f43716f28e nixos: Add networking.fqdnOrHostName option, readOnly 2022-10-06 16:21:09 +02:00
digital
12d64e041b nixos/networking: add a suggestion to use networkd options 2022-09-15 18:07:24 +02:00