1
0

flake.nix 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. };
  11. outputs =
  12. {
  13. self,
  14. nix-flatpak,
  15. ...
  16. }@inputs:
  17. let
  18. hosts = import ./config/hosts.nix;
  19. mkHomeConfigurations =
  20. {
  21. host,
  22. nixpkgs,
  23. home-manager,
  24. modules ? [ ],
  25. }:
  26. home-manager.lib.homeManagerConfiguration {
  27. pkgs = import nixpkgs {
  28. system = host.arch;
  29. config = {
  30. allowUnfree = true;
  31. };
  32. };
  33. modules = [
  34. ./hosts/${host.dir}/home.nix
  35. ] ++ modules;
  36. };
  37. mkNixOSConfigurations =
  38. {
  39. host,
  40. nixpkgs,
  41. home-manager,
  42. modules ? [ ],
  43. overlays ? [ ],
  44. }:
  45. nixpkgs.lib.nixosSystem {
  46. system = host.arch;
  47. modules = [
  48. nix-flatpak.nixosModules.nix-flatpak
  49. ./hosts/${host.dir}/configuration.nix
  50. { nixpkgs.overlays = overlays; }
  51. home-manager.nixosModules.home-manager
  52. {
  53. home-manager.useGlobalPkgs = true;
  54. home-manager.users."${host.user}" = import ./hosts/${host.dir}/home.nix;
  55. }
  56. ] ++ modules;
  57. };
  58. mkISOConfiguration = # Build with: nix build .#nixosConfigurations.<hostname>-iso.config.system.build.isoImage
  59. {
  60. host,
  61. nixpkgs,
  62. }:
  63. nixpkgs.lib.nixosSystem {
  64. system = host.arch;
  65. modules = [
  66. ./hosts/${host.dir}/iso.nix
  67. { networking.hostName = "${host.hostname}-iso"; }
  68. ];
  69. };
  70. in
  71. {
  72. nixosConfigurations."${hosts.nixstation.hostname}" = mkNixOSConfigurations {
  73. host = hosts.nixstation;
  74. nixpkgs = inputs.nixpkgs;
  75. home-manager = inputs.home-manager;
  76. };
  77. nixosConfigurations."${hosts.dellaptop.hostname}" = mkNixOSConfigurations {
  78. host = hosts.dellaptop;
  79. nixpkgs = inputs.nixpkgs;
  80. home-manager = inputs.home-manager;
  81. };
  82. nixosConfigurations."${hosts.nixstation.hostname}-iso" = mkISOConfiguration {
  83. host = hosts.nixstation;
  84. nixpkgs = inputs.nixpkgs;
  85. };
  86. nixosConfigurations."${hosts.dellaptop.hostname}-iso" = mkISOConfiguration {
  87. host = hosts.dellaptop;
  88. nixpkgs = inputs.nixpkgs;
  89. };
  90. homeConfigurations."${hosts.nixstation.user}@${hosts.nixstation.hostname}" = mkHomeConfigurations {
  91. host = hosts.nixstation;
  92. nixpkgs = inputs.nixpkgs;
  93. home-manager = inputs.home-manager;
  94. };
  95. };
  96. }