hosts/data.cs.purdue.edu: init

This commit is contained in:
Infinidoge 2023-09-08 22:31:38 -04:00
parent 33e3b52b2f
commit 93f0bd5357
4 changed files with 56 additions and 0 deletions

View file

@ -1,5 +1,6 @@
{ lib }:
# Importers from digga: https://github.com/divnix/digga/blob/main/src/importers.nix
# Plus the mkHomeConfigurations generator from digga: https://github.com/divnix/digga/blob/main/src/generators.nix
let
flattenTree =
/*
@ -120,9 +121,45 @@ let
lib.filterAttrs (n: v: v != { }) (lib.mapAttrs' collect files);
flattenLeaves = dir: flattenTree (rakeLeaves dir);
getFqdn = c:
let
net = c.config.networking;
fqdn =
if (net ? domain) && (net.domain != null)
then "${net.hostName}.${net.domain}"
else net.hostName;
in
fqdn;
in
{
inherit rakeLeaves flattenTree flattenLeaves;
leaves = dir: builtins.attrValues (flattenLeaves dir);
mkHomeConfigurations = systemConfigurations:
/*
*
Synopsis: mkHomeConfigurations _systemConfigurations_
Generate the `homeConfigurations` attribute expected by `home-manager` cli
from _nixosConfigurations_ or _darwinConfigurations_ in the form
_user@hostname_.
*
*/
let
op = attrs: c:
attrs
// (
lib.mapAttrs'
(user: v: {
name = "${user}@${getFqdn c}";
value = v.home;
})
c.config.home-manager.users
);
mkHmConfigs = lib.foldl op { };
in
mkHmConfigs (builtins.attrValues systemConfigurations);
}