flake.nix 3.5 KB

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