nixos configurations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.1 KiB

4 months ago
  1. {
  2. description = "Nixos config flake";
  3. inputs = {
  4. nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
  5. nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
  6. disko = {
  7. url = "github:nix-community/disko";
  8. inputs.nixpkgs.follows = "nixpkgs";
  9. };
  10. home-manager = {
  11. url = "github:nix-community/home-manager";
  12. inputs.nixpkgs.follows = "nixpkgs";
  13. };
  14. };
  15. outputs = inputs@{ self, ... }:
  16. let
  17. settings = (if (builtins.pathExists ./settings.nix)
  18. then
  19. (import ./settings.nix)
  20. else
  21. (import ./settings-default.nix)
  22. );
  23. nixpkgs = (if (settings.packages == "stable")
  24. then
  25. inputs.nixpkgs
  26. else
  27. inputs.nixpkgs-unstable
  28. );
  29. overlay-unstable = final: prev: {
  30. unstable = import inputs.nixpkgs-unstable {
  31. system = settings.system;
  32. config.allowUnfree = true;
  33. };
  34. };
  35. pkgs = (import nixpkgs {
  36. system = settings.system;
  37. config = {
  38. allowUnfree = true;
  39. allowUnfreePredicate = (_: true);
  40. };
  41. overlays = [ overlay-unstable ];
  42. });
  43. mkSystem = config: nixpkgs.lib.nixosSystem {
  44. system = settings.system;
  45. specialArgs = {
  46. inherit inputs;
  47. inherit pkgs;
  48. inherit settings;
  49. };
  50. modules = [
  51. config
  52. inputs.disko.nixosModules.disko
  53. inputs.home-manager.nixosModules.default
  54. ];
  55. };
  56. mkHome = config: inputs.home-manager.lib.homeManagerConfiguration {
  57. inherit pkgs;
  58. extraSpecialArgs = {
  59. inherit inputs;
  60. inherit settings;
  61. };
  62. modules = [ config ];
  63. };
  64. in {
  65. nixosConfigurations.default = mkSystem ./hosts/default/configuration.nix;
  66. nixosConfigurations.tama = mkSystem ./hosts/tama/configuration.nix;
  67. homeConfigurations = {
  68. ${settings.user.name} = mkHome ./users/main-user.nix;
  69. };
  70. };
  71. }