From 25660d75cf9f4be4956bf430febb1b11e371a832 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Tue, 23 Jan 2024 17:34:04 -0300 Subject: [PATCH] feat: home server configuration --- flake.nix | 1 + hosts/desktop/shared-configuration.nix | 1 - hosts/homex/configuration.nix | 41 ++++++++++++++++++++++++++ hosts/homex/hardware-configuration.nix | 39 ++++++++++++++++++++++++ hosts/homex/home.nix | 21 +++++++++++++ modules/nixos/config/host.nix | 1 + 6 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 hosts/homex/configuration.nix create mode 100644 hosts/homex/hardware-configuration.nix create mode 100644 hosts/homex/home.nix diff --git a/flake.nix b/flake.nix index 9d83074..13b9cee 100644 --- a/flake.nix +++ b/flake.nix @@ -71,6 +71,7 @@ nixosConfigurations = (create-host [ "desktop@default" "desktop@work" + "homex" ]); }; } diff --git a/hosts/desktop/shared-configuration.nix b/hosts/desktop/shared-configuration.nix index 4a54e06..8d7df85 100644 --- a/hosts/desktop/shared-configuration.nix +++ b/hosts/desktop/shared-configuration.nix @@ -2,7 +2,6 @@ { imports = [ - inputs.sops-nix.nixosModules.sops ../../modules/nixos/config/host.nix ../../modules/nixos/systems/set-user.nix # Include the results of the hardware scan. diff --git a/hosts/homex/configuration.nix b/hosts/homex/configuration.nix new file mode 100644 index 0000000..ccdfdef --- /dev/null +++ b/hosts/homex/configuration.nix @@ -0,0 +1,41 @@ +# 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, ... }: + +{ + imports = [ + ../../modules/nixos/systems/set-user.nix + ../../modules/nixos/config/host.nix + ./hardware-configuration.nix + ]; + + host.networking.hostName = "homex"; + networking = { + dhcpcd.enable = true; + interfaces.eno1.ipv4.addresses = [{ + address = "192.168.1.10"; + prefixLength = 28; + }]; + defaultGateway = "192.168.1.1"; + nameservers = [ "1.1.1.1" "8.8.8.8" ]; + }; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + set-user.users = [{ + username = "guz"; + shell = pkgs.zsh; + home = import ./home.nix; + }]; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + +} diff --git a/hosts/homex/hardware-configuration.nix b/hosts/homex/hardware-configuration.nix new file mode 100644 index 0000000..73b9a09 --- /dev/null +++ b/hosts/homex/hardware-configuration.nix @@ -0,0 +1,39 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "usbhid" "usb_storage" "sd_mod" "sdhci_acpi" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/26878c61-60d2-4ac9-967f-30faffc0f21f"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/ACCB-816C"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/878a189a-e5df-4e1c-92d5-df6f77ff53bb"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/homex/home.nix b/hosts/homex/home.nix new file mode 100644 index 0000000..da47bbd --- /dev/null +++ b/hosts/homex/home.nix @@ -0,0 +1,21 @@ +{ config, pkgs, inputs, ... }: + + +{ + imports = [ + ../../modules/home-manager/programs/starship.nix + ../../modules/home-manager/programs/tmux.nix + ../../modules/home-manager/programs/zsh.nix + ]; + + starship.enable = true; + starship.enableZsh = true; + + tmux.enable = true; + tmux.shell = "\${pkgs.zsh}/bin/zsh"; + + zsh.enable = true; + zsh.extraConfig.init = '' + export GPG_TTY=$(tty) + ''; +} diff --git a/modules/nixos/config/host.nix b/modules/nixos/config/host.nix index d8c02c2..1510c64 100644 --- a/modules/nixos/config/host.nix +++ b/modules/nixos/config/host.nix @@ -7,6 +7,7 @@ in { imports = [ inputs.home-manager.nixosModules.default + inputs.sops-nix.nixosModules.sops ../systems/localization.nix ]; options.host = {