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 }:
let
# Set the system type globally (changeme)
system = "x86_64-linux";
# Gather the Nix packages
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
# Gather packages
pkgs = import nixpkgs { system = "x86_64-linux"; };
identity = {
user = "noah";
fullName = "Noah Masur";
name = "Noah Masur";
hostname = "nixos";
gitEmail = "7386960+nmasur@users.noreply.github.com";
};
gui = {
enable = false;
font = {
package = pkgs.victor-mono;
name = "Victor Mono";
};
hostname = "nixos";
gtkTheme = "Adwaita-dark";
};
in {
nixosConfigurations = {
desktop = nixpkgs.lib.nixosSystem {
inherit system;
system = "x86_64-linux";
specialArgs = {
gui = true;
inherit user fullName font hostname gtkTheme;
gui = gui // { enable = true; };
inherit identity;
};
modules = [
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;
home-manager.users.${user} = {
home-manager.users.${identity.user} = {
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";
programs.alacritty = {
enable = true;
@ -18,7 +18,7 @@
scrolling.history = 10000;
font = {
size = 14.0;
normal = { family = font.name; };
normal = { family = gui.font.name; };
};
key_bindings = [
{

View File

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

View File

@ -1,12 +1,12 @@
{ pkgs, lib, user, gui, gtkTheme, ... }:
{ pkgs, lib, identity, gui, ... }:
{
config = lib.mkIf gui {
home-manager.users.${user} = {
config = lib.mkIf gui.enable {
home-manager.users.${identity.user} = {
home.packages = [ pkgs.firefox ];
gtk = {
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 {
home-manager.users.${user}.home.packages = with pkgs; [
config = lib.mkIf gui.enable {
home-manager.users.${identity.user}.home.packages = with pkgs; [
mpv # Video viewer
sxiv # Image viewer
zathura # PDF viewer

View File

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

View File

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

View File

@ -1,4 +1,4 @@
{ pkgs, user, ... }: {
{ pkgs, identity, ... }: {
# Timezone required for Redshift schedule
imports = [ ../system/timezone.nix ];
@ -21,7 +21,7 @@
hardware.i2c.enable = true;
# Grant user access to external monitors
users.users.${user}.extraGroups = [ "i2c" ];
users.users.${identity.user}.extraGroups = [ "i2c" ];
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.
# 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.kbfs.enable = true;
home-manager.users.${user} = {
home.packages = [ (lib.mkIf gui pkgs.keybase-gui) ];
home-manager.users.${identity.user} = {
home.packages = [ (lib.mkIf gui.enable pkgs.keybase-gui) ];
home.file = let
ignorePatterns = ''
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 ];

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 {
home-manager.users.${user} = {
home-manager.users.${identity.user} = {
programs.git = {
enable = true;
userName = fullName;
userEmail = "7386960+nmasur@users.noreply.github.com";
userName = identity.name;
userEmail = identity.gitEmail;
extraConfig = {
pager = { branch = "false"; };
safe = { directory = builtins.toString ../../.; };

View File

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

View File

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

View File

@ -1,6 +1,6 @@
# Replace sudo with doas
{ user, ... }: {
{ identity, ... }: {
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.
users.users.${user} = {
users.users.${identity.user} = {
# Create a home directory for human user
isNormalUser = true;

View File

@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, user, font, ... }:
{ pkgs, ... }:
{
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.useUserPackages = true;
home-manager.users.${user} = {
home-manager.users.${identity.user} = {
home.packages = with pkgs; [
# neomutt