fix: Flake | use nixfmt=classic to format nix files

This commit is contained in:
2025-02-17 19:24:25 +05:00
parent 234e52f051
commit 7eab398f6d
41 changed files with 189 additions and 370 deletions

View File

@@ -1,10 +1,4 @@
{
pkgs,
inputs,
config,
lib,
...
}:
{ pkgs, inputs, config, lib, ... }:
{
imports = lib.flatten [
@@ -20,9 +14,7 @@
hostSpec = {
username = "shahab";
handle = "shahab96";
email = {
user = "shahab@dogar.dev";
};
email = { user = "shahab@dogar.dev"; };
userFullName = "Shahab Dogar";
domain = "rihla";
networking.ports.tcp.ssh = 22;
@@ -60,12 +52,11 @@
warn-dirty = false;
trusted-users = [ "@wheel" ];
substituters = ["https://hyprland.cachix.org"];
trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
experimental-features = [
"nix-command"
"flakes"
substituters = [ "https://hyprland.cachix.org" ];
trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
];
experimental-features = [ "nix-command" "flakes" ];
};
};
@@ -79,9 +70,7 @@
};
# ========= Sops =========
environment.systemPackages = with pkgs; [
sops
];
environment.systemPackages = with pkgs; [ sops ];
#
# ========== Localization ==========

View File

