From 9e4582d3512f8613b0aac4988a39ac3036bdf543 Mon Sep 17 00:00:00 2001 From: Rouven Seifert Date: Sun, 18 Dec 2022 17:01:34 +0100 Subject: [PATCH] initial commit --- flake.lock | 78 ++++++++ flake.nix | 18 ++ hosts/thinkpad/configuration.nix | 208 ++++++++++++++++++++++ hosts/thinkpad/hardware-configuration.nix | 38 ++++ 4 files changed, 342 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100755 hosts/thinkpad/configuration.nix create mode 100755 hosts/thinkpad/hardware-configuration.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..30c1d31 --- /dev/null +++ b/flake.lock @@ -0,0 +1,78 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1671335968, + "narHash": "sha256-V7mjlh7brp70elokmml6XzHinpTilkQJjiYIGjEmSGs=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "37713c6b04b963d41664e03576f73a18c9b0d224", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1671200928, + "narHash": "sha256-mZfzDyzojwj6I0wyooIjGIn81WtGVnx6+avU5Wv+VKU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "757b82211463dd5ba1475b6851d3731dfe14d377", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1671215800, + "narHash": "sha256-2W54K41A7MefEaWzgL/TsaWlhKRK/RhWUybyOW4i0K8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9d692a724e74d2a49f7c985132972f991d144254", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" + } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..57a3740 --- /dev/null +++ b/flake.nix @@ -0,0 +1,18 @@ +{ + description = "My hardware setup"; + inputs = { + nixpkgs.url = github:nixos/nixpkgs/nixos-22.11; + home-manager.url = github:nix-community/home-manager; + }; + + outputs = { self, nixpkgs, home-manager }: { + nixosConfigurations = { + thinkpad = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./hosts/thinkpad/configuration.nix + ]; + }; + }; + }; +} diff --git a/hosts/thinkpad/configuration.nix b/hosts/thinkpad/configuration.nix new file mode 100755 index 0000000..30459af --- /dev/null +++ b/hosts/thinkpad/configuration.nix @@ -0,0 +1,208 @@ +{ config, pkgs, lib, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "thinkpad"; # Define your hostname. + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + networking.firewall = { + allowedUDPPorts = [51820]; + checkReversePath = false; + }; + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + useXkbConfig = true; # use xkbOptions in tty. + }; + + # Enable the X11 windowing system. + services.xserver = { + enable = true; + + displayManager = { + lightdm.enable = true; + defaultSession = "none+awesome"; + }; + windowManager.awesome = { + enable = true; + luaModules = with pkgs.luaPackages; [ + luarocks + vicious + ]; + }; + libinput.enable = true; + }; + + + + # Configure keymap in X11 + services.xserver.layout = "us"; + services.xserver.xkbVariant = "dvorak-alt-intl"; + services.xserver.displayManager.sessionCommands = + "${pkgs.xorg.xmodmap}/bin/xmodmap ${pkgs.writeText "xkb-layout" '' + keycode 108 = Mode_switch + keycode 94 = Shift_L NoSymbol Shift_L + keysym a = a A adiaeresis Adiaeresis + keysym o = o O odiaeresis Odiaeresis + keysym u = u U udiaeresis Udiaeresis + keysym s = s S ssharp + ''}"; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio.enable = true; + hardware.bluetooth.enable = true; + + environment.variables = { EDITOR = "vim"; }; + + # enable polkit + security.polkit.enable = true; + + # Define a user account. + users.users.rouven = { + isNormalUser = true; + extraGroups = [ "wheel" "video" "network" "libvirtd"]; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + ((vim_configurable.override { }).customize{ + name = "vim"; + vimrcConfig.packages.myplugins = with pkgs.vimPlugins; { + start = [ vim-nix vim-lastplace ]; + opt = []; + }; + vimrcConfig.customRC = '' + + " basic commands bound to uppercase key + command Q q + command W w + command Wq wq + command WQ wq + + set number relativenumber + set tabstop=4 + set shiftwidth=4 + set smartcase + set colorcolumn=120 + set nowrap + syntax on + highlight ColorColumn ctermbg=darkgray + + nnoremap ; : + nnoremap : ; + vnoremap ; : + vnoremap : ; + + " set space as leader + nnoremap + let mapleader = " " + + + " beautify indents + :set list lcs=tab:\|\ + + "remove ex-mode shortcut + nmap Q + + " quickfixlist binds + nnoremap :cnext + nnoremap :cprev + + " locallist binds + nnoremap :lnext + nnoremap :lprev + + " split keybinds + nnoremap s :sp + nnoremap v :vs + + nnoremap h h + nnoremap j j + nnoremap k k + nnoremap l l + ''; + } + ) + # essentials + wget + git + gcc + htop + tmux + dig + traceroute + killall + xorg.xmodmap + # libs + libyubikey + libfido2 + # dev + jdk + maven + # virtualisation + virt-manager + ]; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + programs.light.enable = true; # display brightness manager + programs.kdeconnect.enable = true; + + # List services that you want to enable: + services.blueman.enable = true; + services.devmon.enable = true; + services.pcscd.enable = true; # yubikey and smartcard stuff + services.printing.enable = true; + services.fprintd.enable = true; + + # Automatically configure displays + services.autorandr.enable = true; + + + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "steam" + "steam-original" + "steam-runtime" + "steam-run" + ]; + + programs.steam.enable = true; + + services.udev.packages = [ pkgs.yubikey-personalization ]; + + virtualisation.libvirtd.enable = true; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + system.copySystemConfiguration = true; + + # 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 = "22.11"; # Did you read the comment? + +} + diff --git a/hosts/thinkpad/hardware-configuration.nix b/hosts/thinkpad/hardware-configuration.nix new file mode 100755 index 0000000..b7e2c70 --- /dev/null +++ b/hosts/thinkpad/hardware-configuration.nix @@ -0,0 +1,38 @@ +# 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 = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "usbhid" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/8633a706-bf54-4d29-9fba-dbcffd723ab6"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/3A2E-1AB6"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + # 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.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp9s0.useDHCP = lib.mkDefault true; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +}