refactor(base profile): move base profile configurations into modules

This commit is contained in:
ooks-io 2024-04-01 15:00:37 +13:00
parent 51e9493c62
commit 692b18c0f6
7 changed files with 124 additions and 63 deletions

View file

@ -1,7 +1,20 @@
{ lib, ... }:
{
imports = [
./fonts
./monitors
./wallpaper
./nix
./userDirs
./home
./nixColors
];
options.homeModules.config = {
nix.enable = lib.mkEnableOption "enable nix configuration module";
nixColors.enable = lib.mkEnableOption "enable nixColors configuration module";
home.enable = lib.mkEnableOption "enable home configuration module";
userDirs.enable = lib.mkEnableOption "enable userDirs configuration module";
};
}

View file

@ -0,0 +1,29 @@
{ lib, config, ... }:
let
cfg = config.homeModules.config.home;
in
{
config = lib.mkIf cfg.enable {
programs.home-manager.enable = true;
home = {
username = lib.mkDefault "ooks";
homeDirectory = lib.mkDefault "/home/${config.home.username}";
stateVersion = lib.mkDefault "22.05";
sessionPath = [ "${config.home.homeDirectory}/.local/bin" ];
sessionVariables = {
TZ = "Pacific/Auckland";
};
};
# to save space
manual = {
html.enable = false;
json.enable = false;
manpages.enable = true;
};
};
}

View file

@ -0,0 +1,26 @@
{ lib, config, pkgs, outputs, ... }:
let
cfg = config.homeModules.config.nix;
in
{
config = lib.mkIf cfg.enable {
nixpkgs = {
overlays = builtins.attrValues outputs.overlays;
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
};
nix = {
package = lib.mkDefault pkgs.nix;
settings = {
experimental-features = [ "nix-command" "flakes" "repl-flake" ];
warn-dirty = false;
};
};
};
}

View file

@ -0,0 +1,30 @@
{ lib, config, inputs, pkgs, ... }:
let
cfg = config.homeModules.config.nixColors;
inherit (inputs.nix-colors) colorSchemes;
inherit (inputs.nix-colors.lib-contrib { inherit pkgs; }) nixWallpaperFromScheme;
in
{
imports = [ inputs.nix-colors.homeManagerModule ];
config = lib.mkIf cfg.enable {
colorscheme = lib.mkDefault colorSchemes.gruvbox-material-dark-soft;
home.file.".colorscheme".text = config.colorscheme.slug;
wallpaper =
let
largest = f: xs: builtins.head (builtins.sort (a: b: a > b) (map f xs));
largestWidth = largest (x: x.width) config.monitors;
largestHeight = largest (x: x.height) config.monitors;
in
lib.mkDefault (nixWallpaperFromScheme
{
scheme = config.colorscheme;
width = largestWidth;
height = largestHeight;
logoScale = 4;
});
};
}

View file

@ -0,0 +1,14 @@
{ lib, config, ... }:
let
cfg = config.homeModules.config.userDirs;
in
{
config = lib.mkIf cfg.enable {
xdg.userDirs = {
enable = true;
createDirectories = true;
};
};
}

View file

@ -3,8 +3,8 @@
cfg = config.homeModules.console.utility.git;
in
{
config = {
programs.git = lib.mkIf cfg.enable {
config = lib.mkIf cfg.enable {
programs.git = {
enable = true;
package = pkgs.gitAndTools.gitFull;
userName = "ooks-io";

View file

@ -1,64 +1,29 @@
{ inputs, lib, pkgs, config, outputs, ... }:
{ lib, config, ... }:
let
cfg = config.profiles.base;
inherit (inputs.nix-colors) colorSchemes;
inherit (inputs.nix-colors.lib-contrib { inherit pkgs; }) nixWallpaperFromScheme;
in
{
imports = [
inputs.nix-colors.homeManagerModule
../../modules
../../secrets
];
config = lib.mkIf cfg.enable {
nixpkgs = {
overlays = builtins.attrValues outputs.overlays;
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
};
nix = {
package = lib.mkDefault pkgs.nix;
settings = {
experimental-features = [ "nix-command" "flakes" "repl-flake" ];
warn-dirty = false;
};
};
programs = {
home-manager.enable = true;
git.enable = true;
};
home = {
username = lib.mkDefault "ooks";
homeDirectory = lib.mkDefault "/home/${config.home.username}";
stateVersion = lib.mkDefault "22.05";
sessionPath = [ "$HOME/.local/bin" ];
sessionVariables = {
FLAKE = "$HOME/Coding/nix/ooks-io/nix";
SCRIPTS = "$HOME/Coding/sh/scripts";
TZ = "Pacific/Auckland";
};
};
xdg.userDirs = {
enable = true;
createDirectories = true;
extraConfig = {
XDG_CODE_DIR = "${config.home.homeDirectory}/Coding";
XDG_SCREENSHOTS_DIR = "${config.xdg.userDirs.pictures}/Screenshots";
XDG_NOTES_DIR = "${config.xdg.userDirs.documents}/Notes";
XDG_RECORDINGS_DIR = "${config.xdg.userDirs.videos}/Recordings";
};
};
programs.home-manager.enable = true;
xdg.portal.enable = true;
homeModules = {
sops.enable = true;
config = {
nix.enable = true;
nixColors.enable = true;
home.enable = true;
userDirs.enable = true;
};
console = {
editor.helix = {
enable = true;
@ -79,21 +44,5 @@ in
};
};
};
wallpaper =
let
largest = f: xs: builtins.head (builtins.sort (a: b: a > b) (map f xs));
largestWidth = largest (x: x.width) config.monitors;
largestHeight = largest (x: x.height) config.monitors;
in
lib.mkDefault (nixWallpaperFromScheme
{
scheme = config.colorscheme;
width = largestWidth;
height = largestHeight;
logoScale = 4;
});
colorscheme = lib.mkDefault colorSchemes.everforest;
home.file.".colorscheme".text = config.colorscheme.slug;
};
}