diff --git a/flake.nix b/flake.nix index 04d4fb4..f1f2235 100644 --- a/flake.nix +++ b/flake.nix @@ -23,22 +23,13 @@ }; }; - outputs = { self, nixpkgs, home-manager, ... }@inputs: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - in - { - nixosConfigurations.default = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; - modules = [ - inputs.home-manager.nixosModules.default - ./hosts/default/configuration.nix - ]; - }; - homeConfiguration."guz" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { inherit inputs; }; - }; + outputs = { self, nixpkgs, home-manager, ... }@inputs: { + nixosConfigurations.desktop = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.home-manager.nixosModules.default + ./hosts/desktop/configuration.nix + ]; }; + }; } diff --git a/hosts/default/configuration.nix b/hosts/default/configuration.nix deleted file mode 100644 index 76e15f6..0000000 --- a/hosts/default/configuration.nix +++ /dev/null @@ -1,155 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, inputs, lib, ... }: - -{ - imports = - [ - # Include the results of the hardware scan. - ./hardware-configuration.nix - inputs.home-manager.nixosModules.default - ]; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "nixos"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - # Enable networking - networking.networkmanager.enable = true; - - # Set your time zone. - time.timeZone = "America/Sao_Paulo"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "pt_BR.UTF-8"; - LC_IDENTIFICATION = "pt_BR.UTF-8"; - LC_MEASUREMENT = "pt_BR.UTF-8"; - LC_MONETARY = "pt_BR.UTF-8"; - LC_NAME = "pt_BR.UTF-8"; - LC_NUMERIC = "pt_BR.UTF-8"; - LC_PAPER = "pt_BR.UTF-8"; - LC_TELEPHONE = "pt_BR.UTF-8"; - LC_TIME = "pt_BR.UTF-8"; - }; - - # Enable the X11 windowing system. - services.xserver.enable = true; - - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - - # Configure keymap in X11 - services.xserver = { - layout = "br"; - xkbVariant = ""; - }; - - # Configure console keymap - console.keyMap = "br-abnt2"; - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Enable sound with pipewire. - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - programs.zsh.enable = true; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users."guz" = { - isNormalUser = true; - description = "Guz"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; [ - firefox - # thunderbird - ]; - shell = pkgs.zsh; - }; - - home-manager = { - extraSpecialArgs = { inherit inputs; }; - users = { - "guz" = import ./home.nix; - }; - }; - - services.flatpak.enable = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - vim - neovim - git - lazygit - gcc # Added temporally so my neovim config doesn't break - wget - nixpkgs-fmt - nixpkgs-lint - ]; - - environment.sessionVariables = { - EDITOR = "nvim"; - }; - environment.pathsToLink = [ "/share/zsh" ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "23.11"; # Did you read the comment? - -} diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix new file mode 100644 index 0000000..21f9b65 --- /dev/null +++ b/hosts/desktop/configuration.nix @@ -0,0 +1,71 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, inputs, lib, ... }: + +{ + imports = [ + ../../modules/nixos/config/host.nix + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + programs.zsh.enable = true; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users."guz" = { + isNormalUser = true; + description = "Guz"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + firefox + # thunderbird + ]; + shell = pkgs.zsh; + }; + + home-manager = { + extraSpecialArgs = { inherit inputs; }; + users = { + "guz" = import ./home.nix; + }; + }; + + services.flatpak.enable = true; + + environment.pathsToLink = [ "/share/zsh" ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + +} diff --git a/hosts/default/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix similarity index 100% rename from hosts/default/hardware-configuration.nix rename to hosts/desktop/hardware-configuration.nix diff --git a/hosts/default/home.nix b/hosts/desktop/home.nix similarity index 100% rename from hosts/default/home.nix rename to hosts/desktop/home.nix diff --git a/modules/nixos/config/host.nix b/modules/nixos/config/host.nix new file mode 100644 index 0000000..6176011 --- /dev/null +++ b/modules/nixos/config/host.nix @@ -0,0 +1,88 @@ +# Config shared between all host's configuration.nix (NixOS config) +{ config, pkgs, inputs, lib, ... }: + +let + cfg = config.host; +in +{ + imports = [ + inputs.home-manager.nixosModules.default + ../systems/localization.nix + ]; + options.host = { + networking = { + hostName = lib.mkOption { + default = "nixos"; + type = lib.types.str; + description = "Define the host's network name"; + }; + wireless.enable = lib.mkOption { + default = false; + type = lib.types.bool; + description = "Enables wireless support"; + }; + }; + time = { + timeZone = lib.mkOption { + type = lib.types.str; + description = "Sets host's time zone"; + }; + }; + }; + config = { + # Nix configuration + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + boot = { + loader.systemd-boot.enable = true; + loader.efi.canTouchEfiVariables = true; + }; + + networking = { + networkmanager.enable = true; + + hostName = cfg.networking.hostName; + wireless.enable = cfg.networking.wireless.enable; + + # Configure network proxy if necessary + # proxy.default = "http://user:password@proxy:port/"; + # proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + }; + + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + #jack.enable = true; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + vim + neovim + git + lazygit + gcc # Added temporally so my neovim config doesn't break + wget + nixpkgs-fmt + nixpkgs-lint + ]; + environment.sessionVariables = { + EDITOR = "nvim"; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.11"; # Did you read the comment? + + }; +} diff --git a/modules/nixos/systems/localization.nix b/modules/nixos/systems/localization.nix new file mode 100644 index 0000000..4cfd6df --- /dev/null +++ b/modules/nixos/systems/localization.nix @@ -0,0 +1,65 @@ +{ config, pkgs, inputs, lib, ... }: + +let + cfg = config.localization; +in +{ + options.localization = { + locale = lib.mkOption { + default = "en_US.UTF-8"; + type = lib.types.str; + description = "Sets default locale of the host"; + }; + extraLocales = lib.mkOption { + default = rec { + LC_ADDRESS = "pt_BR.UTF-8"; + LC_IDENTIFICATION = LC_ADDRESS; + LC_MEASUREMENT = LC_ADDRESS; + LC_MONETARY = LC_ADDRESS; + LC_NAME = LC_ADDRESS; + LC_NUMERIC = LC_ADDRESS; + LC_PAPER = LC_ADDRESS; + LC_TELEPHONE = LC_ADDRESS; + LC_TIME = LC_ADDRESS; + }; + description = "Extra localization settings"; + }; + + keymap.layout = lib.mkOption { + default = "br"; + type = lib.types.str; + }; + keymap.variant = lib.mkOption { + default = ""; + type = lib.types.str; + }; + keymap.console = lib.mkOption { + default = "br-abnt2"; + type = lib.types.str; + }; + + time = { + zone = lib.mkOption { + default = "America/Sao_Paulo"; + type = lib.types.str; + }; + }; + }; + config = { + i18n = { + defaultLocale = cfg.locale; + extraLocaleSettings = cfg.extraLocales; + }; + + services.xserver = { + layout = cfg.keymap.layout; + xkbVariant = cfg.keymap.variant; + }; + + console.keyMap = cfg.keymap.console; + + time = { + timeZone = cfg.time.zone; + }; + }; +}