liminix/modules/hostname.nix

32 lines
773 B
Nix
Raw Permalink Normal View History

2023-03-08 23:11:59 +01:00
{ lib, pkgs, config, ...}:
let
inherit (lib) mkOption types;
in {
options = {
hostname = mkOption {
2023-08-12 22:13:22 +02:00
description = ''
System hostname of the device, as returned by gethostname(2). May or
may not correspond to any name it's reachable at on any network.
'';
2023-03-08 23:11:59 +01:00
default = "liminix";
type = types.nonEmptyStr;
};
2024-09-27 16:18:13 +02:00
hostname-script = mkOption {
description = ''
Script that outputs the system hostname on stdin.
'';
default = pkgs.writeScript "hostname-gen" ''
#!/bin/sh
echo ${config.hostname}
'';
defaultText = ''
pkgs.writeScript "hostname-gen" '''
#!/bin/sh
echo ''${config.hostname}
'''
'';
type = types.package;
2023-03-08 23:11:59 +01:00
};
};
}