From ff5094e2eeaf92d10f0d4e63ae7998bde0a25122 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Wed, 13 Jul 2022 20:18:52 +0200 Subject: [PATCH] add laptop config --- flake.nix | 44 +++++++++++++++---- nixos/configuration-desktop.nix | 19 ++++++++ nixos/configuration-laptop.nix | 19 ++++++++ nixos/configuration.nix | 28 +++--------- ...nix => hardware-configuration-desktop.nix} | 16 +++++++ 5 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 nixos/configuration-desktop.nix create mode 100644 nixos/configuration-laptop.nix rename nixos/{hardware-configuration.nix => hardware-configuration-desktop.nix} (81%) diff --git a/flake.nix b/flake.nix index 07908e76..37973bac 100644 --- a/flake.nix +++ b/flake.nix @@ -39,6 +39,17 @@ emacs = inputs.emacs-overlay.overlay; }; + homemanager = home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = + true; # Use systems pkgs, disables nixpkgs.* options in home.nix + home-manager.useUserPackages = + true; # Enable installing packages through users.christoph.packages + home-manager.users.christoph = import ./home/home.nix; + + # Make our overlays available in home.nix + home-manager.extraSpecialArgs = { inherit inputs; }; + }; + # The rec expression turns a basic set into a set where self-referencing is possible. # It is a shorthand for recursive and allows to use the values defined in this set from its own scope. in rec { @@ -56,6 +67,7 @@ modules = [ # TODO: Modularize ./nixos/configuration.nix + ./nixos/configuration-desktop.nix # TODO: Investigate this { ... } module syntax # Overlays @@ -65,17 +77,31 @@ } # HomeManager - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = - true; # Use systems pkgs, disables nixpkgs.* options in home.nix - home-manager.useUserPackages = - true; # Enable installing packages through users.christoph.packages - home-manager.users.christoph = import ./home/home.nix; + homemanager + ]; - # Make our overlays available in home.nix - home-manager.extraSpecialArgs = { inherit inputs; }; + # Make our inputs available to the configuration.nix (for importing modules) + specialArgs = { inherit inputs; }; + }; + + nixtop = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + + # >> Main NixOS configuration file << + modules = [ + # TODO: Modularize + ./nixos/configuration.nix + ./nixos/configuration-laptop.nix + + # TODO: Investigate this { ... } module syntax + # Overlays + { + # Since HomeManager uses global pkgs we can set the overlays here + nixpkgs.overlays = attrValues overlays; } + + # HomeManager + homemanager ]; # Make our inputs available to the configuration.nix (for importing modules) diff --git a/nixos/configuration-desktop.nix b/nixos/configuration-desktop.nix new file mode 100644 index 00000000..87b6cbaf --- /dev/null +++ b/nixos/configuration-desktop.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration-desktop.nix + ]; + + networking.hostName = "nixinator"; # Define your hostname. + + services.xserver = { + # Configure keymap in X11 + layout = "us"; + xkbVariant = "altgr-intl"; + + # Proprietary graphics drivers + videoDrivers = [ "nvidia" ]; + }; +} diff --git a/nixos/configuration-laptop.nix b/nixos/configuration-laptop.nix new file mode 100644 index 00000000..d3d88d70 --- /dev/null +++ b/nixos/configuration-laptop.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration-laptop.nix + ]; + + networking.hostName = "nixtop"; # Define your hostname. + + services.xserver = { + # Configure keymap in X11 + layout = "de"; + xkbVariant = "nodeadkeys"; + + # Proprietary graphics drivers + videoDrivers = [ "intel" ]; + }; +} diff --git a/nixos/configuration.nix b/nixos/configuration.nix index fbb604f8..bb4c348a 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -5,9 +5,7 @@ { inputs, lib, config, pkgs, ... }: { - imports = [ # Include the results of the hardware scan. - ./hardware-configuration.nix - + imports = [ # NixCommunity binary cache ./cachix.nix ]; @@ -65,22 +63,6 @@ security.protectKernelImage = true; - hardware = { - # cpu.intel.updateMicrocode = true; # Already defined in hardware.nix - - # Use all redistributable firmware (i.e. nonfree) - enableAllFirmware = true; - enableRedistributableFirmware = true; # Also enables microcode update - - nvidia.modesetting.enable = - true; # Not officially supported by NVidia but needed for wayland - opengl.enable = true; - opengl.driSupport = true; - opengl.driSupport32Bit = true; - - sane.enable = true; # Scanning - }; - # Set your time zone. time.timeZone = "Europe/Berlin"; @@ -105,7 +87,7 @@ # TODO: Other ports (tcp/udp/ssh...)? # Open ports in the firewall. networking = { - hostName = "nixinator"; # Define your hostname. + # hostName = "nixinator"; # Define your hostname. # NOTE: Done in host specific config # wireless.enable = true; # Enables wireless support via wpa_supplicant. # Configure network proxy if necessary @@ -130,12 +112,12 @@ enable = true; # Configure keymap in X11 - layout = "us"; - xkbVariant = "altgr-intl"; + # layout = "us"; # NOTE: Done in host specific config + # xkbVariant = "altgr-intl"; # NOTE: Done in host specific config # Proprietary graphics drivers # TODO: Opengl and stuff - videoDrivers = [ "nvidia" ]; + # videoDrivers = [ "nvidia" ]; # NOTE: Done in host specific config # Startx replaces the displaymanager so default (lightdm) isn't used, start to shell # displayManager.startx.enable = true; diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration-desktop.nix similarity index 81% rename from nixos/hardware-configuration.nix rename to nixos/hardware-configuration-desktop.nix index 7fb8fbd3..482ad186 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/hardware-configuration-desktop.nix @@ -60,4 +60,20 @@ lib.mkDefault config.hardware.enableRedistributableFirmware; # high-resolution display hardware.video.hidpi.enable = lib.mkDefault true; + + hardware = { + # cpu.intel.updateMicrocode = true; # Already defined in hardware.nix + + # Use all redistributable firmware (i.e. nonfree) + enableAllFirmware = true; + enableRedistributableFirmware = true; # Also enables microcode update + + nvidia.modesetting.enable = + true; # Not officially supported by NVidia but needed for wayland + opengl.enable = true; + opengl.driSupport = true; + opengl.driSupport32Bit = true; + + sane.enable = true; # Scanning + }; }