refactor arguments to options

also change theme to colorscheme
This commit is contained in:
Noah Masur 2022-05-05 23:01:56 -04:00
parent 531c78ebe0
commit 417623965e
33 changed files with 415 additions and 347 deletions

View File

@ -12,38 +12,35 @@
outputs = { self, nixpkgs, home-manager }:
let
identity = {
globals = {
user = "noah";
name = "Noah Masur";
hostname = "nixos";
fullName = "Noah Masur";
passwordHash =
"$6$J15o3OLElCEncVB3$0FW.R7YFBMgtBp320kkZO.TdKvYDLHmnP6dgktdrVYCC3LUvzXj0Fj0elR/fXo9geYwwWi.EAHflCngL5T.3g/";
gitEmail = "7386960+nmasur@users.noreply.github.com";
};
gui = {
enable = false;
font = {
package = "victor-mono";
name = "Victor Mono";
};
theme = "gruvbox";
colorscheme = (import ./modules/colorscheme/gruvbox);
wallpaper = ./modules/theme/gruvbox/gray-forest.jpg;
gtkTheme = "Adwaita-dark";
};
};
in {
nixosConfigurations = {
desktop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
gui = gui // { enable = true; };
inherit identity;
};
specialArgs = { };
modules = [
globals
{
networking.hostName = "desktop";
gui.enable = true;
}
home-manager.nixosModules.home-manager
{ networking.hostName = "desktop"; }
./hosts/desktop/hardware-configuration.nix
./modules/common.nix
./modules/desktop
./modules/theme
./modules/hardware
./modules/system
./modules/desktop
./modules/shell
./modules/gaming
./modules/services/keybase.nix

View File

@ -1,8 +1,8 @@
{ pkgs, lib, gui, identity, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
config = lib.mkIf config.gui.enable {
nixpkgs.config.allowUnfree = true;
home-manager.users.${identity.user} = {
home-manager.users.${config.user} = {
home.packages = with pkgs; [ _1password-gui ];
};
};

View File

@ -1,6 +1,6 @@
{ config, pkgs, identity, gui, ... }: {
{ config, pkgs, ... }: {
home-manager.users.${identity.user} = {
home-manager.users.${config.user} = {
xsession.windowManager.i3.config.terminal = "alacritty";
programs.alacritty = {
enable = true;
@ -14,12 +14,15 @@
x = 20;
y = 20;
};
opacity = config.theme.opacity;
opacity = 1.0;
};
scrolling.history = 10000;
font = {
size = 14.0;
normal = { family = gui.font.name; };
normal = {
family =
builtins.head config.fonts.fontconfig.defaultFonts.monospace;
};
};
key_bindings = [
{
@ -39,37 +42,36 @@
action = "ToggleViMode";
}
];
colors = config.theme.colors;
# colors = {
# primary = {
# background = "#282828";
# foreground = "#d5c4a1";
# };
# cursor = {
# text = "#1d2021";
# cursor = "#d5c4a1";
# };
# normal = {
# black = "#1d2021";
# red = "#fb4934";
# green = "#b8bb26";
# yellow = "#fabd2f";
# blue = "#83a598";
# magenta = "#d3869b";
# cyan = "#8ec07c";
# white = "#d5c4a1";
# };
# bright = {
# black = "#665c54";
# red = "#fe8019";
# green = "#3c3836";
# yellow = "#504945";
# blue = "#bdae93";
# magenta = "#ebdbb2";
# cyan = "#d65d0e";
# white = "#fbf1c7";
# };
# };
colors = {
primary = {
background = config.gui.colorscheme.base00;
foreground = config.gui.colorscheme.base05;
};
cursor = {
text = "#1d2021";
cursor = config.gui.colorscheme.base05;
};
normal = {
black = "#1d2021";
red = config.gui.colorscheme.base08;
green = config.gui.colorscheme.base0B;
yellow = config.gui.colorscheme.base0A;
blue = config.gui.colorscheme.base0D;
magenta = config.gui.colorscheme.base0E;
cyan = config.gui.colorscheme.base0C;
white = config.gui.colorscheme.base05;
};
bright = {
black = config.gui.colorscheme.base03;
red = config.gui.colorscheme.base09;
green = config.gui.colorscheme.base01;
yellow = config.gui.colorscheme.base02;
blue = config.gui.colorscheme.base04;
magenta = config.gui.colorscheme.base06;
cyan = config.gui.colorscheme.base0F;
white = config.gui.colorscheme.base07;
};
};
draw_bold_text_with_bright_colors = false;
};
};

View File

@ -1,7 +1,7 @@
{ pkgs, lib, identity, gui, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
home-manager.users.${identity.user} = {
config = lib.mkIf config.gui.enable {
home-manager.users.${config.user} = {
nixpkgs.config.allowUnfree = true;
home.packages = with pkgs; [ discord ];
};

View File

@ -1,12 +1,12 @@
{ pkgs, lib, identity, gui, ... }:
{ config, pkgs, lib, ... }:
{
config = lib.mkIf gui.enable {
home-manager.users.${identity.user} = {
config = lib.mkIf config.gui.enable {
home-manager.users.${config.user} = {
home.packages = [ pkgs.firefox ];
gtk = {
enable = true;
theme = { name = gui.gtkTheme; };
theme = { name = config.gui.gtkTheme; };
};
};

View File

@ -1,7 +1,7 @@
{ pkgs, lib, gui, identity, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
home-manager.users.${identity.user}.home.packages = with pkgs; [
config = lib.mkIf config.gui.enable {
home-manager.users.${config.user}.home.packages = with pkgs; [
mpv # Video viewer
sxiv # Image viewer
zathura # PDF viewer

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, gui, identity, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
config = lib.mkIf config.gui.enable {
home-manager.users.${identity.user} = {
home-manager.users.${config.user} = {
home.packages = with pkgs; [ qbittorrent ];

View File

@ -0,0 +1,21 @@
{
name = "gruvbox"; # Dark, Medium
author =
"Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)";
base00 = "#282828"; # ----
base01 = "#3c3836"; # ---
base02 = "#504945"; # --
base03 = "#665c54"; # -
base04 = "#bdae93"; # +
base05 = "#d5c4a1"; # ++
base06 = "#ebdbb2"; # +++
base07 = "#fbf1c7"; # ++++
base08 = "#fb4934"; # red
base09 = "#fe8019"; # orange
base0A = "#fabd2f"; # yellow
base0B = "#b8bb26"; # green
base0C = "#8ec07c"; # aqua/cyan
base0D = "#83a598"; # blue
base0E = "#d3869b"; # purple
base0F = "#d65d0e"; # brown
}

View File

@ -1,4 +1,4 @@
{ pkgs, ... }: {
{ config, lib, pkgs, ... }: {
nix.extraOptions = "experimental-features = nix-command flakes";

View File

@ -10,11 +10,35 @@
./rofi.nix
];
options = {
launcherCommand = lib.mkOption {
type = lib.types.str;
options = with lib; {
gui = {
enable = mkEnableOption {
description = "Enable graphics";
default = false;
};
compositor.enable = mkEnableOption {
description = "Enable transparency, blur, shadows";
default = false;
};
launcherCommand = mkOption {
type = types.str;
description = "Command to use for launching";
};
gtkTheme = mkOption {
type = types.str;
description = "Theme for GTK applications";
};
colorscheme = mkOption {
type = types.attrs;
description = "Base16 color scheme";
};
wallpaper = mkOption {
type = types.path;
description = "Wallpaper background image file";
};
};
};
}

View File

@ -1,11 +1,11 @@
{ config, pkgs, lib, identity, ... }:
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.services.xserver.enable {
home-manager.users.${identity.user}.home.packages = [ pkgs.dmenu ];
launcherCommand = "${pkgs.dmenu}/bin/dmenu_run";
home-manager.users.${config.user}.home.packages = [ pkgs.dmenu ];
gui.launcherCommand = "${pkgs.dmenu}/bin/dmenu_run";
};

View File

@ -1,13 +1,12 @@
{ pkgs, lib, gui, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
config = lib.mkIf config.gui.enable {
fonts.fonts = with pkgs;
[
pkgs."${gui.font.package}" # Used for Vim and Terminal
# siji # More icons for Polybar
pkgs.victor-mono # Used for Vim and Terminal
];
fonts.fontconfig.defaultFonts.monospace = [ gui.font.name ];
fonts.fontconfig.defaultFonts.monospace = [ "Victor Mono" ];
};

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, identity, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.services.xserver.enable {
@ -15,7 +15,7 @@
playerctl # Media control
];
home-manager.users.${identity.user}.xsession.windowManager.i3 = {
home-manager.users.${config.user}.xsession.windowManager.i3 = {
enable = true;
package = pkgs.i3-gaps;
config = let
@ -40,19 +40,16 @@
};
bars = [{ command = "echo"; }]; # Disable i3bar
colors = let
background = "#2f343f";
inactiveBackground = "#2f343f";
border = "#2f343f";
inactiveBorder = "#2f343f";
# border = "#F0C674";
# inactiveBorder = "#E2B860";
text = "#f3f4f5";
inactiveText = "#676E7D";
urgentBackground = "#E53935";
# indicator = "#00ff00";
background = config.gui.colorscheme.base00;
inactiveBackground = config.gui.colorscheme.base01;
border = config.gui.colorscheme.base01;
inactiveBorder = config.gui.colorscheme.base01;
text = config.gui.colorscheme.base07;
inactiveText = config.gui.colorscheme.base04;
urgentBackground = config.gui.colorscheme.base08;
indicator = "#00000000";
in {
background = background;
background = config.gui.colorscheme.base00;
focused = {
inherit background indicator text border;
childBorder = background;
@ -117,12 +114,13 @@
# Launchers
"${modifier}+Return" = "exec alacritty";
"${modifier}+space" =
"exec --no-startup-id ${config.launcherCommand}";
"exec --no-startup-id ${config.gui.launcherCommand}";
"${modifier}+Shift+c" = "reload";
"${modifier}+Shift+r" = "restart";
"${modifier}+Shift+q" = ''
exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"'';
"${modifier}+Shift+x" = ''exec i3lock --color "#2f343f"'';
"${modifier}+Shift+x" =
''exec i3lock --color "${config.gui.colorscheme.base00}"'';
"${modifier}+Shift+t" = "exec alacritty";
# Window options
@ -202,8 +200,7 @@
};
startup = [
{
command =
"feh --bg-fill ${builtins.toString config.theme.wallpaper}";
command = "feh --bg-fill ${builtins.toString config.gui.wallpaper}";
always = true;
notification = false;
}

View File

@ -1,10 +1,11 @@
{ config, lib, identity, ... }: {
{ config, lib, ... }: {
config = lib.mkIf config.services.xserver.enable {
home-manager.users.${identity.user} = {
config =
lib.mkIf (config.services.xserver.enable && config.gui.compositor.enable) {
home-manager.users.${config.user} = {
services.picom = {
enable = false;
enable = true;
blur = true;
blurExclude = [ ];
# extraOptions = ''

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, identity, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.services.xserver.enable {
@ -6,7 +6,7 @@
fonts.fonts = with pkgs;
[ (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) ];
home-manager.users.${identity.user} = {
home-manager.users.${config.user} = {
services.polybar = {
enable = true;
@ -16,17 +16,7 @@
githubSupport = true;
};
script = "polybar &";
config = let
colors = {
background = "#282828";
background-alt = "#373B41";
foreground = "#C5C8C6";
primary = "#F0C674";
secondary = "#8ABEB7";
alert = "#A54242";
disabled = "#707880";
};
in {
config = {
"bar/main" = {
bottom = false;
width = "100%";
@ -35,14 +25,14 @@
# offset-y = -5;
# offset-y = "5%";
# dpi = 96;
background = config.theme.colors.primary.background;
foreground = config.theme.colors.primary.foreground;
background = config.gui.colorscheme.base00;
foreground = config.gui.colorscheme.base07;
line-size = "3pt";
border-top-size = 0;
border-right-size = 0;
border-left-size = 0;
border-bottom-size = "4pt";
border-color = config.theme.colors.cursor.text;
border-color = config.gui.colorscheme.base02;
padding-left = 2;
padding-right = 2;
module-margin = 1;
@ -68,17 +58,17 @@
"module/xworkspaces" = {
type = "internal/xworkspaces";
label-active = "%name%";
label-active-background = config.theme.colors.primary.foreground;
label-active-foreground = config.theme.colors.primary.background;
label-active-background = config.gui.colorscheme.base07;
label-active-foreground = config.gui.colorscheme.base00;
# label-active-underline = config.theme.colors.normal.yellow;
label-active-padding = 1;
label-occupied = "%name%";
label-occupied-padding = 1;
label-urgent = "%name%";
label-urgent-background = config.theme.colors.bright.red;
label-urgent-background = config.gui.colorscheme.base08;
label-urgent-padding = 1;
label-empty = "%name%";
label-empty-foreground = config.theme.colors.normal.white;
label-empty-foreground = config.gui.colorscheme.base06;
label-empty-padding = 1;
};
"module/xwindow" = {
@ -100,10 +90,10 @@
format-volume = "<ramp-volume> <label-volume>";
# format-volume-background = colors.background;
# label-volume-background = colors.background;
format-volume-foreground = config.theme.colors.primary.foreground;
format-volume-foreground = config.gui.colorscheme.base07;
label-volume = "%percentage%%";
label-muted = " ---";
label-muted-foreground = config.theme.colors.bright.black;
label-muted-foreground = config.gui.colorscheme.base03;
ramp-volume-0 = "";
ramp-volume-1 = "";
ramp-volume-2 = "";

View File

@ -1,16 +1,16 @@
{ config, pkgs, lib, identity, ... }:
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.services.xserver.enable {
home-manager.users.${identity.user}.programs.rofi = {
home-manager.users.${config.user}.programs.rofi = {
enable = true;
cycle = true;
location = "center";
plugins = [ pkgs.rofi-calc pkgs.rofi-emoji ];
};
launcherCommand = "${pkgs.rofi}/bin/rofi -show run";
gui.launcherCommand = "${pkgs.rofi}/bin/rofi -show run";
};

View File

@ -1,10 +1,10 @@
{ config, pkgs, lib, identity, gui, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
config = lib.mkIf config.gui.enable {
# Enable the X11 windowing system.
services.xserver = {
enable = gui.enable;
enable = config.gui.enable;
# Enable touchpad support
libinput.enable = true;
@ -15,7 +15,7 @@
enable = config.services.xserver.enable;
# Make the login screen dark
greeters.gtk.theme.name = gui.gtkTheme;
greeters.gtk.theme.name = config.gui.gtkTheme;
};
};
@ -27,7 +27,7 @@
xclip # Clipboard
];
home-manager.users.${identity.user}.programs.fish.shellAliases = {
home-manager.users.${config.user}.programs.fish.shellAliases = {
pbcopy = "xclip -selection clipboard -in";
pbpaste = "xclip -selection clipboard -out";
};

View File

@ -1,6 +1,6 @@
{ pkgs, identity, ... }: {
{ config, pkgs, ... }: {
home-manager.users.${identity.user} = {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
neovim

View File

@ -1,8 +1,9 @@
{ identity, ... }: {
home-manager.users.${identity.user} = {
{ config, ... }: {
home-manager.users.${config.user} = {
home.sessionVariables = {
NOTES_PATH = "/home/${identity.user}/dev/personal/notes";
NOTES_PATH = "/home/${config.user}/dev/personal/notes";
};
};

View File

@ -1,6 +1,6 @@
{ pkgs, lib, gui, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
config = lib.mkIf config.gui.enable {
sound.enable = true;
hardware.pulseaudio.enable = true;

View File

@ -1,4 +1,4 @@
{ lib, gui, ... }: {
{ ... }: {
imports = [
./audio.nix
@ -7,6 +7,7 @@
./monitors.nix
./mouse.nix
./networking.nix
./wifi.nix
];
}

View File

@ -1,9 +1,9 @@
{ pkgs, lib, gui, identity, ... }: {
{ config, pkgs, lib, ... }: {
# Timezone required for Redshift schedule
imports = [ ../system/timezone.nix ];
config = lib.mkIf gui.enable {
config = lib.mkIf config.gui.enable {
environment.systemPackages = with pkgs;
[
@ -23,7 +23,7 @@
hardware.i2c.enable = true;
# Grant user access to external monitors
users.users.${identity.user}.extraGroups = [ "i2c" ];
users.users.${config.user}.extraGroups = [ "i2c" ];
services.xserver.displayManager = {

View File

@ -1,6 +1,6 @@
{ pkgs, lib, gui, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf gui.enable {
config = lib.mkIf config.gui.enable {
# Mouse config
services.ratbagd.enable = true;

View File

@ -1,9 +1,5 @@
{ ... }: {
networking.wireless.enable =
true; # Enables wireless support via wpa_supplicant.
networking.wireless.userControlled.enable = true;
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.

View File

@ -0,0 +1,7 @@
{ ... }: {
networking.wireless.enable =
true; # Enables wireless support via wpa_supplicant.
networking.wireless.userControlled.enable = true;
}

View File

@ -1,10 +1,10 @@
{ pkgs, lib, identity, gui, ... }: {
{ config, pkgs, lib, ... }: {
services.keybase.enable = true;
services.kbfs.enable = true;
home-manager.users.${identity.user} = {
home.packages = [ (lib.mkIf gui.enable pkgs.keybase-gui) ];
home-manager.users.${config.user} = {
home.packages = [ (lib.mkIf config.gui.enable pkgs.keybase-gui) ];
home.file = let
ignorePatterns = ''
keybase/

View File

@ -1,8 +1,8 @@
{ pkgs, identity, ... }: {
{ config, pkgs, ... }: {
users.users.${identity.user}.shell = pkgs.fish;
users.users.${config.user}.shell = pkgs.fish;
home-manager.users.${identity.user} = {
home-manager.users.${config.user} = {
home.packages = with pkgs; [ exa fd bat ripgrep ];

View File

@ -1,22 +1,35 @@
{ config, pkgs, lib, identity, ... }:
{ config, pkgs, lib, ... }:
let home-packages = config.home-manager.users.${identity.user}.home.packages;
let home-packages = config.home-manager.users.${config.user}.home.packages;
in {
home-manager.users.root.programs.git = {
enable = true;
extraConfig.safe.directory = "/home/${identity.user}/dev/personal/dotfiles";
options = {
fullName = lib.mkOption {
type = lib.types.str;
description = "Human readable name of the user";
};
gitEmail = lib.mkOption {
type = lib.types.str;
description = "Email to use for git commits";
};
};
home-manager.users.${identity.user} = {
config = {
home-manager.users.root.programs.git = {
enable = true;
extraConfig.safe.directory = "/home/${config.user}/dev/personal/dotfiles";
};
home-manager.users.${config.user} = {
programs.git = {
enable = true;
userName = identity.name;
userEmail = identity.gitEmail;
userName = config.fullName;
userEmail = config.gitEmail;
extraConfig = {
pager = { branch = "false"; };
safe = { directory = "/home/${identity.user}/dev/personal/dotfiles"; };
safe = { directory = "/home/${config.user}/dev/personal/dotfiles"; };
pull = { ff = "only"; };
};
};
@ -94,12 +107,12 @@ in {
../../fish.configlink/functions/git-show-fuzzy.fish;
};
git-commits = {
body =
builtins.readFile ../../fish.configlink/functions/git-commits.fish;
body = builtins.readFile
../../fish.configlink/functions/git-commits.fish;
};
git-history = {
body =
builtins.readFile ../../fish.configlink/functions/git-history.fish;
body = builtins.readFile
../../fish.configlink/functions/git-history.fish;
};
git-push-upstream = {
description = "Create upstream branch";
@ -108,10 +121,12 @@ in {
};
uncommitted = {
description = "Find uncommitted git repos";
body =
builtins.readFile ../../fish.configlink/functions/uncommitted.fish;
body = builtins.readFile
../../fish.configlink/functions/uncommitted.fish;
};
};
};
};
}

View File

@ -1,15 +1,16 @@
{ pkgs, identity, ... }: {
{ config, pkgs, lib, ... }: {
imports = [ ./git.nix ];
home-manager.users.${config.user} = {
home-manager.users.${identity.user} = {
programs.gh = {
programs.gh =
lib.mkIf config.home-manager.users.${config.user}.programs.git.enable {
enable = true;
enableGitCredentialHelper = true;
settings.git_protocol = "https";
};
programs.fish = {
programs.fish =
lib.mkIf config.home-manager.users.${config.user}.programs.gh.enable {
shellAbbrs = {
ghr = "gh repo view -w";
gha =
@ -29,6 +30,7 @@
};
};
};
};
}

View File

@ -1,4 +1,4 @@
{ pkgs, identity, ... }:
{ config, pkgs, ... }:
let
@ -13,7 +13,7 @@ let
in {
home-manager.users.${identity.user} = {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
unzip # Extract zips

View File

@ -1,6 +1,6 @@
# Replace sudo with doas
{ identity, ... }: {
{ config, ... }: {
security = {
@ -24,7 +24,7 @@
};
};
home-manager.users.${identity.user}.programs.fish.shellAliases = {
home-manager.users.${config.user}.programs.fish.shellAliases = {
sudo = "doas";
};
}

View File

@ -1,7 +1,4 @@
{ config, ... }:
{
config = {
{ ... }: {
# Service to determine location for time zone
services.geoclue2.enable = true;
@ -10,5 +7,4 @@
# Enable local time based on time zone
services.localtime.enable = true;
};
}

View File

@ -1,13 +1,30 @@
{ identity, ... }: {
{ config, lib, ... }: {
options = {
user = lib.mkOption {
type = lib.types.str;
description = "Primary user of the system";
default = "nixos";
};
passwordHash = lib.mkOption {
type = lib.types.str;
description = "Password created with mkpasswd -m sha-512";
};
};
config = {
# Define a user account. Don't forget to set a password with passwd.
users.users.${identity.user} = {
users.users.${config.user} = {
# Create a home directory for human user
isNormalUser = true;
# Automatically create a password to start
initialPassword = "changeme";
hashedPassword = config.passwordHash;
extraGroups = [
"wheel" # Sudo privileges
@ -15,4 +32,6 @@
};
};
}