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.

112 lines
3.4 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. {
  2. description = "Nixos config flake";
  3. # Package sources.
  4. inputs = {
  5. nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
  6. nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
  7. disko = {
  8. url = "github:nix-community/disko";
  9. inputs.nixpkgs.follows = "nixpkgs";
  10. };
  11. home-manager = {
  12. url = "github:nix-community/home-manager/release-24.05";
  13. inputs.nixpkgs.follows = "nixpkgs";
  14. };
  15. home-manager-unstable = {
  16. url = "github:nix-community/home-manager";
  17. inputs.nixpkgs.follows = "nixpkgs";
  18. };
  19. flatpaks.url = "github:GermanBread/declarative-flatpak/stable";
  20. };
  21. # Flake outputs, NixOS and Home Configurations.
  22. outputs = inputs@{ self, flatpaks, ... }:
  23. let
  24. # Load settings.nix or the default if not exists.
  25. settings = (if (builtins.pathExists ./settings.nix)
  26. then
  27. (import ./settings.nix)
  28. else
  29. (import ./settings-default.nix)
  30. );
  31. # Based on loaded settings, set the nixpkgs version.
  32. nixpkgs = (if (settings.packages == "stable")
  33. then
  34. inputs.nixpkgs
  35. else
  36. inputs.nixpkgs-unstable
  37. );
  38. # Based on loaded settings, set the home-manager version.
  39. home-manager = (if (settings.packages == "stable")
  40. then
  41. inputs.home-manager
  42. else
  43. inputs.home-manager-unstable
  44. );
  45. # Setup an overlay for unstable packages to include on stable environments.
  46. overlay-unstable = final: prev: {
  47. unstable = import inputs.nixpkgs-unstable {
  48. system = settings.system;
  49. config.allowUnfree = true;
  50. };
  51. };
  52. # Setup the main packages config with the overlays.
  53. pkgs = (import nixpkgs {
  54. system = settings.system;
  55. config = {
  56. allowUnfree = true;
  57. allowUnfreePredicate = (_: true);
  58. };
  59. overlays = [ overlay-unstable ];
  60. });
  61. # Function to configure a system with our defaults.
  62. mkSystem = config: nixpkgs.lib.nixosSystem {
  63. system = settings.system;
  64. specialArgs = {
  65. inherit inputs;
  66. inherit pkgs;
  67. inherit settings;
  68. };
  69. modules = [
  70. inputs.disko.nixosModules.disko
  71. home-manager.nixosModules.default
  72. flatpaks.nixosModules.default
  73. config
  74. ];
  75. };
  76. # Function to configure home-manager for a user.
  77. mkHome = config: home-manager.lib.homeManagerConfiguration {
  78. inherit pkgs;
  79. extraSpecialArgs = {
  80. inherit inputs;
  81. inherit settings;
  82. };
  83. modules = [
  84. flatpaks.homeManagerModules.default
  85. config
  86. ];
  87. };
  88. in {
  89. # NixOS configurations, in most cases we use default with a profile.
  90. # Any host that needs specific configurations separate from what is included by default,
  91. # will need its own configuration for its hostname.
  92. nixosConfigurations.default = mkSystem ./hosts/default/configuration.nix;
  93. nixosConfigurations.tama = mkSystem ./hosts/tama/configuration.nix;
  94. # Home manager configurations, we do the main user from the configuration and root.
  95. homeConfigurations = {
  96. ${settings.user.name} = mkHome ./users/main-user.nix;
  97. "root" = mkHome ./users/root.nix;
  98. };
  99. };
  100. }