1
0

flake.nix 3.6 KB

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