diff --git a/flake.nix b/flake.nix index f696486..050ea55 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; + gui = { + colorscheme = (import ./modules/colorscheme/gruvbox); + wallpaper = ./modules/theme/gruvbox/gray-forest.jpg; + gtkTheme = "Adwaita-dark"; }; - theme = "gruvbox"; - 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 diff --git a/modules/applications/1password.nix b/modules/applications/1password.nix index b62d085..64b7b48 100644 --- a/modules/applications/1password.nix +++ b/modules/applications/1password.nix @@ -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 ]; }; }; diff --git a/modules/applications/alacritty.nix b/modules/applications/alacritty.nix index 090ed3e..56360f6 100644 --- a/modules/applications/alacritty.nix +++ b/modules/applications/alacritty.nix @@ -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; }; }; diff --git a/modules/applications/discord.nix b/modules/applications/discord.nix index 343db1f..8cdfe00 100644 --- a/modules/applications/discord.nix +++ b/modules/applications/discord.nix @@ -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 ]; }; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 98eb47d..d5430e8 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -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; }; }; }; diff --git a/modules/applications/media.nix b/modules/applications/media.nix index bcd88af..34b5de1 100644 --- a/modules/applications/media.nix +++ b/modules/applications/media.nix @@ -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 diff --git a/modules/applications/qbittorrent.nix b/modules/applications/qbittorrent.nix index 0fffcff..4447bb8 100644 --- a/modules/applications/qbittorrent.nix +++ b/modules/applications/qbittorrent.nix @@ -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 ]; diff --git a/modules/colorscheme/gruvbox/default.nix b/modules/colorscheme/gruvbox/default.nix new file mode 100644 index 0000000..45ffb32 --- /dev/null +++ b/modules/colorscheme/gruvbox/default.nix @@ -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 +} diff --git a/modules/common.nix b/modules/common.nix index ba8652d..6359e5d 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: { +{ config, lib, pkgs, ... }: { nix.extraOptions = "experimental-features = nix-command flakes"; diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 569ee8d..a85f206 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -10,11 +10,35 @@ ./rofi.nix ]; - options = { - launcherCommand = lib.mkOption { - type = lib.types.str; - description = "Command to use for launching"; + 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"; + }; }; + }; } diff --git a/modules/desktop/dmenu.nix b/modules/desktop/dmenu.nix index 1731923..9ada181 100644 --- a/modules/desktop/dmenu.nix +++ b/modules/desktop/dmenu.nix @@ -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"; }; diff --git a/modules/desktop/fonts.nix b/modules/desktop/fonts.nix index 7036804..f0848f4 100644 --- a/modules/desktop/fonts.nix +++ b/modules/desktop/fonts.nix @@ -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" ]; }; diff --git a/modules/desktop/i3.nix b/modules/desktop/i3.nix index 833abcd..fcfc411 100644 --- a/modules/desktop/i3.nix +++ b/modules/desktop/i3.nix @@ -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; } diff --git a/modules/desktop/picom.nix b/modules/desktop/picom.nix index 4aa64a3..4cea3d4 100644 --- a/modules/desktop/picom.nix +++ b/modules/desktop/picom.nix @@ -1,48 +1,49 @@ -{ 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 = true; + blur = true; + blurExclude = [ ]; + # extraOptions = '' + # shadow-radius = 20 + # ''; + extraOptions = '' + shadow-radius = 20 + corner-radius = 10 + blur-size = 20 + rounded-corners-exclude = [ + "window_type = 'dock'", + "class_g = 'i3-frame'" + ] + ''; + fade = false; + experimentalBackends = true; + inactiveDim = "0.05"; + inactiveOpacity = "1.0"; + menuOpacity = "1.0"; + noDNDShadow = false; + noDockShadow = false; + opacityRule = [ + "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows + ]; + shadow = true; + shadowExclude = [ ]; + shadowOffsets = [ (-10) (-10) ]; + shadowOpacity = "0.5"; + vSync = false; + }; + + xsession.windowManager.i3.config.startup = [{ + command = "systemctl --user restart picom"; + always = true; + notification = false; + }]; - services.picom = { - enable = false; - blur = true; - blurExclude = [ ]; - # extraOptions = '' - # shadow-radius = 20 - # ''; - extraOptions = '' - shadow-radius = 20 - corner-radius = 10 - blur-size = 20 - rounded-corners-exclude = [ - "window_type = 'dock'", - "class_g = 'i3-frame'" - ] - ''; - fade = false; - experimentalBackends = true; - inactiveDim = "0.05"; - inactiveOpacity = "1.0"; - menuOpacity = "1.0"; - noDNDShadow = false; - noDockShadow = false; - opacityRule = [ - "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows - ]; - shadow = true; - shadowExclude = [ ]; - shadowOffsets = [ (-10) (-10) ]; - shadowOpacity = "0.5"; - vSync = false; }; - - xsession.windowManager.i3.config.startup = [{ - command = "systemctl --user restart picom"; - always = true; - notification = false; - }]; - }; - }; } diff --git a/modules/desktop/polybar.nix b/modules/desktop/polybar.nix index f3910ce..4a3b1fe 100644 --- a/modules/desktop/polybar.nix +++ b/modules/desktop/polybar.nix @@ -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 = " "; # 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 = ""; diff --git a/modules/desktop/rofi.nix b/modules/desktop/rofi.nix index e49cb60..d7cf388 100644 --- a/modules/desktop/rofi.nix +++ b/modules/desktop/rofi.nix @@ -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"; }; diff --git a/modules/desktop/xorg.nix b/modules/desktop/xorg.nix index d09b13f..4c7bd21 100644 --- a/modules/desktop/xorg.nix +++ b/modules/desktop/xorg.nix @@ -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"; }; diff --git a/modules/editor/neovim.nix b/modules/editor/neovim.nix index 0d616d1..84296ec 100644 --- a/modules/editor/neovim.nix +++ b/modules/editor/neovim.nix @@ -1,6 +1,6 @@ -{ pkgs, identity, ... }: { +{ config, pkgs, ... }: { - home-manager.users.${identity.user} = { + home-manager.users.${config.user} = { home.packages = with pkgs; [ neovim diff --git a/modules/editor/notes.nix b/modules/editor/notes.nix index d8e4018..6d07d70 100644 --- a/modules/editor/notes.nix +++ b/modules/editor/notes.nix @@ -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"; }; }; diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix index 6fb3043..632b3cd 100644 --- a/modules/hardware/audio.nix +++ b/modules/hardware/audio.nix @@ -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; diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index c8c4d9f..77a4ef7 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -1,4 +1,4 @@ -{ lib, gui, ... }: { +{ ... }: { imports = [ ./audio.nix @@ -7,6 +7,7 @@ ./monitors.nix ./mouse.nix ./networking.nix + ./wifi.nix ]; } diff --git a/modules/hardware/monitors.nix b/modules/hardware/monitors.nix index 4cd3764..e9329d6 100644 --- a/modules/hardware/monitors.nix +++ b/modules/hardware/monitors.nix @@ -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 = { diff --git a/modules/hardware/mouse.nix b/modules/hardware/mouse.nix index 545a521..861660e 100644 --- a/modules/hardware/mouse.nix +++ b/modules/hardware/mouse.nix @@ -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; diff --git a/modules/hardware/networking.nix b/modules/hardware/networking.nix index 021d02a..4fb79a6 100644 --- a/modules/hardware/networking.nix +++ b/modules/hardware/networking.nix @@ -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. diff --git a/modules/hardware/wifi.nix b/modules/hardware/wifi.nix new file mode 100644 index 0000000..30b7906 --- /dev/null +++ b/modules/hardware/wifi.nix @@ -0,0 +1,7 @@ +{ ... }: { + + networking.wireless.enable = + true; # Enables wireless support via wpa_supplicant. + networking.wireless.userControlled.enable = true; + +} diff --git a/modules/services/keybase.nix b/modules/services/keybase.nix index 40885cb..4e51e2d 100644 --- a/modules/services/keybase.nix +++ b/modules/services/keybase.nix @@ -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/ diff --git a/modules/shell/fish.nix b/modules/shell/fish.nix index 42d58ab..e44d3ac 100644 --- a/modules/shell/fish.nix +++ b/modules/shell/fish.nix @@ -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 ]; diff --git a/modules/shell/git.nix b/modules/shell/git.nix index 5b68270..3034029 100644 --- a/modules/shell/git.nix +++ b/modules/shell/git.nix @@ -1,117 +1,132 @@ -{ 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} = { - programs.git = { + config = { + + home-manager.users.root.programs.git = { enable = true; - userName = identity.name; - userEmail = identity.gitEmail; - extraConfig = { - pager = { branch = "false"; }; - safe = { directory = "/home/${identity.user}/dev/personal/dotfiles"; }; - pull = { ff = "only"; }; - }; + extraConfig.safe.directory = "/home/${config.user}/dev/personal/dotfiles"; }; - programs.fish.shellAbbrs = { - g = "git"; - gs = "git status"; - gd = "git diff"; - gds = "git diff --staged"; - gdp = "git diff HEAD^"; - ga = "git add"; - gaa = "git add -A"; - gac = "git commit -am"; - gc = "git commit -m"; - gca = "git commit --amend --no-edit"; - gcae = "git commit --amend"; - gu = "git pull"; - gp = "git push"; - gpp = "git-push-upstream"; - gl = "git log --graph --decorate --oneline -20"; - gll = "git log --graph --decorate --oneline"; - gco = "git checkout"; - gcom = "git switch master"; - gcob = "git switch -c"; - gb = "git branch"; - gbd = "git branch -d"; - gbD = "git branch -D"; - gr = "git reset"; - grh = "git reset --hard"; - gm = "git merge"; - gcp = "git cherry-pick"; - cdg = "cd (git rev-parse --show-toplevel)"; - }; - - programs.fish.functions = lib.mkIf (builtins.elem pkgs.fzf home-packages - && builtins.elem pkgs.bat home-packages) { - git = { - body = builtins.readFile ../../fish.configlink/functions/git.fish; - }; - git-add-fuzzy = { - body = builtins.readFile - ../../fish.configlink/functions/git-add-fuzzy.fish; - }; - git-fuzzy-branch = { - argumentNames = "header"; - body = builtins.readFile - ../../fish.configlink/functions/git-fuzzy-branch.fish; - }; - git-checkout-fuzzy = { - body = '' - set branch (git-fuzzy-branch "checkout branch...") - and git checkout $branch - ''; - }; - git-delete-fuzzy = { - body = '' - set branch (git-fuzzy-branch "delete branch...") - and git branch -d $branch - ''; - }; - git-force-delete-fuzzy = { - body = '' - set branch (git-fuzzy-branch "force delete branch...") - and git branch -D $branch - ''; - }; - git-merge-fuzzy = { - body = '' - set branch (git-fuzzy-branch "merge from...") - and git merge $branch - ''; - }; - git-show-fuzzy = { - body = builtins.readFile - ../../fish.configlink/functions/git-show-fuzzy.fish; - }; - git-commits = { - body = - builtins.readFile ../../fish.configlink/functions/git-commits.fish; - }; - git-history = { - body = - builtins.readFile ../../fish.configlink/functions/git-history.fish; - }; - git-push-upstream = { - description = "Create upstream branch"; - body = builtins.readFile - ../../fish.configlink/functions/git-push-upstream.fish; - }; - uncommitted = { - description = "Find uncommitted git repos"; - body = - builtins.readFile ../../fish.configlink/functions/uncommitted.fish; + home-manager.users.${config.user} = { + programs.git = { + enable = true; + userName = config.fullName; + userEmail = config.gitEmail; + extraConfig = { + pager = { branch = "false"; }; + safe = { directory = "/home/${config.user}/dev/personal/dotfiles"; }; + pull = { ff = "only"; }; }; }; + + programs.fish.shellAbbrs = { + g = "git"; + gs = "git status"; + gd = "git diff"; + gds = "git diff --staged"; + gdp = "git diff HEAD^"; + ga = "git add"; + gaa = "git add -A"; + gac = "git commit -am"; + gc = "git commit -m"; + gca = "git commit --amend --no-edit"; + gcae = "git commit --amend"; + gu = "git pull"; + gp = "git push"; + gpp = "git-push-upstream"; + gl = "git log --graph --decorate --oneline -20"; + gll = "git log --graph --decorate --oneline"; + gco = "git checkout"; + gcom = "git switch master"; + gcob = "git switch -c"; + gb = "git branch"; + gbd = "git branch -d"; + gbD = "git branch -D"; + gr = "git reset"; + grh = "git reset --hard"; + gm = "git merge"; + gcp = "git cherry-pick"; + cdg = "cd (git rev-parse --show-toplevel)"; + }; + + programs.fish.functions = lib.mkIf (builtins.elem pkgs.fzf home-packages + && builtins.elem pkgs.bat home-packages) { + git = { + body = builtins.readFile ../../fish.configlink/functions/git.fish; + }; + git-add-fuzzy = { + body = builtins.readFile + ../../fish.configlink/functions/git-add-fuzzy.fish; + }; + git-fuzzy-branch = { + argumentNames = "header"; + body = builtins.readFile + ../../fish.configlink/functions/git-fuzzy-branch.fish; + }; + git-checkout-fuzzy = { + body = '' + set branch (git-fuzzy-branch "checkout branch...") + and git checkout $branch + ''; + }; + git-delete-fuzzy = { + body = '' + set branch (git-fuzzy-branch "delete branch...") + and git branch -d $branch + ''; + }; + git-force-delete-fuzzy = { + body = '' + set branch (git-fuzzy-branch "force delete branch...") + and git branch -D $branch + ''; + }; + git-merge-fuzzy = { + body = '' + set branch (git-fuzzy-branch "merge from...") + and git merge $branch + ''; + }; + git-show-fuzzy = { + body = builtins.readFile + ../../fish.configlink/functions/git-show-fuzzy.fish; + }; + git-commits = { + body = builtins.readFile + ../../fish.configlink/functions/git-commits.fish; + }; + git-history = { + body = builtins.readFile + ../../fish.configlink/functions/git-history.fish; + }; + git-push-upstream = { + description = "Create upstream branch"; + body = builtins.readFile + ../../fish.configlink/functions/git-push-upstream.fish; + }; + uncommitted = { + description = "Find uncommitted git repos"; + body = builtins.readFile + ../../fish.configlink/functions/uncommitted.fish; + }; + }; + }; + }; } diff --git a/modules/shell/github.nix b/modules/shell/github.nix index 8bf1c01..1fbe9e4 100644 --- a/modules/shell/github.nix +++ b/modules/shell/github.nix @@ -1,34 +1,36 @@ -{ pkgs, identity, ... }: { +{ config, pkgs, lib, ... }: { - imports = [ ./git.nix ]; + home-manager.users.${config.user} = { - home-manager.users.${identity.user} = { - programs.gh = { - enable = true; - enableGitCredentialHelper = true; - settings.git_protocol = "https"; - }; - - programs.fish = { - shellAbbrs = { - ghr = "gh repo view -w"; - gha = - "gh run list | head -1 | awk '{ print $(NF-2) }' | xargs gh run view"; - grw = "gh run watch"; - grf = "gh run view --log-failed"; - grl = "gh run view --log"; + programs.gh = + lib.mkIf config.home-manager.users.${config.user}.programs.git.enable { + enable = true; + enableGitCredentialHelper = true; + settings.git_protocol = "https"; }; - functions = { - repos = { - description = "Clone GitHub repositories"; - argumentNames = "organization"; - body = '' - set directory (gh-repos $organization) - and cd $directory - ''; + + programs.fish = + lib.mkIf config.home-manager.users.${config.user}.programs.gh.enable { + shellAbbrs = { + ghr = "gh repo view -w"; + gha = + "gh run list | head -1 | awk '{ print $(NF-2) }' | xargs gh run view"; + grw = "gh run watch"; + grf = "gh run view --log-failed"; + grl = "gh run view --log"; + }; + functions = { + repos = { + description = "Clone GitHub repositories"; + argumentNames = "organization"; + body = '' + set directory (gh-repos $organization) + and cd $directory + ''; + }; }; }; - }; + }; } diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index e759347..68bbf81 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -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 diff --git a/modules/system/doas.nix b/modules/system/doas.nix index 96b3627..bbe48b8 100644 --- a/modules/system/doas.nix +++ b/modules/system/doas.nix @@ -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"; }; } diff --git a/modules/system/timezone.nix b/modules/system/timezone.nix index 7af7da6..7de3484 100644 --- a/modules/system/timezone.nix +++ b/modules/system/timezone.nix @@ -1,14 +1,10 @@ -{ config, ... }: +{ ... }: { -{ - config = { + # Service to determine location for time zone + services.geoclue2.enable = true; + location = { provider = "geoclue2"; }; - # Service to determine location for time zone - services.geoclue2.enable = true; - location = { provider = "geoclue2"; }; + # Enable local time based on time zone + services.localtime.enable = true; - # Enable local time based on time zone - services.localtime.enable = true; - - }; } diff --git a/modules/system/user.nix b/modules/system/user.nix index 2b83c7f..115078b 100644 --- a/modules/system/user.nix +++ b/modules/system/user.nix @@ -1,17 +1,36 @@ -{ identity, ... }: { +{ config, lib, ... }: { - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.${identity.user} = { + options = { - # Create a home directory for human user - isNormalUser = true; + user = lib.mkOption { + type = lib.types.str; + description = "Primary user of the system"; + default = "nixos"; + }; - # Automatically create a password to start - initialPassword = "changeme"; + passwordHash = lib.mkOption { + type = lib.types.str; + description = "Password created with mkpasswd -m sha-512"; + }; - extraGroups = [ - "wheel" # Sudo privileges - ]; + }; + + config = { + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.${config.user} = { + + # Create a home directory for human user + isNormalUser = true; + + # Automatically create a password to start + hashedPassword = config.passwordHash; + + extraGroups = [ + "wheel" # Sudo privileges + ]; + + }; };