liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

hostname.nix (587B)


      1 {
      2   lib,
      3   pkgs,
      4   config,
      5   ...
      6 }:
      7 let
      8   inherit (lib) mkOption types;
      9   inherit (pkgs.liminix.services) oneshot;
     10 in
     11 {
     12   options = {
     13     hostname = mkOption {
     14       description = ''
     15         System hostname of the device, as returned by gethostname(2). May or
     16         may not correspond to any name it's reachable at on any network.
     17       '';
     18       default = "liminix";
     19       type = types.nonEmptyStr;
     20     };
     21   };
     22   config = {
     23     services.hostname = oneshot {
     24       name = "hostname";
     25       up = "echo ${config.hostname} > /proc/sys/kernel/hostname";
     26       down = "true";
     27     };
     28   };
     29 }