From 4af3fa88ddd28c6d644844dba43d24d4bacb767f Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 5 Jul 2023 15:34:42 +0800 Subject: [PATCH] feat: install apps using homebrew instead of nix --- README.md | 2 - home/darwin/core.nix | 19 --------- hosts/harmonica/default.nix | 1 + modules/darwin/apps.nix | 78 +++++++++++++++++++++++++++++++++++++ modules/darwin/core.nix | 7 +--- 5 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 modules/darwin/apps.nix diff --git a/README.md b/README.md index a6a59a2f..5afaeb62 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,6 @@ This repository is home to the nix code that builds my systems. - [ ] Enable disk encryption to enhance data security - [ ] `Xcursor.size` does not take effect in i3 -- [ ] update macOS's config, refer to - - Nix is not well supported on macOS, I met some strange bug recently, so I would like to migrate to nix-darwin's [homebrew](https://daiderd.com/nix-darwin/manual/index.html#opt-homebrew.enable) on macOS. ## Why Nix? diff --git a/home/darwin/core.nix b/home/darwin/core.nix index 881d813a..a3647a86 100644 --- a/home/darwin/core.nix +++ b/home/darwin/core.nix @@ -5,27 +5,8 @@ # # MacOS specific home configuration # - # Install those apps using brew, instead of nix - # because they are not available in nixpkgs with the support of darwin - # ==> Brew Casks - # jdk-mission-control - # anki firefox wireshark - # iina openinterminal-lite - # insomnia orbstack - # clashx google-chrome - # google-cloud-sdk telegram ########################################################################## - home.packages = with pkgs; [ - mpv - discord - ]; - - # stable version of vscode - programs.vscode = { - enable = true; - }; - programs.ssh = { enable = true; diff --git a/hosts/harmonica/default.nix b/hosts/harmonica/default.nix index 8474a2a5..11fd0f8b 100644 --- a/hosts/harmonica/default.nix +++ b/hosts/harmonica/default.nix @@ -9,5 +9,6 @@ { imports = [ ../../modules/darwin/core.nix + ../../modules/darwin/apps.nix ]; } diff --git a/modules/darwin/apps.nix b/modules/darwin/apps.nix new file mode 100644 index 00000000..67ebe77e --- /dev/null +++ b/modules/darwin/apps.nix @@ -0,0 +1,78 @@ +{ pkgs, ...}: { + + ########################################################################## + # + # MacOS specific nix-darwin configuration + # + # Nix is not well supported on macOS, I met some strange bug recently. + # So install apps using [homebrew](https://daiderd.com/nix-darwin/manual/index.html#opt-homebrew.enable) here. + # + ########################################################################## + + system = { + defaults = { + dock = { + autohide = true; + }; + + finder = { + _FXShowPosixPathInTitle = false; + }; + }; + + keyboard = { + enableKeyMapping = true; + remapCapsLockToControl = true; + }; + }; + + homebrew = { + enable = true; + + onActivation = { + autoUpdate = false; + # 'zap': uninstalls all formulae(and related files) not listed in the generated Brewfile + cleanup = "zap"; + }; + + taps = [ + "homebrew/cask" + "homebrew/cask-fonts" + "homebrew/services" + "homebrew/cask-versions" + + "hashicorp/tap" + "pulumi/tap" + ]; + + brews = [ + # `brew install` + "httpie" + ]; + + # `brew install --cask` + casks = [ + "firefox" + "google-chrome" + "visual-studio-code" + "visual-studio-code-insiders" + + "telegram" + "discord" + + # "anki" + "clashx" + "iina" + "openinterminal-lite" + "syncthing" + "raycast" + "iglance" + + "iterm2" + "insomnia" + "wireshark" + "jdk-mission-control" + "google-cloud-sdk" + ]; + }; +} \ No newline at end of file diff --git a/modules/darwin/core.nix b/modules/darwin/core.nix index b0e24b06..11f00d19 100644 --- a/modules/darwin/core.nix +++ b/modules/darwin/core.nix @@ -10,10 +10,11 @@ # ################################################################################### - # # enable flakes globally nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.trusted-users = ["admin"]; + # Allow unfree packages nixpkgs.config.allowUnfree = true; @@ -30,10 +31,6 @@ # Add ability to used TouchID for sudo authentication security.pam.enableSudoTouchIdAuth = true; - # Keyboard - system.keyboard.enableKeyMapping = true; - system.keyboard.remapCapsLockToEscape = true; - # Set your time zone. time.timeZone = "Asia/Shanghai";