1
0

default.nix 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 = {
  45. inherit inputs outputs;
  46. isDarwin = isDarwin system;
  47. };
  48. };
  49. mkDevenvShell = config:
  50. eachSystemWithPkgs (
  51. { pkgs }:
  52. lib.mapAttrs
  53. (
  54. _name: module:
  55. devenv.lib.mkShell {
  56. inherit inputs pkgs;
  57. modules = [ module ];
  58. }
  59. )
  60. config
  61. );
  62. eachSystem = lib.genAttrs [
  63. "x86_64-linux"
  64. "x86_64-darwin"
  65. "aarch64-linux"
  66. "aarch64-darwin"
  67. ];
  68. eachSystemWithPkgs = f:
  69. eachSystem (
  70. system:
  71. f {
  72. pkgs = getPkgsForSystem system;
  73. }
  74. );
  75. print = text:
  76. let
  77. json = builtins.toJSON text;
  78. in
  79. builtins.trace (builtins.fromJSON json) (builtins.fromJSON json);
  80. }