From d5193fa2a3b2fea977a871b6cddd7e3e29386d4e Mon Sep 17 00:00:00 2001 From: Louis Gallet Date: Sat, 30 Aug 2025 12:11:32 +0200 Subject: [PATCH] feat: change nix structure --- flake.lock | 21 ++++ flake.nix | 220 +++++++-------------------------------- flake.nix.old | 187 +++++++++++++++++++++++++++++++++ hosts/MBP-Louis.nix | 105 +++++++++++++++++++ hosts/PC-Louis.nix | 5 + modules/apps.nix | 32 ++++++ modules/config.nix | 5 + modules/dotfiles/git.nix | 26 +++++ 8 files changed, 417 insertions(+), 184 deletions(-) create mode 100644 flake.nix.old create mode 100644 hosts/MBP-Louis.nix create mode 100644 hosts/PC-Louis.nix create mode 100644 modules/apps.nix create mode 100644 modules/config.nix create mode 100644 modules/dotfiles/git.nix diff --git a/flake.lock b/flake.lock index fdb1438..4c87c8f 100644 --- a/flake.lock +++ b/flake.lock @@ -17,6 +17,26 @@ "type": "github" } }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1756496801, + "narHash": "sha256-IYIsnPy+cJxe8RbDHBrCtfJY0ry2bG2H7WvMcewiGS8=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "77a71380c38fb2a440b4b5881bbc839f6230e1cb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -73,6 +93,7 @@ }, "root": { "inputs": { + "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", "nixpkgs": "nixpkgs" diff --git a/flake.nix b/flake.nix index 024ab60..440256a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,187 +1,39 @@ { - description = "Louis Darwin system flake"; - inputs = { - nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - nix-darwin.url = "github:LnL7/nix-darwin"; - nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; - }; - outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }: - let - configuration = { pkgs, ... }: { -# List packages installed in system profile. To search by name, run: -# $ nix-env -qaP | grep wget - environment.systemPackages = - [ - pkgs.termdown - pkgs.fastfetch - pkgs.neovim - pkgs.deno - pkgs.pnpm - pkgs.terraform - pkgs.gh-copilot - pkgs.gh - #pkgs.texlab - #pkgs.texliveFull - pkgs.rcm - pkgs.fnm - pkgs.universal-ctags - pkgs.ripgrep - pkgs.pyenv - pkgs.rustup - pkgs.ngrok - pkgs.marp-cli - pkgs.discord - pkgs.yarn - pkgs.typescript - pkgs.firefox - pkgs.warp-terminal - pkgs.raycast - pkgs.bitwarden-desktop - pkgs.jetbrains-toolbox - pkgs.jetbrains.datagrip - pkgs.jetbrains.rider - pkgs.jetbrains.webstorm - pkgs.ffmpeg_6 - ]; - # HomeBrew configuration - homebrew = { - enable = true; - casks = [ - "cyberduck" - #"gpg-suite-no-mail" - "iina" - "keka" - "maccy" - "nordvpn" - "notion" - "swish" - "termius" - "mattermost" - "aldente" - "logi-options+" - "adobe-creative-cloud" - "qbittorrent" - "zoom" - "zed" - "whisky" - "visual-studio-code" - "vmware-fusion" - "pycharm" - "cleanshot" - "bartender" - "chromedriver" - "epic-games" - "alt-tab" - "busycal" - "privileges" - "jdownloader" - "raspberry-pi-imager" - "tailscale-app" - ]; - brews = [ - "wget" - "bear" - "cmake" - "firebase-cli" - "git" - "git-flow" - "git-lfs" - "gnupg" - "llvm@18" - "gtk+3" - "pinentry-mac" - "sdl2" - "sdl2_image" - "sdl2_ttf" - "tmux" - "tree" - "wget" - "zsh" - "yubikey-agent" - "pkg-config" - "serve" - ]; - taps = [ - "hashicorp/tap" - "eranif/codelite" - "macos-fuse-t/homebrew-cask" - ]; - onActivation.cleanup = "uninstall"; - onActivation.autoUpdate = true; - onActivation.upgrade = true; - }; # System configuration - security.pam.services.sudo_local.touchIdAuth = true; - system.defaults = { - dock = { - autohide = true; - orientation = "bottom"; - show-recents = false; - magnification = false; - autohide-time-modifier = 0.0; - persistent-apps = [ - "/System/Applications/Launchpad.app" - "/System/Applications/Messages.app" - "/Applications/Nix Apps/Firefox.app" - "/System/Applications/Mail.app" - "/Applications/BusyCal.app" - "/Applications/Things3.app" - "/System/Applications/Music.app" - "/Applications/Nix Apps/Discord.app" - "/Applications/Zed.app" - "/Applications/Visual\ Studio\ Code.app" - "/Applications/Nix Apps/Warp.app" - "/System/Applications/System\ Settings.app" - "/Applications/Privileges.app" - ]; - }; - finder.FXPreferredViewStyle = "Nlsv"; - SoftwareUpdate.AutomaticallyInstallMacOSUpdates = true; - }; - # Allow broken packages - nixpkgs.config.allowBroken = true; - # allow unfree packages - nixpkgs.config.allowUnfree = true; - # Auto upgrade nix package and the daemon service. - # services.nix-daemon.enable = 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; - # Set Git commit hash for darwin-version. - system.configurationRevision = self.rev or self.dirtyRev or null; - # Used for backwards compatibility, please read the changelog before changing. - # $ darwin-rebuild changelog - system.stateVersion = 5; - system.primaryUser = "louisgallet"; - # The platform the configuration will be used on. - nixpkgs.hostPlatform = "aarch64-darwin"; - }; - in - { - # Build darwin flake using: - # $ darwin-rebuild build --flake .#simple - darwinConfigurations."MBP-Louis" = nix-darwin.lib.darwinSystem { - modules = [ - configuration - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - # Install Homebrew under the default prefix - enable = true; - # Apple Silicon Only: Also install Homebrew under the default Intel prefix for Rosetta 2 - enableRosetta = true; - # User owning the Homebrew prefix - user = "louisgallet"; - # Automatically migrate existing Homebrew installations - autoMigrate = true; - }; - } - ]; - }; - # Expose the package set, including overlays, for convenience. - darwinPackages = self.darwinConfigurations."MBP-Louis".pkgs; + description = "Louis multi-platform flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-darwin.url = "github:LnL7/nix-darwin"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs@{ self, nixpkgs, nix-darwin, nix-homebrew, home-manager, ... }: + let + # Imports communs aux deux machines + commonModules = [ + ./modules/apps.nix + ./modules/config.nix + ./modules/dotfiles/git.nix + ]; + in { + darwinConfigurations."MBP-Louis" = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = commonModules ++ [ + ./hosts/MBP-Louis.nix + nix-homebrew.darwinModules.nix-homebrew + home-manager.darwinModules.home-manager + ]; + }; + + nixosConfigurations."PC-Louis" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = commonModules ++ [ + ./hosts/PC-Louis.nix + home-manager.nixosModules.home-manager + ]; + }; }; } diff --git a/flake.nix.old b/flake.nix.old new file mode 100644 index 0000000..024ab60 --- /dev/null +++ b/flake.nix.old @@ -0,0 +1,187 @@ +{ + description = "Louis Darwin system flake"; + inputs = { + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-darwin.url = "github:LnL7/nix-darwin"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + }; + outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }: + let + configuration = { pkgs, ... }: { +# List packages installed in system profile. To search by name, run: +# $ nix-env -qaP | grep wget + environment.systemPackages = + [ + pkgs.termdown + pkgs.fastfetch + pkgs.neovim + pkgs.deno + pkgs.pnpm + pkgs.terraform + pkgs.gh-copilot + pkgs.gh + #pkgs.texlab + #pkgs.texliveFull + pkgs.rcm + pkgs.fnm + pkgs.universal-ctags + pkgs.ripgrep + pkgs.pyenv + pkgs.rustup + pkgs.ngrok + pkgs.marp-cli + pkgs.discord + pkgs.yarn + pkgs.typescript + pkgs.firefox + pkgs.warp-terminal + pkgs.raycast + pkgs.bitwarden-desktop + pkgs.jetbrains-toolbox + pkgs.jetbrains.datagrip + pkgs.jetbrains.rider + pkgs.jetbrains.webstorm + pkgs.ffmpeg_6 + ]; + # HomeBrew configuration + homebrew = { + enable = true; + casks = [ + "cyberduck" + #"gpg-suite-no-mail" + "iina" + "keka" + "maccy" + "nordvpn" + "notion" + "swish" + "termius" + "mattermost" + "aldente" + "logi-options+" + "adobe-creative-cloud" + "qbittorrent" + "zoom" + "zed" + "whisky" + "visual-studio-code" + "vmware-fusion" + "pycharm" + "cleanshot" + "bartender" + "chromedriver" + "epic-games" + "alt-tab" + "busycal" + "privileges" + "jdownloader" + "raspberry-pi-imager" + "tailscale-app" + ]; + brews = [ + "wget" + "bear" + "cmake" + "firebase-cli" + "git" + "git-flow" + "git-lfs" + "gnupg" + "llvm@18" + "gtk+3" + "pinentry-mac" + "sdl2" + "sdl2_image" + "sdl2_ttf" + "tmux" + "tree" + "wget" + "zsh" + "yubikey-agent" + "pkg-config" + "serve" + ]; + taps = [ + "hashicorp/tap" + "eranif/codelite" + "macos-fuse-t/homebrew-cask" + ]; + onActivation.cleanup = "uninstall"; + onActivation.autoUpdate = true; + onActivation.upgrade = true; + }; # System configuration + security.pam.services.sudo_local.touchIdAuth = true; + system.defaults = { + dock = { + autohide = true; + orientation = "bottom"; + show-recents = false; + magnification = false; + autohide-time-modifier = 0.0; + persistent-apps = [ + "/System/Applications/Launchpad.app" + "/System/Applications/Messages.app" + "/Applications/Nix Apps/Firefox.app" + "/System/Applications/Mail.app" + "/Applications/BusyCal.app" + "/Applications/Things3.app" + "/System/Applications/Music.app" + "/Applications/Nix Apps/Discord.app" + "/Applications/Zed.app" + "/Applications/Visual\ Studio\ Code.app" + "/Applications/Nix Apps/Warp.app" + "/System/Applications/System\ Settings.app" + "/Applications/Privileges.app" + ]; + }; + finder.FXPreferredViewStyle = "Nlsv"; + SoftwareUpdate.AutomaticallyInstallMacOSUpdates = true; + }; + # Allow broken packages + nixpkgs.config.allowBroken = true; + # allow unfree packages + nixpkgs.config.allowUnfree = true; + # Auto upgrade nix package and the daemon service. + # services.nix-daemon.enable = 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; + # Set Git commit hash for darwin-version. + system.configurationRevision = self.rev or self.dirtyRev or null; + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 5; + system.primaryUser = "louisgallet"; + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "aarch64-darwin"; + }; + in + { + # Build darwin flake using: + # $ darwin-rebuild build --flake .#simple + darwinConfigurations."MBP-Louis" = nix-darwin.lib.darwinSystem { + modules = [ + configuration + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + # Install Homebrew under the default prefix + enable = true; + # Apple Silicon Only: Also install Homebrew under the default Intel prefix for Rosetta 2 + enableRosetta = true; + # User owning the Homebrew prefix + user = "louisgallet"; + # Automatically migrate existing Homebrew installations + autoMigrate = true; + }; + } + ]; + }; + # Expose the package set, including overlays, for convenience. + darwinPackages = self.darwinConfigurations."MBP-Louis".pkgs; + }; +} diff --git a/hosts/MBP-Louis.nix b/hosts/MBP-Louis.nix new file mode 100644 index 0000000..50736fe --- /dev/null +++ b/hosts/MBP-Louis.nix @@ -0,0 +1,105 @@ +{ pkgs, ... }: { + # HomeBrew configuration + homebrew = { + enable = true; + casks = [ + "cyberduck" + "iina" + "keka" + "maccy" + "nordvpn" + "notion" + "swish" + "termius" + "mattermost" + "aldente" + "logi-options+" + "adobe-creative-cloud" + "qbittorrent" + "zoom" + "zed" + "whisky" + "visual-studio-code" + "vmware-fusion" + "pycharm" + "cleanshot" + "bartender" + "chromedriver" + "epic-games" + "alt-tab" + "busycal" + "privileges" + "jdownloader" + "raspberry-pi-imager" + "tailscale-app" + ]; + + brews = [ + "wget" + "bear" + "cmake" + "firebase-cli" + "git" + "git-flow" + "git-lfs" + "gnupg" + "llvm@18" + "gtk+3" + "pinentry-mac" + "sdl2" + "sdl2_image" + "sdl2_ttf" + "tmux" + "tree" + "zsh" + "yubikey-agent" + "pkg-config" + "serve" + ]; + + taps = [ + "hashicorp/tap" + "eranif/codelite" + "macos-fuse-t/homebrew-cask" + ]; + + onActivation.cleanup = "uninstall"; + onActivation.autoUpdate = true; + onActivation.upgrade = true; + }; + + # MacOS system configuration + security.pam.services.sudo_local.touchIdAuth = true; + + system.defaults = { + dock = { + autohide = true; + orientation = "bottom"; + show-recents = false; + magnification = false; + autohide-time-modifier = 0.0; + persistent-apps = [ + "/System/Applications/Launchpad.app" + "/System/Applications/Messages.app" + "/Applications/Nix Apps/Firefox.app" + "/System/Applications/Mail.app" + "/Applications/BusyCal.app" + "/Applications/Things3.app" + "/System/Applications/Music.app" + "/Applications/Nix Apps/Discord.app" + "/Applications/Zed.app" + "/Applications/Visual\\ Studio\\ Code.app" + "/Applications/Nix Apps/Warp.app" + "/System/Applications/System\\ Settings.app" + "/Applications/Privileges.app" + ]; + }; + finder.FXPreferredViewStyle = "Nlsv"; + SoftwareUpdate.AutomaticallyInstallMacOSUpdates = true; + }; + + programs.zsh.enable = true; + + system.stateVersion = 5; + system.primaryUser = "louisgallet"; +} diff --git a/hosts/PC-Louis.nix b/hosts/PC-Louis.nix new file mode 100644 index 0000000..81719e6 --- /dev/null +++ b/hosts/PC-Louis.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: { + services.openssh.enable = true; + programs.zsh.enable = true; + system.stateVersion = "25.05"; +} diff --git a/modules/apps.nix b/modules/apps.nix new file mode 100644 index 0000000..a5c976f --- /dev/null +++ b/modules/apps.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: { + environment.systemPackages = with pkgs; [ + termdown + fastfetch + neovim + deno + pnpm + terraform + gh-copilot + gh + rcm + fnm + universal-ctags + ripgrep + pyenv + rustup + ngrok + marp-cli + discord + yarn + typescript + firefox + ffmpeg_6 + warp-terminal + raycast + bitwarden-desktop + jetbrains-toolbox + jetbrains.datagrip + jetbrains.rider + jetbrains.webstorm + ]; +} diff --git a/modules/config.nix b/modules/config.nix new file mode 100644 index 0000000..0f2ff0c --- /dev/null +++ b/modules/config.nix @@ -0,0 +1,5 @@ +{ + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nixpkgs.config.allowBroken = true; + nixpkgs.config.allowUnfree = true; +} diff --git a/modules/dotfiles/git.nix b/modules/dotfiles/git.nix new file mode 100644 index 0000000..0b4ef02 --- /dev/null +++ b/modules/dotfiles/git.nix @@ -0,0 +1,26 @@ +{ pkgs, ... }: { + home-manager.users.louisgallet = { pkgs, ... }: { + programs.git = { + enable = true; + userName = "Louis Gallet"; + userEmail = "me@louisgallet.fr"; + signing = { + key = "9AD287ECD257A6B61ECD592CD4C61677B9CC4C9B"; + signByDefault = true; + }; + extraConfig = { + init.defaultBranch = "master"; + gpg.format = "openpgp"; + gpg.program = + if pkgs.stdenv.isDarwin then "/opt/homebrew/bin/gpg" + else "${pkgs.gnupg}/bin/gpg"; + filter.lfs = { + clean = "git-lfs clean -- %f"; + smudge = "git-lfs smudge -- %f"; + process = "git-lfs filter-process"; + required = true; + }; + }; + }; + }; +}