1
0

flake.nix 3.7 KB

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