Skip to content

feat(nix): add flake.nix for macOS builds#153

Open
Kyure-A wants to merge 2 commits intoglide-wm:mainfrom
Kyure-A:main
Open

feat(nix): add flake.nix for macOS builds#153
Kyure-A wants to merge 2 commits intoglide-wm:mainfrom
Kyure-A:main

Conversation

@Kyure-A
Copy link

@Kyure-A Kyure-A commented Mar 4, 2026

This adds a flake.nix so Glide can be built and run directly with Nix on macOS.

It exposes:

  • packages.<system>.default as the app bundle
  • packages.<system>.bundle as the same bundled output
  • packages.<system>.unbundled for the raw binaries
  • apps.<system>.default for nix run

Motivation

I've been using Glide and have had a great experience with it.

I wanted a Nix-native way to build and install it, and I think it can also be useful for users who want to track upstream directly without depending on Homebrew cask update timing.

Notes

This is an additive change for Nix users and does not change the existing Homebrew or manual installation paths.

For instance, https://github.com/openai/codex provides itself via flake.nix. Furthermore, Codex declaratively manages its development environment using a Nix mechanism called devShells, and we believe that incorporating devShells in the future would further improve the workflow.

Kyure-A added 2 commits March 3, 2026 19:17
- Add flake.nix to define build and bundle outputs for macOS using Nix
- Update .gitignore to exclude Nix build result directory
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates Nix support for building and installing the Glide application on macOS. It provides a Nix-native method for users to obtain and manage Glide, offering an alternative to existing installation paths like Homebrew. The changes are additive, focusing on enhancing build and distribution options for Nix users without affecting current workflows.

Highlights

  • Nix Flake Integration: Introduced a flake.nix file to enable building and running Glide directly with Nix on macOS.
  • Nix Outputs Defined: The Nix flake exposes packages.<system>.default and packages.<system>.bundle for the app bundle, packages.<system>.unbundled for raw binaries, and apps.<system>.default for nix run.
  • Build Process for macOS: The flake defines a rustPlatform.buildRustPackage for the core binaries and a runCommand to create the macOS .app bundle, including Info.plist and PkgInfo.
Changelog
  • .gitignore
    • Added 'result' to the ignore list to prevent Nix build outputs from being tracked.
  • flake.lock
    • Added a new file to lock the versions of Nix dependencies, ensuring reproducible builds.
  • flake.nix
    • Added a new file defining the Nix flake for Glide, including build instructions for Rust packages and the creation of a macOS application bundle.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Nix support for building Glide on macOS via a flake.nix file. The implementation is solid and covers package outputs for both bundled and unbundled versions, as well as a nix run app. I've provided a couple of suggestions to improve the maintainability and efficiency of the Nix expression by using more idiomatic patterns.

