From 22e31ff60b174ed2f3a791f73cc2cf1919a7b129 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 5 Apr 2024 11:26:22 -0400 Subject: [PATCH] chore: Format with nixpkgs-fmt Note that we will continue to use nixpkgs-fmt for the time being here since nixfmt-rfc-style breaks string syntax highlighting and comments like `/* this */` get turned into `# this`. The conversion from lisp-like formatting to something else in flake.nix is a bit unfortunate, but I'd rather have a singular style for the entire code base to make things easier. --- flake.nix | 144 ++++++++++++++++++++++--------------------- hardware/laptop.nix | 24 ++++---- modules/desktop.nix | 2 +- modules/packages.nix | 2 +- modules/shell.nix | 6 +- modules/system.nix | 3 +- packages/hycov.nix | 11 ++-- tests/hyprland.nix | 3 +- tests/neovim.nix | 3 +- 9 files changed, 103 insertions(+), 95 deletions(-) diff --git a/flake.nix b/flake.nix index 69094d3d..a5fd6aa5 100644 --- a/flake.nix +++ b/flake.nix @@ -21,81 +21,87 @@ }; }; - outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs: let - inherit (nixpkgs.lib) nixosSystem; - inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage; - inherit (builtins) attrValues attrNames listToAttrs map replaceStrings readDir; + outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs: + let + inherit (nixpkgs.lib) nixosSystem; + inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage; + inherit (builtins) attrValues attrNames listToAttrs map replaceStrings readDir; - checkArgs = { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - inherit self; - }; - - flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" ]; - flakeDirectories = [ "overlays" "modules" "home" "packages" ]; - packageDirectory = "packages"; - in { - formatter.x86_64-linux = nixpkgs-fmt; - - nixosConfigurations = { - nixos = nixosSystem { - system = "x86_64-linux"; - specialArgs = attrs // { nix-config = self; }; - modules = [ - ./hardware/laptop.nix - { - environment.pathsToLink = [ - "/share/backgrounds" - "/share/eww" - "/share/thumbnailers" - "/share/fonts" - ]; - - nixpkgs.overlays = attrValues self.overlays; - imports = attrValues self.nixosModules; - home-manager.sharedModules = attrValues self.homeManagerModules; - environment.systemPackages = attrValues self.packages.x86_64-linux; - - modules = { - hardware = { - disableLaptopKeyboard = true; - lidIgnore = true; - powerIgnore = true; - }; - - networking = { - mullvad = true; - }; - - desktop = { - japanese = true; - bloat = true; - wine = true; - }; - }; - } - ]; + checkArgs = { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + inherit self; }; - }; - checks.x86_64-linux = { - hyprland = import ./tests/hyprland.nix checkArgs; - neovim = import ./tests/neovim.nix checkArgs; - }; - } // + flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" ]; + flakeDirectories = [ "overlays" "modules" "home" "packages" ]; + packageDirectory = "packages"; + in + { + formatter.x86_64-linux = nixpkgs-fmt; + + nixosConfigurations = { + nixos = nixosSystem { + system = "x86_64-linux"; + specialArgs = attrs // { nix-config = self; }; + modules = [ + ./hardware/laptop.nix + { + environment.pathsToLink = [ + "/share/backgrounds" + "/share/eww" + "/share/thumbnailers" + "/share/fonts" + ]; + + nixpkgs.overlays = attrValues self.overlays; + imports = attrValues self.nixosModules; + home-manager.sharedModules = attrValues self.homeManagerModules; + environment.systemPackages = attrValues self.packages.x86_64-linux; + + modules = { + hardware = { + disableLaptopKeyboard = true; + lidIgnore = true; + powerIgnore = true; + }; + + networking = { + mullvad = true; + }; + + desktop = { + japanese = true; + bloat = true; + wine = true; + }; + }; + } + ]; + }; + }; + + checks.x86_64-linux = { + hyprland = import ./tests/hyprland.nix checkArgs; + neovim = import ./tests/neovim.nix checkArgs; + }; + } // (listToAttrs (map (attributeName: { name = attributeName; - value = let - directory = replaceStrings flakeOutputs flakeDirectories attributeName; - attributeValue = (listToAttrs - (map - (file: { - name = replaceStrings [ ".nix" ] [ "" ] file; - value = if directory == packageDirectory then callPackage ./${directory}/${file} { } else import ./${directory}/${file}; }) - (attrNames (readDir ./${directory})))); - attributeSet = if directory == packageDirectory then { x86_64-linux = attributeValue; } else attributeValue; - in (attributeSet); }) + value = + let + directory = replaceStrings flakeOutputs flakeDirectories attributeName; + attributeValue = (listToAttrs + (map + (file: { + name = replaceStrings [ ".nix" ] [ "" ] file; + value = if directory == packageDirectory then callPackage ./${directory}/${file} { } else import ./${directory}/${file}; + }) + (attrNames (readDir ./${directory})))); + attributeSet = if directory == packageDirectory then { x86_64-linux = attributeValue; } else attributeValue; + in + (attributeSet); + }) (flakeOutputs))); } diff --git a/hardware/laptop.nix b/hardware/laptop.nix index cbc25b01..bf76c9a6 100644 --- a/hardware/laptop.nix +++ b/hardware/laptop.nix @@ -1,26 +1,26 @@ -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-label/nixos"; - fsType = "btrfs"; - }; + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "btrfs"; + }; boot.initrd.luks.devices."root".device = "/dev/disk/by-label/nixos-luks"; - fileSystems."/boot" = - { device = "/dev/disk/by-label/boot"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-label/boot"; + fsType = "vfat"; + }; swapDevices = [ ]; diff --git a/modules/desktop.nix b/modules/desktop.nix index 49c687c9..70d1314b 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -100,7 +100,7 @@ in ungoogled-chromium qbittorrent obs-studio - ; + ; })) (attrValues { diff --git a/modules/packages.nix b/modules/packages.nix index 0453ab20..4f23fb9a 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -19,7 +19,7 @@ killall trashy whois - + dig yt-dlp brightnessctl diff --git a/modules/shell.nix b/modules/shell.nix index 43b002d8..1ee3fcc8 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -47,7 +47,7 @@ in colorpanes sanctity cmatrix - ; + ; }) (attrValues { inherit (pkgs) @@ -55,7 +55,7 @@ in hexyl visidata zellij - ; + ; }) (attrValues { @@ -64,7 +64,7 @@ in unar rsync rclone - ; + ; }) (mkIf postgres (attrValues { diff --git a/modules/system.nix b/modules/system.nix index 3f7997e5..c9e77491 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -45,7 +45,8 @@ in config = { boot = { - tmp = if iHaveLotsOfRam + tmp = + if iHaveLotsOfRam then { useTmpfs = true; } else { cleanOnBoot = true; }; diff --git a/packages/hycov.nix b/packages/hycov.nix index a8e743fd..20a0a802 100644 --- a/packages/hycov.nix +++ b/packages/hycov.nix @@ -1,9 +1,8 @@ -{ - lib, - stdenv, - hyprland, - fetchFromGitHub, - fetchpatch, +{ lib +, stdenv +, hyprland +, fetchFromGitHub +, fetchpatch }: stdenv.mkDerivation (finalAttrs: { diff --git a/tests/hyprland.nix b/tests/hyprland.nix index b59764fb..ef79bb72 100644 --- a/tests/hyprland.nix +++ b/tests/hyprland.nix @@ -1,7 +1,8 @@ # TODO: Write test to ensure that Hyprland starts with basic config let inherit (builtins) attrValues; -in (import ./lib.nix) { +in +(import ./lib.nix) { name = "hyprland"; nodes.machine = { self, pkgs, ... }: { diff --git a/tests/neovim.nix b/tests/neovim.nix index 3663f882..ffd8ea60 100644 --- a/tests/neovim.nix +++ b/tests/neovim.nix @@ -1,7 +1,8 @@ # TODO: Ensure that neovim config works without errors on startup let inherit (builtins) attrValues; -in (import ./lib.nix) { +in +(import ./lib.nix) { name = "neovim"; nodes.machine = { self, pkgs, ... }: {