flake.nix 3.0 KB

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