{ description = "Martin's NixOS configuration - Based on EmergentMind/nix-config"; inputs = { # # ========= Official NixOS and HM Package Sources ========= # nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; # The next two are for pinning to stable vs unstable regardless of what the above is set to # This is particularly useful when an upcoming stable release is in beta because you can effectively # keep 'nixpkgs-stable' set to stable for critical packages while setting 'nixpkgs' to the beta branch to # get a jump start on deprecation changes. # See also 'stable-packages' and 'unstable-packages' overlays at 'overlays/default.nix" nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-25.05"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; home-manager = { url = "github:nix-community/home-manager/release-25.05"; inputs.nixpkgs.follows = "nixpkgs"; }; home-manager-unstable = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs-unstable"; }; # # ========= Utilities ========= # # Secrets management sops-nix = { url = "github:mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; # Catppuccin theming catppuccin.url = "github:catppuccin/nix"; simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-25.05"; # Spotify spicetify-nix = { url = "github:Gerg-L/spicetify-nix"; inputs.nixpkgs.follows = "nixpkgs-unstable"; }; # Browser zen-browser.url = "github:0xc000022070/zen-browser-flake"; }; outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, home-manager-unstable, ... }@inputs: let inherit (self) outputs; common = import ./shared/common.nix; theme = import ./shared/theme.nix; # # ========= Architectures ========= # forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]; systems = import ./systems.nix { inherit common; }; in { # # ========= Overlays ========= # # Custom modifications/overrides to upstream packages overlays = import ./overlays.nix { inherit inputs; }; # # ========= Host Configurations ========= # nixosConfigurations = builtins.mapAttrs ( hostName: { system, username, nixos, ... }@systemConfig: let pkgs = if nixos.channel == "stable" then nixpkgs else nixpkgs-unstable; hm = if nixos.channel == "stable" then home-manager else home-manager-unstable; # ========== Extend lib with lib.custom ========== # NOTE: This approach allows lib.custom to propagate into hm # see: https://github.com/nix-community/home-manager/pull/3454 customLib = (_self: _super: { custom = import ./lib { inherit (pkgs) lib; }; }); lib = pkgs.lib.extend customLib; libHm = hm.lib.extend customLib; in pkgs.lib.nixosSystem { inherit system; specialArgs = { inherit outputs inputs common theme lib hostName systemConfig systems ; isDarwin = false; }; modules = [ ./hosts/${hostName} hm.nixosModules.home-manager { home-manager = { # Backups conflicting files in case of error backupFileExtension = "bkp"; useGlobalPkgs = true; useUserPackages = true; extraSpecialArgs = { inherit inputs common theme libHm systemConfig systems ; }; users.${username} = import ./hosts/${hostName}/home-manager; }; } { nixpkgs.overlays = [ # TODO temp fix for tailscale: https://github.com/tailscale/tailscale/issues/16966#issuecomment-3239543750 (_: prev: { tailscale = prev.tailscale.overrideAttrs (old: { checkFlags = builtins.map ( flag: if prev.lib.hasPrefix "-skip=" flag then flag + "|^TestGetList$|^TestIgnoreLocallyBoundPorts$|^TestPoller$" else flag ) old.checkFlags; }); }) ]; } ]; } ) systems; # # ========= Formatting ========= # # Nix formatter available through 'nix fmt' https://github.com/NixOS/nixfmt formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); # # ========= DevShell ========= # # Custom shell for bootstrapping on new hosts, modifying nix-config, and secrets management devShells = forAllSystems ( system: import ./shell.nix { pkgs = nixpkgs.legacyPackages.${system}; } ); }; }