From bb98a6a66c12b87cbf1869d6992bbf94878bd923 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 7 Apr 2021 12:44:07 -0400 Subject: [PATCH 1/4] Add initial p71 config --- flake.nix | 4 +- p71/configuration.nix | 97 +++++++++++++++++++++ configuration.nix => x1c7/configuration.nix | 0 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 p71/configuration.nix rename configuration.nix => x1c7/configuration.nix (100%) diff --git a/flake.nix b/flake.nix index b3212de..fd9c006 100644 --- a/flake.nix +++ b/flake.nix @@ -7,11 +7,11 @@ }; outputs = { self, home-manager, nixpkgs }: { - nixosConfigurations.x1c7 = nixpkgs.lib.nixosSystem { + nixosConfigurations.p71 = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ # System configuration - ./configuration.nix + ./p71/configuration.nix ./modules/passwordstore.nix ./modules/protonmail-bridge.nix diff --git a/p71/configuration.nix b/p71/configuration.nix new file mode 100644 index 0000000..3d17f05 --- /dev/null +++ b/p71/configuration.nix @@ -0,0 +1,97 @@ +{ config, pkgs, lib, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/4200ca92-3b3c-4a41-98d5-92bbc0a5597e"; + fsType = "ext4"; + }; + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/7C8B-3F49"; + fsType = "vfat"; + }; + swapDevices = + [ { device = "/dev/disk/by-uuid/b03a08aa-1c9c-4674-b03b-ec59003306f5"; } + ]; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + # high-resolution display + hardware.video.hidpi.enable = lib.mkDefault true; + + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.kernelPackages = pkgs.linuxPackages_latest; + + nixpkgs.config.allowUnfree = true; + nix = { + package = pkgs.nixFlakes; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + networking.hostName = "p71"; # Define your hostname. + networking.networkmanager.enable = true; + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Set your time zone. + time.timeZone = "America/New_York"; + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.enp0s31f6.useDHCP = true; + networking.interfaces.wlp4s0.useDHCP = true; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + + # Enable the GNOME 3 Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome3.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.srid = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user. + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + gnome3.gnome-tweaks + brave + vscode + obsidian + ]; + + 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 = "20.09"; # Did you read the comment? + +} + diff --git a/configuration.nix b/x1c7/configuration.nix similarity index 100% rename from configuration.nix rename to x1c7/configuration.nix From c6a6c82bf9048eb6941bfdd8e5d3bab6ab23c30a Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 7 Apr 2021 13:04:23 -0400 Subject: [PATCH 2/4] Add nvidia --- p71/configuration.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/p71/configuration.nix b/p71/configuration.nix index 3d17f05..a77dd34 100644 --- a/p71/configuration.nix +++ b/p71/configuration.nix @@ -55,8 +55,10 @@ networking.interfaces.wlp4s0.useDHCP = true; # Enable the X11 windowing system. - services.xserver.enable = true; - + services.xserver = { + enable = true; + videoDrivers = [ "nvidia" "intel" ]; + }; # Enable the GNOME 3 Desktop Environment. services.xserver.displayManager.gdm.enable = true; From 12ff5b0ae4cb6c7fda938789230a31ef51c0a52f Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 7 Apr 2021 13:04:45 -0400 Subject: [PATCH 3/4] Add ddcutil --- .vscode/extensions.json | 5 +++++ flake.nix | 1 + modules/monitor-brightness.nix | 8 ++++++++ 3 files changed, 14 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 modules/monitor-brightness.nix diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..482f80d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "bbenoist.nix" + ] +} \ No newline at end of file diff --git a/flake.nix b/flake.nix index fd9c006..842e067 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,7 @@ ./p71/configuration.nix ./modules/passwordstore.nix ./modules/protonmail-bridge.nix + ./modules/monitor-brightness.nix # home-manager configuration home-manager.nixosModules.home-manager diff --git a/modules/monitor-brightness.nix b/modules/monitor-brightness.nix new file mode 100644 index 0000000..22269f9 --- /dev/null +++ b/modules/monitor-brightness.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: { + # ddcutils requires i2c + boot.kernelModules = [ "i2c-dev" ]; + + environment.systemPackages = with pkgs; [ + ddcutil + ]; +} From 2f407dd8e502c27e4e5afdb8159cd2a6a54b7e55 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 7 Apr 2021 13:13:54 -0400 Subject: [PATCH 4/4] Generalize --- flake.nix | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 842e067..cd018b0 100644 --- a/flake.nix +++ b/flake.nix @@ -6,24 +6,29 @@ home-manager.url = "github:nix-community/home-manager"; }; - outputs = { self, home-manager, nixpkgs }: { - nixosConfigurations.p71 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - # System configuration - ./p71/configuration.nix - ./modules/passwordstore.nix - ./modules/protonmail-bridge.nix - ./modules/monitor-brightness.nix + outputs = { self, home-manager, nixpkgs }: + let + # Make configuration for any computer I use in my home office. + mkHomeMachine = configurationNix: nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + # System configuration + configurationNix + ./modules/passwordstore.nix + ./modules/protonmail-bridge.nix + ./modules/monitor-brightness.nix - # home-manager configuration - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.srid = import ./home.nix; - } - ]; + # home-manager configuration + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.srid = import ./home.nix; + } + ]; + }; + in { + nixosConfigurations.p71 = mkHomeMachine ./p71/configuration.nix; + nixosConfigurations.x1c7 = mkHomeMachine ./x1c7/configuration.nix; }; - }; }