2024-11-19 10:31:29 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
writeText,
|
|
|
|
writeShellApplication,
|
|
|
|
substituteAll,
|
|
|
|
gum,
|
|
|
|
inputs,
|
|
|
|
hosts ? { },
|
|
|
|
...
|
2024-03-21 15:00:36 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mapAttrsToList concatStringsSep;
|
|
|
|
inherit (lib.metacfg) override-meta;
|
|
|
|
|
|
|
|
substitute = args: builtins.readFile (substituteAll args);
|
|
|
|
|
2024-11-19 10:31:29 +01:00
|
|
|
formatted-hosts = mapAttrsToList (name: host: "${name},${host.pkgs.system}") hosts;
|
2024-03-21 15:00:36 +01:00
|
|
|
|
|
|
|
hosts-csv = writeText "hosts.csv" ''
|
|
|
|
Name,System
|
|
|
|
${concatStringsSep "\n" formatted-hosts}
|
|
|
|
'';
|
|
|
|
|
|
|
|
nixos-hosts = writeShellApplication {
|
|
|
|
name = "nixos-hosts";
|
|
|
|
|
|
|
|
text = substitute {
|
|
|
|
src = ./nixos-hosts.sh;
|
|
|
|
|
|
|
|
help = ./help;
|
|
|
|
hosts = if hosts == { } then "" else hosts-csv;
|
|
|
|
};
|
|
|
|
|
|
|
|
checkPhase = "";
|
|
|
|
|
2024-11-19 10:31:29 +01:00
|
|
|
runtimeInputs = [ gum ];
|
2024-03-21 15:00:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
new-meta = with lib; {
|
|
|
|
description = "A helper to list all of the NixOS hosts available from your flake.";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ jakehamilton ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
override-meta new-meta nixos-hosts
|