Skip to content

Commit

Permalink
Initial setup with hive
Browse files Browse the repository at this point in the history
  • Loading branch information
yousiki committed Mar 20, 2024
1 parent 592aac7 commit 54380fc
Show file tree
Hide file tree
Showing 11 changed files with 788 additions and 146 deletions.
10 changes: 10 additions & 0 deletions cells/common/commonProfiles.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
inputs,
cell,
}: let
inherit (inputs.cells.common.lib) importProfiles;
in
importProfiles {
src = ./profiles;
args = {inherit inputs cell;};
}
28 changes: 28 additions & 0 deletions cells/common/lib.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
inputs,
cell,
}: let
inherit (inputs) haumea;

defaultAsRoot = _: mod: mod.default or mod;
in {
importConfigurations = {
src,
args ? {},
}:
haumea.lib.load {
inherit src;
inputs = args;
transformer = defaultAsRoot;
};

importProfiles = {
src,
args ? {},
}:
haumea.lib.load {
inherit src;
inputs = args;
transformer = haumea.lib.transformers.liftDefault;
};
}
53 changes: 53 additions & 0 deletions cells/common/profiles/core.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
inputs,
cell,
}: {
pkgs,
lib,
...
}: let
l = builtins // lib;

flake = import "${inputs.self}/flake.nix";
in {
# Basic nix configuration for both NixOS and Darwin.
nix = {
settings = {
# Nix automatically detects files in the store that have identical contents, and replaces them with hard links to a single copy.
auto-optimise-store = true;
# Nix will instruct remote build machines to use their own binary substitutes if available.
builders-use-substitutes = true;
# Experimental nix features.
experimental-features = ["flakes" "nix-command"];
# Nix will fall back to building from source if a binary substitute fails.
fallback = true;
# The garbage collector will keep the derivations from which non-garbage store paths were built.
keep-derivations = true;
# The garbage collector will keep the outputs of non-garbage derivations.
keep-outputs = true;
# Builds will be performed in a sandboxed environment on Linux.
sandbox = pkgs.stdenv.isLinux;
# These users will have additional rights when connecting to the Nix daemon.
trusted-users = ["root" "@wheel" "@admin"];
# Never warn about dirty Git/Mercurial trees.
warn-dirty = false;
# Substituters and public keys.
inherit (flake.nixConfig) substituters trusted-substituters trusted-public-keys;
};

# Garbage collector
gc.automatic = true;

# List of directories to be searched for <...> file references.
nixPath = [
"nixpkgs=flake:nixpkgs"
"darwin=/etc/nix/inputs/darwin"
"home-manager=flake:home-manager"
];

registry =
l.mapAttrs
(n: v: {flake = v;})
(l.removeAttrs inputs ["nixpkgs" "cells" "self"]);
};
}
32 changes: 32 additions & 0 deletions cells/nixos/hosts/hakase/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{
config,
lib,
pkgs,
...
}: {
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;

boot.kernelPackages = pkgs.linuxPackages_latest;

networking.hostName = "hakase";

time.timeZone = "Asia/Shanghai";

networking.proxy.default = "http://yousiki:[email protected]:7890";
networking.proxy.noProxy = "127.0.0.1,localhost,cn.yousiki.top,edu.cn";

users.users.yousiki = {
isNormalUser = true;
extraGroups = ["wheel" "docker"];
shell = pkgs.zsh;
};

programs.zsh.enable = true;

services.openssh.enable = true;
services.openssh.openFirewall = true;
}
35 changes: 35 additions & 0 deletions cells/nixos/hosts/hakase/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
inputs,
cell,
}: {
_module.specialArgs = {
inherit inputs;
};

imports = [
./configuration.nix
./hardware-configuration.nix

inputs.nixos-hardware.nixosModules.common-cpu-intel-cpu-only
inputs.nixos-hardware.nixosModules.common-gpu-nvidia-nonprime
inputs.nixos-hardware.nixosModules.common-pc-hdd
inputs.nixos-hardware.nixosModules.common-pc-ssd

inputs.cells.common.commonProfiles.core

inputs.cells.nixos.nixosProfiles.core
];

bee = rec {
system = "x86_64-linux";
home = inputs.home-manager;
pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
};
overlays = [];
};
};
}
47 changes: 47 additions & 0 deletions cells/nixos/hosts/hakase/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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 = ["vmd" "xhci_pci" "ahci" "nvme" "usbhid" "uas" "sd_mod"];
boot.initrd.kernelModules = [];
boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [];
boot.supportedFilesystems = ["bcachefs"];

fileSystems."/" = {
device = "/dev/disk/by-uuid/d7bb32dc-4599-499c-913e-73660f0cf3c6";
fsType = "bcachefs";
options = ["noatime"];
};

fileSystems."/boot" = {
device = "/dev/disk/by-uuid/5764-78C1";
fsType = "vfat";
};

swapDevices = [
{device = "/dev/disk/by-uuid/d1772975-d75b-4efa-aed1-3cb602761b56";}
{device = "/dev/disk/by-uuid/9dc3e2ac-b63d-4dda-8b4c-7be566aa349a";}
];

# 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.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp2s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
10 changes: 10 additions & 0 deletions cells/nixos/nixosConfigurations.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
inputs,
cell,
}: let
inherit (inputs.cells.common.lib) importConfigurations;
in
importConfigurations {
src = ./hosts;
args = {inherit inputs cell;};
}
10 changes: 10 additions & 0 deletions cells/nixos/nixosProfiles.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
inputs,
cell,
}: let
inherit (inputs.cells.common.lib) importProfiles;
in
importProfiles {
src = ./profiles;
args = {inherit inputs cell;};
}
6 changes: 6 additions & 0 deletions cells/nixos/profiles/core.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
inputs,
cell,
}: {...}: {
system.stateVersion = "24.05";
}
Loading

0 comments on commit 54380fc

Please sign in to comment.