diff options
Diffstat (limited to 'users/wpcarro/emacs')
-rw-r--r-- | users/wpcarro/emacs/AppIcon.icns | bin | 0 -> 449758 bytes | |||
-rw-r--r-- | users/wpcarro/emacs/default.nix | 80 |
2 files changed, 66 insertions, 14 deletions
diff --git a/users/wpcarro/emacs/AppIcon.icns b/users/wpcarro/emacs/AppIcon.icns new file mode 100644 index 000000000000..b3be251ccf8e --- /dev/null +++ b/users/wpcarro/emacs/AppIcon.icns Binary files differdiff --git a/users/wpcarro/emacs/default.nix b/users/wpcarro/emacs/default.nix index 4ba737d75282..3af7d2648cc8 100644 --- a/users/wpcarro/emacs/default.nix +++ b/users/wpcarro/emacs/default.nix @@ -3,7 +3,7 @@ # - Darwin # # USAGE: -# $ mg build //users/wpcarro/emacs:osx +# $ nix-build -A users.wpcarro.emacs.osx -o /Applications/BillsEmacs.app { depot, pkgs, lib, ... }: # TODO(wpcarro): See if it's possible to expose emacsclient on PATH, so that I @@ -32,10 +32,10 @@ let rust-analyzer rustc rustfmt + xorg.xset ] ++ (if pkgs.stdenv.isLinux then [ scrot - xorg.xset ] else [ ])) ); @@ -174,25 +174,75 @@ let ${concatStringsSep "\n " (map (el: "--load ${el} \\") load)} "$@" ''; + + # I can't figure out how to augment LSEnvironment.PATH such that it inherits + # the default $PATH and adds the things that I need as well, so let's + # hardcode the desired outcome in the meantime. + osxDefaultPath = builtins.concatStringsSep ":" [ + "/Users/bill/.nix-profile/bin" + "/nix/var/nix/profiles/default/bin" + "/opt/homebrew/bin" + "/opt/homebrew/sbin" + "/usr/local/bin" + "/usr/bin" + "/bin" + "/usr/sbin" + "/sbin" + "/opt/X11/bin" + ]; + + infoPlist = pkgs.writeText "Info.plist" (pkgs.lib.generators.toPlist { } { + LSEnvironment = { + PATH = "${emacsBinPath}:${osxDefaultPath}"; + }; + CFBundleExecutable = "BillsEmacs"; + CFBundleDisplayName = "BillsEmacs"; + CFBundleIconFile = "AppIcon"; + CFBundleIconName = "AppIcon"; + }); + + versionPlist = pkgs.writeText "version.plist" (pkgs.lib.generators.toPlist { } { + ProjectName = "OSXPlatformSupport"; + }); in -depot.nix.readTree.drvTargets { +{ # TODO(wpcarro): Support this with base.overrideAttrs or something similar. nixos = { load ? [ ] }: withEmacsPath { inherit load; emacsBin = "${wpcarrosEmacs}/bin/emacs"; }; - osx = writeShellScriptBin "wpcarros-emacs" '' - export PATH="${emacsBinPath}:$PATH" - export EMACSLOADPATH="${loadPath}" - exec ${wpcarrosEmacs}/bin/emacs \ - --debug-init \ - --no-init-file \ - --no-site-file \ - --no-site-lisp \ - --load ${./.emacs.d/init.el} \ - "$@" - ''; + # To install GUI: + # $ nix-build -A users.wpcarro.emacs.osx -o /Applications/BillsEmacs.app + osx = pkgs.stdenv.mkDerivation { + pname = "bills-emacs"; + version = "0.0.1"; + src = ./.; + dontFixup = true; + installPhase = '' + runHook preInstall + APP="$out" + mkdir -p "$APP/Contents/MacOS" + mkdir -p "$APP/Contents/Resources" + cp ${infoPlist} "$APP/Contents/Info.plist" + cp ${versionPlist} "$APP/Contents/version.plist" + cp ${./AppIcon.icns} "$APP/Contents/Resources/AppIcon.icns" + echo "APPL????" > "$APP/Contents/PkgInfo" + cat << EOF > "$APP/Contents/MacOS/BillsEmacs" + #!${pkgs.stdenvNoCC.shell} + export EMACSLOADPATH="${loadPath}" + exec ${wpcarrosEmacs}/bin/emacs \ + --debug-init \ + --no-init-file \ + --no-site-file \ + --no-site-lisp \ + --load ${./.emacs.d/init.el} + EOF + chmod +x "$APP/Contents/MacOS/BillsEmacs" + runHook postInstall + ''; + meta.platforms = [ "aarch64-darwin" ]; + }; # Script that asserts my Emacs can initialize without warnings or errors. check = runCommand "check-emacs" { } '' @@ -209,4 +259,6 @@ depot.nix.readTree.drvTargets { ${./.emacs.d/init.el} && \ touch $out ''; + + meta.ci.targets = [ "check" ]; } |