flake.nix 3.4 KB

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