diff --git a/flake.lock b/flake.lock index 3f31ab2..6e850eb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "cl-nix-lite": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1766810506, + "narHash": "sha256-I4BxozsEu205tA7jazufztI8ZQ5p7hcCnjqrSKPz9nI=", + "owner": "hraban", + "repo": "cl-nix-lite", + "rev": "038e341cede255a83a8f04af114dc95717461d32", + "type": "github" + }, + "original": { + "owner": "hraban", + "repo": "cl-nix-lite", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -44,6 +65,23 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1730663653, + "narHash": "sha256-kFCUWettiFHDIqxCWWQ9qY8pVh+Lj+XL0Giyy/kdomg=", + "owner": "hraban", + "repo": "flake-compat", + "rev": "e5b16676185cb7548581c852f51ce7f3a49bba5e", + "type": "github" + }, + "original": { + "owner": "hraban", + "ref": "fixed-output", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1767039857, @@ -59,6 +97,44 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1765835352, + "narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "a34fae9c08a15ad73f295041fec82323541400a9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": [ + "mac-app-util", + "systems" + ] + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -79,6 +155,29 @@ "type": "github" } }, + "mac-app-util": { + "inputs": { + "cl-nix-lite": "cl-nix-lite", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_3", + "systems": "systems_2", + "treefmt-nix": "treefmt-nix_2" + }, + "locked": { + "lastModified": 1766810876, + "narHash": "sha256-VPElWFQIiP31lXQXEom+L4sl85alZpZn33O4hewsP9k=", + "owner": "hraban", + "repo": "mac-app-util", + "rev": "4747968574ea58512c5385466400b2364c85d2d0", + "type": "github" + }, + "original": { + "owner": "hraban", + "repo": "mac-app-util", + "type": "github" + } + }, "nix-vscode-extensions": { "inputs": { "nixpkgs": [ @@ -117,8 +216,8 @@ }, "nixos-wsl": { "inputs": { - "flake-compat": "flake-compat", - "nixpkgs": "nixpkgs" + "flake-compat": "flake-compat_2", + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1771563879, @@ -136,6 +235,85 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1766736597, + "narHash": "sha256-BASnpCLodmgiVn0M1MU2Pqyoz0aHwar/0qLkp7CjvSQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f560ccec6b1116b22e6ed15f4c510997d99d5852", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1761236834, + "narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1732617236, + "narHash": "sha256-PYkz6U0bSEaEB1al7O1XsqVNeSNS+s3NVclJw7YC43w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1761236834, + "narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { "locked": { "lastModified": 1770019141, "narHash": "sha256-VKS4ZLNx4PNrABoB0L8KUpc1fE7CLpQXQs985tGfaCU=", @@ -151,7 +329,7 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_6": { "locked": { "lastModified": 1771848320, "narHash": "sha256-0MAd+0mun3K/Ns8JATeHT1sX28faLII5hVLq0L3BdZU=", @@ -172,10 +350,77 @@ "darwin": "darwin", "firefox-addons": "firefox-addons", "home-manager": "home-manager", + "mac-app-util": "mac-app-util", "nix-vscode-extensions": "nix-vscode-extensions", "nixos-hardware": "nixos-hardware", "nixos-wsl": "nixos-wsl", + "nixpkgs": "nixpkgs_6" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1689347925, + "narHash": "sha256-ozenz5bFe1UUqOn7f60HRmgc01BgTGIKZ4Xl+HbocGQ=", + "owner": "nix-systems", + "repo": "default-darwin", + "rev": "2235d7e6cc29ae99878133c95e9fe5e157661ffb", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-darwin", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1766000401, + "narHash": "sha256-+cqN4PJz9y0JQXfAK5J1drd0U05D5fcAGhzhfVrDlsI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "42d96e75aa56a3f70cab7e7dc4a32868db28e8fd", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { + "inputs": { + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1766000401, + "narHash": "sha256-+cqN4PJz9y0JQXfAK5J1drd0U05D5fcAGhzhfVrDlsI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "42d96e75aa56a3f70cab7e7dc4a32868db28e8fd", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 3705bd7..7010c6d 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; + mac-app-util.url = "github:hraban/mac-app-util"; darwin.url = "github:lnl7/nix-darwin/master"; darwin.inputs.nixpkgs.follows = "nixpkgs"; @@ -26,7 +27,7 @@ }; - outputs = { self, darwin,nixpkgs, nixos-hardware, nixos-wsl, home-manager, ... }@inputs: + outputs = { self, darwin, nixpkgs, nixos-hardware, nixos-wsl, home-manager, mac-app-util, ... }@inputs: let system = "x86_64-linux"; pkgs = import nixpkgs { @@ -82,6 +83,7 @@ system = "aarch64-darwin"; modules = [ ./cleo.darwin.nix + mac-app-util.darwinModules.default home-manager.darwinModules.home-manager { home-manager.useGlobalPkgs = true; @@ -93,6 +95,26 @@ ]; }; + darwinConfigurations.hydrogen = darwin.lib.darwinSystem { + specialArgs = { inherit system; inherit inputs; }; + system = "aarch64-darwin"; + modules = [ + ./hydrogen.darwin.nix + mac-app-util.darwinModules.default + home-manager.darwinModules.home-manager + # home-manager.sharedModules = [ + # mac-app-util.homeManagerModules.default + # ] + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { inherit inputs; }; + home-manager.users."mbessette" = import ./hydrogen.home.nix; + home-manager.backupFileExtension = ".before-nix"; + } + ]; + }; + homeManagerModules.default = "./nixos-modules/home-manager"; }; } diff --git a/hydrogen.darwin.nix b/hydrogen.darwin.nix index e69de29..147bab6 100644 --- a/hydrogen.darwin.nix +++ b/hydrogen.darwin.nix @@ -0,0 +1,52 @@ +{ pkgs, inputs, ... }: { + nixpkgs.config.allowUnfree = true; + nixpkgs.overlays = [ inputs.nix-vscode-extensions.overlays.default ]; + ids.gids.nixbld = 350; + security.pam.services.sudo_local.touchIdAuth = true; + + # 1Password SSH Socket + environment.variables.SSH_AUTH_SOCK = "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"; + + # Set vim as default editor + environment.variables.EDITOR = "vim"; + environment.variables.VISUAL = "vim"; + environment.variables.GIT_EDITOR = "vim"; + + # Add Homebrew to PATH + environment.systemPath = [ "/opt/homebrew/bin" "/opt/homebrew/sbin" ]; + + # Biome config + environment.etc."biome.json".source = ./config.biome.json; + environment.etc."oxlintrc.json".source = ./config.oxlintrc.json; + + system.primaryUser = "mbessette"; + users.users."mbessette" = { + name = "mbessette"; + home = "/Users/mbessette"; + }; + + # Homebrew for Casks and specific binaries + # In a nix-darwin setup, Homebrew packages are not actually stored inside the Nix store. + # Instead, nix-darwin acts as a manager that triggers the standard Homebrew installation + # process on your macOS system. + homebrew = { + enable = true; + onActivation.cleanup = "uninstall"; + onActivation.autoUpdate = true; + onActivation.upgrade = true; + taps = [ "bufbuild/buf" "jacobjohansen/tap" ]; + brews = [ + "biome" + ]; + casks = [ + "1password" + "iterm2" + "obsidian" + "signal" + "spotify" + ]; + }; + + nix.settings.experimental-features = "nix-command flakes"; + system.stateVersion = 4; +} diff --git a/hydrogen.home.nix b/hydrogen.home.nix index e69de29..72f58e3 100644 --- a/hydrogen.home.nix +++ b/hydrogen.home.nix @@ -0,0 +1,111 @@ +{ config, pkgs, ... }: { + home.stateVersion = "23.11"; + + home.username = "mbessette"; + home.homeDirectory = "/Users/mbessette"; + + home.packages = with pkgs; [ + # Dev Specs + python3 + pipenv + nodejs_22 + ]; + + # Enable direnv for automatic environment switching + programs.direnv = { + enable = true; + nix-direnv.enable = true; # Better Nix flakes integration with caching + }; + + # Managed VS Code Extensions (The "Clean" Way) + programs.vscode = { + enable = true; + profiles.default = { + userSettings = builtins.fromJSON (builtins.readFile ./config.vscode.settings.json); + extensions = with pkgs.vscode-marketplace; [ + biomejs.biome + bbenoist.nix + eamodio.gitlens + github.copilot-chat + graphql.vscode-graphql-syntax + hashicorp.terraform + mechatroner.rainbow-csv + mermaidchart.vscode-mermaid-chart + ms-python.debugpy + ms-python.python + ms-python.vscode-pylance + oxc.oxc-vscode + redhat.vscode-xml + vscode-icons-team.vscode-icons + typescriptteam.native-preview + ]; + }; + }; + + # Automatically load the 1Password agent in your shell + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + oh-my-zsh.enable = true; + oh-my-zsh.theme = "robbyrussell"; + oh-my-zsh.plugins = [ + "git" + "npm" + ]; + + initContent = '' + export SSH_AUTH_SOCK=~/Library/Group\ Containers/2BU8OCWD5C.com.1password/t/agent.sock + + # Auto-allow direnv for directories with flake.nix + auto_allow_direnv() { + if [[ -f flake.nix ]] && [[ ! -f .envrc ]]; then + echo "use flake" > .envrc + direnv allow + elif [[ -f flake.nix ]] && [[ -f .envrc ]]; then + direnv allow + fi + } + + # Run auto-allow when changing directories + chpwd_functions+=(auto_allow_direnv) + ''; + + shellAliases = { + ll = "ls -l"; + update = "sudo darwin-rebuild switch --flake ~/nixos#hydrogen"; + laws = "aws --endpoint=http://localhost:4566"; + dev = "nix develop -c $SHELL"; + nixos = "code ~/nixos"; + }; + }; + + home.sessionVariables = { + # Points to the Homebrew location mentioned in your caveat + NPM_CONFIG_PREFIX = "${config.home.homeDirectory}/.npm-global"; + }; + + home.sessionPath = [ + "${config.home.homeDirectory}/.npm-global/bin" + ]; + + home.file.".npmrc".text = '' + prefix=${config.home.homeDirectory}/.npm-global + '' ; + + programs.git = { + enable = true; + + settings.user = { + name = "Matthew Bessette"; + email = "bessette.matthew94@gmail.com"; + }; + + settings.init.defaultBranch = "main"; + + # This creates ~/.config/git/ignore and sets core.excludesFile + ignores = [ + ]; + }; +}