diff --git a/flake.lock b/flake.lock index bc476de..9b9f195 100644 --- a/flake.lock +++ b/flake.lock @@ -197,10 +197,7 @@ }, "flake-parts": { "inputs": { - "nixpkgs-lib": [ - "nixvim", - "nixpkgs" - ] + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { "lastModified": 1743550720, @@ -315,7 +312,7 @@ }, "flake-utils_5": { "inputs": { - "systems": "systems_5" + "systems": "systems_6" }, "locked": { "lastModified": 1705309234, @@ -333,7 +330,7 @@ }, "flake-utils_6": { "inputs": { - "systems": "systems_6" + "systems": "systems_7" }, "locked": { "lastModified": 1710146030, @@ -351,7 +348,7 @@ }, "flake-utils_7": { "inputs": { - "systems": "systems_7" + "systems": "systems_8" }, "locked": { "lastModified": 1705309234, @@ -527,34 +524,6 @@ "type": "github" } }, - "ixx": { - "inputs": { - "flake-utils": [ - "nixvim", - "nuschtosSearch", - "flake-utils" - ], - "nixpkgs": [ - "nixvim", - "nuschtosSearch", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1737371634, - "narHash": "sha256-fTVAWzT1UMm1lT+YxHuVPtH+DATrhYfea3B0MxG/cGw=", - "owner": "NuschtOS", - "repo": "ixx", - "rev": "a1176e2a10ce745ff8f63e4af124ece8fe0b1648", - "type": "github" - }, - "original": { - "owner": "NuschtOS", - "ref": "v0.0.7", - "repo": "ixx", - "type": "github" - } - }, "langref": { "flake": false, "locked": { @@ -567,6 +536,21 @@ "url": "https://raw.githubusercontent.com/ziglang/zig/0fb2015fd3422fc1df364995f9782dfe7255eccd/doc/langref.html.in" } }, + "mnw": { + "locked": { + "lastModified": 1746338991, + "narHash": "sha256-GbyoHjf14LOxZQc+0NFblI4xf/uwGrYo3W8lwE4HcwI=", + "owner": "Gerg-L", + "repo": "mnw", + "rev": "c65407ee9387ef75985dad3e30f58c822c766ec1", + "type": "github" + }, + "original": { + "owner": "Gerg-L", + "repo": "mnw", + "type": "github" + } + }, "moonlight": { "inputs": { "flake-utils": "flake-utils", @@ -608,6 +592,32 @@ "type": "github" } }, + "nil": { + "inputs": { + "flake-utils": [ + "nvf", + "flake-utils" + ], + "nixpkgs": [ + "nvf", + "nixpkgs" + ], + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1741118843, + "narHash": "sha256-ggXU3RHv6NgWw+vc+HO4/9n0GPufhTIUjVuLci8Za8c=", + "owner": "oxalica", + "repo": "nil", + "rev": "577d160da311cc7f5042038456a0713e9863d09e", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "nil", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -687,6 +697,21 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1746557022, @@ -765,28 +790,6 @@ "type": "github" } }, - "nixvim": { - "inputs": { - "flake-parts": "flake-parts", - "nixpkgs": [ - "nixpkgs" - ], - "nuschtosSearch": "nuschtosSearch" - }, - "locked": { - "lastModified": 1746625905, - "narHash": "sha256-El/fOZAhTDJRsPN5dro9F3cNHyclk00Acjl1nVQAEDI=", - "owner": "nix-community", - "repo": "nixvim", - "rev": "5c52e8f9e438b6850f2c7a6e4bf3f967a3a699fd", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixvim", - "type": "github" - } - }, "nur": { "inputs": { "flake-parts": "flake-parts_2", @@ -810,26 +813,28 @@ "type": "github" } }, - "nuschtosSearch": { + "nvf": { "inputs": { + "flake-parts": "flake-parts", "flake-utils": "flake-utils_3", - "ixx": "ixx", + "mnw": "mnw", + "nil": "nil", "nixpkgs": [ - "nixvim", "nixpkgs" - ] + ], + "systems": "systems_4" }, "locked": { - "lastModified": 1745046075, - "narHash": "sha256-8v4y6k16Ra/fiecb4DxhsoOGtzLKgKlS+9/XJ9z0T2I=", - "owner": "NuschtOS", - "repo": "search", - "rev": "066afe8643274470f4a294442aadd988356a478f", + "lastModified": 1746940940, + "narHash": "sha256-ASB3QVEoFK5//280uedYdt8jyDLhFa9zgj8qfc0S7Sk=", + "owner": "notashelf", + "repo": "nvf", + "rev": "815ed49d3693346122ef61da6d7443cd3cc21752", "type": "github" }, "original": { - "owner": "NuschtOS", - "repo": "search", + "owner": "notashelf", + "repo": "nvf", "type": "github" } }, @@ -857,8 +862,8 @@ "nixos-cosmic": "nixos-cosmic", "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable_2", - "nixvim": "nixvim", - "rust-overlay": "rust-overlay_2", + "nvf": "nvf", + "rust-overlay": "rust-overlay_3", "stylix": "stylix", "zig": "zig", "zls": "zls" @@ -886,6 +891,28 @@ } }, "rust-overlay_2": { + "inputs": { + "nixpkgs": [ + "nvf", + "nil", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741055476, + "narHash": "sha256-52vwEV0oS2lCnx3c/alOFGglujZTLmObit7K8VblnS8=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "aefb7017d710f150970299685e8d8b549d653649", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_3": { "inputs": { "nixpkgs": [ "nixpkgs" @@ -1005,7 +1032,7 @@ "nixpkgs" ], "nur": "nur", - "systems": "systems_4", + "systems": "systems_5", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", @@ -1131,6 +1158,21 @@ "type": "github" } }, + "systems_8": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tinted-foot": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index ee9fe40..4cc9d0e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "New Modular flake!"; + description = "multi device configuration flake"; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs-stable.url = "nixpkgs/nixos-23.11"; @@ -7,112 +7,155 @@ home-manager.url = "github:nix-community/home-manager/master"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; - apple-fonts = { - url = "github:Lyndeno/apple-fonts.nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + apple-fonts.url = "github:Lyndeno/apple-fonts.nix"; + apple-fonts.inputs.nixpkgs.follows = "nixpkgs"; - nixvim = { - url = "github:nix-community/nixvim"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + nvf.url = "github:notashelf/nvf"; + nvf.inputs.nixpkgs.follows = "nixpkgs"; - darwin = { - url = "github:lnl7/nix-darwin/master"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + darwin.url = "github:lnl7/nix-darwin/master"; + darwin.inputs.nixpkgs.follows = "nixpkgs"; zig.url = "github:mitchellh/zig-overlay"; zls.url = "github:zigtools/zls?rev=a26718049a8657d4da04c331aeced1697bc7652b"; - stylix = { - url = "github:danth/stylix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + stylix.url = "github:danth/stylix"; + stylix.inputs.nixpkgs.follows = "nixpkgs"; - moonlight = { - url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly. - inputs.nixpkgs.follows = "nixpkgs"; - }; - nixos-cosmic = { - url = "github:lilyinstarlight/nixos-cosmic"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + moonlight.url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly. + moonlight.inputs.nixpkgs.follows = "nixpkgs"; - nh = { - url = "github:viperML/nh"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - nix-options-search = { - url = "github:madsbv/nix-options-search"; - }; + nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic"; + nixos-cosmic.inputs.nixpkgs.follows = "nixpkgs"; + + nh.url = "github:viperML/nh"; + nh.inputs.nixpkgs.follows = "nixpkgs"; + + nix-options-search.url = "github:madsbv/nix-options-search"; nix-index-database.url = "github:nix-community/nix-index-database"; nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { - nixpkgs, - nixos-cosmic, - nix-index-database, - darwin, - ... - } @ inputs: let - overlays = [ - inputs.zig.overlays.default - inputs.rust-overlay.overlays.default - inputs.nh.overlays.default - ]; + outputs = + { + nixpkgs, + nixos-cosmic, + darwin, + ... + }@inputs: + let + lib = nixpkgs.lib; - mkSystem = import ./lib/mkSystem.nix { - inherit overlays nixpkgs inputs; - }; - in rec { - # "nix run .#darwin-rebuild" - packages.aarch64-darwin.darwin-rebuild = darwin.packages.aarch64-darwin.darwin-rebuild; - # "nix fmt ." - formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; - formatter.aarch64-darwin = nixpkgs.legacyPackages.aarch64-darwin.alejandra; + # TODO: apply these overlays sooner and remove uses of legacyPackages elsewhere. + overlays = [ + inputs.zig.overlays.default + inputs.rust-overlay.overlays.default + inputs.nh.overlays.default - # natalie's desktop computer - nixosConfigurations.nixos = mkSystem "nixos" { - user = "natalie"; - host = "desktop"; - system = "x86_64-linux"; - extraModules = [ - nixos-cosmic.nixosModules.default + # https://github.com/LnL7/nix-darwin/issues/1041 + (_: prev: { + karabiner-elements = prev.karabiner-elements.overrideAttrs (old: { + version = "14.13.0"; + + src = prev.fetchurl { + inherit (old.src) url; + hash = "sha256-gmJwoht/Tfm5qMecmq1N6PSAIfWOqsvuHU8VDJY8bLw="; + }; + }); + }) ]; - }; - # natalie's laptop - darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { - user = "natalie"; - host = "laptop"; - system = "aarch64-darwin"; - }; - # chloe's mac studio "sandwich" - darwinConfigurations.sandwich = mkSystem "sandwich" { - user = "chloe"; - host = "sandwich"; - system = "aarch64-darwin"; - }; - # chloe's macbook air "paperback" - darwinConfigurations.paperback = mkSystem "paperback" { - user = "chloe"; - host = "paperback"; - system = "aarch64-darwin"; - }; + # Users of this flake currently use x86_64 Linux and Apple Silicon + systems = [ + "x86_64-linux" + "aarch64-darwin" + ]; + forAllSystems = + f: + builtins.listToAttrs ( + builtins.map (system: { + name = system; + value = f ( + inputs + // { + inherit system; + pkgs = nixpkgs.legacyPackages.${system}; + } + ); + }) systems + ); - # generate checks for "nix flake check --all-systems --no-build" - checks.aarch64-darwin = builtins.listToAttrs (builtins.map (name: let - d = darwinConfigurations.${name}.system; - in { - name = "darwinConfiguration-" + d.name; - value = d; - }) (builtins.attrNames darwinConfigurations)); - }; + mkSystem = import ./lib/mkSystem.nix { + inherit + overlays + nixpkgs + inputs + mkNeovim + ; + }; + mkNeovim = import ./lib/mkNeovim.nix { + inherit overlays nixpkgs inputs; + }; + in + rec { + # "nix fmt" + formatter = forAllSystems (inputs: inputs.pkgs.nixfmt-tree); + packages = forAllSystems ( + { system, ... }: + { + nvim-chloe = mkNeovim "chloe" system; + nvim-natalie = mkNeovim "natalie" system; + } + // lib.optionalAttrs (system == "aarch64-darwin") { + # "nix run .#darwin-rebuild" + darwin-rebuild = darwin.packages.aarch64-darwin.darwin-rebuild; + } + ); + + # natalie's desktop computer + nixosConfigurations.nixos = mkSystem "nixos" { + user = "natalie"; + host = "desktop"; + system = "x86_64-linux"; + extraModules = [ + nixos-cosmic.nixosModules.default + ]; + }; + # natalie's laptop + darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { + user = "natalie"; + host = "laptop"; + system = "aarch64-darwin"; + }; + + # chloe's mac studio "sandwich" + darwinConfigurations.sandwich = mkSystem "sandwich" { + user = "chloe"; + host = "sandwich"; + system = "aarch64-darwin"; + }; + # chloe's macbook air "paperback" + darwinConfigurations.paperback = mkSystem "paperback" { + user = "chloe"; + host = "paperback"; + system = "aarch64-darwin"; + }; + + # generate checks for "nix flake check --all-systems --no-build" + checks.aarch64-darwin = builtins.listToAttrs ( + builtins.map ( + name: + let + d = darwinConfigurations.${name}.system; + in + { + name = "darwinConfiguration-" + d.name; + value = d; + } + ) (builtins.attrNames darwinConfigurations) + ); + }; } diff --git a/lib/mkNeovim.nix b/lib/mkNeovim.nix new file mode 100644 index 0000000..3922e43 --- /dev/null +++ b/lib/mkNeovim.nix @@ -0,0 +1,29 @@ +{ + nixpkgs, + # TODO: apply overlays here + overlays, + inputs, +}: +user: system: +let + darwin = nixpkgs.lib.strings.hasSuffix "-darwin" system; + + host = { + inherit darwin; + linux = !darwin; + }; + + userDir = ../users + "/${user}"; + userConfig = import (userDir + "/user.nix"); +in +(inputs.nvf.lib.neovimConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + modules = builtins.filter (f: f != null) [ + (../users + ("/" + user + "/vim.nix")) + ../modules/neovim + ]; + extraSpecialArgs = { + inherit host; + user = userConfig; + }; +}).neovim diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index 09f69df..53992b3 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -4,30 +4,21 @@ nixpkgs, overlays, inputs, -}: name: { + mkNeovim, +}: +name: +{ user, # ./users/{name} host, # ./users/{name}/{host} (optional) system, # arch-os - extraModules ? [], -}: let - inherit (builtins) pathExists; + extraModules ? [ ], +}: +let darwin = nixpkgs.lib.strings.hasSuffix "-darwin" system; - getInputModule = a: b: - inputs.${ - a - }.${ - if darwin - then "darwinModules" - else "nixosModules" - }.${ - b - }; + getInputModule = a: b: inputs.${a}.${if darwin then "darwinModules" else "nixosModules"}.${b}; # NixOS vs nix-darwin functions - systemFunc = - if darwin - then inputs.darwin.lib.darwinSystem - else nixpkgs.lib.nixosSystem; + systemFunc = if darwin then inputs.darwin.lib.darwinSystem else nixpkgs.lib.nixosSystem; userDir = ../users + "/${user}"; userConfig = import (userDir + "/user.nix"); @@ -38,10 +29,7 @@ hostHomePath = hostDir + "/home.nix"; userHomePath = userDir + "/home.nix"; - pathOrNull = a: - if pathExists a - then a - else null; + pathOrNull = a: if builtins.pathExists a then a else null; # Arguments passed to all module files args = { @@ -50,100 +38,92 @@ # Details about the host machine host = { inherit darwin name; + linux = !darwin; }; - user = ({ - # This acts as formal documentation for what is allowed in user.nix - username, # unix username - name, # your display name - email, # for identity in programs such as git - dotfilesDir, # location to `../.` - timeZone ? "America/Los_Angeles", - # Stylix/Theming - theme ? null, # theme name for stylix - sexuality ? null, # pride flag for hyfetch - font ? null, # font to use - term, # preferred $TERM - editor, # preferred $EDITOR - browser ? null, # preferred $BROWSER - } @ user: - user) - userConfig; + user = + ( + { + # This acts as formal documentation for what is allowed in user.nix + username, # unix username + name, # your display name + email, # for identity in programs such as git + dotfilesDir, # location to `../.` + timeZone ? "America/Los_Angeles", + # Stylix/Theming + theme ? null, # theme name for stylix + sexuality ? null, # pride flag for hyfetch + font ? null, # font to use + term, # preferred $TERM + editor, # preferred $EDITOR + browser ? null, # preferred $BROWSER + }@user: + user + ) + userConfig; }; systemSettings = rec { inherit darwin; - homeDir = "/${ - if darwin - then "Users" - else "home" - }/${userConfig.username}"; + homeDir = "/${if darwin then "Users" else "home"}/${userConfig.username}"; }; + + mainHomeImports = builtins.filter (f: f != null) [ + (pathOrNull userHomePath) + (pathOrNull hostHomePath) + { + home.packages = [ + (mkNeovim user system) + ]; + } + ]; in - systemFunc { - inherit system; +systemFunc { + inherit system; - modules = - builtins.filter (f: f != null) - [ - # Apply our overlays. Overlays are keyed by system type so we have - # to go through and apply our system type. We do this first so - # the overlays are available globally. - {nixpkgs.overlays = overlays;} + modules = + builtins.filter (f: f != null) [ + # Apply our overlays. Overlays are keyed by system type so we have + # to go through and apply our system type. We do this first so + # the overlays are available globally. + { nixpkgs.overlays = overlays; } - # Modules shared between nix-darwin and NixOS - ../modules/shared - # Modules for the specific OS - ( - if darwin - then ../modules/macos - else ../modules/nixos - ) + # Modules shared between nix-darwin and NixOS + ../modules/shared + # Modules for the specific OS + (if darwin then ../modules/macos else ../modules/nixos) - # The user-wide configuration.nix - (pathOrNull userConfigPath) - # The host-wide configuration.nix - ( - pathOrNull hostConfigPath - ) + # The user-wide configuration.nix + (pathOrNull userConfigPath) + # The host-wide configuration.nix + (pathOrNull hostConfigPath) - # Set up nix-index and enable comma for easy one-shot command use - # https://github.com/nix-community/comma - (getInputModule "nix-index-database" "nix-index") - {programs.nix-index-database.comma.enable = true;} + # Set up nix-index and enable comma for easy one-shot command use + # https://github.com/nix-community/comma + (getInputModule "nix-index-database" "nix-index") + { programs.nix-index-database.comma.enable = true; } - # Themes for all programs - (getInputModule "stylix" "stylix") + # Themes for all programs + (getInputModule "stylix" "stylix") - # Home manager - (getInputModule "home-manager" "home-manager") - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - backupFileExtension = "hm-backup"; - # Arguments passed to all module files - extraSpecialArgs = - args - // { - mainHomeImports = builtins.filter (f: f != null) [ - ( - pathOrNull userHomePath - ) - ( - pathOrNull hostHomePath - ) - #Can't have conditional import path - ../modules/macos/tiling/sketchybar-home.nix - ]; - }; - # can't find how to make this an array without the param - users.${userConfig.username} = ../modules/home-manager.nix; + # Home manager + (getInputModule "home-manager" "home-manager") + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "hm-backup"; + # Arguments passed to all module files + extraSpecialArgs = args // { + inherit mainHomeImports; }; - users.users.${userConfig.username}.home = systemSettings.homeDir; - } + # can't find how to make this an array without the param + users.${userConfig.username} = ../modules/home; + }; + users.users.${userConfig.username}.home = systemSettings.homeDir; + } - # Arguments passed to all module files - {config._module.args = args;} - ] - # Add extra modules specified from config - ++ extraModules; - } + # Arguments passed to all module files + { config._module.args = args; } + ] + # Add extra modules specified from config + ++ extraModules; +} diff --git a/modules/home-manager.nix b/modules/home/default.nix similarity index 88% rename from modules/home-manager.nix rename to modules/home/default.nix index ae8767d..98635b4 100644 --- a/modules/home-manager.nix +++ b/modules/home/default.nix @@ -8,10 +8,14 @@ host, mainHomeImports, ... -}: let +}: +let cfg = config.programs; -in { - imports = mainHomeImports; +in +{ + imports = mainHomeImports ++ [ + ./macos/sketchybar.nix + ]; programs = { home-manager.enable = true; nix-index.enable = true; @@ -40,7 +44,14 @@ in { daemon.enable = cfg.atuin.enable; }; bat = { - extraPackages = with pkgs.bat-extras; [batdiff batman batgrep batwatch batpipe prettybat]; + extraPackages = with pkgs.bat-extras; [ + batdiff + batman + batgrep + batwatch + batpipe + prettybat + ]; }; hyfetch = { settings = { @@ -69,7 +80,7 @@ in { } ]; shellAliases = - {} + { } // lib.optionalAttrs (!host.darwin) { reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; }; diff --git a/modules/home/macos/sketchybar.nix b/modules/home/macos/sketchybar.nix new file mode 100644 index 0000000..8df07f7 --- /dev/null +++ b/modules/home/macos/sketchybar.nix @@ -0,0 +1,408 @@ +{ + pkgs, + lib, + config, + host, + ... +}: +let + # folder = "${config.home.homeDirectory}.dotfiles/files/sketchybar"; + # folder = "~/.dotfiles/files/sketchybar"; + folder = ../../../files/sketchybar; +in +lib.mkIf (host.darwin) { + home.file = + lib.attrsets.mapAttrs + ( + file: value: (lib.attrsets.overrideExisting value { enable = config.shared.darwin.tiling.enable; }) + ) + { + sketchybarrc = { + executable = true; + target = ".config/sketchybar/sketchybarrc"; + text = '' + #!/usr/bin/env sh + + source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors + source "$HOME/.config/sketchybar/icons.sh" # Loads all defined icons + + ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured + PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored + + FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants + PADDINGS=3 # All paddings use this value (icon, label, background) + + # Setting up and starting the helper process + HELPER=git.felix.helper + killall helper + cd $HOME/.config/sketchybar/helper && make + $HOME/.config/sketchybar/helper/helper $HELPER > /dev/null 2>&1 & + + # Unload the macOS on screen indicator overlay for volume change + # launchctl unload -F /System/Library/LaunchAgents/com.apple.OSDUIHelper.plist > /dev/null 2>&1 & + + # Setting up the general bar appearance and default values + ${pkgs.sketchybar}/bin/sketchybar --bar height=40 \ + color=$BAR_COLOR \ + shadow=off \ + position=top \ + sticky=on \ + padding_right=0 \ + padding_left=0 \ + corner_radius=12 \ + y_offset=0 \ + margin=2 \ + blur_radius=0 \ + notch_width=0 \ + --default updates=when_shown \ + icon.font="$FONT:Bold:14.0" \ + icon.color=$ICON_COLOR \ + icon.padding_left=$PADDINGS \ + icon.padding_right=$PADDINGS \ + label.font="$FONT:Semibold:13.0" \ + label.color=$LABEL_COLOR \ + label.padding_left=$PADDINGS \ + label.padding_right=$PADDINGS \ + background.padding_right=$PADDINGS \ + background.padding_left=$PADDINGS \ + background.height=26 \ + background.corner_radius=9 \ + popup.background.border_width=2 \ + popup.background.corner_radius=11 \ + popup.background.border_color=$POPUP_BORDER_COLOR \ + popup.background.color=$POPUP_BACKGROUND_COLOR \ + popup.background.shadow.drawing=on + + # Left + source "$ITEM_DIR/apple.sh" + source "$ITEM_DIR/spaces.sh" + source "$ITEM_DIR/front_app.sh" + + # Center + # source "$ITEM_DIR/spotify.sh" + source "$ITEM_DIR/calendar.sh" + + # Right + # source "$ITEM_DIR/brew.sh" + # source "$ITEM_DIR/github.sh" + source "$ITEM_DIR/volume.sh" + # source "$ITEM_DIR/divider.sh" + # source "$ITEM_DIR/cpu.sh" + + # Forcing all item scripts to run (never do this outside of sketchybarrc) + ${pkgs.sketchybar}/bin/sketchybar --update + + echo "sketchybar configuation loaded.." + ''; + }; + icons = { + executable = true; + target = ".config/sketchybar/icons.sh"; + source = folder + /icons.sh; + }; + colors = { + executable = true; + target = ".config/sketchybar/colors.sh"; + text = '' + #!/usr/bin/env sh + # Color Palette + export BLACK=0xff4c4f69 + export WHITE=0xffeff1f5 + export RED=0xffd20f39 + export GREEN=0xff40a02b + export BLUE=0xff1e66f5 + export YELLOW=0xffdf8e1d + export ORANGE=0xfffe640b + export MAGENTA=0xffea76cb + export GREY=0xff9ca0b0 + export TRANSPARENT=0xff000000 + export BLUE2=0xff7287fd + export FLAMINGO=0xffdd7878 + + # General bar colors + export BAR_COLOR=0xeff1f5ff # Color of the bar + export ICON_COLOR=0xff4c4f69 + export LABEL_COLOR=0xff4c4f69 # Color of all labels + export BACKGROUND_1=0xffbcc0cc + export BACKGROUND_2=0xffbcc0cc + + export POPUP_BACKGROUND_COLOR=$BLACK + export POPUP_BORDER_COLOR=$WHITE + + export SHADOW_COLOR=$BLACK + ''; + }; + items_apple = { + executable = true; + target = ".config/sketchybar/items/apple.sh"; + source = folder + /items/executable_apple.sh; + }; + items_brew = { + executable = true; + target = ".config/sketchybar/items/brew.sh"; + source = folder + /items/executable_brew.sh; + }; + items_calendar = { + executable = true; + target = ".config/sketchybar/items/calendar.sh"; + text = '' + #!/usr/bin/env sh + + sketchybar --add item calendar center \ + --set calendar icon=cal \ + display=1 \ + icon.font="$FONT:Black:12.0" \ + icon.padding_right=0 \ + label.width=50 \ + label.align=right \ + background.padding_left=15 \ + update_freq=30 \ + script="$PLUGIN_DIR/calendar.sh" \ + click_script="$PLUGIN_DIR/zen.sh" + ''; + }; + items_cpu = { + executable = true; + target = ".config/sketchybar/items/cpu.sh"; + source = folder + /items/executable_cpu.sh; + }; + items_divider = { + executable = true; + target = ".config/sketchybar/items/divider.sh"; + source = folder + /items/executable_divider.sh; + }; + items_front_app = { + executable = true; + target = ".config/sketchybar/items/front_app.sh"; + text = '' + #!/usr/bin/env sh + FRONT_APP_SCRIPT='sketchybar --set $NAME label="$INFO"' + sketchybar --add event window_focus \ + --add event windows_on_spaces \ + --add item system.aerospace left \ + --set system.aerospace script="$PLUGIN_DIR/aerospace.sh" \ + icon.font="$FONT:Bold:16.0" \ + label.drawing=off \ + icon.width=30 \ + icon=$YABAI_GRID \ + icon.color=$BLACK \ + updates=on \ + display=active \ + --subscribe system.aerospace window_focus \ + windows_on_spaces \ + mouse.clicked \ + --add item front_app left \ + --set front_app script="$FRONT_APP_SCRIPT" \ + icon.drawing=off \ + background.padding_left=0 \ + background.padding_right=10 \ + label.color=$BLACK \ + label.font="$FONT:Black:12.0" \ + display=active \ + --subscribe front_app front_app_switched + ''; + }; + items_github = { + executable = true; + target = ".config/sketchybar/items/github.sh"; + source = folder + /items/executable_github.sh; + }; + items_spaces = { + executable = true; + target = ".config/sketchybar/items/spaces.sh"; + # label.background.color=$BACKGROUND_2 + text = '' + ${pkgs.sketchybar}/bin/sketchybar --add event aerospace_workspace_change + ${pkgs.sketchybar}/bin/sketchybar --add event aerospace_mode_change + for sid in $(${pkgs.aerospace}/bin/aerospace list-workspaces --all); do + ${pkgs.sketchybar}/bin/sketchybar --add item space.$sid left \ + --subscribe space.$sid aerospace_workspace_change \ + --subscribe space.$sid aerospace_mode_change \ + --set space.$sid \ + icon=$sid \ + icon.padding_left=22 \ + icon.padding_right=22 \ + icon.highlight_color=$WHITE \ + icon.highlight=off \ + icon.color=0xff4c566a \ + background.padding_left=-8 \ + background.padding_right=-8 \ + background.color=$BACKGROUND_1 \ + background.drawing=on \ + script="$PLUGIN_DIR/aerospace.sh $sid" \ + click_script="aerospace workspace $sid" \ + label.font="Iosevka Nerd Font:Regular:16.0" \ + label.padding_right=33 \ + label.background.height=26 \ + label.background.drawing=on \ + label.background.corner_radius=9 \ + label.drawing=off + done + ${pkgs.sketchybar}/bin/sketchybar --add item separator left \ + --set separator icon= \ + icon.font="Iosevka Nerd Font:Regular:16.0" \ + background.padding_left=26 \ + background.padding_right=15 \ + label.drawing=off \ + display=active \ + icon.color=$GREEN + ''; + }; + items_spotify = { + executable = true; + target = ".config/sketchybar/items/spotify.sh"; + source = folder + /items/executable_spotify.sh; + }; + items_volume = { + executable = true; + target = ".config/sketchybar/items/volume.sh"; + text = '' + INITIAL_WIDTH=$(osascript -e 'set ovol to output volume of (get volume settings)') + ${pkgs.sketchybar}/bin/sketchybar --add item volume right \ + --subscribe volume volume_change \ + --set volume script="$PLUGIN_DIR/volume.sh" \ + updates=on \ + icon.background.drawing=on \ + icon.background.color=$FLAMINGO \ + icon.background.height=8 \ + icon.background.corner_radius=3 \ + icon.width=$INITIAL_WIDTH \ + width=100 \ + icon.align=right \ + label.drawing=off \ + background.drawing=on \ + background.color=$BACKGROUND_2 \ + background.height=8 \ + background.corner_radius=3 \ + align=left + + ${pkgs.sketchybar}/bin/sketchybar --add alias "Control Center,Sound" right \ + --rename "Control Center,Sound" volume_alias \ + --set volume_alias icon.drawing=off \ + label.drawing=off \ + alias.color=$BLUE2 \ + background.padding_right=0 \ + background.padding_left=5 \ + width=50 \ + align=right \ + click_script="$PLUGIN_DIR/volume_click.sh" + + ''; + }; + plugins_brew = { + executable = true; + target = ".config/sketchybar/plugins/brew.sh"; + source = folder + /plugins/executable_brew.sh; + }; + plugins_calendar = { + executable = true; + target = ".config/sketchybar/plugins/calendar.sh"; + source = folder + /plugins/executable_calendar.sh; + }; + plugins_github = { + executable = true; + target = ".config/sketchybar/plugins/github.sh"; + source = folder + /plugins/executable_github.sh; + }; + plugins_icon_map = { + executable = true; + target = ".config/sketchybar/plugins/icon_map.sh"; + source = folder + /plugins/executable_icon_map.sh; + }; + plugins_space = { + executable = true; + target = ".config/sketchybar/plugins/space.sh"; + source = folder + /plugins/executable_space.sh; + }; + plugins_spotify = { + executable = true; + target = ".config/sketchybar/plugins/spotify.sh"; + source = folder + /plugins/executable_spotify.sh; + }; + plugins_volume = { + executable = true; + target = ".config/sketchybar/plugins/volume.sh"; + text = '' + #!/usr/bin/env sh + WIDTH=100 + + volume_change() { + # INITIAL_WIDTH=$(${pkgs.sketchybar}/bin/sketchybar --query $NAME | ${pkgs.jq}/bin/jq ".icon.width") + # if [ "$INITIAL_WIDTH" -eq "0" ]; then + # ${pkgs.sketchybar}/bin/sketchybar --animate tanh 30 --set $NAME width=$WIDTH icon.width=$INFO + # else + # ${pkgs.sketchybar}/bin/sketchybar --set $NAME icon.width=$INFO width=$WIDTH + # fi + ${pkgs.sketchybar}/bin/sketchybar --set $NAME icon.width=$INFO + + + # sleep 5 + # FINAL_WIDTH=$(${pkgs.sketchybar}/bin/sketchybar --query $NAME | ${pkgs.jq}/bin/jq ".icon.width") + # if [ "$FINAL_WIDTH" -eq "$INFO" ]; then + # ${pkgs.sketchybar}/bin/sketchybar --animate tanh 30 --set $NAME width=0 icon.width=0 + # fi + } + + case "$SENDER" in + "volume_change") volume_change + ;; + esac + ''; + }; + plugins_volume_click = { + executable = true; + target = ".config/sketchybar/plugins/volume_click.sh"; + text = '' + #!/usr/bin/env sh + MUTED=$(osascript -e 'output muted of (get volume settings)') + if [ "$MUTED" = "false" ]; then + osascript -e 'set volume output muted true' + else + osascript -e 'set volume output muted false' + fi + ''; + }; + plugins_zen = { + executable = true; + target = ".config/sketchybar/plugins/zen.sh"; + source = folder + /plugins/executable_zen.sh; + }; + plugins_aerospace = { + executable = true; + target = ".config/sketchybar/plugins/aerospace.sh"; + text = '' + #!/usr/bin/env bash + source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors + + highlight_focused_workspace() { + if [[ "$1" = "$FOCUSED_WORKSPACE" ]] + then + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=on label.width=0 + else + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=off label.width=dynamic + fi + } + + illuminate_mode() { + if [[ "$mode" = "service" ]] + then + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$ORANGE + elif [[ "$mode" = "resize" ]] + then + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$GREEN + else + ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$BACKGROUND_1 + fi + } + case "$SENDER" in + "aerospace_workspace_change") + highlight_focused_workspace $1 + ;; + "aerospace_mode_change") + illuminate_mode + ;; + esac + ''; + }; + }; +} diff --git a/modules/macos/default.nix b/modules/macos/default.nix index 23d44c7..41568bb 100644 --- a/modules/macos/default.nix +++ b/modules/macos/default.nix @@ -2,7 +2,8 @@ pkgs, lib, ... -}: { +}: +{ imports = [ # sort-lines: start ./mac-app-store.nix @@ -14,7 +15,7 @@ # make 'shared.linux' not an error to define. options.shared.linux = lib.mkOption { type = lib.types.anything; - default = {}; + default = { }; description = "no-op on darwin"; }; } diff --git a/modules/macos/icons.nix b/modules/macos/icons.nix index 649e7eb..c59735c 100644 --- a/modules/macos/icons.nix +++ b/modules/macos/icons.nix @@ -2,17 +2,18 @@ lib, config, ... -}: let +}: +let cfg = config.environment.customIcons; - inherit - (lib) + inherit (lib) mkEnableOption mkIf mkMerge mkOption types ; -in { +in +{ options.environment.customIcons = { enable = mkEnableOption "environment.customIcons"; clearCacheOnActivation = mkEnableOption "environment.customIcons.clearCacheOnActivation"; @@ -21,8 +22,8 @@ in { type = types.listOf ( types.submodule { options = { - path = mkOption {type = types.path;}; - icon = mkOption {type = types.path;}; + path = mkOption { type = types.path; }; + icon = mkOption { type = types.path; }; }; } ); @@ -46,8 +47,7 @@ in { set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:iconPath) (current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:destPath options:2) EOF - '') - cfg.icons + '') cfg.icons )) } diff --git a/modules/macos/mac-app-store.nix b/modules/macos/mac-app-store.nix index 3b0dc41..6f5ce30 100644 --- a/modules/macos/mac-app-store.nix +++ b/modules/macos/mac-app-store.nix @@ -3,7 +3,8 @@ lib, pkgs, ... -}: let +}: +let types = lib.types; # Mapping of Mac App Store applications. @@ -23,12 +24,13 @@ # the resolved configuration from the user masApps = config.shared.darwin.macAppStoreApps; -in { +in +{ options = { # Installs Mac Applications via name using homebrew. shared.darwin.macAppStoreApps = lib.mkOption { type = types.listOf types.str; - default = []; + default = [ ]; }; }; config = lib.mkIf (builtins.length masApps > 0) { @@ -37,8 +39,7 @@ in { builtins.map (name: { inherit name; value = allMasApps.${name}; - }) - masApps + }) masApps ); }; } diff --git a/modules/macos/system.nix b/modules/macos/system.nix index 44de3bf..aced96e 100644 --- a/modules/macos/system.nix +++ b/modules/macos/system.nix @@ -3,9 +3,11 @@ pkgs, lib, ... -}: let +}: +let tiling = config.shared.darwin.tiling.enable; -in { +in +{ # Use touchid or watch to activate sudo security.pam.services.sudo_local = { enable = true; @@ -111,11 +113,6 @@ in { "com.apple.dock" = { workspaces-edge-delay = 0.15; }; - "com.apple.symbolichotkeys" = { - AppleSymbolicHotKeys = { - "64".enabled = false; - }; - }; "com.apple.CrashReporter" = { DialogType = "developer"; # display crash reports when apps crash. }; diff --git a/modules/macos/tiling/aerospace.nix b/modules/macos/tiling/aerospace.nix index 464967d..3036330 100644 --- a/modules/macos/tiling/aerospace.nix +++ b/modules/macos/tiling/aerospace.nix @@ -2,7 +2,8 @@ config, pkgs, ... -}: { +}: +{ services.aerospace = { enable = config.shared.darwin.tiling.enable; settings = { @@ -85,8 +86,8 @@ alt-shift-8 = "move-node-to-workspace 8"; alt-shift-9 = "move-node-to-workspace 9"; - cmd-h = []; # Disable "hide application" - cmd-alt-h = []; # Disable "hide others" + cmd-h = [ ]; # Disable "hide application" + cmd-alt-h = [ ]; # Disable "hide others" # # See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth # alt-tab = "workspace-back-and-forth"; @@ -97,22 +98,49 @@ alt-shift-semicolon = "mode service"; }; mode.service.binding = { - esc = ["reload-config" "mode main"]; - r = ["flatten-workspace-tree" "mode main"]; # reset layout - f = ["layout floating tiling" "mode main"]; # Toggle between floating and tiling layout - backspace = ["close-all-windows-but-current" "mode main"]; + esc = [ + "reload-config" + "mode main" + ]; + r = [ + "flatten-workspace-tree" + "mode main" + ]; # reset layout + f = [ + "layout floating tiling" + "mode main" + ]; # Toggle between floating and tiling layout + backspace = [ + "close-all-windows-but-current" + "mode main" + ]; # sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 #s = ["layout sticky tiling", "mode main"] - alt-shift-h = ["join-with left" "mode main"]; - alt-shift-j = ["join-with down" "mode main"]; - alt-shift-k = ["join-with up" "mode main"]; - alt-shift-l = ["join-with right" "mode main"]; + alt-shift-h = [ + "join-with left" + "mode main" + ]; + alt-shift-j = [ + "join-with down" + "mode main" + ]; + alt-shift-k = [ + "join-with up" + "mode main" + ]; + alt-shift-l = [ + "join-with right" + "mode main" + ]; down = "volume down"; up = "volume up"; - shift-down = ["volume set 0" "mode main"]; + shift-down = [ + "volume set 0" + "mode main" + ]; }; after-startup-command = [ "exec-and-forget sketchybar" @@ -131,7 +159,7 @@ "if" = { app-id = "com.mitchellh.ghostty"; }; - run = ["layout floating"]; + run = [ "layout floating" ]; check-further-callbacks = true; } ]; diff --git a/modules/macos/tiling/default.nix b/modules/macos/tiling/default.nix index 1be7097..bcd00cf 100644 --- a/modules/macos/tiling/default.nix +++ b/modules/macos/tiling/default.nix @@ -1,6 +1,8 @@ -{lib, ...}: let +{ lib, ... }: +let inherit (lib) types; -in { +in +{ imports = [ ./sketchybar.nix ./aerospace.nix diff --git a/modules/macos/tiling/sketchybar-home.nix b/modules/macos/tiling/sketchybar-home.nix deleted file mode 100644 index 0b8a6e9..0000000 --- a/modules/macos/tiling/sketchybar-home.nix +++ /dev/null @@ -1,403 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: let - # folder = "${config.home.homeDirectory}.dotfiles/files/sketchybar"; - # folder = "~/.dotfiles/files/sketchybar"; - folder = ../../../files/sketchybar; -in { - home.file = - lib.attrsets.mapAttrs (file: value: ( - lib.attrsets.overrideExisting value {enable = config.shared.darwin.tiling.enable;} - )) { - sketchybarrc = { - executable = true; - target = ".config/sketchybar/sketchybarrc"; - text = '' - #!/usr/bin/env sh - - source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors - source "$HOME/.config/sketchybar/icons.sh" # Loads all defined icons - - ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured - PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored - - FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants - PADDINGS=3 # All paddings use this value (icon, label, background) - - # Setting up and starting the helper process - HELPER=git.felix.helper - killall helper - cd $HOME/.config/sketchybar/helper && make - $HOME/.config/sketchybar/helper/helper $HELPER > /dev/null 2>&1 & - - # Unload the macOS on screen indicator overlay for volume change - # launchctl unload -F /System/Library/LaunchAgents/com.apple.OSDUIHelper.plist > /dev/null 2>&1 & - - # Setting up the general bar appearance and default values - ${pkgs.sketchybar}/bin/sketchybar --bar height=40 \ - color=$BAR_COLOR \ - shadow=off \ - position=top \ - sticky=on \ - padding_right=0 \ - padding_left=0 \ - corner_radius=12 \ - y_offset=0 \ - margin=2 \ - blur_radius=0 \ - notch_width=0 \ - --default updates=when_shown \ - icon.font="$FONT:Bold:14.0" \ - icon.color=$ICON_COLOR \ - icon.padding_left=$PADDINGS \ - icon.padding_right=$PADDINGS \ - label.font="$FONT:Semibold:13.0" \ - label.color=$LABEL_COLOR \ - label.padding_left=$PADDINGS \ - label.padding_right=$PADDINGS \ - background.padding_right=$PADDINGS \ - background.padding_left=$PADDINGS \ - background.height=26 \ - background.corner_radius=9 \ - popup.background.border_width=2 \ - popup.background.corner_radius=11 \ - popup.background.border_color=$POPUP_BORDER_COLOR \ - popup.background.color=$POPUP_BACKGROUND_COLOR \ - popup.background.shadow.drawing=on - - # Left - source "$ITEM_DIR/apple.sh" - source "$ITEM_DIR/spaces.sh" - source "$ITEM_DIR/front_app.sh" - - # Center - # source "$ITEM_DIR/spotify.sh" - source "$ITEM_DIR/calendar.sh" - - # Right - # source "$ITEM_DIR/brew.sh" - # source "$ITEM_DIR/github.sh" - source "$ITEM_DIR/volume.sh" - # source "$ITEM_DIR/divider.sh" - # source "$ITEM_DIR/cpu.sh" - - # Forcing all item scripts to run (never do this outside of sketchybarrc) - ${pkgs.sketchybar}/bin/sketchybar --update - - echo "sketchybar configuation loaded.." - ''; - }; - icons = { - executable = true; - target = ".config/sketchybar/icons.sh"; - source = folder + /icons.sh; - }; - colors = { - executable = true; - target = ".config/sketchybar/colors.sh"; - text = '' - #!/usr/bin/env sh - # Color Palette - export BLACK=0xff4c4f69 - export WHITE=0xffeff1f5 - export RED=0xffd20f39 - export GREEN=0xff40a02b - export BLUE=0xff1e66f5 - export YELLOW=0xffdf8e1d - export ORANGE=0xfffe640b - export MAGENTA=0xffea76cb - export GREY=0xff9ca0b0 - export TRANSPARENT=0xff000000 - export BLUE2=0xff7287fd - export FLAMINGO=0xffdd7878 - - # General bar colors - export BAR_COLOR=0xeff1f5ff # Color of the bar - export ICON_COLOR=0xff4c4f69 - export LABEL_COLOR=0xff4c4f69 # Color of all labels - export BACKGROUND_1=0xffbcc0cc - export BACKGROUND_2=0xffbcc0cc - - export POPUP_BACKGROUND_COLOR=$BLACK - export POPUP_BORDER_COLOR=$WHITE - - export SHADOW_COLOR=$BLACK - ''; - }; - items_apple = { - executable = true; - target = ".config/sketchybar/items/apple.sh"; - source = folder + /items/executable_apple.sh; - }; - items_brew = { - executable = true; - target = ".config/sketchybar/items/brew.sh"; - source = folder + /items/executable_brew.sh; - }; - items_calendar = { - executable = true; - target = ".config/sketchybar/items/calendar.sh"; - text = '' - #!/usr/bin/env sh - - sketchybar --add item calendar center \ - --set calendar icon=cal \ - display=1 \ - icon.font="$FONT:Black:12.0" \ - icon.padding_right=0 \ - label.width=50 \ - label.align=right \ - background.padding_left=15 \ - update_freq=30 \ - script="$PLUGIN_DIR/calendar.sh" \ - click_script="$PLUGIN_DIR/zen.sh" - ''; - }; - items_cpu = { - executable = true; - target = ".config/sketchybar/items/cpu.sh"; - source = folder + /items/executable_cpu.sh; - }; - items_divider = { - executable = true; - target = ".config/sketchybar/items/divider.sh"; - source = folder + /items/executable_divider.sh; - }; - items_front_app = { - executable = true; - target = ".config/sketchybar/items/front_app.sh"; - text = '' - #!/usr/bin/env sh - FRONT_APP_SCRIPT='sketchybar --set $NAME label="$INFO"' - sketchybar --add event window_focus \ - --add event windows_on_spaces \ - --add item system.aerospace left \ - --set system.aerospace script="$PLUGIN_DIR/aerospace.sh" \ - icon.font="$FONT:Bold:16.0" \ - label.drawing=off \ - icon.width=30 \ - icon=$YABAI_GRID \ - icon.color=$BLACK \ - updates=on \ - display=active \ - --subscribe system.aerospace window_focus \ - windows_on_spaces \ - mouse.clicked \ - --add item front_app left \ - --set front_app script="$FRONT_APP_SCRIPT" \ - icon.drawing=off \ - background.padding_left=0 \ - background.padding_right=10 \ - label.color=$BLACK \ - label.font="$FONT:Black:12.0" \ - display=active \ - --subscribe front_app front_app_switched - ''; - }; - items_github = { - executable = true; - target = ".config/sketchybar/items/github.sh"; - source = folder + /items/executable_github.sh; - }; - items_spaces = { - executable = true; - target = ".config/sketchybar/items/spaces.sh"; - # label.background.color=$BACKGROUND_2 - text = '' - ${pkgs.sketchybar}/bin/sketchybar --add event aerospace_workspace_change - ${pkgs.sketchybar}/bin/sketchybar --add event aerospace_mode_change - for sid in $(${pkgs.aerospace}/bin/aerospace list-workspaces --all); do - ${pkgs.sketchybar}/bin/sketchybar --add item space.$sid left \ - --subscribe space.$sid aerospace_workspace_change \ - --subscribe space.$sid aerospace_mode_change \ - --set space.$sid \ - icon=$sid \ - icon.padding_left=22 \ - icon.padding_right=22 \ - icon.highlight_color=$WHITE \ - icon.highlight=off \ - icon.color=0xff4c566a \ - background.padding_left=-8 \ - background.padding_right=-8 \ - background.color=$BACKGROUND_1 \ - background.drawing=on \ - script="$PLUGIN_DIR/aerospace.sh $sid" \ - click_script="aerospace workspace $sid" \ - label.font="Iosevka Nerd Font:Regular:16.0" \ - label.padding_right=33 \ - label.background.height=26 \ - label.background.drawing=on \ - label.background.corner_radius=9 \ - label.drawing=off - done - ${pkgs.sketchybar}/bin/sketchybar --add item separator left \ - --set separator icon= \ - icon.font="Iosevka Nerd Font:Regular:16.0" \ - background.padding_left=26 \ - background.padding_right=15 \ - label.drawing=off \ - display=active \ - icon.color=$GREEN - ''; - }; - items_spotify = { - executable = true; - target = ".config/sketchybar/items/spotify.sh"; - source = folder + /items/executable_spotify.sh; - }; - items_volume = { - executable = true; - target = ".config/sketchybar/items/volume.sh"; - text = '' - INITIAL_WIDTH=$(osascript -e 'set ovol to output volume of (get volume settings)') - ${pkgs.sketchybar}/bin/sketchybar --add item volume right \ - --subscribe volume volume_change \ - --set volume script="$PLUGIN_DIR/volume.sh" \ - updates=on \ - icon.background.drawing=on \ - icon.background.color=$FLAMINGO \ - icon.background.height=8 \ - icon.background.corner_radius=3 \ - icon.width=$INITIAL_WIDTH \ - width=100 \ - icon.align=right \ - label.drawing=off \ - background.drawing=on \ - background.color=$BACKGROUND_2 \ - background.height=8 \ - background.corner_radius=3 \ - align=left - - ${pkgs.sketchybar}/bin/sketchybar --add alias "Control Center,Sound" right \ - --rename "Control Center,Sound" volume_alias \ - --set volume_alias icon.drawing=off \ - label.drawing=off \ - alias.color=$BLUE2 \ - background.padding_right=0 \ - background.padding_left=5 \ - width=50 \ - align=right \ - click_script="$PLUGIN_DIR/volume_click.sh" - - ''; - }; - plugins_brew = { - executable = true; - target = ".config/sketchybar/plugins/brew.sh"; - source = folder + /plugins/executable_brew.sh; - }; - plugins_calendar = { - executable = true; - target = ".config/sketchybar/plugins/calendar.sh"; - source = folder + /plugins/executable_calendar.sh; - }; - plugins_github = { - executable = true; - target = ".config/sketchybar/plugins/github.sh"; - source = folder + /plugins/executable_github.sh; - }; - plugins_icon_map = { - executable = true; - target = ".config/sketchybar/plugins/icon_map.sh"; - source = folder + /plugins/executable_icon_map.sh; - }; - plugins_space = { - executable = true; - target = ".config/sketchybar/plugins/space.sh"; - source = folder + /plugins/executable_space.sh; - }; - plugins_spotify = { - executable = true; - target = ".config/sketchybar/plugins/spotify.sh"; - source = folder + /plugins/executable_spotify.sh; - }; - plugins_volume = { - executable = true; - target = ".config/sketchybar/plugins/volume.sh"; - text = '' - #!/usr/bin/env sh - WIDTH=100 - - volume_change() { - # INITIAL_WIDTH=$(${pkgs.sketchybar}/bin/sketchybar --query $NAME | ${pkgs.jq}/bin/jq ".icon.width") - # if [ "$INITIAL_WIDTH" -eq "0" ]; then - # ${pkgs.sketchybar}/bin/sketchybar --animate tanh 30 --set $NAME width=$WIDTH icon.width=$INFO - # else - # ${pkgs.sketchybar}/bin/sketchybar --set $NAME icon.width=$INFO width=$WIDTH - # fi - ${pkgs.sketchybar}/bin/sketchybar --set $NAME icon.width=$INFO - - - # sleep 5 - # FINAL_WIDTH=$(${pkgs.sketchybar}/bin/sketchybar --query $NAME | ${pkgs.jq}/bin/jq ".icon.width") - # if [ "$FINAL_WIDTH" -eq "$INFO" ]; then - # ${pkgs.sketchybar}/bin/sketchybar --animate tanh 30 --set $NAME width=0 icon.width=0 - # fi - } - - case "$SENDER" in - "volume_change") volume_change - ;; - esac - ''; - }; - plugins_volume_click = { - executable = true; - target = ".config/sketchybar/plugins/volume_click.sh"; - text = '' - #!/usr/bin/env sh - MUTED=$(osascript -e 'output muted of (get volume settings)') - if [ "$MUTED" = "false" ]; then - osascript -e 'set volume output muted true' - else - osascript -e 'set volume output muted false' - fi - ''; - }; - plugins_zen = { - executable = true; - target = ".config/sketchybar/plugins/zen.sh"; - source = folder + /plugins/executable_zen.sh; - }; - plugins_aerospace = { - executable = true; - target = ".config/sketchybar/plugins/aerospace.sh"; - text = '' - #!/usr/bin/env bash - source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors - - highlight_focused_workspace() { - if [[ "$1" = "$FOCUSED_WORKSPACE" ]] - then - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=on label.width=0 - else - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=off label.width=dynamic - fi - } - - illuminate_mode() { - if [[ "$mode" = "service" ]] - then - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$ORANGE - elif [[ "$mode" = "resize" ]] - then - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$GREEN - else - ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$BACKGROUND_1 - fi - } - case "$SENDER" in - "aerospace_workspace_change") - highlight_focused_workspace $1 - ;; - "aerospace_mode_change") - illuminate_mode - ;; - esac - ''; - }; - }; -} diff --git a/modules/macos/tiling/sketchybar.nix b/modules/macos/tiling/sketchybar.nix index abc3b03..e60e2a3 100644 --- a/modules/macos/tiling/sketchybar.nix +++ b/modules/macos/tiling/sketchybar.nix @@ -2,7 +2,8 @@ config, pkgs, ... -}: { +}: +{ services.sketchybar = { enable = config.shared.darwin.tiling.enable; package = pkgs.sketchybar; diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix new file mode 100644 index 0000000..84be6e1 --- /dev/null +++ b/modules/neovim/default.nix @@ -0,0 +1,140 @@ +{ + config, + lib, + host, + ... +}: +{ + # based on default options from upstream: + # https://github.com/NotAShelf/nvf/blob/main/configuration.nix + # + # a full list of options is available too: + # https://notashelf.github.io/nvf/options.html + # + # override level 999 is used to not conflict with mkDefault as used by nvf. + # which allows user configurations to disable/override anything here. + vim = lib.mkOverride 999 { + theme = { + enable = true; + }; + visuals = { + # notification system + # https://github.com/j-hui/fidget.nvim + fidget-nvim.enable = true; + # highlight undo / paste / autoformat / macros + # https://github.com/tzachar/highlight-undo.nvim + highlight-undo.enable = true; + # indentation guides + # https://github.com/lukas-reineke/indent-blankline.nvim + indent-blankline.enable = false; + # extra icons + nvim-web-devicons.enable = true; + # https://github.com/petertriho/nvim-scrollbar + nvim-scrollbar.enable = false; + }; + lsp = { + # Must be enabled for language modules to hook into the LSP API. + enable = true; + formatOnSave = true; + # show errors inline + # https://github.com/folke/trouble.nvim + trouble.enable = true; + # show lightbulb icon in gutter to indicate code actions + # https://github.com/kosayoda/nvim-lightbulb + lightbulb.enable = true; + # show icons in auto-completion menu + # https://github.com/onsails/lspkind.nvim + lspkind.enable = config.vim.autocomplete.blink-cmp.enable; + }; + debugger = { + nvim-dap = { + enable = true; + ui.enable = true; + }; + }; + languages = { + enableFormat = true; + enableTreesitter = true; + enableExtraDiagnostics = true; + + # sort-lines: on + assembly.enable = true; + bash.enable = true; + clang.enable = true; + css.enable = true; + html.enable = true; + nix.enable = true; + rust.crates.enable = true; + rust.enable = true; + ts.enable = true; + zig.enable = true; + # sort-lines: off + + nix.format.type = "nixfmt"; # looks so much nicer + }; + filetree = { + neo-tree = { + enable = true; + }; + }; + tabline = { + nvimBufferline.enable = true; + }; + autocomplete = { + blink-cmp.enable = true; + }; + statusline = { + lualine = { + enable = true; + refresh = { + statusline = 100; + tabline = 100; + winbar = 100; + }; + }; + }; + binds = { + whichKey.enable = true; + cheatsheet.enable = true; + # discourages bad keyboard habit, e.g. disables arrow keys, explains better binds + # https://github.com/m4xshen/hardtime.nvim + hardtime-nvim.enable = true; + hardtime-nvim.setupOpts = { + disable_mouse = false; + restriction_mode = "hint"; # default behavior is lenient + }; + }; + ui = { + borders.enable = true; + # https://github.com/norcalli/nvim-colorizer.lua + colorizer.enable = true; + # https://github.com/RRethy/vim-illuminate + illuminate.enable = true; + breadcrumbs = { + enable = false; + navbuddy.enable = config.vim.ui.breadcrumbs.enable; + }; + smartcolumn = { + enable = true; + setupOpts.custom_colorcolumn = { + # this is a freeform module, it's `buftype = int;` for configuring column position + nix = "110"; + ruby = "120"; + java = "130"; + go = [ + "90" + "130" + ]; + }; + }; + }; + notes = { + todo-comments.enable = true; + }; + git = { + enable = true; + gitsigns.enable = true; + gitsigns.codeActions.enable = false; # throws an annoying debug message + }; + }; +} diff --git a/modules/nixos/boot.nix b/modules/nixos/boot.nix index d9e3a89..9593a0c 100644 --- a/modules/nixos/boot.nix +++ b/modules/nixos/boot.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ boot = { kernelPackages = pkgs.linuxPackages_latest; # _zen, _hardened, _rt, _rt_latest, etc. loader = { diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index cb547e4..c094a9b 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -2,7 +2,8 @@ lib, pkgs, ... -}: { +}: +{ imports = [ ./boot.nix ./ld.nix @@ -12,7 +13,7 @@ # make 'shared.darwin' not an error to define. options.shared.darwin = lib.mkOption { type = lib.types.anything; - default = {}; + default = { }; description = "no-op on linux"; }; } diff --git a/modules/nixos/ld.nix b/modules/nixos/ld.nix index 24cd8c0..0bb6938 100644 --- a/modules/nixos/ld.nix +++ b/modules/nixos/ld.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ programs.nix-ld.enable = true; # "minimum" amount of libraries needed for most games to run without steam-run diff --git a/modules/nixos/nvidia.nix b/modules/nixos/nvidia.nix index 18f6dde..2f107a1 100644 --- a/modules/nixos/nvidia.nix +++ b/modules/nixos/nvidia.nix @@ -2,10 +2,12 @@ pkgs, config, ... -}: let +}: +let nvidiaDriverChannel = config.boot.kernelPackages.nvidiaPackages.latest; -in { - services.xserver.videoDrivers = ["nvidia"]; +in +{ + services.xserver.videoDrivers = [ "nvidia" ]; nixpkgs.config = { nvidia.acceptLicense = true; @@ -18,7 +20,7 @@ in { ]; # Blacklist nouveau to avoid conflicts - boot.blacklistedKernelModules = ["nouveau"]; + boot.blacklistedKernelModules = [ "nouveau" ]; environment.variables = { LIBVA_DRIVER_NAME = "nvidia"; # Hardware video acceleration XDG_SESSION_TYPE = "wayland"; # Force Wayland @@ -80,7 +82,7 @@ in { }; nix.settings = { - substituters = ["https://cuda-maintainers.cachix.org"]; + substituters = [ "https://cuda-maintainers.cachix.org" ]; trusted-public-keys = [ "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" ]; diff --git a/modules/nixos/services.nix b/modules/nixos/services.nix index b48a52a..a5c6f0f 100644 --- a/modules/nixos/services.nix +++ b/modules/nixos/services.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ services = { avahi = { enable = true; @@ -39,7 +40,7 @@ # Enable CUPS to print documents. printing = { enable = true; - drivers = [pkgs.brlaser]; # Brother printer driver + drivers = [ pkgs.brlaser ]; # Brother printer driver }; pipewire = { @@ -54,7 +55,7 @@ openssh = { enable = true; - ports = [22]; + ports = [ 22 ]; settings = { PasswordAuthentication = true; UseDns = true; diff --git a/modules/nixvim/default.nix b/modules/nixvim/default.nix deleted file mode 100644 index fe644b7..0000000 --- a/modules/nixvim/default.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - pkgs, - inputs, - nixvim, - ... -}: { - imports = [ - ./opts.nix - ./keymaps.nix - ./plugins - ]; - programs.nixvim = { - enable = true; - - globals = { - #Set leader to space, and localleader to \ - mapleader = " "; - maplocalleader = "\\"; - - have_nerd_font = true; - }; - - clipboard = { - providers = { - wl-copy.enable = true; # For Wayland - xsel.enable = true; # For X11 - }; - - # Sync clipboard between OS and Neovim - # Remove this option if you want your OS clipboard to remain independent. - register = "unnamedplus"; - }; - - opts = { - # Show line numbers - number = true; - # You can also add relative line numbers, to help with jumping. - # Experiment for yourself to see if you like it! - #relativenumber = true - - # Enable mouse mode, can be useful for resizing splits for example! - mouse = "a"; - - # Don't show the mode, since it's already in the statusline - showmode = false; - - # Enable break indent - breakindent = true; - - # Save undo history - undofile = true; - - # Case-insensitive searching UNLESS \C or one or more capital letters in the search term - ignorecase = true; - smartcase = true; - - # Keep signcolumn on by default - signcolumn = "yes"; - - # Decrease update time - updatetime = 250; - - # Decrease mapped sequence wait time - # Displays which-key popup sooner - timeoutlen = 300; - - # Configure how new splits should be opened - splitright = true; - splitbelow = true; - - # Sets how neovim will display certain whitespace characters in the editor - # See `:help 'list'` - # and `:help 'listchars'` - list = true; - # NOTE: .__raw here means that this field is raw lua code - listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '␣' }"; - - # Preview substitutions live, as you type! - inccommand = "split"; - - # Show which line your cursor is on - cursorline = true; - - # Minimal number of screen lines to keep above and below the cursor. - scrolloff = 10; - - # if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), - # instead raise a dialog asking if you wish to save the current file(s) - # See `:help 'confirm'` - confirm = true; - - # See `:help hlsearch` - hlsearch = true; - }; - }; -} diff --git a/modules/nixvim/icons.nix b/modules/nixvim/icons.nix deleted file mode 100644 index 956bc87..0000000 --- a/modules/nixvim/icons.nix +++ /dev/null @@ -1,189 +0,0 @@ -{lib, ...}: { - options.nvix.icons = lib.mkOption { - type = lib.types.attrs; - default = {}; - }; - config.nvix.icons = { - kind = { - Array = ""; - Boolean = ""; - Class = ""; - Color = ""; - Constant = ""; - Constructor = ""; - Enum = ""; - EnumMember = ""; - Event = ""; - Field = ""; - File = ""; - Folder = ""; - Function = ""; - Interface = ""; - Key = ""; - Keyword = ""; - Method = ""; - Module = ""; - Namespace = ""; - Null = "ﳠ"; - Number = ""; - Object = ""; - Operator = ""; - Package = ""; - Property = ""; - Reference = ""; - Snippet = ""; - String = ""; - Struct = ""; - Text = ""; - TypeParameter = ""; - Unit = ""; - Value = ""; - Variable = ""; - Copilot = ""; - TabNine = "⌬"; - }; - git = { - LineAdded = ""; - LineModified = ""; - LineRemoved = ""; - FileDeleted = ""; - FileIgnored = "󰫙"; - FileRenamed = ""; - FileStaged = "✓"; - FileUnmerged = ""; - FileMerged = ""; - FileUnstaged = ""; - FileUntracked = "◌"; - FileChanged = "󰉺"; - Copied = "󰆏"; - Ignored = ""; - Diff = ""; - Repo = ""; - Octoface = ""; - Branch = ""; - }; - ui = { - lazy = { - ft = ""; - lazy = "󰂠 "; - loaded = ""; - not_loaded = ""; - }; - ArrowCircleDown = ""; - ArrowCircleLeft = ""; - ArrowCircleRight = ""; - ArrowCircleUp = ""; - BoldArrowDown = ""; - BoldArrowLeft = ""; - BoldArrowRight = ""; - BoldArrowUp = ""; - BoldClose = ""; - BoldDividerLeft = ""; - BoldDividerRight = ""; - BoldLineLeft = "▎"; - BookMark = ""; - BoxChecked = ""; - Bug = ""; - Stacks = ""; - Scopes = ""; - Watches = ""; - DebugConsole = ""; - Calendar = ""; - Check = ""; - ChevronRight = ">"; - ChevronShortDown = ""; - ChevronShortLeft = ""; - ChevronShortRight = ""; - ChevronShortUp = ""; - Circle = ""; - Close = ""; - CloudDownload = ""; - Code = ""; - Comment = ""; - Dashboard = ""; - DividerLeft = ""; - DividerRight = ""; - DoubleChevronRight = "»"; - Ellipsis = ""; - EmptyFolder = ""; - EmptyFolderOpen = ""; - ExitCircle = "󰿅"; - File = ""; - FileSymlink = ""; - Files = ""; - FileRename = ""; - FindFile = "󰈞"; - FindText = ""; - Fire = ""; - Folder = ""; - FolderOpen = ""; - FolderSymlink = ""; - Forward = ""; - Gear = ""; - History = ""; - Lightbulb = ""; - LineLeft = "▏"; - LineMiddle = "│"; - List = ""; - Lock = ""; - NewFile = ""; - Note = ""; - Package = ""; - Pencil = "󰏫"; - Plus = ""; - Project = ""; - Search = ""; - SignIn = ""; - SignOut = ""; - Tab = ""; - Table = ""; - Target = "󰀘"; - Telescope = ""; - Text = ""; - Tree = ""; - Triangle = "󰐊"; - TriangleShortArrowDown = ""; - TriangleShortArrowLeft = ""; - TriangleShortArrowRight = ""; - TriangleShortArrowUp = ""; - }; - diagnostics = { - BoldError = ""; - Error = ""; - BoldWarning = ""; - Warning = ""; - BoldInformation = ""; - Information = ""; - BoldQuestion = ""; - Question = ""; - BoldHint = ""; - Hint = "󰌶"; - Debug = ""; - Trace = "✎"; - }; - misc = { - Robot = "ﮧ"; - Squirrel = ""; - Tag = ""; - Watch = ""; - Smiley = ""; - Package = ""; - CircuitBoard = ""; - LualineFmt = ""; - }; - nvtree_chad = { - default = "󰈚"; - symlink = ""; - folder = { - default = ""; - empty = ""; - empty_open = ""; - open = ""; - symlink = ""; - symlink_open = ""; - arrow_open = ""; - arrow_closed = ""; - }; - }; - }; -} diff --git a/modules/nixvim/keymaps.nix b/modules/nixvim/keymaps.nix deleted file mode 100644 index 8710d6b..0000000 --- a/modules/nixvim/keymaps.nix +++ /dev/null @@ -1,42 +0,0 @@ -{pkgs, ...}: { - programs.nixvim = { - keymaps = [ - # Keybinds to make split navigation easier. - # Use CTRL+ to switch between windows - # - # See `:help wincmd` for a list of all window commands - { - mode = "n"; - key = ""; - action = ""; - options = { - desc = "Move focus to the left window"; - }; - } - { - mode = "n"; - key = ""; - action = ""; - options = { - desc = "Move focus to the right window"; - }; - } - { - mode = "n"; - key = ""; - action = ""; - options = { - desc = "Move focus to the lower window"; - }; - } - { - mode = "n"; - key = ""; - action = ""; - options = { - desc = "Move focus to the upper window"; - }; - } - ]; - }; -} diff --git a/modules/nixvim/opts.nix b/modules/nixvim/opts.nix deleted file mode 100644 index 8c6b35e..0000000 --- a/modules/nixvim/opts.nix +++ /dev/null @@ -1,65 +0,0 @@ -{pkgs, ...}: { - programs.nixvim = { - opts = { - # Show line numbers - number = true; - relativenumber = true; - - shiftwidth = 2; - - # Enable mouse mode, can be useful for resizing splits for example! - mouse = "a"; - - # Don't show the mode, since it's already in the statusline - showmode = false; - - # Enable break indent - breakindent = true; - - # Save undo history - undofile = true; - - # Case-insensitive searching UNLESS \C or one or more capital letters in the search term - ignorecase = true; - smartcase = true; - - # Keep signcolumn on by default - signcolumn = "yes"; - - # Decrease update time - updatetime = 250; - - # Decrease mapped sequence wait time - # Displays which-key popup sooner - timeoutlen = 300; - - # Configure how new splits should be opened - splitright = true; - splitbelow = true; - - # Sets how neovim will display certain whitespace characters in the editor - # See `:help 'list'` - # and `:help 'listchars'` - list = true; - # NOTE: .__raw here means that this field is raw lua code - listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '␣' }"; - - # Preview substitutions live, as you type! - inccommand = "split"; - - # Show which line your cursor is on - cursorline = true; - - # Minimal number of screen lines to keep above and below the cursor. - scrolloff = 10; - - # if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), - # instead raise a dialog asking if you wish to save the current file(s) - # See `:help 'confirm'` - confirm = true; - - # See `:help hlsearch` - hlsearch = true; - }; - }; -} diff --git a/modules/nixvim/plugins/blink.nix b/modules/nixvim/plugins/blink.nix deleted file mode 100644 index 4768ef2..0000000 --- a/modules/nixvim/plugins/blink.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ - lib, - pkgs, - ... -}: { - programs.nixvim = { - extraPackages = with pkgs; [ - gh - wordnet - glab - ]; - - extraPlugins = [ - ]; - - plugins = { - blink-cmp = { - enable = true; - - lazyLoad.settings.event = [ - "InsertEnter" - "CmdlineEnter" - ]; - - settings = { - keymap.preset = "super-tab"; - completion = { - accept.auto_brackets.enabled = false; - ghost_test.enabled = false; - - list.selection = { - preselect = true; - auto_insert = false; - }; - - documentation = { - auto_show = true; - - window.border = "rounded"; - }; - }; - - menu.draw.components = { - kind_icon.text.__raw = '' - function(ctx) - local kind_icon, _, _ = require('mini.icons').get('lsp', ctx.kind) - -- Check for both nil and the default fallback icon - if not kind_icon or kind_icon == '󰞋' then - -- Use our configured kind_icons - return require('blink.cmp.config').appearance.kind_icons[ctx.kind] or "" - end - return kind_icon - end, - -- Optionally, you may also use the highlights from mini.icons - highlight = function(ctx) - local _, hl, _ = require('mini.icons').get('lsp', ctx.kind) - return hl - end - ''; - }; - }; - - fuzzy = { - implementation = "prefer_rust_with_warning"; - }; - }; - }; - }; -} diff --git a/modules/nixvim/plugins/default.nix b/modules/nixvim/plugins/default.nix deleted file mode 100644 index 997bb04..0000000 --- a/modules/nixvim/plugins/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{pkgs, ...}: { - imports = [ - ./blink.nix - ./lz-n.nix - ]; -} diff --git a/modules/nixvim/plugins/lz-n.nix b/modules/nixvim/plugins/lz-n.nix deleted file mode 100644 index 695dd3d..0000000 --- a/modules/nixvim/plugins/lz-n.nix +++ /dev/null @@ -1,7 +0,0 @@ -{pkgs, ...}: { - programs.nixvim.plugins = { - lz-n = { - enable = true; - }; - }; -} diff --git a/modules/shared/default.nix b/modules/shared/default.nix index e44a841..6ec64f5 100644 --- a/modules/shared/default.nix +++ b/modules/shared/default.nix @@ -1,9 +1,15 @@ # shared is used by nixos-rebuild and darwin-rebuild -{pkgs, ...}: { +{ pkgs, ... }: +{ imports = [ # sort-lines:start ./user-system-settings.nix ./nix.nix # sort-lines:end ]; + # install neovim globally, but let home-manager install + # the per-user configured one. + environment.systemPackages = [ + pkgs.neovim + ]; } diff --git a/modules/shared/nix.nix b/modules/shared/nix.nix index d9f8ec0..2070f0c 100644 --- a/modules/shared/nix.nix +++ b/modules/shared/nix.nix @@ -1,10 +1,11 @@ -{inputs, ...}: { +{ inputs, ... }: +{ nixpkgs.config = { allowUnfree = true; }; nix = { - nixPath = ["nixpkgs = ${inputs.nixpkgs}"]; + nixPath = [ "nixpkgs = ${inputs.nixpkgs}" ]; extraOptions = '' warn-dirty = false ''; @@ -14,7 +15,10 @@ }; settings = { - experimental-features = ["nix-command" "flakes"]; + experimental-features = [ + "nix-command" + "flakes" + ]; substituters = [ "https://cache.nixos.org/?priority=10" diff --git a/modules/shared/user-system-settings.nix b/modules/shared/user-system-settings.nix index 99ef4f7..842f046 100644 --- a/modules/shared/user-system-settings.nix +++ b/modules/shared/user-system-settings.nix @@ -1,10 +1,12 @@ # applies user settings for the system { + config, pkgs, user, lib, ... -}: { +}: +{ # Set your time zone. time.timeZone = user.timeZone; @@ -17,8 +19,8 @@ BROWSER = user.browser; }; - stylix = { - enable = user ? "theme"; + stylix = lib.mkIf (user ? "theme" && user.theme != null) { + enable = false; base16Scheme = "${pkgs.base16-schemes}/share/themes/${user.theme}.yaml"; fonts = lib.optionalAttrs (user ? "font") { diff --git a/nvim b/nvim new file mode 100755 index 0000000..9e71b9c --- /dev/null +++ b/nvim @@ -0,0 +1,13 @@ +#!/bin/sh +username="$(id -u -n)" +if [ "$username" = "clo" ]; then + name="chloe"; +elif [ "$username" = "nmarks" ]; then + name="natalie"; +fi +if [ -z "$name" ]; then + echo "Configure this wrapper script with your name." >2 + exit 1 +fi +exec nix run ".#nvim-$name" -- "$@" + diff --git a/readme.md b/readme.md index e48f331..7cab111 100644 --- a/readme.md +++ b/readme.md @@ -1,13 +1,14 @@ # nix config -this setup allows natalie and chloe to share common configuration between their machines, but also share useful modules between each other. +this setup allows natalie and chloe to share common configuration between their +machines, but also share useful modules between each other. ``` lib/ # reusable functions modules/ # reusable modules +-- macos/ # nix-darwin configurations +-- nixos/ # linux configurations - +-- nixvim/ # neovim configurations + +-- neovim/ # nvf configurations +-- shared/ # shared between nixos-rebuild & darwin-rebuild +-- home-manager.nix # home program presets users/ @@ -15,6 +16,7 @@ users/ | +-- user.nix # info about her | +-- configuration.nix # for all hosts | +-- home.nix # for all hosts + | +-- vim.nix # for neovim | +-- sandwich/ | | +-- configuration.nix # per host | | +-- home.nix @@ -25,7 +27,8 @@ users/ ... ``` -A new machine can be added by adding a new definition in `flake.nix`. Note that the user and host `configuration.nix` and `home.nix` files are +A new machine can be added by adding a new definition in `flake.nix`. Note that +the user and host `configuration.nix` and `home.nix` files are ## macOS installation instructions @@ -40,11 +43,12 @@ While this installs, now is a good time to perform manual setup steps: - Setup your SSH keys in `~/.ssh` - Configure the device hostname in System Settings in - - About -> Name - - General -> Sharing -> Local Hostname + - About -> Name + - General -> Sharing -> Local Hostname - Make sure you're logged into iCloud / Mac App Store - `xcode-select --install` to make sure Git and other utilities are available. -- Optional: Disable app verification with `sudo spctl --master-disable`, then, go to System Settings -> Privacy to allow unsigned apps. +- Optional: Disable app verification with `sudo spctl --master-disable`, then, + go to System Settings -> Privacy to allow unsigned apps. Once Nix is installed, open a new shell and clone the repository: @@ -55,11 +59,11 @@ git clone https://git.paperclover.net/clo/config.git git clone git@git.paperclover.net:clo/config ``` -The location of the cloned repository must match what is in your `user.nix` file. +The location of the cloned repository must match what is in your `user.nix` +file. Setup `nix-darwin` using the `switch` helper: ``` ./switch ``` - diff --git a/sample.keys b/sample.keys new file mode 100644 index 0000000..6abfbdb --- /dev/null +++ b/sample.keys @@ -0,0 +1,9 @@ +global { + cmd + opt + backtick -> app "Keyboard Maestro" +} + +device WorkLouder { + a -> { + if app "REAPER" -> key cmd + shift + } +} diff --git a/users/chloe/configuration.nix b/users/chloe/configuration.nix index 70550f6..4f47f34 100644 --- a/users/chloe/configuration.nix +++ b/users/chloe/configuration.nix @@ -1,11 +1,11 @@ # Configuration applied to all of chloe's machines -{pkgs, ...}: { +{ pkgs, ... }: +{ # packages for all machines environment.systemPackages = with pkgs; [ - neovim ]; # services for all machines - # services.karabiner-elements.enable = true; # BROKEN + services.karabiner-elements.enable = true; # configuration for shared modules. # all custom options in 'shared' for clarity. @@ -29,6 +29,14 @@ NSGlobalDomain = { # TODO: how to change system accent color AppleHighlightColor = "1.000000 0.874510 0.701961 Orange"; + + # control how the fn keys operate + # 0 = default to media keys, 1 = default to FN1-12 + "com.apple.keyboard.fnState" = 1; + + NSUserKeyEquivalents = { + Minimize = "@~^\\Uf70f"; # set minimize to a stupidly hard key to press + }; }; }; }; diff --git a/users/chloe/home.nix b/users/chloe/home.nix index 1149c15..5aa9dc9 100644 --- a/users/chloe/home.nix +++ b/users/chloe/home.nix @@ -1,46 +1,34 @@ -{ - inputs, - pkgs, - lib, - host, - ... -}: let +{ pkgs, host, ... }: +let hostServer = false; -in { +in +{ home = { stateVersion = "23.05"; # Please read the comment before changing. - packages = with pkgs; let - # packages to always install - all = [ - ffmpeg - ripgrep - uv - ]; - # packages to install for desktop environments (non-server) - desktop = [ - ]; - # packages to install on all servers - server = []; - # packages to install on macOS desktops - darwin = [ - raycast - ]; - # packages to install on linux desktops - linux = [ - reaper # TODO: why does this break on macOS - ]; - in - all - ++ ( - if host.darwin - then darwin - else linux - ) - ++ ( - if hostServer - then server - else desktop - ); + packages = + with pkgs; + let + # packages to always install + all = [ + ffmpeg + ripgrep + uv + ]; + # packages to install for desktop environments (non-server) + desktop = [ + ]; + # packages to install on all servers + server = [ ]; + # packages to install on macOS desktops + darwin = [ + raycast + ]; + # packages to install on linux desktops + linux = [ + reaper # TODO: why does this break on macOS + ]; + in + all ++ (if host.darwin then darwin else linux) ++ (if hostServer then server else desktop); }; programs = { # sort-lines:start @@ -61,7 +49,14 @@ in { user = "clo"; port = 222; }; - "nas.paperclover.net" = lib.mkIf zenith; + "nas.paperclover.net" = zenith; + }; + }; + neovide = { + enable = !hostServer; + settings = { + font.normal = "AT Name Mono"; + font.size = 13; }; }; }; diff --git a/users/chloe/paperback/home.nix b/users/chloe/paperback/home.nix index ce35b97..eff27c5 100644 --- a/users/chloe/paperback/home.nix +++ b/users/chloe/paperback/home.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ # these programs are not globally installed to reduce distractions. # most of these are needed for my work environment. programs.bun.enable = true; @@ -10,5 +11,7 @@ typescript pm2 pnpm + yt-dlp + spotdl ]; } diff --git a/users/chloe/sandwich/configuration.nix b/users/chloe/sandwich/configuration.nix index c668657..a9702e9 100644 --- a/users/chloe/sandwich/configuration.nix +++ b/users/chloe/sandwich/configuration.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ shared.darwin = { macAppStoreApps = [ "final-cut-pro" diff --git a/users/chloe/user.nix b/users/chloe/user.nix index 376ec60..284592d 100644 --- a/users/chloe/user.nix +++ b/users/chloe/user.nix @@ -8,7 +8,7 @@ dotfilesDir = "~/config"; # absolute path of the local repo # Stylix/Theming - theme = "catppuccin-mocha"; + theme = null; #font sexuality = "lesbian"; # hyfetch diff --git a/users/chloe/vim.nix b/users/chloe/vim.nix new file mode 100644 index 0000000..f7db33f --- /dev/null +++ b/users/chloe/vim.nix @@ -0,0 +1,20 @@ +{ ... }: +{ + vim.theme.extraConfig = '' + if vim.g.neovide then + vim.g.neovide_cursor_trail_size = 0.3 + vim.g.neovide_scroll_animation_length = 0.1; + + vim.keymap.set('n', '', ':w') -- Save + vim.keymap.set('v', '', '"+y') -- Copy + vim.keymap.set('n', '', '"+P') -- Paste normal mode + vim.keymap.set('v', '', '"+P') -- Paste visual mode + vim.keymap.set('c', '', '+') -- Paste command mode + vim.keymap.set('i', '', 'l"+Pli') -- Paste insert mode + end + vim.api.nvim_set_keymap("", '', '+p', { noremap = true, silent = true}) + vim.api.nvim_set_keymap('!', '', '+', { noremap = true, silent = true}) + vim.api.nvim_set_keymap('t', '', '+', { noremap = true, silent = true}) + vim.api.nvim_set_keymap('v', '', '+', { noremap = true, silent = true}) + ''; +} diff --git a/users/natalie/configuration.nix b/users/natalie/configuration.nix index 63ad4e3..0a7c0a3 100644 --- a/users/natalie/configuration.nix +++ b/users/natalie/configuration.nix @@ -4,7 +4,8 @@ pkgs, host, ... -}: { +}: +{ services.tailscale.enable = true; fonts.packages = with pkgs; [ nerd-fonts.fira-code diff --git a/users/natalie/desktop/configuration.nix b/users/natalie/desktop/configuration.nix index 22c8521..d5caecf 100644 --- a/users/natalie/desktop/configuration.nix +++ b/users/natalie/desktop/configuration.nix @@ -3,7 +3,8 @@ user, host, ... -}: { +}: +{ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -16,7 +17,7 @@ enable = true; # Certain features, including CLI integration and system authentication support, # require enabling PolKit integration on some desktop environments (e.g. Plasma). - polkitPolicyOwners = [user.username]; + polkitPolicyOwners = [ user.username ]; }; noisetorch.enable = true; @@ -31,14 +32,9 @@ flake = "/home/nmarks/.dotfiles#nixosConfigurations.nixos"; }; - neovim = { - enable = true; - defaultEditor = true; - }; - steam = { enable = true; - package = with pkgs; steam.override {extraPkgs = pkgs: [attr];}; + package = with pkgs; steam.override { extraPkgs = pkgs: [ attr ]; }; }; git = { @@ -62,7 +58,7 @@ xdg.portal = { enable = true; - extraPortals = with pkgs; [xdg-desktop-portal-gtk]; + extraPortals = with pkgs; [ xdg-desktop-portal-gtk ]; }; virtualisation = { containers.enable = true; @@ -75,7 +71,10 @@ libvirtd.enable = true; }; - nix.settings.trusted-users = ["root" user.username]; + nix.settings.trusted-users = [ + "root" + user.username + ]; systemd = { targets = { sleep.enable = false; @@ -84,16 +83,16 @@ hybrid-sleep.enable = false; }; - packages = [pkgs.observatory]; + packages = [ pkgs.observatory ]; - services.monitord.wantedBy = ["multi-user.target"]; + services.monitord.wantedBy = [ "multi-user.target" ]; }; i18n = { # Select internationalisation properties. defaultLocale = "en_US.UTF-8"; - supportedLocales = ["all"]; + supportedLocales = [ "all" ]; extraLocaleSettings = { LC_ADDRESS = "en_US.UTF-8"; @@ -133,7 +132,11 @@ shell = pkgs.fish; isNormalUser = true; description = user.name; - extraGroups = ["networkmanager" "wheel" "docker"]; + extraGroups = [ + "networkmanager" + "wheel" + "docker" + ]; # openssh.authorizedKeys.keyFiles = ["~/.ssh/id_ed25519.pub"]; packages = with pkgs; [ firefox @@ -157,12 +160,16 @@ # wireless.enable = true; # Enables wireless support via wpa_supplicant. networkmanager.enable = true; firewall = { - allowedTCPPorts = [22 80 443]; + allowedTCPPorts = [ + 22 + 80 + 443 + ]; enable = true; }; interfaces.enp11s0.wakeOnLan = { enable = true; - policy = ["magic"]; + policy = [ "magic" ]; }; }; diff --git a/users/natalie/desktop/hardware-configuration.nix b/users/natalie/desktop/hardware-configuration.nix index 92f5c10..3ff0e15 100644 --- a/users/natalie/desktop/hardware-configuration.nix +++ b/users/natalie/desktop/hardware-configuration.nix @@ -7,15 +7,22 @@ pkgs, modulesPath, ... -}: { +}: +{ imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = ["nvme" "ahci" "xhci_pci" "usbhid" "sd_mod"]; - boot.initrd.kernelModules = []; - boot.kernelModules = ["kvm-amd"]; - boot.extraModulePackages = []; + boot.initrd.availableKernelModules = [ + "nvme" + "ahci" + "xhci_pci" + "usbhid" + "sd_mod" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; fileSystems."/" = { device = "/dev/disk/by-uuid/5838d50d-e6e8-4ad2-a25e-524f4c46da35"; @@ -25,7 +32,10 @@ fileSystems."/boot/efi" = { device = "/dev/disk/by-uuid/2319-EE79"; fsType = "vfat"; - options = ["fmask=0022" "dmask=0022"]; + options = [ + "fmask=0022" + "dmask=0022" + ]; }; fileSystems."/home/nmarks/Games/steam" = { @@ -34,7 +44,7 @@ }; swapDevices = [ - {device = "/dev/disk/by-uuid/a4128bb9-239c-4aa9-9777-5067feb77b28";} + { device = "/dev/disk/by-uuid/a4128bb9-239c-4aa9-9777-5067feb77b28"; } ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking diff --git a/users/natalie/desktop/home.nix b/users/natalie/desktop/home.nix index 54607fd..d3aa825 100644 --- a/users/natalie/desktop/home.nix +++ b/users/natalie/desktop/home.nix @@ -6,12 +6,8 @@ userSettings, systemSettings, ... -}: { - imports = [ - inputs.nixvim.homeManagerModules.nixvim - #set up nixvim - # ../../modules/nixvim - ]; +}: +{ home = { stateVersion = "23.05"; # Please read the comment before changing. @@ -32,7 +28,7 @@ path-of-building wineWowPackages.stable winetricks - (prismlauncher.override {gamemodeSupport = true;}) + (prismlauncher.override { gamemodeSupport = true; }) #window manager stuff wofi diff --git a/users/natalie/home.nix b/users/natalie/home.nix index 1e8f9ef..ee30ddf 100644 --- a/users/natalie/home.nix +++ b/users/natalie/home.nix @@ -2,7 +2,8 @@ pkgs, lib, ... -} @ args: { +}@args: +{ programs = { # sort-lines:start atuin.enable = true; diff --git a/users/natalie/laptop/configuration.nix b/users/natalie/laptop/configuration.nix index 3c1d194..f7d8c3e 100644 --- a/users/natalie/laptop/configuration.nix +++ b/users/natalie/laptop/configuration.nix @@ -1,6 +1,6 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ environment.systemPackages = with pkgs; [ - neovim pinentry_mac signal-desktop-bin ]; @@ -8,7 +8,7 @@ # Custom configuration modules in "modules" are shared between users, # and can be configured in this "shared" namespace shared.darwin = { - macAppStoreApps = ["wireguard"]; + macAppStoreApps = [ "wireguard" ]; }; # Create /etc/zshrc that loads the nix-darwin environment. diff --git a/users/natalie/laptop/home.nix b/users/natalie/laptop/home.nix index 7aaf691..4c981e9 100644 --- a/users/natalie/laptop/home.nix +++ b/users/natalie/laptop/home.nix @@ -6,12 +6,8 @@ user, host, ... -} @ args: { - imports = [ - inputs.nixvim.homeManagerModules.nixvim - #set up nixvim - # ../../modules/nixvim - ]; +}@args: +{ home = { stateVersion = "23.05"; # Please read the comment before changing. # shell = pkgs.fish; diff --git a/users/natalie/packages.nix b/users/natalie/packages.nix index cafa7fb..3ae3b5c 100644 --- a/users/natalie/packages.nix +++ b/users/natalie/packages.nix @@ -1,6 +1,7 @@ # Packages installed with home-manager -{pkgs, ...}: -with pkgs; [ +{ pkgs, ... }: +with pkgs; +[ #general development just pkg-config @@ -35,7 +36,7 @@ with pkgs; [ nh #terminal stuff - (btop.override {cudaSupport = true;}) + (btop.override { cudaSupport = true; }) tmux zellij lazygit @@ -78,6 +79,7 @@ with pkgs; [ statix #neovim deps + # TODO: from clo, maybe u can remove all of these? i don't wanna break tho lua51Packages.lua lua51Packages.luarocks-nix codespell diff --git a/users/natalie/user.nix b/users/natalie/user.nix index 5d87f17..9c90a82 100644 --- a/users/natalie/user.nix +++ b/users/natalie/user.nix @@ -3,7 +3,7 @@ rec { name = "Natalie"; # name/identifier email = "nmarks413@gmail.com"; # email (used for certain configurations) dotfilesDir = "~/.dotfiles"; # absolute path of the local repo - theme = "catppuccin-mocha"; #name of theme that stylix will use + theme = "catppuccin-mocha"; # name of theme that stylix will use browser = "firefox"; # Default browser; must select one from ./user/app/browser/ term = "ghostty"; # Default terminal command; font = "iosevka"; # Selected font diff --git a/users/natalie/vim.nix b/users/natalie/vim.nix new file mode 100644 index 0000000..938e199 --- /dev/null +++ b/users/natalie/vim.nix @@ -0,0 +1,9 @@ +{ ... }: +{ + vim = { + theme = { + name = "catppuccin"; + style = "mocha"; + }; + }; +}