From 0a085f889503270fc687df443995989d0ba394ca Mon Sep 17 00:00:00 2001 From: Alexander Szczepanski Date: Wed, 9 Jun 2021 21:31:21 +0200 Subject: [PATCH] added thinkpad --- configs/common.nix | 26 +++ configs/gui.nix | 46 ++--- machine/desktop/configuration.nix | 24 +-- machine/thinkpad/configuration.nix | 282 +++++++++++++++++++++++++++++ rsync.sh | 2 + 5 files changed, 334 insertions(+), 46 deletions(-) create mode 100644 configs/common.nix create mode 100644 machine/thinkpad/configuration.nix mode change 100644 => 100755 rsync.sh diff --git a/configs/common.nix b/configs/common.nix new file mode 100644 index 0000000..978dfb5 --- /dev/null +++ b/configs/common.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +{ + environment.systemPackages = with pkgs; [ + ack + dfc + git + glances + home-manager + htop + ncdu + zsh + ruby + pstree + pciutils + borgbackup + bpytop + broot + bwm_ng + nodejs + sshfs + tealdeer + tree + lm_sensors + ]; +} diff --git a/configs/gui.nix b/configs/gui.nix index 17f9848..dd772a9 100644 --- a/configs/gui.nix +++ b/configs/gui.nix @@ -1,28 +1,28 @@ { pkgs, ... }: { - environment.systemPackages = with pkgs; [ - kitty - chromium - gparted - keepassxc - meld - twemoji-color-font - mpv - brave - firefox - alacritty - baobab - lutris - insomnia - jellyfin-web - kdenlive - nextcloud-client - barrier - solaar - spotify - vulkan-tools - gnome.eog - virtmanager + environment.systemPackages = with pkgs; [ + kitty + chromium + gparted + keepassxc + meld + twemoji-color-font + mpv + brave + firefox + alacritty + baobab + lutris + insomnia + jellyfin-web + kdenlive + nextcloud-client + barrier + solaar + spotify + vulkan-tools + gnome.eog + virtmanager ]; } diff --git a/machine/desktop/configuration.nix b/machine/desktop/configuration.nix index d9bd7c0..b14089e 100644 --- a/machine/desktop/configuration.nix +++ b/machine/desktop/configuration.nix @@ -10,6 +10,7 @@ in # ./vscode.nix ../../configs/gui.nix ../../configs/virtualisation.nix + ../../configs/common.nix ]; # Use the systemd-boot EFI boot loader. @@ -174,29 +175,6 @@ in nixpkgs.config.allowUnfree = true; - environment.systemPackages = with pkgs; [ - ack - dfc - git - glances -# home-manager - htop - ncdu - zsh - ruby - pstree - pciutils - borgbackup - bpytop - broot - bwm_ng - nodejs - sshfs - tealdeer - tree - lm_sensors - ]; - # Some programs need SUID wrappers, can be configured further or are # started in user sessions. # programs.mtr.enable = true; diff --git a/machine/thinkpad/configuration.nix b/machine/thinkpad/configuration.nix new file mode 100644 index 0000000..459d449 --- /dev/null +++ b/machine/thinkpad/configuration.nix @@ -0,0 +1,282 @@ +# 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, lib, ... }: +let + nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' + export __NV_PRIME_RENDER_OFFLOAD=1 + export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export __VK_LAYER_NV_optimus=NVIDIA_only + exec -a "$0" "$@" + ''; +in +{ + imports = + [ # Include the results of the hardware scan. + + /etc/nixos/hardware-configuration.nix + ../../configs/gui.nix + ../../configs/virtualisation.nix + ../../configs/common.nix + ]; + + # boot.initrd.luks.devices = { + # root = { + # preLVM = true; + # device = "/dev/disk/by-uuid/b59e9746-b9b4-4de1-94f6-84a387b9d72e"; + # allowDiscards = true; + # }; + # }; + + fileSystems."/".options = [ "noatime" "discard" ]; + + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.device = "nodev"; + boot.loader.grub.efiSupport = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.grub.gfxmodeEfi = "1024x768"; + + boot.tmpOnTmpfs = true; + #boot.plymouth.enable = true; + + environment.etc."issue.d/ip.issue".text = "\\4\n"; + + networking.hostName = "thinkpad"; # Define your hostname. + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # 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.wlp0s20f3.useDHCP = true; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "latarcyrheb-sun32"; + keyMap = "us"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + services.xserver.desktopManager.pantheon.enable = true; + services.xserver.desktopManager.pantheon.extraWingpanelIndicators = [ pkgs.pantheon.wingpanel-indicator-nightlight ]; + #services.xserver.dpi = 144; + + services.xserver = { + videoDrivers = [ "nvidia" ]; +# deviceSection = ''BusID "PCI:0:2:0"''; + }; + + hardware.nvidia.prime = { + offload.enable = true; + + # Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA + intelBusId = "PCI:0:2:0"; + + # Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA + nvidiaBusId = "PCI:1:0:0"; + }; + +# hardware.bumblebee = { +# enable = true; +# connectDisplay = true; +# }; + + hardware.opengl = { + enable = true; + driSupport32Bit = true; + extraPackages = with pkgs; [ + intel-media-driver # LIBVA_DRIVER_NAME=iHD + vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) + vaapiVdpau + libvdpau-va-gl + ]; + }; + + nixpkgs.config.packageOverrides = pkgs: rec { +# bumblebee = pkgs.bumblebee.override { +# extraNvidiaDeviceOptions = '' +# Option "ProbeAllGpus" "false" +# Option "AllowEmptyInitialConfiguration" +# EndSection# + +# Section "ServerLayout" +# Identifier "Layout0" +# Option "AutoAddDevices" "true" # Bumblebee defaults to false +# Option "AutoAddGPU" "false" +# EndSection + +# Section "Screen" # Add this section +# Identifier "Screen0" +# Device "DiscreteNvidia" +# ''; +# }; + vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; + }; + + # Configure keymap in X11 + # services.xserver.layout = "us"; + # services.xserver.xkbOptions = "eurosign:e"; + + fonts.fonts = with pkgs; [ + open-sans + roboto-mono + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + liberation_ttf + fira-code + fira-code-symbols + mplus-outline-fonts + dina-font + proggyfonts + ]; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio.enable = true; + hardware.pulseaudio.support32Bit = true; + + #thinkfan + services.thinkfan = { + enable = true; + levels = [ + [0 0 67] + [1 65 75] + [2 73 80] + [3 78 85] + [4 83 90] + [6 88 95] + [7 93 32767] + ]; + }; + + #nextdns + services.nextdns = { + enable = true; + arguments = [ + "-config" + "aaa56c" + ]; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users = { + defaultUserShell = pkgs.zsh; + + users.alex = { + isNormalUser = true; + extraGroups = [ "wheel" "docker" "networkmanager" ]; + }; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + nixpkgs.config.chromium.commandLineArgs = "--enable-features=WebUIDarkMode,NativeNotifications,VaapiVideoDecoder --ignore-gpu-blocklist --use-gl=desktop --force-dark-mode --disk-cache-dir=/tmp/cache"; + programs.chromium = { + enable = true; + extensions = [ + "cbnipbdpgcncaghphljjicfgmkonflee" # Axel Springer Blocker + "cjpalhdlnbpafiamejdnhcphjbkeiagm" # uBlock Origin + "mnjggcdmjocbbbhaepdhchncahnbgone" # SponsorBlock for YouTube + "gcbommkclmclpchllfjekcdonpmejbdp" # HTTPS Everywhere + "oboonakemofpalcgghocfoadofidjkkk" # KeePassXC-Browser + "fploionmjgeclbkemipmkogoaohcdbig" # Page load time + "egnjhciaieeiiohknchakcodbpgjnchh" # Tab Wrangler + "fnaicdffflnofjppbagibeoednhnbjhg" # Floccus bookmarks + ]; + extraOpts = { + "BrowserSignin" = 0; + "SyncDisabled" = true; + "PasswordManagerEnabled" = false; + "AutofillAddressEnabled" = true; + "AutofillCreditCardEnabled" = false; + "BuiltInDnsClientEnabled" = false; + "MetricsReportingEnabled" = true; + "SearchSuggestEnabled" = false; + "AlternateErrorPagesEnabled" = false; + "UrlKeyedAnonymizedDataCollectionEnabled" = false; + "SpellcheckEnabled" = true; + "SpellcheckLanguage" = [ + "de" + "en-US" + ]; + "CloudPrintSubmitEnabled" = false; + }; + }; + + programs.zsh = { + enable = true; + + enableCompletion = true; + autosuggestions.enable = true; + syntaxHighlighting.enable = true; + + ohMyZsh = { + enable = true; + theme = "agnoster"; + plugins = [ + "cp" + "common-aliases" + "docker " + "systemd" + "wd" + "kubectl" +# "zsh-autosuggestions" +# "zsh-syntax-highlightin" + "git" + ]; + }; + }; + + nixpkgs.config.allowUnfree = true; + environment.systemPackages = with pkgs; [ + nvidia-offload + xorg.xf86videointel + intel-gpu-tools + steam + vscode + ]; + + # 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 = [ 52698 ]; + networking.firewall.allowedUDPPorts = [ 52698 ]; + # 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 = "21.05"; # Did you read the comment? +} + diff --git a/rsync.sh b/rsync.sh old mode 100644 new mode 100755 index b26ef8b..c1527e3 --- a/rsync.sh +++ b/rsync.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + sudo rsync -ah --delete --progress /home/alex/Workspace/nixos-config/ /root/nixos/ sudo rm /etc/nixos/configuration.nix sudo ln -s /root/nixos/machine/`hostname`/configuration.nix /etc/nixos/configuration.nix