diff --git a/flake.nix b/flake.nix index e423464..c20b750 100644 --- a/flake.nix +++ b/flake.nix @@ -1,75 +1,16 @@ { description = "Daily configuration based on Nix and Flake"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - - darwin.url = "github:LnL7/nix-darwin"; - darwin.inputs.nixpkgs.follows = "nixpkgs"; - - haumea.url = "github:nix-community/haumea"; - haumea.inputs.nixpkgs.follows = "nixpkgs"; - - fenix.url = "github:nix-community/fenix"; - fenix.inputs.nixpkgs.follows = "nixpkgs"; - - hyprland.url = "github:hyprwm/Hyprland"; - hyprland.inputs.nixpkgs.follows = "nixpkgs"; - - nvfetcher.url = "github:berberman/nvfetcher"; - nvfetcher.inputs.nixpkgs.follows = "nixpkgs"; - - treefmt-nix.url = "github:numtide/treefmt-nix"; - treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; - - nix-index-database.url = "github:nix-community/nix-index-database"; - nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; - - neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; - neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs"; - - fh.url = "github:DeterminateSystems/fh"; - fh.inputs.nixpkgs.follows = "nixpkgs"; - fh.inputs.fenix.follows = "fenix"; - - nix-ld.url = "github:Mic92/nix-ld"; - nix-ld.inputs.nixpkgs.follows = "nixpkgs"; - - nixos-vscode-server.url = "github:nix-community/nixos-vscode-server"; - nixos-vscode-server.inputs.nixpkgs.follows = "nixpkgs"; - - agenix.url = "github:ryantm/agenix"; - agenix.inputs.darwin.follows = "darwin"; - agenix.inputs.home-manager.follows = "home-manager"; - agenix.inputs.nixpkgs.follows = "nixpkgs"; - - arion.url = "github:hercules-ci/arion"; - arion.inputs.nixpkgs.follows = "nixpkgs"; - - default-systems.url = "github:nix-systems/default"; - - flake-root.url = "github:srid/flake-root"; - - flake-parts.url = "github:hercules-ci/flake-parts"; - }; - outputs = {self, ...} @ inputs: let globals = { root = ./.; - nixpkgs = { - config = { - allowUnfree = true; - }; - overlays = [ - inputs.agenix.overlays.default - inputs.arion.overlays.default - inputs.fenix.overlays.default - inputs.fh.overlays.default - inputs.neovim-nightly-overlay.overlay - ]; + nixpkgs.overlays = [ + inputs.agenix.overlays.default + inputs.arion.overlays.default + inputs.fenix.overlays.default + ]; + nixpkgs.config = { + allowUnfree = true; }; inherit self inputs; inherit (self) outputs; @@ -94,7 +35,8 @@ }: rec { _module.args.pkgs = import inputs.nixpkgs { inherit system; - inherit (globals.nixpkgs) config overlays; + inherit (globals.nixpkgs) config; + inherit (globals.nixpkgs) overlays; }; treefmt.config = { @@ -137,10 +79,60 @@ }; }; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + darwin.url = "github:LnL7/nix-darwin"; + darwin.inputs.nixpkgs.follows = "nixpkgs"; + + haumea.url = "github:nix-community/haumea"; + haumea.inputs.nixpkgs.follows = "nixpkgs"; + + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + + hyprland.url = "github:hyprwm/Hyprland"; + hyprland.inputs.nixpkgs.follows = "nixpkgs"; + + nvfetcher.url = "github:berberman/nvfetcher"; + nvfetcher.inputs.nixpkgs.follows = "nixpkgs"; + + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + + nix-index-database.url = "github:nix-community/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; + + nix-ld.url = "github:Mic92/nix-ld"; + nix-ld.inputs.nixpkgs.follows = "nixpkgs"; + + nixos-vscode-server.url = "github:nix-community/nixos-vscode-server"; + nixos-vscode-server.inputs.nixpkgs.follows = "nixpkgs"; + + agenix.url = "github:ryantm/agenix"; + agenix.inputs.darwin.follows = "darwin"; + agenix.inputs.home-manager.follows = "home-manager"; + agenix.inputs.nixpkgs.follows = "nixpkgs"; + + arion.url = "github:hercules-ci/arion"; + arion.inputs.nixpkgs.follows = "nixpkgs"; + + default-systems.url = "github:nix-systems/default"; + + flake-root.url = "github:srid/flake-root"; + + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + nixConfig = { extra-trusted-substituters = [ "https://cache.garnix.io" "https://hyprland.cachix.org" + "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" + "https://mirrors.ustc.edu.cn/nix-channels/store" "https://nichijou.cachix.org" "https://nix-community.cachix.org" "https://nixpkgs-wayland.cachix.org" diff --git a/src/commonProfiles/nix.nix b/src/commonProfiles/nix.nix index d8428fd..f3cf47c 100644 --- a/src/commonProfiles/nix.nix +++ b/src/commonProfiles/nix.nix @@ -33,6 +33,8 @@ with builtins // lib; { trusted-substituters = [ "https://cache.garnix.io" "https://hyprland.cachix.org" + "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" + "https://mirrors.ustc.edu.cn/nix-channels/store" "https://nichijou.cachix.org" "https://nix-community.cachix.org" "https://nixpkgs-wayland.cachix.org" diff --git a/src/commonProfiles/packages.nix b/src/commonProfiles/packages.nix index addc8b6..938b26b 100644 --- a/src/commonProfiles/packages.nix +++ b/src/commonProfiles/packages.nix @@ -5,24 +5,19 @@ ... }: with builtins // lib; { - environment.systemPackages = - (with pkgs; [ - cachix - clash-meta - curl - duf - eza - gh - git - helix - nettools - tmux - vim - wget - ]) - ++ (optionals pkgs.stdenv.isLinux (with pkgs; [ - cloudflare-warp - ])); + environment.systemPackages = with pkgs; [ + curl + duf + eza + gh + git + helix + tmux + vim + wget + ]; + programs.fish.enable = true; programs.zsh.enable = true; + } diff --git a/src/nixosConfigurations/hakase/_configuration.nix b/src/nixosConfigurations/hakase/_configuration.nix index ce69cff..dbfa156 100644 --- a/src/nixosConfigurations/hakase/_configuration.nix +++ b/src/nixosConfigurations/hakase/_configuration.nix @@ -20,7 +20,6 @@ # Enable the Desktop Environments. services.xserver.displayManager.sddm.enable = true; services.xserver.desktopManager.plasma5.enable = true; - services.xserver.desktopManager.xfce.enable = true; # Enable xwayland. programs.xwayland.enable = true; @@ -29,4 +28,8 @@ # Disable automatic suspend. services.autosuspend.enable = false; + + # Configure network proxy. + networking.proxy.default = "http://satoshi.mck.cn.yousiki.top:7890"; + networking.proxy.noProxy = "127.0.0.1,localhost,yousiki.top,ybh1998.space,pku.edu.cn"; } diff --git a/src/nixosConfigurations/hakase/_hardware-configuration.nix b/src/nixosConfigurations/hakase/_hardware-configuration.nix index dde40da..b018ad7 100644 --- a/src/nixosConfigurations/hakase/_hardware-configuration.nix +++ b/src/nixosConfigurations/hakase/_hardware-configuration.nix @@ -17,28 +17,16 @@ boot.kernelModules = ["kvm-intel"]; boot.extraModulePackages = []; - fileSystems."/" = { - device = "/dev/disk/by-uuid/f4dd6d7c-e625-4a74-9325-85691ff9c351"; - fsType = "btrfs"; - options = ["subvol=@" "compress=zstd"]; - }; - - fileSystems."/boot" = { - device = "/dev/disk/by-uuid/4ABE-0CAF"; - fsType = "vfat"; - }; - - fileSystems."/mnt/ssd" = { - device = "/dev/disk/by-uuid/11db0944-b7ae-4e84-8dbd-13de8537efd1"; - fsType = "btrfs"; + fileSystems."/" = + { device = "/dev/disk/by-uuid/facf9680-93f9-4799-9277-54aee06a418b"; + fsType = "btrfs"; options = ["compress=zstd"]; - }; + }; - fileSystems."/mnt/hdd" = { - device = "/dev/disk/by-uuid/0c2264ed-46f9-4868-bab0-2efa61c7bb1f"; - fsType = "btrfs"; - options = ["compress=zstd"]; - }; + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/899E-B417"; + fsType = "vfat"; + }; swapDevices = [ { diff --git a/src/nixosConfigurations/hakase/default.nix b/src/nixosConfigurations/hakase/default.nix index a954314..cd74b44 100644 --- a/src/nixosConfigurations/hakase/default.nix +++ b/src/nixosConfigurations/hakase/default.nix @@ -5,13 +5,7 @@ globals.outputs.commonProfiles.nix globals.outputs.commonProfiles.packages globals.outputs.nixosProfiles.base - globals.outputs.nixosProfiles.desktop.fonts - globals.outputs.nixosProfiles.desktop.hyprland globals.outputs.nixosProfiles.nvidia-gpu - globals.outputs.nixosProfiles.secrets - globals.outputs.nixosProfiles.virtualisation.adrive-webdav - globals.outputs.nixosProfiles.virtualisation.base - globals.outputs.nixosProfiles.virtualisation.traefik globals.outputs.nixosProfiles.vscode-server globals.inputs.home-manager.nixosModules.home-manager { @@ -22,17 +16,7 @@ users.yousiki = { imports = [ globals.outputs.homeProfiles.base - globals.outputs.homeProfiles.desktop.applications - globals.outputs.homeProfiles.desktop.fcitx5 - globals.outputs.homeProfiles.desktop.hyprland - globals.outputs.homeProfiles.desktop.kitty - globals.outputs.homeProfiles.lang.c - globals.outputs.homeProfiles.lang.latex - globals.outputs.homeProfiles.lang.nix - globals.outputs.homeProfiles.lang.python - globals.outputs.homeProfiles.lang.rust globals.outputs.homeProfiles.secrets - globals.outputs.homeProfiles.shell.combined ]; }; }; diff --git a/src/nixosProfiles/base.nix b/src/nixosProfiles/base.nix index d50540a..a93283a 100644 --- a/src/nixosProfiles/base.nix +++ b/src/nixosProfiles/base.nix @@ -3,7 +3,7 @@ lib, pkgs, ... -}: { +}: with builtins // lib; { # Define a user account. Don't forget to set a password with ‘passwd’. users.users.yousiki = { isNormalUser = true; @@ -11,47 +11,23 @@ shell = pkgs.zsh; }; - # Enable ssh. - services.openssh.enable = true; - services.openssh.openFirewall = true; + # Make sure zsh is enabled. + programs.zsh.enable = true; - # Enable mosh. - programs.mosh.enable = true; + # Enable ssh. + services.openssh.enable = mkDefault true; + services.openssh.openFirewall = mkDefault true; # networking.wireless.enable = true; networking.networkmanager.enable = true; networking.firewall.enable = true; - networking.firewall.allowedTCPPorts = [22]; - networking.firewall.allowedUDPPortRanges = [ - # Mosh uses UDP ports in range [60000, 61000] - { - from = 60000; - to = 61000; - } - ]; time.timeZone = "Asia/Shanghai"; # Select internationalisation properties. i18n.defaultLocale = "en_US.UTF-8"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; - }; i18n.supportedLocales = ["all"]; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # useXkbConfig = true; # use xkbOptions in tty. - # }; services.xserver = { layout = "cn"; @@ -63,6 +39,11 @@ sound.enable = true; hardware.pulseaudio.enable = true; security.rtkit.enable = true; + + hardware.bluetooth.enable = true; + + hardware.opengl.enable = true; + hardware.opengl.driSupport32Bit = true; programs.mtr.enable = true; programs.gnupg.agent = { @@ -70,10 +51,5 @@ enableSSHSupport = true; }; - hardware.bluetooth.enable = true; - - hardware.opengl.enable = true; - hardware.opengl.driSupport32Bit = true; - - system.stateVersion = "23.05"; + system.stateVersion = "23.11"; } diff --git a/src/nixosProfiles/desktop/hyprland.nix b/src/nixosProfiles/desktop/hyprland.nix index 6e16c07..c318365 100644 --- a/src/nixosProfiles/desktop/hyprland.nix +++ b/src/nixosProfiles/desktop/hyprland.nix @@ -15,5 +15,6 @@ in { xwayland.enable = true; package = hyprlandPkgs.hyprland; portalPackage = hyprlandPkgs.xdg-desktop-portal-hyprland; + enableNvidiaPatches = nixpkgs.config.cudaSupport; }; } diff --git a/src/nixosProfiles/nvidia-gpu.nix b/src/nixosProfiles/nvidia-gpu.nix index 370d09e..413d80e 100644 --- a/src/nixosProfiles/nvidia-gpu.nix +++ b/src/nixosProfiles/nvidia-gpu.nix @@ -20,5 +20,4 @@ with builtins // lib; { nvtop python311Packages.gpustat ]; - programs.hyprland.enableNvidiaPatches = mkForce true; } diff --git a/src/nixosProfiles/vscode-server.nix b/src/nixosProfiles/vscode-server.nix index 9d16c80..c71f623 100644 --- a/src/nixosProfiles/vscode-server.nix +++ b/src/nixosProfiles/vscode-server.nix @@ -5,28 +5,8 @@ ... }: { imports = [ - globals.inputs.nix-ld.nixosModules.nix-ld globals.inputs.nixos-vscode-server.nixosModules.default ]; services.vscode-server.enable = true; - services.vscode-server.installPath = "$HOME/.vscode-server"; - - programs.nix-ld.enable = true; - - services.openssh.extraConfig = '' - AcceptEnv NIX_LD NIX_LD_LIBRARY_PATH - ''; - - environment.etc."vscode-server-support".source = pkgs.stdenv.mkDerivation { - name = "vscode-server-support"; - phases = ["installPhase"]; - installPhase = '' - set -e - mkdir -p $out - for lib in ${pkgs.glibc}/lib/ld-linux* ${pkgs.stdenv.cc.cc.lib}/lib/*; do - ln -sf $lib $out/$(basename $lib) - done - ''; - }; } diff --git a/src/packages/fh.nix b/src/packages/fh.nix deleted file mode 100644 index 5debce9..0000000 --- a/src/packages/fh.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ - globals, - config, - self', - inputs', - pkgs, - system, - ... -}: let - package = globals.inputs.fh.packages.${pkgs.system}.default; - - systems = import globals.inputs.default-systems; -in - if builtins.elem system systems - then package - else null