Skip to content

Commit

Permalink
chore: Format with nixpkgs-fmt
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donovanglover committed Apr 5, 2024
1 parent 01acf81 commit 22e31ff
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 88 deletions.
130 changes: 68 additions & 62 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
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;
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"
];
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;
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;
};
modules = {
hardware = {
disableLaptopKeyboard = true;
lidIgnore = true;
powerIgnore = true;
};

networking = {
mullvad = true;
};
networking = {
mullvad = true;
};

desktop = {
japanese = true;
bloat = true;
wine = true;
desktop = {
japanese = true;
bloat = true;
wine = true;
};
};
};
}
];
}
];
};
};
};

checks.x86_64-linux = {
hyprland = import ./tests/hyprland.nix checkArgs;
neovim = import ./tests/neovim.nix checkArgs;
};
} //
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)));
}
24 changes: 12 additions & 12 deletions hardware/laptop.nix
Original file line number Diff line number Diff line change
@@ -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 = [ ];

Expand Down
2 changes: 1 addition & 1 deletion modules/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ in
ungoogled-chromium
qbittorrent
obs-studio
;
;
}))

(attrValues {
Expand Down
2 changes: 1 addition & 1 deletion modules/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
killall
trashy
whois

dig
yt-dlp
brightnessctl
Expand Down
6 changes: 3 additions & 3 deletions modules/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ in
colorpanes
sanctity
cmatrix
;
;
})
(attrValues {
inherit (pkgs)
gdu
hexyl
visidata
zellij
;
;
})

(attrValues {
Expand All @@ -64,7 +64,7 @@ in
unar
rsync
rclone
;
;
})

(mkIf postgres (attrValues {
Expand Down
3 changes: 2 additions & 1 deletion modules/system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ in

config = {
boot = {
tmp = if iHaveLotsOfRam
tmp =
if iHaveLotsOfRam
then { useTmpfs = true; }
else { cleanOnBoot = true; };

Expand Down
11 changes: 5 additions & 6 deletions packages/hycov.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
lib,
stdenv,
hyprland,
fetchFromGitHub,
fetchpatch,
{ lib
, stdenv
, hyprland
, fetchFromGitHub
, fetchpatch
}:

stdenv.mkDerivation (finalAttrs: {
Expand Down
3 changes: 2 additions & 1 deletion tests/hyprland.nix
Original file line number Diff line number Diff line change
@@ -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, ... }: {
Expand Down
3 changes: 2 additions & 1 deletion tests/neovim.nix
Original file line number Diff line number Diff line change
@@ -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, ... }: {
Expand Down

0 comments on commit 22e31ff

Please sign in to comment.