mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-07-16 17:41:09 +02:00
refactor: Use haumea for filesystem-based module system for flake outputs
refactor: Use hyphen(`-`) for variable names & folder names(except Python), replace all unserscore(`_`) with hyphen(`-`).
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# Host - Shoukei
|
||||
|
||||
This is NixOS's configuration for my Macbook Pro 2022 Intel i5, 13.3-inch, 16G RAM + 512G SSD.
|
||||
|
||||
Related:
|
||||
|
||||
- [/nixos-installer/README.shoukei.md](/nixos-installer/README.shoukei.md)
|
||||
- <https://github.com/NixOS/nixos-hardware/tree/master/apple/t2>
|
||||
- <https://wiki.t2linux.org/distributions/nixos/installation/>
|
||||
|
||||
|
||||
TODOs:
|
||||
|
||||
- [ ] Resume from suspend(close the lid) doesn't work
|
||||
- [ ] Show battery percentage in i3blocks/waybar
|
||||
- [ ] Touchbar unusable some times
|
||||
- It works on boot, but after a while it stops working
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
t2Cfg = config.hardware.myapple-t2;
|
||||
efiPrefix = config.boot.loader.efi.efiSysMountPoint;
|
||||
|
||||
apple-set-os-loader-installer = pkgs.stdenv.mkDerivation rec {
|
||||
name = "apple-set-os-loader-installer-1.0";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Redecorating";
|
||||
repo = "apple_set_os-loader";
|
||||
rev = "r33.9856dc4";
|
||||
sha256 = "hvwqfoF989PfDRrwU0BMi69nFjPeOmSaD6vR6jIRK2Y=";
|
||||
};
|
||||
buildInputs = [pkgs.gnu-efi];
|
||||
buildPhase = ''
|
||||
substituteInPlace Makefile --replace "/usr" '$(GNU_EFI)'
|
||||
export GNU_EFI=${pkgs.gnu-efi}
|
||||
make
|
||||
'';
|
||||
installPhase = ''
|
||||
install -D bootx64_silent.efi $out/bootx64.efi
|
||||
'';
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
hardware.myapple-t2.enableAppleSetOsLoader = lib.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
description = "Whether to enable the appleSetOsLoader activation script.";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
# Activation script to install apple-set-os-loader in order to unlock the iGPU
|
||||
system.activationScripts.myappleSetOsLoader = lib.optionalString t2Cfg.enableAppleSetOsLoader ''
|
||||
if [[ -e ${efiPrefix}/efi/boot/bootx64_original.efi ]]; then
|
||||
true # It's already installed, no action required
|
||||
elif [[ -e ${efiPrefix}/efi/boot/bootx64.efi ]]; then
|
||||
# Copy the new bootloader to a temporary location
|
||||
cp ${apple-set-os-loader-installer}/bootx64.efi ${efiPrefix}/efi/boot/bootx64_temp.efi
|
||||
|
||||
# Rename the original bootloader
|
||||
mv ${efiPrefix}/efi/boot/bootx64.efi ${efiPrefix}/efi/boot/bootx64_original.efi
|
||||
|
||||
# Move the new bootloader to the final destination
|
||||
mv ${efiPrefix}/efi/boot/bootx64_temp.efi ${efiPrefix}/efi/boot/bootx64.efi
|
||||
else
|
||||
echo "Error: ${efiPrefix}/efi/boot/bootx64.efi is missing" >&2
|
||||
fi
|
||||
'';
|
||||
|
||||
# Enable the iGPU by default if present
|
||||
environment.etc."modprobe.d/apple-gmux.conf".text = lib.optionalString t2Cfg.enableAppleSetOsLoader ''
|
||||
options apple-gmux force_igd=y
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "brcm-firmware";
|
||||
nativeBuildInputs = with pkgs; [gnutar xz];
|
||||
buildCommand = ''
|
||||
dir="$out/lib/"
|
||||
mkdir -p "$dir"
|
||||
tar -axvf ${./firmware.tar.xz} -C "$dir"
|
||||
'';
|
||||
}
|
||||
Binary file not shown.
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1703068421,
|
||||
"narHash": "sha256-WSw5Faqlw75McIflnl5v7qVD/B3S2sLh+968bpOGrWA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d65bceaee0fb1e64363f7871bc43dc1c6ecad99f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-23.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
# a flake for testing
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
||||
outputs = {nixpkgs, ...}: let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
in {
|
||||
packages."${system}".default = pkgs.callPackage ./default.nix {};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
nixos-hardware,
|
||||
myvars,
|
||||
...
|
||||
}:
|
||||
#############################################################
|
||||
#
|
||||
# Shoukei - NixOS running on Macbook Pro 2020 I5 16G
|
||||
# https://github.com/NixOS/nixos-hardware/tree/master/apple/t2
|
||||
#
|
||||
#############################################################
|
||||
let
|
||||
hostName = "shoukei"; # Define your hostname.
|
||||
in {
|
||||
imports = [
|
||||
nixos-hardware.nixosModules.apple-t2
|
||||
./apple-set-os-loader.nix
|
||||
{hardware.myapple-t2.enableAppleSetOsLoader = true;}
|
||||
|
||||
./hardware-configuration.nix
|
||||
../idols-ai/impermanence.nix
|
||||
];
|
||||
|
||||
boot.kernelModules = ["kvm-amd"];
|
||||
boot.extraModprobeConfig = "options kvm_amd nested=1"; # for amd cpu
|
||||
|
||||
networking = {
|
||||
inherit hostName;
|
||||
inherit (myvars.networking) defaultGateway nameservers;
|
||||
|
||||
# configures the network interface(include wireless) via `nmcli` & `nmtui`
|
||||
networkmanager.enable = true;
|
||||
};
|
||||
|
||||
# This value determines the NixOS release from which the default
|
||||
# settings for stateful data, like file locations and database versions
|
||||
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||
# this value at the release version of the first install of this system.
|
||||
# Before changing this value read the documentation for this option
|
||||
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||
system.stateVersion = "23.11"; # Did you read the comment?
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
# 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")
|
||||
];
|
||||
|
||||
hardware.firmware = [
|
||||
(import ./brcm-firmware {inherit pkgs;})
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod"];
|
||||
boot.initrd.kernelModules = [];
|
||||
boot.kernelModules = ["kvm-intel"];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
# Use the EFI boot loader.
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
# depending on how you configured your disk mounts, change this to /boot or /boot/efi.
|
||||
boot.loader.efi.efiSysMountPoint = "/boot";
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
|
||||
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
|
||||
boot.binfmt.emulatedSystems = ["aarch64-linux" "riscv64-linux"];
|
||||
# supported file systems, so we can mount any removable disks with these filesystems
|
||||
boot.supportedFilesystems = lib.mkForce [
|
||||
"ext4"
|
||||
"btrfs"
|
||||
"xfs"
|
||||
"ntfs"
|
||||
"fat"
|
||||
"vfat"
|
||||
"cifs" # mount windows share
|
||||
];
|
||||
|
||||
# clear /tmp on boot to get a stateless /tmp directory.
|
||||
boot.tmp.cleanOnBoot = true;
|
||||
boot.initrd = {
|
||||
# unlocked luks devices via a keyfile or prompt a passphrase.
|
||||
luks.devices."crypted-nixos" = {
|
||||
device = "/dev/nvme0n1p4";
|
||||
# the keyfile(or device partition) that should be used as the decryption key for the encrypted device.
|
||||
# if not specified, you will be prompted for a passphrase instead.
|
||||
#keyFile = "/root-part.key";
|
||||
|
||||
# whether to allow TRIM requests to the underlying device.
|
||||
# it's less secure, but faster.
|
||||
allowDiscards = true;
|
||||
# Whether to bypass dm-crypt’s internal read and write workqueues.
|
||||
# Enabling this should improve performance on SSDs;
|
||||
# https://wiki.archlinux.org/index.php/Dm-crypt/Specialties#Disable_workqueue_for_increased_solid_state_drive_(SSD)_performance
|
||||
bypassWorkqueues = true;
|
||||
};
|
||||
};
|
||||
|
||||
# equal to `mount -t tmpfs tmpfs /`
|
||||
fileSystems."/" = {
|
||||
device = "tmpfs";
|
||||
fsType = "tmpfs";
|
||||
# set mode to 755, otherwise systemd will set it to 777, which cause problems.
|
||||
# relatime: Update inode access times relative to modify or change time.
|
||||
options = ["relatime" "mode=755"];
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/nvme0n1p1";
|
||||
fsType = "vfat";
|
||||
};
|
||||
|
||||
fileSystems."/nix" = {
|
||||
device = "/dev/disk/by-uuid/2f4db246-e65d-4808-8ab4-5365f9dea1ef";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=@nix" "noatime" "compress-force=zstd:1"];
|
||||
};
|
||||
|
||||
fileSystems."/tmp" = {
|
||||
device = "/dev/disk/by-uuid/2f4db246-e65d-4808-8ab4-5365f9dea1ef";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=@tmp" "noatime" "compress-force=zstd:1"];
|
||||
};
|
||||
|
||||
fileSystems."/persistent" = {
|
||||
device = "/dev/disk/by-uuid/2f4db246-e65d-4808-8ab4-5365f9dea1ef";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=@persistent" "noatime" "compress-force=zstd:1"];
|
||||
# impermanence's data is required for booting.
|
||||
neededForBoot = true;
|
||||
};
|
||||
|
||||
fileSystems."/snapshots" = {
|
||||
device = "/dev/disk/by-uuid/2f4db246-e65d-4808-8ab4-5365f9dea1ef";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=@snapshots" "noatime" "compress-force=zstd:1"];
|
||||
};
|
||||
|
||||
# mount swap subvolume in readonly mode.
|
||||
fileSystems."/swap" = {
|
||||
device = "/dev/disk/by-uuid/2f4db246-e65d-4808-8ab4-5365f9dea1ef";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=@swap" "ro"];
|
||||
};
|
||||
|
||||
# remount swapfile in read-write mode
|
||||
fileSystems."/swap/swapfile" = {
|
||||
# the swapfile is located in /swap subvolume, so we need to mount /swap first.
|
||||
depends = ["/swap"];
|
||||
|
||||
device = "/swap/swapfile";
|
||||
fsType = "none";
|
||||
options = ["bind" "rw"];
|
||||
};
|
||||
|
||||
swapDevices = [
|
||||
{device = "/swap/swapfile";}
|
||||
];
|
||||
|
||||
# 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.enp230s0f1u1.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.wlp229s0.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
modules.desktop.hyprland = {
|
||||
nvidia = false;
|
||||
settings = {
|
||||
# Configure your Display resolution, offset, scale and Monitors here, use `hyprctl monitors` to get the info.
|
||||
# highres: get the best possible resolution
|
||||
# auto: postition automatically
|
||||
# 1.5: scale to 1.5 times
|
||||
# bitdepth,10: enable 10 bit support
|
||||
monitor = "eDP-1,highres,auto,1.5,bitdepth,10";
|
||||
};
|
||||
};
|
||||
|
||||
modules.desktop.i3 = {
|
||||
nvidia = false;
|
||||
};
|
||||
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
Host github.com
|
||||
Hostname github.com
|
||||
# github is controlled by shoukei~
|
||||
IdentityFile ~/.ssh/shoukei
|
||||
# Specifies that ssh should only use the identity file explicitly configured above
|
||||
# required to prevent sending default identity files first.
|
||||
IdentitiesOnly yes
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user