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.
This commit is contained in:
Donovan Glover 2024-04-05 11:26:22 -04:00
parent 01acf8197d
commit 22e31ff60b
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
9 changed files with 103 additions and 95 deletions

144
flake.nix
View File

@ -21,81 +21,87 @@
}; };
}; };
outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs: let outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs:
inherit (nixpkgs.lib) nixosSystem; let
inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage; inherit (nixpkgs.lib) nixosSystem;
inherit (builtins) attrValues attrNames listToAttrs map replaceStrings readDir; inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage;
inherit (builtins) attrValues attrNames listToAttrs map replaceStrings readDir;
checkArgs = { checkArgs = {
pkgs = nixpkgs.legacyPackages.x86_64-linux; pkgs = nixpkgs.legacyPackages.x86_64-linux;
inherit self; 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;
};
};
}
];
}; };
};
checks.x86_64-linux = { flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" ];
hyprland = import ./tests/hyprland.nix checkArgs; flakeDirectories = [ "overlays" "modules" "home" "packages" ];
neovim = import ./tests/neovim.nix checkArgs; 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 (listToAttrs
(map (map
(attributeName: { (attributeName: {
name = attributeName; name = attributeName;
value = let value =
directory = replaceStrings flakeOutputs flakeDirectories attributeName; let
attributeValue = (listToAttrs directory = replaceStrings flakeOutputs flakeDirectories attributeName;
(map attributeValue = (listToAttrs
(file: { (map
name = replaceStrings [ ".nix" ] [ "" ] file; (file: {
value = if directory == packageDirectory then callPackage ./${directory}/${file} { } else import ./${directory}/${file}; }) name = replaceStrings [ ".nix" ] [ "" ] file;
(attrNames (readDir ./${directory})))); value = if directory == packageDirectory then callPackage ./${directory}/${file} { } else import ./${directory}/${file};
attributeSet = if directory == packageDirectory then { x86_64-linux = attributeValue; } else attributeValue; })
in (attributeSet); }) (attrNames (readDir ./${directory}))));
attributeSet = if directory == packageDirectory then { x86_64-linux = attributeValue; } else attributeValue;
in
(attributeSet);
})
(flakeOutputs))); (flakeOutputs)));
} }

View File

@ -1,26 +1,26 @@
{ config, lib, pkgs, modulesPath, ... }: { config, lib, modulesPath, ... }:
{ {
imports = imports = [
[ (modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
fsType = "btrfs"; fsType = "btrfs";
}; };
boot.initrd.luks.devices."root".device = "/dev/disk/by-label/nixos-luks"; boot.initrd.luks.devices."root".device = "/dev/disk/by-label/nixos-luks";
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-label/boot"; device = "/dev/disk/by-label/boot";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ ]; swapDevices = [ ];

View File

@ -100,7 +100,7 @@ in
ungoogled-chromium ungoogled-chromium
qbittorrent qbittorrent
obs-studio obs-studio
; ;
})) }))
(attrValues { (attrValues {

View File

@ -19,7 +19,7 @@
killall killall
trashy trashy
whois whois
dig dig
yt-dlp yt-dlp
brightnessctl brightnessctl

View File

@ -47,7 +47,7 @@ in
colorpanes colorpanes
sanctity sanctity
cmatrix cmatrix
; ;
}) })
(attrValues { (attrValues {
inherit (pkgs) inherit (pkgs)
@ -55,7 +55,7 @@ in
hexyl hexyl
visidata visidata
zellij zellij
; ;
}) })
(attrValues { (attrValues {
@ -64,7 +64,7 @@ in
unar unar
rsync rsync
rclone rclone
; ;
}) })
(mkIf postgres (attrValues { (mkIf postgres (attrValues {

View File

@ -45,7 +45,8 @@ in
config = { config = {
boot = { boot = {
tmp = if iHaveLotsOfRam tmp =
if iHaveLotsOfRam
then { useTmpfs = true; } then { useTmpfs = true; }
else { cleanOnBoot = true; }; else { cleanOnBoot = true; };

View File

@ -1,9 +1,8 @@
{ { lib
lib, , stdenv
stdenv, , hyprland
hyprland, , fetchFromGitHub
fetchFromGitHub, , fetchpatch
fetchpatch,
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {

View File

@ -1,7 +1,8 @@
# TODO: Write test to ensure that Hyprland starts with basic config # TODO: Write test to ensure that Hyprland starts with basic config
let let
inherit (builtins) attrValues; inherit (builtins) attrValues;
in (import ./lib.nix) { in
(import ./lib.nix) {
name = "hyprland"; name = "hyprland";
nodes.machine = { self, pkgs, ... }: { nodes.machine = { self, pkgs, ... }: {

View File

@ -1,7 +1,8 @@
# TODO: Ensure that neovim config works without errors on startup # TODO: Ensure that neovim config works without errors on startup
let let
inherit (builtins) attrValues; inherit (builtins) attrValues;
in (import ./lib.nix) { in
(import ./lib.nix) {
name = "neovim"; name = "neovim";
nodes.machine = { self, pkgs, ... }: { nodes.machine = { self, pkgs, ... }: {