flake.nix 3.3 KB

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