From 1c4d0e63a15bc4d92c44541a6eaa35c92391d67a Mon Sep 17 00:00:00 2001 From: Stephen Bryant Date: Fri, 3 Jan 2025 18:54:09 -0500 Subject: [PATCH] nix darwin config --- flake-snapshot.nix | 103 +++++++++++++++++++++++++++++ flake.lock | 48 ++++++++++++++ flake.nix | 97 +++++++++++++++++++++++++++ home.nix | 19 ++++++ modules/apps/.DS_Store | Bin 0 -> 6148 bytes modules/apps/1password/default.nix | 50 ++++++++++++++ modules/environment/default.nix | 0 rebuild.sh | 2 + update.sh | 3 + 9 files changed, 322 insertions(+) create mode 100644 flake-snapshot.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 modules/apps/.DS_Store create mode 100644 modules/apps/1password/default.nix create mode 100644 modules/environment/default.nix create mode 100644 rebuild.sh create mode 100644 update.sh diff --git a/flake-snapshot.nix b/flake-snapshot.nix new file mode 100644 index 0000000..fdc19bc --- /dev/null +++ b/flake-snapshot.nix @@ -0,0 +1,103 @@ +{ + description = "Example Darwin system flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-darwin.url = "github:LnL7/nix-darwin"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + }; + + configuration = { pkgs, ... }: { + # List packages installed in system profile. To search by name, run: + # $ nix-env -qaP | grep wget + environment.systemPackages = + [ + pkgs.vim + # pkgs._1password-cli + # pkgs._1password-gui + pkgs.homebrew = { + enable = true; + packages = with pkgs; [ + # homebrew packages + "1password-cli" + "1password" + ]; + }; + ]; + + nix.extraOptions = '' + extra-platforms = x86_64-darwin aarch64-darwin + ''; + # Auto upgrade nix package and the daemon service. + services.nix-daemon.enable = true; + services.tailscale = { + enable = true; + }; + + security.pam.enableSudoTouchIdAuth = true; + + # nix.package = pkgs.nix; + + # Necessary for using flakes on this system. + nix.settings.experimental-features = "nix-command flakes"; + + # Create /etc/zshrc that loads the nix-darwin environment. + programs.zsh.enable = true; # default shell on catalina + # programs.fish.enable = true; + # Enable 1password plugins on interactive shell init + programs.bash.interactiveShellInit = '' + source /home/stephen/.config/op/plugins.sh + ''; + + # Set Git commit hash for darwin-version. + system.configurationRevision = self.rev or self.dirtyRev or null; + + system.defaults = { + dock.autohide = true; + dock.mru-spaces = false; + finder.AppleShowAllExtensions = true; + finder.FXPreferredViewStyle = "clmv"; + loginwindow.LoginwindowText = "swaphb-mba"; + screencapture.location = "~/Pictures/screenshots"; + screensaver.askForPasswordDelay = 10; + }; + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 4; + + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "aarch64-darwin"; + nixpkgs.config = { + allowUnfree = true; + allowBroken = true; + # homebrew = { + # enable = true; + # packages = with pkgs; [ + # # homebrew packages + # "1password-cli" + # "1password" + # ]; + # }; + # allowAliases = true; + # packageOverrides = pkgs: { + # # Add a package to the set. + # _1password-cli = pkgs.callPackage ./pkgs/1password-cli { }; + # _1password-gui = pkgs.callPackage ./pkgs/1password-gui { }; + # }; + }; + }; + in + { + # Build darwin flake using: + # $ darwin-rebuild build --flake .#swaphb-mba + darwinConfigurations."swaphb-mba" = nix-darwin.lib.darwinSystem { + modules = [ configuration ]; + }; + + # Expose the package set, including overlays, for convenience. + darwinPackages = self.darwinConfigurations."swaphb-mba".pkgs; + }; +} + + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..17665ae --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735685839, + "narHash": "sha256-62xAPSs5VRZoPH7eRanUn5S5vZEd+8vM4bD5I+zxokc=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "6a1fdb2a1204c0de038847b601cff5012e162b5e", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1735821806, + "narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d6973081434f88088e5321f83ebafe9a1167c367", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9e70e12 --- /dev/null +++ b/flake.nix @@ -0,0 +1,97 @@ +{ + description = "Example Darwin system flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-darwin.url = "github:LnL7/nix-darwin"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + # home-manager.url = "github:nix-community/home-manager"; + # home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs@{ self, nix-darwin, nixpkgs }: + let + configuration = { pkgs, ... }: { + # List packages installed in system profile. To search by name, run: + # $ nix-env -qaP | grep wget + environment.systemPackages = + [ + pkgs.vim + ]; + + nix.extraOptions = '' + extra-platforms = x86_64-darwin aarch64-darwin + ''; + # Auto upgrade nix package and the daemon service. + services.nix-daemon.enable = true; + services.tailscale = { + enable = true; + }; + + security.pam.enableSudoTouchIdAuth = true; + + # nix.package = pkgs.nix; + + # Necessary for using flakes on this system. + nix.settings.experimental-features = "nix-command flakes"; + + # Create /etc/zshrc that loads the nix-darwin environment. + programs.zsh.enable = true; # default shell on catalina + # programs.fish.enable = true; + # Enable 1password plugins on interactive shell init + programs.bash.interactiveShellInit = '' + source /home/stephen/.config/op/plugins.sh + ''; + + # Set Git commit hash for darwin-version. + system.configurationRevision = self.rev or self.dirtyRev or null; + + system.defaults = { + dock.autohide = true; + dock.mru-spaces = false; + finder.AppleShowAllExtensions = true; + finder.FXPreferredViewStyle = "clmv"; + loginwindow.LoginwindowText = "swaphb-mba"; + screencapture.location = "~/Pictures/screenshots"; + screensaver.askForPasswordDelay = 10; + }; + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 4; + + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "aarch64-darwin"; + nixpkgs.config = { + allowUnfree = true; + allowBroken = true; + # homebrew = { + # enable = true; + # packages = with pkgs; [ + # # homebrew packages + # "1password-cli" + # "1password" + # ]; + # }; + # allowAliases = true; + # packageOverrides = pkgs: { + # # Add a package to the set. + # _1password-cli = pkgs.callPackage ./pkgs/1password-cli { }; + # _1password-gui = pkgs.callPackage ./pkgs/1password-gui { }; + # }; + }; + }; + in + { + # Build darwin flake using: + # $ darwin-rebuild build --flake .#swaphb-mba + darwinConfigurations."swaphb-mba" = nix-darwin.lib.darwinSystem { + modules = [ configuration ]; + }; + + # Expose the package set, including overlays, for convenience. + darwinPackages = self.darwinConfigurations."swaphb-mba".pkgs; + }; +} + + diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..e42e188 --- /dev/null +++ b/home.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: { + home = { + stateVersion = "23.11"; + username = "emiliazapata"; + homeDirectory = "/Users/emiliazapata"; + # Then we add the packages we want in the array using pkgs. + packages = [ + pkgs.git + pkgs.neovim + ]; + }; + # This is to ensure programs are using ~/.config rather than + # /Users/+mc9Nf4}xmWNF7Gs~l7jVFkCfLRyN&BjtD@XI_Lx_1!6G&r5AkD5; zvyV5$(-Qz&zU>yk9Ke+Bh))k=^KqiR>Tz z)BfeKf6kk)QH40R-4t5uT;Ht^m5*78+}XnnlHK=*Fj;3c1($0*9W=4+n!!XYu}%m