Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,26 @@ in rec {
in
lib.optional (builtins.hasAttr hostname homesNested) module;

homesGeneric =
let
getEntryPath =
_username: userEntry:
if builtins.pathExists (userEntry.path + "/home-configuration.nix") then
userEntry.path + "/home-configuration.nix"
else
# If we decide to add users/<username>.nix, it's as simple as
# testing `if userEntry.type == "regular"`
null;

mkUsers =
userEntries:
let
users = lib.mapAttrs getEntryPath userEntries;
in
lib.filterAttrs (_name: value: value != null) users;
in
importDir (src + "/users") mkUsers;

# Attribute set mapping hostname (defined in hosts/) to a set of home
# configurations (modules) for that host. If a host has no home
# configuration, it will be omitted from the set. Likewise, if the user
Expand Down Expand Up @@ -362,13 +382,17 @@ in rec {
eachSystem (
{ pkgs, system, ... }:
{
homeConfigurations = lib.mapAttrs (
_name: homeData:
mkHomeConfiguration {
inherit (homeData) modulePath username;
inherit pkgs system;
}
) homesFlat;
homeConfigurations =
lib.mapAttrs (
_name: homeData:
mkHomeConfiguration {
inherit (homeData) modulePath username;
inherit pkgs system;
}
) homesFlat
// lib.mapAttrs (
username: modulePath: mkHomeConfiguration { inherit pkgs username modulePath system; }
) homesGeneric;
}
);

Expand Down Expand Up @@ -693,7 +717,7 @@ in rec {
# nix3 CLI output (`packages` output expects flat attrset)
# FIXME: Find another way to make this work without introducing legacyPackages.
# May involve changing upstream home-manager.
legacyPackages = lib.optionalAttrs (homesNested != { }) standaloneHomeConfigurations;
legacyPackages = standaloneHomeConfigurations;

darwinConfigurations = lib.mapAttrs (_: x: x.value) (hostsByCategory.darwinConfigurations or { });
nixosConfigurations = lib.mapAttrs (_: x: x.value) (hostsByCategory.nixosConfigurations or { });
Expand Down