collapse gui and identity arguments

This commit is contained in:
Noah Masur 2022-04-30 12:07:58 -04:00
parent 8e08b70d86
commit 9d7307d16d
21 changed files with 89 additions and 84 deletions

View File

@ -12,31 +12,29 @@
outputs = { self, nixpkgs, home-manager }: outputs = { self, nixpkgs, home-manager }:
let let
# Set the system type globally (changeme) # Gather packages
system = "x86_64-linux"; pkgs = import nixpkgs { system = "x86_64-linux"; };
identity = {
# Gather the Nix packages user = "noah";
pkgs = import nixpkgs { name = "Noah Masur";
inherit system; hostname = "nixos";
config.allowUnfree = true; gitEmail = "7386960+nmasur@users.noreply.github.com";
}; };
gui = {
user = "noah"; enable = false;
fullName = "Noah Masur"; font = {
font = { package = pkgs.victor-mono;
package = pkgs.victor-mono; name = "Victor Mono";
name = "Victor Mono"; };
gtkTheme = "Adwaita-dark";
}; };
hostname = "nixos";
gtkTheme = "Adwaita-dark";
in { in {
nixosConfigurations = { nixosConfigurations = {
desktop = nixpkgs.lib.nixosSystem { desktop = nixpkgs.lib.nixosSystem {
inherit system; system = "x86_64-linux";
specialArgs = { specialArgs = {
gui = true; gui = gui // { enable = true; };
inherit user fullName font hostname gtkTheme; inherit identity;
}; };
modules = [ modules = [
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager

View File

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

View File

@ -1,6 +1,6 @@
{ pkgs, user, font, ... }: { { pkgs, identity, gui, ... }: {
home-manager.users.${user} = { home-manager.users.${identity.user} = {
xsession.windowManager.i3.config.terminal = "alacritty"; xsession.windowManager.i3.config.terminal = "alacritty";
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
@ -18,7 +18,7 @@
scrolling.history = 10000; scrolling.history = 10000;
font = { font = {
size = 14.0; size = 14.0;
normal = { family = font.name; }; normal = { family = gui.font.name; };
}; };
key_bindings = [ key_bindings = [
{ {

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
{ pkgs, font, ... }: { { pkgs, gui, ... }: {
fonts.fonts = with pkgs; [ fonts.fonts = with pkgs;
font.package # Used for Vim and Terminal [
font-awesome # Icons for i3 gui.font.package # Used for Vim and Terminal
# siji # More icons for Polybar # siji # More icons for Polybar
]; ];
fonts.fontconfig.defaultFonts.monospace = [ font.name ]; fonts.fontconfig.defaultFonts.monospace = [ gui.font.name ];
} }

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, user, ... }: { config, pkgs, lib, identity, ... }:
let let
@ -8,6 +8,9 @@ let
polybar & polybar &
''; '';
i3 =
config.home-manager.users.${identity.user}.xsession.windowManager.i3.config;
in { in {
config = lib.mkIf config.services.xserver.enable { config = lib.mkIf config.services.xserver.enable {
@ -21,11 +24,13 @@ in {
polybarFull # Polybar + PulseAudio polybarFull # Polybar + PulseAudio
]; ];
home-manager.users.${user}.xsession.windowManager.i3 = { # Icons for i3
fonts.fonts = with pkgs; [ font-awesome ];
home-manager.users.${identity.user}.xsession.windowManager.i3 = {
enable = true; enable = true;
config = let config = let
modifier = modifier = i3.modifier;
config.home-manager.users.${user}.xsession.windowManager.i3.config.modifier;
ws1 = "1:"; ws1 = "1:";
ws2 = "2:"; ws2 = "2:";
ws3 = "3:"; ws3 = "3:";
@ -118,16 +123,16 @@ in {
# Launchers # Launchers
"${modifier}+Return" = "exec alacritty"; "${modifier}+Return" = "exec alacritty";
"${modifier}+d" = "exec --no-startup-id dmenu_run"; "${modifier}+space" = "exec --no-startup-id dmenu_run";
"${modifier}+Shift+c" = "reload"; "${modifier}+Shift+c" = "reload";
"${modifier}+Shift+r" = "restart"; "${modifier}+Shift+r" = "restart";
"${modifier}+Shift+e" = '' "${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'"''; 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 "#2f343f"'';
"${modifier}+Shift+t" = "exec alacritty"; "${modifier}+Shift+t" = "exec alacritty";
# Window options # Window options
"${modifier}+Shift+q" = "kill"; "${modifier}+q" = "kill";
"${modifier}+h" = "focus left"; "${modifier}+h" = "focus left";
"${modifier}+j" = "focus down"; "${modifier}+j" = "focus down";
"${modifier}+k" = "focus up"; "${modifier}+k" = "focus up";
@ -149,10 +154,10 @@ in {
"${modifier}+i" = "split h"; "${modifier}+i" = "split h";
"${modifier}+v" = "split v"; "${modifier}+v" = "split v";
"${modifier}+s" = "layout stacking"; "${modifier}+s" = "layout stacking";
"${modifier}+w" = "layout tabbed"; "${modifier}+t" = "layout tabbed";
"${modifier}+e" = "layout toggle split"; "${modifier}+e" = "layout toggle split";
"${modifier}+Shift+space" = "floating toggle"; "${modifier}+Shift+space" = "floating toggle";
"${modifier}+space" = "focus mode_toggle"; "${modifier}+Control+space" = "focus mode_toggle";
"${modifier}+a" = "focus parent"; "${modifier}+a" = "focus parent";
# Workspaces # Workspaces

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{ hostname, ... }: { { identity, ... }: {
networking.hostName = hostname; # Define your hostname. networking.hostName = identity.hostname; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# The global useDHCP flag is deprecated, therefore explicitly set to false here. # The global useDHCP flag is deprecated, therefore explicitly set to false here.

View File

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

View File

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

View File

@ -1,14 +1,14 @@
{ config, pkgs, lib, user, fullName, ... }: { config, pkgs, lib, identity, ... }:
let home-packages = config.home-manager.users.${user}.home.packages; let home-packages = config.home-manager.users.${identity.user}.home.packages;
in { in {
home-manager.users.${user} = { home-manager.users.${identity.user} = {
programs.git = { programs.git = {
enable = true; enable = true;
userName = fullName; userName = identity.name;
userEmail = "7386960+nmasur@users.noreply.github.com"; userEmail = identity.gitEmail;
extraConfig = { extraConfig = {
pager = { branch = "false"; }; pager = { branch = "false"; };
safe = { directory = builtins.toString ../../.; }; safe = { directory = builtins.toString ../../.; };

View File

@ -1,8 +1,8 @@
{ pkgs, user, ... }: { { pkgs, identity, ... }: {
imports = [ ./git.nix ]; imports = [ ./git.nix ];
home-manager.users.${user} = { home-manager.users.${identity.user} = {
programs.gh = { programs.gh = {
enable = true; enable = true;
enableGitCredentialHelper = true; enableGitCredentialHelper = true;

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{ user, ... }: { { identity, ... }: {
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.${user} = { users.users.${identity.user} = {
# Create a home directory for human user # Create a home directory for human user
isNormalUser = true; isNormalUser = true;

View File

@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, user, font, ... }: { pkgs, ... }:
{ {
nix.extraOptions = "experimental-features = nix-command flakes"; nix.extraOptions = "experimental-features = nix-command flakes";

View File

@ -1,7 +1,7 @@
{ pkgs, lib, user, ... }: { { pkgs, lib, identity, ... }: {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.${user} = { home-manager.users.${identity.user} = {
home.packages = with pkgs; [ home.packages = with pkgs; [
# neomutt # neomutt