diff --git a/flake.nix b/flake.nix index c89eae0..c9e03d4 100644 --- a/flake.nix +++ b/flake.nix @@ -60,6 +60,6 @@ modules = (import ./modules-all {}) // (import ./modules-linux {}) // (import ./modules-darwin {}); - packages = import ./overlays/packages.nix { pkgs = nixstable; }; + packages = (import ./overlays/packages.nix { inherit nixunstable flake-utils; }); }; } diff --git a/home/home.nix b/home/home.nix index 902fa97..74af169 100644 --- a/home/home.nix +++ b/home/home.nix @@ -31,6 +31,7 @@ home.stateVersion = "22.05"; home.packages = with pkgs; [ bitwarden-cli + brew diffutils findutils git diff --git a/home/xonsh_header.xsh b/home/xonsh_header.xsh index 6c5f60d..22441ec 100644 --- a/home/xonsh_header.xsh +++ b/home/xonsh_header.xsh @@ -1,6 +1,7 @@ # vim: set ft=python: from os import getcwd, uname from pathlib import Path +from sys import platform #if uname().sysname == 'Darwin' and ('__NIX_DARWIN_SET_ENVIRONMENT_DONE' not in ${...} or not $__NIX_DARWIN_SET_ENVIRONMENT_DONE): @@ -19,3 +20,6 @@ xontrib load coreutils $PATH.insert(0, Path("~/.nix-profile/bin").expanduser()) $PATH.insert(0, Path("~/src/bin").expanduser()) $PATH.insert(0, Path("~/.local/bin").expanduser()) + +if platform == "darwin": + $PATH.append(Path("/opt/homebrew/bin/")) diff --git a/overlays/default.nix b/overlays/default.nix index 8af1cf8..977f1ee 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -80,6 +80,7 @@ in rec { }; #fcitx-engines = if ! super.stdenv.isDarwin then super.fcitx5 else super.fcitx-engines; + brew = super.callPackage ./homebrew.nix {}; enwiki-dump = super.callPackage ./enwiki-dump.nix {}; hms = super.callPackage ./hms.nix { diff --git a/overlays/homebrew.nix b/overlays/homebrew.nix new file mode 100644 index 0000000..6d8e1f4 --- /dev/null +++ b/overlays/homebrew.nix @@ -0,0 +1,43 @@ +{ +lib, +pkgs, +stdenv, + +bash, +curl, +git, +ruby, +...}: + +stdenv.mkDerivation rec { + pname = "homebrew-installer"; + version = "20230531"; + + src = pkgs.fetchFromGitHub { + owner = "Homebrew"; + repo = "install"; + rev = "716a1d024f32890ef75ea82c18a769abc24e9475"; + sha256 = "sha256-xhxWWeCJm49bDzmBT2GHSC0CK1SoQArBhfh5sltGY5o="; + }; + + buildInputs = [ + bash + curl + git + ruby + ]; + + installPhase = '' + mkdir -p $out/bin/ + cp ${src}/install.sh $out/bin/install-homebrew.sh + cp ${src}/uninstall.sh $out/bin/uninstall-homebrew.sh + ''; + + meta = with lib; { + description = "Runs the homebrew installer"; + homepage = "https://github.com/Homebrew/"; + license = licenses.bsd2; + platforms = [ "aarch64-darwin" "x86_64-darwin" ]; + maintainers = [ maintainers.greg ]; + }; +} diff --git a/overlays/packages.nix b/overlays/packages.nix index c8d435c..73b5ee6 100644 --- a/overlays/packages.nix +++ b/overlays/packages.nix @@ -1,24 +1,28 @@ -{ pkgs, ... }: +{ nixunstable, flake-utils }: -let - callPackage = pkgs.lib.callPackageWith pkgs; - lib = pkgs.lib; - python = pkgs.packages.python3; - cp = pkgs.packages.python3.pkgs.callPackage; -in { - datadog-api-client = callPackage ./datadog-api-client.nix { - inherit pkgs lib; - buildPythonPackage = python.pkgs.buildPythonPackage; - fetchPypi = pkgs.python.pkgs.fetchPypi; - }; +flake-utils.lib.eachDefaultSystemMap (system: + let + pkgs = (import nixunstable { inherit system; }); + lib = pkgs.lib; + callPackage = pkgs.lib.callPackageWith pkgs; + python = pkgs.packages.python3; + cp = pkgs.packages.python3.pkgs.callPackage; + in { + datadog-api-client = callPackage ./datadog-api-client.nix { + inherit pkgs lib; + buildPythonPackage = python.pkgs.buildPythonPackage; + fetchPypi = pkgs.python.pkgs.fetchPypi; + }; - hms = pkgs.callPackage ./hms.nix { - inherit pkgs; - }; + hms = pkgs.callPackage ./hms.nix { + inherit pkgs; + }; - xonsh-direnv = pkgs.callPackage ./xonsh-direnv.nix { - buildPythonPackage = pkgs.python3.pkgs.buildPythonPackage; - fetchPypi = pkgs.python.pkgs.fetchPypi; - }; + brew = pkgs.callPackage ./homebrew.nix {}; -} + xonsh-direnv = pkgs.callPackage ./xonsh-direnv.nix { + buildPythonPackage = pkgs.python3.pkgs.buildPythonPackage; + fetchPypi = pkgs.python.pkgs.fetchPypi; + }; + } +)