From e6ce4f526b1e876f0c2b29fe45cbab17901534dc Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Wed, 18 Dec 2024 21:55:46 -0500 Subject: [PATCH] added some pkgs and went back to usng stow --- nix-darwin/.config/nix-darwin/flake.nix | 192 +++++++++++------------- nix-darwin/.config/nix-darwin/home.nix | 109 ++++++++------ 2 files changed, 147 insertions(+), 154 deletions(-) diff --git a/nix-darwin/.config/nix-darwin/flake.nix b/nix-darwin/.config/nix-darwin/flake.nix index 9b9fe41..bb4b86c 100644 --- a/nix-darwin/.config/nix-darwin/flake.nix +++ b/nix-darwin/.config/nix-darwin/flake.nix @@ -16,33 +16,52 @@ let userConfig = import ./user.nix; inherit (userConfig) username hostname; + configuration = { pkgs, config, ... }: { # Allow unfree packages nixpkgs.config.allowUnfree = true; - nixpkgs.system = "aarch64-darwin"; - # Dynamically set the home directory + # User configuration users.users.${username} = { - home = "/Users/jfraeys/"; + home = "/Users/${username}"; shell = pkgs.zsh; }; - # System packages and fonts + # System packages environment.systemPackages = with pkgs; [ - mkalias neovim wezterm git ripgrep fd pyenv mos teams docker docker-compose atac gh rustup - sd sphinx starship stow tree zoxide spotify direnv unibilium uv zathura raycast skim eza - fzf zsh gettext python3 pyright ruff lua luarocks bat go openssl + neovim wezterm git ripgrep fd pyenv mos docker docker-compose gh rustup + sd sphinx starship stow tree zoxide spotify direnv unibilium uv raycast skim + eza fzf zsh gettext python3 ruff lua luarocks bat go openssl topgrade vault + yamllint + + (zathura.overrideAttrs (finalAttrs: previousAttrs: { + pname = previousAttrs.pname + "-with-synctex"; + nativeBuildInputs = previousAttrs.nativeBuildInputs or [] ++ [ pkgs.pkg-config ]; + enableSynctex = true; + zathuraPlugins = [ "zathura-pdf-poppler" ]; + })) ]; - fonts.packages = with pkgs; [ - nerd-fonts.meslo - ]; + # Fonts + fonts.packages = with pkgs; [ nerd-fonts.meslo-lg ]; - # Homebrew configuration + # Homebrew setup homebrew = { enable = true; brews = [ "mas" "shpotify" "zathura-pdf-poppler" "girara" ]; - casks = [ "zotero" "firefox" "aerospace" "logi-options+" "hiddenbar" "miniforge" "google-drive" "vscodium" "mactex-no-gui" ]; + casks = [ + { name = "zotero"; greedy = true; } + { name = "microsoft-teams"; greedy = true; } + { name = "firefox"; greedy = true; } + { name = "aerospace"; greedy = true; } + { name = "logi-options+"; greedy = true; } + { name = "hiddenbar"; greedy = true; } + { name = "insomnia"; greedy=true; } + { name = "miniforge"; greedy = true; } + { name = "google-drive"; greedy = true; } + { name = "vscodium"; greedy = true; } + { name = "mactex-no-gui"; greedy = true; } + ]; masApps = { "notability" = 360593530; }; taps = [ "nikitabobko/tap" "zegervdv/zathura" ]; onActivation = { @@ -52,74 +71,38 @@ }; }; - # # System activation script for Applications - # system.activationScripts.applications.text = let - # env = pkgs.buildEnv { - # name = "system-applications"; - # paths = config.environment.systemPackages; - # pathsToLink = "/Applications"; - # }; - # in - # pkgs.lib.mkForce '' - # echo "Setting up /Applications..." >&2 - # rm -rf /Applications/Nix\ Apps - # mkdir -p /Applications/Nix\ Apps - # for app in ${env}/Applications/*; do - # ln -s "$app" "/Applications/Nix Apps/$(basename "$app")" - # done - # ''; + # System activation scripts + system.activationScripts = { + applications.text = let + env = pkgs.buildEnv { + name = "system-applications"; + paths = config.environment.systemPackages; + pathsToLink = "/Applications"; + }; + in pkgs.lib.mkForce '' + echo "Setting up /Applications..." >&2 - system.activationScripts.applications.text = let - env = pkgs.buildEnv { - name = "system-applications"; - paths = config.environment.systemPackages; - pathsToLink = "/Applications"; - }; - - # Function to handle errors and log messages - handleError = message: '' - echo "ERROR: ${message}" >&2 - exit 1 + [ ! -d "/Applications" ] && echo "ERROR: /Applications does not exist." && exit 1 + rm -rf "/Applications/Nix Apps" + mkdir -p "/Applications/Nix Apps" + for app in ${env}/Applications/*; do + [ -e "$app" ] && ln -s "$app" "/Applications/Nix Apps/$(basename "$app")" + done + echo "Applications setup complete." ''; - - in pkgs.lib.mkForce '' - echo "Setting up /Applications..." >&2 - - # Ensure /Applications exists - if [ ! -d "/Applications" ]; then - ${handleError "Directory /Applications does not exist"} - fi - - # Remove existing Nix Apps folder if it exists - if [ -d "/Applications/Nix Apps" ]; then - echo "Removing existing /Applications/Nix Apps folder..." - rm -rf "/Applications/Nix Apps" || ${handleError "Failed to remove existing /Applications/Nix Apps"} - fi - - # Create new Nix Apps directory - echo "Creating /Applications/Nix Apps directory..." - mkdir -p "/Applications/Nix Apps" || ${handleError "Failed to create /Applications/Nix Apps"} - - # Symlink applications to /Applications - for app in ${env}/Applications/*; do - if [ -e "$app" ]; then - ln -s "$app" "/Applications/Nix Apps/$(basename "$app")" || ${handleError "Failed to symlink $app"} - else - echo "Warning: $app does not exist, skipping symlink." >&2 - fi - done - - echo "Applications setup complete." - ''; - - # System defaults - system.defaults = { - dock.autohide = true; - loginwindow.GuestEnabled = false; - NSGlobalDomain.AppleICUForce24HourTime = true; }; - # Enable alternative shell support in nix-darwin. + system = { + configurationRevision = self.rev or self.dirtyRev or null; + stateVersion = 5; + defaults = { + dock.autohide = true; + loginwindow.GuestEnabled = false; + NSGlobalDomain.AppleICUForce24HourTime = true; + }; + }; + + # Zsh configuration programs.zsh = { enable = true; shellInit = '' @@ -128,26 +111,17 @@ ''; }; - # Configure LuaRocks to use local installation by default + # LuaRocks setup system.activationScripts.luarocksConfig.text = '' mkdir -p "$HOME/.luarocks" - echo 'local_by_default = true' > "$HOME/.luarocks/config-5.2.lua" + echo 'local_by_default = true' > "$HOME/.luarocks/config-5.4.lua" ''; - # Track configuration version with Git commit hash - system.configurationRevision = self.rev or self.dirtyRev or null; - - # Enable nix-daemon for flake support and updates + # Enable Nix daemon and Touch ID services.nix-daemon.enable = true; - nix.settings.experimental-features = "nix-command flakes"; - - # Set state version to match nix-darwin version - system.stateVersion = 5; - - # Enable Touch ID for sudo security.pam.enableSudoTouchIdAuth = true; - # Home Manager configuration + # Home Manager integration home-manager = { useGlobalPkgs = true; useUserPackages = true; @@ -155,26 +129,32 @@ backupFileExtension = "backup"; }; - # Enable build users for nix-darwin - nix.configureBuildUsers = true; - nix.useDaemon = true; + # Nix configuration + nix = { + configureBuildUsers = true; + useDaemon = true; + settings.experimental-features = [ "nix-command" "flakes" ]; + }; }; in { - darwinConfigurations."${hostname}" = nix-darwin.lib.darwinSystem { - modules = [ - configuration - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - enable = true; - enableRosetta = true; # For Apple Silicon with Rosetta - user = "${username}"; - autoMigrate = true; - }; - } - home-manager.darwinModules.home-manager - ]; + darwinConfigurations = { + "${hostname}" = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + configuration + nix-homebrew.darwinModules.nix-homebrew + home-manager.darwinModules.home-manager + { + nix-homebrew = { + enable = true; + enableRosetta = true; # Enable Rosetta for Apple Silicon + user = "${username}"; + autoMigrate = true; + }; + } + ]; + }; }; }; } diff --git a/nix-darwin/.config/nix-darwin/home.nix b/nix-darwin/.config/nix-darwin/home.nix index 0e4db68..ceac075 100644 --- a/nix-darwin/.config/nix-darwin/home.nix +++ b/nix-darwin/.config/nix-darwin/home.nix @@ -2,61 +2,74 @@ { # General home configuration - home.username = "jfraeys"; - home.homeDirectory = "/Users/jfraeys/"; - home.stateVersion = "23.05"; # Match your NixOS/Home Manager version. + home = { + username = "jfraeys"; + homeDirectory = "/Users/jfraeys"; + stateVersion = "25.05"; # Match your NixOS/Home Manager version. - # Define packages to install - home.packages = with pkgs; [ + # Define packages to install + packages = with pkgs; [ zsh - neovim - wezterm - starship - fzf - ripgrep - bat - lazygit - zoxide - ]; + neovim + wezterm + starship + fzf + ripgrep + bat + lazygit + zoxide + ]; - # File management - home.file = { - ".zshrc".source = ~/.dotfiles/zsh/.zshrc; - # ".zshenv".source = ~/.dotfiles/zsh/.zshenv; - # ".zprofile".source = ~/.dotfiles/zsh/.zprofile; - # ".fzf.zsh".source = ~/.dotfiles/zsh/.fzf.zsh; - # ".config/wezterm".source = ~/.dotfiles/wezterm; - # ".config/starship".source = ~/.dotfiles/starship; - # ".config/nvim".source = ~/.dotfiles/nvim; - # ".config/aerospace".source = ~/.dotfiles/aerospace; - # ".config/gh".source = ~/.dotfiles/gh; - # ".config/nix-darwin".source = ~/.dotfiles/nix-darwin; + # File management + file = { + # ".zshrc".source = ~/.dotfiles/zsh/.zshrc; + # ".zshenv".source = "/Users/jfraeys/.dotfiles/zsh/.zshenv"; + # ".zprofile".source = "/Users/jfraeys/.dotfiles/zsh/.zprofile"; + # ".fzf.zsh".source = "/Users/jfraeys/.dotfiles/zsh/.fzf.zsh"; + # ".ipython".source = "/Users/jfraeys/.dotfiles/jupyter/.ipython"; + # ".jupyter".source = "/Users/jfraeys/.dotfiles/jupyter/.jupyter"; + # ".parallel".source = "/Users/jfraeys/.dotfiles/parallel/.parallel"; + # "terraform.d".source = "/Users/jfraeys/.dotfiles/terraform/terraform.d"; + # ".vim".source = "/Users/jfraeys/.dotfiles/vim/.vim"; + # ".vimrc".source = "/Users/jfraeys/.dotfiles/vim/.vimrc"; + # ".tox".source = "/Users/jfraeys/.dotfiles/tox/.tox"; + # ".wezterm.lua".source = "/Users/jfraeys/.dotfiles/wezterm/.wezterm.lua"; + # ".gitconfig".source = "/Users/jfraeys/.dotfiles/git/.gitconfig"; + # ".config/wezterm".source = "/Users/jfraeys/.dotfiles/wezterm/config/wezterm"; + # ".config/starship".source = ~/.dotfiles/starship; + # ".config/nvim".source = "/Users/jfraeys/.dotfiles/nvim/.config/nvim"; + # ".config/aerospace".source = "/Users/jfraeys/.dotfiles/aerospace/.config/aerospace"; + # ".config/gh".source = "/Users/jfraeys/.dotfiles/gh/.config/gh"; + # ".config/nix-darwin".source = "/Users/jfraeys/.dotfiles/nix-darwin/.config/nix-darwin"; + }; + + # Session variables + sessionVariables = { + PATH = "${pkgs.coreutils}/bin:${pkgs.gnugrep}/bin:/run/current-system/sw/bin:$HOME/.nix-profile/bin"; + }; + + # Session PATH configuration + sessionPath = [ + "/run/current-system/sw/bin" + "$HOME/.nix-profile/bin" + ]; }; - # Session variables - home.sessionVariables = { - PATH = "${pkgs.coreutils}/bin:${pkgs.gnugrep}/bin:/run/current-system/sw/bin:$HOME/.nix-profile/bin"; - }; - - # Session PATH configuration - home.sessionPath = [ - "/run/current-system/sw/bin" - "$HOME/.nix-profile/bin" - ]; - # Enable Home Manager - programs.home-manager.enable = true; + programs = { + home-manager.enable = true; - # Zsh configuration - programs.zsh = { - enable = true; - oh-my-zsh.enable = false; # No Oh-My-Zsh - initExtra = '' - export PATH=/run/current-system/sw/bin:$HOME/.nix-profile/bin:$PATH - if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then - . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' - fi - ''; + # Zsh configuration + zsh = { + enable = true; + oh-my-zsh.enable = false; + initExtra = '' + export PATH=/run/current-system/sw/bin:$HOME/.nix-profile/bin:$PATH + if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then + . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' + fi + ''; + }; }; }