Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/batteredbunny/brew-nix
Experimental nix expression to package all MacOS casks from homebrew automatically
https://github.com/batteredbunny/brew-nix
brew flake homebrew nix nix-darwin nix-flake
Last synced: about 8 hours ago
JSON representation
Experimental nix expression to package all MacOS casks from homebrew automatically
- Host: GitHub
- URL: https://github.com/batteredbunny/brew-nix
- Owner: BatteredBunny
- License: mit
- Created: 2024-05-04T11:07:43.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-01-20T19:22:56.000Z (12 days ago)
- Last Synced: 2025-02-01T15:06:49.288Z (about 8 hours ago)
- Topics: brew, flake, homebrew, nix, nix-darwin, nix-flake
- Language: Nix
- Homepage:
- Size: 24.4 KB
- Stars: 210
- Watchers: 7
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# brew-nix
Experimental nix expression to package all MacOS casks from [homebrew](https://brew.sh/) automatically.
## Benefits over nix-darwin's homebrew module
1. No homebrew needed, packages are fully managed by nix.
2. Fully nix package expressions, everything is type checked and it will give you an error when you specify an invalid package for example.## Limitations/flaws
1. Running most programs with ``nix run`` wont work, so you should install them first.
2. Some programs refuse to run from non standard locations, since this is automatic there isnt a good way to fix it.
3. About 700 casks dont come with hashes, so you have to [override the package and provide the hash yourself](https://github.com/BatteredBunny/brew-nix?tab=readme-ov-file#overriding-casks-with-no-hash).
4. Having multiple generations of this will take A LOT of space, so keep that in mind## Related projects
- [mac-app-util](https://github.com/hraban/mac-app-util)
- [nixcasks](https://github.com/jcszymansk/nixcasks)# Usage examples
## Basic usage
```bash
nix build github:BatteredBunny/brew-nix#blender
./result/Applications/Blender.app/Contents/MacOS/Blender
```## Overriding casks with no hash
Many casks come with no hash so you have to provide one yourself
```nix
home.packages = with pkgs; [
(brewCasks.marta.overrideAttrs (o: {
src = pkgs.fetchurl {
url = builtins.head oldAttrs.src.urls;
hash = lib.fakeHash; # Replace me with real hash after building once
};
}))
];
```## Using with nix-darwin
See [`examples/flake.nix`](examples/flake.nix).
## Using with home-manager
```nix
# flake.nix
inputs = {
brew-nix = {
url = "github:BatteredBunny/brew-nix";
inputs.brew-api.follows = "brew-api";
};
brew-api = {
url = "github:BatteredBunny/brew-api";
flake = false;
};
};
```
```nix
# home.nix
nixpkgs = {
overlays = [
inputs.brew-nix.overlays.default
];
};home.packages = with pkgs; [
brewCasks.marta
brewCasks."firefox@developer-edition" # Casks with special characters in their name need to be defined in quotes
];
```