nixos: cosmetic refactor of environment.etc."hostid"

Create the file using attrset instead of list, to make it easier to
later provide other files in the same module.
This commit is contained in:
Bjørn Forsman 2017-01-01 16:41:34 +01:00
parent 31dc66a55a
commit 49d444416c

View file

@ -910,20 +910,16 @@ in
domainname "${cfg.domain}"
'';
environment.etc = mkIf (cfg.hostId != null)
[
{
target = "hostid";
source = pkgs.runCommand "gen-hostid" {} ''
hi="${cfg.hostId}"
${if pkgs.stdenv.isBigEndian then ''
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > $out
'' else ''
echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > $out
''}
'';
}
];
environment.etc."hostid" = mkIf (cfg.hostId != null)
{ source = pkgs.runCommand "gen-hostid" {} ''
hi="${cfg.hostId}"
${if pkgs.stdenv.isBigEndian then ''
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > $out
'' else ''
echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > $out
''}
'';
};
environment.systemPackages =
[ pkgs.host