nixfiles/home-modules/common.nix

92 lines
2.2 KiB
Nix
Raw Normal View History

2022-02-13 23:06:31 +00:00
{ lib, pkgs, inputs, isStandalone, config, ... }:
let
inherit (lib) mkMerge mkIf mkDefault mkForce;
in
mkMerge [
{
nix.registry = {
pkgs = {
to = {
type = "path";
path = toString pkgs.path;
};
exact = true;
};
};
2022-02-13 23:06:31 +00:00
programs = {
# Even when enabled this will only be actually installed in standalone mode
# Note: `home-manager.path` is for telling home-manager is installed and setting it in NIX_PATH, which we should
# never care about.
home-manager.enable = true;
2022-02-13 23:06:31 +00:00
bash = {
# This not only installs bash but has home-manager control .bashrc and friends
enable = mkDefault true;
2022-02-13 23:06:31 +00:00
};
2022-02-14 00:56:43 +00:00
direnv = {
enable = mkDefault true;
nix-direnv.enable = true;
stdlib =
''
# addition to nix-direnv's use_nix that registers outputs as gc roots (as well as the .drv)
use_nix_outputs() {
local layout_dir drv deps
layout_dir="$(direnv_layout_dir)"
drv="$layout_dir/drv"
deps="$layout_dir/deps"
if [ ! -e "$deps" ] || (( "$(stat --format=%Z "$drv")" > "$(stat --format=%Z "$deps")" )); then
rm -rf "$deps"
mkdir -p "$deps"
nix-store --indirect --add-root "$deps/out" --realise $(nix-store --query --references "$drv") > /dev/null
log_status renewed outputs gc roots
fi
}
'';
};
htop = {
enable = true;
settings = {};
};
2022-02-13 23:06:31 +00:00
};
home = {
packages = with pkgs; [
tree
iperf3
];
2022-02-15 01:08:00 +00:00
sessionVariables = {
EDITOR = "vim";
};
language.base = mkDefault "en_IE.UTF-8";
2022-02-13 23:06:31 +00:00
# The flake passes a default setting, but we don't care about that
stateVersion = mkForce "22.05";
};
}
(mkIf isStandalone {
# Note: this only applies outside NixOS where home-manager imports nixpkgs internally
nixpkgs = {
overlays = [
inputs.nix.overlay
];
config = {
allowUnfree = true;
};
};
2022-02-15 01:08:00 +00:00
fonts.fontconfig.enable = true;
2022-02-13 23:06:31 +00:00
home = {
packages = with pkgs; [
nix
];
};
})
]