universe/modules/options.nix

38 lines
1 KiB
Nix

# Heavily inspired by hlissner: https://github.com/hlissner/dotfiles/blob/master/modules/options.nix
{ config, options, lib, home-manager, ... }:
with lib;
with lib.hlissner;
{
options = with types; {
user = mkOpt attrs { };
home = mkOpt attrs { };
dotfiles = {
dir = mkOpt path (findFirst pathExists (toString ../.) [
"/etc/nixos"
]);
homeFile = mkOpt attrs { };
configFile = mkOpt attrs { };
dataFile = mkOpt attrs { };
};
env = mkOpt attrs { };
};
config = {
users.users.${config.user.name} = mkAliasDefinitions options.user;
home-manager.users.${config.user.name} = mkAliasDefinitions options.home;
home = {
home.file = mkAliasDefinitions options.dotfiles.homeFile;
xdg = {
configFile = mkAliasDefinitions options.dotfiles.configFile;
dataFile = mkAliasDefinitions options.dotfiles.dataFile;
};
};
environment.variables = mkAliasDefinitions options.env;
bud.localFlakeClone = config.dotfiles.dir;
};
}