refactor(nix/darwin): Include modified brew-nix overlay
This one should work on nix v2.18.x since v2.19.x is reported to have regressions
This commit is contained in:
parent
96590a271e
commit
60964a91e2
5 changed files with 128 additions and 49 deletions
36
.config/nix/flake.lock
generated
36
.config/nix/flake.lock
generated
|
@ -16,34 +16,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"brew-nix": {
|
|
||||||
"inputs": {
|
|
||||||
"brew-api": [
|
|
||||||
"brew-api"
|
|
||||||
],
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nix-darwin": [
|
|
||||||
"nix-darwin"
|
|
||||||
],
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs-stable"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1724407874,
|
|
||||||
"narHash": "sha256-3nw5O0wLkeTeBXJTyY2pZ57JaRtouLva1a6nVx2syLU=",
|
|
||||||
"owner": "BatteredBunny",
|
|
||||||
"repo": "brew-nix",
|
|
||||||
"rev": "d3d3a2666e5330e83b6a64b1eb3e1e9380f6da9b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "BatteredBunny",
|
|
||||||
"repo": "brew-nix",
|
|
||||||
"rev": "d3d3a2666e5330e83b6a64b1eb3e1e9380f6da9b",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727974419,
|
"lastModified": 1727974419,
|
||||||
|
@ -121,11 +93,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710146030,
|
"lastModified": 1726560853,
|
||||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -312,8 +284,8 @@
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"brew-api": "brew-api",
|
"brew-api": "brew-api",
|
||||||
"brew-nix": "brew-nix",
|
|
||||||
"firefox-darwin": "firefox-darwin",
|
"firefox-darwin": "firefox-darwin",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"nix-darwin": "nix-darwin",
|
"nix-darwin": "nix-darwin",
|
||||||
"nixpkgs-stable": "nixpkgs-stable",
|
"nixpkgs-stable": "nixpkgs-stable",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
description = "null2264's Nix Setup";
|
description = "null2264's Nix Setup";
|
||||||
|
|
||||||
outputs = inputs@{ self, nix-darwin, nixpkgs-stable, nixpkgs-unstable, home-manager, system-manager, ... }:
|
outputs = inputs@{ self, nix-darwin, brew-api, nixpkgs-stable, nixpkgs-unstable, home-manager, system-manager, ... }:
|
||||||
let
|
let
|
||||||
vars = {
|
vars = {
|
||||||
floorp = {
|
floorp = {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
darwinConfigurations = (
|
darwinConfigurations = (
|
||||||
import ./systems/darwin {
|
import ./systems/darwin {
|
||||||
inherit (nixpkgs-unstable) lib;
|
inherit (nixpkgs-unstable) lib;
|
||||||
inherit inputs nixpkgs-stable nixpkgs-unstable nix-darwin home-manager vars;
|
inherit inputs nixpkgs-stable nixpkgs-unstable nix-darwin brew-api home-manager vars;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs-stable.url = "github:NixOS/nixpkgs/release-24.05";
|
nixpkgs-stable.url = "github:NixOS/nixpkgs/release-24.05";
|
||||||
nixpkgs-unstable.url = "github:NixOS/nixpkgs/2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53";
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
nix-darwin = {
|
nix-darwin = {
|
||||||
url = "github:LnL7/nix-darwin/470f87c1827b51169ed4f91cdbdfd48417bfff3d";
|
url = "github:LnL7/nix-darwin/470f87c1827b51169ed4f91cdbdfd48417bfff3d";
|
||||||
|
@ -45,12 +46,6 @@
|
||||||
url = "github:bandithedoge/nixpkgs-firefox-darwin";
|
url = "github:bandithedoge/nixpkgs-firefox-darwin";
|
||||||
inputs.nixpkgs.follows = "nixpkgs-stable";
|
inputs.nixpkgs.follows = "nixpkgs-stable";
|
||||||
};
|
};
|
||||||
brew-nix = {
|
|
||||||
url = "github:BatteredBunny/brew-nix/d3d3a2666e5330e83b6a64b1eb3e1e9380f6da9b";
|
|
||||||
inputs.nix-darwin.follows = "nix-darwin";
|
|
||||||
inputs.brew-api.follows = "brew-api";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs-stable";
|
|
||||||
};
|
|
||||||
brew-api = {
|
brew-api = {
|
||||||
url = "github:BatteredBunny/brew-api";
|
url = "github:BatteredBunny/brew-api";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|
103
.config/nix/overlays/darwin/brew.nix
Normal file
103
.config/nix/overlays/darwin/brew.nix
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
# Modified version of brew-nix/casks.nix
|
||||||
|
#
|
||||||
|
# REF: https://github.com/BatteredBunny/brew-nix/blob/9dfab294afea5029922bbc59a10ae487c7318d59/casks.nix
|
||||||
|
{ system, nixpkgs, brew-api, ... }:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
|
||||||
|
hasBinary = cask: pkgs.lib.hasAttr "binary" (getArtifacts cask);
|
||||||
|
hasApp = cask: pkgs.lib.hasAttr "app" (getArtifacts cask);
|
||||||
|
hasPkg = cask: pkgs.lib.hasAttr "pkg" (getArtifacts cask);
|
||||||
|
|
||||||
|
getName = cask: builtins.elemAt cask.name 0;
|
||||||
|
|
||||||
|
getBinary = cask: builtins.elemAt (getArtifacts cask).binary 0;
|
||||||
|
getApp = cask: builtins.elemAt (getArtifacts cask).app 0;
|
||||||
|
getArtifacts = cask: pkgs.lib.mergeAttrsList cask.artifacts;
|
||||||
|
|
||||||
|
caskToDerivation = cask: pkgs.stdenv.mkDerivation rec {
|
||||||
|
pname = cask.token;
|
||||||
|
version = cask.version;
|
||||||
|
|
||||||
|
# FIXME: support variants
|
||||||
|
src = pkgs.fetchurl {
|
||||||
|
url = cask.url;
|
||||||
|
sha256 = pkgs.lib.optionalString (cask.sha256 != "no_check") cask.sha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
undmg
|
||||||
|
unzip
|
||||||
|
gzip
|
||||||
|
_7zz
|
||||||
|
makeWrapper
|
||||||
|
] ++ pkgs.lib.optional (hasPkg cask) (with pkgs; [
|
||||||
|
xar
|
||||||
|
cpio
|
||||||
|
]);
|
||||||
|
|
||||||
|
unpackPhase =
|
||||||
|
if (hasPkg cask) then ''
|
||||||
|
xar -xf $src
|
||||||
|
for pkg in $(cat Distribution | grep -oE "#.+\.pkg" | sed -e "s/^#//" -e "s/$/\/Payload/"); do
|
||||||
|
zcat $pkg | cpio -i
|
||||||
|
done
|
||||||
|
'' else if (hasApp cask) then ''
|
||||||
|
undmg $src || 7zz x -snld $src
|
||||||
|
'' else if (hasBinary cask) then ''
|
||||||
|
if [ "$(file --mime-type -b "$src")" == "application/gzip" ]; then
|
||||||
|
gunzip $src -c > ${getBinary cask}
|
||||||
|
elif [ "$(file --mime-type -b "$src")" == "application/x-mach-binary" ]; then
|
||||||
|
cp $src ${getBinary cask}
|
||||||
|
fi
|
||||||
|
'' else "";
|
||||||
|
|
||||||
|
sourceRoot = pkgs.lib.optionalString (hasApp cask) (getApp cask);
|
||||||
|
|
||||||
|
installPhase =
|
||||||
|
if (hasPkg cask) then ''
|
||||||
|
mkdir -p $out/Applications
|
||||||
|
cp -R Applications/* $out/Applications/
|
||||||
|
|
||||||
|
if [ -d "Resources" ]; then
|
||||||
|
mkdir -p $out/Resources
|
||||||
|
cp -R Resources/* $out/Resources/
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "Library" ]; then
|
||||||
|
mkdir -p $out/Library
|
||||||
|
cp -R Library/* $out/Library/
|
||||||
|
fi
|
||||||
|
'' else if (hasApp cask) then ''
|
||||||
|
mkdir -p "$out/Applications/${sourceRoot}"
|
||||||
|
cp -R . "$out/Applications/${sourceRoot}"
|
||||||
|
|
||||||
|
if [[ -e "$out/Applications/${sourceRoot}/Contents/MacOS/${getName cask}" ]]; then
|
||||||
|
makeWrapper "$out/Applications/${sourceRoot}/Contents/MacOS/${getName cask}" $out/bin/${cask.token}
|
||||||
|
elif [[ -e "$out/Applications/${sourceRoot}/Contents/MacOS/${pkgs.lib.removeSuffix ".app" sourceRoot}" ]]; then
|
||||||
|
makeWrapper "$out/Applications/${sourceRoot}/Contents/MacOS/${pkgs.lib.removeSuffix ".app" sourceRoot}" $out/bin/${cask.token}
|
||||||
|
fi
|
||||||
|
'' else if (hasBinary cask && !hasApp cask) then ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp -R ./* $out/bin
|
||||||
|
'' else "";
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = cask.homepage;
|
||||||
|
description = cask.desc;
|
||||||
|
platforms = pkgs.lib.platforms.darwin;
|
||||||
|
mainProgram = if (hasBinary cask && !hasApp cask) then (getBinary cask) else (cask.token);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
casks = builtins.fromJSON (builtins.readFile (brew-api + "/cask.json"));
|
||||||
|
in final: prev: {
|
||||||
|
casks = builtins.listToAttrs (builtins.map
|
||||||
|
(cask: {
|
||||||
|
name = cask.token;
|
||||||
|
value = caskToDerivation cask;
|
||||||
|
})
|
||||||
|
casks);
|
||||||
|
}
|
|
@ -32,7 +32,8 @@
|
||||||
pkgs.pinentry_mac
|
pkgs.pinentry_mac
|
||||||
pkgs.iina
|
pkgs.iina
|
||||||
pkgs.floorp-bin
|
pkgs.floorp-bin
|
||||||
pkgs.brewCasks.zotero
|
|
||||||
|
pkgs.casks.zotero
|
||||||
|
|
||||||
pkgs.lf
|
pkgs.lf
|
||||||
pkgs.yazi # lf replacement, need further testing
|
pkgs.yazi # lf replacement, need further testing
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
# Auto upgrade nix package and the daemon service.
|
# Auto upgrade nix package and the daemon service.
|
||||||
services.nix-daemon.enable = true;
|
services.nix-daemon.enable = true;
|
||||||
nix = {
|
nix = {
|
||||||
package = pkgs.nixVersions.nix_2_19; # brew-nix requires nix v2.19
|
package = pkgs.nix;
|
||||||
settings.experimental-features = "nix-command flakes"; # stopping nix from crying about using experimental features flakes and nix-command
|
settings.experimental-features = "nix-command flakes"; # stopping nix from crying about using experimental features flakes and nix-command
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ inputs, nixpkgs-stable, nixpkgs-unstable, nix-darwin, vars, ... }:
|
{ inputs, nixpkgs-stable, nixpkgs-unstable, nix-darwin, brew-api, vars, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
mkCommon = import ../../lib/mkCommon.nix;
|
mkCommon = import ../../lib/mkCommon.nix;
|
||||||
|
@ -13,18 +13,22 @@ in
|
||||||
# Lenovo ThinkPad L460; Intel Core i5-6300U
|
# Lenovo ThinkPad L460; Intel Core i5-6300U
|
||||||
"ThiccBook-Pro" =
|
"ThiccBook-Pro" =
|
||||||
let
|
let
|
||||||
|
system = "x86_64-darwin";
|
||||||
inherit (
|
inherit (
|
||||||
mkSystem {
|
mkSystem {
|
||||||
arch = "x86_64-darwin";
|
arch = system;
|
||||||
stable = nixpkgs-stable;
|
stable = nixpkgs-stable;
|
||||||
unstable = nixpkgs-unstable;
|
unstable = nixpkgs-unstable;
|
||||||
extraOverlays = [
|
extraOverlays = [
|
||||||
inputs.firefox-darwin.overlay
|
inputs.firefox-darwin.overlay
|
||||||
inputs.brew-nix.overlays.default
|
(import ../../overlays/darwin/brew.nix {
|
||||||
|
inherit system brew-api;
|
||||||
|
nixpkgs = nixpkgs-stable;
|
||||||
|
})
|
||||||
(import ../../overlays/darwin/inkscape.nix)
|
(import ../../overlays/darwin/inkscape.nix)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
) system pkgs pkgs-unstable;
|
) pkgs pkgs-unstable;
|
||||||
common = (mkCommon { inherit pkgs pkgs-unstable; });
|
common = (mkCommon { inherit pkgs pkgs-unstable; });
|
||||||
in
|
in
|
||||||
nix-darwin.lib.darwinSystem {
|
nix-darwin.lib.darwinSystem {
|
||||||
|
@ -38,18 +42,22 @@ in
|
||||||
# Imaginary M1, just for reference
|
# Imaginary M1, just for reference
|
||||||
MacBookProM1 =
|
MacBookProM1 =
|
||||||
let
|
let
|
||||||
|
system = "aarch64-darwin";
|
||||||
inherit (
|
inherit (
|
||||||
mkSystem {
|
mkSystem {
|
||||||
arch = "aarch64-darwin";
|
arch = system;
|
||||||
stable = nixpkgs-stable;
|
stable = nixpkgs-stable;
|
||||||
unstable = nixpkgs-unstable;
|
unstable = nixpkgs-unstable;
|
||||||
extraOverlays = [
|
extraOverlays = [
|
||||||
inputs.firefox-darwin.overlay
|
inputs.firefox-darwin.overlay
|
||||||
inputs.brew-nix.overlays.default
|
(import ../../overlays/darwin/brew.nix {
|
||||||
|
inherit system brew-api;
|
||||||
|
nixpkgs = nixpkgs-stable;
|
||||||
|
})
|
||||||
(import ../../overlays/darwin/inkscape.nix)
|
(import ../../overlays/darwin/inkscape.nix)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
) system pkgs pkgs-unstable;
|
) pkgs pkgs-unstable;
|
||||||
common = (mkCommon { inherit pkgs pkgs-unstable; });
|
common = (mkCommon { inherit pkgs pkgs-unstable; });
|
||||||
in
|
in
|
||||||
nix-darwin.lib.darwinSystem {
|
nix-darwin.lib.darwinSystem {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue