Skip to content

Instantly share code, notes, and snippets.

@pjan
Created February 25, 2018 07:16
Show Gist options
  • Save pjan/8a281e79409fc702d70bd03bbd7499c6 to your computer and use it in GitHub Desktop.
Save pjan/8a281e79409fc702d70bd03bbd7499c6 to your computer and use it in GitHub Desktop.
nix overlay for the creation of mac applications
# overlays/pkgs/osx/dash/default.nix
{ pkgs }:
with pkgs; osx.mkAppDerivation rec {
name = "Dash";
sourceRoot = "Dash.app";
src = fetchurl {
url = "https://kapeli.com/downloads/v4/Dash.zip";
sha256 = "073fzga9gra5rln7cixj50h7c6zgajhd2jibslkx2qrdbry67mc4";
};
meta = {
version = "4.1.3";
description = "API Documentation Browser and Code Snippet Manager";
homepage = https://kapeli.com/dash;
};
}
# overlays/mkAppDerivation.nix
self: super:
let
mkAppDerivation =
{ name
, ...
} @ args:
let
drvName =
let
root = builtins.replaceStrings [ " " ] [ "-" ] name;
suffix =
if (super.lib.hasAttrByPath [ "meta" "version" ] args)
then ''-${super.lib.getAttrFromPath [ "meta" "version" ] args}''
else "";
in "${root}${suffix}";
in with super; stdenv.mkDerivation (args // {
name = drvName;
buildInputs = [ undmg unzip ];
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
installPhase = ''
mkdir -p "$out/Applications/${name}.app"
cp -pR * "$out/Applications/${name}.app"
'';
});
in rec {
osx = {
inherit mkAppDerivation;
};
}
# overlays/pkgs.nix
self: super:
rec {
dash = super.callPackage ./pkgs/osx/dash { };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment