diff --git a/flake.nix b/flake.nix index 910796f..6208616 100644 --- a/flake.nix +++ b/flake.nix @@ -39,16 +39,9 @@ globals = { user = "noah"; fullName = "Noah Masur"; - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; gitEmail = "7386960+nmasur@users.noreply.github.com"; mailServer = "noahmasur.com"; dotfilesRepo = "https://github.com/nmasur/dotfiles"; - gui = { - colorscheme = (import ./modules/colorscheme/gruvbox); - wallpaper = "${wallpapers}/gruvbox/road.jpg"; - gtk.theme = { name = "Adwaita-dark"; }; - }; }; # System types to support. @@ -64,8 +57,9 @@ # nix-shell -p nixFlakes # sudo nixos-rebuild switch --flake github:nmasur/dotfiles#desktop nixosConfigurations = { - desktop = - import ./hosts/desktop { inherit nixpkgs home-manager nur globals; }; + desktop = import ./hosts/desktop { + inherit nixpkgs home-manager nur globals wallpapers; + }; }; darwinConfigurations = { diff --git a/hosts/common.nix b/hosts/common.nix index 2c4e2c9..a7f2032 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -3,10 +3,33 @@ imports = [ ../modules/shell ../modules/editor ../modules/mail/himalaya.nix ]; options = with lib; { + user = mkOption { + type = types.str; + description = "Primary user of the system"; + }; + userDirs = { + # Required to prevent infinite recursion when referenced by himalaya + download = lib.mkOption { + type = lib.types.str; + description = "XDG directory for downloads"; + default = + if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads"; + }; + }; + gui = { + enable = mkEnableOption { + description = "Enable graphics"; + default = false; + }; + colorscheme = mkOption { + type = types.attrs; + description = "Base16 color scheme"; + }; + }; dotfilesPath = mkOption { type = types.path; description = "Path of dotfiles repository."; - default = builtins.toPath "/home/${config.user}/dev/personal/dotfiles"; + default = builtins.toPath "$HOME/dev/personal/dotfiles"; }; dotfilesRepo = mkOption { type = types.str; @@ -24,9 +47,6 @@ # Enable features in Nix commands nix.extraOptions = "experimental-features = nix-command flakes"; - # Pin a state version to prevent warnings - # system.stateVersion = "22.11"; - # Basic common system packages for all devices environment.systemPackages = with pkgs; [ git vim wget curl ]; diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 8e5072a..4a2b02d 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -1,4 +1,4 @@ -{ nixpkgs, home-manager, nur, globals, ... }: +{ nixpkgs, home-manager, nur, globals, wallpapers, ... }: # System configuration for my desktop nixpkgs.lib.nixosSystem { @@ -9,13 +9,21 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager { networking.hostName = "desktop"; - gui.enable = true; - gui.compositor.enable = true; nixpkgs.overlays = [ nur.overlay ]; gaming.steam = true; gaming.leagueoflegends = true; gaming.legendary = true; + gui = { + enable = true; + compositor.enable = true; + colorscheme = (import ../modules/colorscheme/gruvbox); + wallpaper = "${wallpapers}/gruvbox/road.jpg"; + gtk.theme = { name = "Adwaita-dark"; }; + }; + passwordHash = + "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; } + ./hardware-configuration.nix ../common.nix ../../modules/hardware diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index bba704f..3fdf8a0 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -5,24 +5,17 @@ darwin.lib.darwinSystem { system = "x86_64-darwin"; specialArgs = { }; modules = [ + globals home-manager.darwinModules.home-manager { user = "Noah.Masur"; - fullName = globals.fullName; - gitEmail = globals.gitEmail; - mailServer = globals.mailServer; - dotfilesRepo = globals.dotfilesRepo; - dotfilesPath = "/Users/Noah.Masur/dev/dotfiles"; - gui = { - enable = true; - colorscheme = globals.gui.colorscheme; - }; + gui.enable = true; + gui.colorscheme = (import ../modules/colorscheme/gruvbox); nixpkgs.overlays = [ nur.overlay ]; } ../common.nix ../../modules/darwin ../../modules/applications/alacritty.nix ../../modules/applications/discord.nix - ../../modules/applications/obsidian.nix ]; } diff --git a/modules/applications/alacritty.nix b/modules/applications/alacritty.nix index 4da3f04..77f6daf 100644 --- a/modules/applications/alacritty.nix +++ b/modules/applications/alacritty.nix @@ -19,15 +19,7 @@ opacity = 1.0; }; scrolling.history = 10000; - font = { - size = 14.0; - normal = { - family = builtins.head (if pkgs.stdenv.isDarwin then - [ "FiraCode Nerd Font Mono" ] - else - config.fonts.fontconfig.defaultFonts.monospace); - }; - }; + font = { size = 14.0; }; key_bindings = [ { key = "L"; diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 564d7ba..16ed22f 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,34 +1,15 @@ -{ lib, ... }: { +{ ... }: { imports = [ - ./system.nix - ./user.nix - ./tmux.nix - ./utilities.nix - ./hammerspoon.nix ./alacritty.nix + ./dotfiles.nix + ./fonts.nix + ./hammerspoon.nix ./homebrew.nix + ./system.nix + ./tmux.nix + ./user.nix + ./utilities.nix ]; - options = with lib; { - - user = mkOption { - type = types.str; - description = "Primary user of the system"; - }; - - gui = { - enable = mkEnableOption { - description = "Enable graphics"; - default = false; - }; - - colorscheme = mkOption { - type = types.attrs; - description = "Base16 color scheme"; - }; - - }; - }; - } diff --git a/modules/darwin/dotfiles.nix b/modules/darwin/dotfiles.nix new file mode 100644 index 0000000..e753c12 --- /dev/null +++ b/modules/darwin/dotfiles.nix @@ -0,0 +1,28 @@ +{ config, ... }: { + + home-manager.users.${config.user} = { + + programs.fish = { + shellAbbrs = { + nr = "rebuild-darwin"; + nro = "rebuild-darwin offline"; + }; + functions = { + rebuild-nixos = { + body = '' + if test "$argv[1]" = "offline" + set option "--option substitute false" + end + pushd ${config.dotfilesPath} + git add --all + popd + commandline -r darwin-rebuild switch $option --flake ${config.dotfilesPath}#macbook + commandline -f execute + ''; + }; + }; + }; + + }; + +} diff --git a/modules/darwin/fonts.nix b/modules/darwin/fonts.nix new file mode 100644 index 0000000..20ea0dc --- /dev/null +++ b/modules/darwin/fonts.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: { + + home-manager.users.${config.user} = { + + home.packages = with pkgs; + [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) ]; + + programs.alacritty.settings = { + font.normal.family = "FiraCode Nerd Font Mono"; + }; + + }; + +} diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 157cb00..7824f66 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -1,5 +1,8 @@ { config, ... }: { + # Homebrew - Mac-specific packages that aren't in Nix + # Requires Homebrew to be installed (works if you rebuild twice) + homebrew = { enable = true; autoUpdate = false; # Don't update during rebuild @@ -34,10 +37,10 @@ config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ] '' if ! xcode-select --version 2>/dev/null; then - xcode-select --install + $DRY_RUN_CMD xcode-select --install fi if ! /usr/local/bin/brew --version 2>/dev/null; then - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + $DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi ''; diff --git a/modules/darwin/networking.nix b/modules/darwin/networking.nix new file mode 100644 index 0000000..319f49b --- /dev/null +++ b/modules/darwin/networking.nix @@ -0,0 +1,8 @@ +{ ... }: { + + networking = { + computerName = "MacBook"; # Host name + hostName = "MacBook"; + }; + +} diff --git a/modules/darwin/user.nix b/modules/darwin/user.nix index 668a4cd..d6ff3a5 100644 --- a/modules/darwin/user.nix +++ b/modules/darwin/user.nix @@ -5,9 +5,4 @@ shell = pkgs.zsh; # Default shell }; - #networking = { - # computerName = "MacBook"; # Host name - # hostName = "MacBook"; - #}; - } diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index 8d95bd4..b082145 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -14,7 +14,6 @@ kubectl k9s noti # Create notifications programmatically - (pkgs.nerdfonts.override { fonts = [ "FiraCode" ]; }) ]; }; diff --git a/modules/editor/dotfiles.nix b/modules/editor/dotfiles.nix index ee9766b..8dce093 100644 --- a/modules/editor/dotfiles.nix +++ b/modules/editor/dotfiles.nix @@ -16,16 +16,13 @@ }; - programs.fish = let - system = if pkgs.stdenv.isDarwin then "darwin" else "nixos"; - sudo = if pkgs.stdenv.isDarwin then "" else "doas"; - in { + programs.fish = { shellAbbrs = { - nr = "rebuild-${system}"; - nro = "rebuild-${system} offline"; + nr = "rebuild-nixos"; + nro = "rebuild-nixos offline"; }; functions = { - "rebuild-${system}" = { + rebuild-nixos = { body = '' if test "$argv[1]" = "offline" set option "--option substitute false" @@ -33,8 +30,8 @@ pushd ${config.dotfilesPath} git add --all popd - echo "${sudo} ${system}-rebuild switch $option --flake ${config.dotfilesPath}" - ${sudo} ${system}-rebuild switch $option --flake ${config.dotfilesPath} + commandline -r doas nixos-rebuild switch $option --flake ${config.dotfilesPath} + commandline -f execute ''; }; }; diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix index fa59cc5..ea6a7a8 100644 --- a/modules/graphical/default.nix +++ b/modules/graphical/default.nix @@ -13,10 +13,6 @@ options = with lib; { gui = { - enable = mkEnableOption { - description = "Enable graphics"; - default = false; - }; compositor.enable = mkEnableOption { description = "Enable transparency, blur, shadows"; default = false; @@ -48,10 +44,6 @@ default = "gnome-themes-extra"; }; }; - colorscheme = mkOption { - type = types.attrs; - description = "Base16 color scheme"; - }; wallpaper = mkOption { type = types.path; description = "Wallpaper background image file"; diff --git a/modules/graphical/fonts.nix b/modules/graphical/fonts.nix index dde5a7c..ae81955 100644 --- a/modules/graphical/fonts.nix +++ b/modules/graphical/fonts.nix @@ -20,6 +20,7 @@ in { }; services.polybar.config."bar/main".font-0 = "Hack Nerd Font:size=10;2"; programs.rofi.font = "Hack Nerd Font 14"; + programs.alacritty.settings.font.normal.family = fontName; }; }; diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 92dfe5c..76a443c 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -39,7 +39,7 @@ himalaya = { enable = true; settings = { - downloads-dir = if pkgs.stdenv.isDarwin then "$HOME/Downloads" else config.userDirs.download; + downloads-dir = config.userDirs.download; smtp-insecure = true; }; }; diff --git a/modules/system/default.nix b/modules/system/default.nix index 02bf010..0a8574e 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -2,4 +2,7 @@ imports = [ ./user.nix ./timezone.nix ./doas.nix ]; + # Pin a state version to prevent warnings + system.stateVersion = "22.11"; + } diff --git a/modules/system/user.nix b/modules/system/user.nix index 23cef2e..9d42048 100644 --- a/modules/system/user.nix +++ b/modules/system/user.nix @@ -2,26 +2,11 @@ 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"; }; - userDirs = { - # Required to prevent infinite recursion when referenced by himalaya - download = lib.mkOption { - type = lib.types.str; - description = "XDG directory for downloads"; - default = "$HOME/downloads"; - }; - }; - }; config = {