1
0

default.nix 1.6 KB

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