Refactor back to a more modular configuration

This commit is contained in:
Oliver Davies 2025-04-23 14:19:05 +01:00
parent 19ea08a716
commit 2bedd41d83
178 changed files with 2245 additions and 1847 deletions

122
hosts/common/default.nix Normal file
View file

@ -0,0 +1,122 @@
{
hostname,
inputs,
outputs,
pkgs,
self,
stateVersion,
system,
username,
...
}:
{
imports = [
./users
inputs.home-manager.nixosModules.home-manager
outputs.nixosModules.default
];
nix = {
settings = {
auto-optimise-store = true;
download-buffer-size = "104857600";
experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false;
};
};
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
environment.systemPackages = with pkgs; [
cryptsetup
fastfetch
mermaid-cli
mkcert
passmenu-otp
(pass.withExtensions (
e: with e; [
passExtensions.pass-audit
passExtensions.pass-import
passExtensions.pass-otp
passExtensions.pass-update
]
))
];
home-manager = {
backupFileExtension = "backup";
extraSpecialArgs = {
inherit
hostname
inputs
outputs
self
system
username
;
};
useGlobalPkgs = true;
useUserPackages = true;
users."${username}" = import ./home.nix;
};
nixpkgs = {
config = {
allowUnfree = true;
permittedInsecurePackages = [ "electron-27.3.11" ];
};
overlays = [
inputs.nur.overlays.default
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.stable-packages
];
};
nix.extraOptions = ''
trusted-users = root ${username}
'';
networking.hostName = hostname;
time.timeZone = "Europe/London";
i18n = {
defaultLocale = "en_GB.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "en_GB.UTF-8";
LC_IDENTIFICATION = "en_GB.UTF-8";
LC_MEASUREMENT = "en_GB.UTF-8";
LC_MONETARY = "en_GB.UTF-8";
LC_NAME = "en_GB.UTF-8";
LC_NUMERIC = "en_GB.UTF-8";
LC_PAPER = "en_GB.UTF-8";
LC_TELEPHONE = "en_GB.UTF-8";
LC_TIME = "en_GB.UTF-8";
};
};
console.keyMap = "uk";
security.sudo.wheelNeedsPassword = false;
system.stateVersion = stateVersion;
}

108
hosts/common/home.nix Normal file
View file

@ -0,0 +1,108 @@
{
config,
inputs,
outputs,
system,
...
}:
let
pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
outputs.overlays.additions
outputs.overlays.stable-packages
];
};
inherit (pkgs) lib;
inherit (config.xdg)
cacheHome
configHome
dataHome
stateHome
;
in
{
imports = [
outputs.homeManagerModules.default
];
home.username = "opdavies";
home.homeDirectory = "/home/${config.home.username}";
home.packages = with pkgs; [
cachix
delta
entr
gcc
git
git-crypt
gnupg
inotify-tools
jq
killall
lua
mob
pv
simple-http-server
sshs
tldr
tree
tree-sitter
unzip
w3m
watchexec
wget
xclip
xdg-utils
zbar
];
programs.home-manager.enable = true;
home.sessionVariables = {
EDITOR = "nvim";
IMAPFILTER_HOME = "${configHome}/imapfilter";
LANG = "en_GB.UTF-8";
LC_ALL = "en_GB.UTF-8";
LC_CTYPE = "en_GB.UTF-8";
PASSWORD_STORE_DIR = "${dataHome}/pass";
PATH = lib.concatStringsSep ":" [
"$PATH"
"$HOME/go/bin"
"./vendor/bin"
"./node_modules/.bin"
];
PULUMI_SKIP_UPDATE_CHECK = "true";
W3M_DIR = "${stateHome}/w3m";
WGETRC = "${configHome}/wgetrc";
XDG_CONFIG_HOME = config.xdg.configHome;
XDG_DATA_HOME = dataHome;
XDG_STATE_HOME = stateHome;
};
xdg = {
configFile = {
"${config.home.sessionVariables.WGETRC}".text = ''
hsts-file = "${cacheHome}/wget-hsts"
'';
};
userDirs = {
enable = true;
extraConfig = {
XDG_REPOS_DIR = "${config.home.homeDirectory}/Code";
};
};
};
# Nicely reload system units when changing configs.
systemd.user.startServices = "sd-switch";
home.stateVersion = "22.05"; # Please read the comment before changing.
}

View file

@ -0,0 +1,5 @@
{
imports = [
./opdavies.nix
];
}

View file

@ -0,0 +1,7 @@
{ config, ... }:
{
users.users.opdavies = { };
home-manager.users.opdavies = import ../../../home/opdavies/${config.networking.hostName}.nix;
}