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
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)));
}

View File

@ -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 = [ ];

View File

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

View File

@ -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 {

View File

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

View File

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

View File

@ -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, ... }: {

View File

@ -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, ... }: {