@@ -1,12 +1,4 @@
{
lib,
config,
device,
withSwap,
swapSize,
label,
...
}:
{ lib, config, device, withSwap, swapSize, label, ... }:
{
disko = {
@@ -42,10 +34,8 @@
passwordFile = "/tmp/secret.key";
settings = {
allowDiscards = true;
crypttabExtraOpts = [
"fido2-device=auto"
"token-timeout=10"
];
crypttabExtraOpts =
[ "fido2-device=auto" "token-timeout=10" ];
};
content = {
type = "lvm_pv";
@@ -72,35 +62,20 @@
size = "100%";
content = {
type = "btrfs";
extraArgs = [
"-L"
label
"-f"
];
extraArgs = [ "-L" label "-f" ];
subvolumes = {
"@root" = {
mountpoint = "/";
mountOptions = [
"subvol=root"
"compress=zstd"
"noatime"
];
mountOptions = [ "subvol=root" "compress=zstd" "noatime" ];
};
"@persist" = {
mountpoint = config.hostSpec.persist;
mountOptions = [
"subvol=persist"
"compress=zstd"
"noatime"
];
mountOptions =
[ "subvol=persist" "compress=zstd" "noatime" ];
};
"@nix" = {
mountpoint = "/nix";
mountOptions = [
"subvol=nix"
"compress=zstd"
"noatime"
];
mountOptions = [ "subvol=nix" "compress=zstd" "noatime" ];
};
};
};

View File

@@ -1,7 +1,4 @@
{
config,
...
}:
{ config, ... }:
{
programs = {

View File

@@ -1,6 +1,4 @@
{
...
}:
{ ... }:
{
programs.dconf.enable = true;

View File

@@ -1,7 +1,4 @@
{
pkgs,
...
}: {
{ pkgs, ... }: {
virtualisation = {
podman = {
enable = true;
@@ -14,11 +11,7 @@
};
};
containers = {
registries = {
search = ["docker.io"];
};
};
containers = { registries = { search = [ "docker.io" ]; }; };
libvirtd = {
enable = true;
@@ -27,7 +20,7 @@
ovmf = {
enable = true;
packages = with pkgs; [OVMFFull.fd];
packages = with pkgs; [ OVMFFull.fd ];
};
};
};

View File

@@ -1,7 +1,4 @@
{
pkgs,
...
}:
{ pkgs, ... }:
{
programs = {
@@ -15,8 +12,5 @@
gamemode.enable = true;
};
environment.systemPackages = with pkgs; [
mangohud
protonup-qt
];
environment.systemPackages = with pkgs; [ mangohud protonup-qt ];
}

View File

@@ -1,13 +1,10 @@
{
inputs,
pkgs,
...
}:
{ inputs, pkgs, ... }:
{
programs.hyprland = {
enable = true;
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
package =
inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
portalPackage =
inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
};

View File

@@ -1,6 +1,4 @@
{
...
}:
{ ... }:
{
programs.nix-ld.enable = true;

View File

@@ -1,10 +1,5 @@
{
pkgs,
...
}:
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
sbctl
];
environment.systemPackages = with pkgs; [ sbctl ];
}

View File

@@ -1,7 +1,4 @@
{
pkgs,
...
}:
{ pkgs, ... }:
{
services = {
@@ -17,7 +14,6 @@
};
security.rtkit.enable = true;
environment.systemPackages = builtins.attrValues {
inherit (pkgs) pavucontrol;
};
environment.systemPackages =
builtins.attrValues { inherit (pkgs) pavucontrol; };
}

View File

@@ -1,6 +1,4 @@
{
...
}:
{ ... }:
{
services.blueman.enable = true;

View File

@@ -1,6 +1,4 @@
{
...
}:
{ ... }:
{
services.fwupd.enable = true;

View File

@@ -1,14 +1,12 @@
{
pkgs,
...
}:
{ pkgs, ... }:
{
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --greeting 'Welcome to NixOS!' --asterisks --remember --remember-user-session --time --cmd ${pkgs.hyprland}/bin/Hyprland";
command =
"${pkgs.greetd.tuigreet}/bin/tuigreet --greeting 'Welcome to NixOS!' --asterisks --remember --remember-user-session --time --cmd ${pkgs.hyprland}/bin/Hyprland";
user = "greeter";
};
};

View File

@@ -1,11 +1,6 @@
{
config,
...
}:
let
sshPort = config.hostSpec.networking.ports.tcp.ssh;
in
{
{ config, ... }:
let sshPort = config.hostSpec.networking.ports.tcp.ssh;
in {
services.openssh = {
enable = true;
ports = [ sshPort ];

View File

@@ -1,7 +1,5 @@
# Reminder that CUPS cpanel defaults to localhost:631
{
...
}:
{ ... }:
{
services.printing.enable = true;

View File

@@ -1,6 +1,4 @@
{
...
}:
{ ... }:
{
services.pcscd.enable = true;

View File

@@ -1,7 +1,4 @@
{
pkgs,
...
}:
{ pkgs, ... }:
{
# yubikey login / sudo
@@ -16,7 +13,5 @@
};
};
environment.systemPackages = with pkgs; [
yubikey-manager
];
environment.systemPackages = with pkgs; [ yubikey-manager ];
}

View File

@@ -1,10 +1,4 @@
{
pkgs,
config,
lib,
inputs,
...
}:
{ pkgs, config, lib, inputs, ... }:
let
hostSpec = config.hostSpec;
pubKeys = lib.filesystem.listFilesRecursive ./keys;
@@ -19,20 +13,15 @@ in {
shell = pkgs.zsh;
home = hostSpec.home;
isNormalUser = true;
hashedPassword = "$y$j9T$pvjyL7hL5x2VBarGNTnMl1$mLA2UsWTbfp8Hgp/ug5l8224thi..Mo8.p7ME.tDZ.4";
extraGroups = [
"networkmanager"
"wheel"
"input"
"libvirtd"
];
hashedPassword =
"$y$j9T$pvjyL7hL5x2VBarGNTnMl1$mLA2UsWTbfp8Hgp/ug5l8224thi..Mo8.p7ME.tDZ.4";
extraGroups = [ "networkmanager" "wheel" "input" "libvirtd" ];
# Read all keys in ./keys and add them to authorizedKeys.
openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key);
openssh.authorizedKeys.keys =
lib.lists.forEach pubKeys (key: builtins.readFile key);
packages = with pkgs; [
libnotify
];
packages = with pkgs; [ libnotify ];
};
};
@@ -41,13 +30,12 @@ in {
inherit pkgs inputs;
hostSpec = config.hostSpec;
};
users.${hostSpec.username}.imports = lib.flatten [
(
{ config, ... }:
import (lib.custom.relativeToRoot "home/${hostSpec.username}/${hostSpec.hostName}.nix") {
inherit pkgs inputs config lib hostSpec;
}
)
users.${hostSpec.username}.imports = lib.flatten [
({ config, ... }:
import (lib.custom.relativeToRoot
"home/${hostSpec.username}/${hostSpec.hostName}.nix") {
inherit pkgs inputs config lib hostSpec;
})
];
};
}

View File

@@ -1,10 +1,4 @@
{
inputs,
pkgs,
lib,
config,
...
}:
{ inputs, pkgs, lib, config, ... }:
{
imports = lib.flatten [
@@ -26,7 +20,8 @@
# ========= Disk Layout =========
#
inputs.disko.nixosModules.disko
(lib.custom.relativeToRoot "hosts/common/disks/rihla.nix") {
(lib.custom.relativeToRoot "hosts/common/disks/rihla.nix")
{
_module.args = {
device = "/dev/nvme0n1";
withSwap = true;
@@ -38,9 +33,7 @@
#
# ========= Required Configs =========
#
(map lib.custom.relativeToRoot [
"hosts/common/core"
])
(map lib.custom.relativeToRoot [ "hosts/common/core" ])
#
# ========= Optional Configs =========
@@ -59,15 +52,16 @@
#
# ========= Optional Services =========
#
(map (s: lib.custom.relativeToRoot "hosts/common/optional/services/${s}.nix") [
"audio"
"bluetooth"
"firmware"
"greetd"
"openssh"
"printing"
"smart-card"
])
(map
(s: lib.custom.relativeToRoot "hosts/common/optional/services/${s}.nix") [
"audio"
"bluetooth"
"firmware"
"greetd"
"openssh"
"printing"
"smart-card"
])
];
#
@@ -91,30 +85,31 @@
efi.canTouchEfiVariables = true;
};
initrd.postResumeCommands = lib.mkIf config.hostSpec.impermanance (lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/crypt_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
initrd.postResumeCommands = lib.mkIf config.hostSpec.impermanance
(lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/crypt_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
'');
btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp
'');
lanzaboote = {
enable = config.hostSpec.secureBoot;
@@ -124,9 +119,7 @@
security.rtkit.enable = true;
environment.systemPackages = with pkgs; [
pciutils
];
environment.systemPackages = with pkgs; [ pciutils ];
system.stateVersion = "25.05";
}

View File

@@ -1,14 +1,8 @@
# 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.
{
pkgs,
config,
lib,
modulesPath,
...
}: {
imports = [(modulesPath + "/installer/scan/not-detected.nix")];
{ pkgs, config, lib, modulesPath, ... }: {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {
initrd = {
@@ -21,11 +15,11 @@
"usb_storage"
"sd_mod"
];
kernelModules = [];
kernelModules = [ ];
};
kernelModules = ["kvm-amd"];
extraModulePackages = [];
kernelModules = [ "kvm-amd" ];
extraModulePackages = [ ];
};
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
@@ -38,10 +32,11 @@
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware = {
cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
cpu.amd.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;
graphics = {
enable = true;
extraPackages = with pkgs; [amdvlk];
extraPackages = with pkgs; [ amdvlk ];
};
};
}