# A NixOS expression that evaluates to top-level system derivation for a node.
{
  # The gridname this node belongs to.  This should correspond to the
  # subdirectory of `morph/grid/` this corresponds to.
  gridname,
  # The hostname of this node.
  hostname,
}:
let
  branch = {
    local = "develop";
    testing = "staging";
    production = "production";
  }.${gridname};
  checkout = builtins.fetchTarball {
    name = "private.storage";
    url = "https://whetstone.privatestorage.io/privatestorage/PrivateStorageio/-/archive/${branch}/privatestorage.tar.bz2";
  };
  pkgs = import "${checkout}/nixpkgs-2105.nix" {};

  morph = (import "${pkgs.morph.lib}/eval-machines.nix") {
    networkExpr = "${checkout}/morph/grid/${gridname}/grid.nix";
  };
in
  morph.nodes.${hostname}.config.system.build.toplevel