Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 68b6d6ca8e84
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b2f3bd4d7939
Choose a head ref
  • 4 commits
  • 4 files changed
  • 3 contributors

Commits on Oct 12, 2020

  1. nixos/networking: Add a read-only option for the FQDN

    This is a convenience option that can be used to quickly obtain the
    configured FQDN.
    primeos committed Oct 12, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    primeos Michael Weiss
    Copy the full SHA
    971f0b4 View commit details

Commits on Jan 23, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    primeos Michael Weiss
    Copy the full SHA
    87fb5d3 View commit details
  2. nixos/smokeping: Replace the tabs in cfg.targetConfig

    This was inconsistent with the rest of the module.
    primeos committed Jan 23, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    primeos Michael Weiss
    Copy the full SHA
    237c20a View commit details

Commits on Jan 25, 2021

  1. Merge pull request #100155 from primeos/nixos-add-fqdn-option

    nixos/networking: Add a read-only option for the FQDN
    flokli authored Jan 25, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b2f3bd4 View commit details
Showing with 44 additions and 17 deletions.
  1. +15 −13 nixos/modules/services/networking/smokeping.nix
  2. +18 −0 nixos/modules/tasks/network-interfaces.nix
  3. +10 −4 nixos/tests/hostname.nix
  4. +1 −0 nixos/tests/smokeping.nix
28 changes: 15 additions & 13 deletions nixos/modules/services/networking/smokeping.nix
Original file line number Diff line number Diff line change
@@ -124,7 +124,8 @@ in
};
hostName = mkOption {
type = types.str;
default = config.networking.hostName;
default = config.networking.fqdn;
defaultText = "\${config.networking.fqdn}";
example = "somewhere.example.com";
description = "DNS name for the urls generated in the cgi.";
};
@@ -156,6 +157,7 @@ in
ownerEmail = mkOption {
type = types.str;
default = "no-reply@${cfg.hostName}";
defaultText = "no-reply@\${hostName}";
example = "no-reply@yourdomain.com";
description = "Email contact for owner";
};
@@ -239,18 +241,18 @@ in
targetConfig = mkOption {
type = types.lines;
default = ''
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
Here you will learn all about the latency of our network.
+ Local
menu = Local
title = Local Network
++ LocalMachine
menu = Local Machine
title = This host
host = localhost
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
Here you will learn all about the latency of our network.
+ Local
menu = Local
title = Local Network
++ LocalMachine
menu = Local Machine
title = This host
host = localhost
'';
description = "Target configuration";
};
18 changes: 18 additions & 0 deletions nixos/modules/tasks/network-interfaces.nix
Original file line number Diff line number Diff line change
@@ -398,6 +398,24 @@ in
'';
};

networking.fqdn = mkOption {
readOnly = true;
type = types.str;
default = if (cfg.hostName != "" && cfg.domain != null)
then "${cfg.hostName}.${cfg.domain}"
else throw ''
The FQDN is required but cannot be determined. Please make sure that
both networking.hostName and networking.domain are set properly.
'';
defaultText = literalExample ''''${networking.hostName}.''${networking.domain}'';
description = ''
The fully qualified domain name (FQDN) of this host. It is the result
of combining networking.hostName and networking.domain. Using this
option will result in an evaluation error if the hostname is empty or
no domain is specified.
'';
};

networking.hostId = mkOption {
default = null;
example = "4e98920d";
14 changes: 10 additions & 4 deletions nixos/tests/hostname.nix
Original file line number Diff line number Diff line change
@@ -7,9 +7,12 @@ with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;

let
makeHostNameTest = hostName: domain:
makeHostNameTest = hostName: domain: fqdnOrNull:
let
fqdn = hostName + (optionalString (domain != null) ".${domain}");
getStr = str: # maybeString2String
let res = builtins.tryEval str;
in if (res.success && res.value != null) then res.value else "null";
in
makeTest {
name = "hostname-${fqdn}";
@@ -26,13 +29,16 @@ let
];
};

testScript = ''
testScript = { nodes, ... }: ''
start_all()
machine = ${hostName}
machine.wait_for_unit("network-online.target")
# Test if NixOS computes the correct FQDN (either a FQDN or an error/null):
assert "${getStr nodes.machine.config.networking.fqdn}" == "${getStr fqdnOrNull}"
# The FQDN, domain name, and hostname detection should work as expected:
assert "${fqdn}" == machine.succeed("hostname --fqdn").strip()
assert "${optionalString (domain != null) domain}" == machine.succeed("dnsdomainname").strip()
@@ -60,7 +66,7 @@ let

in
{
noExplicitDomain = makeHostNameTest "ahost" null;
noExplicitDomain = makeHostNameTest "ahost" null null;

explicitDomain = makeHostNameTest "ahost" "adomain";
explicitDomain = makeHostNameTest "ahost" "adomain" "ahost.adomain";
}
1 change: 1 addition & 0 deletions nixos/tests/smokeping.nix
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
sm =
{ ... }:
{
networking.domain = "example.com"; # FQDN: sm.example.com
services.smokeping = {
enable = true;
port = 8081;