{ config, lib, pkgs, ... }:

with lib;
# Config common to all hosts, which don't belong anywhere else
{
  config = let
    hashed-build-seed = pkgs.stdenv.mkDerivation {
      name = "build-seed-hash";

      phases = [ "installPhase" ];

      buildInputs = with pkgs; [ coreutils ];

      installPhase = ''
        echo "${config.instance.build-seed}" | sha1sum | grep -o "^[^ ]*" > $out
      '';
    };
  in {
    nix.nixPath = lib.mkBefore [ "/nix/var/nix/profiles/per-user/$USER/channels" ];

    environment.etc = {
      build-timestamp.text = toString config.instance.build-timestamp;
      "build-seed.sha1sum".source = "${hashed-build-seed}";
    };
  };
}