{ inputs = { # Upstream deps nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixos-hardware.url = "github:NixOS/nixos-hardware"; # Packages home-manager.url = "github:nix-community/home-manager/master"; home-manager.inputs.nixpkgs.follows = "nixpkgs-stable"; catppuccin.url = "github:catppuccin/nix"; fcc-unlock = { url = "git+file:///etc/nixos/fcc-unlock"; inputs.nixos-stable.follows = "nixpkgs-stable"; }; }; outputs = { self, nixpkgs-unstable, nixpkgs-stable, home-manager, nixos-hardware, fcc-unlock, catppuccin, ... }@inputs: let system = "x86_64-linux"; pkgsUnstable = import nixpkgs-unstable { inherit system; config.allowUnfree = true; # For vscode }; hosts = [ "speer" "hummelberg" "ochsenchopf" ]; in { # Build with `nixos-rebuild --flake .#` or # `nix build .#nixosConfigurations..config.system.build.toplevel nixosConfigurations = let sharedSpecialArgs = { inherit pkgsUnstable; pkgFccUnlock = fcc-unlock.packages.${system}.default; }; home-manager-config = { home-manager = { backupFileExtension = ".hm-bak"; useGlobalPkgs = true; useUserPackages = true; extraSpecialArgs = sharedSpecialArgs; users.fhauser.imports = [ ./home/fhauser/default.nix catppuccin.homeManagerModules.catppuccin ]; }; }; mapHostnameToAttr = host: nixpkgs-stable.lib.nixosSystem { inherit system; specialArgs = sharedSpecialArgs // { hardwareModules = nixos-hardware.nixosModules; }; modules = [ home-manager.nixosModules.home-manager catppuccin.nixosModules.catppuccin ./host/${host}/default.nix ] ++ (if host == "bachtel" then [ ] else [ home-manager-config ]); }; in pkgsUnstable.lib.genAttrs hosts mapHostnameToAttr; # Nix development shell devShells.${system}.default = import ./shell.nix { pkgs = pkgsUnstable; }; # Run checks and build all hosts as default package packages.${system}.default = with pkgsUnstable.lib; let checks = attrValues self.checks.${system}; nixosConfigs = mapAttrsToList (n: v: v.config.system.build.toplevel) self.nixosConfigurations; in pkgsUnstable.linkFarmFromDrvs "allHosts" (checks ++ nixosConfigs); formatter.${system} = pkgsUnstable.nixfmt-rfc-style; }; }