mirror of
https://github.com/larstvei/nix-config.git
synced 2024-11-26 08:58:31 +00:00
Initial commit
Trying out nix on a new machine. I would think the install instructions are under-specified. We'll see if this will turn out usable.
This commit is contained in:
commit
746ea0f434
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "emacs"]
|
||||||
|
path = emacs
|
||||||
|
url = git@github.com:larstvei/dot-emacs.git
|
38
README.org
Normal file
38
README.org
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
* My macOS config
|
||||||
|
|
||||||
|
This repo contains a declarative specification of the setup of my mac, using
|
||||||
|
[[https://nixos.org/][Nix]], with [[https://github.com/LnL7/nix-darwin][nix-darwin]] and [[https://nixos.wiki/wiki/Flakes][Nix Flakes]]. The initial setup is mimicked after
|
||||||
|
[[https://github.com/shaunsingh/nix-darwin-dotfiles][shaunsingh's setup]]. [[https://brew.sh/][Homebrew]] is installed for its cask support (i.e. mac apps
|
||||||
|
lacking a Nix derivation).
|
||||||
|
|
||||||
|
* Steps to install
|
||||||
|
|
||||||
|
1. [[https://nixos.org/download.html#nix-install-macos][Install Nix for macOS]]
|
||||||
|
#+begin_src sh
|
||||||
|
sh <(curl -L https://nixos.org/nix/install)
|
||||||
|
#+end_src
|
||||||
|
2. [[https://brew.sh/][Install Homebrew]]
|
||||||
|
#+begin_src sh
|
||||||
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
|
#+end_src
|
||||||
|
3. Clone this repo (assuming there is no =~/.config= on the system already)
|
||||||
|
#+begin_src sh
|
||||||
|
git clone --recurse-submodules https://github.com/larstvei/dotfiles.git ~/.config
|
||||||
|
#+end_src
|
||||||
|
Note that the =--recurse-submodules= pulls down my [[https://github.com/larstvei/dot-emacs/][Emacs configuration]],
|
||||||
|
which is not necessary for the setup to work.
|
||||||
|
4. Build the setup from =flake.nix=
|
||||||
|
#+begin_src sh
|
||||||
|
cd ~/.config/
|
||||||
|
nix build .#darwinConfigurations.larstvei-macbookpro.system --extra-experimental-features nix-command --extra-experimental-features flakes
|
||||||
|
./result/sw/bin/darwin-rebuild switch --flake .#larstvei-macbookpro
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
* Maintaining
|
||||||
|
|
||||||
|
After making changes, I run the following command (from the =~/.config=
|
||||||
|
directory):
|
||||||
|
|
||||||
|
#+begin_src sh
|
||||||
|
darwin-rebuild switch --flake .#larstvei-macbookpro
|
||||||
|
#+end_src
|
1
emacs
Submodule
1
emacs
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 4bc7e9ac94e62062aaed57275099bfdfb699e66f
|
119
flake.lock
Normal file
119
flake.lock
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"darwin": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs-unstable"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1662478528,
|
||||||
|
"narHash": "sha256-Myjd0HPL5lXri3NXOcJ6gP7IKod2eMweQBKM4uxgEGw=",
|
||||||
|
"owner": "LnL7",
|
||||||
|
"repo": "nix-darwin",
|
||||||
|
"rev": "3b69bf3cc26ae19de847bfe54d6ab22d7381a90a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "LnL7",
|
||||||
|
"repo": "nix-darwin",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"emacs-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663433932,
|
||||||
|
"narHash": "sha256-JgoayvAG/dPrRVNlj3QGsmqHtKkaa+4UoLjlZP2Ndm0=",
|
||||||
|
"owner": "emacs-mirror",
|
||||||
|
"repo": "emacs",
|
||||||
|
"rev": "7fe22182d3abcb3124c50f717cc74925800b7720",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "emacs-mirror",
|
||||||
|
"repo": "emacs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"home-manager": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs-unstable"
|
||||||
|
],
|
||||||
|
"utils": "utils"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663328500,
|
||||||
|
"narHash": "sha256-7n+J/exp8ky4dmk02y5a9R7CGmJvHpzrHMzfEkMtSWA=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"rev": "5427f3d1f0ea4357cd4af0bffee7248d640c6ffc",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663314999,
|
||||||
|
"narHash": "sha256-G/vrVz+sw8xXICQdhsJcb26uxp5EarEfkSokvnPQX7A=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "0dfa3b283abc1cc2297653210f33585b390a6a50",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixpkgs-22.05-darwin",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-unstable": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663372752,
|
||||||
|
"narHash": "sha256-HxP/vZFDD/5Q9VEyX3VmsnCnm7vsH4IX6j/xE/+IVkc=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "d9a1414346059619d9e13ab93e749bbb82e5252a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"darwin": "darwin",
|
||||||
|
"emacs-src": "emacs-src",
|
||||||
|
"home-manager": "home-manager",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"nixpkgs-unstable": "nixpkgs-unstable"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1659877975,
|
||||||
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
82
flake.nix
Normal file
82
flake.nix
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
description = "Lars' MacBook Pro";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
|
||||||
|
nixpkgs = {
|
||||||
|
url = "github:nixos/nixpkgs/nixpkgs-22.05-darwin";
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs-unstable.url = github:NixOS/nixpkgs/nixpkgs-unstable;
|
||||||
|
|
||||||
|
# Nix-Darwin
|
||||||
|
darwin = {
|
||||||
|
url = "github:LnL7/nix-darwin";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
# HM-manager for dotfile/user management
|
||||||
|
home-manager = {
|
||||||
|
url = "github:nix-community/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
emacs-src = {
|
||||||
|
url = "github:emacs-mirror/emacs";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, darwin, home-manager, ... }@inputs: {
|
||||||
|
darwinConfigurations."larstvei-macbookpro" = darwin.lib.darwinSystem {
|
||||||
|
system = "aarch64-darwin";
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
./modules/mac.nix
|
||||||
|
home-manager.darwinModule
|
||||||
|
{
|
||||||
|
home-manager = {
|
||||||
|
useGlobalPkgs = true;
|
||||||
|
useUserPackages = true;
|
||||||
|
users.larstvei = {
|
||||||
|
imports = [
|
||||||
|
./modules/home.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
({ config, pkgs, lib, ... }: {
|
||||||
|
services.nix-daemon.enable = true;
|
||||||
|
|
||||||
|
nixpkgs = {
|
||||||
|
config.allpwUnfree = true;
|
||||||
|
overlays =
|
||||||
|
let
|
||||||
|
versionOf = input: input.rev;
|
||||||
|
in
|
||||||
|
with inputs; [
|
||||||
|
(final: prev: {
|
||||||
|
emacs-mac = (prev.emacs.override {
|
||||||
|
srcRepo = true;
|
||||||
|
nativeComp = true;
|
||||||
|
withSQLite3 = true;
|
||||||
|
withNS = true;
|
||||||
|
}).overrideAttrs (o: rec {
|
||||||
|
version = "29.0.50";
|
||||||
|
src = inputs.emacs-src;
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./patches/fix-window-role.patch
|
||||||
|
./patches/my-no-titlebar.patch
|
||||||
|
./patches/system-appearance.patch
|
||||||
|
];
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
69
modules/home.nix
Normal file
69
modules/home.nix
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{ pkgs, lib, config, home-manager, nix-darwin, inputs, ... }: {
|
||||||
|
|
||||||
|
# Can probably be removed when this is resolved:
|
||||||
|
# https://github.com/nix-community/home-manager/issues/1341
|
||||||
|
home.activation = {
|
||||||
|
copyApplications = let
|
||||||
|
apps = pkgs.buildEnv {
|
||||||
|
name = "home-manager-applications";
|
||||||
|
paths = config.home.packages;
|
||||||
|
pathsToLink = "/Applications";
|
||||||
|
};
|
||||||
|
in lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
|
baseDir="$HOME/Applications/Home Manager Apps"
|
||||||
|
if [ -d "$baseDir" ]; then
|
||||||
|
rm -rf "$baseDir"
|
||||||
|
fi
|
||||||
|
mkdir -p "$baseDir"
|
||||||
|
for appFile in ${apps}/Applications/*; do
|
||||||
|
target="$baseDir/$(basename "$appFile")"
|
||||||
|
$DRY_RUN_CMD cp ''${VERBOSE_ARG:+-v} -fHRL "$appFile" "$baseDir"
|
||||||
|
$DRY_RUN_CMD chmod ''${VERBOSE_ARG:+-v} -R +w "$target"
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
((emacsPackagesFor emacs-mac).emacsWithPackages
|
||||||
|
(epkgs: [
|
||||||
|
epkgs.vterm
|
||||||
|
epkgs.pdf-tools
|
||||||
|
]))
|
||||||
|
sqlite
|
||||||
|
htop
|
||||||
|
(aspellWithDicts (ds: with ds; [ en en-computers en-science ]))
|
||||||
|
fd
|
||||||
|
fzf
|
||||||
|
ripgrep
|
||||||
|
nixpkgs-fmt
|
||||||
|
tree
|
||||||
|
wget
|
||||||
|
];
|
||||||
|
|
||||||
|
home.file.".aspell.conf".text = "data-dir ${pkgs.aspell}/lib/aspell";
|
||||||
|
|
||||||
|
programs.fzf = {
|
||||||
|
enable = true;
|
||||||
|
enableFishIntegration = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
userName = "larstvei";
|
||||||
|
userEmail = "larstvei@ifi.uio.no";
|
||||||
|
ignores = [ ".dir-locals.el" ".envrc" ".DS_Store" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# This value determines the Home Manager release that your
|
||||||
|
# configuration is compatible with. This helps avoid breakage
|
||||||
|
# when a new Home Manager release introduces backwards
|
||||||
|
# incompatible changes.
|
||||||
|
#
|
||||||
|
# You can update Home Manager without changing this value. See
|
||||||
|
# the Home Manager release notes for a list of state version
|
||||||
|
# changes in each release.
|
||||||
|
home.stateVersion = "22.05";
|
||||||
|
|
||||||
|
# Let Home Manager install and manage itself.
|
||||||
|
programs.home-manager.enable = true;
|
||||||
|
}
|
70
modules/mac.nix
Normal file
70
modules/mac.nix
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
{ config, pkgs, lib, ... }: {
|
||||||
|
|
||||||
|
nix = {
|
||||||
|
package = pkgs.nix;
|
||||||
|
extraOptions = ''
|
||||||
|
system = aarch64-darwin # M1 gang
|
||||||
|
extra-platforms = aarch64-darwin x86_64-darwin # But we use rosetta too
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
build-users-group = nixbld
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
fonts = {
|
||||||
|
fontDir.enable = true;
|
||||||
|
fonts = with pkgs; [
|
||||||
|
fira
|
||||||
|
fira-code
|
||||||
|
roboto
|
||||||
|
roboto-mono
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.fish.enable = true;
|
||||||
|
system.activationScripts.postActivation.text = ''
|
||||||
|
# Set the default shell as fish for the user. MacOS doesn't do this like nixOS does
|
||||||
|
sudo chsh -s ${lib.getBin pkgs.fish}/bin/fish larstvei
|
||||||
|
'';
|
||||||
|
|
||||||
|
networking.hostName = "macbookpro";
|
||||||
|
system.stateVersion = 4;
|
||||||
|
|
||||||
|
system.keyboard = {
|
||||||
|
enableKeyMapping = true;
|
||||||
|
remapCapsLockToControl = true;
|
||||||
|
};
|
||||||
|
system.defaults = {
|
||||||
|
screencapture = { location = "/tmp"; };
|
||||||
|
dock = {
|
||||||
|
autohide = true;
|
||||||
|
showhidden = true;
|
||||||
|
mru-spaces = false;
|
||||||
|
};
|
||||||
|
finder = {
|
||||||
|
AppleShowAllExtensions = true;
|
||||||
|
QuitMenuItem = true;
|
||||||
|
FXEnableExtensionChangeWarning = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
NSGlobalDomain = {
|
||||||
|
AppleKeyboardUIMode = 3;
|
||||||
|
ApplePressAndHoldEnabled = false;
|
||||||
|
AppleFontSmoothing = 1;
|
||||||
|
_HIHideMenuBar = true;
|
||||||
|
InitialKeyRepeat = 15;
|
||||||
|
KeyRepeat = 1;
|
||||||
|
"com.apple.mouse.tapBehavior" = 1;
|
||||||
|
"com.apple.swipescrolldirection" = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
homebrew = {
|
||||||
|
enable = true;
|
||||||
|
onActivation.upgrade = true;
|
||||||
|
casks = [
|
||||||
|
"amethyst"
|
||||||
|
"raycast"
|
||||||
|
"iina"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
15
patches/fix-window-role.patch
Normal file
15
patches/fix-window-role.patch
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
|
index 6f9b208953..aa6c1d286f 100644
|
||||||
|
--- a/src/nsterm.m
|
||||||
|
+++ b/src/nsterm.m
|
||||||
|
@@ -8768,7 +8768,7 @@ - (id)accessibilityAttributeValue:(NSString *)attribute
|
||||||
|
NSTRACE ("[EmacsWindow accessibilityAttributeValue:]");
|
||||||
|
|
||||||
|
if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
|
||||||
|
- return NSAccessibilityTextFieldRole;
|
||||||
|
+ return NSAccessibilityWindowRole;
|
||||||
|
|
||||||
|
if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]
|
||||||
|
&& curbuf && ! NILP (BVAR (curbuf, mark_active)))
|
||||||
|
--
|
||||||
|
2.26.2
|
22
patches/my-no-titlebar.patch
Normal file
22
patches/my-no-titlebar.patch
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
|
index 44979c7c04e..eee75641f61 100644
|
||||||
|
--- a/src/nsterm.m
|
||||||
|
+++ b/src/nsterm.m
|
||||||
|
@@ -9021,7 +9021,7 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
|
||||||
|
else if (f->tooltip)
|
||||||
|
styleMask = 0;
|
||||||
|
else
|
||||||
|
- styleMask = (NSWindowStyleMaskTitled
|
||||||
|
+ styleMask = (NSWindowStyleMaskBorderless
|
||||||
|
| NSWindowStyleMaskResizable
|
||||||
|
| NSWindowStyleMaskMiniaturizable
|
||||||
|
| NSWindowStyleMaskClosable);
|
||||||
|
@@ -9098,7 +9098,7 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
|
||||||
|
[self setOpaque:NO];
|
||||||
|
|
||||||
|
/* toolbar support */
|
||||||
|
- [self createToolbar:f];
|
||||||
|
+ // [self createToolbar:f];
|
||||||
|
|
||||||
|
/* macOS Sierra automatically enables tabbed windows. We can't
|
||||||
|
allow this to be enabled until it's available on a Free system.
|
287
patches/nyxt-darwin-build.patch
Normal file
287
patches/nyxt-darwin-build.patch
Normal file
@ -0,0 +1,287 @@
|
|||||||
|
From 922bd3b630b6e232c1ccab17e70bd14ce84f172d Mon Sep 17 00:00:00 2001
|
||||||
|
From: midchildan <git@midchildan.org>
|
||||||
|
Date: Wed, 2 Jun 2021 02:30:44 +0900
|
||||||
|
Subject: [PATCH 1/2] nyxt: fix darwin build
|
||||||
|
|
||||||
|
Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com>
|
||||||
|
---
|
||||||
|
.../networking/browsers/nyxt/default.nix | 104 +++++++++++++-----
|
||||||
|
.../lisp-modules/lisp-packages.nix | 44 ++++++--
|
||||||
|
2 files changed, 107 insertions(+), 41 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pkgs/applications/networking/browsers/nyxt/default.nix b/pkgs/applications/networking/browsers/nyxt/default.nix
|
||||||
|
index 59bb2adbf5182..5af706a73d56c 100644
|
||||||
|
--- a/pkgs/applications/networking/browsers/nyxt/default.nix
|
||||||
|
+++ b/pkgs/applications/networking/browsers/nyxt/default.nix
|
||||||
|
@@ -1,9 +1,19 @@
|
||||||
|
-{ stdenv, lib, lispPackages
|
||||||
|
-, makeWrapper, wrapGAppsHook, gst_all_1
|
||||||
|
-, glib, gdk-pixbuf, cairo
|
||||||
|
-, mime-types, pango, gtk3
|
||||||
|
-, glib-networking, gsettings-desktop-schemas
|
||||||
|
-, xclip, notify-osd, enchant
|
||||||
|
+{ lib
|
||||||
|
+, stdenv
|
||||||
|
+, cairo
|
||||||
|
+, enchant
|
||||||
|
+, gdk-pixbuf
|
||||||
|
+, glib
|
||||||
|
+, glib-networking
|
||||||
|
+, gobject-introspection
|
||||||
|
+, gsettings-desktop-schemas
|
||||||
|
+, gtk3
|
||||||
|
+, gst_all_1
|
||||||
|
+, lispPackages
|
||||||
|
+, mime-types
|
||||||
|
+, pango
|
||||||
|
+, wrapGAppsHook
|
||||||
|
+, xclip
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
@@ -12,39 +22,75 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
|
src = lispPackages.nyxt;
|
||||||
|
|
||||||
|
- nativeBuildInputs = [ makeWrapper wrapGAppsHook ];
|
||||||
|
- gstBuildInputs = with gst_all_1; [
|
||||||
|
- gstreamer gst-libav
|
||||||
|
+ nativeBuildInputs = [ wrapGAppsHook ];
|
||||||
|
+ buildInputs = [
|
||||||
|
+ cairo
|
||||||
|
+ enchant
|
||||||
|
+ gdk-pixbuf
|
||||||
|
+ glib
|
||||||
|
+ glib-networking
|
||||||
|
+ gobject-introspection
|
||||||
|
+ gsettings-desktop-schemas
|
||||||
|
+ gtk3
|
||||||
|
+ mime-types
|
||||||
|
+ pango
|
||||||
|
+ ] ++ (with gst_all_1; [
|
||||||
|
+ gstreamer
|
||||||
|
+ gst-libav
|
||||||
|
gst-plugins-base
|
||||||
|
gst-plugins-good
|
||||||
|
gst-plugins-bad
|
||||||
|
gst-plugins-ugly
|
||||||
|
- ];
|
||||||
|
- buildInputs = [
|
||||||
|
- glib gdk-pixbuf cairo
|
||||||
|
- mime-types pango gtk3
|
||||||
|
- glib-networking gsettings-desktop-schemas
|
||||||
|
- xclip notify-osd enchant
|
||||||
|
- ] ++ gstBuildInputs;
|
||||||
|
+ ]);
|
||||||
|
|
||||||
|
- GST_PLUGIN_SYSTEM_PATH_1_0 = lib.concatMapStringsSep ":" (p: "${p}/lib/gstreamer-1.0") gstBuildInputs;
|
||||||
|
+ binPath = lib.optionals (!stdenv.isDarwin) [ xclip ];
|
||||||
|
|
||||||
|
+ doInstallCheck = !stdenv.isDarwin;
|
||||||
|
+ dontBuild = true;
|
||||||
|
dontWrapGApps = true;
|
||||||
|
+
|
||||||
|
+ # stripping breaks the Linux build, possibly because the resulting binary is
|
||||||
|
+ # already stripped once in lispPackages.nyxt
|
||||||
|
+ dontStrip = true;
|
||||||
|
+
|
||||||
|
installPhase = ''
|
||||||
|
- mkdir -p $out/share/applications/
|
||||||
|
- sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
|
||||||
|
- for i in 16 32 128 256 512; do
|
||||||
|
- mkdir -p "$out/share/icons/hicolor/''${i}x''${i}/apps/"
|
||||||
|
- cp -f $src/lib/common-lisp/nyxt/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
|
||||||
|
- done
|
||||||
|
-
|
||||||
|
- mkdir -p $out/bin && makeWrapper $src/bin/nyxt $out/bin/nyxt \
|
||||||
|
- --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "${GST_PLUGIN_SYSTEM_PATH_1_0}" \
|
||||||
|
- --argv0 nyxt "''${gappsWrapperArgs[@]}"
|
||||||
|
- '';
|
||||||
|
+ runHook preInstall
|
||||||
|
+ '' + (if stdenv.isDarwin then ''
|
||||||
|
+ mkdir -p $out/bin $out/Applications/Nyxt.app/Contents
|
||||||
|
+ pushd $out/Applications/Nyxt.app/Contents
|
||||||
|
+ install -Dm644 $src/lib/common-lisp/nyxt/assets/Info.plist Info.plist
|
||||||
|
+ install -Dm644 $src/lib/common-lisp/nyxt/assets/nyxt.icns Resources/nyxt.icns
|
||||||
|
+ install -Dm755 $src/bin/nyxt MacOS/nyxt
|
||||||
|
+ popd
|
||||||
|
+
|
||||||
|
+ gappsWrapperArgsHook # FIXME: currently runs at preFixup
|
||||||
|
+ wrapGApp $out/Applications/Nyxt.app/Contents/MacOS/nyxt \
|
||||||
|
+ --prefix PATH : "${lib.makeBinPath binPath}" \
|
||||||
|
+ --argv0 nyxt
|
||||||
|
+
|
||||||
|
+ ln -s $out/Applications/Nyxt.app/Contents/MacOS/nyxt $out/bin/nyxt
|
||||||
|
+ '' else ''
|
||||||
|
+ mkdir -p $out/share/applications/
|
||||||
|
+ sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
|
||||||
|
+ for i in 16 32 128 256 512; do
|
||||||
|
+ mkdir -p "$out/share/icons/hicolor/''${i}x''${i}/apps/"
|
||||||
|
+ cp -f $src/lib/common-lisp/nyxt/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
|
||||||
|
+ done
|
||||||
|
+
|
||||||
|
+ install -Dm755 $src/bin/nyxt $out/bin/nyxt
|
||||||
|
+
|
||||||
|
+ gappsWrapperArgsHook # FIXME: currently runs at preFixup
|
||||||
|
+ wrapGApp $out/bin/nyxt \
|
||||||
|
+ --prefix PATH : "${lib.makeBinPath binPath}" \
|
||||||
|
+ --argv0 nyxt
|
||||||
|
+ '') + ''
|
||||||
|
+ runHook postInstall
|
||||||
|
+ '';
|
||||||
|
|
||||||
|
- checkPhase = ''
|
||||||
|
+ installCheckPhase = ''
|
||||||
|
+ runHook preCheck
|
||||||
|
$out/bin/nyxt -h
|
||||||
|
+ runHook postCheck
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
diff --git a/pkgs/development/lisp-modules/lisp-packages.nix b/pkgs/development/lisp-modules/lisp-packages.nix
|
||||||
|
index e4f623686a9af..74ae5a05b575d 100644
|
||||||
|
--- a/pkgs/development/lisp-modules/lisp-packages.nix
|
||||||
|
+++ b/pkgs/development/lisp-modules/lisp-packages.nix
|
||||||
|
@@ -129,22 +129,42 @@ let lispPackages = rec {
|
||||||
|
description = "Browser";
|
||||||
|
|
||||||
|
overrides = x: {
|
||||||
|
+ patches = [
|
||||||
|
+ # Fixes a startup crash on Darwin
|
||||||
|
+ # https://github.com/atlas-engineer/nyxt/pull/1476
|
||||||
|
+ (pkgs.fetchpatch {
|
||||||
|
+ url = "https://github.com/midchildan/nyxt/commit/6184884b48b7cacdc51d104cb2299c26437a73d8.diff";
|
||||||
|
+ sha256 = "sha256-A8Hwfjn/B5fv8OTKM5i9YrNFAMbPAg9xRH7gwoMMlQs=";
|
||||||
|
+ })
|
||||||
|
+
|
||||||
|
+ # Fix list-buffers
|
||||||
|
+ (pkgs.fetchpatch {
|
||||||
|
+ url = "https://github.com/atlas-engineer/nyxt/commit/4e2efb5a456d8d647f3eeaeb52cb21f96c92471c.diff";
|
||||||
|
+ sha256 = "sha256-xt+jXZlTktznAoEWsaO5uQywo+bR9PecgTKOjY7UNvY=";
|
||||||
|
+ })
|
||||||
|
+
|
||||||
|
+ # Fix non-functional "Update" button in the buffer list
|
||||||
|
+ # https://github.com/atlas-engineer/nyxt/pull/1484
|
||||||
|
+ (pkgs.fetchpatch {
|
||||||
|
+ url = "https://github.com/midchildan/nyxt/commit/7589181d6e367442bad8011f0ef5b42fc1cfd3c5.diff";
|
||||||
|
+ sha256 = "sha256-4uXm7yxkhcArk39JBealGr1N4r/8AM5v/1VYHw1y4hw=";
|
||||||
|
+ })
|
||||||
|
+ ];
|
||||||
|
+
|
||||||
|
postInstall = ''
|
||||||
|
echo "Building nyxt binary"
|
||||||
|
- (
|
||||||
|
- source "$out/lib/common-lisp-settings"/*-shell-config.sh
|
||||||
|
- cd "$out/lib/common-lisp"/*/
|
||||||
|
- makeFlags="''${makeFlags:-}"
|
||||||
|
- make LISP=common-lisp.sh NYXT_INTERNAL_QUICKLISP=false PREFIX="$out" $makeFlags all
|
||||||
|
- make LISP=common-lisp.sh NYXT_INTERNAL_QUICKLISP=false PREFIX="$out" $makeFlags install
|
||||||
|
- cp nyxt "$out/bin/nyxt"
|
||||||
|
- )
|
||||||
|
+
|
||||||
|
+ # clear unnecessary environment variables to avoid hitting the limit
|
||||||
|
+ env -i \
|
||||||
|
+ NIX_LISP="$NIX_LISP" \
|
||||||
|
NIX_LISP_PRELAUNCH_HOOK='
|
||||||
|
- nix_lisp_build_system nyxt/gtk-application \
|
||||||
|
- "(asdf/system:component-entry-point (asdf:find-system :nyxt/gtk-application))" \
|
||||||
|
- "" "(format *error-output* \"Alien objects:~%~s~%\" sb-alien::*shared-objects*)"
|
||||||
|
+ nix_lisp_build_system nyxt/gi-gtk-application \
|
||||||
|
+ "(asdf/system:component-entry-point (asdf:find-system :nyxt/gi-gtk-application))" \
|
||||||
|
+ "" \
|
||||||
|
+ "(format *error-output* \"Alien objects:~%~s~%\" sb-alien::*shared-objects*)"
|
||||||
|
' "$out/bin/nyxt-lisp-launcher.sh"
|
||||||
|
- cp "$out/lib/common-lisp/nyxt/nyxt" "$out/bin/"
|
||||||
|
+
|
||||||
|
+ mv "$out/lib/common-lisp/nyxt/nyxt" "$out/bin/"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
From c6598c61e74135b3b3848da46af62f0ee59ce9aa Mon Sep 17 00:00:00 2001
|
||||||
|
From: midchildan <git@midchildan.org>
|
||||||
|
Date: Tue, 8 Jun 2021 03:30:00 +0900
|
||||||
|
Subject: [PATCH 2/2] lispPackages.nyxt-unwrapped: rename from
|
||||||
|
lispPackages.nyxt
|
||||||
|
|
||||||
|
---
|
||||||
|
.../networking/browsers/nyxt/default.nix | 12 ++++++------
|
||||||
|
pkgs/development/lisp-modules/lisp-packages.nix | 11 +++++++----
|
||||||
|
2 files changed, 13 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pkgs/applications/networking/browsers/nyxt/default.nix b/pkgs/applications/networking/browsers/nyxt/default.nix
|
||||||
|
index 5af706a73d56c..6b00e54794728 100644
|
||||||
|
--- a/pkgs/applications/networking/browsers/nyxt/default.nix
|
||||||
|
+++ b/pkgs/applications/networking/browsers/nyxt/default.nix
|
||||||
|
@@ -18,9 +18,9 @@
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "nyxt";
|
||||||
|
- inherit (lispPackages.nyxt.meta) version;
|
||||||
|
+ inherit (lispPackages.nyxt-unwrapped.meta) version;
|
||||||
|
|
||||||
|
- src = lispPackages.nyxt;
|
||||||
|
+ src = lispPackages.nyxt-unwrapped;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ wrapGAppsHook ];
|
||||||
|
buildInputs = [
|
||||||
|
@@ -58,8 +58,8 @@ stdenv.mkDerivation rec {
|
||||||
|
'' + (if stdenv.isDarwin then ''
|
||||||
|
mkdir -p $out/bin $out/Applications/Nyxt.app/Contents
|
||||||
|
pushd $out/Applications/Nyxt.app/Contents
|
||||||
|
- install -Dm644 $src/lib/common-lisp/nyxt/assets/Info.plist Info.plist
|
||||||
|
- install -Dm644 $src/lib/common-lisp/nyxt/assets/nyxt.icns Resources/nyxt.icns
|
||||||
|
+ install -Dm644 $src/lib/common-lisp/nyxt-unwrapped/assets/Info.plist Info.plist
|
||||||
|
+ install -Dm644 $src/lib/common-lisp/nyxt-unwrapped/assets/nyxt.icns Resources/nyxt.icns
|
||||||
|
install -Dm755 $src/bin/nyxt MacOS/nyxt
|
||||||
|
popd
|
||||||
|
|
||||||
|
@@ -71,10 +71,10 @@ stdenv.mkDerivation rec {
|
||||||
|
ln -s $out/Applications/Nyxt.app/Contents/MacOS/nyxt $out/bin/nyxt
|
||||||
|
'' else ''
|
||||||
|
mkdir -p $out/share/applications/
|
||||||
|
- sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
|
||||||
|
+ sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt-unwrapped/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
|
||||||
|
for i in 16 32 128 256 512; do
|
||||||
|
mkdir -p "$out/share/icons/hicolor/''${i}x''${i}/apps/"
|
||||||
|
- cp -f $src/lib/common-lisp/nyxt/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
|
||||||
|
+ cp -f $src/lib/common-lisp/nyxt-unwrapped/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
|
||||||
|
done
|
||||||
|
|
||||||
|
install -Dm755 $src/bin/nyxt $out/bin/nyxt
|
||||||
|
diff --git a/pkgs/development/lisp-modules/lisp-packages.nix b/pkgs/development/lisp-modules/lisp-packages.nix
|
||||||
|
index 74ae5a05b575d..10eb880fe663a 100644
|
||||||
|
--- a/pkgs/development/lisp-modules/lisp-packages.nix
|
||||||
|
+++ b/pkgs/development/lisp-modules/lisp-packages.nix
|
||||||
|
@@ -122,8 +122,8 @@ let lispPackages = rec {
|
||||||
|
|
||||||
|
asdFilesToKeep = [ "cluffer.asd" "cluffer-base.asd" "cluffer-simple-buffer.asd" "cluffer-simple-line.asd" "cluffer-standard-buffer.asd" "cluffer-standard-line.asd" ];
|
||||||
|
};
|
||||||
|
- nyxt = pkgs.lispPackages.buildLispPackage rec {
|
||||||
|
- baseName = "nyxt";
|
||||||
|
+ nyxt-unwrapped = pkgs.lispPackages.buildLispPackage rec {
|
||||||
|
+ baseName = "nyxt-unwrapped";
|
||||||
|
version = "2.0.0";
|
||||||
|
|
||||||
|
description = "Browser";
|
||||||
|
@@ -162,9 +162,9 @@ let lispPackages = rec {
|
||||||
|
"(asdf/system:component-entry-point (asdf:find-system :nyxt/gi-gtk-application))" \
|
||||||
|
"" \
|
||||||
|
"(format *error-output* \"Alien objects:~%~s~%\" sb-alien::*shared-objects*)"
|
||||||
|
- ' "$out/bin/nyxt-lisp-launcher.sh"
|
||||||
|
+ ' "$out/bin/${baseName}-lisp-launcher.sh"
|
||||||
|
|
||||||
|
- mv "$out/lib/common-lisp/nyxt/nyxt" "$out/bin/"
|
||||||
|
+ mv "$out/lib/common-lisp/${baseName}/nyxt" "$out/bin/"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -225,5 +225,8 @@ let lispPackages = rec {
|
||||||
|
pkgs.sbcl
|
||||||
|
];
|
||||||
|
};
|
||||||
|
+
|
||||||
|
+ # added 2021-06-14
|
||||||
|
+ nyxt = throw "lispPackages.nyxt was renamed to lispPackages.nyxt-unwrapped";
|
||||||
|
};
|
||||||
|
in lispPackages
|
316
patches/system-appearance.patch
Normal file
316
patches/system-appearance.patch
Normal file
@ -0,0 +1,316 @@
|
|||||||
|
|
||||||
|
Patch to make emacs 28 aware of the macOS 10.14+ system appearance changes.
|
||||||
|
|
||||||
|
From 6e73cd55ebfd3b0967357b3c3ead16d2f8539526 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Nicolas G. Querol" <nicolas.gquerol@gmail.com>
|
||||||
|
Date: Wed, 11 Nov 2020 12:35:47 +0100
|
||||||
|
Subject: [PATCH] Add `ns-system-appearance-change-functions' hook
|
||||||
|
|
||||||
|
This implements a new hook, effective only on macOS >= 10.14 (Mojave),
|
||||||
|
that is called when the system changes its appearance (e.g. from light
|
||||||
|
to dark). Users can then implement functions that take this change
|
||||||
|
into account, for instance to load a particular theme.
|
||||||
|
|
||||||
|
Minor changes are also made to select the right "dark" appearance
|
||||||
|
(NSAppearanceNameDarkAqua) on macOS versions >= 10.14, the previous one
|
||||||
|
(NSAppearanceNameVibrantDark) being deprecated.
|
||||||
|
|
||||||
|
* src/frame.h (enum ns_appearance_type): Add new
|
||||||
|
"ns_appearance_dark_aqua" case.
|
||||||
|
|
||||||
|
* src/nsfns.m (defun x-create-frame): Use "dark aqua" appearance on
|
||||||
|
macOS >= 10.14.
|
||||||
|
|
||||||
|
* src/nsterm.m:
|
||||||
|
- (ns_set_appearance): Use "dark aqua" appearance on
|
||||||
|
macOS >= 10.14, reset appearance to the system one
|
||||||
|
if `ns-appearance' frame parameter is not set to
|
||||||
|
either `dark' or `light'.
|
||||||
|
- (initFrameFromEmacs): Use "dark aqua" appearance on
|
||||||
|
macOS >= 10.14.
|
||||||
|
- (EmacsApp) Add the `systemDidChangeAppearance' private method,
|
||||||
|
as well as the appropriate Key-Value Observing calls to update
|
||||||
|
the frame's appearance when the system (and thus the app's)
|
||||||
|
appearance changes.
|
||||||
|
- Add `ns-system-appearance-change-functions' hook variable and
|
||||||
|
symbol, to allow users to add functions that react to the
|
||||||
|
change of the system's appearance.
|
||||||
|
- Add `ns-system-appearance' variable, to allow users to consult
|
||||||
|
the current system appearance.
|
||||||
|
|
||||||
|
Here is an example on how to use this new feature:
|
||||||
|
|
||||||
|
(defun my/load-theme (appearance)
|
||||||
|
"Load theme, taking current system APPEARANCE into consideration."
|
||||||
|
(mapc #'disable-theme custom-enabled-themes)
|
||||||
|
(pcase appearance
|
||||||
|
('light (load-theme 'tango t))
|
||||||
|
('dark (load-theme 'tango-dark t))))
|
||||||
|
|
||||||
|
(add-hook 'ns-system-appearance-change-functions #'my/load-theme)
|
||||||
|
|
||||||
|
The hook being run on each system appearance change as well as at
|
||||||
|
startup time, Emacs should then always load the appropriate theme.
|
||||||
|
---
|
||||||
|
src/frame.h | 3 +-
|
||||||
|
src/nsfns.m | 13 ++++-
|
||||||
|
src/nsterm.m | 153 ++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||||
|
3 files changed, 153 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/frame.h b/src/frame.h
|
||||||
|
index a8ad011889..e7f7fdafe1 100644
|
||||||
|
--- a/src/frame.h
|
||||||
|
+++ b/src/frame.h
|
||||||
|
@@ -71,7 +71,8 @@ #define EMACS_FRAME_H
|
||||||
|
{
|
||||||
|
ns_appearance_system_default,
|
||||||
|
ns_appearance_aqua,
|
||||||
|
- ns_appearance_vibrant_dark
|
||||||
|
+ ns_appearance_vibrant_dark,
|
||||||
|
+ ns_appearance_dark_aqua
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
#endif /* HAVE_WINDOW_SYSTEM */
|
||||||
|
diff --git a/src/nsfns.m b/src/nsfns.m
|
||||||
|
index 07bcab1816..4766eb91ae 100644
|
||||||
|
--- a/src/nsfns.m
|
||||||
|
+++ b/src/nsfns.m
|
||||||
|
@@ -1256,14 +1256,25 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil);
|
||||||
|
|
||||||
|
#ifdef NS_IMPL_COCOA
|
||||||
|
+#ifndef NSAppKitVersionNumber10_14
|
||||||
|
+#define NSAppKitVersionNumber10_14 1671
|
||||||
|
+#endif
|
||||||
|
tem = gui_display_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL,
|
||||||
|
RES_TYPE_SYMBOL);
|
||||||
|
if (EQ (tem, Qdark))
|
||||||
|
- FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark;
|
||||||
|
+ if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14)
|
||||||
|
+ {
|
||||||
|
+ FRAME_NS_APPEARANCE (f) = ns_appearance_dark_aqua;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark;
|
||||||
|
+ }
|
||||||
|
else if (EQ (tem, Qlight))
|
||||||
|
FRAME_NS_APPEARANCE (f) = ns_appearance_aqua;
|
||||||
|
else
|
||||||
|
FRAME_NS_APPEARANCE (f) = ns_appearance_system_default;
|
||||||
|
+
|
||||||
|
store_frame_param (f, Qns_appearance,
|
||||||
|
(!NILP (tem) && !EQ (tem, Qunbound)) ? tem : Qnil);
|
||||||
|
|
||||||
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
|
index 4bdc67c10b..0d2f3e0b2b 100644
|
||||||
|
--- a/src/nsterm.m
|
||||||
|
+++ b/src/nsterm.m
|
||||||
|
@@ -1889,11 +1889,25 @@ Hide the window (X11 semantics)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (EQ (new_value, Qdark))
|
||||||
|
- FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark;
|
||||||
|
- else if (EQ (new_value, Qlight))
|
||||||
|
- FRAME_NS_APPEARANCE (f) = ns_appearance_aqua;
|
||||||
|
+ {
|
||||||
|
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||||
|
+#ifndef NSAppKitVersionNumber10_14
|
||||||
|
+#define NSAppKitVersionNumber10_14 1671
|
||||||
|
+#endif
|
||||||
|
+ if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14)
|
||||||
|
+ FRAME_NS_APPEARANCE(f) = ns_appearance_dark_aqua;
|
||||||
|
+ else
|
||||||
|
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */
|
||||||
|
+ FRAME_NS_APPEARANCE(f) = ns_appearance_vibrant_dark;
|
||||||
|
+ }
|
||||||
|
+ else if (EQ(new_value, Qlight))
|
||||||
|
+ {
|
||||||
|
+ FRAME_NS_APPEARANCE (f) = ns_appearance_aqua;
|
||||||
|
+ }
|
||||||
|
else
|
||||||
|
- FRAME_NS_APPEARANCE (f) = ns_appearance_system_default;
|
||||||
|
+ {
|
||||||
|
+ FRAME_NS_APPEARANCE (f) = ns_appearance_system_default;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
[window setAppearance];
|
||||||
|
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */
|
||||||
|
@@ -5381,6 +5395,7 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
|
||||||
|
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
+static const void *kEmacsAppKVOContext = &kEmacsAppKVOContext;
|
||||||
|
|
||||||
|
@implementation EmacsApp
|
||||||
|
|
||||||
|
@@ -5626,6 +5641,18 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
|
||||||
|
object:nil];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||||
|
+ [self addObserver:self
|
||||||
|
+ forKeyPath:NSStringFromSelector(@selector(effectiveAppearance))
|
||||||
|
+ options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew
|
||||||
|
+ context:&kEmacsAppKVOContext];
|
||||||
|
+
|
||||||
|
+ pending_funcalls = Fcons(list3(Qrun_hook_with_args,
|
||||||
|
+ Qns_system_appearance_change_functions,
|
||||||
|
+ Vns_system_appearance),
|
||||||
|
+ pending_funcalls);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#ifdef NS_IMPL_COCOA
|
||||||
|
/* Some functions/methods in CoreFoundation/Foundation increase the
|
||||||
|
maximum number of open files for the process in their first call.
|
||||||
|
@@ -5664,6 +5691,68 @@ - (void)antialiasThresholdDidChange:(NSNotification *)notification
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||||
|
+ ofObject:(id)object
|
||||||
|
+ change:(NSDictionary *)change
|
||||||
|
+ context:(void *)context
|
||||||
|
+{
|
||||||
|
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||||
|
+ if (context == kEmacsAppKVOContext
|
||||||
|
+ && object == self
|
||||||
|
+ && [keyPath isEqualToString:
|
||||||
|
+ NSStringFromSelector (@selector(effectiveAppearance))])
|
||||||
|
+ [self systemAppearanceDidChange:
|
||||||
|
+ [change objectForKey:NSKeyValueChangeNewKey]];
|
||||||
|
+ else
|
||||||
|
+#endif /* (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */
|
||||||
|
+ [super observeValueForKeyPath:keyPath
|
||||||
|
+ ofObject:object
|
||||||
|
+ change:change
|
||||||
|
+ context:context];
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||||
|
+#ifndef NSAppKitVersionNumber10_14
|
||||||
|
+#define NSAppKitVersionNumber10_14 1671
|
||||||
|
+#endif
|
||||||
|
+- (void)systemAppearanceDidChange:(NSAppearance *)newAppearance
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ if (NSAppKitVersionNumber < NSAppKitVersionNumber10_14)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ NSAppearanceName appearance_name =
|
||||||
|
+ [newAppearance bestMatchFromAppearancesWithNames:@[
|
||||||
|
+ NSAppearanceNameAqua, NSAppearanceNameDarkAqua
|
||||||
|
+ ]];
|
||||||
|
+
|
||||||
|
+ BOOL is_dark_appearance =
|
||||||
|
+ [appearance_name isEqualToString:NSAppearanceNameDarkAqua];
|
||||||
|
+ Vns_system_appearance = is_dark_appearance ? Qdark : Qlight;
|
||||||
|
+
|
||||||
|
+ run_system_appearance_change_hook ();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline void run_system_appearance_change_hook (void)
|
||||||
|
+{
|
||||||
|
+ if (NILP (Vns_system_appearance_change_functions))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ block_input ();
|
||||||
|
+
|
||||||
|
+ bool owfi = waiting_for_input;
|
||||||
|
+ waiting_for_input = false;
|
||||||
|
+
|
||||||
|
+ safe_call2 (Qrun_hook_with_args,
|
||||||
|
+ Qns_system_appearance_change_functions,
|
||||||
|
+ Vns_system_appearance);
|
||||||
|
+ Fredisplay(Qt);
|
||||||
|
+
|
||||||
|
+ waiting_for_input = owfi;
|
||||||
|
+
|
||||||
|
+ unblock_input ();
|
||||||
|
+}
|
||||||
|
+#endif /* (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */
|
||||||
|
|
||||||
|
/* Termination sequences:
|
||||||
|
C-x C-c:
|
||||||
|
@@ -5828,6 +5917,14 @@ - (void)applicationDidResignActive: (NSNotification *)notification
|
||||||
|
ns_send_appdefined (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
+- (void)applicationWillTerminate:(NSNotification *)notification
|
||||||
|
+{
|
||||||
|
+ NSTRACE ("[EmacsApp applicationWillTerminate:]");
|
||||||
|
+
|
||||||
|
+ [self removeObserver:self
|
||||||
|
+ forKeyPath:NSStringFromSelector(@selector(effectiveAppearance))
|
||||||
|
+ context:&kEmacsAppKVOContext];
|
||||||
|
+}
|
||||||
|
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
@@ -8805,17 +8902,26 @@ - (void)setAppearance
|
||||||
|
#define NSAppKitVersionNumber10_10 1343
|
||||||
|
#endif
|
||||||
|
|
||||||
|
- if (NSAppKitVersionNumber < NSAppKitVersionNumber10_10)
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- if (FRAME_NS_APPEARANCE (f) == ns_appearance_vibrant_dark)
|
||||||
|
- appearance =
|
||||||
|
- [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
|
||||||
|
- else if (FRAME_NS_APPEARANCE (f) == ns_appearance_aqua)
|
||||||
|
- appearance =
|
||||||
|
- [NSAppearance appearanceNamed:NSAppearanceNameAqua];
|
||||||
|
+ if (NSAppKitVersionNumber < NSAppKitVersionNumber10_10)
|
||||||
|
+ return;
|
||||||
|
|
||||||
|
- [self setAppearance:appearance];
|
||||||
|
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||||
|
+#ifndef NSAppKitVersionNumber10_14
|
||||||
|
+#define NSAppKitVersionNumber10_14 1671
|
||||||
|
+#endif
|
||||||
|
+ if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14
|
||||||
|
+ && FRAME_NS_APPEARANCE(f) == ns_appearance_dark_aqua)
|
||||||
|
+ appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
|
||||||
|
+ else
|
||||||
|
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 */
|
||||||
|
+ if (FRAME_NS_APPEARANCE(f) == ns_appearance_vibrant_dark)
|
||||||
|
+ appearance =
|
||||||
|
+ [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
|
||||||
|
+ else if (FRAME_NS_APPEARANCE (f) == ns_appearance_aqua)
|
||||||
|
+ appearance =
|
||||||
|
+ [NSAppearance appearanceNamed:NSAppearanceNameAqua];
|
||||||
|
+
|
||||||
|
+ [self setAppearance:appearance];
|
||||||
|
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -9952,6 +10058,25 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with
|
||||||
|
This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */);
|
||||||
|
ns_use_mwheel_momentum = YES;
|
||||||
|
|
||||||
|
+ DEFVAR_LISP ("ns-system-appearance", Vns_system_appearance,
|
||||||
|
+ doc: /* Current system appearance, i.e. `dark' or `light'.
|
||||||
|
+
|
||||||
|
+This variable is ignored on macOS < 10.14 and GNUstep. Default is nil. */);
|
||||||
|
+ Vns_system_appearance = Qnil;
|
||||||
|
+ DEFSYM(Qns_system_appearance, "ns-system-appearance");
|
||||||
|
+
|
||||||
|
+ DEFVAR_LISP ("ns-system-appearance-change-functions",
|
||||||
|
+ Vns_system_appearance_change_functions,
|
||||||
|
+ doc: /* List of functions to call when the system appearance changes.
|
||||||
|
+Each function is called with a single argument, which corresponds to the new
|
||||||
|
+system appearance (`dark' or `light').
|
||||||
|
+
|
||||||
|
+This hook is also run once at startup.
|
||||||
|
+
|
||||||
|
+This variable is ignored on macOS < 10.14 and GNUstep. Default is nil. */);
|
||||||
|
+ Vns_system_appearance_change_functions = Qnil;
|
||||||
|
+ DEFSYM(Qns_system_appearance_change_functions, "ns-system-appearance-change-functions");
|
||||||
|
+
|
||||||
|
/* TODO: Move to common code. */
|
||||||
|
DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
|
||||||
|
doc: /* SKIP: real doc in xterm.c. */);
|
||||||
|
|
||||||
|
base-commit: e5c481b61c26bcf83779db9fb3ac6b96bc50ab2e
|
||||||
|
--
|
||||||
|
2.33.0
|
Loading…
Reference in New Issue
Block a user