From 2d956525cc4bd00b49b51e3c8b52136c081d2ba8 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Mon, 13 Apr 2026 16:39:18 -0400 Subject: [PATCH] formatting and hooks --- .gitignore | 3 +- .pre-commit-config.yaml | 1 + flake.lock | 60 +++++++++++++++++++ flake.nix | 25 ++++++-- hosts/fwbook.nix | 1 + hosts/hl-bigbox2.hardware-configuration.nix | 25 +++++--- hosts/hl-bigbox2.nix | 14 ++--- hosts/hl-fwdesk.nix | 16 ++--- hosts/hl-minipc1.nix | 2 +- hosts/hl-terra1.nix | 2 +- hosts/iso.nix | 4 +- modules/lib.nix | 12 ++-- modules/network-drives.nix | 38 ++++++------ modules/nixos/common/core.nix | 4 +- .../nixos/server/services/audiobookshelf.nix | 4 +- 15 files changed, 146 insertions(+), 65 deletions(-) create mode 120000 .pre-commit-config.yaml diff --git a/.gitignore b/.gitignore index 8e0ce25..5a62bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,7 @@ result.diff # direnv .direnv -# pre-commit -.pre-commit-config.yaml + # nix build result diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 120000 index 0000000..191e070 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1 @@ +/nix/store/3alj2xk8hgfqh6rrdh6bvfmmbzh9w92q-pre-commit-config.json \ No newline at end of file diff --git a/flake.lock b/flake.lock index cf7eebd..6c9aba6 100644 --- a/flake.lock +++ b/flake.lock @@ -212,6 +212,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -270,6 +286,28 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1775585728, + "narHash": "sha256-8Psjt+TWvE4thRKktJsXfR6PA/fWWsZ04DVaY6PUhr4=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "580633fa3fe5fc0379905986543fd7495481913d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "git-hooks-nix": { "inputs": { "flake-compat": "flake-compat", @@ -296,6 +334,27 @@ "url": "https://flakehub.com/f/cachix/git-hooks.nix/0.1.941" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "gnome-shell": { "flake": false, "locked": { @@ -801,6 +860,7 @@ "inputs": { "determinate": "determinate", "dms": "dms", + "git-hooks": "git-hooks", "home-manager": "home-manager", "hyprlauncher": "hyprlauncher", "nix-darwin": "nix-darwin", diff --git a/flake.nix b/flake.nix index 7a14e25..9db5599 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,11 @@ # Hardware nixos-hardware.url = "github:NixOS/nixos-hardware/master"; systems.url = "github:nix-systems/default"; + # Pre-commit hooks + git-hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # Nixpkgs determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/*"; nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0"; @@ -46,6 +51,7 @@ , stylix , hyprlauncher , dms + , git-hooks , }: let @@ -86,6 +92,12 @@ system: let pkgs = nixpkgs.legacyPackages.${system}; + pre-commit-check = git-hooks.lib.${system}.run { + src = ./.; + hooks = { + nixpkgs-fmt.enable = true; + }; + }; in { default = pkgs.mkShell { @@ -97,6 +109,7 @@ ]; shellHook = '' export PATH=$PATH:$(pwd)/bin + ${pre-commit-check.shellHook} ''; }; } @@ -183,12 +196,12 @@ ./hosts/hl-terra1.hardware-configuration.nix ]; }; - iso = lib.makeIso { - hostName = "skygnix"; - configuration = [ - ./hosts/iso.nix - ]; - }; + iso = lib.makeIso { + hostName = "skygnix"; + configuration = [ + ./hosts/iso.nix + ]; + }; }; }; } diff --git a/hosts/fwbook.nix b/hosts/fwbook.nix index 1c7cc07..7177c0b 100644 --- a/hosts/fwbook.nix +++ b/hosts/fwbook.nix @@ -193,6 +193,7 @@ in code-cursor-fhs nix-prefetch orca-slicer + devcontainer # Run macos apps darling-dmg diff --git a/hosts/hl-bigbox2.hardware-configuration.nix b/hosts/hl-bigbox2.hardware-configuration.nix index 9abc33f..9e4ace2 100644 --- a/hosts/hl-bigbox2.hardware-configuration.nix +++ b/hosts/hl-bigbox2.hardware-configuration.nix @@ -2,7 +2,8 @@ { imports = - [ (modulesPath + "/installer/scan/not-detected.nix") + [ + (modulesPath + "/installer/scan/not-detected.nix") ]; boot.initrd.availableKernelModules = [ "ahci" "ohci_pci" "ehci_pci" "pata_atiixp" "xhci_pci" "usb_storage" "usbhid" "sd_mod" ]; @@ -10,42 +11,48 @@ boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; boot.loader.grub = { - enable = true; - device = "/dev/sdb"; # install GRUB to MBR + enable = true; + device = "/dev/sdb"; # install GRUB to MBR efiSupport = false; }; fileSystems."/" = - { device = "/dev/disk/by-uuid/5bf4a352-412f-47e1-9455-68f3aa629722"; + { + device = "/dev/disk/by-uuid/5bf4a352-412f-47e1-9455-68f3aa629722"; fsType = "btrfs"; options = [ "subvol=@root" "compress=zstd" "noatime" ]; }; fileSystems."/boot" = - { device = "/dev/disk/by-uuid/ccc80fd2-b38b-412b-9988-12a3194a5b57"; + { + device = "/dev/disk/by-uuid/ccc80fd2-b38b-412b-9988-12a3194a5b57"; fsType = "ext4"; }; fileSystems."/var" = - { device = "/dev/disk/by-uuid/5bf4a352-412f-47e1-9455-68f3aa629722"; + { + device = "/dev/disk/by-uuid/5bf4a352-412f-47e1-9455-68f3aa629722"; fsType = "btrfs"; options = [ "compress=zstd" "subvol=@var" "noatime" ]; }; fileSystems."/nix" = - { device = "/dev/disk/by-uuid/8cd6e560-4db9-4cf1-8048-27a7c6308965"; + { + device = "/dev/disk/by-uuid/8cd6e560-4db9-4cf1-8048-27a7c6308965"; fsType = "btrfs"; options = [ "compress=zstd" "subvol=@nix" "noatime" ]; }; fileSystems."/home" = - { device = "/dev/disk/by-uuid/6f4b2adc-5818-41ea-a4ba-720fb96b8f98"; + { + device = "/dev/disk/by-uuid/6f4b2adc-5818-41ea-a4ba-720fb96b8f98"; fsType = "btrfs"; options = [ "compress=zstd" "subvol=@home" "noatime" ]; }; fileSystems."/data/fourTerra" = - { device = "/dev/sde1"; + { + device = "/dev/sde1"; fsType = "btrfs"; options = [ "compress=zstd" "subvol=@data" "noatime" ]; }; diff --git a/hosts/hl-bigbox2.nix b/hosts/hl-bigbox2.nix index f86d8dc..03b80a3 100644 --- a/hosts/hl-bigbox2.nix +++ b/hosts/hl-bigbox2.nix @@ -1,12 +1,12 @@ { config, pkgs, ... }: let -ports = { - nixServe = 5000; - lockdPort = 4001; - mountdPort = 4002; - statdPort = 4000; -}; -openPorts = builtins.attrValues ports; + ports = { + nixServe = 5000; + lockdPort = 4001; + mountdPort = 4002; + statdPort = 4000; + }; + openPorts = builtins.attrValues ports; in { skyg = { diff --git a/hosts/hl-fwdesk.nix b/hosts/hl-fwdesk.nix index e761797..56f3cd0 100644 --- a/hosts/hl-fwdesk.nix +++ b/hosts/hl-fwdesk.nix @@ -11,7 +11,7 @@ let comfyui = 8188; }; openPorts = [ - ports.ollama + ports.ollama ports.tabby ports.fastWhisper ports.piper @@ -143,11 +143,11 @@ in environmentVariables = { # Stability fix — SDMA is buggy on Strix Halo unified memory - HSA_ENABLE_SDMA = "0"; + HSA_ENABLE_SDMA = "0"; # Flash attention for better performance OLLAMA_FLASH_ATTENTION = "1"; # Keep models loaded - OLLAMA_KEEP_ALIVE = "24h"; + OLLAMA_KEEP_ALIVE = "24h"; }; }; hardware.graphics.enable = true; @@ -175,11 +175,11 @@ in streaming = true; }; faster-whisper.servers.todd = { - enable = true; - uri = "tcp://0.0.0.0:${toString ports.fastWhisper}"; - model = "tiny.en"; - language = "en"; - device = "auto"; + enable = true; + uri = "tcp://0.0.0.0:${toString ports.fastWhisper}"; + model = "tiny.en"; + language = "en"; + device = "auto"; }; }; virtualisation.docker = { diff --git a/hosts/hl-minipc1.nix b/hosts/hl-minipc1.nix index 46f78a5..a17dc88 100644 --- a/hosts/hl-minipc1.nix +++ b/hosts/hl-minipc1.nix @@ -53,7 +53,7 @@ in openFirewall = true; port = ports.audiobookshelf; configDir = "/mnt/Data/audiobookshelf/config"; - metadtaDir = "/mnt/Data/audiobookshelf/metadata"; + metadataDir = "/mnt/Data/audiobookshelf/metadata"; }; }; services.dockerRegistry = { diff --git a/hosts/hl-terra1.nix b/hosts/hl-terra1.nix index f17552f..96eb890 100644 --- a/hosts/hl-terra1.nix +++ b/hosts/hl-terra1.nix @@ -1,6 +1,6 @@ { pkgs, ... }: let - openPorts = [ + openPorts = [ # nfs 111 2049 diff --git a/hosts/iso.nix b/hosts/iso.nix index 258d368..4b51f53 100644 --- a/hosts/iso.nix +++ b/hosts/iso.nix @@ -7,7 +7,7 @@ # Networking networking.networkmanager.enable = true; - # Skyg Settings + # Skyg Settings skyg = { user.enable = true; nixos.common = { @@ -26,7 +26,7 @@ environment.systemPackages = with pkgs; [ # Disk tools parted - gparted # GUI partitioner + gparted # GUI partitioner cryptsetup btrfs-progs dosfstools diff --git a/modules/lib.nix b/modules/lib.nix index 6b8905a..fcac8c5 100644 --- a/modules/lib.nix +++ b/modules/lib.nix @@ -22,11 +22,11 @@ let } ); osModules = [ - determinate.nixosModules.default - stylix.nixosModules.stylix - home-manager.nixosModules.default - nix-flatpak.nixosModules.nix-flatpak - specialArgs.dms.nixosModules.dank-material-shell + determinate.nixosModules.default + stylix.nixosModules.stylix + home-manager.nixosModules.default + nix-flatpak.nixosModules.nix-flatpak + specialArgs.dms.nixosModules.dank-material-shell ]; # makeHomeManagerUsers = # { modules ? [ ] @@ -96,7 +96,7 @@ in hostName systemStateVersion homeManagerVersion - ; + ; }) ] ++ configuration; }; diff --git a/modules/network-drives.nix b/modules/network-drives.nix index a64074b..b50b2e5 100644 --- a/modules/network-drives.nix +++ b/modules/network-drives.nix @@ -4,27 +4,27 @@ }: let cfg = config.skyg.networkDrives; - makeCommonOption = { - defaultHost, - enabledByDefault ? true - } : lib.mkOption { - type = lib.types.submodule { - options = { - enable = lib.mkOption { - type = lib.types.bool; - default = enabledByDefault; - }; - host = lib.mkOption { - type = lib.types.str; - default = defaultHost; + makeCommonOption = + { defaultHost + , enabledByDefault ? true + }: lib.mkOption { + type = lib.types.submodule { + options = { + enable = lib.mkOption { + type = lib.types.bool; + default = enabledByDefault; + }; + host = lib.mkOption { + type = lib.types.str; + default = defaultHost; + }; }; }; + default = { + enable = enabledByDefault; + host = defaultHost; + }; }; - default = { - enable = enabledByDefault; - host = defaultHost; - }; - }; in { options = { @@ -77,7 +77,7 @@ in }; fileSystems."/homelab/bigbox2/data/fourTerra" = lib.mkIf cfg.bigBox2.enable { - device = "${cfg.terra1.host}:/data/fourTerra"; + device = "${cfg.bigBox2.host}:/data/fourTerra"; fsType = "nfs"; options = cfg.options; }; diff --git a/modules/nixos/common/core.nix b/modules/nixos/common/core.nix index 5270573..85cd176 100644 --- a/modules/nixos/common/core.nix +++ b/modules/nixos/common/core.nix @@ -58,8 +58,8 @@ services.cron = { enable = true; systemCronJobs = [ - "* 23 * * * root nix-collect-garbage --delete-older-than 7d" - "* 23 * * * ${config.skyg.user.name} nix-collect-garbage --delete-older-than 7d" + "0 23 * * * root nix-collect-garbage --delete-older-than 7d" + "0 23 * * * ${config.skyg.user.name} nix-collect-garbage --delete-older-than 7d" ]; }; } diff --git a/modules/nixos/server/services/audiobookshelf.nix b/modules/nixos/server/services/audiobookshelf.nix index a91cc6d..cf37ac6 100644 --- a/modules/nixos/server/services/audiobookshelf.nix +++ b/modules/nixos/server/services/audiobookshelf.nix @@ -23,7 +23,7 @@ in { type = types.str; }; - metadtaDir = mkOption { + metadataDir = mkOption { description = "Path to Audiobookshelf config folder"; type = types.str; @@ -80,7 +80,7 @@ in { ExecStart = "${cfg.package}/bin/audiobookshelf --host ${cfg.host} --port ${ toString cfg.port - } --config ${cfg.configDir} --metadata ${cfg.metadtaDir}"; + } --config ${cfg.configDir} --metadata ${cfg.metadataDir}"; Restart = "on-failure"; }; };