dotfiles/modules/common/default.nix

162 lines
4.8 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }: {
2022-05-01 23:39:50 -04:00
imports =
[ ./applications ./mail ./neovim ./programming ./repositories ./shell ];
2022-05-01 23:39:50 -04:00
2022-12-13 21:02:42 -07:00
options = {
user = lib.mkOption {
type = lib.types.str;
2022-06-19 23:44:29 -04:00
description = "Primary user of the system";
};
2022-09-09 22:16:45 -04:00
fullName = lib.mkOption {
type = lib.types.str;
description = "Human readable name of the user";
};
2022-06-19 23:44:29 -04:00
userDirs = {
# Required to prevent infinite recursion when referenced by himalaya
download = lib.mkOption {
type = lib.types.str;
description = "XDG directory for downloads";
default =
if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads";
};
};
2022-10-16 14:20:50 +00:00
identityFile = lib.mkOption {
type = lib.types.str;
2022-10-28 23:58:33 -04:00
description = "Path to existing private key file.";
2022-10-16 14:20:50 +00:00
default = "/etc/ssh/ssh_host_ed25519_key";
};
2022-06-19 23:44:29 -04:00
gui = {
enable = lib.mkEnableOption {
description = "Enable graphics.";
2022-06-19 23:44:29 -04:00
default = false;
};
2022-07-25 23:36:06 -04:00
};
theme = {
colors = lib.mkOption {
type = lib.types.attrs;
description = "Base16 color scheme.";
2022-12-21 14:18:03 -07:00
default = (import ../colorscheme/gruvbox).dark;
};
dark = lib.mkOption {
type = lib.types.bool;
description = "Enable dark mode.";
default = true;
};
2022-06-19 23:44:29 -04:00
};
homePath = lib.mkOption {
type = lib.types.path;
description = "Path of user's home directory.";
default = builtins.toPath (if pkgs.stdenv.isDarwin then
2022-06-19 23:54:16 -04:00
"/Users/${config.user}"
else
"/home/${config.user}");
};
dotfilesPath = lib.mkOption {
type = lib.types.path;
2022-05-29 13:44:45 -04:00
description = "Path of dotfiles repository.";
default = config.homePath + "/dev/personal/dotfiles";
2022-05-29 13:44:45 -04:00
};
dotfilesRepo = lib.mkOption {
type = lib.types.str;
description = "Link to dotfiles repository HTTPS URL.";
2022-06-04 10:29:36 -04:00
};
unfreePackages = lib.mkOption {
type = lib.types.listOf lib.types.str;
2022-06-04 21:08:09 -04:00
description = "List of unfree packages to allow.";
default = [ ];
};
2023-07-07 10:16:07 -06:00
hostnames = {
git = lib.mkOption {
type = lib.types.str;
description = "Hostname for git server (Gitea).";
};
metrics = lib.mkOption {
type = lib.types.str;
description = "Hostname for metrics server.";
};
prometheus = lib.mkOption {
type = lib.types.str;
description = "Hostname for Prometheus server.";
};
secrets = lib.mkOption {
type = lib.types.str;
description = "Hostname for passwords and secrets (Vaultwarden).";
};
stream = lib.mkOption {
type = lib.types.str;
description = "Hostname for video/media library (Jellyfin).";
};
content = lib.mkOption {
type = lib.types.str;
description = "Hostname for personal content system (Nextcloud).";
};
books = lib.mkOption {
type = lib.types.str;
description = "Hostname for books library (Calibre-Web).";
};
download = lib.mkOption {
type = lib.types.str;
description = "Hostname for download services.";
};
};
2022-05-29 13:44:45 -04:00
};
2022-12-13 21:02:42 -07:00
config = let stateVersion = "23.05";
2022-10-16 14:20:50 +00:00
in {
2022-05-01 23:39:50 -04:00
2023-03-03 09:39:42 -05:00
nix = {
# Enable features in Nix commands
extraOptions = ''
experimental-features = nix-command flakes
warn-dirty = false
'';
2023-04-15 10:07:59 -04:00
gc = {
automatic = true;
options = "--delete-older-than 7d";
};
2023-03-03 09:39:42 -05:00
settings = {
# Add community Cachix to binary cache
2023-07-01 15:33:24 -06:00
# Don't use with macOS because blocked by corporate firewall
2023-04-15 10:07:59 -04:00
builders-use-substitutes = true;
substituters = lib.mkIf (!pkgs.stdenv.isDarwin)
[ "https://nix-community.cachix.org" ];
trusted-public-keys = lib.mkIf (!pkgs.stdenv.isDarwin) [
2023-03-03 09:39:42 -05:00
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
# Scans and hard links identical files in the store
2023-03-22 16:20:30 -04:00
# Not working with macOS: https://github.com/NixOS/nix/issues/7273
auto-optimise-store = lib.mkIf (!pkgs.stdenv.isDarwin) true;
2023-03-03 09:39:42 -05:00
};
};
2022-05-22 19:43:46 -04:00
2022-10-16 14:20:50 +00:00
# Basic common system packages for all devices
environment.systemPackages = with pkgs; [ git vim wget curl ];
2022-05-29 13:44:45 -04:00
2022-10-16 14:20:50 +00:00
# Use the system-level nixpkgs instead of Home Manager's
home-manager.useGlobalPkgs = true;
2022-05-29 13:44:45 -04:00
2022-10-16 14:20:50 +00:00
# Install packages to /etc/profiles instead of ~/.nix-profile, useful when
# using multiple profiles for one user
home-manager.useUserPackages = true;
2022-05-22 19:43:46 -04:00
2022-10-16 14:20:50 +00:00
# Allow specified unfree packages (identified elsewhere)
# Retrieves package object based on string name
nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) config.unfreePackages;
2022-06-04 21:08:09 -04:00
2022-10-16 14:20:50 +00:00
# Pin a state version to prevent warnings
home-manager.users.${config.user}.home.stateVersion = stateVersion;
home-manager.users.root.home.stateVersion = stateVersion;
2022-05-22 19:43:46 -04:00
2022-10-16 14:20:50 +00:00
};
2022-05-01 23:39:50 -04:00
}