From 428f2b7089fb89c37a664c5d93703b1f8d88b4e3 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Sat, 14 Sep 2024 22:23:45 +0200 Subject: [PATCH] feat: initial commit --- flake.lock | 48 ++++++ flake.nix | 22 +++ hosts/default/configuration.nix | 184 +++++++++++++++++++++++ hosts/default/hardware-configuration.nix | 40 +++++ hosts/default/home.nix | 73 +++++++++ modules/home-manager/btop.nix | 11 ++ modules/home-manager/git.nix | 10 ++ modules/home-manager/hyprland.nix | 153 +++++++++++++++++++ modules/home-manager/pass.nix | 13 ++ modules/home-manager/zsh.nix | 25 +++ modules/nixos/main-user.nix | 29 ++++ 11 files changed, 608 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/default/configuration.nix create mode 100644 hosts/default/hardware-configuration.nix create mode 100644 hosts/default/home.nix create mode 100644 modules/home-manager/btop.nix create mode 100644 modules/home-manager/git.nix create mode 100644 modules/home-manager/hyprland.nix create mode 100644 modules/home-manager/pass.nix create mode 100644 modules/home-manager/zsh.nix create mode 100644 modules/nixos/main-user.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a0c9643 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1726308872, + "narHash": "sha256-d4vwO5N4RsLnCY7k5tY9xbdYDWQsY3RDMeUoIa4ms2A=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "6c1a461a444e6ccb3f3e42bb627b510c3a722a57", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1726062873, + "narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4f807e8940284ad7925ebd0a0993d2a1791acb2f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9d6e815 --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + description = "Nixos config flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, ... }@inputs: { + nixosConfigurations.default = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/default/configuration.nix + inputs.home-manager.nixosModules.default + ]; + }; + }; +} diff --git a/hosts/default/configuration.nix b/hosts/default/configuration.nix new file mode 100644 index 0000000..ba2a1c2 --- /dev/null +++ b/hosts/default/configuration.nix @@ -0,0 +1,184 @@ +# 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, inputs, ... }: + +{ + imports = + [ + ../../modules/nixos/main-user.nix + ./hardware-configuration.nix + inputs.home-manager.nixosModules.default + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "nixos"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Vienna"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "de_AT.UTF-8"; + LC_IDENTIFICATION = "de_AT.UTF-8"; + LC_MEASUREMENT = "de_AT.UTF-8"; + LC_MONETARY = "de_AT.UTF-8"; + LC_NAME = "de_AT.UTF-8"; + LC_NUMERIC = "de_AT.UTF-8"; + LC_PAPER = "de_AT.UTF-8"; + LC_TELEPHONE = "de_AT.UTF-8"; + LC_TIME = "de_AT.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + services.pcscd.enable = true; + services.dbus.packages = [ pkgs.gcr ]; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Define a user account. Don't forget to set a password with ‘passwd’. + main-user = { + enable = true; + username = "sprechtl"; + }; + + home-manager = { + extraSpecialArgs = { inherit inputs; }; + users = { + "sprechtl" = import ./home.nix; + }; + }; + + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + vim + wget + usbutils + alacritty + ripgrep + git + brave + pavucontrol + wl-clipboard + wofi + waybar + nerdfonts + gnumake + gccgo + unzip + python3 + go + discord + php83 + nodejs_22 + libgcc + spotify + pass + gnupg + blueman + pinentry-qt + fastfetch + networkmanagerapplet + wdisplays + ]; + + programs = { + neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + }; + firefox.enable = true; + hyprland.enable = true; + gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryPackage = pkgs.pinentry-qt; + }; + }; + + # 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; + # }; + + + services.fprintd.enable = true; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # 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 = "24.05"; # Did you read the comment? + +} diff --git a/hosts/default/hardware-configuration.nix b/hosts/default/hardware-configuration.nix new file mode 100644 index 0000000..9248617 --- /dev/null +++ b/hosts/default/hardware-configuration.nix @@ -0,0 +1,40 @@ +# 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" "thunderbolt" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/ed1afa26-1c26-4da6-a4b4-b5cb6e0b2222"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/1FDC-CD90"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/cee4a6a9-f044-4258-9d4b-35c67cc59e2c"; } + ]; + + # 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.wlp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/default/home.nix b/hosts/default/home.nix new file mode 100644 index 0000000..335a41f --- /dev/null +++ b/hosts/default/home.nix @@ -0,0 +1,73 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../../modules/home-manager/hyprland.nix + ../../modules/home-manager/pass.nix + ../../modules/home-manager/btop.nix + ../../modules/home-manager/git.nix + ../../modules/home-manager/zsh.nix + ]; + home.username = "sprechtl"; + home.homeDirectory = "/home/sprechtl"; + + # 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 should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "24.05"; # Please read the comment before changing. + nixpkgs.config.allowUnfree = true; + home.packages = with pkgs; [ + zsh-autosuggestions + zsh-syntax-highlighting + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/sprechtl/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + EDITOR = "nvim"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/modules/home-manager/btop.nix b/modules/home-manager/btop.nix new file mode 100644 index 0000000..240f1a1 --- /dev/null +++ b/modules/home-manager/btop.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + programs.btop = { + enable = true; + settings = { + color_theme = "gruvbox_dark_v2"; + vim_keys = true; + }; + }; +} diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix new file mode 100644 index 0000000..9c10e02 --- /dev/null +++ b/modules/home-manager/git.nix @@ -0,0 +1,10 @@ +{ config, pkgs, ... }: + +{ + programs.git = { + enable = true; + delta.enable = true; + userEmail = "stefan@tague.at"; + userName = "s-prechtl"; + }; +} diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix new file mode 100644 index 0000000..37c7b5a --- /dev/null +++ b/modules/home-manager/hyprland.nix @@ -0,0 +1,153 @@ +{ config, pkgs, ... }: + +{ + wayland.windowManager.hyprland = { + enable = true; + xwayland.enable = true; + systemd.enable = true; + settings = { + # BINDS + "$mod" = "SUPER"; + bind = [ + "SUPERSHIFT, E, exit" + "$mod, Q, killactive" + "$mod, B, exec, brave" + "$mod, return, exec, alacritty" + "$mod,E,exec,nautilus" + "$mod,D,exec,killall -q wofi; wofi --show drun -I" + "SUPERSHIFT,R,exec,hyprctl reload" + "$mod,space,togglefloating," + "ALTSHIFT, L, exec, swaylock" + "$mod,F,fullscreen" + "ALTSHIFT,K,exec,amixer set 'Master' 5%+" + "ALTSHIFT,J,exec,amixer set 'Master' 5%-" + "SUPERSHIFT,N,exec, swaync-client -t -sw" + "$mod, M, exec,hyprctl keyword monitor 'eDP-1, enable'" + "SUPERSHIFT, M, exec,hyprctl keyword monitor 'eDP-1, disable'" + "SUPERSHIFT,P,exec,hyprshot -m region -o ~/Screenshot/" + "SUPERALTSHIFT, P, exec, hyprshot -m window -o ~/Screenshot/" + + "$mod,left,movefocus,l" + "$mod, H,movefocus,l" + "SUPERALT, left, movewindow, l" + "SUPERALT, H, movewindow, l" + "$mod,right,movefocus,r" + "$mod, L,movefocus,r" + "SUPERALT, right, movewindow, r" + "SUPERALT, L, movewindow, r" + "$mod,up,movefocus,u" + "$mod, K,movefocus,u" + "SUPERALT, up, movewindow, u" + "SUPERALT, K, movewindow, u" + "$mod,down,movefocus,d" + "$mod, J,movefocus,d" + "SUPERALT, down, movewindow, d" + "SUPERALT, J, movewindow, d" + ] + ++ ( + # workspaces + # binds $mod + [shift +] {1..9} to [move to] workspace {1..9} + builtins.concatLists (builtins.genList (i: + let ws = i + 1; + in [ + "$mod, code:1${toString i}, workspace, ${toString ws}" + "$mod SHIFT, code:1${toString i}, movetoworkspace, ${toString ws}" + ] + ) + 9) + ); + + bindm = [ + "$mod, mouse:272,movewindow" + "$mod, mouse:273,resizewindow" + ]; + binde = [ + ",XF86MonBrightnessDown,exec,brightnessctl --device=intel_backlight s 5%-" + ",XF86MonBrightnessUp,exec,brightnessctl --device=intel_backlight s 5%+" + "SUPERSHIFT,right,resizeactive, 10 0" + "SUPERSHIFT,L,resizeactive, 10 0" + "SUPERSHIFT,down,resizeactive, 0 10" + "SUPERSHIFT,J,resizeactive, 0 10" + "SUPERSHIFT,left,resizeactive, -10 0" + "SUPERSHIFT,H,resizeactive, -10 0" + "SUPERSHIFT,up,resizeactive, 0 -10" + "SUPERSHIFT,K,resizeactive, 0 -10" + ]; + + # MONITOR + + monitor = [ + "eDP-1,2560x1600@165.0,0x0,2" + ]; + + # INPUT + + input = { + kb_layout="us"; + kb_options="compose:ralt,caps:escape"; + follow_mouse=2; + + touchpad = { + natural_scroll="yes"; + }; + + sensitivity=0.0; # -1.0 - 1.0, 0 means no modification. + }; + + # GENERAL + general = { + gaps_in=10; + gaps_out=20; + + border_size=2; + "col.active_border"="0xffBF616A"; + "col.inactive_border"="0xffebdbb2"; + }; + + # CURSOR + cursor = { + no_warps=true; + inactive_timeout=3; + }; + + # DECORATION + decoration = { + active_opacity=0.95; + inactive_opacity=0.95; + rounding=10; + }; + + # ANIMATION + animations = { + enabled=1; + bezier="overshot,0.13,0.99,0.29,1.1"; + animation = [ + "windows,1,4,overshot,slide" + "border,1,10,default" + "fade,1,10,default" + "workspaces,1,6,overshot,slide" + ]; + }; + + # EXEC ONCE + exec-once = [ + "waybar" + "nm-applet" + "swaync" + "whatpulse" + ]; + + + # WINDOW RULES + windowrule = [ + "move 400 400, float, title:(jetbrains toolbox)" + "float,wofi" + "opacity 1 override,title:^(.*)(Brave)(.*)$" + ]; + }; +}; + # Optional, hint Electron apps to use Wayland: + home.sessionVariables = { + NIXOS_OZONE_WL = "1"; + }; +} diff --git a/modules/home-manager/pass.nix b/modules/home-manager/pass.nix new file mode 100644 index 0000000..2b1995d --- /dev/null +++ b/modules/home-manager/pass.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + programs.password-store = { + enable = true; + settings = { + PASSWORD_STORE_DIR="$HOME/.password-store"; + PASSWORD_STORE_GENERATED_LENGTH = "20"; + PASSWORD_STORE_ENABLE_EXTENSIONS = "true"; + }; + }; + programs.browserpass.enable = true; +} diff --git a/modules/home-manager/zsh.nix b/modules/home-manager/zsh.nix new file mode 100644 index 0000000..4b9b454 --- /dev/null +++ b/modules/home-manager/zsh.nix @@ -0,0 +1,25 @@ +{ config, pkgs, ... }: + +{ + programs.eza.enable = true; + programs.zsh = { + enable = true; + shellAliases = { + ll = "exa --icons -l"; + l = "exa --icons -la"; + ls = "exa --icons"; + update = "sudo nixos-rebuild switch"; + clear = "clear && fastfetch"; + }; + + history.size = 10000; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + oh-my-zsh = { + enable = true; + plugins = [ "git" "docker" ]; + theme = "strug"; + }; + }; +} diff --git a/modules/nixos/main-user.nix b/modules/nixos/main-user.nix new file mode 100644 index 0000000..fc51b90 --- /dev/null +++ b/modules/nixos/main-user.nix @@ -0,0 +1,29 @@ +{ lib, config, pkgs, ... }: + +let + cfg = config.main-user; +in +{ + options.main-user = { + enable + = lib.mkEnableOption "enable user module"; + + username = lib.mkOption { + default = "mainuser"; + description = '' + username + ''; + }; + }; + + config = lib.mkIf cfg.enable { + programs.zsh.enable = true; + users.users.${cfg.username} = { + isNormalUser = true; + initialPassword = "12345"; + extraGroups = [ "input" "networkmanager" "wheel" ]; + description = "Stefan"; + shell = pkgs.zsh; + }; + }; +}