flake.nix 3.5 KB

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