flake.nix 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.8.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. onthespot.url = "github:johron/onthespot";
  22. sonora.url = "github:sonorahq/sonora";
  23. dux = {
  24. url = "github:duxlabs-dev/dux-shell/stable";
  25. inputs.nixpkgs.follows = "nixpkgs";
  26. };
  27. dux-greeter = {
  28. url = "github:duxlabs-dev/dux-greeter";
  29. inputs.nixpkgs.follows = "nixpkgs";
  30. };
  31. dux-files = {
  32. url = "github:duxlabs-dev/dux-files";
  33. inputs.nixpkgs.follows = "nixpkgs";
  34. };
  35. };
  36. outputs =
  37. {
  38. self,
  39. nix-flatpak,
  40. ...
  41. }@inputs:
  42. let
  43. lib = inputs.nixpkgs.lib;
  44. hosts = import ./config/hosts.nix;
  45. mkHomeConfigurations =
  46. {
  47. host,
  48. nixpkgs,
  49. home-manager,
  50. modules ? [ ],
  51. }:
  52. home-manager.lib.homeManagerConfiguration {
  53. pkgs = import nixpkgs {
  54. system = host.arch;
  55. config = {
  56. allowUnfree = true;
  57. };
  58. };
  59. extraSpecialArgs = { inherit inputs host; };
  60. modules = [
  61. ./hosts/${host.dir}/home
  62. ] ++ modules;
  63. };
  64. mkNixOSConfigurations =
  65. {
  66. host,
  67. nixpkgs,
  68. home-manager,
  69. modules ? [ ],
  70. overlays ? [],
  71. }:
  72. nixpkgs.lib.nixosSystem {
  73. system = host.arch;
  74. specialArgs = {
  75. inherit inputs host;
  76. };
  77. modules = [
  78. nix-flatpak.nixosModules.nix-flatpak
  79. ./hosts/${host.dir}/nixos
  80. { nixpkgs.overlays = overlays; }
  81. home-manager.nixosModules.home-manager
  82. {
  83. home-manager.extraSpecialArgs = { inherit inputs host; };
  84. home-manager.useGlobalPkgs = true;
  85. home-manager.useUserPackages = true;
  86. home-manager.backupFileExtension = "backup";
  87. home-manager.users."${host.user}" = import ./hosts/${host.dir}/home;
  88. }
  89. ] ++ modules;
  90. };
  91. mkISOConfiguration = # Build with: nix build .#nixosConfigurations.<hostname>-iso.config.system.build.isoImage
  92. {
  93. host,
  94. nixpkgs,
  95. }:
  96. nixpkgs.lib.nixosSystem {
  97. system = host.arch;
  98. modules = [
  99. ./hosts/${host.dir}/iso.nix
  100. { networking.hostName = "${host.hostname}-iso"; }
  101. ];
  102. };
  103. in
  104. {
  105. nixosConfigurations =
  106. lib.mapAttrs
  107. (name: host:
  108. mkNixOSConfigurations {
  109. inherit host;
  110. nixpkgs = inputs.nixpkgs;
  111. home-manager = inputs.home-manager;
  112. }
  113. )
  114. hosts
  115. // lib.mapAttrs'
  116. (name: host:
  117. lib.nameValuePair
  118. "${host.hostname}-iso"
  119. (mkISOConfiguration {
  120. inherit host;
  121. nixpkgs = inputs.nixpkgs;
  122. })
  123. )
  124. hosts;
  125. homeConfigurations = lib.mapAttrs'
  126. (name: host:
  127. lib.nameValuePair
  128. "${host.user}@${host.hostname}"
  129. (mkHomeConfigurations {
  130. inherit host;
  131. nixpkgs = inputs.nixpkgs;
  132. home-manager = inputs.home-manager;
  133. })
  134. )
  135. hosts;
  136. };
  137. }