1
0

flake.nix 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. {
  2. description = "Nix Dotfiles with flake";
  3. inputs = {
  4. nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
  5. home-manager = {
  6. url = "github:nix-community/home-manager/release-26.05";
  7. inputs.nixpkgs.follows = "nixpkgs";
  8. };
  9. nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.7.0";
  10. mangowm = {
  11. url = "github:mangowm/mango";
  12. inputs.nixpkgs.follows = "nixpkgs";
  13. };
  14. nixvim = {
  15. url = "github:nix-community/nixvim";
  16. };
  17. something-x = {
  18. url = "github:SoaOaoS/something-x";
  19. inputs.nixpkgs.follows = "nixpkgs";
  20. };
  21. dux = {
  22. url = "github:duxlabs-dev/dux-shell/stable";
  23. inputs.nixpkgs.follows = "nixpkgs";
  24. };
  25. dux-greeter = {
  26. url = "github:duxlabs-dev/dux-greeter";
  27. inputs.nixpkgs.follows = "nixpkgs";
  28. };
  29. dux-files = {
  30. url = "github:duxlabs-dev/dux-files";
  31. inputs.nixpkgs.follows = "nixpkgs";
  32. };
  33. hypryou = {
  34. url = "github:johron/hyprland-material-you";
  35. inputs.nixpkgs.follows = "nixpkgs";
  36. };
  37. };
  38. outputs =
  39. {
  40. self,
  41. nix-flatpak,
  42. ...
  43. }@inputs:
  44. let
  45. lib = inputs.nixpkgs.lib;
  46. hosts = import ./config/hosts.nix;
  47. mkHomeConfigurations =
  48. {
  49. host,
  50. nixpkgs,
  51. home-manager,
  52. modules ? [ ],
  53. }:
  54. home-manager.lib.homeManagerConfiguration {
  55. pkgs = import nixpkgs {
  56. system = host.arch;
  57. config = {
  58. allowUnfree = true;
  59. };
  60. };
  61. extraSpecialArgs = { inherit inputs host; };
  62. modules = [
  63. ./hosts/${host.dir}/home
  64. ] ++ modules;
  65. };
  66. mkNixOSConfigurations =
  67. {
  68. host,
  69. nixpkgs,
  70. home-manager,
  71. modules ? [ ],
  72. overlays ? [],
  73. }:
  74. nixpkgs.lib.nixosSystem {
  75. system = host.arch;
  76. specialArgs = {
  77. inherit inputs host;
  78. };
  79. modules = [
  80. nix-flatpak.nixosModules.nix-flatpak
  81. ./hosts/${host.dir}/nixos
  82. { nixpkgs.overlays = overlays; }
  83. home-manager.nixosModules.home-manager
  84. {
  85. home-manager.extraSpecialArgs = { inherit inputs host; };
  86. home-manager.useGlobalPkgs = true;
  87. home-manager.useUserPackages = true;
  88. home-manager.backupFileExtension = "backup";
  89. home-manager.users."${host.user}" = import ./hosts/${host.dir}/home;
  90. }
  91. ] ++ modules;
  92. };
  93. mkISOConfiguration = # Build with: nix build .#nixosConfigurations.<hostname>-iso.config.system.build.isoImage
  94. {
  95. host,
  96. nixpkgs,
  97. }:
  98. nixpkgs.lib.nixosSystem {
  99. system = host.arch;
  100. modules = [
  101. ./hosts/${host.dir}/iso.nix
  102. { networking.hostName = "${host.hostname}-iso"; }
  103. ];
  104. };
  105. in
  106. {
  107. nixosConfigurations =
  108. lib.mapAttrs
  109. (name: host:
  110. mkNixOSConfigurations {
  111. inherit host;
  112. nixpkgs = inputs.nixpkgs;
  113. home-manager = inputs.home-manager;
  114. }
  115. )
  116. hosts
  117. // lib.mapAttrs'
  118. (name: host:
  119. lib.nameValuePair
  120. "${host.hostname}-iso"
  121. (mkISOConfiguration {
  122. inherit host;
  123. nixpkgs = inputs.nixpkgs;
  124. })
  125. )
  126. hosts;
  127. homeConfigurations = lib.mapAttrs'
  128. (name: host:
  129. lib.nameValuePair
  130. "${host.user}@${host.hostname}"
  131. (mkHomeConfigurations {
  132. inherit host;
  133. nixpkgs = inputs.nixpkgs;
  134. home-manager = inputs.home-manager;
  135. })
  136. )
  137. hosts;
  138. };
  139. }