Comment on lines +21 to +24
forAllSystems = f:
lib.genAttrs supportedSystems (
system: f (import nixpkgs { inherit system; })
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using import nixpkgs { inherit system; } inside lib.genAttrs can be inefficient as it re-evaluates the nixpkgs import for each system. A more idiomatic and efficient approach in flakes is to use nixpkgs.legacyPackages.${system}.

      forAllSystems = f:
        lib.genAttrs supportedSystems (
          system: f nixpkgs.legacyPackages.${system}
        );

Comment on lines +50 to +107
mkGlideBundle = pkgs: unbundled:
pkgs.runCommand "${cargoToml.package.name}-app-${version}" {
meta = with pkgs.lib; {
description = "${cargoToml.package.description} (${bundleName})";
homepage = cargoToml.package.homepage;
license = [
licenses.asl20
licenses.mit
];
mainProgram = "glide";
platforms = platforms.darwin;
};
} ''
bundle="$out/Applications/${bundleName}"

mkdir -p "$bundle/Contents/MacOS" "$out/bin"

install -m755 ${unbundled}/bin/glide "$bundle/Contents/MacOS/glide"
install -m755 ${unbundled}/bin/glide_server "$bundle/Contents/MacOS/glide_server"

printf '%s\n' \
'<?xml version="1.0" encoding="UTF-8"?>' \
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' \
'<plist version="1.0">' \
' <dict>' \
' <key>CFBundleDevelopmentRegion</key>' \
' <string>en</string>' \
' <key>CFBundleExecutable</key>' \
' <string>glide_server</string>' \
' <key>CFBundleIdentifier</key>' \
' <string>${bundleIdentifier}</string>' \
' <key>CFBundleInfoDictionaryVersion</key>' \
' <string>6.0</string>' \
' <key>CFBundleName</key>' \
' <string>${productName}</string>' \
' <key>CFBundlePackageType</key>' \
' <string>APPL</string>' \
' <key>CFBundleShortVersionString</key>' \
' <string>${version}</string>' \
' <key>CFBundleVersion</key>' \
' <string>${version}</string>' \
' <key>NSPrincipalClass</key>' \
' <string>NSApplication</string>' \
' </dict>' \
'</plist>' \
> "$bundle/Contents/Info.plist"

printf 'APPL????' > "$bundle/Contents/PkgInfo"

ln -s "../Applications/${bundleName}/Contents/MacOS/glide" "$out/bin/glide"
ln -s "../Applications/${bundleName}/Contents/MacOS/glide_server" "$out/bin/glide_server"

printf '%s\n' \
'#!/bin/sh' \
"exec \"$out/bin/glide\" launch \"\$@\"" \
> "$out/bin/glide-launch"
chmod +x "$out/bin/glide-launch"
'';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The mkGlideBundle function can be made more robust and maintainable by using some standard Nix helper functions.

  • Explicitly declare nativeBuildInputs like makeWrapper and coreutils for tools used in the script.
  • Generate the Info.plist file using pkgs.writeText outside the script to separate data from logic.
  • Use pkgs.makeWrapper to create the glide-launch script, which is the standard way to create wrapper scripts in Nix.

Here's a suggested refactoring that applies these improvements:

      mkGlideBundle = pkgs: unbundled:
        let
          infoPlist = pkgs.writeText "Info.plist" ''
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
            <plist version="1.0">
              <dict>
                <key>CFBundleDevelopmentRegion</key>
                <string>en</string>
                <key>CFBundleExecutable</key>
                <string>glide_server</string>
                <key>CFBundleIdentifier</key>
                <string>${bundleIdentifier}</string>
                <key>CFBundleInfoDictionaryVersion</key>
                <string>6.0</string>
                <key>CFBundleName</key>
                <string>${productName}</string>
                <key>CFBundlePackageType</key>
                <string>APPL</string>
                <key>CFBundleShortVersionString</key>
                <string>${version}</string>
                <key>CFBundleVersion</key>
                <string>${version}</string>
                <key>NSPrincipalClass</key>
                <string>NSApplication</string>
              </dict>
            </plist>
          '';
        in
        pkgs.runCommand "${cargoToml.package.name}-app-${version}" {
          nativeBuildInputs = [ pkgs.makeWrapper pkgs.coreutils ];
          meta = with pkgs.lib; {
            description = "${cargoToml.package.description} (${bundleName})";
            homepage = cargoToml.package.homepage;
            license = [
              licenses.asl20
              licenses.mit
            ];
            mainProgram = "glide";
            platforms = platforms.darwin;
          };
        } ''
          bundle="$out/Applications/${bundleName}"

          mkdir -p "$bundle/Contents/MacOS" "$out/bin"

          install -m755 ${unbundled}/bin/glide "$bundle/Contents/MacOS/glide"
          install -m755 ${unbundled}/bin/glide_server "$bundle/Contents/MacOS/glide_server"

          cp ${infoPlist} "$bundle/Contents/Info.plist"

          printf 'APPL????' > "$bundle/Contents/PkgInfo"

          ln -s "../Applications/${bundleName}/Contents/MacOS/glide" "$out/bin/glide"
          ln -s "../Applications/${bundleName}/Contents/MacOS/glide_server" "$out/bin/glide_server"

          makeWrapper "$out/bin/glide" "$out/bin/glide-launch" --add-flags "launch"
        '';

@tmandry
Copy link
Contributor

tmandry commented Mar 12, 2026

This seems like it duplicates stuff like the plist generation which I already have a tool (cargo packager) doing. I don't want to maintain two different ways of creating the plist.

I'm also not sure about the user experience - I think you would have to add permissions again every time you update, unless you are running the glide server in the terminal (in which case you have to give accessibility permissions to your terminal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants