2024-02-11 07:16:25 +00:00
|
|
|
# All of the functions suitable only for NixOS.
|
2024-02-28 10:44:27 +00:00
|
|
|
{ pkgs, config, lib }:
|
2022-07-09 05:46:06 +00:00
|
|
|
|
|
|
|
rec {
|
2022-12-10 10:47:34 +00:00
|
|
|
# This is only used for home-manager users without a NixOS user counterpart.
|
2022-07-09 05:54:05 +00:00
|
|
|
mapHomeManagerUser = user: settings:
|
|
|
|
let
|
2022-08-06 05:58:24 +00:00
|
|
|
homeDirectory = "/home/${user}";
|
2022-07-09 05:54:05 +00:00
|
|
|
defaultUserConfig = {
|
2024-02-25 14:27:05 +00:00
|
|
|
extraGroups = pkgs.lib.mkDefault [ "wheel" ];
|
|
|
|
createHome = pkgs.lib.mkDefault true;
|
|
|
|
home = pkgs.lib.mkDefault homeDirectory;
|
|
|
|
isNormalUser = pkgs.lib.mkForce true;
|
2022-07-09 05:54:05 +00:00
|
|
|
};
|
2022-11-19 03:05:31 +00:00
|
|
|
in
|
2023-10-03 13:33:16 +00:00
|
|
|
({ lib, ... }: {
|
2022-08-06 05:58:24 +00:00
|
|
|
home-manager.users."${user}" = { ... }: {
|
2023-10-28 04:23:24 +00:00
|
|
|
imports = [
|
|
|
|
{
|
|
|
|
home.username = user;
|
|
|
|
home.homeDirectory = homeDirectory;
|
|
|
|
}
|
|
|
|
|
2024-02-11 07:16:25 +00:00
|
|
|
../configs/home-manager/${user}
|
2023-10-28 04:23:24 +00:00
|
|
|
];
|
2022-08-06 05:58:24 +00:00
|
|
|
};
|
2023-10-03 13:33:16 +00:00
|
|
|
|
|
|
|
users.users."${user}" = lib.mkMerge [
|
|
|
|
defaultUserConfig
|
|
|
|
settings
|
|
|
|
];
|
|
|
|
});
|
2024-02-28 10:44:27 +00:00
|
|
|
|
|
|
|
# Checks if the NixOS configuration is part of the nixos-generator build.
|
|
|
|
# Typically, we just check if there's a certain attribute that is imported
|
|
|
|
# from it.
|
|
|
|
hasNixosFormat =
|
|
|
|
pkgs.lib.hasAttrByPath [ "formatAttr" ] config;
|
|
|
|
|
|
|
|
# Checks if the NixOS config is being built for a particular format.
|
|
|
|
isFormat = format:
|
|
|
|
hasNixosFormat && config.formatAttr == format;
|
2022-07-09 05:46:06 +00:00
|
|
|
}
|