From a535553cbed54c0d4d0ffad0f2024c7ef8f1e1fc Mon Sep 17 00:00:00 2001 From: MoritzBoehme Date: Wed, 8 Sep 2021 19:43:08 +0200 Subject: [PATCH] added flake --- flake.lock | 100 ++++++++++ flake.nix | 34 ++++ hosts/nixos-laptop/default.nix | 109 +++++++++++ hosts/nixos-laptop/hardware-configuration.nix | 58 ++++++ modules/default.nix | 173 ++++++++++++++++++ 5 files changed, 474 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/nixos-laptop/default.nix create mode 100644 hosts/nixos-laptop/hardware-configuration.nix create mode 100644 modules/default.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..53a1081 --- /dev/null +++ b/flake.lock @@ -0,0 +1,100 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1631051269, + "narHash": "sha256-ZL5TgMYPpRUWN/GGdJ7gIiYjxaWI+EP8HdFT1GZ+wd0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "275f39611dc32243842d5818141278b5676653f2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1631117094, + "narHash": "sha256-FMdGgsJq1wGmMo98KjyUPN5ofqxuEru4ZmAn80LXa/8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b5c0ce5bef110c66d4cff87289c1b462ea7031ec", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "unstable": "unstable", + "utils": "utils" + } + }, + "unstable": { + "locked": { + "lastModified": 1631015389, + "narHash": "sha256-9SKTwRbp7OQGa4wKTo1wB6ctC2VlaIeKFZ+flqzPuoI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "bc06c93905f60a82d6ebbb78f78cf289257860cc", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "utils": { + "inputs": { + "flake-utils": "flake-utils" + }, + "locked": { + "lastModified": 1631019843, + "narHash": "sha256-DUcnmOHK35JGfseRT/hhf5jSaN0+pSi9zoI9vLstlZk=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "8cd9fd963f7ff2fa5c11177cd9d8f9199b60e54b", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "ref": "release-1.2.0-without-deprecated-code", + "repo": "flake-utils-plus", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e05bdc0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "My awesome system config"; + + inputs = { + nixpkgs.url = github:nixos/nixpkgs/release-21.05; + unstable.url = github:nixos/nixpkgs/nixos-unstable; + utils.url = github:gytis-ivaskevicius/flake-utils-plus/release-1.2.0-without-deprecated-code; + + home-manager = { + url = github:nix-community/home-manager; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs@{ self, utils, home-manager, ...}: { + utils.lib.mkFlake = { + inherit self inputs; + + # Channel definitions. + # Channels are automatically generated from nixpkgs inputs + # e.g the inputs which contain `legacyPackages` attribute are used. + channelsConfig.allowUnfree = true; + + hostDefaults.modules = [ + home-manager.nixos.Modules.home-manager + ./modules + ]; + + hosts.nixos-laptop.modules = [ + ./hosts/nixos-laptop + ]; + }; + }; +} diff --git a/hosts/nixos-laptop/default.nix b/hosts/nixos-laptop/default.nix new file mode 100644 index 0000000..40ea691 --- /dev/null +++ b/hosts/nixos-laptop/default.nix @@ -0,0 +1,109 @@ +# 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 + ]; + + nix.package = pkgs.nixFlakes; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + + # BOOT + boot = { + supportedFilesystems = [ "btrfs" ]; + loader = { + grub = { + enable = true; + version = 2; + device = "nodev"; + efiSupport = true; + }; + efi.canTouchEfiVariables = true; + }; + kernelPackages = pkgs.linuxPackages_zen; + }; + + # NETWORKING + networking = { + hostName = "nixos-laptop"; + 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; + }; + }; + + libinput.enable = true; + + windowManager.bspwm.enable = true; + }; + printing.enable = true; + }; + + # Enable sound. + services.pipewire.enable = true; + + # Powersaving + services.tlp.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" "JetBrainsMono"];}) + ]; + + # 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/hosts/nixos-laptop/hardware-configuration.nix b/hosts/nixos-laptop/hardware-configuration.nix new file mode 100644 index 0000000..13440c6 --- /dev/null +++ b/hosts/nixos-laptop/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/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..6133ca2 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,173 @@ +{ 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 = { + 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 = { + 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 = { + 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; + }; + }; + + exa.enable = true; + bat.enable = true; + + starship = { + enable = true; + enableZshIntegration = true; + }; + + rofi = { + enable = true; + theme = ~/.dotfiles/config/rofi/dracula_old.rasi; + }; + + emacs.enable = true; + }; + + xdg = { + enable = true; + configFile = { + "sxhkd/sxhkdrc" = { + source = ~/.dotfiles/config/sxhkd/sxhkdrc; + onChange = "pkill -USR1 -x sxhkd"; + }; + "bspwm/bspwmrc" = { + source = ~/.dotfiles/config/bspwm/bspwmrc; + onChange = "bspc wm -r"; + }; + "doom" = { + source = ~/.dotfiles/config/doom; + recursive = true; + onChange = builtins.readFile ~/.dotfiles/config/doom/reload.sh; + }; + "dunst/dunstrc" = { + source = ~/.dotfiles/config/dunst/dunstrc; + }; + }; + }; + + services = { + polybar = { + enable = true; + script = ''for m in $(polybar --list-monitors | ${pkgs.coreutils}/bin/cut -d":" -f1); do + MONITOR=$m polybar --reload bottom & + done + ''; + config = ~/.dotfiles/config/polybar/config.ini; + extraConfig = builtins.readFile ~/.dotfiles/config/polybar/modules.ini + + builtins.readFile ~/.dotfiles/config/polybar/colors.ini; + }; + + picom = { + enable = true; + inactiveOpacity = "0.95"; + opacityRule = [ + "100:fullscreen" + "80 :class_g = 'Polybar'" + ]; + blur = true; + inactiveDim = "0.1"; + }; + + emacs = { + enable = true; + package = pkgs.emacsUnstable; + }; + + dunst.enable = true; + + kdeconnect.enable = true; + }; + + + home.packages = with pkgs; [ + neofetch + feh + keepassxc + ]; + + nixpkgs.overlays = [ + (import (builtins.fetchTarball { + url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz; + })) + ]; + + # 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"; +}