From e64f7a78e01e5fa661471cb518cc71fc33223b5a Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 21 Jul 2024 01:49:04 +0700 Subject: m --- hosts/mac/m1mba/configuration.nix | 18 +++++++++++ hosts/mac/m1mba/keyboard.nix | 53 ++++++++++++++++++++++++++++++ hosts/mac/m1mba/mac.nix | 12 +++++++ hosts/mac/m1mba/pkgs.nix | 68 +++++++++++++++++++++++++++++++++++++++ hosts/mac/m1mba/services.nix | 11 +++++++ hosts/mac/m1mba/users.nix | 43 +++++++++++++++++++++++++ 6 files changed, 205 insertions(+) create mode 100644 hosts/mac/m1mba/configuration.nix create mode 100644 hosts/mac/m1mba/keyboard.nix create mode 100644 hosts/mac/m1mba/mac.nix create mode 100644 hosts/mac/m1mba/pkgs.nix create mode 100644 hosts/mac/m1mba/services.nix create mode 100644 hosts/mac/m1mba/users.nix (limited to 'hosts/mac/m1mba') diff --git a/hosts/mac/m1mba/configuration.nix b/hosts/mac/m1mba/configuration.nix new file mode 100644 index 0000000..373f781 --- /dev/null +++ b/hosts/mac/m1mba/configuration.nix @@ -0,0 +1,18 @@ +{...}: { + imports = [ + ../../base.nix + ../mac.nix + ./users.nix + ./pkgs.nix + ]; + + # Auto upgrade nix package and the daemon service. + services.nix-daemon.enable = true; + # nix.package = pkgs.nix; + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 4; + + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "aarch64-darwin"; +} diff --git a/hosts/mac/m1mba/keyboard.nix b/hosts/mac/m1mba/keyboard.nix new file mode 100644 index 0000000..f6b164f --- /dev/null +++ b/hosts/mac/m1mba/keyboard.nix @@ -0,0 +1,53 @@ +{ kmonad, config, lib, pkgs, ... }: + +let cfg = config.y.kmonad; in +{ + options.y.kmonad = { + enable = lib.mkEnableOption "kmonad"; + + config = lib.mkOption { + type = lib.types.lines; + }; + }; + + config = lib.mkIf cfg.enable { + nixpkgs.overlays = [ kmonad.overlays.default ]; + + launchd.daemons.kmonad-default.serviceConfig = { + EnvironmentVariables.PATH = "${pkgs.kmonad}/bin:${pkgs.overlays.Karabiner-DriverKit-VirtualHIDDevice}/Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/Applications/Karabiner-DriverKit-VirtualHIDDeviceClient.app/Contents/MacOS:${config.environment.systemPath}"; + KeepAlive = true; + Nice = -20; + ProgramArguments = [ + "/Applications/.Karabiner-VirtualHIDDevice-Manager.app/kmonad-daemon-shim" + "--input" + ''iokit-name "Apple Internal Keyboard / Trackpad"'' + + (toString (builtins.toFile "../../kmonad/mac.kbd" '' + (defcfg + input (iokit-name "Apple Internal Keyboard / Trackpad") + output (kext) + fallthrough true + allow-cmd false + ) + + ${cfg.config} + '')) + ]; + StandardOutPath = "/Library/Logs/KMonad/default-stdout"; + StandardErrorPath = "/Library/Logs/KMonad/default-stderr"; + RunAtLoad = true; + }; + + system.activationScripts.script.applications.text = '' + echo copying dext... + ${pkgs.rsync}/bin/rsync -a --delete ${pkgs.overlays.Karabiner-DriverKit-VirtualHIDDevice}/Applications/.Karabiner-VirtualHIDDevice-Manager.app/ /Applications/.Karabiner-VirtualHIDDevice-Manager.app + echo copying shim... + cp --no-preserve mode ${pkgs.overlays.kmonad-daemon-shim}/bin/kmonad-daemon-shim /Applications/.Karabiner-VirtualHIDDevice-Manager.app/kmonad-daemon-shim + chown root /Applications/.Karabiner-VirtualHIDDevice-Manager.app/kmonad-daemon-shim + chmod u=rx,og= /Applications/.Karabiner-VirtualHIDDevice-Manager.app/kmonad-daemon-shim + echo activating dext... + /Applications/.Karabiner-VirtualHIDDevice-Manager.app/Contents/MacOS/Karabiner-VirtualHIDDevice-Manager activate + printf '\x1b[0;31mPlease grant Input Monitoring permissions to /Applications/.Karabiner-VirtualHIDDevice-Manager.app/kmonad-daemon-shim in System Preferences > Security & Privacy > Privacy > Input Monitoring\x1b[0m\n' + ''; + }; +} diff --git a/hosts/mac/m1mba/mac.nix b/hosts/mac/m1mba/mac.nix new file mode 100644 index 0000000..dba3035 --- /dev/null +++ b/hosts/mac/m1mba/mac.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: +{ + fonts.fontDir.enable = true; + fonts.fonts = with pkgs; [ + recursive + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + ]; + system.keyboard = { + enableKeyMapping = true; + remapCapsLockToEscape = true; + }; +} diff --git a/hosts/mac/m1mba/pkgs.nix b/hosts/mac/m1mba/pkgs.nix new file mode 100644 index 0000000..dffcd66 --- /dev/null +++ b/hosts/mac/m1mba/pkgs.nix @@ -0,0 +1,68 @@ +{ pkgs, kmonad, unstablePkgs, ...}: + +{ +# custom +# y.kmonad.enable = true; + environment.systemPackages = with unstablePkgs; [ + # custom + pkgs.overlays.yabai + #unfree +# slack +# spotify +# corefonts +# symbola + #gui + alacritty + vscodium + tdesktop + # terminal + # + vim + neovim + helix + # --- + wget + htop + bat + gitAndTools.gitFull + lazygit + git-lfs + lsd + lsof + tmux + tmate + curlFull + ripgrep + ranger + minio + minio-client + zip + unzip + jq + vifm + nnn + # neovim asks for a c compiler just to run nvim-treesitter commands. let's see + fzf + killall + tree + deluge + ncdu + edir + bottom + pigz + rclone + # direnv + direnv + nix-direnv + # scraping + python310Packages.yt-dlp + # code + nodejs + node2nix + zig + gcc + gnumake + sqlite + ]; +} + diff --git a/hosts/mac/m1mba/services.nix b/hosts/mac/m1mba/services.nix new file mode 100644 index 0000000..52572ac --- /dev/null +++ b/hosts/mac/m1mba/services.nix @@ -0,0 +1,11 @@ +inputs: pkgs: +let inherit (pkgs) callPackage +in { + Karabiner-DriverKit-VirtualHIDDevice = callPackage + ./Karabiner-DriverKit-VirtualHIDDevice + { Karabiner-DriverKit-VirtualHIDDevice-src = inputs.kmonad + "/../c_src/mac/Karabiner-DriverKit-VirtualHIDDevice"; }; + kmonad-daemon-shim = callPackage ./kmonad-daemon-shim { }; + yabai = callPackage ./yabai { + inherit (pkgs) yabai; + }; +} \ No newline at end of file diff --git a/hosts/mac/m1mba/users.nix b/hosts/mac/m1mba/users.nix new file mode 100644 index 0000000..10eceac --- /dev/null +++ b/hosts/mac/m1mba/users.nix @@ -0,0 +1,43 @@ +{ config, pkgs, ... }: + + +let shellAliases = { + l = "lsd -lAh"; + la = "lsd -lAh"; + ports = "sudo lsof -i -P -n | grep LISTEN"; + gco = "git checkout"; + gcob = "git checkout -b"; + v = "nvim"; + sv = "sudo nvim"; + dotsin = "sh ~/dotfiles/commit.sh"; + sourceit = ". (sed 's/^/export /' .env | psub)"; + rebuild = "darwin-rebuild switch --flake ~/dotfiles/nixos/mac"; +}; + +in { + programs.fish = { + inherit shellAliases; + enable = true; +# plugins = [{ +# name="foreign-env"; +# src = pkgs.fetchFromGitHub { +# owner = "oh-my-fish"; +# repo = "plugin-foreign-env"; +# rev = "dddd9213272a0ab848d474d0cbde12ad034e65bc"; +# sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"; +# }; +# }]; +}; + + users = { + users = { + y = { + createHome = true; + home = "/home/y"; + shell = pkgs.fish; + }; + }; + }; +} + + -- cgit v1.2.3