├── README.md ├── darwin-configuration.nix ├── home.nix ├── link-apps ├── create-macos-alias.swift └── default.nix ├── misc.nix ├── modules ├── git │ └── default.nix ├── gpg │ └── default.nix └── zsh │ ├── .zshrc │ └── default.nix └── overlays ├── default.nix ├── emacs ├── default.nix ├── fix-window-role.patch ├── ligatures-freeze-fix.patch ├── no-frame-refocus-cocoa.patch ├── no-titlebar.patch └── system-appearance.patch ├── firefox └── default.nix └── solidity └── default.nix /README.md: -------------------------------------------------------------------------------- 1 | # nix-config 2 | 3 | My nix configuration. 4 | 5 | ## Installation 6 | 7 | 1. Install nix 8 | 2. Install nix-darwin 9 | 10 | In addition to the regular installation steps (which were painful), I had to add darwin as a channel for my user: 11 | 12 | ```sh 13 | nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin 14 | nix-channel --update 15 | ``` 16 | 17 | 3. Install home-manager 18 | 19 | ```sh 20 | nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager 21 | nix-channel --update 22 | ``` 23 | 24 | 4. Clone this repo into `~/.nixpkgs` 25 | 26 | 5. Run: 27 | 28 | ``` sh 29 | darwin-rebuild switch 30 | ``` 31 | 32 | ### Alfred 33 | 34 | Mac apps built with Nix don't play well with Alfred / spotlight search. To work around this, we create aliases for nix applications and place them in `$HOME/Applications/Nix`. See [this issue](https://github.com/LnL7/nix-darwin/issues/139) for more context. 35 | 36 | We need to configure Alfred to index aliases by going to `Alfred Preferences -> Features -> Default Results -> Extras -> Advanced...` and dragging in one of the aliases in `$HOME/Applications/Nix`. 37 | 38 | ## Updating 39 | 40 | Root owns the nixpkgs channel so sudo is needed to update that: 41 | 42 | ```sh 43 | sudo nix-channel --update 44 | ``` 45 | 46 | User channels should be updated as well: 47 | 48 | ```sh 49 | nix-channel --update 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /darwin-configuration.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, options, ... }: 2 | 3 | with pkgs.stdenv; with lib; { 4 | imports = [ 5 | 6 | ./link-apps 7 | ]; 8 | 9 | nix.useSandbox = true; 10 | 11 | nixpkgs.overlays = import ./overlays; 12 | 13 | # List packages installed in system profile. To search by name, run: 14 | # $ nix-env -qaP | grep wget 15 | environment.systemPackages = 16 | [ pkgs.vim 17 | ]; 18 | 19 | # Use a custom configuration.nix location. 20 | # $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix 21 | # environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix"; 22 | 23 | # Auto upgrade nix package and the daemon service. 24 | services.nix-daemon.enable = true; 25 | # nix.package = pkgs.nix; 26 | 27 | # Create /etc/zshrc that loads the nix-darwin environment. 28 | programs.zsh.enable = true; 29 | environment.shells = with pkgs; [ zsh ]; 30 | 31 | users.users.mark = { 32 | name = "mark"; 33 | home = "/Users/mark"; 34 | shell = pkgs.zsh; 35 | }; 36 | 37 | home-manager.users.mark = import ./home.nix; 38 | home-manager.useGlobalPkgs = true; 39 | 40 | # Add home-manager applications to `system.build.applications` so they will be linked 41 | # by services.link-apps. 42 | system.build.applications = pkgs.lib.mkForce (pkgs.buildEnv { 43 | name = "applications"; 44 | paths = config.environment.systemPackages ++ config.home-manager.users.mark.home.packages; 45 | pathsToLink = "/Applications"; 46 | }); 47 | 48 | services.link-apps = { 49 | enable = true; 50 | userName = config.users.users.mark.name; 51 | userHome = config.users.users.mark.home; 52 | }; 53 | 54 | services.lorri.enable = true; 55 | 56 | # Used for backwards compatibility, please read the changelog before changing. 57 | # $ darwin-rebuild changelog 58 | system.stateVersion = 4; 59 | } 60 | -------------------------------------------------------------------------------- /home.nix: -------------------------------------------------------------------------------- 1 | { pkgs, ... }: 2 | 3 | { 4 | home.stateVersion = "20.09"; 5 | 6 | imports = [ 7 | ./modules/zsh 8 | ./modules/git 9 | ./modules/gpg 10 | ./misc.nix 11 | ]; 12 | 13 | home.username = "mark"; 14 | home.homeDirectory = "/Users/mark"; 15 | 16 | programs.home-manager.enable = true; 17 | 18 | landakram.programs.zsh.enable = true; 19 | landakram.programs.git.enable = true; 20 | landakram.programs.gpg.enable = true; 21 | 22 | programs.keychain = { 23 | enable = true; 24 | keys = [ "id_rsa" "54583DDF0BD31A45" ]; 25 | agents = [ "ssh" "gpg" ]; 26 | inheritType = "any"; 27 | }; 28 | 29 | programs.direnv.enable = true; 30 | programs.fzf.enable = true; 31 | programs.z-lua.enable = true; 32 | 33 | programs.firefox = { 34 | enable = true; 35 | package = pkgs.firefox; 36 | }; 37 | 38 | programs.emacs = { 39 | enable = true; 40 | package = pkgs.emacs; 41 | }; 42 | 43 | programs.go.enable = true; 44 | } 45 | -------------------------------------------------------------------------------- /link-apps/create-macos-alias.swift: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env swift 2 | 3 | // Create an alias file ("bookmark88" format). Note that although Finder treats 4 | // this like a symlink, it is different. 5 | // 6 | // Equivalent to: 7 | // osascript -e "tell application "Finder" to make new alias at POSIX file \"${dest}\" to POSIX file \"${src}\"" 8 | 9 | 10 | import Foundation 11 | 12 | var src: String? 13 | var dest: String? 14 | 15 | if CommandLine.argc < 3 { 16 | print("Expected two arguments: src and dest.") 17 | exit(1) 18 | } else { 19 | src = CommandLine.arguments[1] 20 | dest = CommandLine.arguments[2] 21 | } 22 | 23 | let url = URL(fileURLWithPath: src!) 24 | let aliasUrl = URL(fileURLWithPath: dest!) 25 | 26 | do { 27 | let data = try url.bookmarkData(options: .suitableForBookmarkFile, includingResourceValuesForKeys: nil, relativeTo: nil) 28 | try URL.writeBookmarkData(data, to: aliasUrl) 29 | } catch { 30 | print("Unexpected error: \(error).") 31 | exit(1) 32 | } 33 | -------------------------------------------------------------------------------- /link-apps/default.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | with lib; 4 | let 5 | cfg = config.services.link-apps; 6 | 7 | createMacOSAlias = ( 8 | (builtins.toString ( 9 | pkgs.callPackage 10 | ({ stdenv }: 11 | 12 | stdenv.mkDerivation rec { 13 | name = "create-macos-alias"; 14 | 15 | unpackPhase = "true"; # nothing to unpack 16 | 17 | src = ./create-macos-alias.swift; 18 | 19 | dontConfigure = true; 20 | 21 | buildInputs = [ ]; 22 | 23 | dontBuild = true; 24 | 25 | installPhase = '' 26 | install -D -m755 $src $out/bin/create-macos-alias 27 | ''; 28 | 29 | meta = with stdenv.lib; { 30 | license = licenses.mit; 31 | platforms = platforms.darwin; 32 | maintainers = with maintainers; [ landakram ]; 33 | }; 34 | } 35 | ) { } 36 | )) + "/bin/create-macos-alias" 37 | ); 38 | in 39 | { 40 | options = { 41 | services.link-apps = { 42 | enable = mkEnableOption "create aliases (not symlinks) for macOS Apps at activation time"; 43 | 44 | userName = mkOption { 45 | type = types.str; 46 | }; 47 | 48 | userHome = mkOption { 49 | type = types.path; 50 | }; 51 | 52 | dest = mkOption { 53 | type = types.path; 54 | default = "${cfg.userHome}/Applications/Nix"; 55 | description = "Destination where nix-compiled Apps will be aliased."; 56 | }; 57 | }; 58 | }; 59 | 60 | config = mkIf cfg.enable { 61 | system.activationScripts.postActivation.text = '' 62 | echo "Aliasing Apps to ${cfg.dest}" 63 | mkdir -p ${cfg.dest} 64 | chown ${cfg.userName} ${cfg.dest} 65 | find ${config.system.build.applications}/Applications -maxdepth 1 -type l | while read f; do 66 | src="$(/usr/bin/stat -f%Y $f)" 67 | appname="$(basename $src)" 68 | dest=${cfg.dest}/$appname 69 | [ -f $dest ] && rm $dest 70 | ${createMacOSAlias} "''${src}" "''${dest}" 71 | done 72 | ''; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /misc.nix: -------------------------------------------------------------------------------- 1 | { pkgs, ... }: 2 | 3 | with pkgs; 4 | { 5 | home.packages = [ 6 | htop 7 | wget 8 | fortune 9 | tree 10 | ripgrep 11 | telnet 12 | jdk11 13 | bfg-repo-cleaner 14 | clojure 15 | python3 16 | python37Packages.pipx 17 | ruby 18 | cabal-install 19 | ghc 20 | clang 21 | cachix 22 | chicken 23 | racket-minimal 24 | ipfs 25 | graphviz 26 | ansible 27 | sshpass 28 | kubectl 29 | watch 30 | inkscape 31 | # TODO: Results in an error 32 | # sandbox-exec: pattern serialization length 67173 exceeds maximum (65535) 33 | # https://github.com/NixOS/nix/issues/4119 34 | # texlive.combined.scheme-medium 35 | 36 | solc 37 | ]; 38 | } 39 | -------------------------------------------------------------------------------- /modules/git/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, config, ... }: 2 | 3 | with lib; let 4 | cfg = config.landakram.programs.git; 5 | in { 6 | options = { 7 | landakram.programs.git = { 8 | enable = mkEnableOption "landakram's git"; 9 | }; 10 | }; 11 | 12 | config = mkIf cfg.enable { 13 | programs.git = { 14 | enable = true; 15 | 16 | userName = "Mark Hudnall"; 17 | userEmail = "me@markhudnall.com"; 18 | 19 | extraConfig = { 20 | credential = { 21 | helper = "osxkeychain"; 22 | }; 23 | color = { 24 | ui = true; 25 | }; 26 | push = { 27 | default = "matching"; 28 | }; 29 | }; 30 | 31 | ignores = [ 32 | # Mac OS X hidden files 33 | ".DS_Store" 34 | 35 | # Vim swap files 36 | ".*.sw?" 37 | "*un~" 38 | 39 | # Pow and Powder config 40 | "/.pow*" 41 | 42 | # RVM and rbenv 43 | "/.rvmrc" 44 | "/.rbenv-version" 45 | 46 | "node_modules" 47 | "dump.rdb" 48 | ]; 49 | }; 50 | 51 | home.packages = with pkgs; [ 52 | git-lfs 53 | ]; 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /modules/gpg/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, config, ... }: 2 | 3 | with lib; let 4 | cfg = config.landakram.programs.gpg; 5 | in 6 | { 7 | options = { 8 | landakram.programs.gpg = { 9 | enable = mkEnableOption "confiuure gpg with defaults and pin entry"; 10 | 11 | pinentry-program = mkOption { 12 | default = pkgs.pinentry_mac; 13 | type = types.attrs; 14 | description = "Pinentry program for decrypting GPG keys."; 15 | }; 16 | 17 | pinentry-program-bin = mkOption { 18 | default = "${cfg.pinentry-program}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac"; 19 | type = types.path; 20 | description = "Bin to use for pinentry. Should be consistent with pinentry-program option."; 21 | }; 22 | 23 | default-key = mkOption { 24 | default = "54583DDF0BD31A45"; 25 | type = types.str; 26 | description = "Default GPG key"; 27 | }; 28 | }; 29 | }; 30 | 31 | config = mkIf cfg.enable { 32 | programs.gpg = { 33 | enable = true; 34 | settings = { 35 | default-key = cfg.default-key; 36 | keyid-format = "LONG"; 37 | keyserver = "hkp://keys.gnupg.net"; 38 | keyserver-options = "auto-key-retrieve"; 39 | auto-key-locate = "cert pka ldap hkp://keys.gnupg.net"; 40 | }; 41 | }; 42 | 43 | home.packages = [ 44 | cfg.pinentry-program 45 | ]; 46 | home.file.".gnupg/gpg-agent.conf".text = '' 47 | pinentry-program ${cfg.pinentry-program-bin} 48 | default-cache-ttl 2400 49 | max-cache-ttl 7200 50 | ''; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /modules/zsh/.zshrc: -------------------------------------------------------------------------------- 1 | # This isn't actually used anymore. Just here for reference. 2 | 3 | export PATH=/usr/local/Cellar/chicken/5.2.0/bin/:$PATH 4 | export PATH=/usr/local/Cellar/gnupg/2.2.19/bin/:$PATH 5 | export PATH=/usr/local/bin/libimobiledevice:$PATH 6 | export PATH=/usr/local/opt/gettext/bin:$PATH 7 | export PATH=/usr/local/bin/packer:$PATH 8 | export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH 9 | export PATH=$PATH:$GOPATH/bin 10 | export PATH=/usr/local/bin/:$PATH 11 | export PATH=/usr/local/Cellar/mysql55/5.5.44/bin:$PATH 12 | export PATH=/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/bin:$PATH 13 | export PATH=/Users/mark/Library/Android/sdk/tools:$PATH 14 | export PATH=/Users/mark/Library/Android/sdk/platform-tools:$PATH 15 | export PATH=/Users/mark/.pyenv/shims:$PATH 16 | export PATH=/Users/mark/.local/bin:$PATH 17 | export PATH=/Applications/Processing.app/Contents/PlugIns/jdk1.8.0_202.jdk/Contents/Home/jre/bin/:$PATH 18 | 19 | source ~/.secrets.zsh 20 | 21 | source ~/.ghcup/env 22 | 23 | eval $(opam env) 24 | 25 | export PUSHOVER_API_KEY=***REMOVED*** 26 | export PUSHOVER_USER_KEY=***REMOVED*** 27 | 28 | export NOTI_PUSHOVER_APITOKEN=$PUSHOVER_API_KEY 29 | export NOTI_PUSHOVER_USERKEY=$PUSHOVER_USER_KEY 30 | 31 | # Z configuration 32 | . `brew --prefix`/etc/profile.d/z.sh 33 | 34 | export GOPATH=$HOME/go 35 | 36 | export AWS_CREDENTIAL_FILE=~/.aws_credentials 37 | export AWS_ELB_HOME="/usr/local/Cellar/elb-tools/1.0.34.0/libexec" 38 | 39 | export LEDGER_FILE=~/ledger-files/journal.ledger 40 | export PASSWORD_STORE_DIR=~/.password-store 41 | 42 | ############## 43 | 44 | eval "$(rbenv init -)" 45 | 46 | # Allow direnv to load .envrc files 47 | eval "$(direnv hook zsh)" 48 | 49 | source "$HOME/.homesick/repos/homeshick/homeshick.sh" 50 | 51 | 52 | export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" 53 | -------------------------------------------------------------------------------- /modules/zsh/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, config, ... }: 2 | 3 | with lib; let 4 | cfg = config.landakram.programs.zsh; 5 | in { 6 | options = { 7 | landakram.programs.zsh = { 8 | enable = mkEnableOption "landakram's zsh"; 9 | }; 10 | }; 11 | 12 | config = mkIf cfg.enable { 13 | programs.zsh = { 14 | enable = true; 15 | enableCompletion = true; 16 | 17 | shellAliases = { 18 | vi = "vim"; 19 | }; 20 | 21 | history = { 22 | save = 10000; 23 | share = true; 24 | size = 10000; 25 | }; 26 | 27 | initExtra = '' 28 | function virtualenv_info { [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' } 29 | 30 | bindkey -e 31 | 32 | # Show selected item in tab completion 33 | zstyle ':completion:*' menu select 34 | 35 | # Let alt-backspace delete to slashes, which is more consistent with 36 | # fish's behavior 37 | backward-kill-dir () { 38 | local WORDCHARS=''${WORDCHARS/\/} 39 | zle backward-kill-word 40 | } 41 | zle -N backward-kill-dir 42 | bindkey '^[^?' backward-kill-dir 43 | 44 | # Load keychain (ssh-agent, gpg-agent) 45 | eval $(keychain --quiet --inherit any --eval --agents ssh,gpg -Q id_rsa 54583DDF0BD31A45) 46 | 47 | bindkey -M emacs '^P' history-substring-search-up 48 | bindkey -M emacs '^N' history-substring-search-down 49 | 50 | bindkey '^R' zaw-history 51 | bindkey -M filterselect '^R' down-line-or-history 52 | bindkey -M filterselect '^S' up-line-or-history 53 | bindkey -M filterselect '^E' accept-search 54 | zstyle ':filter-select:highlight' matched fg=green 55 | zstyle ':filter-select' max-lines 3 56 | zstyle ':filter-select' case-insensitive yes # enable case-insensitive 57 | zstyle ':filter-select' extended-search yes # see below 58 | ''; 59 | 60 | envExtra = '' 61 | export PATH=~/.local/bin:/usr/local/texlive/2016/bin/x86_64-darwin/:~/go/bin/:$PATH 62 | export NVM_LAZY_LOAD=true 63 | export NVM_COMPLETION=true 64 | export EDITOR=vim 65 | export CLICOLOR=1 66 | export JAVA_HOME="$(/usr/libexec/java_home)" 67 | 68 | export GO111MODULE=on 69 | ''; 70 | 71 | zplug = { 72 | enable = true; 73 | plugins = [ 74 | { 75 | name = "landakram/lambda-mod-zsh-theme"; 76 | tags = ["as:theme"]; 77 | } 78 | { 79 | name = "zsh-users/zsh-autosuggestions"; 80 | } 81 | { 82 | name = "zsh-users/zsh-history-substring-search"; 83 | } 84 | { 85 | name = "lukechilds/zsh-nvm"; 86 | } 87 | { 88 | name = "zsh-users/zaw"; 89 | } 90 | { 91 | name = "zsh-users/zsh-syntax-highlighting"; 92 | tags = ["defer:2"]; 93 | } 94 | ]; 95 | }; 96 | }; 97 | }; 98 | } 99 | -------------------------------------------------------------------------------- /overlays/default.nix: -------------------------------------------------------------------------------- 1 | [ 2 | (import ./firefox) 3 | (import ./emacs) 4 | (import ./solidity) 5 | ] 6 | -------------------------------------------------------------------------------- /overlays/emacs/default.nix: -------------------------------------------------------------------------------- 1 | self: super: 2 | { 3 | emacs = (super.emacs27.overrideAttrs (o: rec { 4 | patches = [ 5 | ./fix-window-role.patch 6 | ./ligatures-freeze-fix.patch 7 | ./no-frame-refocus-cocoa.patch 8 | # ./no-titlebar.patch 9 | ./system-appearance.patch 10 | ]; 11 | })); 12 | } 13 | -------------------------------------------------------------------------------- /overlays/emacs/fix-window-role.patch: -------------------------------------------------------------------------------- 1 | From 614bc763e72bdd5b26add04338cacc6803e2a0d6 Mon Sep 17 00:00:00 2001 2 | From: Golem 3 | Date: Thu, 9 Jan 2020 07:22:17 +0200 4 | Subject: [PATCH] [patch] fix-window-role 5 | 6 | --- 7 | src/nsterm.m | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/src/nsterm.m b/src/nsterm.m 11 | index 6f9b208953..aa6c1d286f 100644 12 | --- a/src/nsterm.m 13 | +++ b/src/nsterm.m 14 | @@ -8768,7 +8768,7 @@ - (id)accessibilityAttributeValue:(NSString *)attribute 15 | NSTRACE ("[EmacsWindow accessibilityAttributeValue:]"); 16 | 17 | if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) 18 | - return NSAccessibilityTextFieldRole; 19 | + return NSAccessibilityWindowRole; 20 | 21 | if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute] 22 | && curbuf && ! NILP (BVAR (curbuf, mark_active))) 23 | -- 24 | 2.26.2 25 | 26 | -------------------------------------------------------------------------------- /overlays/emacs/ligatures-freeze-fix.patch: -------------------------------------------------------------------------------- 1 | From fe903c5ab7354b97f80ecf1b01ca3ff1027be446 Mon Sep 17 00:00:00 2001 2 | From: Eli Zaretskii 3 | Date: Sat, 8 Feb 2020 15:41:36 +0200 4 | Subject: [PATCH] Allow composition of pure-ASCII strings in the mode line 5 | 6 | * src/composite.c (Fcomposition_get_gstring): Allow unibyte 7 | strings if they are pure ASCII, by copying text into a 8 | multibyte string. 9 | --- 10 | src/composite.c | 13 ++++++++++++- 11 | 1 file changed, 12 insertions(+), 1 deletion(-) 12 | 13 | diff --git a/src/composite.c b/src/composite.c 14 | index 53e6930b5f..05365cfb65 100644 15 | --- a/src/composite.c 16 | +++ b/src/composite.c 17 | @@ -1746,7 +1746,18 @@ Otherwise (for terminal display), FONT-OBJECT must be a terminal ID, a 18 | CHECK_STRING (string); 19 | validate_subarray (string, from, to, SCHARS (string), &frompos, &topos); 20 | if (! STRING_MULTIBYTE (string)) 21 | - error ("Attempt to shape unibyte text"); 22 | + { 23 | + ptrdiff_t i; 24 | + 25 | + for (i = SBYTES (string) - 1; i >= 0; i--) 26 | + if (!ASCII_CHAR_P (SREF (string, i))) 27 | + error ("Attempt to shape unibyte text"); 28 | + /* STRING is a pure-ASCII string, so we can convert it (or, 29 | + rather, its copy) to multibyte and use that thereafter. */ 30 | + Lisp_Object string_copy = Fconcat (1, &string); 31 | + STRING_SET_MULTIBYTE (string_copy); 32 | + string = string_copy; 33 | + } 34 | frombyte = string_char_to_byte (string, frompos); 35 | } 36 | 37 | -- 38 | 2.28.0 39 | 40 | -------------------------------------------------------------------------------- /overlays/emacs/no-frame-refocus-cocoa.patch: -------------------------------------------------------------------------------- 1 | From 7c14b8b6e6d4ed5ee88b6fd2857a2f07057fc058 Mon Sep 17 00:00:00 2001 2 | From: Golem 3 | Date: Thu, 9 Jan 2020 07:21:55 +0200 4 | Subject: [PATCH] [patch] no-frame-refocus-cocoa 5 | 6 | --- 7 | src/frame.c | 9 --------- 8 | 1 file changed, 9 deletions(-) 9 | 10 | diff --git a/src/frame.c b/src/frame.c 11 | index c871e4fd99..470ab948bd 100644 12 | --- a/src/frame.c 13 | +++ b/src/frame.c 14 | @@ -2056,15 +2056,6 @@ delete_frame (Lisp_Object frame, Lisp_Object force) 15 | } 16 | } 17 | } 18 | -#ifdef NS_IMPL_COCOA 19 | - else 20 | - /* Under NS, there is no system mechanism for choosing a new 21 | - window to get focus -- it is left to application code. 22 | - So the portion of THIS application interfacing with NS 23 | - needs to know about it. We call Fraise_frame, but the 24 | - purpose is really to transfer focus. */ 25 | - Fraise_frame (frame1); 26 | -#endif 27 | 28 | do_switch_frame (frame1, 0, 1, Qnil); 29 | sf = SELECTED_FRAME (); 30 | -- 31 | 2.26.2 32 | 33 | -------------------------------------------------------------------------------- /overlays/emacs/no-titlebar.patch: -------------------------------------------------------------------------------- 1 | From 056e5949bd162caf44e40deac66f6d060aa598fc Mon Sep 17 00:00:00 2001 2 | From: Golem 3 | Date: Thu, 9 Jan 2020 07:21:27 +0200 4 | Subject: [PATCH] [patch] no-titlebar-emacs-27 5 | 6 | --- 7 | src/nsterm.m | 65 +++++++--------------------------------------------- 8 | 1 file changed, 8 insertions(+), 57 deletions(-) 9 | 10 | diff --git a/src/nsterm.m b/src/nsterm.m 11 | index c1d1d41117..f19ea70b22 100644 12 | --- a/src/nsterm.m 13 | +++ b/src/nsterm.m 14 | @@ -470,11 +470,9 @@ - (NSColor *)colorUsingDefaultColorSpace 15 | 16 | /* These flags will be OR'd or XOR'd with the NSWindow's styleMask 17 | property depending on what we're doing. */ 18 | -#define FRAME_DECORATED_FLAGS (NSWindowStyleMaskTitled \ 19 | - | NSWindowStyleMaskResizable \ 20 | +#define FRAME_UNDECORATED_FLAGS ( NSWindowStyleMaskResizable \ 21 | | NSWindowStyleMaskMiniaturizable \ 22 | | NSWindowStyleMaskClosable) 23 | -#define FRAME_UNDECORATED_FLAGS NSWindowStyleMaskBorderless 24 | 25 | /* TODO: Get rid of need for these forward declarations. */ 26 | static void ns_condemn_scroll_bars (struct frame *f); 27 | @@ -1830,23 +1828,11 @@ Hide the window (X11 semantics) 28 | { 29 | block_input (); 30 | 31 | - if (NILP (new_value)) 32 | - { 33 | - FRAME_UNDECORATED (f) = false; 34 | - [window setStyleMask: ((window.styleMask | FRAME_DECORATED_FLAGS) 35 | - ^ FRAME_UNDECORATED_FLAGS)]; 36 | - 37 | - [view createToolbar: f]; 38 | - } 39 | - else 40 | - { 41 | - [window setToolbar: nil]; 42 | - /* Do I need to release the toolbar here? */ 43 | + [window setToolbar: nil]; 44 | + /* Do I need to release the toolbar here? */ 45 | 46 | - FRAME_UNDECORATED (f) = true; 47 | - [window setStyleMask: ((window.styleMask | FRAME_UNDECORATED_FLAGS) 48 | - ^ FRAME_DECORATED_FLAGS)]; 49 | - } 50 | + FRAME_UNDECORATED (f) = true; 51 | + [window setStyleMask: (window.styleMask | FRAME_UNDECORATED_FLAGS)]; 52 | 53 | /* At this point it seems we don't have an active NSResponder, 54 | so some key presses (TAB) are swallowed by the system. */ 55 | @@ -7021,36 +7007,7 @@ - (void) updateFrameSize: (BOOL) delay 56 | NSTRACE_MSG ("Original columns: %d", cols); 57 | NSTRACE_MSG ("Original rows: %d", rows); 58 | 59 | - if (! [self isFullscreen]) 60 | - { 61 | - int toolbar_height; 62 | -#ifdef NS_IMPL_GNUSTEP 63 | - // GNUstep does not always update the tool bar height. Force it. 64 | - if (toolbar && [toolbar isVisible]) 65 | - update_frame_tool_bar (emacsframe); 66 | -#endif 67 | - 68 | - toolbar_height = FRAME_TOOLBAR_HEIGHT (emacsframe); 69 | - if (toolbar_height < 0) 70 | - toolbar_height = 35; 71 | - 72 | - extra = FRAME_NS_TITLEBAR_HEIGHT (emacsframe) 73 | - + toolbar_height; 74 | - } 75 | - 76 | - if (wait_for_tool_bar) 77 | - { 78 | - /* The toolbar height is always 0 in fullscreen and undecorated 79 | - frames, so don't wait for it to become available. */ 80 | - if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0 81 | - && FRAME_UNDECORATED (emacsframe) == false 82 | - && ! [self isFullscreen]) 83 | - { 84 | - NSTRACE_MSG ("Waiting for toolbar"); 85 | - return; 86 | - } 87 | - wait_for_tool_bar = NO; 88 | - } 89 | + wait_for_tool_bar = NO; 90 | 91 | neww = (int)wr.size.width - emacsframe->border_width; 92 | newh = (int)wr.size.height - extra; 93 | @@ -7425,11 +7382,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f 94 | maximizing_resize = NO; 95 | #endif 96 | 97 | - win = [[EmacsWindow alloc] 98 | + win = [[EmacsFSWindow alloc] 99 | initWithContentRect: r 100 | - styleMask: (FRAME_UNDECORATED (f) 101 | - ? FRAME_UNDECORATED_FLAGS 102 | - : FRAME_DECORATED_FLAGS) 103 | + styleMask: FRAME_UNDECORATED_FLAGS 104 | backing: NSBackingStoreBuffered 105 | defer: YES]; 106 | 107 | @@ -7462,10 +7417,6 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f 108 | NILP (tem) ? "Emacs" : SSDATA (tem)]; 109 | [win setTitle: name]; 110 | 111 | - /* toolbar support */ 112 | - if (! FRAME_UNDECORATED (f)) 113 | - [self createToolbar: f]; 114 | - 115 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 116 | #ifndef NSAppKitVersionNumber10_10 117 | #define NSAppKitVersionNumber10_10 1343 118 | -- 119 | 2.24.1 120 | 121 | -------------------------------------------------------------------------------- /overlays/emacs/system-appearance.patch: -------------------------------------------------------------------------------- 1 | Patch to make emacs 27 aware of the macOS 10.14+ system appearance changes. 2 | From 43963fc1a2c37657067710243bfeda6c7dd06a67 Mon Sep 17 00:00:00 2001 3 | From: "Nicolas G. Querol" 4 | Date: Sun, 8 Nov 2020 19:07:31 +0100 5 | Subject: [PATCH] Add `ns-system-appearance-change-functions' hook 6 | 7 | This implements a new hook, effective only on macOS >= 10.14 (Mojave), 8 | that is called when the system changes its appearance (e.g. from light 9 | to dark). Users can then implement functions that take this change 10 | into account, for instance to load a particular theme. 11 | 12 | Minor changes are also made to select the right "dark" appearance 13 | (NSAppearanceNameDarkAqua) on macOS versions >= 10.14, the previous one 14 | (NSAppearanceNameVibrantDark) being deprecated. 15 | 16 | * src/frame.h (enum ns_appearance_type): Add new 17 | "ns_appearance_dark_aqua" case. 18 | 19 | * src/nsfns.m (defun x-create-frame): Use "dark aqua" appearance on 20 | macOS >= 10.14. 21 | 22 | * src/nsterm.m: 23 | - (ns_set_appearance): Use "dark aqua" appearance on 24 | macOS >= 10.14, reset appearance to the system one 25 | if `ns-appearance' frame parameter is not set to 26 | either `dark' or `light'. 27 | - (initFrameFromEmacs): Use "dark aqua" appearance on 28 | macOS >= 10.14. 29 | - (EmacsApp) Add the `systemDidChangeAppearance' private method, 30 | as well as the appropriate Key-Value Observing calls to update 31 | the frame's appearance when the system (and thus the app's) 32 | appearance changes. 33 | - Add `ns-system-appearance-change-functions' hook variable and 34 | symbol, to allow users to add functions that react to the 35 | change of the system's appearance. 36 | - Add `ns-system-appearance' variable, to allow users to consult 37 | the current system appearance. 38 | 39 | Here is an example on how to use this new feature: 40 | 41 | (defun my/load-theme (appearance) 42 | "Load theme, taking current system APPEARANCE into consideration." 43 | (mapc #'disable-theme custom-enabled-themes) 44 | (pcase appearance 45 | ('light (load-theme 'tango t)) 46 | ('dark (load-theme 'tango-dark t)))) 47 | 48 | (add-hook 'ns-system-appearance-change-functions #'my/load-theme) 49 | 50 | The hook being run on each system appearance change as well as at 51 | startup time, Emacs should then always load the appropriate theme. 52 | --- 53 | src/frame.h | 1 + 54 | src/nsfns.m | 13 ++++- 55 | src/nsterm.m | 139 ++++++++++++++++++++++++++++++++++++++++++++++++--- 56 | 3 files changed, 143 insertions(+), 10 deletions(-) 57 | 58 | diff --git a/src/frame.h b/src/frame.h 59 | index a54b8623e5..46a7c34cb7 100644 60 | --- a/src/frame.h 61 | +++ b/src/frame.h 62 | @@ -70,6 +70,7 @@ #define EMACS_FRAME_H 63 | enum ns_appearance_type 64 | { 65 | ns_appearance_aqua, 66 | + ns_appearance_dark_aqua, 67 | ns_appearance_vibrant_dark 68 | }; 69 | #endif 70 | diff --git a/src/nsfns.m b/src/nsfns.m 71 | index 0f879fe390..5a4dd3a157 100644 72 | --- a/src/nsfns.m 73 | +++ b/src/nsfns.m 74 | @@ -1269,10 +1269,19 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. 75 | store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil); 76 | 77 | #ifdef NS_IMPL_COCOA 78 | +#ifndef NSAppKitVersionNumber10_14 79 | +#define NSAppKitVersionNumber10_14 1671 80 | +#endif 81 | tem = gui_display_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL, 82 | RES_TYPE_SYMBOL); 83 | - FRAME_NS_APPEARANCE (f) = EQ (tem, Qdark) 84 | - ? ns_appearance_vibrant_dark : ns_appearance_aqua; 85 | + 86 | + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) 87 | + FRAME_NS_APPEARANCE(f) = 88 | + EQ(tem, Qdark) ? ns_appearance_dark_aqua : ns_appearance_aqua; 89 | + else 90 | + FRAME_NS_APPEARANCE(f) = 91 | + EQ(tem, Qdark) ? ns_appearance_vibrant_dark : ns_appearance_aqua; 92 | + 93 | store_frame_param (f, Qns_appearance, tem); 94 | 95 | tem = gui_display_get_arg (dpyinfo, parms, Qns_transparent_titlebar, 96 | diff --git a/src/nsterm.m b/src/nsterm.m 97 | index 3dd915e370..6dddd01c90 100644 98 | --- a/src/nsterm.m 99 | +++ b/src/nsterm.m 100 | @@ -2027,16 +2027,35 @@ so some key presses (TAB) are swallowed by the system. */ 101 | 102 | if (EQ (new_value, Qdark)) 103 | { 104 | - window.appearance = [NSAppearance 105 | - appearanceNamed: NSAppearanceNameVibrantDark]; 106 | - FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark; 107 | +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 108 | +#ifndef NSAppKitVersionNumber10_14 109 | +#define NSAppKitVersionNumber10_14 1671 110 | +#endif 111 | + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) 112 | + { 113 | + window.appearance = [NSAppearance 114 | + appearanceNamed: NSAppearanceNameDarkAqua]; 115 | + FRAME_NS_APPEARANCE (f) = ns_appearance_dark_aqua; 116 | + } 117 | + else 118 | +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */ 119 | + { 120 | + window.appearance = [NSAppearance 121 | + appearanceNamed: NSAppearanceNameVibrantDark]; 122 | + FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark; 123 | + } 124 | } 125 | - else 126 | + else if (EQ (new_value, Qlight)) 127 | { 128 | window.appearance = [NSAppearance 129 | appearanceNamed: NSAppearanceNameAqua]; 130 | FRAME_NS_APPEARANCE (f) = ns_appearance_aqua; 131 | } 132 | + else 133 | + { 134 | + // Reset window appearance to track the system appearance. 135 | + window.appearance = nil; 136 | + } 137 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */ 138 | } 139 | 140 | @@ -5566,6 +5585,7 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes. 141 | 142 | ========================================================================== */ 143 | 144 | +static const void *kEmacsAppKVOContext = &kEmacsAppKVOContext; 145 | 146 | @implementation EmacsApp 147 | 148 | @@ -5811,6 +5831,18 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification 149 | object:nil]; 150 | #endif 151 | 152 | +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 153 | + [self addObserver:self 154 | + forKeyPath:NSStringFromSelector(@selector(effectiveAppearance)) 155 | + options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew 156 | + context:&kEmacsAppKVOContext]; 157 | + 158 | + pending_funcalls = Fcons(list3(Qrun_hook_with_args, 159 | + Qns_system_appearance_change_functions, 160 | + Vns_system_appearance), 161 | + pending_funcalls); 162 | +#endif 163 | + 164 | #ifdef NS_IMPL_COCOA 165 | /* Some functions/methods in CoreFoundation/Foundation increase the 166 | maximum number of open files for the process in their first call. 167 | @@ -5849,6 +5881,54 @@ - (void)antialiasThresholdDidChange:(NSNotification *)notification 168 | #endif 169 | } 170 | 171 | +- (void)observeValueForKeyPath:(NSString *)keyPath 172 | + ofObject:(id)object 173 | + change:(NSDictionary *)change 174 | + context:(void *)context 175 | +{ 176 | +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 177 | + if (context == kEmacsAppKVOContext 178 | + && object == self 179 | + && [keyPath isEqualToString: 180 | + NSStringFromSelector (@selector(effectiveAppearance))]) 181 | + [self systemAppearanceDidChange: 182 | + [change objectForKey:NSKeyValueChangeNewKey]]; 183 | + else 184 | +#endif /* (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */ 185 | + [super observeValueForKeyPath:keyPath 186 | + ofObject:object 187 | + change:change 188 | + context:context]; 189 | +} 190 | + 191 | +- (void)systemAppearanceDidChange:(NSAppearance *)newAppearance 192 | +{ 193 | +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 194 | +#ifndef NSAppKitVersionNumber10_14 195 | +#define NSAppKitVersionNumber10_14 1671 196 | +#endif 197 | + 198 | + if (NSAppKitVersionNumber < NSAppKitVersionNumber10_14) 199 | + return; 200 | + 201 | + NSAppearanceName appearance_name = 202 | + [newAppearance bestMatchFromAppearancesWithNames:@[ 203 | + NSAppearanceNameAqua, NSAppearanceNameDarkAqua 204 | + ]]; 205 | + 206 | + BOOL is_dark_appearance = 207 | + [appearance_name isEqualToString:NSAppearanceNameDarkAqua]; 208 | + Lisp_Object effective_appearance = is_dark_appearance ? Qdark : Qlight; 209 | + 210 | + Vns_system_appearance = effective_appearance; 211 | + 212 | + safe_call2 (Qrun_hook_with_args, 213 | + Qns_system_appearance_change_functions, 214 | + effective_appearance); 215 | + 216 | + Fredisplay(Qnil); 217 | +#endif /* (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */ 218 | +} 219 | 220 | /* Termination sequences: 221 | C-x C-c: 222 | @@ -6013,6 +6093,14 @@ - (void)applicationDidResignActive: (NSNotification *)notification 223 | ns_send_appdefined (-1); 224 | } 225 | 226 | +- (void)applicationWillTerminate:(NSNotification *)notification 227 | +{ 228 | + NSTRACE ("[EmacsApp applicationWillTerminate:]"); 229 | + 230 | + [self removeObserver:self 231 | + forKeyPath:NSStringFromSelector(@selector(effectiveAppearance)) 232 | + context:&kEmacsAppKVOContext]; 233 | +} 234 | 235 | 236 | /* ========================================================================== 237 | @@ -7492,12 +7580,27 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f 238 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 239 | #ifndef NSAppKitVersionNumber10_10 240 | #define NSAppKitVersionNumber10_10 1343 241 | +#endif 242 | +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 243 | +#ifndef NSAppKitVersionNumber10_14 244 | +#define NSAppKitVersionNumber10_14 1671 245 | #endif 246 | 247 | - if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_10 248 | - && FRAME_NS_APPEARANCE (f) != ns_appearance_aqua) 249 | - win.appearance = [NSAppearance 250 | - appearanceNamed: NSAppearanceNameVibrantDark]; 251 | + if (NSAppKitVersionNumber < NSAppKitVersionNumber10_14) 252 | +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */ 253 | + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_10) 254 | + { 255 | + if (FRAME_NS_APPEARANCE(f) != ns_appearance_aqua) 256 | + { 257 | + win.appearance = 258 | + [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; 259 | + } 260 | + else 261 | + { 262 | + win.appearance = 263 | + [NSAppearance appearanceNamed:NSAppearanceNameAqua]; 264 | + } 265 | + } 266 | #endif 267 | 268 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 269 | @@ -9606,6 +9709,26 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with 270 | This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */); 271 | ns_use_mwheel_momentum = YES; 272 | 273 | + DEFVAR_LISP ("ns-system-appearance", Vns_system_appearance, 274 | + doc: /* Current system appearance, i.e. `dark' or `light'. 275 | + 276 | +This variable is ignored on macOS < 10.14 and GNUstep. Default is nil. */); 277 | + Vns_system_appearance = Qnil; 278 | + DEFSYM(Qns_system_appearance, "ns-system-appearance"); 279 | + 280 | + DEFVAR_LISP ("ns-system-appearance-change-functions", 281 | + Vns_system_appearance_change_functions, 282 | + doc: /* List of functions to call when the system appearance changes. 283 | +Each function is called with a single argument, which corresponds to the new 284 | +system appearance (`dark' or `light'). 285 | + 286 | +This hook is also run once at startup, so that the initial system appearance 287 | +can be taken into account. 288 | + 289 | +This variable is ignored on macOS < 10.14 and GNUstep. Default is nil. */); 290 | + Vns_system_appearance_change_functions = Qnil; 291 | + DEFSYM(Qns_system_appearance_change_functions, "ns-system-appearance-change-functions"); 292 | + 293 | /* TODO: Move to common code. */ 294 | DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars, 295 | doc: /* SKIP: real doc in xterm.c. */); 296 | -- 297 | 2.29.2 298 | 299 | 300 | 301 | -------------------------------------------------------------------------------- /overlays/firefox/default.nix: -------------------------------------------------------------------------------- 1 | self: super: 2 | with super; 3 | { 4 | firefox = 5 | stdenv.mkDerivation rec { 6 | pname = "Firefox"; 7 | version = "82.0.3"; 8 | 9 | buildInputs = [ undmg ]; 10 | sourceRoot = "."; 11 | phases = [ "unpackPhase" "installPhase" ]; 12 | installPhase = '' 13 | mkdir -p "$out/Applications" 14 | cp -r Firefox.app "$out/Applications/Firefox.app" 15 | ''; 16 | 17 | src = fetchurl { 18 | name = "Firefox-${version}.dmg"; 19 | url = "https://download-installer.cdn.mozilla.net/pub/firefox/releases/${version}/mac/en-US/Firefox%20${version}.dmg"; 20 | sha256 = "10srb6pjy729zl71gsammp294kg531m3fgghd8lrw05pbm9lxxy1"; 21 | }; 22 | 23 | meta = with stdenv.lib; { 24 | description = "The Firefox web browser"; 25 | homepage = "https://www.mozilla.org/en-US/firefox"; 26 | maintainers = [ maintainers.cmacrae ]; 27 | platforms = platforms.darwin; 28 | }; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /overlays/solidity/default.nix: -------------------------------------------------------------------------------- 1 | self: super: 2 | with super; 3 | { 4 | solc = stdenv.mkDerivation rec { 5 | pname = "solc"; 6 | version = "0.8.0"; 7 | 8 | src = fetchurl { 9 | url = "https://github.com/ethereum/solidity/releases/download/v${version}/solc-macos"; 10 | sha256 = "0dak6b4fjqm31jcw78cnbf4g4zq5yvn48b8qzi897mid9m4gzhy7"; 11 | }; 12 | phases = ["installPhase" "patchPhase"]; 13 | installPhase = '' 14 | mkdir -p $out/bin 15 | cp $src $out/bin/solc 16 | chmod +x $out/bin/solc 17 | ''; 18 | }; 19 | } 20 | --------------------------------------------------------------------------------