diff --git a/flake.nix b/flake.nix index 0554d6b..5e98fe8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,3 @@ -# ~/nixos/flake.nix { description = "Nixos config flake"; @@ -20,11 +19,6 @@ flake = false; }; }; - # never got nixvim to wokrs. ): - # nixvim = { - # url = "github:nix-community/nixvim/nixos-25.11"; - # }; - outputs = { self, nixpkgs, @@ -35,38 +29,43 @@ ... } @ inputs: let system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; + + unfreePkgs = [ + "hplip" + "vivify.vim" + "cheatsheet.nvim" + ]; + + mkUnfreePredicate = pkg: + builtins.elem (nixpkgs.lib.getName pkg) unfreePkgs; + pkgs-unstable = import nixpkgs-unstable { inherit system; - config.allowUnfree = true; #hplipWithPlugins is unfree... + + config.allowUnfreePredicate = mkUnfreePredicate; }; + in { nixosConfigurations = { laptop = nixpkgs.lib.nixosSystem { specialArgs = {inherit inputs pkgs-unstable;}; modules = [ ./hosts/laptop/configuration.nix + # solves evaluation warning + /* + You have set specialArgs.pkgs, which means that options like nixpkgs.config + and nixpkgs.overlays will be ignored. If you wish to reuse an already created + pkgs, which you know is configured correctly for this NixOS configuration, + please import the `nixosModules.readOnlyPkgs` module from the nixpkgs flake or + `(modulesPath + "/misc/nixpkgs/read-only.nix"), and set `{ nixpkgs.pkgs = ; }`. + This properly disables the ignored options to prevent future surprises. + */ + { + nixpkgs.config.allowUnfreePredicate = mkUnfreePredicate; + } ]; }; }; # we use home-manager directly inside of configuration.nix - # last time i tried to use flake i broke everything ): - # homeManagerConfigurations = { - # tomasr = home-manager.lib.homeManagerConfiguration { - # pkgs = pkgs; - # system = "x86_64-linux"; - # username = "tomasr"; - # homeDirectory = "/home/tomasr"; - # modules = [ - # ./hosts/laptop/home.nix - # #nixvim.homeModules.default - #]; - # Import your Home Manager module - # configuration = ./hosts/laptop/home.nix; - - # extraSpecialArgs = { inherit inputs; }; - # }; - #}; - #}; }; } diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index baa3f6b..ecd1f49 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -2,6 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). { + # nixd says that those attributes are not used. The are used in the imported file. Do not remove. config, pkgs, pkgs-unstable, @@ -17,311 +18,32 @@ #../../modules/nixos/ly.nix ../../modules/nixos/ly.nix ../../modules/nixos/anki.nix - ../../modules/nixos/nixUtils.nix + ../../modules/nixos/nixUtils.nix ../../hostsModules/laptop/nixos/nixUtils.nix ../../hostsModules/laptop/nixos/udev.nix - ../../hostsModules/laptop/nixos/disk.nix + ../../modules/nixos/disk.nix ../../hostsModules/laptop/nixos/disk.nix ../../modules/nixos/printer.nix ../../hostsModules/laptop/nixos/ollama.nix # llm config ../../modules/nixos/mullvad.nix # vpn config ../../hostsModules/laptop/nixos/autoUpdate.nix # auto update the flakes. Handles notification via libnotify and matrix-commander-rs + ../../hostsModules/laptop/nixos/bootloader.nix + ../../hostsModules/laptop/nixos/networking.nix # firewall, ssh, networkmanager, etc. + ../../modules/nixos/bluetooth.nix + ../../modules/nixos/audioAndMedia.nix + ../../modules/nixos/windowManager.nix + ../../modules/nixos/documentation.nix + ../../modules/nixos/IO.nix + ../../modules/nixos/fonts.nix + ../../modules/nixos/latex.nix + ../../modules/nixos/development.nix + ../../modules/nixos/user.nix ../../hostsModules/laptop/nixos/user.nix + ../../modules/nixos/notifications.nix + ../../modules/nixos/browser.nix + ../../modules/nixos/theme.nix # install theming packages and some quickshell stuff + ../../hostsModules/laptop/nixos/hardwareUtils.nix + ../../modules/nixos/otherUtils.nix + ../../modules/nixos/office.nix ]; - - - programs.nix-ld.enable = true; #Run unpatched dynamic binaries on NixOS. For example lets run ./a.out from gcc - - documentation.man.generateCaches = true; # used for the man script - - hardware.bluetooth.enable = true; - - qt.enable = true; - - # grub theme - boot.loader.grub = { - theme = inputs.nixos-grub-themes.packages.${pkgs.system}.nixos; # if you want to use nixos grub theme - }; - - nix.nixPath = [ - "nixpkgs=${inputs.nixpkgs.outPath}" - "home-manager=${inputs.home-manager.outPath}" - ]; #manix is unhappy without this - - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users = { - tomasr = ./home.nix; - }; - extraSpecialArgs = {inherit inputs pkgs-unstable;}; - }; - - services.dbus.enable = true; - security.polkit.enable = true; - - environment.pathsToLink = [ - "/share/applications" - "/share/xdg-desktop-portal" - ]; - xdg.portal = { - enable = true; - - extraPortals = [ - pkgs.xdg-desktop-portal-wlr - pkgs.xdg-desktop-portal-gtk - ]; - }; - # removes uxterm - services.xserver.excludePackages = [pkgs.xterm]; - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - #networking.Name = "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/Zurich"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - # Enable the X11 windowing system. - services.xserver.enable = true; - - # zsh dont want to work if it is not initialzed here. - programs.zsh.enable = true; - - security.wrappers.gsr-kms-server = { - # to remove the password prompt when using gpu-screen-recorder - owner = "root"; - group = "root"; - capabilities = "cap_sys_admin+ep"; - source = "${pkgs.gpu-screen-recorder}/bin/gsr-kms-server"; - }; - - # Enable the GNOME Desktop Environment. - # services.displayManager.gdm.enable = true; - # services.desktopManager.gnome.enable = true; - # we dont use gnome but some utils yes -> see pckgs - #enable sddm - #services.displayManager.sddm = { - # enable = true; - # wayland.enable = true; - #}; - # we use ly as the displayManager. see ../../modules/nixos/ly.nix - - # enable hyprland WM - programs.hyprland = { - enable = true; - package = pkgs-unstable.hyprland; # we use the unstable branch to get the latest features - withUWSM = true; - xwayland.enable = true; - }; - - services.upower.enable = true; - - # Configure keymap in X11 - services.xserver.xkb = { - layout = "ch"; - variant = "fr"; - }; - - # Configure console keymap - console.keyMap = "fr_CH"; - - - # Enable sound with pipewire. - services.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; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.tomasr = { - isNormalUser = true; - description = "Tomas Rivera"; - extraGroups = ["networkmanager" "wheel"]; #wheel allow to use sudo - shell = pkgs.zsh; - }; - - # removes need for password for nixos-rebuild - security.sudo.extraRules = [ - { - users = [ "tomasr" ]; - commands = [ - { - command = "/run/current-system/sw/bin/nixos-rebuild"; - options = [ "NOPASSWD" ]; - } - ]; - } - ]; - - - #adds nixos experimental features: - nix.settings.experimental-features = ["nix-command" "flakes"]; - - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; # Nonfree packages: hplipWithPlugin - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - # use pkgs-unstable if you want the package from the unstable channel - #we need to install gnome and kde utils individually as we dont use gnome - gnome-calculator - snapshot - gnome-characters - gnome-disk-utility - kdePackages.okular - kdePackages.dolphin - gnome-font-viewer - wget - #tree # shows dir in tree # we use eza now - zsh # better bash - brightnessctl # control brightness - pulseaudio # sound server - playerctl # controls media player - blueman # GTK-based Bluetooth Manager - udiskie # removable disk automounter for udisks - networkmanagerapplet # NetworkManager control applet - cliphist # Wayland clipboard manager - wl-clipboard # cli copy/past utilities for Wayland - jp # lightweight and flexible cli JSON parser - libnotify # Library that sends desktop notifications to a notification daemon - hyprkeys # keybind helper - cowsay - cmatrix - swww #wallpaper daemon - socat # Utility for bidirectional data transfer between two independent data channels (used to communicate between hyprland and swww to change wallpapers dinamically) - gcc # GNU C compiler - libreoffice - gruvbox-gtk-theme - hyprpicker - powertop - inetutils # collections of network programs such as telnet - python313Packages.pygments # used for ccat (comment of colorize plugin from oh-my-zsh) - fzf - jq # json parser used in some scripts - bottom # Cross-platform graphical process/system monitor with a customizable interface - cmatrix - tomato-c # pomodoro timer - pavucontrol # PulseAudio Volume Control - #hyprshot - xdg-utils - mailcap - pkgs-unstable.vimPluginsUpdater # used for building plugins - hyprcursor - vial # Open-source GUI and QMK fork for configuring your keyboard in real time - mplayer # Movie player that supports many video formats - chromium # used only to flash the firmware on my framework laptop 16 (keyboard.frame.work) as only chromium based browser support webHID. - capitaine-cursors-themed # cursor theme - usbutils # used for lsusb - # used for the framework 16 laptop - framework-tool - framework-tool-tui - krita # image edition - yt-dlp # some youtube downloader - vlc - (pkgs-unstable.python314.withPackages (ps: - with ps; [ - matplotlib - networkx - scipy - ])) - fluffychat matrix-commander-rs # matrix client - direnv - # utils for dev - pkg-config - gdb - raylib - glfw # raylib and some dependecies - rembg # background remover - #some nix tools - manix - deadnix - alejandra - cling # c interpreter used for coding - mprisence - gif-for-cli - # lsp - texlab - clang-tools - python311Packages.python-lsp-server - lua-language-server - ltex-ls-plus - pylint - black - nixd - # for caelestia - kdePackages.qtdeclarative # provides qmlls and other things - quickshell # we have it but adding it there solves "WARN qt.qpa.services: Failed to register with host portal QDBusError("org.freedesktop.portal.Error.Failed", "Could not register app ID: App info not found for 'org.quickshell'")" - gpu-screen-recorder - fuzzel - papirus-icon-theme - papirus-folders - inkscape - birdtray # thunderbird tray app - # this is more up to date - #(callPackage ../../modules/packages/vivify.nix {}) - #(callPackage ../../modules/packages/sbb-tui.nix {}) - pkgs-unstable.nixpkgs-review - pkgs-unstable.nixfmt-tree - pkgs-unstable.treefmt - pkgs-unstable.tor-browser - pkgs-unstable.bitwarden-desktop - ]; - - # fonts - fonts.packages = with pkgs; [ - nerd-fonts._0xproto - cinzel - times-newer-roman - ]; - - # 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; - # }; - - # to resolve this https://wiki.nixos.org/wiki/Home_Manager#I_cannot_set_GNOME_or_Gtk_themes_via_Home_Manager - programs.dconf.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 diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 2b5d28e..b903d09 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -44,15 +44,12 @@ ../../modules/home-manager/sbb-tui.nix # cff TUI app ../../modules/home-manager/mullvad.nix # mullvad vpn - ../../modules/other/desktopEntries.nix # creates .desktop files + ../../modules/home-manager/other/desktopEntries.nix # creates .desktop files + ../../modules/home-manager/other/user.nix ]; - # Required for Home Manager - home.username = "tomasr"; - home.homeDirectory = "/home/tomasr"; home.stateVersion = "25.11"; # match your Home Manager release - # 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. @@ -61,81 +58,6 @@ # want to update the value, then make sure to first check the Home Manager # release notes. - # The home.packages option allows you to install Nix packages into your - # environment. - home.packages = [ - #scritps - (pkgs.callPackage ../../modules/scripts/dontkillsteam.nix {}) # kill app (if it is steam put it in some background - (pkgs.callPackage ../../hostsModules/laptop/scripts/batterynotify.nix {}) - (pkgs.callPackage ../../hostsModules/laptop/scripts/batterywarning.nix {}) - - # checks if matrix-commander-rs is installed and logged in - (pkgs.callPackage ../../hostsModules/laptop/scripts/checkMatrix.nix {}) - - (pkgs.callPackage ../../modules/scripts/weather.nix {}) - (pkgs.callPackage ../../modules/scripts/wallpaper.nix {}) - (pkgs.callPackage ../../modules/scripts/mountkdrive.nix {}) - (pkgs.callPackage ../../modules/scripts/colorpicker.nix {}) - (pkgs.callPackage ../../modules/scripts/killall.nix {}) # kill all windows except focused window - (pkgs.callPackage ../../modules/scripts/gitnotify.nix {}) - (pkgs.callPackage ../../modules/scripts/tomato.nix {}) - (pkgs.callPackage ../../modules/scripts/librewolfprofiles.nix {}) - (pkgs.callPackage ../../modules/scripts/btm.nix {}) - (pkgs.callPackage ../../modules/scripts/manix.nix {}) - (pkgs.callPackage ../../modules/scripts/man.nix {}) - (pkgs.callPackage ../../modules/scripts/trimmer.nix {}) - (pkgs.callPackage ../../modules/scripts/syllabes.nix {}) # python script to get number of syllabes in french - (pkgs.callPackage ../../hostsModules/laptop/qt/qtbatticon.nix {}) - #pkgs - pkgs.gruvbox-gtk-theme - pkgs.biber - (pkgs.texliveMedium.withPackages ( - ps: - with ps; [ - # these few pkgs are used in the CV template - titlesec # allows creating custom \section - marvosym # some symboles - ebgaramond # Use the EB Garamond font - microtype # To enable letterspacing - fontaxes - # these few pkgs were used for my TM - svg - catchfile - caption - transparent - cfr-lm - svn-prov - nfssext-cfr - hyphenat - csquotes - enumitem - chngcntr - tcolorbox - pdfcol - wrapfig - tocloft - lastpage - biblatex - biblatex-iso690 - libertine - minted - upquote - lipsum - footmisc - #(setq org-latex-compiler "lualatex") - #(setq org-preview-latex-default-process 'dvisvgm) - ] - )) - ]; - - - home.sessionVariables = { - EDITOR = "neovim"; - # Git update function - # Prompts for commit message; defaults if empty - TERMINAL = "kitty"; - }; - # Let Home Manager install and manage itself. programs.home-manager.enable = true; } diff --git a/hostsModules/laptop/home-manager/zsh.nix b/hostsModules/laptop/home-manager/zsh.nix index 7ff0679..cc383e7 100644 --- a/hostsModules/laptop/home-manager/zsh.nix +++ b/hostsModules/laptop/home-manager/zsh.nix @@ -5,8 +5,8 @@ }: { programs.zsh = { shellAliases = { - snrt = "git add -A && time sudo nixos-rebuild test --flake ~/nixos/#laptop"; - snrs = "git add -A && time sudo nixos-rebuild switch --flake ~/nixos/#laptop"; + snrt = "git -C ~/nixos add -A && time sudo nixos-rebuild test --flake ~/nixos/#laptop"; + snrs = "git -C ~/nixos add -A && time sudo nixos-rebuild switch --flake ~/nixos/#laptop"; }; }; } diff --git a/hostsModules/laptop/nixos/bootloader.nix b/hostsModules/laptop/nixos/bootloader.nix new file mode 100644 index 0000000..f58aaf2 --- /dev/null +++ b/hostsModules/laptop/nixos/bootloader.nix @@ -0,0 +1,15 @@ +{ + inputs, + pkgs, + ... +}: +{ + # grub theme + boot.loader.grub = { + theme = inputs.nixos-grub-themes.packages.${pkgs.system}.nixos; # if you want to use nixos grub theme + }; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/hostsModules/laptop/nixos/hardwareUtils.nix b/hostsModules/laptop/nixos/hardwareUtils.nix new file mode 100644 index 0000000..7b3a1ee --- /dev/null +++ b/hostsModules/laptop/nixos/hardwareUtils.nix @@ -0,0 +1,12 @@ +{ + pkgs, + ... +}: +{ + environment.systemPackages = with pkgs; [ + # used for the framework 16 laptop + framework-tool + framework-tool-tui + vial # Open-source GUI and QMK fork for configuring your keyboard in real time + ]; +} diff --git a/hostsModules/laptop/nixos/networking.nix b/hostsModules/laptop/nixos/networking.nix new file mode 100644 index 0000000..427c276 --- /dev/null +++ b/hostsModules/laptop/nixos/networking.nix @@ -0,0 +1,30 @@ +{ + pkgs, + ... +}: +{ + environment.systemPackages = with pkgs; [ + wget + networkmanagerapplet # NetworkManager control applet + inetutils # collections of network programs such as telnet + +]; + #networking.Name = "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; + + # 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; +} diff --git a/hostsModules/laptop/nixos/nixUtils.nix b/hostsModules/laptop/nixos/nixUtils.nix new file mode 100644 index 0000000..838e561 --- /dev/null +++ b/hostsModules/laptop/nixos/nixUtils.nix @@ -0,0 +1,8 @@ +{ + ... +}: +{ + # nixpkgs-review crashed my laptop multiple times. + nix.settings.max-jobs = 2; + nix.settings.cores = 2; +} diff --git a/hostsModules/laptop/nixos/user.nix b/hostsModules/laptop/nixos/user.nix new file mode 100644 index 0000000..be1f3a4 --- /dev/null +++ b/hostsModules/laptop/nixos/user.nix @@ -0,0 +1,7 @@ +# configuration is in ../../../modules/nixos/user.nix +{ + ... +}: +{ + home-manager.users.tomasr = ../../../hosts/laptop/home.nix; +} diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix index 4e08037..9a92b51 100644 --- a/modules/home-manager/hyprland.nix +++ b/modules/home-manager/hyprland.nix @@ -206,8 +206,10 @@ in { "blueman-applet" # systray app for Bluetooth "udiskie --no-automount --smart-tray" # front-end that allows to manage removable media "nm-applet --indicator" # systray app for Network/wifi - "wl-paste --type text --watch cliphist store" # clipboard store text data - "wl-paste --type image --watch cliphist store" # clipboard store image data + #setups clipboard + "rm -rf ~/.cache/cliphist/ && wl-paste --type text --watch cliphist store & wl-paste --type image --watch cliphist store" + #"wl-paste --type text --watch cliphist store" # clipboard store text data + #"wl-paste --type image --watch cliphist store" # clipboard store image data "custom-batterynotify" "custom-batterywarning" "birdtray" # thunderbird tray app @@ -215,7 +217,7 @@ in { "swww img ${wallpaper}" "swww-daemon" "sleep 1 && custom-wallpaper" - "custom-mountkdrive" + "sleep 5 && custom-checkKdrive && custom-mountkdrive" # checks if the remote works and mount it #"waybar" "custom-gitnotify" "custom-checkMatrix" # checks if matrix-commander-rs is connected which is important for other stuff @@ -246,7 +248,6 @@ in { # █▄▄ █▀█ ░█░ █▄█ █▄█ ░█░ ▄█ dwindle = { - pseudotile = true; preserve_split = true; }; scrolling = { diff --git a/modules/other/desktopEntries.nix b/modules/home-manager/other/desktopEntries.nix similarity index 100% rename from modules/other/desktopEntries.nix rename to modules/home-manager/other/desktopEntries.nix diff --git a/modules/home-manager/other/user.nix b/modules/home-manager/other/user.nix new file mode 100644 index 0000000..5e66367 --- /dev/null +++ b/modules/home-manager/other/user.nix @@ -0,0 +1,12 @@ +{ + ... +}: +{ + home.username = "tomasr"; + home.homeDirectory = "/home/tomasr"; + + home.sessionVariables = { + EDITOR = "neovim"; + TERMINAL = "kitty"; + }; +} diff --git a/modules/home-manager/rclone.nix b/modules/home-manager/rclone.nix index ddb235c..18ca66b 100644 --- a/modules/home-manager/rclone.nix +++ b/modules/home-manager/rclone.nix @@ -1,10 +1,9 @@ { - config, - pkgs, - agenix, + pkgs-unstable, ... }: { programs.rclone = { enable = true; + package = pkgs-unstable.rclone; }; } diff --git a/modules/home-manager/result b/modules/home-manager/result deleted file mode 120000 index 7b4d62c..0000000 --- a/modules/home-manager/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/c0iwr0v7bjfka094wv6hd1hjmrkx9hm9-options.json \ No newline at end of file diff --git a/modules/home-manager/ssh.nix b/modules/home-manager/ssh.nix index 22f3666..2c48548 100644 --- a/modules/home-manager/ssh.nix +++ b/modules/home-manager/ssh.nix @@ -5,6 +5,7 @@ }: { programs.ssh = { enable = true; + enableDefaultConfig = false; # will be removed in the futur. Removes evaluation warning matchBlocks."*" = { # equivalent to the default config forwardAgent = false; diff --git a/modules/home-manager/zsh.nix b/modules/home-manager/zsh.nix index 4d0428d..27fbd99 100644 --- a/modules/home-manager/zsh.nix +++ b/modules/home-manager/zsh.nix @@ -43,6 +43,12 @@ mplayer = "mplayer -volume 5"; # these are to create the developpement shell cenv = "nix-shell -p zsh gcc raylib libx11 libGL"; + # i always write nvim wrong :( + nbim = "nvim"; + nivm = "nvim"; + bivm = "nvim"; + nibm = "nvim"; + vikm = "nvim"; }; }; } diff --git a/modules/nixos/IO.nix b/modules/nixos/IO.nix new file mode 100644 index 0000000..a820e9e --- /dev/null +++ b/modules/nixos/IO.nix @@ -0,0 +1,24 @@ +{ + pkgs, + ... +}: +{ + # Configure keymap in X11 + services.xserver.xkb = { + layout = "ch"; + variant = "fr"; + }; + + # Configure console keymap + console.keyMap = "fr_CH"; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + environment.systemPackages = with pkgs; [ + wl-clipboard + cliphist + hyprkeys # keybind helper + hyprpicker + ]; +} diff --git a/modules/nixos/audioAndMedia.nix b/modules/nixos/audioAndMedia.nix new file mode 100644 index 0000000..f363e8b --- /dev/null +++ b/modules/nixos/audioAndMedia.nix @@ -0,0 +1,38 @@ +{ + pkgs, + pkgs-unstable, + ... +}: +{ + # Enable sound with pipewire. + services.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; + }; + environment.systemPackages = with pkgs; [ + kdePackages.okular + kdePackages.dolphin + pulseaudio # sound server + playerctl # controls media player + pavucontrol # PulseAudio Volume Control + mplayer # Movie player that supports many video formats + krita # image edition + yt-dlp # some youtube downloader + vlc + #mprisence # Highly customizable Discord Rich Presence for MPRIS media players on Linux + #gif-for-cli # Render gifs as ASCII art in your cli + #rembg # background remover + gpu-screen-recorder + inkscape + ]; +} diff --git a/modules/nixos/autoUpdate.nix b/modules/nixos/autoUpdate.nix deleted file mode 100644 index 30f743f..0000000 --- a/modules/nixos/autoUpdate.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ pkgs, ... }: - -{ - # Ensure your script is available system-wide - environment.systemPackages = [ - (pkgs.callPackage ./custom-autoupdate.nix {}) - ]; - - # ---------------------------- - # 🔥 Enable lingering for user services (IMPORTANT) - # ---------------------------- - users.users.tomasr = { - isNormalUser = true; - - # other config... - - linger = true; # <-- declarative equivalent of `loginctl enable-linger` - }; - - # ---------------------------- - # ✅ 2. Systemd USER service - # ---------------------------- - systemd.user.services.custom-autoupdate = { - description = "NixOS flake auto update"; - - serviceConfig = { - Type = "oneshot"; - - ExecStart = "/run/current-system/sw/bin/custom-autoupdate"; - - # safety for long rebuilds - TimeoutStartSec = "45min"; - TimeoutStopSec = "10min"; - - # avoid overlap - RemainAfterExit = true; - - # 🔥 recommended reliability tweaks - Nice = 10; - IOSchedulingClass = "best-effort"; - IOSchedulingPriority = 7; - }; - }; - - # ---------------------------- - # ⏱️ 3. Systemd USER timer - # ---------------------------- - systemd.user.timers.custom-autoupdate = { - wantedBy = [ "timers.target" ]; - - timerConfig = { - OnBootSec = "10min"; # run after boot - OnUnitActiveSec = "6h"; # every 6 hours - - # 🔥 ensures missed runs after shutdown happen - Persistent = true; - - # avoids thundering herd on boot - RandomizedDelaySec = "30min"; - }; - }; -} diff --git a/modules/nixos/bluetooth.nix b/modules/nixos/bluetooth.nix new file mode 100644 index 0000000..9892a08 --- /dev/null +++ b/modules/nixos/bluetooth.nix @@ -0,0 +1,10 @@ +{ + pkgs, + ... +}: +{ + hardware.bluetooth.enable = true; + environment.systemPackages = with pkgs; [ + blueman # GTK-based Bluetooth Manager + ]; +} diff --git a/modules/nixos/browser.nix b/modules/nixos/browser.nix new file mode 100644 index 0000000..63ad142 --- /dev/null +++ b/modules/nixos/browser.nix @@ -0,0 +1,14 @@ +# configuration for main browser is in ../home-manager/librewolf.nix +# configuration for qutebrowser is in ../home-manager/vivify.nix +{ + pkgs, + pkgs-unstable, + ... +}: +{ + environment.systemPackages = with pkgs; [ + chromium # used only to flash the firmware on my framework laptop 16 (keyboard.frame.work) as only chromium based browser support webHID. + pkgs-unstable.tor-browser + (pkgs.callPackage ../../modules/scripts/librewolfprofiles.nix {}) # fzf librewolf profile selector + ]; +} diff --git a/modules/nixos/development.nix b/modules/nixos/development.nix new file mode 100644 index 0000000..5e1f9d4 --- /dev/null +++ b/modules/nixos/development.nix @@ -0,0 +1,33 @@ +{ + pkgs, + pkgs-unstable, + ... +}: +{ + programs.nix-ld.enable = true; #Run unpatched dynamic binaries on NixOS. For example lets run ./a.out from gcc + environment.systemPackages = with pkgs; [ + gcc + jq # json parser used in some scripts + jp # lightweight and flexible cli JSON parser + (pkgs-unstable.python314.withPackages (ps: + with ps; [ + matplotlib + networkx + scipy + ])) + python313Packages.pygments # used for ccat (comment of colorize plugin from oh-my-zsh) + pkg-config + gdb + raylib + glfw # raylib and some dependecies + + direnv + cling # c interpreter used for coding + # lsp + clang-tools + python311Packages.python-lsp-server + ltex-ls-plus + pylint + black + ]; +} diff --git a/modules/nixos/disk.nix b/modules/nixos/disk.nix new file mode 100644 index 0000000..0b9dbff --- /dev/null +++ b/modules/nixos/disk.nix @@ -0,0 +1,15 @@ +{ + pkgs, + ... +}: +{ + environment.systemPackages = with pkgs; [ + gnome-disk-utility + udiskie # removable disk automounter for udisks + (pkgs.callPackage ../../modules/scripts/mountkdrive.nix {}) + ]; + + # removes rclone error + programs.fuse.userAllowOther = true; + programs.fuse.enable = true; +} diff --git a/modules/nixos/documentation.nix b/modules/nixos/documentation.nix new file mode 100644 index 0000000..756d132 --- /dev/null +++ b/modules/nixos/documentation.nix @@ -0,0 +1,17 @@ +{ + pkgs, + ... +}: +{ + documentation.man.generateCaches = true; # used for the man script + + environment.pathsToLink = [ # see https://wiki.nixos.org/wiki/Documentation_Gaps#How_do_manpages_work?_Or:_environment.pathsToLink_and_buildEnv + "/share/applications" + "/share/xdg-desktop-portal" + ]; + environment.systemPackages = [ + pkgs.manix + (pkgs.callPackage ../../modules/scripts/manix.nix {}) # fzf manix searcher + (pkgs.callPackage ../../modules/scripts/man.nix {}) # fzf man searcher + ]; +} diff --git a/modules/nixos/fonts.nix b/modules/nixos/fonts.nix new file mode 100644 index 0000000..1f7e00c --- /dev/null +++ b/modules/nixos/fonts.nix @@ -0,0 +1,16 @@ +{ + pkgs, + ... +}: +{ + # fonts + fonts.packages = with pkgs; [ + nerd-fonts._0xproto + cinzel + times-newer-roman + ]; + + environment.systemPackages = with pkgs; [ + gnome-font-viewer + ]; +} diff --git a/modules/nixos/latex.nix b/modules/nixos/latex.nix new file mode 100644 index 0000000..f69b66d --- /dev/null +++ b/modules/nixos/latex.nix @@ -0,0 +1,48 @@ +{ + pkgs, + ... +}: +{ + environment.systemPackages = with pkgs; [ + texlab + ltex-ls-plus + biber + (pkgs.texliveMedium.withPackages ( + ps: + with ps; [ + # these few pkgs are used in the CV template + titlesec # allows creating custom \section + marvosym # some symboles + ebgaramond # Use the EB Garamond font + microtype # To enable letterspacing + fontaxes + # these few pkgs were used for my TM + svg + catchfile + caption + transparent + cfr-lm + svn-prov + nfssext-cfr + hyphenat + csquotes + enumitem + chngcntr + tcolorbox + pdfcol + wrapfig + tocloft + lastpage + biblatex + biblatex-iso690 + libertine + minted + upquote + lipsum + footmisc + #(setq org-latex-compiler "lualatex") + #(setq org-preview-latex-default-process 'dvisvgm) + ] + )) + ]; +} diff --git a/modules/nixos/nixUtils.nix b/modules/nixos/nixUtils.nix index a6e263d..fdf6108 100644 --- a/modules/nixos/nixUtils.nix +++ b/modules/nixos/nixUtils.nix @@ -1,18 +1,32 @@ +# some options are in ../../hostsModules/laptop/nixos/nixUtils.nix { - config, - pkgs, pkgs-unstable, - libs, inputs, ... }: { -# Garbage collector of generations + # Garbage collector of generations nix.gc = { automatic = true; dates = "weekly"; options = "--delete-older-than 7d"; # every week delete generations older than a month }; - # nixpkgs-review crashed my laptop multiple times. - nix.settings.max-jobs = 2; - nix.settings.cores = 2; + + #manix is unhappy without this + nix.nixPath = [ + "nixpkgs=${inputs.nixpkgs.outPath}" + "home-manager=${inputs.home-manager.outPath}" + ]; + + #adds nixos experimental features: + nix.settings.experimental-features = ["nix-command" "flakes"]; + + environment.systemPackages = with pkgs-unstable; [ + nixpkgs-review + nixfmt-tree + treefmt + nixd + deadnix + alejandra + vimPluginsUpdater # used for building plugins + ]; } diff --git a/modules/nixos/notifications.nix b/modules/nixos/notifications.nix new file mode 100644 index 0000000..cdbcf74 --- /dev/null +++ b/modules/nixos/notifications.nix @@ -0,0 +1,20 @@ +# notifications server is set by caelestia-shell. See ../home-manager/caelestia.nix +{ + pkgs, + ... +}: +{ + environment.systemPackages = with pkgs; [ + libnotify # Library that sends desktop notifications to a notification daemon + socat # Utility for bidirectional data transfer between two independent data channels (used to communicate between hyprland and swww to change wallpapers dinamically) + matrix-commander-rs # matrix client used to send notifications from scripts to my phone + # battery notifications + (pkgs.callPackage ../../hostsModules/laptop/scripts/batterynotify.nix {}) + (pkgs.callPackage ../../hostsModules/laptop/scripts/batterywarning.nix {}) + # checks if matrix-commander-rs is installed and logged in + (pkgs.callPackage ../../hostsModules/laptop/scripts/checkMatrix.nix {}) + (pkgs.callPackage ../../modules/scripts/gitnotify.nix {}) # check if git is set up + (pkgs.callPackage ../../modules/scripts/checkKdrive.nix {}) # check if kdrive is set up with rclone + + ]; +} diff --git a/modules/nixos/office.nix b/modules/nixos/office.nix new file mode 100644 index 0000000..674f9a2 --- /dev/null +++ b/modules/nixos/office.nix @@ -0,0 +1,10 @@ +{ + pkgs, + ... +}: +{ + environment.systemPackages = with pkgs; [ + libreoffice + birdtray + ]; +} diff --git a/modules/nixos/otherUtils.nix b/modules/nixos/otherUtils.nix new file mode 100644 index 0000000..48945c4 --- /dev/null +++ b/modules/nixos/otherUtils.nix @@ -0,0 +1,29 @@ +# try to keep packages here at a minium. Preferably use a dedicated file +{ + pkgs, + pkgs-unstable, + ... +}: +{ + environment.systemPackages = with pkgs; [ + gnome-calculator + snapshot + gnome-characters + #tree # shows dir in tree # we use eza now + brightnessctl # control brightness + powertop + fzf + bottom # Cross-platform graphical process/system monitor with a customizable interface + tomato-c # pomodoro timer + #hyprshot + mailcap + fuzzel + usbutils # used for lsusb + (pkgs.callPackage ../../modules/scripts/dontkillsteam.nix {}) # kill app (if it is steam put it in some background + (pkgs.callPackage ../../modules/scripts/killall.nix {}) # kill all windows except focused window + (pkgs.callPackage ../../modules/scripts/tomato.nix {}) + (pkgs.callPackage ../../modules/scripts/syllabes.nix {}) # python script to get number of syllabes in french + pkgs-unstable.bitwarden-desktop + fluffychat # matrix client + ]; +} diff --git a/modules/nixos/theme.nix b/modules/nixos/theme.nix new file mode 100644 index 0000000..25e98f2 --- /dev/null +++ b/modules/nixos/theme.nix @@ -0,0 +1,26 @@ +# most of the themeing are in the home-manager modules. This just installs some packages needed +{ + pkgs, + ... +}: +{ + qt.enable = true; + + # to resolve this https://wiki.nixos.org/wiki/Home_Manager#I_cannot_set_GNOME_or_Gtk_themes_via_Home_Manager + programs.dconf.enable = true; + + environment.systemPackages = with pkgs; [ + swww #wallpaper daemon + gruvbox-gtk-theme + hyprcursor + capitaine-cursors-themed # cursor theme + kdePackages.qtdeclarative # provides qmlls and other things + quickshell # we have it but adding it there solves "WARN qt.qpa.services: Failed to register with host portal QDBusError("org.freedesktop.portal.Error.Failed", "Could not register app ID: App info not found for 'org.quickshell'")" + papirus-icon-theme + papirus-folders + (pkgs.callPackage ../../modules/scripts/wallpaper.nix {}) + #(pkgs.callPackage ../../modules/scripts/colorpicker.nix {}) # old color picker + #(pkgs.callPackage ../../modules/scripts/weather.nix {}) # old cli weather + (pkgs.callPackage ../../hostsModules/laptop/qt/qtbatticon.nix {}) # custom qt tray icon for battery + ]; +} diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix new file mode 100644 index 0000000..35cec27 --- /dev/null +++ b/modules/nixos/user.nix @@ -0,0 +1,56 @@ +{ + pkgs, + pkgs-unstable, + inputs, + ... +}: +{ + services.dbus.enable = true; + security.polkit.enable = true; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + # the home manager config is set in ../../hostsModules/*/nixos/user.nix + extraSpecialArgs = {inherit inputs pkgs-unstable;}; + }; + + # Set your time zone. + time.timeZone = "Europe/Zurich"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + # zsh dont want to work if it is not initialzed here. + programs.zsh.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.tomasr = { + isNormalUser = true; + description = "Tomas Rivera"; + extraGroups = ["networkmanager" "wheel" "fuse"]; #wheel allow to use sudo / fuse -> rclone + shell = pkgs.zsh; + }; + + security.wrappers.gsr-kms-server = { + # to remove the password prompt when using gpu-screen-recorder + owner = "root"; + group = "root"; + capabilities = "cap_sys_admin+ep"; + source = "${pkgs.gpu-screen-recorder}/bin/gsr-kms-server"; + }; + + services.upower.enable = true; + + # removes need for password for nixos-rebuild + security.sudo.extraRules = [ + { + users = [ "tomasr" ]; + commands = [ + { + command = "/run/current-system/sw/bin/nixos-rebuild"; + options = [ "NOPASSWD" ]; + } + ]; + } + ]; +} diff --git a/modules/nixos/windowManager.nix b/modules/nixos/windowManager.nix new file mode 100644 index 0000000..3dde05a --- /dev/null +++ b/modules/nixos/windowManager.nix @@ -0,0 +1,43 @@ +# customization is in ../home-manager/hyprland.nix +{ + pkgs-unstable, + pkgs, + ... +}: +{ + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + # services.displayManager.gdm.enable = true; + # services.desktopManager.gnome.enable = true; + # we dont use gnome but some utils yes -> see pckgs + #enable sddm + #services.displayManager.sddm = { + # enable = true; + # wayland.enable = true; + #}; + # we use ly as the displayManager. see ../../modules/nixos/ly.nix + + # enable hyprland WM + programs.hyprland = { + enable = true; + package = pkgs-unstable.hyprland; # we use the unstable branch to get the latest features + withUWSM = true; + xwayland.enable = true; + }; + + xdg.portal = { + enable = true; + extraPortals = [ + pkgs.xdg-desktop-portal-wlr + pkgs.xdg-desktop-portal-gtk + ]; + }; + # removes uxterm + services.xserver.excludePackages = [pkgs.xterm]; + + environment.systemPackages = with pkgs; [ + xdg-utils + ]; +} diff --git a/modules/scripts/checkKdrive.nix b/modules/scripts/checkKdrive.nix new file mode 100644 index 0000000..a7160a0 --- /dev/null +++ b/modules/scripts/checkKdrive.nix @@ -0,0 +1,33 @@ +{ + writeShellApplication, + rclone, + matrix-commander-rs, + libnotify, + ... +}: +writeShellApplication { + name = "custom-checkKdrive"; + runtimeInputs = [ + rclone + matrix-commander-rs + libnotify + ]; + text = '' +set +e + +output=$(rclone lsd kdrive: 2>&1) +status=$? + +set -e + +if [ $status -eq 0 ]; then + echo "kdrive OK" +else + echo "kdrive rclone failed with error: $output" + notify-send "rclone kdrive failed" "$output" + matrix-commander-rs --verbose -m "rclone kdrive failed.
Error:
$output

@notificationbot_0000" \ + --html \ + -r "\!7j-78_02dHROeLj4Ns8F12eo4IiZGv4zNsQ_1-WlyIU" +fi + ''; +} diff --git a/modules/scripts/gitnotify.nix b/modules/scripts/gitnotify.nix index e54ef5b..5decd7a 100644 --- a/modules/scripts/gitnotify.nix +++ b/modules/scripts/gitnotify.nix @@ -23,6 +23,9 @@ writeShellApplication { notify-send \ "Git not configured" \ "Set your identity\n or remove this warning by removing the custom-gitnotify line in\n ~/nixos/modules/home-manager/hyprland.nix" + matrix-commander-rs --verbose -m "Git not configured.
Set your identify or remove this warning by removing the custom-gitnotify in ~/nixos/modules/home-manager/hyprland.nix
@notificationbot_0000" \ + --html \ + -r "\!7j-78_02dHROeLj4Ns8F12eo4IiZGv4zNsQ_1-WlyIU" fi ''; }