diff --git a/flake.lock b/flake.lock index 97688a5..ae0b14b 100644 --- a/flake.lock +++ b/flake.lock @@ -32,6 +32,26 @@ "type": "github" } }, + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs-darwin" + ] + }, + "locked": { + "lastModified": 1622060422, + "narHash": "sha256-hPVlvrAyf6zL7tTx0lpK+tMxEfZeMiIZ/A2xaJ41WOY=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "007d700e644ac588ad6668e6439950a5b6e2ff64", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1629481132, @@ -247,6 +267,22 @@ "type": "github" } }, + "nixpkgs-darwin": { + "locked": { + "lastModified": 1630964657, + "narHash": "sha256-owGDhoOhY9AXsqkPvGJrprxfH3VEEiRmmzZiHy2bibM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e421291bdd94c79d6ae98f05ed8f09412d0b6ad7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1630140382, @@ -267,6 +303,7 @@ "inputs": { "active-window": "active-window", "comma": "comma", + "darwin": "darwin", "fzf-tab": "fzf-tab", "home-manager": "home-manager", "kak-lsp": "kak-lsp", @@ -278,6 +315,7 @@ "naersk": "naersk", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", + "nixpkgs-darwin": "nixpkgs-darwin", "nixpkgs-unstable": "nixpkgs-unstable", "shellcheck-kak": "shellcheck-kak", "similar-sort": "similar-sort", diff --git a/flake.nix b/flake.nix index 5c67c51..e23f5a7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,9 +4,13 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/release-21.05"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-21.05-darwin"; nixos-hardware.url = "github:NixOS/nixos-hardware"; + darwin.url = "github:LnL7/nix-darwin"; + darwin.inputs.nixpkgs.follows = "nixpkgs-darwin"; + home-manager.url = "github:nix-community/home-manager/release-21.05"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; @@ -197,5 +201,14 @@ inputs.home-manager.nixosModules.home-manager ]; }; + + darwinConfigurations.flame = inputs.darwin.lib.darwinSystem { + modules = [ + ({ pkgs, ... }: { + nix.package = pkgs.nixUnstable; + nixpkgs.overlays = mkOverlays "x86_64-darwin"; + }) + ]; + }; }; } diff --git a/machines.sh b/machines.sh index c86f143..3a0cefa 100755 --- a/machines.sh +++ b/machines.sh @@ -1,4 +1,20 @@ #!/usr/bin/env bash set -euo pipefail -nixos-rebuild --flake . "$@" +case "$(uname -s)" in + Linux) + nixos-rebuild --flake . "$@" + ;; + + Darwin) + nix-shell "-p" nixUnstable --run 'nix --experimental-features "nix-command flakes" build .#darwinConfigurations.flame.system' + if test "$@" != "build"; then + ./result/sw/bin/darwin-rebuild --flake . "$@" + fi + ;; + + *) + echo "I don't know how to build on a $(uname -s) system." + exit 1 + ;; +esac