pub-solar-os/lib/generators.nix
Pacman99 b8f7cdbe63 improve home-manager and deploy-rs integration
move both to be setup in template
only set home-manager options if they exist
2021-05-03 19:20:41 -05:00

51 lines
1.2 KiB
Nix

{ lib, deploy }:
{
mkHomeConfigurations = nixosConfigurations:
with lib;
let
mkHomes = host: config:
mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home)
config.config.system.build.homes;
hmConfigs = mapAttrs mkHomes nixosConfigurations;
in
foldl recursiveUpdate { } (attrValues hmConfigs);
mkDeployNodes = hosts: extraConfig:
/**
Synopsis: mkNodes _nixosConfigurations_
Generate the `nodes` attribute expected by deploy-rs
where _nixosConfigurations_ are `nodes`.
**/
lib.mapAttrs
(_: config: lib.recursiveUpdate
{
hostname = config.config.networking.hostName;
profiles.system = {
user = "root";
path = deploy.lib.x86_64-linux.activate.nixos config;
};
}
extraConfig)
hosts;
mkSuites = { suites, profiles }:
let
profileSet = lib.genAttrs' profiles (path: {
name = baseNameOf path;
value = lib.mkProfileAttrs (toString path);
});
definedSuites = suites profileSet;
allProfiles = lib.collectProfiles profileSet;
in
lib.mapAttrs (_: v: lib.profileMap v) definedSuites // {
inherit allProfiles;
};
}