Skip to content

Commit

Permalink
treewide: add and apply nixfmt pre-commit hook
Browse files Browse the repository at this point in the history
Link: danth#519
  • Loading branch information
trueNAHO committed Jan 4, 2025
1 parent 807c818 commit ad64260
Show file tree
Hide file tree
Showing 108 changed files with 3,125 additions and 2,353 deletions.
15 changes: 9 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url =
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) { src = ./.; }).defaultNix
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).defaultNix
42 changes: 27 additions & 15 deletions docs/default.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
{ pkgs, lib, inputs, ... }:
{
pkgs,
lib,
inputs,
...
}:

let
makeOptionsDoc = configuration: pkgs.nixosOptionsDoc {
inherit (configuration) options;
makeOptionsDoc =
configuration:
pkgs.nixosOptionsDoc {
inherit (configuration) options;

# Filter out any options not beginning with `stylix`
transformOptions = option: option // {
visible = option.visible &&
builtins.elemAt option.loc 0 == "stylix";
# Filter out any options not beginning with `stylix`
transformOptions =
option:
option
// {
visible = option.visible && builtins.elemAt option.loc 0 == "stylix";
};
};
};

nixos = makeOptionsDoc
(lib.nixosSystem {
nixos = makeOptionsDoc (
lib.nixosSystem {
inherit (pkgs) system;
modules = [
inputs.home-manager.nixosModules.home-manager
inputs.self.nixosModules.stylix
./settings.nix
];
});
}
);

homeManager = makeOptionsDoc
(inputs.home-manager.lib.homeManagerConfiguration {
homeManager = makeOptionsDoc (
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
inputs.self.homeManagerModules.stylix
Expand All @@ -35,9 +45,11 @@ let
};
}
];
});
}
);

