From a5a3750cac3e89123aaf341cb4a0cd88590403b2 Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Sat, 2 Nov 2024 12:57:45 +0700 Subject: [PATCH] feat(nix/darwin/brew): Support variation --- .config/nix/lib/mkCommon.nix | 3 +- .config/nix/overlays/darwin/brew.nix | 10 +++-- .config/nix/overlays/darwin/inkscape.nix | 45 -------------------- .config/nix/systems/darwin/configuration.nix | 1 + .config/nix/systems/darwin/default.nix | 2 - .config/nix/users/default.nix | 8 +++- 6 files changed, 14 insertions(+), 55 deletions(-) delete mode 100644 .config/nix/overlays/darwin/inkscape.nix diff --git a/.config/nix/lib/mkCommon.nix b/.config/nix/lib/mkCommon.nix index 8b4b60d..26c3444 100644 --- a/.config/nix/lib/mkCommon.nix +++ b/.config/nix/lib/mkCommon.nix @@ -8,13 +8,12 @@ let 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 { inherit custom; packages = [ pkgs.zsh pkgs.home-manager pkgs.zoxide - custom.inkscape ]; } diff --git a/.config/nix/overlays/darwin/brew.nix b/.config/nix/overlays/darwin/brew.nix index c981ece..0da9049 100644 --- a/.config/nix/overlays/darwin/brew.nix +++ b/.config/nix/overlays/darwin/brew.nix @@ -1,7 +1,7 @@ # Modified version of brew-nix/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 pkgs = import nixpkgs { inherit system; @@ -17,14 +17,16 @@ let getApp = cask: builtins.elemAt (getArtifacts cask).app 0; 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 { 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; + url = (getUrl cask); + sha256 = pkgs.lib.optionalString ((getHash cask) != "no_check") (getHash cask); }; nativeBuildInputs = with pkgs; [ diff --git a/.config/nix/overlays/darwin/inkscape.nix b/.config/nix/overlays/darwin/inkscape.nix deleted file mode 100644 index 4fbdd88..0000000 --- a/.config/nix/overlays/darwin/inkscape.nix +++ /dev/null @@ -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"; -} diff --git a/.config/nix/systems/darwin/configuration.nix b/.config/nix/systems/darwin/configuration.nix index 96628e8..4efcdd8 100644 --- a/.config/nix/systems/darwin/configuration.nix +++ b/.config/nix/systems/darwin/configuration.nix @@ -17,6 +17,7 @@ pkgs.gnupg pkgs.htop-vim common.custom.python + common.custom.inkscape #(pkgs.poetry.override { python3 = common.custom.python; }) pkgs.fastfetch pkgs.eza diff --git a/.config/nix/systems/darwin/default.nix b/.config/nix/systems/darwin/default.nix index f50a262..5d0bba3 100644 --- a/.config/nix/systems/darwin/default.nix +++ b/.config/nix/systems/darwin/default.nix @@ -25,7 +25,6 @@ in inherit system brew-api; nixpkgs = nixpkgs-stable; }) - (import ../../overlays/darwin/inkscape.nix) ]; } ) pkgs pkgs-unstable; @@ -54,7 +53,6 @@ in inherit system brew-api; nixpkgs = nixpkgs-stable; }) - (import ../../overlays/darwin/inkscape.nix) ]; } ) pkgs pkgs-unstable; diff --git a/.config/nix/users/default.nix b/.config/nix/users/default.nix index e8439b6..47aa082 100644 --- a/.config/nix/users/default.nix +++ b/.config/nix/users/default.nix @@ -18,6 +18,7 @@ in "ziro@ThiccBook-Pro" = let + system = "x86_64-darwin"; inherit ( mkSystem { arch = "x86_64-darwin"; @@ -25,10 +26,13 @@ in unstable = nixpkgs-unstable; extraOverlays = [ 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.floorp.verticalTabHoverWidthInEm = 28; in