feat(nix/darwin/brew): Support variation

This commit is contained in:
Ahmad Ansori Palembani 2024-11-02 12:57:45 +07:00
parent 60964a91e2
commit a5a3750cac
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
6 changed files with 14 additions and 55 deletions

View file

@ -8,13 +8,12 @@ let
py.dnspython py.dnspython
])); ]));
}; };
custom.inkscape = if pkgs.stdenv.isDarwin then pkgs.inkscape-bin else (pkgs.inkscape.override { python3 = custom.python; }); custom.inkscape = if pkgs.stdenv.isDarwin then pkgs.casks.inkscape else (pkgs.inkscape.override { python3 = custom.python; });
in { in {
inherit custom; inherit custom;
packages = [ packages = [
pkgs.zsh pkgs.zsh
pkgs.home-manager pkgs.home-manager
pkgs.zoxide pkgs.zoxide
custom.inkscape
]; ];
} }

View file

@ -1,7 +1,7 @@
# Modified version of brew-nix/casks.nix # Modified version of brew-nix/casks.nix
# #
# REF: https://github.com/BatteredBunny/brew-nix/blob/9dfab294afea5029922bbc59a10ae487c7318d59/casks.nix # REF: https://github.com/BatteredBunny/brew-nix/blob/9dfab294afea5029922bbc59a10ae487c7318d59/casks.nix
{ system, nixpkgs, brew-api, ... }: { system, mac-version ? "ventura", nixpkgs, brew-api, ... }:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
@ -17,14 +17,16 @@ let
getApp = cask: builtins.elemAt (getArtifacts cask).app 0; getApp = cask: builtins.elemAt (getArtifacts cask).app 0;
getArtifacts = cask: pkgs.lib.mergeAttrsList cask.artifacts; getArtifacts = cask: pkgs.lib.mergeAttrsList cask.artifacts;
getUrl = cask: (cask.variations.${mac-version} or cask).url;
getHash = cask: (cask.variations.${mac-version} or cask).sha256;
caskToDerivation = cask: pkgs.stdenv.mkDerivation rec { caskToDerivation = cask: pkgs.stdenv.mkDerivation rec {
pname = cask.token; pname = cask.token;
version = cask.version; version = cask.version;
# FIXME: support variants
src = pkgs.fetchurl { src = pkgs.fetchurl {
url = cask.url; url = (getUrl cask);
sha256 = pkgs.lib.optionalString (cask.sha256 != "no_check") cask.sha256; sha256 = pkgs.lib.optionalString ((getHash cask) != "no_check") (getHash cask);
}; };
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [

View file

@ -1,45 +0,0 @@
# REF: https://github.com/bandithedoge/nixpkgs-firefox-darwin/blob/ceaca2359e5371ccef3f92a36baf7c438b354afb/overlay.nix
final: prev:
let
inkscapePackage = version:
final.stdenv.mkDerivation rec {
pname = "Inkscape";
inherit version;
buildInputs = [ final.pkgs.undmg ];
sourceRoot = ".";
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r Inkscape*.app "$out/Applications/"
runHook postInstall
'';
src = final.fetchurl {
name = "Inkscape-${version}.dmg";
url = "https://media.inkscape.org/dl/resources/file/Inkscape-${version}_${if final.stdenv.isAarch64 then "arm64" else "x86_64"}.dmg";
sha256 = if final.stdenv.isAarch64 then "c2d89809ad8d85021e7784e72e28aee2231b0b8675ec3ede3e6fb9f1ffedb4b3" else "e3f968e131e5c3577ee21809da487eafe2a9b42370e2bf408e5811b6f965912e";
};
meta = with final.lib; {
description = "Vector graphics editor";
homepage = "https://www.inkscape.org";
license = licenses.gpl3Plus;
maintainers = [ maintainers.jtojnar ];
platforms = platforms.all;
mainProgram = "inkscape";
longDescription = ''
Inkscape is a feature-rich vector graphics editor that edits
files in the W3C SVG (Scalable Vector Graphics) file format.
If you want to import .eps files install ps2edit.
'';
};
};
in {
inkscape-bin = inkscapePackage "1.4.028868";
}

View file

@ -17,6 +17,7 @@
pkgs.gnupg pkgs.gnupg
pkgs.htop-vim pkgs.htop-vim
common.custom.python common.custom.python
common.custom.inkscape
#(pkgs.poetry.override { python3 = common.custom.python; }) #(pkgs.poetry.override { python3 = common.custom.python; })
pkgs.fastfetch pkgs.fastfetch
pkgs.eza pkgs.eza

View file

@ -25,7 +25,6 @@ in
inherit system brew-api; inherit system brew-api;
nixpkgs = nixpkgs-stable; nixpkgs = nixpkgs-stable;
}) })
(import ../../overlays/darwin/inkscape.nix)
]; ];
} }
) pkgs pkgs-unstable; ) pkgs pkgs-unstable;
@ -54,7 +53,6 @@ in
inherit system brew-api; inherit system brew-api;
nixpkgs = nixpkgs-stable; nixpkgs = nixpkgs-stable;
}) })
(import ../../overlays/darwin/inkscape.nix)
]; ];
} }
) pkgs pkgs-unstable; ) pkgs pkgs-unstable;

View file

@ -18,6 +18,7 @@ in
"ziro@ThiccBook-Pro" = "ziro@ThiccBook-Pro" =
let let
system = "x86_64-darwin";
inherit ( inherit (
mkSystem { mkSystem {
arch = "x86_64-darwin"; arch = "x86_64-darwin";
@ -25,10 +26,13 @@ in
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;
})
]; ];
} }
) system pkgs pkgs-unstable; ) pkgs pkgs-unstable;
vars.name = "ziro"; vars.name = "ziro";
vars.floorp.verticalTabHoverWidthInEm = 28; vars.floorp.verticalTabHoverWidthInEm = 28;
in in