diff --git a/flake.nix b/flake.nix index 12042a2..9aca032 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,8 @@ ... }: let inherit (self) outputs; - specialArgs = {inherit inputs outputs;}; + user = "joonas"; + specialArgs = {inherit inputs outputs user;}; in { nixosModules = import ./modules; homeManagerModules = import ./home-modules; diff --git a/home-modules/common.nix b/home-modules/common.nix index dd21c29..5fff170 100644 --- a/home-modules/common.nix +++ b/home-modules/common.nix @@ -1,40 +1,12 @@ { - pkgs, - user, - ... -}: { home.stateVersion = "23.11"; + programs.home-manager.enable = true; dconf.enable = true; + nixpkgs.config.allowUnfree = true; systemd.user.startServices = "sd-switch"; - programs.home-manager.enable = true; - - # temp fix while sourcehut is down - manual.manpages.enable = false; - - # this needs to be done separately for home manager - nixpkgs = { - config.allowUnfree = true; - overlays = import ../overlays {inherit pkgs;}; - }; - - xdg = { - enable = true; - userDirs = { - enable = true; - desktop = "/home/${user}"; - templates = "/home/${user}"; - publicShare = "/home/${user}"; - documents = "/home/${user}/documents"; - download = "/home/${user}/downloads"; - music = "/home/${user}/music"; - pictures = "/home/${user}/pictures"; - videos = "/home/${user}/videos"; - }; - desktopEntries."transmission-magnet" = { - name = "Transmission add torrent"; - exec = ''add-torrent %u''; - mimeType = ["x-scheme-handler/magnet"]; - }; + services = { + easyeffects.enable = true; + udiskie.enable = true; }; } diff --git a/home-modules/default.nix b/home-modules/default.nix index 187c65d..1568a21 100644 --- a/home-modules/default.nix +++ b/home-modules/default.nix @@ -1,26 +1,57 @@ # Reusable Home-manager modules -{ +rec { + polybar = import ./polybar; + xmonad = import ./xmonad; common = import ./common.nix; - neovim = import ./neovim.nix; - zsh = import ./zsh.nix; - xresources = import ./xresources.nix; - wezterm = import ./wezterm.nix; - xinitrc = import ./xinitrc.nix; + dark-mode = import ./dark-mode.nix; + discord = import ./discord.nix; dunst = import ./dunst.nix; - picom = import ./picom.nix; + firefox = import ./firefox.nix; + flameshot = import ./flameshot.nix; git = import ./git.nix; - ssh-personal = import ./ssh-personal.nix; - ssh-work = import ./ssh-work.nix; + gtk = import ./gtk.nix; hidpi = import ./hidpi.nix; - rofi = import ./rofi.nix; - discord = import ./discord.nix; + imv = import ./imv.nix; + mpv = import ./mpv.nix; + neovim = import ./neovim.nix; + picom = import ./picom.nix; redshift = import ./redshift.nix; - flameshot = import ./flameshot.nix; + rofi = import ./rofi.nix; + ssh-personal = import ./ssh-personal.nix; + ssh-work = import ./ssh-work.nix; starship = import ./starship.nix; - imv = import ./imv.nix; + wezterm = import ./wezterm.nix; + xdg = import ./xdg.nix; + xinitrc = import ./xinitrc.nix; + xresources = import ./xresources.nix; yazi = import ./yazi.nix; - gtk = import ./gtk.nix; - xmonad = import ./xmonad; - polybar = import ./polybar; - mpv = import ./mpv.nix; + zsh = import ./zsh.nix; + + default-modules = [ + polybar + xmonad + common + dark-mode + discord + dunst + firefox + flameshot + git + gtk + imv + mpv + neovim + picom + redshift + rofi + ssh-personal + ssh-work + starship + wezterm + xdg + xinitrc + xresources + yazi + zsh + ]; } diff --git a/home-modules/firefox.nix b/home-modules/firefox.nix new file mode 100644 index 0000000..baeab69 --- /dev/null +++ b/home-modules/firefox.nix @@ -0,0 +1,9 @@ +{ + programs.firefox = { + enable = true; + policies = { + DownloadDirectory = "\${home}/downloads"; + OfferToSaveLogins = false; + }; + }; +} diff --git a/home-modules/flameshot.nix b/home-modules/flameshot.nix index 02c41ca..6c8809a 100644 --- a/home-modules/flameshot.nix +++ b/home-modules/flameshot.nix @@ -6,8 +6,6 @@ General = { disabledTrayIcon = true; showStartupLaunchMessage = false; - # breaks clipboard.. - # useJpgForClipboard = true; checkForUpdates = false; savePath = "/home/${user}/pictures/screenshots"; }; diff --git a/home-modules/xdg.nix b/home-modules/xdg.nix new file mode 100644 index 0000000..d114833 --- /dev/null +++ b/home-modules/xdg.nix @@ -0,0 +1,22 @@ +{user, ...}: { + xdg = { + enable = true; + userDirs = { + enable = true; + desktop = "/home/${user}"; + templates = "/home/${user}"; + publicShare = "/home/${user}"; + documents = "/home/${user}/documents"; + download = "/home/${user}/downloads"; + music = "/home/${user}/music"; + pictures = "/home/${user}/pictures"; + videos = "/home/${user}/videos"; + }; + + desktopEntries."transmission-magnet" = { + name = "Transmission add torrent"; + exec = ''add-torrent %u''; + mimeType = ["x-scheme-handler/magnet"]; + }; + }; +} diff --git a/home-modules/xmonad/default.nix b/home-modules/xmonad/default.nix index e33d270..7267749 100644 --- a/home-modules/xmonad/default.nix +++ b/home-modules/xmonad/default.nix @@ -9,4 +9,13 @@ enableContribAndExtras = true; config = ./xmonad.hs; }; + + home.packages = [ + (pkgs.haskellPackages.ghcWithPackages (p: + with p; [ + xmobar + xmonad + xmonad-contrib + ])) + ]; } diff --git a/hosts/hetzner/configuration.nix b/hosts/hetzner/configuration.nix index b1e368f..32e316e 100644 --- a/hosts/hetzner/configuration.nix +++ b/hosts/hetzner/configuration.nix @@ -2,21 +2,18 @@ lib, inputs, outputs, - config, pkgs, modulesPath, ... -}: let - user = "joonas"; -in { +}: { imports = lib.flatten [ (modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/profiles/qemu-guest.nix") (with outputs.nixosModules; [ - (common {inherit user pkgs outputs;}) - (syncthing {inherit user config lib;}) - (ssh-access {inherit user;}) - (docker {inherit user;}) + common + syncthing + ssh-access + docker nginx ]) inputs.disko.nixosModules.disko @@ -29,8 +26,6 @@ in { boot = { initrd.availableKernelModules = ["ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod"]; loader.grub = { - # no need to set devices, disko will add all devices that have a EF02 partition to the list already - # devices = [ ]; efiSupport = true; efiInstallAsRemovable = true; }; @@ -49,8 +44,8 @@ in { environment.systemPackages = with pkgs; [ neovim - wget git + busybox ]; services.syncthing = { diff --git a/hosts/unikie/configuration.nix b/hosts/unikie/configuration.nix index 56b6eed..97e3694 100644 --- a/hosts/unikie/configuration.nix +++ b/hosts/unikie/configuration.nix @@ -2,15 +2,12 @@ pkgs, lib, outputs, - config, ... -}: let - user = "joonas"; -in { +}: { imports = lib.flatten [ (with outputs.nixosModules; [ - (common {inherit user pkgs outputs;}) - (syncthing {inherit user config lib;}) + common + syncthing laptop bluetooth gui diff --git a/hosts/x1/configuration.nix b/hosts/x1/configuration.nix index 4692439..eb6fd70 100644 --- a/hosts/x1/configuration.nix +++ b/hosts/x1/configuration.nix @@ -2,42 +2,29 @@ inputs, outputs, lib, - config, pkgs, ... -}: let - user = "joonas"; - system = "x86_64-linux"; -in { +}: { imports = lib.flatten [ (with outputs.nixosModules; [ - (common {inherit user pkgs outputs;}) - (syncthing {inherit user config lib;}) - (docker {inherit user;}) + common + syncthing + docker + bootloader laptop bluetooth gui work-vpn keyd - (bin {inherit inputs system;}) + bin ]) (with inputs.nixos-hardware.nixosModules; [ lenovo-thinkpad-x1-11th-gen ]) - (import ./home.nix {inherit inputs outputs pkgs user lib;}) ./hardware-configuration.nix + ./home.nix ]; - boot = { - # force S3 sleep mode - kernelParams = ["mem_sleep_default=deep"]; - - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - }; - networking = { hostName = "x1"; hostId = "c08d7d71"; @@ -55,10 +42,6 @@ in { }; tailscale.enable = true; - - # fingerprint scanner daemon - # to enroll a finger, use sudo fprintd-enroll $USER - fprintd.enable = false; }; environment.systemPackages = lib.flatten [ diff --git a/hosts/x1/home.nix b/hosts/x1/home.nix index 30a3a46..faba9e7 100644 --- a/hosts/x1/home.nix +++ b/hosts/x1/home.nix @@ -3,47 +3,26 @@ outputs, pkgs, user, - lib, ... }: { imports = [ inputs.home-manager.nixosModules.home-manager ]; - home-manager.users."${user}" = { - imports = pkgs.lib.flatten [ - (with outputs.homeManagerModules; [ - (common {inherit pkgs user;}) - xresources - (neovim {inherit pkgs user;}) - zsh - wezterm - xinitrc - picom - git - ssh-personal - ssh-work - dunst - rofi - discord - redshift - (flameshot {inherit user;}) - starship - imv - yazi - gtk - xmonad - polybar - mpv - ]) - inputs.nixvim.homeManagerModules.nixvim - inputs.nix-index-database.hmModules.nix-index - ]; + home-manager = { + extraSpecialArgs = {inherit user;}; - services = { - easyeffects.enable = true; - batsignal.enable = true; - udiskie.enable = true; + users."${user}" = { + imports = pkgs.lib.flatten [ + (with outputs.homeManagerModules; [ + default-modules + hidpi + ]) + inputs.nixvim.homeManagerModules.nixvim + inputs.nix-index-database.hmModules.nix-index + ]; + + services.batsignal.enable = true; }; }; } diff --git a/hosts/zeus/configuration.nix b/hosts/zeus/configuration.nix index 8b98ed4..532cdb2 100644 --- a/hosts/zeus/configuration.nix +++ b/hosts/zeus/configuration.nix @@ -2,23 +2,20 @@ inputs, outputs, lib, - config, pkgs, ... -}: let - user = "joonas"; - system = "x86_64-linux"; -in { +}: { imports = lib.flatten [ (with outputs.nixosModules; [ - (common {inherit user pkgs outputs;}) - (syncthing {inherit user config lib;}) - (docker {inherit user;}) + common + syncthing + docker + bootloader bluetooth gui work-vpn keyd - (bin {inherit inputs system;}) + bin ]) (with inputs.nixos-hardware.nixosModules; [ common-cpu-amd @@ -26,17 +23,10 @@ in { common-pc-ssd common-pc ]) - (import ./home.nix {inherit inputs outputs pkgs user lib;}) ./hardware-configuration.nix + ./home.nix ]; - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - }; - networking = { hostName = "zeus"; hostId = "c5a9072d"; @@ -58,9 +48,6 @@ in { }; }; - # Enable firmware update - services.fwupd.enable = true; - services.transmission = { enable = true; settings = { @@ -69,28 +56,8 @@ in { }; }; - # better for steam proton games - systemd.extraConfig = "DefaultLimitNOFILE=1048576"; - - programs.gamemode.enable = true; - - # Add opengl/vulkan support - hardware.opengl.extraPackages = with pkgs; [ - libva - ]; - - hardware.pulseaudio.daemon.config = { - default-sample-format = "float32le"; - }; - - hardware.xone.enable = true; - services.xserver = { - libinput = { - enable = true; - mouse.accelProfile = "flat"; - }; - + videoDrivers = ["amdgpu"]; xrandrHeads = [ { output = "DisplayPort-0"; @@ -101,68 +68,34 @@ in { ''; } ]; - - videoDrivers = ["amdgpu"]; }; environment.systemPackages = lib.flatten [ ( with pkgs; [ - # languages and dev tools + # development python3 rustup lua nodejs statix - (haskellPackages.ghcWithPackages (hpkgs: - with hpkgs; [ - xmobar - xmonad - xmonad-contrib - ])) + actionlint + gitmoji-cli - # apps + # gui apps spotify darktable slack pavucontrol pcmanfm obsidian - dwmblocks gimp - firefox chromium - keyd - # open source minecraft launcher - prismlauncher prusa-slicer - # cli tools + # cli apps ffmpeg-full - fastfetch - wget - mons - file - bottom - xdotool - playerctl - pulseaudio - alsa-utils - jq # json parser - fd # faster find - dig - rsync glow # render markdown on the cli - xclip - pciutils - usbutils - vulkan-tools - mangohud - gitmoji-cli - actionlint - - # libs - libnotify ] ) ]; diff --git a/hosts/zeus/home.nix b/hosts/zeus/home.nix index 798cdd3..67dd1fd 100644 --- a/hosts/zeus/home.nix +++ b/hosts/zeus/home.nix @@ -3,46 +3,23 @@ outputs, pkgs, user, - lib, ... }: { imports = [ inputs.home-manager.nixosModules.home-manager ]; - home-manager.users."${user}" = { - imports = pkgs.lib.flatten [ - (with outputs.homeManagerModules; [ - (common {inherit pkgs user;}) - xresources - (neovim {inherit pkgs user;}) - zsh - wezterm - xinitrc - picom - git - ssh-personal - ssh-work - dunst - rofi - discord - redshift - (flameshot {inherit user;}) - starship - imv - yazi - gtk - xmonad - polybar - mpv - ]) - inputs.nixvim.homeManagerModules.nixvim - inputs.nix-index-database.hmModules.nix-index - ]; + home-manager = { + extraSpecialArgs = {inherit user;}; - services = { - easyeffects.enable = true; - udiskie.enable = true; + users."${user}" = { + imports = pkgs.lib.flatten [ + (with outputs.homeManagerModules; [ + default-modules + ]) + inputs.nixvim.homeManagerModules.nixvim + inputs.nix-index-database.hmModules.nix-index + ]; }; }; } diff --git a/modules/bin.nix b/modules/bin.nix index a372d5a..3748a3c 100644 --- a/modules/bin.nix +++ b/modules/bin.nix @@ -1,7 +1,9 @@ { inputs, - system, + pkgs, ... }: { - environment.systemPackages = builtins.attrValues inputs.bin.packages.${system}; + environment.systemPackages = ( + builtins.attrValues inputs.bin.packages.${pkgs.system} + ); } diff --git a/modules/bootloader.nix b/modules/bootloader.nix new file mode 100644 index 0000000..de71bc4 --- /dev/null +++ b/modules/bootloader.nix @@ -0,0 +1,8 @@ +{ + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + }; +} diff --git a/modules/common.nix b/modules/common.nix index 3aabd11..c33e9c9 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -9,12 +9,10 @@ i18n.defaultLocale = "en_US.UTF-8"; boot.blacklistedKernelModules = ["pcspkr"]; + hardware.enableAllFirmware = true; - nixpkgs = { - config.allowUnfree = true; - overlays = import ../overlays {inherit pkgs;}; - }; + nixpkgs.config.allowUnfree = true; # allow old electron for obsidian version <= 1.4.16" # https://github.com/NixOS/nixpkgs/issues/273611 @@ -58,6 +56,8 @@ }; }; + # login automatically to my user + # this is fine because the hard drive is encrypted anyway services.getty = { autologinUser = user; helpLine = ""; @@ -78,12 +78,27 @@ }; polkit.enable = true; - audit.enable = true; - auditd.enable = true; }; networking = { networkmanager.enable = true; firewall.enable = true; }; + + environment.systemPackages = with pkgs; [ + busybox + fastfetch + file + bottom + xdotool + playerctl + pulseaudio + jq + fd # faster find + dig + rsync + xclip + pciutils + usbutils + ]; } diff --git a/modules/default.nix b/modules/default.nix index 5c1b208..cf41b75 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,15 +1,18 @@ # Reusable NixOS modules { - laptop = import ./laptop.nix; - common = import ./common.nix; + bin = import ./bin.nix; bluetooth = import ./bluetooth.nix; - gui = import ./gui.nix; - syncthing = import ./syncthing.nix; - work-vpn = import ./work-vpn.nix; - ssh-access = import ./ssh-access.nix; - nginx = import ./nginx.nix; + bootloader = import ./bootloader.nix; + common = import ./common.nix; docker = import ./docker.nix; + gaming = import ./gaming.nix; + gui = import ./gui.nix; keyd = import ./keyd.nix; + laptop = import ./laptop.nix; + nginx = import ./nginx.nix; + sound = import ./sound.nix; + ssh-access = import ./ssh-access.nix; + syncthing = import ./syncthing.nix; trackpoint = import ./trackpoint.nix; - bin = import ./bin.nix; + work-vpn = import ./work-vpn.nix; } diff --git a/modules/gaming.nix b/modules/gaming.nix new file mode 100644 index 0000000..b365b4c --- /dev/null +++ b/modules/gaming.nix @@ -0,0 +1,32 @@ +{pkgs, ...}: { + programs = { + steam.enable = true; + gamemode.enable = true; + # for minecraft + java.enable = true; + }; + + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + # better for steam proton games + systemd.extraConfig = "DefaultLimitNOFILE=1048576"; + + # Add opengl/vulkan support + hardware.opengl.extraPackages = with pkgs; [ + libva + ]; + + # Xbox wireless controller driver + hardware.xone.enable = true; + + environment.systemPackages = with pkgs; [ + vulkan-tools + mangohud + # open source minecraft launcher + prismlauncher + ]; +} diff --git a/modules/gui.nix b/modules/gui.nix index 0dfb3b6..2186a70 100644 --- a/modules/gui.nix +++ b/modules/gui.nix @@ -54,46 +54,38 @@ }; }; - services.xserver = { - enable = true; - xkb.layout = "eu"; - autoRepeatDelay = 300; - autoRepeatInterval = 25; - - # window and display manager - # windowManager.dwm.enable = true; - displayManager.startx.enable = true; - }; - - security = { - # for pipewire - rtkit.enable = true; - }; - - # use X keyboard options in console + # use X11 keyboard settings in tty console.useXkbConfig = true; services = { gnome.gnome-keyring.enable = true; + + # compositor picom.enable = true; - pipewire = { + + # use X11 + xserver = { enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; + + # keyboard settings + xkb.layout = "eu"; + autoRepeatDelay = 300; + autoRepeatInterval = 25; + + # use startx as a display manager + displayManager.startx.enable = true; + libinput = { + enable = true; + mouse.accelProfile = "flat"; + }; }; }; programs = { - java.enable = true; dconf.enable = true; - gamemode.enable = true; - steam.enable = true; }; - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; + environment.systemPackages = with pkgs; [ + libnotify + ]; } diff --git a/modules/keyd.nix b/modules/keyd.nix index ca4a674..9e7ad3b 100644 --- a/modules/keyd.nix +++ b/modules/keyd.nix @@ -9,6 +9,7 @@ }; }; + # when left alt is held down, hjkl acts as arrow keys environment.etc."keyd/default.conf".text = '' [ids] * diff --git a/modules/laptop.nix b/modules/laptop.nix index ca07997..76aaec0 100644 --- a/modules/laptop.nix +++ b/modules/laptop.nix @@ -1,6 +1,13 @@ {pkgs, ...}: { environment.systemPackages = with pkgs; [ + # backlight brightness utility brightnessctl + + # screen locker + physlock + + # manage displays when docking + mons ]; services.xserver = { @@ -17,34 +24,34 @@ }; }; + # use S3 sleep mode + boot.kernelParams = ["mem_sleep_default=deep"]; + # battery life improvements powerManagement.enable = true; powerManagement.powertop.enable = true; services.tlp.enable = true; - # able to change backlight or turn off wifi without sudo - security.sudo = { - extraRules = [ - { - groups = ["wheel"]; - commands = [ - { - command = "/run/current-system/sw/bin/light"; - options = ["NOPASSWD"]; - } - { - command = "/run/current-system/sw/bin/rfkill"; - options = ["NOPASSWD"]; - } - ]; - } - ]; - }; + # turn off wifi without sudo + security.sudo.extraRules = [ + { + groups = ["wheel"]; + commands = [ + { + command = "/run/current-system/sw/bin/rfkill"; + options = ["NOPASSWD"]; + } + ]; + } + ]; + # screen locker service services.physlock = { enable = true; allowAnyUser = true; }; + + # lock screen automatically after inactivity services.xserver.xautolock = let cmd = "/run/wrappers/physlock -d"; in { diff --git a/modules/sound.nix b/modules/sound.nix new file mode 100644 index 0000000..bb991aa --- /dev/null +++ b/modules/sound.nix @@ -0,0 +1,14 @@ +{ + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + security.rtkit.enable = true; + + hardware.pulseaudio.daemon.config = { + default-sample-format = "float32le"; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix deleted file mode 100644 index 21c0020..0000000 --- a/overlays/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{pkgs, ...}: [ - (import ./dwm.nix {inherit pkgs;}) - (import ./dwmblocks.nix {inherit pkgs;}) -] diff --git a/overlays/dwm.nix b/overlays/dwm.nix deleted file mode 100644 index 03bfd72..0000000 --- a/overlays/dwm.nix +++ /dev/null @@ -1,16 +0,0 @@ -{pkgs, ...}: _final: prev: { - dwm = prev.dwm.overrideAttrs (_old: { - src = pkgs.fetchFromGitHub { - owner = "joinemm"; - repo = "dwm"; - rev = "c0b431747eb4afa4f31b1dce79ff53253f2c4b63"; - sha256 = "sha256-YfMJVKMdNR9NiR3OK7CrHdrC3k9NLZ1UTI24KTa0Wt4="; - }; - nativeBuildInputs = with pkgs; [ - xorg.libX11 - xorg.libX11.dev - xorg.libXft - xorg.libXinerama - ]; - }); -} diff --git a/overlays/dwmblocks.nix b/overlays/dwmblocks.nix deleted file mode 100644 index 2cf9851..0000000 --- a/overlays/dwmblocks.nix +++ /dev/null @@ -1,24 +0,0 @@ -{pkgs, ...}: _final: prev: { - dwmblocks = prev.dwmblocks.overrideAttrs (_old: { - src = pkgs.fetchFromGitHub { - owner = "joinemm"; - repo = "dwmblocks"; - rev = "367ae57afd8d4cfdc663c239febb9b85638502d0"; - sha256 = "sha256-X51HAexp7Dmr7TZHdiqfu+B4YzTiEOsBqAkxw16zPJc="; - }; - nativeBuildInputs = with pkgs; [ - xorg.libX11 - xorg.libX11.dev - xorg.libXft - xorg.libXinerama - ]; - - unpackPhase = '' - cp -r $src/* . - ''; - - installPhase = '' - make PREFIX=$out DESTDIR="" install - ''; - }); -}