From 87c0e537fe76cd1634cffab53f8220d5aa87c2f3 Mon Sep 17 00:00:00 2001 From: Dict Xiong Date: Mon, 27 May 2024 20:55:15 +0800 Subject: [PATCH] feat(g2): ok --- flake.lock | 82 +++++++++++++++++++++++++++++ hosts/g2/hardware-configuration.nix | 39 ++++++++++++++ hosts/modules/nasp.nix | 8 +-- 3 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 flake.lock create mode 100644 hosts/g2/hardware-configuration.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..fc36b35 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1716633019, + "narHash": "sha256-xim1b5/HZYbWaZKyI7cn9TJCM6ewNVZnesRr00mXeS4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9d29cd266cebf80234c98dd0b87256b6be0af44e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1716655032, + "narHash": "sha256-kQ25DAiCGigsNR/Quxm3v+JGXAEXZ8I7RAF4U94bGzE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "59a450646ec8ee0397f5fa54a08573e8240eb91f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1716715802, + "narHash": "sha256-usk0vE7VlxPX8jOavrtpOqphdfqEQpf9lgedlY/r66c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e2dd4e18cc1c7314e24154331bae07df76eb582f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", + "sops-nix": "sops-nix" + } + }, + "sops-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1716692524, + "narHash": "sha256-sALodaA7Zkp/JD6ehgwc0UCBrSBfB4cX66uFGTsqeFU=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "962797a8d7f15ed7033031731d0bb77244839960", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/hosts/g2/hardware-configuration.nix b/hosts/g2/hardware-configuration.nix new file mode 100644 index 0000000..110a05e --- /dev/null +++ b/hosts/g2/hardware-configuration.nix @@ -0,0 +1,39 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "ehci_pci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/3e260c5d-3e8c-47ad-9cad-ce3613c4e7a0"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/8956-3461"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.eno2.useDHCP = lib.mkDefault true; + # networking.interfaces.enp2s0np0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/modules/nasp.nix b/hosts/modules/nasp.nix index f90697c..6e0622e 100644 --- a/hosts/modules/nasp.nix +++ b/hosts/modules/nasp.nix @@ -3,7 +3,7 @@ let mainCfg = config.nasp; hostName = ("g" + (builtins.toString mainCfg.serial)); - ipSuffix = (builtins.toString (mainCfg.serial + 100)) + ipSuffix = (builtins.toString (mainCfg.serial + 100)); in { options.nasp = { @@ -14,6 +14,7 @@ in }; # inplementation + config = { nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.substituters = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" ]; ## system config @@ -51,7 +52,6 @@ in address = "0.0.0.0"; prefixLength = 0; via = "192.168.16.118"; - metric = 10; } ]; }; @@ -130,6 +130,7 @@ in ]; hashedPassword = "$y$j9T$Ei67I7VhQD6gF20/lNBUx0$jnrLqLNSJVCS959deKCamoOi4Q76nNeQ7/kDQCCABl1"; }; + users.groups.nasp = {}; security.sudo.extraConfig = '' %nasp ALL = (root) NOPASSWD: /usr/bin/docker %nasp ALL = (root) NOPASSWD: /usr/sbin/reboot @@ -139,4 +140,5 @@ in %nasp ALL = (root) NOPASSWD: /usr/sbin/ufw %nasp ALL = (root) NOPASSWD: /usr/sbin/ip ''; -} \ No newline at end of file + }; +}