From df61c211c247cf069e0d6b9b118127c7a65dee28 Mon Sep 17 00:00:00 2001 From: Origami404 Date: Sat, 16 May 2026 21:42:13 +0800 Subject: [PATCH] [hosts] add oparic-local-dev --- flake.nix | 23 ++++ home/hosts/oparic-local-dev.nix | 17 +++ hosts/oparic-local-dev/configuration.nix | 105 ++++++++++++++++++ .../hardware-configuration.nix | 28 +++++ 4 files changed, 173 insertions(+) create mode 100644 home/hosts/oparic-local-dev.nix create mode 100644 hosts/oparic-local-dev/configuration.nix create mode 100644 hosts/oparic-local-dev/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index 6158616..926fec0 100644 --- a/flake.nix +++ b/flake.nix @@ -28,6 +28,13 @@ ./hosts/eris/configuration.nix ]; }; + "oparic-local-dev" = nixpkgs-linux.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./hosts/oparic-local-dev/configuration.nix + ]; + }; }; darwinConfigurations = { @@ -73,6 +80,22 @@ }; }; + "origami@oparic-local-dev" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs-linux.legacyPackages.x86_64-linux; + modules = [ + { nixpkgs.config.allowUnfreePredicate = _: true; } + inputs.sops-nix.homeManagerModules.sops + ./home/hosts/oparic-local-dev.nix + ]; + extraSpecialArgs = { + inherit inputs; + lib = import ./home/lib/origami404.nix { + hmSource = inputs.home-manager; + npLib = nixpkgs-linux.lib; + }; + }; + }; + "origami@hypnos" = home-manager-darwin.lib.homeManagerConfiguration { pkgs = nixpkgs-darwin.legacyPackages.aarch64-darwin; modules = [ diff --git a/home/hosts/oparic-local-dev.nix b/home/hosts/oparic-local-dev.nix new file mode 100644 index 0000000..e2e5054 --- /dev/null +++ b/home/hosts/oparic-local-dev.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +{ + home.homeDirectory = "/home/origami"; + + imports = [ + ../modules/common.nix + ../modules/shell.nix + ../modules/zsh.nix + ../modules/shell-develop.nix + ../modules/ssh.nix + ]; + + programs.fish.shellAliases = { + "flake-update" = "nixos-rebuild switch --use-remote-sudo --flake ${config.home.homeDirectory}/flakes#oparic-local-dev"; + }; +} diff --git a/hosts/oparic-local-dev/configuration.nix b/hosts/oparic-local-dev/configuration.nix new file mode 100644 index 0000000..3368aa5 --- /dev/null +++ b/hosts/oparic-local-dev/configuration.nix @@ -0,0 +1,105 @@ +{ config, lib, pkgs, inputs, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + inputs.sops-nix.nixosModules.sops + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # BIOS + GRUB, 安装到 MBR + boot.loader.grub = { + enable = true; + device = "/dev/sda"; + configurationLimit = 10; + }; + + networking.hostName = "oparic-local-dev"; + + # 静态 IP + networking.interfaces.ens18.ipv4.addresses = [{ + address = "192.168.2.22"; + prefixLength = 24; + }]; + networking.defaultGateway = "192.168.2.1"; + networking.nameservers = [ "119.29.29.29" ]; + + time.timeZone = "Asia/Shanghai"; + + nix.settings = { + trusted-users = [ "origami" ]; + substituters = [ + "https://mirrors.bfsu.edu.cn/nix-channels/store" + ]; + auto-optimise-store = true; + }; + + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 1w"; + }; + + environment.systemPackages = with pkgs; [ + git + vim + wget + curl + + zip + xz + unzip + p7zip + zstd + gnutar + + file + which + tree + gnused + gawk + gnupg + pciutils + usbutils + + home-manager + nix-output-monitor + ]; + + i18n = { + defaultLocale = "C.UTF-8"; + extraLocaleSettings = { + LC_MESSAGES = "en_US.UTF-8"; + LC_TIME = "C.UTF-8"; + LC_CTYPE = "zh_CN.UTF-8"; + }; + }; + + # PVE guest agent + services.qemuGuest.enable = true; + + # 用户 + programs.fish.enable = true; + users.groups.origami.gid = 1000; + users.users.origami = { + isNormalUser = true; + shell = pkgs.fish; + description = "Origami404"; + group = "origami"; + extraGroups = [ "wheel" ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAZxRoweHoLfoaydPqhsLnc4EGgwTp7Uz1DZ2DG447B+ origami@fedora" + ]; + }; + security.sudo.wheelNeedsPassword = false; + + sops.defaultSopsFile = ../../secrets/ssh-private.yaml; + sops.defaultSopsFormat = "yaml"; + sops.age.keyFile = "/home/origami/.config/sops/age/keys.txt"; + + services.openssh.enable = true; + + system.stateVersion = "23.11"; +} diff --git a/hosts/oparic-local-dev/hardware-configuration.nix b/hosts/oparic-local-dev/hardware-configuration.nix new file mode 100644 index 0000000..344339b --- /dev/null +++ b/hosts/oparic-local-dev/hardware-configuration.nix @@ -0,0 +1,28 @@ +# PVE 虚拟机, BIOS 启动, 单 ext4 硬盘 +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/5cc6cc26-502d-4a00-9f7a-95fd4432a1f4"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/396a18e2-4091-4da2-ab46-9a6ef3ae6e3d"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + + networking.useDHCP = lib.mkDefault false; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}