72 lines
2.0 KiB
Nix
72 lines
2.0 KiB
Nix
{ config, options, lib, home-manager, ... }:
|
|
|
|
with lib;
|
|
with lib.my;
|
|
{
|
|
options = with types; {
|
|
user = mkOpt attrs {};
|
|
|
|
home = {
|
|
file = mkOpt' attrs {} "Files to place directly in $HOME";
|
|
configFile = mkOpt' attrs {} "Files to place in $XDG_CONFIG_HOME";
|
|
dataFile = mkOpt' attrs {} "Files to place in $XDG_DATA_HOME";
|
|
};
|
|
|
|
env = mkOption {
|
|
# env = { PATH = ["$PATH" ./test]; TEST = "test"; }
|
|
type = attrsOf (oneOf [ str path (listOf (either str path)) ]);
|
|
# env = { PATH = "$PATH:./test"; TEST = "test"; }
|
|
apply = mapAttrs
|
|
(n: v: if isList v
|
|
then concatMapStringsSep ":" (x: toString x) v
|
|
else (toString v));
|
|
default = {};
|
|
description = "Set environment variables that will be joined by a colon";
|
|
};
|
|
};
|
|
|
|
config = {
|
|
user = let name = "marc"; in {
|
|
inherit name;
|
|
description = "The primary user account";
|
|
extraGroups = [ "wheel" ];
|
|
isNormalUser = true;
|
|
home = "/home/${name}";
|
|
group = "users";
|
|
uid = 1000;
|
|
};
|
|
|
|
home-manager = {
|
|
# extraSpecialArgs = { inherit inputs; };
|
|
useGlobalPkgs = true;
|
|
useUserPackages = true;
|
|
|
|
users.${config.user.name} = {
|
|
home = {
|
|
file = mkAliasDefinitions options.home.file;
|
|
# Necessary for home-manager to work with flakes, otherwise it will
|
|
# look for a nixpkgs channel.
|
|
stateVersion = config.system.stateVersion;
|
|
};
|
|
xdg = {
|
|
configFile = mkAliasDefinitions options.home.configFile;
|
|
dataFile = mkAliasDefinitions options.home.dataFile;
|
|
};
|
|
};
|
|
};
|
|
|
|
users.users.${config.user.name} = mkAliasDefinitions options.user;
|
|
|
|
nix.settings = let users = [ "root" config.user.name ]; in {
|
|
trusted-users = users;
|
|
allowed-users = users;
|
|
};
|
|
|
|
env.PATH = [ "$PATH" ];
|
|
|
|
environment.extraInit =
|
|
concatStringsSep "\n"
|
|
(mapAttrsToList (n: v: "export ${n}=\"${v}\"") config.env);
|
|
};
|
|
}
|