default.nix 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. { inputs, outputs }:
  2. let
  3. # Helper to determine if a system is Darwin
  4. isDarwin = system: builtins.elem "darwin" (builtins.split "-" system);
  5. # Helper to get the appropriate nixpkgs for a system
  6. getPkgsForSystem =
  7. system:
  8. if isDarwin system then
  9. inputs.nixpkgs-darwin.legacyPackages.${system}
  10. else
  11. inputs.nixpkgs.legacyPackages.${system};
  12. in
  13. rec {
  14. mkSystem =
  15. {
  16. system,
  17. nixpkgs ? inputs.nixpkgs,
  18. modules ? [ ],
  19. }:
  20. inputs.nixpkgs.lib.nixosSystem {
  21. inherit system modules nixpkgs;
  22. specialArgs = { inherit inputs outputs; };
  23. };
  24. mkDarwin =
  25. {
  26. system,
  27. modules ? [ ],
  28. }:
  29. inputs.darwin.lib.darwinSystem {
  30. inherit system modules;
  31. specialArgs = { inherit inputs outputs; };
  32. };
  33. mkHome =
  34. {
  35. system,
  36. modules ? [ ],
  37. }:
  38. inputs.home-manager.lib.homeManagerConfiguration {
  39. inherit modules;
  40. pkgs = getPkgsForSystem system;
  41. extraSpecialArgs = { inherit inputs outputs; };
  42. };
  43. eachSystem = inputs.nixpkgs.lib.genAttrs [
  44. "x86_64-linux"
  45. "x86_64-darwin"
  46. "aarch64-linux"
  47. "aarch64-darwin"
  48. ];
  49. eachSystemWithPkgs =
  50. f:
  51. eachSystem (
  52. system:
  53. f {
  54. pkgs = getPkgsForSystem system;
  55. }
  56. );
  57. }