From 1226eafef2ff3e384d35e8b2a769b58c910f7d55 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Feb 2025 16:10:16 -0500 Subject: [PATCH] more stuff --- modules/common/default.nix | 7 -- modules/nixos/default.nix | 12 ---- modules/nixos/graphical/default.nix | 64 ----------------- modules/nixos/graphical/fonts.nix | 34 --------- modules/nixos/graphical/rofi.nix | 36 ---------- platforms/home-manager/default.nix | 4 ++ .../{1password.nix => _1password.nix} | 5 +- .../nmasur/presets/programs/default.nix | 16 ----- .../nmasur/presets/programs/direnv.nix | 5 -- .../modules/nmasur/presets/programs/doas.nix | 0 .../nmasur/presets/programs/dotfiles.nix | 3 + .../nmasur/presets/programs/git-work.nix | 69 +++++++++++++++++++ .../modules/nmasur/presets/programs/git.nix | 32 ++------- .../nmasur/presets/programs/rofi/default.nix | 32 ++++++++- .../modules/nmasur/presets/services/i3.nix | 8 ++- .../modules/nmasur/profiles/common.nix | 34 ++++++--- .../modules/nmasur/profiles/darwin-base.nix | 2 +- .../profiles/{fun.nix => experimental.nix} | 4 +- .../modules/nmasur/profiles/extra.nix | 24 ++++--- .../modules/nmasur/profiles/linux-gaming.nix | 2 +- .../modules/nmasur/profiles/work.nix | 53 +++++++------- platforms/nix-darwin/default.nix | 4 ++ .../modules/nmasur/profiles/base.nix | 5 ++ .../modules/nmasur/profiles/extra.nix | 6 +- .../modules/nmasur/profiles/gaming.nix | 2 + .../modules/nmasur/profiles/work.nix | 3 + platforms/nixos/default.nix | 4 ++ .../nmasur/presets/services/lightdm.nix | 10 ++- .../nmasur/presets/services/logind.nix | 18 +++++ .../nixos/modules/nmasur/profiles/base.nix | 21 ++++-- .../modules/nmasur/profiles/on-premises.nix | 33 +++++++-- .../nixos/modules/nmasur/profiles/server.nix | 34 ++------- .../modules/nmasur/profiles/shared-media.nix | 1 - .../nixos/modules/nmasur/profiles/wsl.nix | 12 ++-- 34 files changed, 291 insertions(+), 308 deletions(-) delete mode 100644 modules/nixos/default.nix delete mode 100644 modules/nixos/graphical/default.nix delete mode 100644 modules/nixos/graphical/fonts.nix delete mode 100644 modules/nixos/graphical/rofi.nix create mode 100644 platforms/home-manager/default.nix rename platforms/home-manager/modules/nmasur/presets/programs/{1password.nix => _1password.nix} (87%) delete mode 100644 platforms/home-manager/modules/nmasur/presets/programs/default.nix rename platforms/{nix-darwin => home-manager}/modules/nmasur/presets/programs/doas.nix (100%) create mode 100644 platforms/home-manager/modules/nmasur/presets/programs/git-work.nix rename platforms/home-manager/modules/nmasur/profiles/{fun.nix => experimental.nix} (70%) create mode 100644 platforms/nix-darwin/default.nix create mode 100644 platforms/nixos/default.nix create mode 100644 platforms/nixos/modules/nmasur/presets/services/logind.nix diff --git a/modules/common/default.nix b/modules/common/default.nix index 6af1f50..8868ded 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -179,13 +179,6 @@ curl ]; - # Use the system-level nixpkgs instead of Home Manager's - home-manager.useGlobalPkgs = true; - - # Install packages to /etc/profiles instead of ~/.nix-profile, useful when - # using multiple profiles for one user - home-manager.useUserPackages = true; - # Allow specified unfree packages (identified elsewhere) # Retrieves package object based on string name nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.unfreePackages; diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix deleted file mode 100644 index af38f80..0000000 --- a/modules/nixos/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ ... }: -{ - - imports = [ - ./applications - ./gaming - ./graphical - ./hardware - ./services - ./system - ]; -} diff --git a/modules/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix deleted file mode 100644 index 76705f3..0000000 --- a/modules/nixos/graphical/default.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ lib, ... }: -{ - - imports = [ - ./dunst.nix - ./fonts.nix - ./gtk.nix - ./i3.nix - ./picom.nix - ./polybar.nix - ./rofi.nix - ./xorg.nix - ]; - - options = { - - launcherCommand = lib.mkOption { - type = lib.types.str; - description = "Command to use for launching"; - }; - systemdSearch = lib.mkOption { - type = lib.types.str; - description = "Command to use for interacting with systemd"; - }; - altTabCommand = lib.mkOption { - type = lib.types.str; - description = "Command to use for choosing windows"; - }; - audioSwitchCommand = lib.mkOption { - type = lib.types.str; - description = "Command to use for switching audio sink"; - }; - brightnessCommand = lib.mkOption { - type = lib.types.str; - description = "Command to use for adjusting brightness"; - }; - calculatorCommand = lib.mkOption { - type = lib.types.str; - description = "Command to use for quick calculations"; - }; - toggleBarCommand = lib.mkOption { - type = lib.types.str; - description = "Command to hide and show the status bar."; - }; - powerCommand = lib.mkOption { - type = lib.types.str; - description = "Command to use for power options menu"; - }; - terminal = lib.mkOption { - type = lib.types.nullOr lib.types.str; - description = "Path to executable for terminal emulator program."; - default = null; - }; - terminalLaunchCommand = lib.mkOption { - type = lib.types.nullOr lib.types.str; - description = "Command for using the terminal to launch a new window with a program."; - default = null; - }; - wallpaper = lib.mkOption { - type = lib.types.path; - description = "Wallpaper background image file"; - }; - }; -} diff --git a/modules/nixos/graphical/fonts.nix b/modules/nixos/graphical/fonts.nix deleted file mode 100644 index 8fc8431..0000000 --- a/modules/nixos/graphical/fonts.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: - -let - fontName = "Victor Mono"; -in -{ - - config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) { - - fonts.packages = with pkgs; [ - victor-mono # Used for Vim and Terminal - nerd-fonts.hack # For Polybar, Rofi - ]; - fonts.fontconfig.defaultFonts.monospace = [ fontName ]; - - home-manager.users.${config.user} = { - xsession.windowManager.i3.config.fonts = { - names = [ "pango:${fontName}" ]; - # style = "Regular"; - # size = 11.0; - }; - 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; - programs.kitty.font.name = fontName; - services.dunst.settings.global.font = "Hack Nerd Font 14"; - }; - }; -} diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix deleted file mode 100644 index f62e1d0..0000000 --- a/modules/nixos/graphical/rofi.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: - -let - - rofi = config.home-manager.users.${config.user}.programs.rofi.finalPackage; -in -{ - - imports = [ - ./rofi/power.nix - ./rofi/brightness.nix - ]; - - config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { - - launcherCommand = ''${rofi}/bin/rofi -modes drun -show drun -theme-str '@import "launcher.rasi"' ''; - systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; - altTabCommand = "${rofi}/bin/rofi -show window -modi window"; - calculatorCommand = "${rofi}/bin/rofi -modes calc -show calc"; - audioSwitchCommand = "${ - (pkgs.writeShellApplication { - name = "switch-audio"; - runtimeInputs = [ - pkgs.ponymix - rofi - ]; - text = builtins.readFile ./rofi/pulse-sink.sh; - }) - }/bin/switch-audio"; - }; -} diff --git a/platforms/home-manager/default.nix b/platforms/home-manager/default.nix new file mode 100644 index 0000000..2de487f --- /dev/null +++ b/platforms/home-manager/default.nix @@ -0,0 +1,4 @@ +{ lib, ... }: +{ + imports = lib.filesystem.listFilesRecursive ./.; +} diff --git a/platforms/home-manager/modules/nmasur/presets/programs/1password.nix b/platforms/home-manager/modules/nmasur/presets/programs/_1password.nix similarity index 87% rename from platforms/home-manager/modules/nmasur/presets/programs/1password.nix rename to platforms/home-manager/modules/nmasur/presets/programs/_1password.nix index a05d3a6..4c2f5b4 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/1password.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/_1password.nix @@ -6,13 +6,12 @@ }: let - cfg = config.nmasur.presets.programs."1password"; + cfg = config.nmasur.presets.programs._1password; in { - options.nmasur.presets.programs."1password".enable = - lib.mkEnableOption "1Password password manager"; + options.nmasur.presets.programs._1password.enable = lib.mkEnableOption "1Password password manager"; config = lib.mkIf cfg.enable { unfreePackages = [ diff --git a/platforms/home-manager/modules/nmasur/presets/programs/default.nix b/platforms/home-manager/modules/nmasur/presets/programs/default.nix deleted file mode 100644 index a77815f..0000000 --- a/platforms/home-manager/modules/nmasur/presets/programs/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ ... }: -{ - - imports = [ - ./1password.nix - ./alacritty.nix - ./discord.nix - ./firefox.nix - ./kitty.nix - ./media.nix - ./nsxiv.nix - ./wezterm.nix - ./yt-dlp.nix - ./zathura.nix - ]; -} diff --git a/platforms/home-manager/modules/nmasur/presets/programs/direnv.nix b/platforms/home-manager/modules/nmasur/presets/programs/direnv.nix index 727e083..23b9609 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/direnv.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/direnv.nix @@ -17,11 +17,6 @@ in programs.direnv = { enable = true; nix-direnv.enable = true; - config = { - whitelist = { - prefix = [ config.nmasur.dotfilesPath ]; - }; - }; }; }; } diff --git a/platforms/nix-darwin/modules/nmasur/presets/programs/doas.nix b/platforms/home-manager/modules/nmasur/presets/programs/doas.nix similarity index 100% rename from platforms/nix-darwin/modules/nmasur/presets/programs/doas.nix rename to platforms/home-manager/modules/nmasur/presets/programs/doas.nix diff --git a/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix b/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix index 9257d05..708c242 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix @@ -28,6 +28,9 @@ in config = lib.mkIf cfg.enable { + programs.git.extraConfig.safe.directory = cfg.path; + programs.direnv.config.whitelist.prefix = [ cfg.path ]; + home.activation = { # Always clone dotfiles repository if it doesn't exist diff --git a/platforms/home-manager/modules/nmasur/presets/programs/git-work.nix b/platforms/home-manager/modules/nmasur/presets/programs/git-work.nix new file mode 100644 index 0000000..4232169 --- /dev/null +++ b/platforms/home-manager/modules/nmasur/presets/programs/git-work.nix @@ -0,0 +1,69 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + cfg = config.nmasur.presets.programs.git-work; +in + +{ + + options.nmasur.presets.programs.git-work = { + enable = lib.mkEnableOption "Git settings for work"; + work = { + name = lib.mkOption { + type = lib.types.str; + description = "Name to use for work git commits"; + }; + email = lib.mkOption { + type = lib.types.str; + description = "Email to use for work git commits"; + }; + }; + personal = { + name = lib.mkOption { + type = lib.types.str; + description = "Name to use for personal git commits"; + }; + email = lib.mkOption { + type = lib.types.str; + description = "Email to use for personal git commits"; + }; + }; + }; + + config = lib.mkIf cfg.enable { + + programs.git = { + userName = lib.mkForce cfg.work.name; + userEmail = lib.mkForce cfg.work.email; + includes = [ + { + path = "${config.xdg.configHome}/${config.xdg.configFile."git/personal".target}"; + condition = "gitdir:~/dev/personal/"; + } + ]; + + }; + + # Personal git config + xdg.configFile."git/personal".text = pkgs.formats.gitIni { + user = { + name = cfg.personal.name; + email = cfg.personal.email; + signingkey = "~/.ssh/id_ed25519"; + }; + commit = { + gpgsign = true; + }; + tag = { + gpgsign = true; + }; + }; + + }; + +} diff --git a/platforms/home-manager/modules/nmasur/presets/programs/git.nix b/platforms/home-manager/modules/nmasur/presets/programs/git.nix index c7692d9..17f6eab 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/git.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/git.nix @@ -12,12 +12,12 @@ in { options.nmasur.presets.programs.git = { - enable = lib.mkEnableOption ""; - gitName = lib.mkOption { + enable = lib.mkEnableOption "Git version control"; + name = lib.mkOption { type = lib.types.str; description = "Name to use for git commits"; }; - gitEmail = lib.mkOption { + email = lib.mkOption { type = lib.types.str; description = "Email to use for git commits"; }; @@ -27,17 +27,14 @@ in programs.git = { enable = true; - userName = config.gitName; - userEmail = config.gitEmail; + userName = cfg.name; + userEmail = cfg.email; extraConfig = { core.pager = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight | less -F"; interactive.difffilter = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight"; pager = { branch = "false"; }; - safe = { - directory = config.dotfilesPath; - }; pull = { ff = "only"; }; @@ -61,27 +58,8 @@ in ".direnv/**" "result" ]; - includes = [ - { - path = "~/.config/git/personal"; - condition = "gitdir:~/dev/personal/"; - } - ]; }; - # Personal git config - # TODO: fix with variables - xdg.configFile."git/personal".text = '' - [user] - name = "${config.fullName}" - email = "7386960+nmasur@users.noreply.github.com" - signingkey = ~/.ssh/id_ed25519 - [commit] - gpgsign = true - [tag] - gpgsign = true - ''; - xdg.configFile."git/allowed-signers".text = '' 7386960+nmasur@users.noreply.github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s ''; diff --git a/platforms/home-manager/modules/nmasur/presets/programs/rofi/default.nix b/platforms/home-manager/modules/nmasur/presets/programs/rofi/default.nix index 5d26411..b61b7f7 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/rofi/default.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/rofi/default.nix @@ -16,7 +16,14 @@ in ./brightness.nix ]; - options.nmasur.presets.programs.rofi.enable = lib.mkEnableOption "Rofi quick launcher"; + options.nmasur.presets.programs.rofi = { + enable = lib.mkEnableOption "Rofi quick launcher"; + terminal = lib.mkOption { + type = lib.types.package; + description = "Terminal application for rofi"; + default = config.nmasur.presets.services.i3.terminal; + }; + }; config = lib.mkIf cfg.enable { @@ -24,12 +31,33 @@ in jq # Required for rofi-systemd ]; + nmasur.presets.services.i3.commands = + let + rofi = config.programs.rofi.finalPackage; + in + { + launcher = ''${lib.getExe rofi} -modes drun -show drun -theme-str '@import "launcher.rasi"' ''; + systemdSearch = lib.getExe pkgs.rofi-systemd; + altTab = "${lib.getExe rofi} -show window -modi window"; + calculator = "${lib.getExe rofi} -modes calc -show calc"; + audioSwitch = lib.getExe ( + pkgs.writeShellApplication { + name = "switch-audio"; + runtimeInputs = [ + pkgs.ponymix + rofi + ]; + text = builtins.readFile ./rofi/pulse-sink.sh; + } + ); + }; + programs.rofi = { enable = true; cycle = true; location = "center"; pass = { }; - terminal = lib.mkIf pkgs.stdenv.isLinux config.terminal; + terminal = lib.getExe cfg.terminal; plugins = [ pkgs.rofi-calc pkgs.rofi-emoji diff --git a/platforms/home-manager/modules/nmasur/presets/services/i3.nix b/platforms/home-manager/modules/nmasur/presets/services/i3.nix index e0f10af..db8ebd2 100644 --- a/platforms/home-manager/modules/nmasur/presets/services/i3.nix +++ b/platforms/home-manager/modules/nmasur/presets/services/i3.nix @@ -17,6 +17,10 @@ in type = lib.types.package; description = "Terminal application to launch"; }; + wallpaper = { + type = lib.types.path; + description = "Wallpaper background image file"; + }; commands = { launcher = lib.mkOption { type = lib.types.nullOr lib.types.str; @@ -31,7 +35,7 @@ in updateLockScreen = lib.mkOption { type = lib.types.nullOr lib.types.str; description = "Update lock screen cache"; - default = "${lib.getExe pkgs.betterlockscreen} --update ${config.wallpaper} --display 1 --span"; + default = "${lib.getExe pkgs.betterlockscreen} --update ${cfg.wallpaper} --display 1 --span"; }; toggleBar = lib.mkOption { type = lib.types.nullOr lib.types.str; @@ -271,7 +275,7 @@ in modes = { }; startup = [ { - command = "feh --bg-fill ${config.wallpaper}"; + command = "feh --bg-fill ${cfg.wallpaper}"; always = true; notification = false; } diff --git a/platforms/home-manager/modules/nmasur/profiles/common.nix b/platforms/home-manager/modules/nmasur/profiles/common.nix index 6a43f39..174556b 100644 --- a/platforms/home-manager/modules/nmasur/profiles/common.nix +++ b/platforms/home-manager/modules/nmasur/profiles/common.nix @@ -12,18 +12,30 @@ in options.nmasur.profiles.common.enable = lib.mkEnableOption "Common home-manager config"; config = lib.mkIf cfg.enable { - home.packages = with pkgs; [ - dig # DNS lookup - fd # find - htop # Show system processes - killall # Force quit - inetutils # Includes telnet, whois - jq # JSON manipulation - rsync # Copy folders - ripgrep # grep - sd # sed - unzip # Extract zips + + home.packages = [ + pkgs.dig # DNS lookup + pkgs.fd # find + pkgs.htop # Show system processes + pkgs.killall # Force quit + pkgs.inetutils # Includes telnet, whois + pkgs.jq # JSON manipulation + pkgs.rsync # Copy folders + pkgs.ripgrep # grep + pkgs.sd # sed + pkgs.unzip # Extract zips ]; + nmasur.presets = { + programs = { + bat.enable = true; + ripgrep.enable = true; + fd.enable = true; + }; + services = { + loadkey.enable = lib.mkDefault true; + }; + }; + }; } diff --git a/platforms/home-manager/modules/nmasur/profiles/darwin-base.nix b/platforms/home-manager/modules/nmasur/profiles/darwin-base.nix index 624ca11..8fdf40f 100644 --- a/platforms/home-manager/modules/nmasur/profiles/darwin-base.nix +++ b/platforms/home-manager/modules/nmasur/profiles/darwin-base.nix @@ -20,7 +20,7 @@ in }; # Used for aerc - xdg.enable = true; + xdg.enable = lib.mkDefault pkgs.stdenv.isDarwin; home.packages = [ pkgs.noti # Create notifications programmatically diff --git a/platforms/home-manager/modules/nmasur/profiles/fun.nix b/platforms/home-manager/modules/nmasur/profiles/experimental.nix similarity index 70% rename from platforms/home-manager/modules/nmasur/profiles/fun.nix rename to platforms/home-manager/modules/nmasur/profiles/experimental.nix index 3de70a4..7ea8839 100644 --- a/platforms/home-manager/modules/nmasur/profiles/fun.nix +++ b/platforms/home-manager/modules/nmasur/profiles/experimental.nix @@ -6,12 +6,12 @@ }: let - cfg = config.nmasur.profiles.fun; + cfg = config.nmasur.profiles.experimental; in { - options.nmasur.profiles.fun.enable = lib.mkEnableOption "Fun tools"; + options.nmasur.profiles.experimental.enable = lib.mkEnableOption "experimental tools"; config = lib.mkIf cfg.enable { diff --git a/platforms/home-manager/modules/nmasur/profiles/extra.nix b/platforms/home-manager/modules/nmasur/profiles/extra.nix index 1baf4d9..06b3f58 100644 --- a/platforms/home-manager/modules/nmasur/profiles/extra.nix +++ b/platforms/home-manager/modules/nmasur/profiles/extra.nix @@ -35,23 +35,25 @@ in programs.zoxide.enable = lib.mkDefault true; # Shortcut jump command programs.fish.shellAliases = { - "cd" = lib.mkDefault "${pkgs.zoxide}/bin/zoxide"; - "du" = lib.mkDefault "${pkgs.dua}/bin/dua"; - "ncdu" = lib.mkDefault "${pkgs.du-dust}/bin/du-dust"; - "df" = lib.mkDefault "${pkgs.duf}/bin/duf"; + "cd" = lib.mkDefault lib.getExe pkgs.zoxide; + "du" = lib.mkDefault lib.getExe pkgs.dua; + "ncdu" = lib.mkDefault lib.getExe pkgs.du-dust; + "df" = lib.mkDefault lib.getExe pkgs.duf; # Use eza (exa) instead of ls for fancier output - ls = "${pkgs.eza}/bin/eza --group"; + ls = lib.mkDefault "${lib.getExe pkgs.eza} --group"; # Version of bash which works much better on the terminal - bash = "${pkgs.bashInteractive}/bin/bash"; + bash = lib.mkDefault lib.getExe pkgs.bashInteractive; }; - config.nmasur.presets.bat.enable = lib.mkDefault true; - config.nmasur.presets.fd.enable = lib.mkDefault true; - config.nmasur.presets.ripgrep.enable = lib.mkDefault true; - config.nmasur.presets.prettyping.enable = lib.mkDefault true; - config.nmasur.presets.weather.enable = lib.mkDefault true; + nmasur.presets = { + bat.enable = lib.mkDefault true; + fd.enable = lib.mkDefault true; + ripgrep.enable = lib.mkDefault true; + prettyping.enable = lib.mkDefault true; + weather.enable = lib.mkDefault true; + }; }; } diff --git a/platforms/home-manager/modules/nmasur/profiles/linux-gaming.nix b/platforms/home-manager/modules/nmasur/profiles/linux-gaming.nix index 0a7f139..7cc2ad4 100644 --- a/platforms/home-manager/modules/nmasur/profiles/linux-gaming.nix +++ b/platforms/home-manager/modules/nmasur/profiles/linux-gaming.nix @@ -15,7 +15,7 @@ in config = lib.mkIf cfg.enable { - config.nmasur.programs.wine.enable = lib.mkDefault true; + nmasur.programs.wine.enable = lib.mkDefault true; home.packages = lib.mkDefault [ pkgs.heroic diff --git a/platforms/home-manager/modules/nmasur/profiles/work.nix b/platforms/home-manager/modules/nmasur/profiles/work.nix index 1cdb241..7fc26d2 100644 --- a/platforms/home-manager/modules/nmasur/profiles/work.nix +++ b/platforms/home-manager/modules/nmasur/profiles/work.nix @@ -34,35 +34,40 @@ in pkgs.ipcalc # Make IP network calculations pkgs.cloudflared # Allow connecting to Cloudflare tunnels pkgs.monitorcontrol # Allows adjusting external displays - (pkgs.writeShellApplication { - name = "ocr"; - runtimeInputs = [ pkgs.tesseract ]; - text = builtins.readFile ../../modules/common/shell/bash/scripts/ocr.sh; - }) - (pkgs.writeShellApplication { - name = "ec2"; - runtimeInputs = [ - pkgs.awscli2 - pkgs.jq - pkgs.fzf - ]; - text = builtins.readFile ../../modules/common/shell/bash/scripts/aws-ec2.sh; - }) - (pkgs.writeShellApplication { - name = "tfinit"; - runtimeInputs = [ - pkgs.terraform - pkgs.gawk - pkgs.git - ]; - text = builtins.readFile ../../modules/common/shell/bash/scripts/terraform-init.sh; - }) + pkgs.ocr # Converts images to text + pkgs.aws-ec2 # Browse EC2 instances + pkgs.terraform-init # Quick shortcut for initializing Terraform backend ]; programs.helix.enable = lib.mkDefault true; programs.zed-editor.enable = lib.mkDefault true; - config.nmasur.presets.programs.terraform.enable = lib.mkDefault true; + nmasur.presets = { + programs = { + _1password.enable = lib.mkDefault true; + atuin.enable = lib.mkDefault true; + bash.enable = lib.mkDefault true; + bat.enable = lib.mkDefault true; + direnv.enable = lib.mkDefault true; + dotfiles.enable = lib.mkDefault true; + fd.enable = lib.mkDefault true; + firefox.enable = lib.mkDefault true; + fish.enable = lib.mkDefault true; + fzf.enable = lib.mkDefault true; + git-work.enable = lib.mkDefault true; + git.enable = lib.mkDefault true; + github.enable = lib.mkDefault true; + jujutsu.enable = lib.mkDefault true; + k9s.enable = lib.mkDefault true; + kubectl.enable = lib.mkDefault true; + ldapsearch.enable = lib.mkDefault true; + ripgrep.enable = lib.mkDefault true; + starship.enable = lib.mkDefault true; + terraform.enable = lib.mkDefault true; + weather.enable = lib.mkDefault true; + wezterm.enable = lib.mkDefault true; + }; + }; }; diff --git a/platforms/nix-darwin/default.nix b/platforms/nix-darwin/default.nix new file mode 100644 index 0000000..2de487f --- /dev/null +++ b/platforms/nix-darwin/default.nix @@ -0,0 +1,4 @@ +{ lib, ... }: +{ + imports = lib.filesystem.listFilesRecursive ./.; +} diff --git a/platforms/nix-darwin/modules/nmasur/profiles/base.nix b/platforms/nix-darwin/modules/nmasur/profiles/base.nix index 93a57ec..954043a 100644 --- a/platforms/nix-darwin/modules/nmasur/profiles/base.nix +++ b/platforms/nix-darwin/modules/nmasur/profiles/base.nix @@ -14,6 +14,11 @@ in config = lib.mkIf cfg.enable { + nmasur.presets = { + fish = lib.mkDefault true; + homebrew = lib.mkDefault true; + }; + homebrew.brews = lib.mkDefault [ "trash" # Delete files and folders to trash instead of rm ]; diff --git a/platforms/nix-darwin/modules/nmasur/profiles/extra.nix b/platforms/nix-darwin/modules/nmasur/profiles/extra.nix index 98d4172..756613f 100644 --- a/platforms/nix-darwin/modules/nmasur/profiles/extra.nix +++ b/platforms/nix-darwin/modules/nmasur/profiles/extra.nix @@ -5,15 +5,17 @@ }: let - cfg = config.nmasur.profiles.gaming; + cfg = config.nmasur.profiles.extra; in { - options.nmasur.profiles.gaming.enable = lib.mkEnableOption "extra config for macOS"; + options.nmasur.profiles.extra.enable = lib.mkEnableOption "extra config for macOS"; config = lib.mkIf cfg.enable { + nmasur.profiles.base.enable = lib.mkDefault true; + homebrew.casks = lib.mkDefault [ "keybase" # GUI on Nix not available for macOS ]; diff --git a/platforms/nix-darwin/modules/nmasur/profiles/gaming.nix b/platforms/nix-darwin/modules/nmasur/profiles/gaming.nix index ccba736..ef875aa 100644 --- a/platforms/nix-darwin/modules/nmasur/profiles/gaming.nix +++ b/platforms/nix-darwin/modules/nmasur/profiles/gaming.nix @@ -14,6 +14,8 @@ in config = lib.mkIf cfg.enable { + nmasur.profiles.base.enable = lib.mkDefault true; + homebrew.casks = lib.mkDefault [ "steam" # Not packaged for Nixon macOS "epic-games" # Not packaged for Nix diff --git a/platforms/nix-darwin/modules/nmasur/profiles/work.nix b/platforms/nix-darwin/modules/nmasur/profiles/work.nix index a22d6b7..6c4f5fc 100644 --- a/platforms/nix-darwin/modules/nmasur/profiles/work.nix +++ b/platforms/nix-darwin/modules/nmasur/profiles/work.nix @@ -13,6 +13,9 @@ in options.nmasur.profiles.work.enable = lib.mkEnableOption "work machine"; config = lib.mkIf cfg.enable { + + nmasur.profiles.base.enable = lib.mkDefault true; + homebrew.casks = [ "1password" # 1Password will not launch from Nix on macOS # "gitify" # Git notifications in menu bar (downgrade manually from 4.6.1) diff --git a/platforms/nixos/default.nix b/platforms/nixos/default.nix new file mode 100644 index 0000000..2de487f --- /dev/null +++ b/platforms/nixos/default.nix @@ -0,0 +1,4 @@ +{ lib, ... }: +{ + imports = lib.filesystem.listFilesRecursive ./.; +} diff --git a/platforms/nixos/modules/nmasur/presets/services/lightdm.nix b/platforms/nixos/modules/nmasur/presets/services/lightdm.nix index 3d01348..8c7a105 100644 --- a/platforms/nixos/modules/nmasur/presets/services/lightdm.nix +++ b/platforms/nixos/modules/nmasur/presets/services/lightdm.nix @@ -10,7 +10,13 @@ in { - options.nmasur.presets.services.lightdm.enable = lib.mkEnableOption "Lightdm display manager"; + options.nmasur.presets.services.lightdm = { + enable = lib.mkEnableOption "Lightdm display manager"; + wallpaper = { + type = lib.types.path; + description = "Wallpaper background image file"; + }; + }; config = lib.mkIf cfg.enable { @@ -21,7 +27,7 @@ in displayManager = { lightdm = { enable = true; - background = config.wallpaper; + background = cfg.wallpaper; # Show default user # Also make sure /var/lib/AccountsService/users/ has SystemAccount=false diff --git a/platforms/nixos/modules/nmasur/presets/services/logind.nix b/platforms/nixos/modules/nmasur/presets/services/logind.nix new file mode 100644 index 0000000..5de2166 --- /dev/null +++ b/platforms/nixos/modules/nmasur/presets/services/logind.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +let + cfg = config.nmasur.presets.services.logind; +in +{ + + options.nmasur.presets.services.logind.enable = lib.mkEnableOption "Logind power key management"; + + config = lib.mkIf cfg.enable { + + # Use power button to sleep instead of poweroff + services.logind.powerKey = "suspend"; + services.logind.powerKeyLongPress = "poweroff"; + + }; + +} diff --git a/platforms/nixos/modules/nmasur/profiles/base.nix b/platforms/nixos/modules/nmasur/profiles/base.nix index 4ef3ad0..9969bf0 100644 --- a/platforms/nixos/modules/nmasur/profiles/base.nix +++ b/platforms/nixos/modules/nmasur/profiles/base.nix @@ -15,21 +15,34 @@ in config = lib.mkIf cfg.enable { # Allows us to declaritively set password - users.mutableUsers = false; + users.mutableUsers = lib.mkDefault false; # 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; + isNormalUser = lib.mkDefault true; # Automatically create a password to start - hashedPassword = config.passwordHash; + hashedPassword = lib.mkDefault config.passwordHash; - extraGroups = [ + extraGroups = lib.mkDefault [ "wheel" # Sudo privileges ]; }; + # Include home-manager config in NixOS + home-manager = { + sharedModules = [ ../../../../home-manager ]; + + # Use the system-level nixpkgs instead of Home Manager's + useGlobalPkgs = lib.mkDefault true; + + # Install packages to /etc/profiles instead of ~/.nix-profile, useful when + # using multiple profiles for one user + useUserPackages = lib.mkDefault true; + + }; + }; } diff --git a/platforms/nixos/modules/nmasur/profiles/on-premises.nix b/platforms/nixos/modules/nmasur/profiles/on-premises.nix index 32e51ab..6fa2a72 100644 --- a/platforms/nixos/modules/nmasur/profiles/on-premises.nix +++ b/platforms/nixos/modules/nmasur/profiles/on-premises.nix @@ -15,24 +15,27 @@ in config = lib.mkIf cfg.enable { + # Configure physical power buttons + nmasur.presets.services.logind.enable = lib.mkDefault true; + # Enable automatic timezone updates based on location - services.tzupdate.enable = true; + services.tzupdate.enable = lib.mkDefault true; # Allow reading from Windows drives boot.supportedFilesystems = [ "ntfs" ]; # Enable fstrim, which tracks free space on SSDs for garbage collection # More info: https://www.reddit.com/r/NixOS/comments/rbzhb1/if_you_have_a_ssd_dont_forget_to_enable_fstrim/ - services.fstrim.enable = true; + services.fstrim.enable = lib.mkDefault true; - networking.useDHCP = !config.networking.networkmanager.enable; + networking.useDHCP = lib.mkDefault (!config.networking.networkmanager.enable); networking.wireless = { # Enables wireless support via wpa_supplicant. - enable = !config.networking.networkmanager.enable; + enable = lib.mkDefault (!config.networking.networkmanager.enable); # Allows the user to control the WiFi settings. - userControlled.enable = true; + userControlled.enable = lib.mkDefault true; }; # Wake up tempest with a command @@ -40,5 +43,25 @@ in (pkgs.writeShellScriptBin "wake-tempest" "${pkgs.wakeonlan}/bin/wakeonlan --ip=192.168.1.255 74:56:3C:40:37:5D") ]; + # Prevent wake from keyboard + powerManagement.powerDownCommands = lib.mkDefault '' + set +e + + # Fix for Gigabyte motherboard + # /r/archlinux/comments/y7b97e/my_computer_wakes_up_immediately_after_i_suspend/isu99sr/ + # Disable if enabled + if (grep "GPP0.*enabled" /proc/acpi/wakeup >/dev/null); then + echo GPP0 | ${pkgs.doas}/bin/doas tee /proc/acpi/wakeup + fi + + sleep 2 + + set -e + ''; + services.udev.extraRules = lib.mkDefault '' + ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usb", ATTR{power/wakeup}="disabled" + ACTION=="add", SUBSYSTEM=="i2c", ATTR{power/wakeup}="disabled" + ''; + }; } diff --git a/platforms/nixos/modules/nmasur/profiles/server.nix b/platforms/nixos/modules/nmasur/profiles/server.nix index d3bd5a7..4cb91b7 100644 --- a/platforms/nixos/modules/nmasur/profiles/server.nix +++ b/platforms/nixos/modules/nmasur/profiles/server.nix @@ -1,6 +1,5 @@ { config, - pkgs, lib, ... }: @@ -15,38 +14,13 @@ in config = lib.mkIf cfg.enable { - networking.firewall.allowPing = true; + networking.firewall.allowPing = lib.mkDefault true; # Implement a simple fail2ban service for sshd - services.sshguard.enable = true; + services.sshguard.enable = lib.mkDefault true; # Servers need a bootloader or they won't start - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - # Use power button to sleep instead of poweroff - services.logind.powerKey = "suspend"; - services.logind.powerKeyLongPress = "poweroff"; - - # Prevent wake from keyboard - powerManagement.powerDownCommands = '' - set +e - - # Fix for Gigabyte motherboard - # /r/archlinux/comments/y7b97e/my_computer_wakes_up_immediately_after_i_suspend/isu99sr/ - # Disable if enabled - if (grep "GPP0.*enabled" /proc/acpi/wakeup >/dev/null); then - echo GPP0 | ${pkgs.doas}/bin/doas tee /proc/acpi/wakeup - fi - - sleep 2 - - set -e - ''; - services.udev.extraRules = '' - ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usb", ATTR{power/wakeup}="disabled" - ACTION=="add", SUBSYSTEM=="i2c", ATTR{power/wakeup}="disabled" - ''; - + boot.loader.systemd-boot.enable = lib.mkDefault true; + boot.loader.efi.canTouchEfiVariables = lib.mkDefault true; }; } diff --git a/platforms/nixos/modules/nmasur/profiles/shared-media.nix b/platforms/nixos/modules/nmasur/profiles/shared-media.nix index f2a46e0..088c089 100644 --- a/platforms/nixos/modules/nmasur/profiles/shared-media.nix +++ b/platforms/nixos/modules/nmasur/profiles/shared-media.nix @@ -1,6 +1,5 @@ { config, - pkgs, lib, ... }: diff --git a/platforms/nixos/modules/nmasur/profiles/wsl.nix b/platforms/nixos/modules/nmasur/profiles/wsl.nix index f857c72..b8f93cc 100644 --- a/platforms/nixos/modules/nmasur/profiles/wsl.nix +++ b/platforms/nixos/modules/nmasur/profiles/wsl.nix @@ -9,12 +9,12 @@ in config = lib.mkIf cfg.enable { - # Replace config directory with our repo, since it sources from config on - # every launch - system.activationScripts.configDir.text = '' - rm -rf /etc/nixos - ln --symbolic --no-dereference --force ${config.dotfilesPath} /etc/nixos - ''; + # # Replace config directory with our repo, since it sources from config on + # # every launch + # system.activationScripts.configDir.text = '' + # rm -rf /etc/nixos + # ln --symbolic --no-dereference --force ${config.dotfilesPath} /etc/nixos + # ''; };