dotfiles/.config/nixpkgs/hostname.nix

22 lines
425 B
Nix
Raw Normal View History

2021-08-14 13:36:11 -04:00
lib:
let
inherit (builtins) currentSystem;
inherit (lib) maybeEnv fileContents;
inherit (lib.systems.elaborate { system = currentSystem; }) isLinux isDarwin;
in
maybeEnv "HOST" (fileContents (
if !isDarwin then
/etc/hostname
else
derivation {
name = "hostname";
system = currentSystem;
builder = "/bin/sh";
args = [ "-c" "/usr/sbin/scutil --get LocalHostName > $out" ];
}
))