flake.nix 3.4 KB

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