From 90d10606bcb7202f6e930c50beb22290fc706249 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Tue, 20 May 2025 12:53:13 +0800 Subject: [PATCH] chore: format nix files treewide --- flake.nix | 36 +++-- homes/x86_64-linux/rafiq/default.nix | 19 ++- modules/home/cli/default.nix | 13 +- modules/home/cli/editor/nvf/default.nix | 10 +- modules/home/cli/editor/nvf/keymaps.nix | 16 +- modules/home/cli/file-browser/yazi.nix | 4 +- modules/home/cli/shell/default.nix | 20 +-- modules/home/cli/utilities/default.nix | 2 +- modules/home/cli/utilities/git.nix | 44 ++--- .../home/desktop/browser/firefox/default.nix | 12 +- modules/home/desktop/default.nix | 23 +-- modules/home/desktop/terminal/default.nix | 7 +- .../windowManager/hyprland/default.nix | 89 +++++----- modules/home/system/default.nix | 10 +- modules/nixos/cli/default.nix | 27 ++-- modules/nixos/desktop/default.nix | 12 +- modules/nixos/desktop/windowManager.nix | 20 +-- modules/nixos/hardware/audio.nix | 8 +- modules/nixos/hardware/btrfs.nix | 152 +++++++++--------- modules/nixos/hardware/cpu.nix | 6 +- modules/nixos/hardware/default.nix | 2 +- modules/nixos/hardware/networking.nix | 26 +-- modules/nixos/hardware/nvidia.nix | 45 +++--- modules/nixos/system/boot.nix | 17 +- modules/nixos/system/default.nix | 10 +- modules/nixos/system/localisation.nix | 4 +- modules/nixos/system/secrets.nix | 4 +- modules/nixos/system/users.nix | 25 +-- packages/rebuild/default.nix | 26 +-- systems/x86_64-linux/nemesis/default.nix | 17 +- 30 files changed, 387 insertions(+), 319 deletions(-) diff --git a/flake.nix b/flake.nix index 117c306..3b96a38 100644 --- a/flake.nix +++ b/flake.nix @@ -16,20 +16,24 @@ nvf.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = inputs: - inputs.snowfall-lib.mkFlake { - inherit inputs; - src = ./.; - snowfall.namespace = "pantheon"; - systems.modules.nixos = with inputs; [ - disko.nixosModules.disko - impermanence.nixosModules.impermanence - sops-nix.nixosModules.sops - ]; - homes.modules = with inputs; [ -impermanence.homeManagerModules.impermanence -nix-index-database.hmModules.nix-index -nvf.homeManagerModules.default - ]; - }; + outputs = + inputs: + inputs.snowfall-lib.mkFlake { + inherit inputs; + src = ./.; + snowfall.namespace = "pantheon"; + systems.modules.nixos = with inputs; [ + disko.nixosModules.disko + impermanence.nixosModules.impermanence + sops-nix.nixosModules.sops + ]; + homes.modules = with inputs; [ + impermanence.homeManagerModules.impermanence + nix-index-database.hmModules.nix-index + nvf.homeManagerModules.default + ]; + outputs-builder = channels: { + formatter = channels.nixpkgs.nixfmt-rfc-style; + }; + }; } diff --git a/homes/x86_64-linux/rafiq/default.nix b/homes/x86_64-linux/rafiq/default.nix index 377a436..86ad923 100644 --- a/homes/x86_64-linux/rafiq/default.nix +++ b/homes/x86_64-linux/rafiq/default.nix @@ -1,4 +1,9 @@ -{ config, pkgs, osConfig, ... }: +{ + config, + pkgs, + osConfig, + ... +}: { cli.shell = "zsh"; cli.editor = "nvf"; @@ -23,12 +28,12 @@ ]; home.persistence."/persist/home/rafiq".directories = [ - "repos" - ]; + "repos" + ]; - programs.direnv = { - enable = true; - nix-direnv.enable = true; - }; + programs.direnv = { + enable = true; + nix-direnv.enable = true; + }; } diff --git a/modules/home/cli/default.nix b/modules/home/cli/default.nix index 86e9a4e..085f7e2 100644 --- a/modules/home/cli/default.nix +++ b/modules/home/cli/default.nix @@ -1,6 +1,11 @@ -{config, lib, osConfig, ... }: { - options.cli = { + config, + lib, + osConfig, + ... +}: +{ + options.cli = { shell = lib.pantheon.mkStrOption; editor = lib.pantheon.mkStrOption; file-browser = lib.pantheon.mkStrOption; @@ -14,7 +19,9 @@ config = lib.mkMerge [ { programs.zoxide.enable = true; - home.persistence."/persist/home/${config.snowfallorg.user.name}".directories = [ "./local/share/zoxide" ]; + home.persistence."/persist/home/${config.snowfallorg.user.name}".directories = [ + "./local/share/zoxide" + ]; } { programs.nix-index.enable = true; diff --git a/modules/home/cli/editor/nvf/default.nix b/modules/home/cli/editor/nvf/default.nix index ef30023..b030b32 100644 --- a/modules/home/cli/editor/nvf/default.nix +++ b/modules/home/cli/editor/nvf/default.nix @@ -5,15 +5,15 @@ programs.nvf = { enable = true; settings.vim = { - keymaps = import ./keymaps.nix; + keymaps = import ./keymaps.nix; utility.yazi-nvim = { enable = true; - mappings = { + mappings = { openYazi = "t"; openYaziDir = "T"; - }; - setupOpts.open_for_directories = true; - }; + }; + setupOpts.open_for_directories = true; + }; }; }; }; diff --git a/modules/home/cli/editor/nvf/keymaps.nix b/modules/home/cli/editor/nvf/keymaps.nix index 3a90792..6b53f99 100644 --- a/modules/home/cli/editor/nvf/keymaps.nix +++ b/modules/home/cli/editor/nvf/keymaps.nix @@ -1,9 +1,9 @@ [ - { - desc = "Open the file path under the cursor, making the file if it doesn't exist."; - key = "gf"; - mode = "n"; - action = ":cd %:p:h:e "; - silent = true; - } - ] + { + desc = "Open the file path under the cursor, making the file if it doesn't exist."; + key = "gf"; + mode = "n"; + action = ":cd %:p:h:e "; + silent = true; + } +] diff --git a/modules/home/cli/file-browser/yazi.nix b/modules/home/cli/file-browser/yazi.nix index f620f98..f206bfe 100644 --- a/modules/home/cli/file-browser/yazi.nix +++ b/modules/home/cli/file-browser/yazi.nix @@ -1,8 +1,6 @@ { config, lib, ... }: { - config = - lib.mkIf (config.cli.file-browser == "yazi") - { + config = lib.mkIf (config.cli.file-browser == "yazi") { home.sessionVariables.FILE_BROWSER = "yazi"; programs.yazi = { enable = true; diff --git a/modules/home/cli/shell/default.nix b/modules/home/cli/shell/default.nix index cea07bd..a132607 100644 --- a/modules/home/cli/shell/default.nix +++ b/modules/home/cli/shell/default.nix @@ -1,15 +1,15 @@ { config, lib, ... }: { config = lib.mkIf (config.cli.shell == "zsh") { - home.sessionVariables.SHELL = "zsh"; - programs.zsh = { - enable = true; - enableVteIntegration = true; - syntaxHighlighting.enable = true; - history.share = true; - history.size = 10000; - history.ignoreDups = true; - history.ignoreSpace = true; - }; + home.sessionVariables.SHELL = "zsh"; + programs.zsh = { + enable = true; + enableVteIntegration = true; + syntaxHighlighting.enable = true; + history.share = true; + history.size = 10000; + history.ignoreDups = true; + history.ignoreSpace = true; + }; }; } diff --git a/modules/home/cli/utilities/default.nix b/modules/home/cli/utilities/default.nix index a55eb04..3199378 100644 --- a/modules/home/cli/utilities/default.nix +++ b/modules/home/cli/utilities/default.nix @@ -1,3 +1,3 @@ { - imports = [ ./git.nix ]; + imports = [ ./git.nix ]; } diff --git a/modules/home/cli/utilities/git.nix b/modules/home/cli/utilities/git.nix index 0e55c37..9ff8079 100644 --- a/modules/home/cli/utilities/git.nix +++ b/modules/home/cli/utilities/git.nix @@ -1,27 +1,27 @@ -{lib,config,...}: +{ lib, config, ... }: { config = { - home.sessionVariables.GIT_CONFIG_GLOBAL = "$HOME/.config/git/config"; - home.shellAliases = { - gs = "git status"; - gc = "git commit"; - gcam = "git commit -am"; - gu = "git push"; - gy = "git pull"; - }; - programs.git = { - enable = true; - userName = config.cli.git.name; - userEmail = config.cli.git.email; - signing.key = "~/.ssh/id_ed25519.pub"; - signing.signByDefault = true; - extraConfig = { - init.defaultBranch = config.cli.git.defaultBranch; - push.autoSetupRemote = true; - pull.rebase = false; - core.editor = "$EDITOR"; - gpg.format = "ssh"; + home.sessionVariables.GIT_CONFIG_GLOBAL = "$HOME/.config/git/config"; + home.shellAliases = { + gs = "git status"; + gc = "git commit"; + gcam = "git commit -am"; + gu = "git push"; + gy = "git pull"; + }; + programs.git = { + enable = true; + userName = config.cli.git.name; + userEmail = config.cli.git.email; + signing.key = "~/.ssh/id_ed25519.pub"; + signing.signByDefault = true; + extraConfig = { + init.defaultBranch = config.cli.git.defaultBranch; + push.autoSetupRemote = true; + pull.rebase = false; + core.editor = "$EDITOR"; + gpg.format = "ssh"; + }; }; }; - }; } diff --git a/modules/home/desktop/browser/firefox/default.nix b/modules/home/desktop/browser/firefox/default.nix index 5ab8eb8..f485f5b 100644 --- a/modules/home/desktop/browser/firefox/default.nix +++ b/modules/home/desktop/browser/firefox/default.nix @@ -1,12 +1,12 @@ { config, lib, ... }: { config = lib.mkIf (config.desktop.browser == "firefox") { - home.persistence."/persist/home/rafiq".directories = [ ".mozilla/firefox" ]; + home.persistence."/persist/home/rafiq".directories = [ ".mozilla/firefox" ]; home.sessionVariables.BROWSER = "firefox"; - programs.firefox = { - enable = true; - profiles.rafiq.id = 0; - profiles.test.id = 1; - }; + programs.firefox = { + enable = true; + profiles.rafiq.id = 0; + profiles.test.id = 1; + }; }; } diff --git a/modules/home/desktop/default.nix b/modules/home/desktop/default.nix index 5d080f3..35dc813 100644 --- a/modules/home/desktop/default.nix +++ b/modules/home/desktop/default.nix @@ -1,4 +1,9 @@ -{ config, lib, osConfig, ... }: +{ + config, + lib, + osConfig, + ... +}: { options.desktop = { windowManager = lib.pantheon.mkStrOption; @@ -6,14 +11,12 @@ terminal = lib.pantheon.mkStrOption; }; - - config = { - assertions = - [ - { - assertion = (osConfig.desktop.windowManager == config.desktop.windowManager); - message = "You have set your home window manager to one that is not installed on this system."; - } - ]; + config = { + assertions = [ + { + assertion = (osConfig.desktop.windowManager == config.desktop.windowManager); + message = "You have set your home window manager to one that is not installed on this system."; + } + ]; }; } diff --git a/modules/home/desktop/terminal/default.nix b/modules/home/desktop/terminal/default.nix index 6c5b63c..ad5d5fc 100644 --- a/modules/home/desktop/terminal/default.nix +++ b/modules/home/desktop/terminal/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { config = lib.mkMerge [ (lib.mkIf (config.desktop.terminal == "kitty") { diff --git a/modules/home/desktop/windowManager/hyprland/default.nix b/modules/home/desktop/windowManager/hyprland/default.nix index b3fa925..26177ba 100644 --- a/modules/home/desktop/windowManager/hyprland/default.nix +++ b/modules/home/desktop/windowManager/hyprland/default.nix @@ -1,4 +1,9 @@ -{ config, lib, osConfig, ... }: +{ + config, + lib, + osConfig, + ... +}: let mainMonitor = osConfig.desktop.mainMonitor; in @@ -7,48 +12,50 @@ in ]; - config = lib.mkIf (config.desktop.windowManager == "hyprland") (lib.mkMerge [ - { - xdg.configFile."uwsm/env".text = # sh - '' - - ''; - wayland.windowManager.hyprland = { - enable = true; - systemd.enable = false; - settings = { - ecosystem.no_update_news = true; - "$hypr" = "CTRL_SUPER_ALT_SHIFT"; + config = lib.mkIf (config.desktop.windowManager == "hyprland") ( + lib.mkMerge [ + { + xdg.configFile."uwsm/env".text = # sh + '' - monitor = [ - "${mainMonitor.id}, ${mainMonitor.resolution}@${mainMonitor.refresh-rate}, auto, ${mainMonitor.scale}" - ", preferred, auto, 1" - ]; + ''; + wayland.windowManager.hyprland = { + enable = true; + systemd.enable = false; + settings = { + ecosystem.no_update_news = true; + "$hypr" = "CTRL_SUPER_ALT_SHIFT"; - bind = [ - "$hypr, Q, exec, uwsm stop" - "SUPER, W, killactive" + monitor = [ + "${mainMonitor.id}, ${mainMonitor.resolution}@${mainMonitor.refresh-rate}, auto, ${mainMonitor.scale}" + ", preferred, auto, 1" + ]; - "SUPER, return, exec, uwsm app -- $TERMINAL" - "SUPER, O, exec, uwsm app -- $BROWSER" + bind = [ + "$hypr, Q, exec, uwsm stop" + "SUPER, W, killactive" - "SUPER, H, cyclenext, visible" - "SUPER, L, cyclenext, visible prev" - "SUPER_ALT, H, movewindow, l" - "SUPER_ALT, J, movewindow, d" - "SUPER_ALT, K, movewindow, u" - "SUPER_ALT, L, movewindow, r" - "ALT_SHIFT, H, resizeactive, -10% 0" - "ALT_SHIFT, J, resizeactive, 0 -10%" - "ALT_SHIFT, K, resizeactive, 0 10%" - "ALT_SHIFT, L, resizeactive, 10% 0" - "SUPER_CTRL, H, workspace, r-1" - "SUPER_CTRL, L, workspace, r+1" - "$hypr, H, movetoworkspace, r-1" - "$hypr, L, movetoworkspace, r+1" - ]; - }; - }; - } - ]); + "SUPER, return, exec, uwsm app -- $TERMINAL" + "SUPER, O, exec, uwsm app -- $BROWSER" + + "SUPER, H, cyclenext, visible" + "SUPER, L, cyclenext, visible prev" + "SUPER_ALT, H, movewindow, l" + "SUPER_ALT, J, movewindow, d" + "SUPER_ALT, K, movewindow, u" + "SUPER_ALT, L, movewindow, r" + "ALT_SHIFT, H, resizeactive, -10% 0" + "ALT_SHIFT, J, resizeactive, 0 -10%" + "ALT_SHIFT, K, resizeactive, 0 10%" + "ALT_SHIFT, L, resizeactive, 10% 0" + "SUPER_CTRL, H, workspace, r-1" + "SUPER_CTRL, L, workspace, r+1" + "$hypr, H, movetoworkspace, r-1" + "$hypr, L, movetoworkspace, r+1" + ]; + }; + }; + } + ] + ); } diff --git a/modules/home/system/default.nix b/modules/home/system/default.nix index 8da9c36..3996e00 100644 --- a/modules/home/system/default.nix +++ b/modules/home/system/default.nix @@ -1,11 +1,11 @@ { config, ... }: { home.persistence."/persist/home/${config.snowfallorg.user.name}" = { - directories = [ - ".ssh" - ".config/sops/age" - ]; - allowOther = true; + directories = [ + ".ssh" + ".config/sops/age" + ]; + allowOther = true; }; home.stateVersion = "24.11"; diff --git a/modules/nixos/cli/default.nix b/modules/nixos/cli/default.nix index 4bd1711..ebbf824 100644 --- a/modules/nixos/cli/default.nix +++ b/modules/nixos/cli/default.nix @@ -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 + } + ]; } diff --git a/modules/nixos/desktop/default.nix b/modules/nixos/desktop/default.nix index 2c3327b..fd89cad 100644 --- a/modules/nixos/desktop/default.nix +++ b/modules/nixos/desktop/default.nix @@ -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; }; } diff --git a/modules/nixos/desktop/windowManager.nix b/modules/nixos/desktop/windowManager.nix index 2421d70..251690a 100644 --- a/modules/nixos/desktop/windowManager.nix +++ b/modules/nixos/desktop/windowManager.nix @@ -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; }; }) ]; diff --git a/modules/nixos/hardware/audio.nix b/modules/nixos/hardware/audio.nix index 426c003..912a463 100644 --- a/modules/nixos/hardware/audio.nix +++ b/modules/nixos/hardware/audio.nix @@ -1,9 +1,9 @@ { config, lib, ... }: { config = { - services.pipewire = { - enable = true; - pulse.enable = true; - }; + services.pipewire = { + enable = true; + pulse.enable = true; + }; }; } diff --git a/modules/nixos/hardware/btrfs.nix b/modules/nixos/hardware/btrfs.nix index 44a3464..a2e4f58 100644 --- a/modules/nixos/hardware/btrfs.nix +++ b/modules/nixos/hardware/btrfs.nix @@ -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; + }) + ] + ); } diff --git a/modules/nixos/hardware/cpu.nix b/modules/nixos/hardware/cpu.nix index 7d1f809..99e09bf 100644 --- a/modules/nixos/hardware/cpu.nix +++ b/modules/nixos/hardware/cpu.nix @@ -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" ]; }) ]; } diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index 91f6e4d..4f83975 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -1,4 +1,4 @@ -{lib,...}: +{ lib, ... }: { imports = [ ./btrfs.nix diff --git a/modules/nixos/hardware/networking.nix b/modules/nixos/hardware/networking.nix index fcf0e0d..ffcb907 100644 --- a/modules/nixos/hardware/networking.nix +++ b/modules/nixos/hardware/networking.nix @@ -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" ]; } ]; diff --git a/modules/nixos/hardware/nvidia.nix b/modules/nixos/hardware/nvidia.nix index 4708e40..f4a600b 100644 --- a/modules/nixos/hardware/nvidia.nix +++ b/modules/nixos/hardware/nvidia.nix @@ -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"; + }; + } + ] + ); } diff --git a/modules/nixos/system/boot.nix b/modules/nixos/system/boot.nix index 5421655..270ca0f 100644 --- a/modules/nixos/system/boot.nix +++ b/modules/nixos/system/boot.nix @@ -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; }) ]; } diff --git a/modules/nixos/system/default.nix b/modules/nixos/system/default.nix index 2a6641b..793693c 100644 --- a/modules/nixos/system/default.nix +++ b/modules/nixos/system/default.nix @@ -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 = { diff --git a/modules/nixos/system/localisation.nix b/modules/nixos/system/localisation.nix index 904408b..ce5242e 100644 --- a/modules/nixos/system/localisation.nix +++ b/modules/nixos/system/localisation.nix @@ -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"; } ]; } diff --git a/modules/nixos/system/secrets.nix b/modules/nixos/system/secrets.nix index c3b5e18..99de1f2 100644 --- a/modules/nixos/system/secrets.nix +++ b/modules/nixos/system/secrets.nix @@ -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; }; }; diff --git a/modules/nixos/system/users.nix b/modules/nixos/system/users.nix index dad4def..6d8f05d 100644 --- a/modules/nixos/system/users.nix +++ b/modules/nixos/system/users.nix @@ -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; diff --git a/packages/rebuild/default.nix b/packages/rebuild/default.nix index 45b84da..7396d93 100644 --- a/packages/rebuild/default.nix +++ b/packages/rebuild/default.nix @@ -1,16 +1,16 @@ { lib, pkgs, ... }: pkgs.writeShellScriptBin "rebuild" # sh -'' -if [ ! -f "flake.nix" ]; then -echo "flake.nix not found in current directory. exiting..." -exit 1 -fi + '' + if [ ! -f "flake.nix" ]; then + echo "flake.nix not found in current directory. exiting..." + exit 1 + fi -git add . && \ -nixos-rebuild switch --flake . --use-remote-sudo && \ -echo "=== opening test shell. ===" && \ -echo "=== exit = commit ===" && \ -echo "=== exit 1 = abort ===" && \ -$SHELL && \ -git commit -a -'' + git add . && \ + nixos-rebuild switch --flake . --use-remote-sudo && \ + echo "=== opening test shell. ===" && \ + echo "=== exit = commit ===" && \ + echo "=== exit 1 = abort ===" && \ + $SHELL && \ + git commit -a + '' diff --git a/systems/x86_64-linux/nemesis/default.nix b/systems/x86_64-linux/nemesis/default.nix index 43671e0..d1ba2f9 100644 --- a/systems/x86_64-linux/nemesis/default.nix +++ b/systems/x86_64-linux/nemesis/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { system.hostname = "nemesis"; system.mainUser.name = "rafiq"; @@ -14,10 +19,10 @@ desktop.windowManager = "hyprland"; desktop.mainMonitor = { -id = "desc:OOO AN-270W04K"; -scale = "1"; -resolution = "2560x1440"; -refresh-rate = "144"; + id = "desc:OOO AN-270W04K"; + scale = "1"; + resolution = "2560x1440"; + refresh-rate = "144"; }; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; @@ -26,7 +31,7 @@ refresh-rate = "144"; environment.persistence."/persist" = { hideMounts = true; directories = [ - "/var/lib/systemd" + "/var/lib/systemd" ]; files = [ "/etc/ssh/ssh_host_ed25519_key"