treewide: add linters and apply pending suggestions (#426)

This commit is contained in:
Daniel Thwaites 2024-06-16 15:08:25 +01:00 committed by GitHub
parent 29044a0242
commit 80e8e1e2f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 97 additions and 69 deletions

42
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,42 @@
name: Lint
on: pull_request
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
extra-conf: |
extra-experimental-features = nix-command flakes
- name: Set up cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Install tools
run: |
flake='github:nixos/nixpkgs/e913ae340076bbb73d9f4d3d065c2bca7caafb16'
nix profile install "${flake}#statix"
nix profile install "${flake}#deadnix"
nix profile install "${flake}#jq"
- name: Checkout repository
uses: actions/checkout@v4
- name: Run statix
run: |
statix check --format json |\
jq --raw-output '.file as $file | .report[] | .severity as $severity | .diagnostics[] | "::warning file=\($file),line=\(.at.from.line),col=\(.at.from.column)::\(.message)"'
- name: Run deadnix
run: |
deadnix --no-lambda-arg --output-format json |\
jq --raw-output '.file as $file | .results[] | "::warning file=\($file),line=\(.line),col=\(.column)::\(.message)"'

View file

@ -43,7 +43,7 @@ in
white = base07;
red = bright-red;
green = bright-green;
yellow = yellow;
inherit yellow;
blue = bright-blue;
magenta = bright-magenta;
cyan = bright-cyan;

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
{
options.stylix.targets.bat.enable =

View file

@ -1,9 +1,9 @@
{pkgs, config, lib, ... }:
{ config, lib, ... }:
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;
let
bemenuOpacity = lib.toHexString ((((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100));
bemenuOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100);
in {
options.stylix.targets.bemenu = {
enable = config.lib.stylix.mkEnableTarget "bemenu" true;

View file

@ -3,7 +3,7 @@
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;
let
dunstOpacity = lib.toHexString ((((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100));
dunstOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100);
in {
options.stylix.targets.dunst.enable =
config.lib.stylix.mkEnableTarget "Dunst" true;

View file

@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
{
options.stylix.targets.fish.enable =
config.lib.stylix.mkEnableTarget "Fish" true;
config = lib.mkIf (config.stylix.enable && config.stylix.targets.fish.enable) {
programs.fish.interactiveShellInit = import ./prompt.nix { inherit pkgs config; };
programs.fish.interactiveShellInit = import ./prompt.nix config;
};
}

View file

@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
{
options.stylix.targets.fish.enable =
config.lib.stylix.mkEnableTarget "Fish" true;
config = lib.mkIf (config.stylix.enable && config.stylix.targets.fish.enable) {
programs.fish.promptInit = import ./prompt.nix { inherit pkgs config; };
programs.fish.promptInit = import ./prompt.nix config;
};
}

View file

@ -1,4 +1,4 @@
{ pkgs, config }:
config:
let
theme = config.lib.stylix.colors {

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
let
cfg = config.stylix.targets.foot;

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
with config.lib.stylix.colors;

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
let
mkFzfKeyValue = lib.generators.mkKeyValueDefault { } ":";

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
let
style = config.lib.stylix.colors {

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }@args:
{ pkgs, config, lib, ... }:
let
inherit (config.stylix.fonts) sansSerif serif monospace;
@ -39,7 +39,9 @@ in {
xdg.dataFile."themes/Stylix/gnome-shell/gnome-shell.css" = {
source =
let theme = import ./theme.nix args;
let theme = pkgs.callPackage ./theme.nix {
inherit (config.lib.stylix) colors templates;
};
in "${theme}/share/gnome-shell/gnome-shell.css";
onChange = ''
if [[ -x "$(command -v gnome-extensions)" ]]; then

View file

@ -1,7 +1,9 @@
{ lib, pkgs, config, ... }@args:
{ lib, pkgs, config, ... }:
let
theme = import ./theme.nix args;
theme = pkgs.callPackage ./theme.nix {
inherit (config.lib.stylix) colors templates;
};
in {
options.stylix.targets.gnome.enable =

View file

@ -1,21 +1,21 @@
{ config, pkgs, ... }:
{ stdenv, sass, glib, colors, templates }:
let
colors = config.lib.stylix.colors {
colorsScss = colors {
template = ./colors.mustache;
extension = "scss";
};
in pkgs.stdenv.mkDerivation {
name = "${config.lib.stylix.colors.slug}-gnome-shell-theme";
src = config.lib.stylix.templates.gnome-shell;
in stdenv.mkDerivation {
name = "${colors.slug}-gnome-shell-theme";
src = templates.gnome-shell;
patches = [ ./shell_colors.patch ];
postPatch = ''
rm data/theme/gnome-shell-sass/{_colors.scss,_default-colors.scss,_palette.scss}
cp ${colors} data/theme/gnome-shell-sass/_colors.scss
cp ${colorsScss} data/theme/gnome-shell-sass/_colors.scss
'';
nativeBuildInputs = with pkgs; [ sass glib.dev ];
nativeBuildInputs = [ sass glib.dev ];
buildPhase = ''
sass data/theme/gnome-shell-light.scss \
>data/theme/gnome-shell-light.css

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
{
options.stylix.targets.gtk.enable =

View file

@ -9,7 +9,7 @@ let
unfocused = base03;
fonts = let
fonts = config.stylix.fonts;
inherit (config.stylix) fonts;
in {
names = [ fonts.sansSerif.name ];
size = fonts.sizes.desktop * 1.0;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
cfg = config.stylix.targets.kitty;

View file

@ -1,9 +1,9 @@
{pkgs, config, lib, options, ... }:
{ config, lib, options, ... }:
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;
let
makoOpacity = lib.toHexString ((((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100));
makoOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100);
in {
options.stylix.targets.mako.enable =
config.lib.stylix.mkEnableTarget "Mako" true;

View file

@ -1,9 +1,8 @@
{ config, lib, ... }:
let
fonts = config.stylix.fonts;
colors = config.lib.stylix.colors;
opacity = config.stylix.opacity;
inherit (config.stylix) fonts opacity;
inherit (config.lib.stylix) colors;
in {
options.stylix.targets.mangohud.enable = config.lib.stylix.mkEnableTarget "mangohud" true;

View file

@ -9,7 +9,7 @@ with config.lib.stylix.colors;
config.nixpkgs.overlays = lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable) [(self: super: {
nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: {
src = pkgs.applyPatches {
src = oldAttrs.src;
inherit (oldAttrs) src;
prePatch = ''
substituteInPlace logo/nix-snowflake-white.svg --replace-fail '#ffffff' '#${base05}'

View file

@ -17,25 +17,10 @@
lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) {
programs.nixvim = {
colorschemes.base16 = {
colorscheme = let
colors = config.lib.stylix.colors.withHashtag;
in {
base00 = colors.base00;
base01 = colors.base01;
base02 = colors.base02;
base03 = colors.base03;
base04 = colors.base04;
base05 = colors.base05;
base06 = colors.base06;
base07 = colors.base07;
base08 = colors.base08;
base09 = colors.base09;
base0A = colors.base0A;
base0B = colors.base0B;
base0C = colors.base0C;
base0D = colors.base0D;
base0E = colors.base0E;
base0F = colors.base0F;
colorscheme = {
inherit (config.lib.stylix.colors.withHashtag)
base00 base01 base02 base03 base04 base05 base06 base07
base08 base09 base0A base0B base0C base0D base0E base0F;
};
enable = true;

View file

@ -199,7 +199,7 @@ in {
};
indicator = {
error = error;
inherit error;
start = secondary-info;
stop = info;
};

View file

@ -1,8 +1,8 @@
{ config, lib, ... }:
let
colors = config.lib.stylix.colors;
fonts = config.stylix.fonts;
inherit (config.lib.stylix) colors;
inherit (config.stylix) fonts;
in {
options.stylix.targets.sxiv.enable =
config.lib.stylix.mkEnableTarget "Sxiv" true;

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
let
theme = config.lib.stylix.colors {

View file

@ -10,7 +10,7 @@ with config.lib.stylix.colors.withHashtag; {
config = lib.mkIf (config.stylix.enable && config.stylix.targets.tofi.enable) {
programs.tofi.settings =
let
opacity = lib.toHexString ((((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100));
opacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100);
background = base00 + opacity;
foreground = base05;
darkForeground = base04 + opacity;

View file

@ -18,7 +18,7 @@ let
};
vimOptions = let
fonts = config.stylix.fonts;
inherit (config.stylix) fonts;
in {
plugins = [ themePlugin ];
extraConfig = with config.lib.stylix.colors.withHashtag; ''

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }@args:
{ config, lib, ... }:
{
# Disabled by default due to https://github.com/danth/stylix/issues/180

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
{
options.stylix.targets.zellij.enable =

View file

@ -9,6 +9,6 @@ for:
if kind == "directory"
then let
file = "${../modules}/${path}/${for}.nix";
in (if builtins.pathExists file then [ file ] else [ ])
in if builtins.pathExists file then [ file ] else [ ]
else [ ])
(builtins.readDir ../modules))

View file

@ -1,4 +1,4 @@
{ pkgs, lib, ... } @ args:
{ pkgs, lib, ... }:
{
options.stylix.cursor = {

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... } @ args:
{ pkgs, config, lib, ... }:
let
cfg = config.stylix.fonts;

View file

@ -8,9 +8,7 @@ in {
config = lib.mkIf (config.stylix.enable && pkgs.stdenv.hostPlatform.isLinux) {
home.pointerCursor = {
name = cfg.name;
package = cfg.package;
size = cfg.size;
inherit (cfg) name package size;
x11.enable = true;
gtk.enable = true;
};

View file

@ -1,6 +1,6 @@
inputs:
{ palette-generator, base16 }:
{ config, lib, ... }:
{ lib, ... }:
let
autoload = import ../autoload.nix { inherit lib; } "hm";

View file

@ -5,7 +5,7 @@ let
in {
imports = [ ../fonts.nix ];
config.fonts = lib.mkIf config.stylix.enable {
packages = cfg.packages;
inherit (cfg) packages;
fontconfig.defaultFonts = {
monospace = [ cfg.monospace.name ];