in pkgs.stdenvNoCC.mkDerivation {
in
pkgs.stdenvNoCC.mkDerivation {
name = "stylix-book";
src = ./.;

Expand Down
88 changes: 54 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,30 @@
};

outputs =
{ nixpkgs, base16, self, ... }@inputs:
{
nixpkgs,
base16,
self,
...
}@inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system: let
system:
let
inherit (nixpkgs) lib;
pkgs = nixpkgs.legacyPackages.${system};
in {
in
{
checks = lib.attrsets.unionOfDisjoint {
git-hooks = inputs.git-hooks.lib.${system}.run {
hooks = {
deadnix.enable = true;
hlint.enable = true;

nixfmt-rfc-style = {
enable = true;
settings.width = 80;
};

statix.enable = true;
stylish-haskell.enable = true;
typos.enable = true;
Expand All @@ -127,7 +140,8 @@
};
};

packages = let
packages =
let
universalPackages = {
docs = import ./docs { inherit pkgs inputs lib; };

Expand Down Expand Up @@ -159,41 +173,47 @@

# Testbeds are virtual machines based on NixOS, therefore they are
# only available for Linux systems.
testbedPackages = lib.optionalAttrs
(lib.hasSuffix "-linux" system)
(import ./stylix/testbed.nix { inherit pkgs inputs lib; });
testbedPackages = lib.optionalAttrs (lib.hasSuffix "-linux" system) (
import ./stylix/testbed.nix { inherit pkgs inputs lib; }
);
in
universalPackages // testbedPackages;
universalPackages // testbedPackages;
}
)
// {
nixosModules.stylix = { pkgs, ... }@args: {
imports = [
(import ./stylix/nixos inputs {
inherit (self.packages.${pkgs.system}) palette-generator;
base16 = base16.lib args;
homeManagerModule = self.homeManagerModules.stylix;
})
];
};
nixosModules.stylix =
{ pkgs, ... }@args:
{
imports = [
(import ./stylix/nixos inputs {
inherit (self.packages.${pkgs.system}) palette-generator;
base16 = base16.lib args;
homeManagerModule = self.homeManagerModules.stylix;
})
];
};

homeManagerModules.stylix = { pkgs, ... }@args: {
imports = [
(import ./stylix/hm inputs {
inherit (self.packages.${pkgs.system}) palette-generator;
base16 = base16.lib args;
})
];
};
homeManagerModules.stylix =
{ pkgs, ... }@args:
{
imports = [
(import ./stylix/hm inputs {
inherit (self.packages.${pkgs.system}) palette-generator;
base16 = base16.lib args;
})
];
};

darwinModules.stylix = { pkgs, ... }@args: {
imports = [
(import ./stylix/darwin inputs {
inherit (self.packages.${pkgs.system}) palette-generator;
base16 = base16.lib args;
homeManagerModule = self.homeManagerModules.stylix;
})
];
};
darwinModules.stylix =
{ pkgs, ... }@args:
{
imports = [
(import ./stylix/darwin inputs {
inherit (self.packages.${pkgs.system}) palette-generator;
base16 = base16.lib args;
homeManagerModule = self.homeManagerModules.stylix;
})
];
};
};
}
92 changes: 51 additions & 41 deletions modules/alacritty/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,58 @@ let
colors = config.lib.stylix.colors.withHashtag;
in
{
options.stylix.targets.alacritty.enable = config.lib.stylix.mkEnableTarget "Alacritty" true;
options.stylix.targets.alacritty.enable =
config.lib.stylix.mkEnableTarget "Alacritty" true;

config = lib.mkIf (config.stylix.enable && config.stylix.targets.alacritty.enable) {
programs.alacritty.settings = {
font = with config.stylix.fonts; {
normal = {
family = monospace.name;
style = "Regular";
config =
lib.mkIf (config.stylix.enable && config.stylix.targets.alacritty.enable)
{
programs.alacritty.settings = {
font = with config.stylix.fonts; {
normal = {
family = monospace.name;
style = "Regular";
};
size = sizes.terminal;
};
window.opacity = with config.stylix.opacity; terminal;
colors = with colors; {
primary = {
foreground = base05;
background = base00;
bright_foreground = base07;
};
selection = {
text = base05;
background = base02;
};
cursor = {
text = base00;
cursor = base05;
};
normal = {
black = base00;
white = base05;
inherit
red
green
yellow
blue
magenta
cyan
;
};
bright = {
black = base03;
white = base07;
red = bright-red;
green = bright-green;
inherit yellow;
blue = bright-blue;
magenta = bright-magenta;
cyan = bright-cyan;
};
};
};
size = sizes.terminal;
};
window.opacity = with config.stylix.opacity; terminal;
colors = with colors; {
primary = {
foreground = base05;
background = base00;
bright_foreground = base07;
};
selection = {
text = base05;
background = base02;
};
cursor = {
text = base00;
cursor = base05;
};
normal = {
black = base00;
white = base05;
inherit red green yellow blue magenta cyan;
};
bright = {
black = base03;
white = base07;
red = bright-red;
green = bright-green;
inherit yellow;
blue = bright-blue;
magenta = bright-magenta;
cyan = bright-cyan;
};
};
};
};
}
22 changes: 13 additions & 9 deletions modules/alacritty/testbed.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{ pkgs, ... }:

let package = pkgs.alacritty;
let
package = pkgs.alacritty;

in {
in
{
stylix.testbed.application = {
enable = true;
name = "Alacritty";
inherit package;
};

home-manager.sharedModules = [{
programs.alacritty = {
enable = true;
inherit package;
};
}];
}
home-manager.sharedModules = [
{
programs.alacritty = {
enable = true;
inherit package;
};
}
];
}
31 changes: 19 additions & 12 deletions modules/avizo/hm.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ config, lib, options, ... }:
{
config,
lib,
options,
...
}:

with config.lib.stylix.colors;
with config.stylix.fonts;
Expand All @@ -10,17 +15,19 @@ in
config.lib.stylix.mkEnableTarget "Avizo" true;

# Referenced https://github.com/stacyharper/base16-mako
config = lib.optionalAttrs (options.services ? avizo) (lib.mkIf (config.stylix.enable && config.stylix.targets.avizo.enable) {
services.avizo = {
config = lib.optionalAttrs (options.services ? avizo) (
lib.mkIf (config.stylix.enable && config.stylix.targets.avizo.enable) {
services.avizo = {
settings = {
default = {
background = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})";
border-color = "rgba(${base0D-rgb-r}, ${base0D-rgb-g}, ${base0D-rgb-b}, ${aviOpacity})";
bar-fg-color = "rgba(${base05-rgb-r}, ${base05-rgb-g}, ${base05-rgb-b}, ${aviOpacity})";
bar-bg-color = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})";
image-opacity = aviOpacity;
};
default = {
background = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})";
border-color = "rgba(${base0D-rgb-r}, ${base0D-rgb-g}, ${base0D-rgb-b}, ${aviOpacity})";
bar-fg-color = "rgba(${base05-rgb-r}, ${base05-rgb-g}, ${base05-rgb-b}, ${aviOpacity})";
bar-bg-color = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})";
image-opacity = aviOpacity;
};
};
};
});
};
}
);
}
5 changes: 2 additions & 3 deletions modules/bat/hm.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{ config, lib, ... }:

{
options.stylix.targets.bat.enable =
config.lib.stylix.mkEnableTarget "Bat" true;
options.stylix.targets.bat.enable = config.lib.stylix.mkEnableTarget "Bat" true;

config = lib.mkIf (config.stylix.enable && config.stylix.targets.bat.enable) {
programs.bat = {
# This theme is reused for yazi. Changes to the template
# This theme is reused for yazi. Changes to the template
# will need to be applied to modules/yazi/hm.nix
themes."base16-stylix".src = config.lib.stylix.colors {
template = ./base16-stylix.mustache;
Expand Down
Loading

0 comments on commit ad64260

Please sign in to comment.