Switching from hardcoded username.

Will this ever change? No like likely, but I do think that this is the
correct way to do this.
This commit is contained in:
James Patrick 2022-08-14 19:35:15 -04:00
parent 8030f530ce
commit d7e2c0a924
29 changed files with 132 additions and 106 deletions

View File

@ -58,7 +58,10 @@
channelsConfig = { allowUnfree = true; };
sharedOverlays = [ nur.overlay (import ./pkgs) emacs-overlay.overlay ];
hostDefaults = {
specialArgs = { inherit home-manager nixos-hardware; };
specialArgs = {
inherit home-manager nixos-hardware;
user = { name = "james"; description = "James Patrick"; };
};
modules = mapModulesRec' ./modules import;
system = "x86_64-linux";
};

View File

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.onepassword;
graphical = config.my.graphical;
enable = (this.gui.enable || this.cli.enable);
in with lib; {
in
with lib; {
options = {
my.application.onepassword.gui.enable = mkOption {
default = graphical.enable;
@ -17,10 +18,10 @@ in with lib; {
config = mkIf enable (mkMerge [
(mkIf this.cli.enable {
home-manager.users.james.home.packages = with pkgs; [ _1password ];
home-manager.users."${user.name}".home.packages = with pkgs; [ _1password ];
})
(mkIf this.gui.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [ _1password-gui ];
};
systemd.user.services._1password = {

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.blueman;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.blueman.enable = mkOption {
default = graphical.enable;
@ -12,7 +13,7 @@ in with lib; {
config = mkIf this.enable {
hardware.bluetooth.enable = true;
home-manager.users.james = { home.packages = with pkgs; [ blueman ]; };
home-manager.users."${user.name}" = { home.packages = with pkgs; [ blueman ]; };
fileSystems."var/lib/bluetooth" = {
device = "/persist/var/lib/bluetooth";
options = [ "bind" "noauto" "x-systemd.automount" ];

View File

@ -1,9 +1,10 @@
{ options, config, lib, pkgs, ... }:
{ options, config, lib, pkgs, user, ... }:
let
this = config.my.application.dunst;
i3 = config.my.application.i3;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.dunst.enable = mkOption {
default = i3.enable;
@ -12,7 +13,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
systemd.user.startServices = true;
services.dunst.enable = true;
home.packages = with pkgs; [ libnotify ];

View File

@ -1,10 +1,11 @@
{ inputs, config, lib, pkgs, ... }:
{ inputs, config, lib, pkgs, user, ... }:
# TODO Still need the following dependecies
# - Language tools (grammer)
let
this = config.my.application.emacs;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.emacs.enable = mkOption {
default = graphical.enable;
@ -14,7 +15,7 @@ in with lib; {
config = mkIf this.enable {
nixpkgs.overlays = [ inputs.emacs-overlay.overlay ];
home-manager.users.james = {
home-manager.users."${user.name}" = {
programs.emacs = {
package = pkgs.emacs28NativeComp;
enable = true;

View File

@ -1,8 +1,9 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, user, ... }:
let
cfg = config.my.application.firefox;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options.my.application.firefox = {
enable = mkOption {
default = graphical.enable;
@ -18,7 +19,7 @@ in with lib; {
config = mkIf cfg.enable {
environment.sessionVariables = { MOZ_USE_XINPUT2 = "1"; };
home-manager.users.james = {
home-manager.users."${user.name}" = {
programs.firefox = {
enable = true;
package = cfg.pkg;

View File

@ -1,8 +1,9 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, user, ... }:
let
this = config.my.application.firefox.tridactyl;
firefox = config.my.application.firefox;
in with lib; {
in
with lib; {
options = {
my.application.firefox.tridactyl.enable = mkOption {
default = firefox.enable;
@ -14,7 +15,7 @@ in with lib; {
config = mkIf this.enable {
# firefox.pkg =
# pkgs.firefox.override { this = { enableTridactylNative = true; }; };
home-manager.users.james = {
home-manager.users."${user.name}" = {
programs.firefox = {
extensions = with pkgs.nur.repos.rycee.firefox-addons; [ tridactyl ];
};

View File

@ -1,8 +1,9 @@
{ options, config, lib, pkgs, ... }:
{ options, config, lib, pkgs, user, ... }:
let
this = config.my.application.gammastep;
i3 = config.my.application.i3;
in with lib; {
in
with lib; {
options = {
my.application.gammastep.enable = mkOption {
default = i3.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
services.gammastep = {
enable = true;
provider = "geoclue2";

View File

@ -1,13 +1,14 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
graphical = config.my.graphical;
power = config.my.system.power;
keyring = config.my.system.keyring;
in with lib; {
in
with lib; {
config = mkIf graphical.enable {
services.gvfs.enable = true;
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs.gnome;
[
cheese

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.i3;
graphical = config.my.graphical;
@ -8,7 +8,8 @@ let
sha256 = "sha256-dErBslKRBTLKbTTUanIPDwX8CcMJ0Kpi3oof0oXlHys=";
};
in with lib; {
in
with lib; {
options = {
my.application.i3.enable = mkOption {
default = graphical.enable;
@ -55,7 +56,7 @@ in with lib; {
};
};
home-manager.users.james = {
home-manager.users."${user.name}" = {
xsession.windowManager.i3 = {
enable = true;
package = pkgs.i3-gaps;
@ -170,6 +171,6 @@ in with lib; {
};
};
users.users.james.extraGroups = [ "video" "audio" ];
users.users."${user.name}".extraGroups = [ "video" "audio" ];
};
}

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.i3.polybar;
i3 = config.my.application.i3;
@ -11,7 +11,8 @@ let
primary = "#F0C674";
secondary = "#8ABEB7";
};
in with lib; {
in
with lib; {
options = {
my.application.i3.polybar.enable = mkOption {
default = i3.enable;
@ -20,7 +21,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
services.polybar = {
enable = true;
script = "polybar";

View File

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.i3.rofi;
i3 = config.my.application.i3;
in with lib; {
in
with lib; {
options = {
my.application.i3.rofi.enable = mkOption {
default = i3.enable;
@ -12,7 +13,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [ rofi-systemd rofi-power-menu ];
programs.rofi = {
enable = true;

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.kdeconnect;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.kdeconnect.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
# home-manager.users.james = {
# home-manager.users."${user.name}" = {
# services.kdeconnect = {
# indicator = true;
# enable = true;

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.kitty;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.kitty.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [ kitty ];
programs.kitty = {
enable = true;

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.media;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.media.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
programs.mpv = {
enable = true;
scripts = with pkgs.mpvScripts; [ mpris thumbnail ];

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.nextcloud;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.nextcloud.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [ nextcloud-client ];
};

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.spotify;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.spotify.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = { home.packages = with pkgs; [ spotify ]; };
home-manager.users."${user.name}" = { home.packages = with pkgs; [ spotify ]; };
# Local discovery - https://nixos.wiki/wiki/Spotify
networking.firewall.allowedTCPPorts = [ 57621 ];

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.zathura;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.zathura.enable = mkOption {
default = graphical.enable;
@ -11,6 +12,6 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = { programs.zathura = { enable = true; }; };
home-manager.users."${user.name}" = { programs.zathura = { enable = true; }; };
};
}

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.application.zeal;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.application.zeal.enable = mkOption {
default = graphical.enable;
@ -11,6 +12,6 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james.home.packages = with pkgs; [ zeal ];
home-manager.users."${user.name}".home.packages = with pkgs; [ zeal ];
};
}

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.lang.bash;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.lang.bash.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [
nodePackages.bash-language-server
shellcheck

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.lang.golang;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.lang.golang.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
programs.go = {
enable = true;
goPath = ".local/go";

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.lang.bash;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options = {
my.lang.javascript.enable = mkOption {
default = graphical.enable;
@ -11,7 +12,7 @@ in with lib; {
};
config = mkIf this.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [
nodePackages.npm
nodePackages.vue-cli

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let graphical = config.my.graphical;
in with lib; {
in
with lib; {
config = mkIf graphical.enable {
home-manager.users.james = {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [ dracula-theme kora-icon-theme ];
home.sessionVariables = { GTK_THEME = "Dracula"; };
systemd.user.sessionVariables = { GTK_THEME = "Dracula"; };

View File

@ -1,24 +1,16 @@
{ config, home-manager, lib, pkgs, ... }: {
{ config, home-manager, lib, pkgs, user, ... }: {
imports = [ home-manager.nixosModules.home-manager ];
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.james = {
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "james";
home.homeDirectory = "/home/james";
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users."${user.name}" = {
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "21.11";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "21.11";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
};
};
}

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
#with lib.my;
with lib;
let
@ -7,7 +7,8 @@ let
url = "https://github.com/jamesepatrick.keys";
sha256 = "sha256-alm6KRFca4VjzTyVEg+j1s0uKaSfvV76o3sgYNAisSA=";
};
in {
in
{
options.my = {
system.ssh.enable = mkOption {
default = true;
@ -23,6 +24,6 @@ in {
passwordAuthentication = false;
};
users.users.james.openssh.authorizedKeys.keyFiles = [ publicKey ];
users.users."${user.name}".openssh.authorizedKeys.keyFiles = [ publicKey ];
};
}

View File

@ -1,13 +1,19 @@
# Define a user account. Don't forget to set a password with passwd.
{ config, lib, pkgs, ... }: {
{ config, lib, pkgs, user, ... }: {
users.users = {
root.initialPassword = "noreallychangemenow";
james = {
description = "James Patrick";
"${user.name}" = {
description = "${user.description}";
extraGroups = [ "wheel" "systemd-journal" ];
initialPassword = "nixos";
isNormalUser = true;
shell = pkgs.zsh;
};
};
home-manager.users."${user.name}".home = {
username = "${user.name}";
homeDirectory = "/home/${user.name}";
};
}

View File

@ -1,5 +1,5 @@
{ config, pkgs, ... }: {
home-manager.users.james = {
{ config, pkgs, user, ... }: {
home-manager.users."${user.name}" = {
home.packages = with pkgs; [ xdg-utils xdg-launch ];
xdg.enable = true;
};

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, user, ... }:
let
this = config.my.system.yubikey;
graphical = config.my.graphical;
in with lib; {
in
with lib; {
options.my.system.yubikey.enable = mkEnableOption "Yubikey";
config = mkIf this.enable {
@ -35,7 +36,7 @@ in with lib; {
[ yubioath-desktop pinentry-curses ]
++ optionals (graphical.enable) [ pinentry-gnome ];
home-manager.users.james.home = {
home-manager.users."${user.name}".home = {
packages = with pkgs;
[ yubikey-manager yubikey-personalization ]
++ optionals (graphical.enable) [
@ -43,10 +44,11 @@ in with lib; {
yubikey-personalization-gui
];
file.".gnupg/gpg-agent.config" = {
text = if graphical.enable then
"pinentry-program ${pkgs.pinentry-gnome}/bin/pinentry"
else
"pinentry-program ${pkgs.pinentry-curses}/bin/pinentry";
text =
if graphical.enable then
"pinentry-program ${pkgs.pinentry-gnome}/bin/pinentry"
else
"pinentry-program ${pkgs.pinentry-curses}/bin/pinentry";
};
};
};

View File

@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }: {
{ config, lib, pkgs, user, ... }: {
imports = [ ./graphical.nix ];
my.system.boot.enable = true;
networking.networkmanager.enable = true;
users.users.james.extraGroups = [ "networkmanager" ];
users.users."${user.name}".extraGroups = [ "networkmanager" ];
}