A new start
This commit is contained in:
commit
f4e2368893
93 changed files with 7621 additions and 0 deletions
49
packages/nixos-hosts/default.nix
Normal file
49
packages/nixos-hosts/default.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ lib
|
||||
, writeText
|
||||
, writeShellApplication
|
||||
, substituteAll
|
||||
, gum
|
||||
, inputs
|
||||
, hosts ? { }
|
||||
, ...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mapAttrsToList concatStringsSep;
|
||||
inherit (lib.metacfg) override-meta;
|
||||
|
||||
substitute = args: builtins.readFile (substituteAll args);
|
||||
|
||||
formatted-hosts = mapAttrsToList
|
||||
(name: host: "${name},${host.pkgs.system}")
|
||||
hosts;
|
||||
|
||||
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 = "";
|
||||
|
||||
runtimeInputs = [
|
||||
gum
|
||||
];
|
||||
};
|
||||
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue