From f30ff9962c2eb028e1a631d1330e0082ea982031 Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Wed, 8 Jan 2025 21:28:04 -0800 Subject: [PATCH] refactor, add common modules --- flake.lock | 37 ++++++++ flake.nix | 22 ++++- .../Yura-PC/default.nix | 66 ++++---------- .../Yura-PC/hardware-configuration.nix | 0 configuration-vm.nix => hosts/vm/default.nix | 88 ++++++------------- .../vm/hardware-configuration.nix | 0 modules/common/default.nix | 5 ++ modules/common/kb-input.nix | 42 +++++++++ minimak => modules/common/minimak | 0 modules/default.nix | 1 + 10 files changed, 144 insertions(+), 117 deletions(-) rename configuration.nix => hosts/Yura-PC/default.nix (88%) rename hardware-configuration.nix => hosts/Yura-PC/hardware-configuration.nix (100%) rename configuration-vm.nix => hosts/vm/default.nix (78%) rename hardware-configuration-vm.nix => hosts/vm/hardware-configuration.nix (100%) create mode 100644 modules/common/default.nix create mode 100644 modules/common/kb-input.nix rename minimak => modules/common/minimak (100%) diff --git a/flake.lock b/flake.lock index 7672c21..09b93c2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,41 @@ { "nodes": { + "nixlib": { + "locked": { + "lastModified": 1734829460, + "narHash": "sha256-dPhc+f2wkmhMqMIfq+hColJdysgVxKP9ilZ5bR0NRZI=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "0a31e8d833173ae63e43fd9dbff1ccf09c4f778c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1734915500, + "narHash": "sha256-A7CTIQ8SW0hfbhKlwK+vSsu4pD+Oaelw3v6goX6go+U=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "051d1b2dda3b2e81b38d82e2b691e5c2f4d335f4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1735834308, @@ -18,6 +54,7 @@ }, "root": { "inputs": { + "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index f03c4b6..62ee392 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,3 @@ -# /etc/nixos/flake.nix { description = "flake for Yura-PC"; @@ -6,24 +5,39 @@ nixpkgs = { url = "github:NixOS/nixpkgs/nixos-unstable"; }; + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs }: { + outputs = { self, nixpkgs, nixos-generators }: { nixosConfigurations = { Yura-PC = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./modules - ./configuration.nix + ./hosts/Yura-PC ]; }; VM = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./modules - ./configuration-vm.nix + ./hosts/vm ]; }; }; + # https://github.com/nix-community/nixos-generators?tab=readme-ov-file#using-in-a-flake + packages.x86_64-linux = { + proxmox = nixos-generators.nixosGenerate { + system = "x86_64-linux"; + modules = [ + ./modules + ./hosts/vm + ]; + format = "proxmox"; + }; + }; }; } diff --git a/configuration.nix b/hosts/Yura-PC/default.nix similarity index 88% rename from configuration.nix rename to hosts/Yura-PC/default.nix index be461db..ad4cf88 100644 --- a/configuration.nix +++ b/hosts/Yura-PC/default.nix @@ -10,6 +10,7 @@ ./hardware-configuration.nix # ]; + common.kb-input.enable = true; # Bootloader. boot.loader.systemd-boot.enable = true; @@ -110,37 +111,6 @@ security.pam.services.sddm.enableGnomeKeyring = true; # security.pam.services.sddm.gnupg.enable = true; - services.xserver.xkb.extraLayouts = { - minimak-4 = { - description = "English (US, Minimak-4)"; - languages = [ "eng" ]; - # symbolsFile = /etc/nixos/minimak; - symbolsFile = ./minimak; - }; - minimak-8 = { - description = "English (US, Minimak-8)"; - languages = [ "eng" ]; - # symbolsFile = /etc/nixos/minimak; - symbolsFile = ./minimak; - }; - minimak-12 = { - description = "English (US, Minimak-12)"; - languages = [ "eng" ]; - # symbolsFile = /etc/nixos/minimak; - symbolsFile = ./minimak; - }; - }; - - i18n.inputMethod = { - type = "fcitx5"; - enable = true; - fcitx5.waylandFrontend = true; - fcitx5.plasma6Support = true; - fcitx5.addons = with pkgs; [ - fcitx5-mozc - ]; - }; - # Enable touchpad support (enabled default in most desktopManager). # services.xserver.libinput.enable = true; @@ -158,9 +128,6 @@ group = "cazzzer"; extraGroups = [ "networkmanager" "wheel" "docker" "wireshark" "geoclue" ]; packages = with pkgs; [ - - kdePackages.kate - kdePackages.yakuake python3 poetry @@ -191,6 +158,9 @@ programs.gnupg.agent.pinentryPackage = pkgs.pinentry-qt; # programs.starship.enable = true; programs.wireshark.enable = true; + programs.wireshark.package = pkgs.wireshark; # wireshark-cli by default + programs.bat.enable = true; + programs.htop.enable = true; # https://nixos.wiki/wiki/Docker virtualisation.docker.enable = true; @@ -263,13 +233,19 @@ # ]; workarounds.flatpak.enable = true; - fonts.packages = with pkgs; [ nerd-fonts.fantasque-sans-mono ]; + fonts.packages = with pkgs; [ + fantasque-sans-mono + nerd-fonts.fantasque-sans-mono + noto-fonts + noto-fonts-emoji + noto-fonts-cjk-sans + noto-fonts-cjk-serif + jetbrains-mono + ]; # fonts.fontDir.enable = true; # fonts.fontconfig.allowBitmaps = false; environment.systemPackages = with pkgs; [ - bat - # bluez darkman dust efibootmgr @@ -277,16 +253,15 @@ fastfetch fd ffmpeg - # flatpak host-spawn # for flatpaks - kdePackages.flatpak-kcm kdePackages.filelight - # git + kdePackages.flatpak-kcm + kdePackages.kate + kdePackages.yakuake gcr gnome-keyring # config for this and some others gnumake helix - htop jetbrains-toolbox # or maybe do invidual ones? # jetbrains.rust-rover # jetbrains.pycharm-professional @@ -295,11 +270,7 @@ mediainfo micro mpv - neofetch - # neovim nextcloud-client - noto-fonts-cjk-sans - noto-fonts-cjk-serif lxqt.pavucontrol-qt pinentry rbw @@ -308,15 +279,10 @@ starship tealdeer tela-circle-icon-theme - fantasque-sans-mono - jetbrains-mono virt-viewer waypipe whois - # wireshark yt-dlp - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget ]; # nix.package = pkgs.nixFlakes; diff --git a/hardware-configuration.nix b/hosts/Yura-PC/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to hosts/Yura-PC/hardware-configuration.nix diff --git a/configuration-vm.nix b/hosts/vm/default.nix similarity index 78% rename from configuration-vm.nix rename to hosts/vm/default.nix index 7f5bbe4..23886ff 100644 --- a/configuration-vm.nix +++ b/hosts/vm/default.nix @@ -7,8 +7,12 @@ { imports = [ # Include the results of the hardware scan. - ./hardware-configuration-vm.nix +# ./hardware-configuration-vm.nix ]; + common.kb-input.enable = true; + +# boot.kernelParams = [ "console=tty0" ]; + proxmox.qemuConf.bios = "ovmf"; # Bootloader. boot.loader.systemd-boot.enable = true; @@ -19,7 +23,7 @@ "sysrq_always_enabled=1" ]; - boot.loader.timeout = 3; +# boot.loader.timeout = lib.mkForce 3; boot.loader.systemd-boot.configurationLimit = 5; boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_12; boot.extraModulePackages = with config.boot.kernelPackages; [ zfs ]; @@ -77,37 +81,6 @@ services.sshd.enable = true; services.flatpak.enable = true; - services.xserver.xkb.extraLayouts = { - minimak-4 = { - description = "English (US, Minimak-4)"; - languages = [ "eng" ]; - # symbolsFile = /etc/nixos/minimak; - symbolsFile = ./minimak; - }; - minimak-8 = { - description = "English (US, Minimak-8)"; - languages = [ "eng" ]; - # symbolsFile = /etc/nixos/minimak; - symbolsFile = ./minimak; - }; - minimak-12 = { - description = "English (US, Minimak-12)"; - languages = [ "eng" ]; - # symbolsFile = /etc/nixos/minimak; - symbolsFile = ./minimak; - }; - }; - - i18n.inputMethod = { - type = "fcitx5"; - enable = true; - fcitx5.waylandFrontend = true; - fcitx5.plasma6Support = true; - fcitx5.addons = with pkgs; [ - fcitx5-mozc - ]; - }; - # Enable touchpad support (enabled default in most desktopManager). # services.xserver.libinput.enable = true; @@ -119,25 +92,17 @@ }; }; users.users.cazzzer = { + password = ""; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPWgEzbEjbbu96MVQzkiuCrw+UGYAXN4sRe2zM6FVopq cazzzer@Yura-PC" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIApFeLVi3BOquL0Rt+gQK2CutNHaBDQ0m4PcGWf9Bc43 cazzzer@Yura-TPX13" + ]; isNormalUser = true; description = "Yura"; uid = 1000; group = "cazzzer"; - extraGroups = [ "networkmanager" "wheel" "docker" "wireshark" ]; - packages = with pkgs; [ - # Python - # python3 - # poetry + extraGroups = [ "wheel" "docker" "wireshark" ]; - # Haskell - # haskellPackages.ghc - # haskellPackages.stack - - # Node - # nodejs_22 - # pnpm - # bun - ]; }; # Install firefox. @@ -147,6 +112,10 @@ programs.lazygit.enable = true; programs.neovim.enable = true; + programs.bat.enable = true; + programs.htop.enable = true; + programs.wireshark.enable = true; + # https://discourse.nixos.org/t/firefox-does-not-use-kde-window-decorations-and-cursor/32132/3 # programs.dconf.enable = true; # programs.firefox = { @@ -166,50 +135,43 @@ # https://github.com/flatpak/flatpak/issues/2861 xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; - workarounds.flatpak.enable = true; - fonts.packages = with pkgs; [ nerd-fonts.fantasque-sans-mono ]; +# workarounds.flatpak.enable = true; + fonts.packages = with pkgs; [ + noto-fonts-cjk-sans + noto-fonts-cjk-serif + fantasque-sans-mono + nerd-fonts.fantasque-sans-mono + jetbrains-mono + ]; environment.systemPackages = with pkgs; [ - bat - # bluez darkman dust efibootmgr eza fastfetch fd - # flatpak host-spawn # for flatpaks kdePackages.flatpak-kcm kdePackages.filelight kdePackages.kate kdePackages.yakuake - # git gnumake helix - htop mediainfo micro mpv - neofetch - # neovim - noto-fonts-cjk-sans - noto-fonts-cjk-serif ripgrep starship tealdeer tela-circle-icon-theme - fantasque-sans-mono - jetbrains-mono waypipe whois - # wireshark yt-dlp - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + zfs # wget ]; - # nix.package = pkgs.nixFlakes; nix.settings.experimental-features = [ "nix-command" "flakes" ]; environment.etc."current-system-packages".text = diff --git a/hardware-configuration-vm.nix b/hosts/vm/hardware-configuration.nix similarity index 100% rename from hardware-configuration-vm.nix rename to hosts/vm/hardware-configuration.nix diff --git a/modules/common/default.nix b/modules/common/default.nix new file mode 100644 index 0000000..2ab55b2 --- /dev/null +++ b/modules/common/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./kb-input.nix + ]; +} diff --git a/modules/common/kb-input.nix b/modules/common/kb-input.nix new file mode 100644 index 0000000..3bd4821 --- /dev/null +++ b/modules/common/kb-input.nix @@ -0,0 +1,42 @@ +{ + pkgs, + config, + lib, + ... +}: let + cfg = config.common.kb-input; +in { + options = { + common.kb-input = { + enable = lib.mkEnableOption "input method and custom keyboard layout"; + }; + }; + + config = lib.mkIf cfg.enable { + services.xserver.xkb.extraLayouts = { + minimak-4 = { + description = "English (US, Minimak-4)"; + languages = [ "eng" ]; + symbolsFile = ./minimak; + }; + minimak-8 = { + description = "English (US, Minimak-8)"; + languages = [ "eng" ]; + symbolsFile = ./minimak; + }; + minimak-12 = { + description = "English (US, Minimak-12)"; + languages = [ "eng" ]; + symbolsFile = ./minimak; + }; + }; + + i18n.inputMethod = { + type = "fcitx5"; + enable = true; + fcitx5.waylandFrontend = true; + fcitx5.plasma6Support = true; + fcitx5.addons = [ pkgs.fcitx5-mozc ]; + }; + }; +} \ No newline at end of file diff --git a/minimak b/modules/common/minimak similarity index 100% rename from minimak rename to modules/common/minimak diff --git a/modules/default.nix b/modules/default.nix index 417c7db..fb2485c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,5 +1,6 @@ {...}: { imports = [ + ./common ./workarounds ]; }