{ description = "Cross-platform nix config for macOS and Linux"; inputs = { # Nixpkgs nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; # You can access packages and modules from different nixpkgs revs # at the same time. Here's an working example: nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # Also see the 'unstable-packages' overlay at 'overlays/default.nix'. # Home manager home-manager.url = "github:nix-community/home-manager/release-25.05"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; # nix-darwin for macOS darwin.url = "github:LnL7/nix-darwin/nix-darwin-25.05"; darwin.inputs.nixpkgs.follows = "nixpkgs"; # Doom Emacs via nix-doom-emacs-unstraightened # https://github.com/marienz/nix-doom-emacs-unstraightened nix-doom-emacs-unstraightened.url = "github:marienz/nix-doom-emacs-unstraightened"; # Optional: reduce download size by not pulling in nixpkgs from this input nix-doom-emacs-unstraightened.inputs.nixpkgs.follows = ""; # Emacs overlay for latest Emacs builds with native-comp emacs-overlay.url = "github:nix-community/emacs-overlay"; emacs-overlay.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, home-manager, darwin, ... } @ inputs: let # Supported systems for your flake packages, shell, etc. systems = [ "aarch64-linux" "i686-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; # This is a function that generates an attribute by calling a function you # pass to it, with each system as an argument forAllSystems = nixpkgs.lib.genAttrs systems; in { # Your custom packages # Accessible through 'nix build', 'nix shell', etc packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); # Formatter for your nix files, available through 'nix fmt' # Other options beside 'alejandra' include 'nixpkgs-fmt' formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); # Your custom packages and modifications, exported as overlays overlays = import ./overlays {inherit inputs;}; # Reusable nixos modules you might want to export # These are usually stuff you would upstream into nixpkgs nixosModules = import ./modules/nixos; # Reusable home-manager modules you might want to export # These are usually stuff you would upstream into home-manager homeManagerModules = import ./modules/home-manager; # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { # FIXME replace with your hostname your-hostname = nixpkgs.lib.nixosSystem { specialArgs = {inherit inputs;}; modules = [ # > Our main nixos configuration file < ./nixos/configuration.nix # Integrate home-manager as a NixOS module home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.extraSpecialArgs = {inherit inputs;}; home-manager.sharedModules = [ inputs.nix-doom-emacs-unstraightened.homeModule ]; # FIXME: Replace with your username home-manager.users.your-username = import ./home-manager/home.nix; } ]; }; }; # nix-darwin configuration entrypoint # Available through 'darwin-rebuild switch --flake .#m2n1' darwinConfigurations = { # FIXME replace with your hostname m2n1 = darwin.lib.darwinSystem { specialArgs = {inherit inputs;}; modules = [ # > Our main darwin configuration file < ./darwin/configuration.nix # Integrate home-manager as a darwin module home-manager.darwinModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.extraSpecialArgs = {inherit inputs;}; home-manager.sharedModules = [ inputs.nix-doom-emacs-unstraightened.homeModule ]; home-manager.users.df = import ./home-manager/home.nix; } ]; }; }; # Standalone home-manager configuration entrypoint # Available through 'home-manager --flake .#your-username@your-hostname' # Useful for systems where you don't have root access homeConfigurations = { # FIXME replace with your username@hostname "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # FIXME: Set to your architecture extraSpecialArgs = {inherit inputs;}; modules = [ inputs.nix-doom-emacs-unstraightened.homeModule # > Our main home-manager configuration file < ./home-manager/home.nix ]; }; }; }; }