chore: format nix files treewide

This commit is contained in:
Mohammad Rafiq 2025-05-20 12:53:13 +08:00
parent e1652efa53
commit 90d10606bc
No known key found for this signature in database
30 changed files with 387 additions and 319 deletions

View file

@ -1,14 +1,19 @@
{config, lib, pkgs, ...}:
{
imports = [];
options.cli = {};
config = lib.mkMerge [
config,
lib,
pkgs,
...
}:
{
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
environment.pathsToLink = [ "/share/zsh" ]; # enables completion
}
];
imports = [ ];
options.cli = { };
config = lib.mkMerge [
{
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
environment.pathsToLink = [ "/share/zsh" ]; # enables completion
}
];
}

View file

@ -5,12 +5,12 @@
];
options.desktop = {
mainMonitor = {
id = lib.pantheon.mkStrOption;
scale = lib.pantheon.mkStrOption;
resolution = lib.pantheon.mkStrOption;
refresh-rate = lib.pantheon.mkStrOption;
};
mainMonitor = {
id = lib.pantheon.mkStrOption;
scale = lib.pantheon.mkStrOption;
resolution = lib.pantheon.mkStrOption;
refresh-rate = lib.pantheon.mkStrOption;
};
windowManager = lib.pantheon.mkStrOption;
};
}

View file

