From 64194760d24cd7a69d74f656c71b3d419bd89833 Mon Sep 17 00:00:00 2001 From: chn Date: Sun, 23 Jul 2023 00:09:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E5=BE=88=E5=A4=9A=E4=B8=9C?= =?UTF-8?q?=E8=A5=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 6 +- flake.nix | 3 +- modules/hardware/chn-PC.nix | 4 +- modules/packages/hpc.nix | 20 +-- modules/packages/terminal.nix | 62 -------- modules/system/default.nix | 291 +++++++++++++++++++++------------- 6 files changed, 199 insertions(+), 187 deletions(-) delete mode 100644 modules/packages/terminal.nix diff --git a/flake.lock b/flake.lock index e02fdac3..c6225e11 100644 --- a/flake.lock +++ b/flake.lock @@ -286,11 +286,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1689524878, - "narHash": "sha256-auh9qvI/bGlKIZTamiI4J371ZsNtP8yk/TKCFXBDn6Q=", + "lastModified": 1690031053, + "narHash": "sha256-6ikGMvZ5hBL1ChBncEG9cYZkgYHXzq4jRF8gBougWqw=", "owner": "CHN-beta", "repo": "nixpkgs", - "rev": "ece52e008044c2810ff7a75f3287d4610daf2b26", + "rev": "b568ffd587d59272d6a7adaf454c3d49e343aa5b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 03df2a3c..c5626324 100644 --- a/flake.nix +++ b/flake.nix @@ -134,6 +134,7 @@ (inputs.nur-xddxdd.overlays.custom args.config.boot.kernelPackages.nvidia_x11) final prev; } ) inputs.nixd.overlays.default + inputs.nix-alien.overlays.default ]; config.allowUnfree = true; }; @@ -220,6 +221,7 @@ { hostname = "chn-PC"; march = "alderlake"; + type = "workstation"; }; virtualization = { @@ -244,7 +246,6 @@ ./modules/networking/wall_client.nix ./modules/networking/xmunet.nix ./modules/networking/chn-PC.nix - ./modules/packages/terminal.nix ./modules/packages/gui.nix ./modules/packages/hpc.nix [ ./modules/users/root.nix {} ] diff --git a/modules/hardware/chn-PC.nix b/modules/hardware/chn-PC.nix index 8e4efbad..34d6a5c4 100644 --- a/modules/hardware/chn-PC.nix +++ b/modules/hardware/chn-PC.nix @@ -15,8 +15,8 @@ }).pkgs; in { - pandoc = generic-pkgs.pandoc; - fwupd = generic-pkgs.fwupd; + # pandoc = generic-pkgs.pandoc; + # fwupd = generic-pkgs.fwupd; } )]; }; diff --git a/modules/packages/hpc.nix b/modules/packages/hpc.nix index 6803d24d..c7af23f1 100644 --- a/modules/packages/hpc.nix +++ b/modules/packages/hpc.nix @@ -24,15 +24,15 @@ inputs: # config.nixpkgs.config.replaceStdenv = { pkgs }: pkgs.ccacheStdenv; # only replace stdenv for large and tested packages # config.programs.ccache.packageNames = [ "webkitgtk" "libreoffice" "tensorflow" "linux" "chromium" ]; - config.nixpkgs.overlays = [(final: prev: - { - libreoffice-qt = prev.libreoffice-qt.override (prev: { unwrapped = prev.unwrapped.override - (prev: { stdenv = final.ccacheStdenv.override { stdenv = prev.stdenv; }; }); }); - python3 = prev.python3.override { packageOverrides = python-final: python-prev: - { - tensorflow = python-prev.tensorflow.override - { stdenv = final.ccacheStdenv.override { stdenv = python-prev.tensorflow.stdenv; }; }; - };}; + # config.nixpkgs.overlays = [(final: prev: + # { + # libreoffice-qt = prev.libreoffice-qt.override (prev: { unwrapped = prev.unwrapped.override + # (prev: { stdenv = final.ccacheStdenv.override { stdenv = prev.stdenv; }; }); }); + # python3 = prev.python3.override { packageOverrides = python-final: python-prev: + # { + # tensorflow = python-prev.tensorflow.override + # { stdenv = final.ccacheStdenv.override { stdenv = python-prev.tensorflow.stdenv; }; }; + # };}; # # webkitgtk = prev.webkitgtk.override (prev: # # { stdenv = final.ccacheStdenv.override { stdenv = prev.stdenv; }; enableUnifiedBuilds = false; }); # wxGTK31 = prev.wxGTK31.override { stdenv = final.ccacheStdenv.override { stdenv = prev.wxGTK31.stdenv; }; }; @@ -50,7 +50,7 @@ inputs: # # { stdenv = prev.linuxPackages_xanmod_latest.kernel.buildPackages.stdenv; }; # # }; # # }; - })]; + # })]; # config.programs.ccache.packageNames = [ "libreoffice-unwrapped" ]; } diff --git a/modules/packages/terminal.nix b/modules/packages/terminal.nix deleted file mode 100644 index 2def652a..00000000 --- a/modules/packages/terminal.nix +++ /dev/null @@ -1,62 +0,0 @@ -inputs: -{ - config = - { - environment.systemPackages = with inputs.pkgs; - [ - beep neofetch screen dos2unix tldr gnugrep pv - pciutils usbutils lshw powertop compsize iotop iftop smartmontools htop intel-gpu-tools btop wayland-utils clinfo - glxinfo vulkan-tools - ksh - vim nano - wget aria2 curl yt-dlp - tree git autojump exa - nix-output-monitor inputs.topInputs.nix-alien.packages.x86_64-linux.nix-alien nix-template - apacheHttpd certbot-full - pigz rar unrar upx unzip zip lzip - util-linux snapper - ocrmypdf pdfgrep - openssl ssh-to-age gnupg age sops - ipset iptables iproute2 dig nettools - gcc clang-tools - sshfs kio-fuse - pam_u2f - e2fsprogs - trash-cli tmux adb-sync pdfchain wgetpaste httplib clang magic-enum xtensor - go rustc boost cereal cxxopts valgrind - lsd zellij broot - nil nixd - p7zip appimage-run file todo-txt-cli pandoc - ]; - programs = - { - nix-index-database.comma.enable = true; - nix-index.enable = true; - command-not-found.enable = false; - zsh = - { - enable = true; - syntaxHighlighting.enable = true; - autosuggestions.enable = true; - enableCompletion = true; - ohMyZsh = - { - enable = true; - plugins = [ "git" "colored-man-pages" "extract" "history-substring-search" "autojump" ]; - customPkgs = with inputs.pkgs; [ zsh-nix-shell ]; - }; - }; - adb.enable = true; - gnupg.agent = - { - enable = true; - enableSSHSupport = true; - }; - }; - services = - { - fwupd.enable = true; - udev.packages = [ inputs.pkgs.yubikey-personalization ]; - }; - }; -} diff --git a/modules/system/default.nix b/modules/system/default.nix index f2fb746e..32c38032 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -3,116 +3,189 @@ inputs: options.nixos.system = let inherit (inputs.lib) mkOption types; in { hostname = mkOption { type = types.nonEmptyStr; }; - march = mkOption { type = types.nullOr types.nonEmptyStr; }; + march = mkOption { type = types.nullOr types.nonEmptyStr; }; + type = mkOption { type = types.enum [ "headless" "desktop" "workstation" ]; default = "headless"; }; }; config = let inherit (inputs.lib) mkMerge mkIf; inherit (inputs.localLib) mkConditional stripeTabs; in mkMerge [ - # generic - { - nix = - { - settings = - { - system-features = [ "big-parallel" "nixos-test" "benchmark" ]; - experimental-features = [ "nix-command" "flakes" ]; - keep-outputs = true; - keep-failed = true; - auto-optimise-store = true; - }; - daemonIOSchedClass = "idle"; - daemonCPUSchedPolicy = "idle"; - registry = - { - nixpkgs.flake = inputs.topInputs.nixpkgs; - nixos-config.flake = inputs.topInputs.self; - }; - }; - services = - { - udev.extraRules = stripeTabs - '' - ACTION=="add|change", KERNEL=="[sv]d[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq" - ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq" - ''; - dbus.implementation = "broker"; - }; - networking.networkmanager.enable = true; - programs = { dconf.enable = true; nix-ld.enable = true; }; - nixpkgs.config.allowUnfree = true; - time.timeZone = "Asia/Shanghai"; - system = - { - stateVersion = "22.11"; - configurationRevision = inputs.topInputs.self.rev or "dirty"; - }; - boot = - { - kernel.sysctl = - { - "net.core.rmem_max" = 67108864; - "net.core.wmem_max" = 67108864; - "net.ipv4.tcp_rmem" = "4096 87380 67108864"; - "net.ipv4.tcp_wmem" = "4096 65536 67108864"; - "net.ipv4.tcp_mtu_probing" = true; - "net.ipv4.tcp_tw_reuse" = true; - "vm.swappiness" = 10; - "net.ipv4.tcp_max_syn_backlog" = 8388608; - "net.core.netdev_max_backlog" = 8388608; - "net.core.somaxconn" = 8388608; - "vm.oom_kill_allocating_task" = true; - "vm.oom_dump_tasks" = false; - "vm.overcommit_memory" = 1; - "dev.i915.perf_stream_paranoid" = false; - }; - supportedFilesystems = [ "ntfs" ]; - consoleLogLevel = 7; - }; - hardware.enableAllFirmware = true; - systemd = - { - extraConfig = stripeTabs - " - DefaultTimeoutStopSec=10s - DefaultLimitNOFILE=1048576:1048576 - "; - user.extraConfig = "DefaultTimeoutStopSec=10s"; - services = - { - nix-daemon = - { - serviceConfig = { CacheDirectory = "nix"; Slice = "-.slice"; Nice = "19"; }; - environment = { TMPDIR = "/var/cache/nix"; }; - }; - systemd-tmpfiles-setup = { environment = { SYSTEMD_TMPFILES_FORCE_SUBVOL = "0"; }; }; - }; - timers.systemd-tmpfiles-clean.enable = false; - }; - } - # hostname - { networking.hostName = inputs.config.nixos.system.hostname; } - # march - ( - mkConditional (inputs.config.nixos.system.march != null) - { - nixpkgs = - { - hostPlatform = { system = "x86_64-linux"; gcc = - { arch = inputs.config.nixos.system.march; tune = inputs.config.nixos.system.march; }; }; - config.qchem-config.optArch = inputs.config.nixos.system.march; - }; - nix.settings.system-features = [ "gccarch-${inputs.config.nixos.system.march}" ]; - boot.kernelPatches = - [{ - name = "native kernel"; - patch = null; - extraStructuredConfig = - { - GENERIC_CPU = inputs.lib.kernel.no; - "M${inputs.lib.strings.toUpper inputs.config.nixos.system.march}" = inputs.lib.kernel.yes; - }; - }]; - } - { nixpkgs.hostPlatform = inputs.lib.mkDefault "x86_64-linux"; } - ) - ]; + # generic + { + nix = + { + settings = + { + system-features = [ "big-parallel" "nixos-test" "benchmark" ]; + experimental-features = [ "nix-command" "flakes" ]; + keep-outputs = true; + keep-failed = true; + auto-optimise-store = true; + }; + daemonIOSchedClass = "idle"; + daemonCPUSchedPolicy = "idle"; + registry = + { + nixpkgs.flake = inputs.topInputs.nixpkgs; + nixos-config.flake = inputs.topInputs.self; + }; + }; + services = + { + udev.extraRules = stripeTabs + '' + ACTION=="add|change", KERNEL=="[sv]d[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq" + ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq" + ''; + dbus.implementation = "broker"; + }; + networking.networkmanager.enable = true; + programs = { dconf.enable = true; nix-ld.enable = true; }; + nixpkgs.config.allowUnfree = true; + time.timeZone = "Asia/Shanghai"; + system = + { + stateVersion = "22.11"; + configurationRevision = inputs.topInputs.self.rev or "dirty"; + }; + boot = + { + kernel.sysctl = + { + "net.core.rmem_max" = 67108864; + "net.core.wmem_max" = 67108864; + "net.ipv4.tcp_rmem" = "4096 87380 67108864"; + "net.ipv4.tcp_wmem" = "4096 65536 67108864"; + "net.ipv4.tcp_mtu_probing" = true; + "net.ipv4.tcp_tw_reuse" = true; + "vm.swappiness" = 10; + "net.ipv4.tcp_max_syn_backlog" = 8388608; + "net.core.netdev_max_backlog" = 8388608; + "net.core.somaxconn" = 8388608; + "vm.oom_kill_allocating_task" = true; + "vm.oom_dump_tasks" = false; + "vm.overcommit_memory" = 1; + "dev.i915.perf_stream_paranoid" = false; + }; + supportedFilesystems = [ "ntfs" ]; + consoleLogLevel = 7; + }; + hardware.enableAllFirmware = true; + systemd = + { + extraConfig = stripeTabs + " + DefaultTimeoutStopSec=10s + DefaultLimitNOFILE=1048576:1048576 + "; + user.extraConfig = "DefaultTimeoutStopSec=10s"; + services = + { + nix-daemon = + { + serviceConfig = { CacheDirectory = "nix"; Slice = "-.slice"; Nice = "19"; }; + environment = { TMPDIR = "/var/cache/nix"; }; + }; + systemd-tmpfiles-setup = { environment = { SYSTEMD_TMPFILES_FORCE_SUBVOL = "0"; }; }; + }; + timers.systemd-tmpfiles-clean.enable = false; + }; + } + # hostname + { networking.hostName = inputs.config.nixos.system.hostname; } + # march + ( + mkConditional (inputs.config.nixos.system.march != null) + { + nixpkgs = + { + hostPlatform = { system = "x86_64-linux"; gcc = + { arch = inputs.config.nixos.system.march; tune = inputs.config.nixos.system.march; }; }; + config.qchem-config.optArch = inputs.config.nixos.system.march; + }; + nix.settings.system-features = [ "gccarch-${inputs.config.nixos.system.march}" ]; + boot.kernelPatches = + [{ + name = "native kernel"; + patch = null; + extraStructuredConfig = + { + GENERIC_CPU = inputs.lib.kernel.no; + "M${inputs.lib.strings.toUpper inputs.config.nixos.system.march}" = inputs.lib.kernel.yes; + }; + }]; + } + { nixpkgs.hostPlatform = inputs.lib.mkDefault "x86_64-linux"; } + ) + # type + ( + mkMerge + [ + { + environment.systemPackages = with inputs.pkgs; + [ + # shell + ksh + # basic tools + beep dos2unix gnugrep pv tmux + # lsxx + pciutils usbutils lshw wayland-utils clinfo glxinfo vulkan-tools util-linux + # top + iotop iftop htop + # editor + vim nano + # downloader + wget aria2 curl yt-dlp + # file manager + tree git autojump exa trash-cli lsd zellij broot file + # compress + pigz rar upx unzip zip lzip p7zip + # file system management + sshfs e2fsprogs adb-sync + # disk management + smartmontools + # encryption and authentication + apacheHttpd openssl ssh-to-age gnupg age sops + # networking + ipset iptables iproute2 dig nettools + # nix tools + nix-output-monitor nix-template appimage-run nil nixd nix-alien + # development + gcc go rustc + + # move to other place + kio-fuse pam_u2f + pdfchain wgetpaste httplib clang magic-enum xtensor + boost cereal cxxopts valgrind + todo-txt-cli pandoc + # nix-ld + ]; + programs = + { + nix-index-database.comma.enable = true; + nix-index.enable = true; + zsh = + { + enable = true; + syntaxHighlighting.enable = true; + autosuggestions.enable = true; + enableCompletion = true; + ohMyZsh = + { + enable = true; + plugins = [ "git" "colored-man-pages" "extract" "history-substring-search" "autojump" ]; + customPkgs = with inputs.pkgs; [ zsh-nix-shell ]; + }; + }; + command-not-found.enable = false; + adb.enable = true; + gnupg.agent = { enable = true; enableSSHSupport = true; }; + }; + services = + { + fwupd.enable = true; + udev.packages = [ inputs.pkgs.yubikey-personalization ]; + }; + } + ] + ) + ]; }