diff --git a/flake.lock b/flake.lock index 4c0ac19..6e1b77d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1651916036, + "narHash": "sha256-UuD9keUGm4IuVEV6wdSYbuRm7CwfXE63hVkzKDjVsh4=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "2f2bdf658d2b79bada78dc914af99c53cad37cba", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -106,6 +127,7 @@ }, "root": { "inputs": { + "darwin": "darwin", "home-manager": "home-manager", "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 5a03b2a..cf81d1c 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,11 @@ }; }; + darwin = { + url = "github:lnl7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + home-manager = { url = "github:rycee/home-manager/release-22.05"; inputs = { @@ -23,7 +28,7 @@ }; }; - outputs = { self, nixpkgs, unstable, nur, utils, nixos-wsl, home-manager, ... }@inputs: { + outputs = { self, nixpkgs, unstable, nur, utils, nixos-wsl, darwin, home-manager, ... }@inputs: { # This repo's overlay plus any other overlays you use # If you want to use packages from flakes that are not nixpkgs (such as NUR), add their overlays here.\ @@ -85,6 +90,23 @@ }; + darwinConfigurations = { + mac = darwin.lib.darwinSystem { + system = "aarch64-darwin"; + specialArgs = { inherit inputs; }; + modules = [ + self.overlaysModule + home-manager.darwinModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.michael = import ./user/environments/mac/home.nix; + } + + ./machines/mac/configuration.nix + ]; + }; + }; + homeConfigurations = { nixos = inputs.home-manager.lib.homeManagerConfiguration { system = "x86_64-linux"; @@ -115,6 +137,21 @@ ]; }; }; + + mac = inputs.home-manager.lib.homeManagerConfiguration { + system = "aarch64-darwin"; + homeDirectory = "/Users/michael"; + username = "michael"; + stateVersion = "22.05"; + configuration = { config, pkgs, ... }: + { + programs.home-manager.enable = true; + + imports = [ + ./user/environments/mac/home.nix + ]; + }; + }; }; }; diff --git a/machines/mac/configuration.nix b/machines/mac/configuration.nix new file mode 100644 index 0000000..65ae383 --- /dev/null +++ b/machines/mac/configuration.nix @@ -0,0 +1,66 @@ +{ config, pkgs, ... }: + +{ + users.users.michael = { + home = "/Users/michael"; + shell = pkgs.zsh; + }; + + networking = { + computerName = "neptune"; + hostName = "neptune"; + }; + + environment = { + shells = with pkgs; [ zsh ]; + variables = { + EDITOR = "micro"; + VISUAL = "micro"; + }; + systemPackages = with pkgs; [ + # Terminal + git + micro + ]; + }; + + programs = { + zsh.enable = true; + }; + + services = { + nix-daemon.enable = true; + }; + + homebrew = { + enable = true; + autoUpdate = true; # Auto update packages + cleanup = "zap"; # Uninstall not listed packages and casks + brews = [ + ]; + casks = [ + ]; + }; + + nixpkgs = { + config.allowBroken = true; # Workaround for pyopenssl being marked broken + }; + + nix = { + package = pkgs.nix; + gc = { + automatic = true; + interval.Day = 7; + options = "--delete-older-than 7d"; + }; + extraOptions = '' + auto-optimise-store = true + experimental-features = nix-command flakes + ''; + }; + + system = { + activationScripts.postActivation.text = ''sudo chsh -s ${pkgs.zsh}/bin/zsh''; # Since it's not possible to declare default shell, run this command after build + stateVersion = 4; + }; +} diff --git a/user/environments/mac/home.nix b/user/environments/mac/home.nix index 7febef6..2582275 100644 --- a/user/environments/mac/home.nix +++ b/user/environments/mac/home.nix @@ -1,13 +1,31 @@ { config, pkgs, ... }: { imports = [ - ../../modules/home-manager.nix ../../modules/zsh.nix ../../modules/dev.nix + ../../modules/git.nix ../../modules/fonts.nix ]; home.packages = with pkgs; [ neofetch ]; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + # Home Manager needs a bit of information about you and the + # paths it should manage. + home.username = "michael"; + home.homeDirectory = "/Users/michael"; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "22.05"; } \ No newline at end of file