flake.nix 3.6 KB

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