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.

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