From 4c17094aa687873105f51bf6bac2162ecd4eeaae Mon Sep 17 00:00:00 2001 From: Angus Trau Date: Wed, 25 Aug 2021 20:18:42 +1000 Subject: [PATCH] macos nix build support --- .github/workflows/windows_package_create.yml | 4 ++-- docs/contributing.rst | 4 ++-- ev3sim/file_helper.py | 7 ++++++- flake.lock | 12 ++++++------ flake.nix | 6 +++--- nix/{linux.nix => unix.nix} | 0 6 files changed, 19 insertions(+), 14 deletions(-) rename nix/{linux.nix => unix.nix} (100%) diff --git a/.github/workflows/windows_package_create.yml b/.github/workflows/windows_package_create.yml index c939b1fd..9a7926a5 100644 --- a/.github/workflows/windows_package_create.yml +++ b/.github/workflows/windows_package_create.yml @@ -23,9 +23,9 @@ jobs: with: name: melbournehighschoolrobotics authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - + + - run: nix build --print-build-logs ".#unix" - run: nix build --print-build-logs ".#windows" - - run: nix flake check - uses: actions/upload-artifact@v1 with: diff --git a/docs/contributing.rst b/docs/contributing.rst index 4e043bf4..b67670f6 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -67,8 +67,8 @@ To build installers for Windows: nix build ".#windows" -To build for Linux: +To build for Linux and macOS: .. code-block:: bash - nix build ".#linux" + nix build ".#unix" diff --git a/ev3sim/file_helper.py b/ev3sim/file_helper.py index d0625e4f..28dac94d 100644 --- a/ev3sim/file_helper.py +++ b/ev3sim/file_helper.py @@ -13,7 +13,8 @@ def find_platform_location(dir_type): """ Attempt to find and create operating system data folders """ - if platform.system() == "Linux": + p = platform.system() + if p == "Linux": home_dir = os.path.expanduser("~") if dir_type == "config": xdg_dir = os.environ.get("XDG_CONFIG_HOME") or os.path.join(home_dir, ".config") @@ -22,6 +23,10 @@ def find_platform_location(dir_type): ev3sim_dir = os.path.join(xdg_dir, "ev3sim") Path(ev3sim_dir).mkdir(parents=True, exist_ok=True) return ev3sim_dir + elif p == "Darwin": + directory = os.path.expanduser("~/Library/Application Support/ev3sim/" + dir_type) + Path(directory).mkdir(parents=True, exist_ok=True) + return directory return None diff --git a/flake.lock b/flake.lock index bffbb6f3..5f5563f6 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1623875721, - "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", "owner": "numtide", "repo": "flake-utils", - "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", "type": "github" }, "original": { @@ -40,11 +40,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1628696641, - "narHash": "sha256-4Qb0Rpx8kjnPxNJiw15CmmV9hfiyvzlUzGcOn8bXKXQ=", + "lastModified": 1629827819, + "narHash": "sha256-cysfDbdjTluO+UtuT6iRrf/2Lt7Qo/qRlpz9F5rz3Sc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "10bb036486138341e4c760c4c98ddadef56fff7b", + "rev": "503209808cd613daed238e21e7a18ffcbeacebe3", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 7e5e4c5c..ab85ef57 100644 --- a/flake.nix +++ b/flake.nix @@ -9,18 +9,18 @@ inputs.mindpile.inputs.flake-utils.follows = "flake-utils"; outputs = { nixpkgs, flake-utils, mindpile, ... }: - flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: + flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system: let pkgs = nixpkgs.legacyPackages.${system}; mp = mindpile.legacyPackages.${system}; in rec { packages = { - linux = pkgs.callPackage ./nix/linux.nix { + unix = pkgs.callPackage ./nix/unix.nix { inherit (mp) mindpile; }; windows = pkgs.callPackage ./nix/windows-installer.nix { }; }; - defaultPackage = packages.linux; + defaultPackage = packages.unix; }); } diff --git a/nix/linux.nix b/nix/unix.nix similarity index 100% rename from nix/linux.nix rename to nix/unix.nix