1
0

default.nix 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. , modules ? [ ]
  20. ,
  21. }:
  22. lib.nixosSystem {
  23. inherit system modules;
  24. specialArgs = { inherit inputs outputs; };
  25. };
  26. mkDarwin =
  27. { system
  28. , modules ? [ ]
  29. ,
  30. }:
  31. darwin.lib.darwinSystem {
  32. inherit system modules;
  33. specialArgs = { inherit inputs outputs; };
  34. };
  35. mkHome =
  36. { system
  37. , modules ? [ ]
  38. ,
  39. }:
  40. home-manager.lib.homeManagerConfiguration {
  41. inherit modules;
  42. pkgs = getPkgsForSystem system;
  43. extraSpecialArgs = {
  44. inherit inputs outputs;
  45. isDarwin = isDarwin system;
  46. };
  47. };
  48. mkDevenvShell = config:
  49. eachSystemWithPkgs (
  50. { pkgs }:
  51. lib.mapAttrs
  52. (
  53. _name: module:
  54. devenv.lib.mkShell {
  55. inherit inputs pkgs;
  56. modules = [ module ];
  57. }
  58. )
  59. config
  60. );
  61. allSystems = [
  62. "x86_64-linux"
  63. "x86_64-darwin"
  64. "aarch64-linux"
  65. "aarch64-darwin"
  66. ];
  67. eachSystem = lib.genAttrs allSystems;
  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. }