2020-08-16 08:33:44 +00:00
|
|
|
{ config, options, lib, ... }:
|
2020-10-05 01:38:58 +00:00
|
|
|
|
2020-08-16 08:33:44 +00:00
|
|
|
with lib;
|
2020-10-05 01:38:58 +00:00
|
|
|
|
|
|
|
let
|
2020-10-25 15:49:14 +00:00
|
|
|
mkOptionStr = value:
|
|
|
|
mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = value;
|
|
|
|
};
|
2020-08-16 08:33:44 +00:00
|
|
|
in {
|
2020-08-06 15:35:49 +00:00
|
|
|
imports = [
|
2020-08-16 08:33:44 +00:00
|
|
|
<home-manager/nixos>
|
|
|
|
|
2020-08-06 15:35:49 +00:00
|
|
|
./desktop
|
|
|
|
./dev
|
2020-10-05 01:38:58 +00:00
|
|
|
./drivers
|
2020-08-06 15:35:49 +00:00
|
|
|
./editors
|
|
|
|
./shell
|
2020-08-16 08:33:44 +00:00
|
|
|
./services
|
|
|
|
./themes
|
2020-08-06 15:35:49 +00:00
|
|
|
];
|
2020-08-16 08:33:44 +00:00
|
|
|
|
|
|
|
options = {
|
|
|
|
my = {
|
|
|
|
# Personal details
|
|
|
|
username = mkOptionStr "foo-dogsquared";
|
|
|
|
email = mkOptionStr "foo.dogsquared@gmail.com";
|
|
|
|
|
|
|
|
# Convenience aliases
|
2020-10-25 15:49:14 +00:00
|
|
|
home =
|
|
|
|
mkOption { type = options.home-manager.users.type.functor.wrapped; };
|
2020-10-05 01:38:58 +00:00
|
|
|
user = mkOption { type = options.users.users.type; };
|
2020-08-16 08:33:44 +00:00
|
|
|
packages = mkOption { type = with types; listOf package; };
|
|
|
|
|
|
|
|
# Environment
|
|
|
|
env = mkOption {
|
2020-10-25 15:49:14 +00:00
|
|
|
type = with types;
|
|
|
|
attrsOf (either (either str path) (listOf (either str path)));
|
|
|
|
apply = mapAttrs (n: v:
|
|
|
|
if isList v then
|
|
|
|
concatMapStringsSep ":" (x: toString x) v
|
|
|
|
else
|
|
|
|
(toString v));
|
2020-08-16 08:33:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
alias = mkOption {
|
|
|
|
type = with types; nullOr (attrsOf (nullOr (either str path)));
|
|
|
|
};
|
|
|
|
|
|
|
|
zsh = {
|
|
|
|
rc = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Zsh lines to be written to $XDG_CONFIG_HOME/zsh/extra.zshrc and
|
|
|
|
sourced by $XDG_CONFIG_HOME/zsh/.zshrc
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
env = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Zsh lines to be written to $XDG_CONFIG_HOME/zsh/extra.zshenv and
|
|
|
|
sourced by $XDG_CONFIG_HOME/zsh/.zshenv
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
# Convenience aliases
|
2020-10-25 15:49:14 +00:00
|
|
|
home-manager.users.${config.my.username} =
|
|
|
|
mkAliasDefinitions options.my.home;
|
2020-08-18 16:48:02 +00:00
|
|
|
home-manager.useGlobalPkgs = true;
|
2020-08-16 08:33:44 +00:00
|
|
|
users.users.${config.my.username} = mkAliasDefinitions options.my.user;
|
|
|
|
my.user.packages = config.my.packages;
|
|
|
|
|
|
|
|
# PATH should always start with its old value
|
|
|
|
my.env.PATH = [ <config/bin> "$PATH" ];
|
|
|
|
|
|
|
|
# Put the configured custom environment variables (config.my.env) into initialization phase.
|
2020-10-25 15:49:14 +00:00
|
|
|
environment.extraInit = let
|
|
|
|
exportLines =
|
|
|
|
mapAttrsToList (key: value: ''export ${key}="${value}"'') config.my.env;
|
|
|
|
in ''
|
2020-08-16 08:33:44 +00:00
|
|
|
export XAUTHORITY=/tmp/XAUTHORITY
|
|
|
|
[ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY"
|
|
|
|
|
|
|
|
${concatStringsSep "\n" exportLines}
|
2020-10-25 15:49:14 +00:00
|
|
|
'';
|
2020-08-16 08:33:44 +00:00
|
|
|
|
|
|
|
my.home.xdg.configFile = {
|
2020-10-25 15:49:14 +00:00
|
|
|
"zsh/.zshrc".text = let
|
|
|
|
aliasLines = mapAttrsToList (key: value: ''alias ${key}="${value}"'')
|
|
|
|
config.my.alias;
|
|
|
|
in ''
|
|
|
|
# This file is autogenerated, do not edit it!
|
|
|
|
${concatStringsSep "\n" aliasLines}
|
|
|
|
${config.my.zsh.rc}
|
|
|
|
'';
|
2020-08-18 16:48:02 +00:00
|
|
|
"zsh/.zshenv".text = ''
|
2020-08-16 08:33:44 +00:00
|
|
|
# This file is autogenerated, please do not edit it!
|
|
|
|
${config.my.zsh.env}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-08-06 15:35:49 +00:00
|
|
|
}
|