diff --git a/apply-system.sh b/apply-system.sh new file mode 100755 index 0000000..cb7c679 --- /dev/null +++ b/apply-system.sh @@ -0,0 +1,4 @@ +#!/bin/sh +pushd ~/.dotfiles +sudo nixos-rebuild switch -I nixos-config=./system/configuration.nix +popd diff --git a/apply-users.sh b/apply-users.sh new file mode 100755 index 0000000..46188e8 --- /dev/null +++ b/apply-users.sh @@ -0,0 +1,4 @@ +#!/bin/sh +pushd ~/.dotfiles +home-manager switch -f ./users/moritz/home.nix +popd diff --git a/system/configuration.nix b/system/configuration.nix new file mode 100644 index 0000000..fd3e836 --- /dev/null +++ b/system/configuration.nix @@ -0,0 +1,98 @@ +# 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 = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # BOOT + boot.supportedFilesystems = [ "btrfs" ]; + boot.loader = { + grub = { + enable = true; + version = 2; + device = "nodev"; + efiSupport = true; + }; + efi.canTouchEfiVariables = true; + }; + + # NETWORKING + networking = { + hostName = "nixos"; + networkmanager.enable = true; + + useDHCP = false; + interfaces.wlp1s0.useDHCP = true; + }; + + # LOCALS + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "firacode-14"; + keyMap = "de"; + }; + time.timeZone = "Europe/Berlin"; + + # SERVICES + services = { + xserver = { + enable = true; + layout = "de"; + + displayManager = { + defaultSession = "none+bspwm"; + + autoLogin = { + enable = true; + user = "moritz"; + }; + lightdm = { + enable = true; + }; + }; + + windowManager.bspwm.enable = true; + }; + printing.enable = true; + }; + # HOMEMANAGER + + # Enable sound. + sound.enable = true; + hardware.pulseaudio.enable = true; + + # USERS + users.users.moritz = { + shell = pkgs.zsh; + isNormalUser = true; + home = "/home/moritz"; + extraGroups = [ "wheel" "networkmanager" "video" ]; # Enable ‘sudo’ for the user. + }; + + fonts.fonts = with pkgs; [ + (nerdfonts.override { fonts = [ "FiraCode" "DroidSansMono" ];}) + ]; + + # PACKAGES + environment.systemPackages = with pkgs; [ + vim + wget + firefox + ]; + + # 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/system/hardware-configuration.nix b/system/hardware-configuration.nix new file mode 100644 index 0000000..13440c6 --- /dev/null +++ b/system/hardware-configuration.nix @@ -0,0 +1,58 @@ +# 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 = [ "nvme" "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/4a91d3eb-1633-42d9-8304-c10e49a61154"; + fsType = "btrfs"; + options = [ "subvol=root" ]; + }; + + boot.initrd.luks.devices."enc".device = "/dev/disk/by-uuid/078b81ba-238e-471d-9951-b743588532b8"; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/4a91d3eb-1633-42d9-8304-c10e49a61154"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/4a91d3eb-1633-42d9-8304-c10e49a61154"; + fsType = "btrfs"; + options = [ "subvol=nix" ]; + }; + + fileSystems."/persist" = + { device = "/dev/disk/by-uuid/4a91d3eb-1633-42d9-8304-c10e49a61154"; + fsType = "btrfs"; + options = [ "subvol=persist" ]; + }; + + fileSystems."/log" = + { device = "/dev/disk/by-uuid/4a91d3eb-1633-42d9-8304-c10e49a61154"; + fsType = "btrfs"; + options = [ "subvol=log" ]; + neededForBoot = true; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/938D-F813"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/29ebf65f-e6ca-4625-9f72-a9321152be1b"; } + ]; + +} diff --git a/update-system.sh b/update-system.sh new file mode 100755 index 0000000..0a7262f --- /dev/null +++ b/update-system.sh @@ -0,0 +1,2 @@ +#!/bin/sh +sudo nix-channel --update diff --git a/update-users.sh b/update-users.sh new file mode 100755 index 0000000..aadccd6 --- /dev/null +++ b/update-users.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nix-channel --update diff --git a/users/moritz/home.nix b/users/moritz/home.nix new file mode 100644 index 0000000..36eacf2 --- /dev/null +++ b/users/moritz/home.nix @@ -0,0 +1,146 @@ +{ config, pkgs, ... }: + +{ + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + # paths it should manage. + home.username = "moritz"; + home.homeDirectory = "/home/moritz"; + + programs.git = { + enable = true; + userName = "MoritzBoehme"; + userEmail = "mr.x@moritzboeh.me"; + }; + + # Zathura + programs.zathura = { + enable = true; + options = { + recolor = true; + completion-bg = "#282a36"; + completion-fg = "#ff79c6"; + default-bg = "#44475a"; + default-fg = "#bd93f9"; + inputbar-bg = "#282a36"; + inputbar-fg = "#8be9fd"; + statusbar-bg = "#282a36"; + statusbar-fg = "#bd93f9"; + font = "Jetbrains Mono 9"; + recolor-lightcolor = "#282a36"; + recolor-darkcolor = "#f8f8f2"; + }; + }; + + # Zsh + programs.zsh = { + enable = true; + + shellGlobalAliases = { + ls = "exa -lh"; + cat = "bat"; + }; + + plugins = [ + { + name = "zsh-autosuggestions"; + src = pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-autosuggestions"; + rev = "v0.4.0"; + sha256 = "0z6i9wjjklb4lvr7zjhbphibsyx51psv50gm07mbb0kj9058j6kc"; + }; + } + { + name = "zsh-syntax-highlighting"; + src = pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-syntax-highlighting"; + rev = "0e1bb14452e3fc66dcc81531212e1061e02c1a61"; + sha256 = "09ncmyqlk9a3h470z0wgbkrznb5zyc9dj96011wm89rdxc1irxk2"; + }; + } + ]; + }; + + # Kitty + programs.kitty = { + enable = true; + settings = { + scrollback_lines = 10000; + enable_audio_bell = false; + cursor_shape = "underline"; + }; + extraConfig = builtins.readFile ~/.dotfiles/config/kitty/dracula.conf; + font = { + name = "FiraCode Nerd Font"; + size = 10; + }; + }; + + programs.exa.enable = true; + programs.bat.enable = true; + + programs.starship = { + enable = true; + enableZshIntegration = true; + }; + + services.polybar = { + enable = true; + script = '' + # Terminate already running bar instances + killall -q polybar + + # Wait until the processes have been shut down + while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + while ! pgrep -x bspwm >/dev/null; do sleep 1; done + + # Launch Polybar + for m in $(polybar --list-monitors | cut -d":" -f1); do + MONITOR=$m polybar --reload bottom & + done + ''; + config = { + "bar/bottom" = { + monitor = "\${env:MONITOR}"; + bottom = true; + fixed-center = true; + width = "100%"; + height = 25; + background = "\${color.background-alt}"; + foreground = "\${color.foreground}"; + line-size = 3; + border-size = 0; + padding-left = 1; + padding-right = 1; + module-margin-left = 3; + module-margin-right = 3; + font-0 = "NotoSans Nerd Font:size=11;0"; + modules-left = "cpu memory wlan eth battery"; + modules-center = "bspwm"; + modules-right = "pulseaudio date powermenu"; + tray-position = "right"; + tray-background = "\${color.background-alt}"; + tray-padding = 2; + wm-restack = "bspwm"; + cursor-click = "pointer"; + }; + }; + }; + + home.packages = with pkgs; [ + neofetch + ]; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "21.05"; +}