1
0

default.nix 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. { inputs
  2. , outputs
  3. ,
  4. }:
  5. let
  6. inherit (inputs) darwin devenv home-manager nixpkgs;
  7. inherit (nixpkgs) lib;
  8. # Helper to determine if a system is Darwin
  9. isDarwin = system: builtins.elem "darwin" (builtins.split "-" system);
  10. # Helper to get the appropriate nixpkgs for a system
  11. getPkgsForSystem = system:
  12. if isDarwin system
  13. then inputs.nixpkgs-darwin.legacyPackages.${system}
  14. else inputs.nixpkgs.legacyPackages.${system};
  15. in
  16. rec {
  17. mkSystem =
  18. { system
  19. , nixpkgs ? nixpkgs
  20. , modules ? [ ]
  21. ,
  22. }:
  23. lib.nixosSystem {
  24. inherit system modules nixpkgs;
  25. specialArgs = { inherit inputs outputs; };
  26. };
  27. mkDarwin =
  28. { system
  29. , modules ? [ ]
  30. ,
  31. }:
  32. darwin.lib.darwinSystem {
  33. inherit system modules;
  34. specialArgs = { inherit inputs outputs; };
  35. };
  36. mkHome =
  37. { system
  38. , modules ? [ ]
  39. ,
  40. }:
  41. home-manager.lib.homeManagerConfiguration {
  42. inherit modules;
  43. pkgs = getPkgsForSystem system;
  44. extraSpecialArgs = { inherit inputs outputs; };
  45. };
  46. mkDevenvShell = config:
  47. eachSystemWithPkgs (
  48. { pkgs }:
  49. lib.mapAttrs
  50. (
  51. _name: module:
  52. devenv.lib.mkShell {
  53. inherit inputs pkgs;
  54. modules = [ module ];
  55. }
  56. )
  57. config
  58. );
  59. eachSystem = lib.genAttrs [
  60. "x86_64-linux"
  61. "x86_64-darwin"
  62. "aarch64-linux"
  63. "aarch64-darwin"
  64. ];
  65. eachSystemWithPkgs = f:
  66. eachSystem (
  67. system:
  68. f {
  69. pkgs = getPkgsForSystem system;
  70. }
  71. );
  72. print = text:
  73. let
  74. json = builtins.toJSON text;
  75. in
  76. builtins.trace (builtins.fromJSON json) (builtins.fromJSON json);
  77. }