@ -2,21 +2,21 @@
{
config = lib.mkMerge [
(lib.mkIf (config.desktop.windowManager == "hyprland") {
environment.loginShellInit = # sh
''
if [[ -z "$SSH_CLIENT" && -z "$SSH_CONNECTION" ]]; then
if uwsm check may-start; then
exec uwsm start hyprland-uwsm.desktop
fi
environment.loginShellInit = # sh
''
if [[ -z "$SSH_CLIENT" && -z "$SSH_CONNECTION" ]]; then
if uwsm check may-start; then
exec uwsm start hyprland-uwsm.desktop
fi
'';
fi
'';
environment.variables = {
ELECTRON_OZONE_PLATFORM_HINT = "auto";
NIXOS_OZONE_WL = "1";
ELECTRON_OZONE_PLATFORM_HINT = "auto";
NIXOS_OZONE_WL = "1";
};
programs.hyprland = {
enable = true;
withUWSM = true;
withUWSM = true;
};
})
];

View file

@ -1,9 +1,9 @@
{ config, lib, ... }:
{
config = {
services.pipewire = {
enable = true;
pulse.enable = true;
};
services.pipewire = {
enable = true;
pulse.enable = true;
};
};
}

View file

@ -1,81 +1,89 @@
{lib, config, ...}:
{ lib, config, ... }:
let
cfg = config.hardware.drives.btrfs;
in
{
config = lib.mkIf (cfg.enable) (lib.mkMerge [
{
boot.initrd.kernelModules = [ "dm-snapshot" ];
disko.devices.disk.main = {
device = cfg.drive;
type = "disk";
content.type = "gpt";
content.partitions = {
boot.name = "boot";
boot.size = "1M";
boot.type = "EF02";
esp.name = "ESP";
esp.size = "500M";
esp.type = "EF00";
esp.content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
swap.size = "4G";
swap.content = {
type = "swap";
resumeDevice = true;
};
root.name = "root";
root.size = "100%";
root.content = {
type = "lvm_pv";
vg = "root_vg";
};
};
};
config = lib.mkIf (cfg.enable) (
lib.mkMerge [
{
boot.initrd.kernelModules = [ "dm-snapshot" ];
disko.devices.disk.main = {
device = cfg.drive;
type = "disk";
content.type = "gpt";
content.partitions = {
boot.name = "boot";
boot.size = "1M";
boot.type = "EF02";
esp.name = "ESP";
esp.size = "500M";
esp.type = "EF00";
esp.content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
swap.size = "4G";
swap.content = {
type = "swap";
resumeDevice = true;
};
root.name = "root";
root.size = "100%";
root.content = {
type = "lvm_pv";
vg = "root_vg";
};
};
};
disko.devices.lvm_vg.root_vg = {
type = "lvm_vg";
lvs.root.size = "100%FREE";
lvs.root.content.type = "btrfs";
lvs.root.content.extraArgs = ["-f"];
lvs.root.content.subvolumes = {
"/root".mountpoint = "/";
"/persist".mountpoint = "/persist";
"/persist".mountOptions = ["subvol=persist" "noatime"];
"/nix".mountpoint = "/nix";
"/nix".mountOptions = ["subvol=nix" "noatime"];
};
};
}
(lib.mkIf (cfg.ephemeralRoot) {
boot.initrd.postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/root_vg/root /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
fi
disko.devices.lvm_vg.root_vg = {
type = "lvm_vg";
lvs.root.size = "100%FREE";
lvs.root.content.type = "btrfs";
lvs.root.content.extraArgs = [ "-f" ];
lvs.root.content.subvolumes = {
"/root".mountpoint = "/";
"/persist".mountpoint = "/persist";
"/persist".mountOptions = [
"subvol=persist"
"noatime"
];
"/nix".mountpoint = "/nix";
"/nix".mountOptions = [
"subvol=nix"
"noatime"
];
};
};
}
(lib.mkIf (cfg.ephemeralRoot) {
boot.initrd.postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/root_vg/root /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
fi
delete_subvolume_recursively() {
IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
delete_subvolume_recursively "/btrfs_tmp/$i"
done
btrfs subvolume delete "$1"
}
delete_subvolume_recursively() {
IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
delete_subvolume_recursively "/btrfs_tmp/$i"
done
btrfs subvolume delete "$1"
}
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
delete_subvolume_recursively "$i"
done
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp
'';
programs.fuse.userAllowOther = true;
})
]);
btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp
'';
programs.fuse.userAllowOther = true;
})
]
);
}

View file

@ -1,9 +1,9 @@
{ config, lib, ... }:
{
config = lib.mkMerge [
(lib.mkIf (config.hardware.platform == "amd"){
hardware.cpu.amd.updateMicrocode = true;
boot.kernelModules = [ "kvm-amd" ];
(lib.mkIf (config.hardware.platform == "amd") {
hardware.cpu.amd.updateMicrocode = true;
boot.kernelModules = [ "kvm-amd" ];
})
];
}

View file

@ -1,4 +1,4 @@
{lib,...}:
{ lib, ... }:
{
imports = [
./btrfs.nix

View file

@ -2,20 +2,22 @@
{
config = lib.mkMerge [
{
networking.useDHCP = lib.mkDefault true;
networking.hostName = config.system.hostname;
networking.networkmanager.enable = true;
networking.useDHCP = lib.mkDefault true;
networking.hostName = config.system.hostname;
networking.networkmanager.enable = true;
services.openssh = {
enable = true;
settings = {
PrintMotd = true;};
};
services.openssh = {
enable = true;
settings = {
PrintMotd = true;
};
};
services.tailscale = {
enable = true;
authKeyFile = config.sops.secrets."keys/tailscale".path;};
environment.persistence."/persist".files = [ "/var/lib/tailscale/tailscaled.state"];
services.tailscale = {
enable = true;
authKeyFile = config.sops.secrets."keys/tailscale".path;
};
environment.persistence."/persist".files = [ "/var/lib/tailscale/tailscaled.state" ];
}
];

View file

@ -1,21 +1,28 @@
{ lib, config, pkgs, ... }:
{
config = lib.mkIf (config.hardware.gpu == "nvidia") (lib.mkMerge [
{
#TODO: Setup CUDA
hardware.graphics.enable = true;
hardware.graphics.extraPackages = with pkgs; [
nvidia-vaapi-driver
];
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.open = true;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
nixpkgs.config.allowUnfree = true;
environment.variables = {
LIBVA_DRIVER_NAME = "nvidia";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
NVD_BACKEND = "direct";
};
}
]);
lib,
config,
pkgs,
...
}:
{
config = lib.mkIf (config.hardware.gpu == "nvidia") (
lib.mkMerge [
{
#TODO: Setup CUDA
hardware.graphics.enable = true;
hardware.graphics.extraPackages = with pkgs; [
nvidia-vaapi-driver
];
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.open = true;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
nixpkgs.config.allowUnfree = true;
environment.variables = {
LIBVA_DRIVER_NAME = "nvidia";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
NVD_BACKEND = "direct";
};
}
]
);
}

View file

@ -1,12 +1,19 @@
{ config, lib, ... }:
{ config, lib, ... }:
{
config = lib.mkMerge [
{
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.availableKernelModules = [
"nvme"
"xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
];
boot.loader.efi.canTouchEfiVariables = true;
}
(lib.mkIf (config.system.bootloader == "systemd-boot"){
boot.loader.systemd-boot.enable = true;
(lib.mkIf (config.system.bootloader == "systemd-boot") {
boot.loader.systemd-boot.enable = true;
})
];
}

View file

@ -1,4 +1,4 @@
{ config, lib, ...}:
{ config, lib, ... }:
{
imports = [
./boot.nix
@ -9,10 +9,10 @@
];
options.system = {
hostname = lib.pantheon.mkStrOption;
mainUser.name = lib.pantheon.mkStrOption;
mainUser.publicKey = lib.pantheon.mkStrOption;
bootloader = lib.pantheon.mkStrOption;
hostname = lib.pantheon.mkStrOption;
mainUser.name = lib.pantheon.mkStrOption;
mainUser.publicKey = lib.pantheon.mkStrOption;
bootloader = lib.pantheon.mkStrOption;
};
config = {

View file

@ -2,8 +2,8 @@
{
config = lib.mkMerge [
{
time.timeZone = "Asia/Singapore";
i18n.defaultLocale = "en_US.UTF-8";
time.timeZone = "Asia/Singapore";
i18n.defaultLocale = "en_US.UTF-8";
}
];
}

View file

@ -2,9 +2,9 @@
{
sops = {
defaultSopsFile = lib.snowfall.fs.get-file "secrets/secrets.yaml";
age.sshKeyPaths = ["/persist/home/rafiq/.ssh/id_ed25519"];
age.sshKeyPaths = [ "/persist/home/rafiq/.ssh/id_ed25519" ];
secrets = {
"keys/tailscale" = {};
"keys/tailscale" = { };
"rafiq/hashedPassword".neededForUsers = true;
};
};

View file

@ -1,19 +1,24 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
config = lib.mkMerge [
{
users.mutableUsers = false;
users.groups.users = {
gid = 100;
members = [ "${config.system.mainUser.name}" ];
};
users.mutableUsers = false;
users.groups.users = {
gid = 100;
members = [ "${config.system.mainUser.name}" ];
};
users.users."${config.system.mainUser.name}" = {
linger = true;
uid = 1000;
linger = true;
uid = 1000;
isNormalUser = true;
hashedPasswordFile = config.sops.secrets."${config.system.mainUser.name}/hashedPassword".path;
hashedPasswordFile = config.sops.secrets."${config.system.mainUser.name}/hashedPassword".path;
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [ config.system.mainUser.publicKey ];
openssh.authorizedKeys.keys = [ config.system.mainUser.publicKey ];
};
services.getty.autologinUser = config.system.mainUser.name;
security.sudo.wheelNeedsPassword = false;