From 703f49aaca9030b066bb60310d19d7cadfb4b376 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:15:29 +0200 Subject: [PATCH 01/18] treewide: add developer shell Link: https://github.com/danth/stylix/pull/519 --- docs/src/SUMMARY.md | 1 + docs/src/development_environment.md | 7 +++++++ flake.nix | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 docs/src/development_environment.md diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index cf475f13b..6fa96b6c5 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -14,6 +14,7 @@ # Contributing - [Commit Convention](commit_convention.md) +- [Development Environment](development_environment.md) - [Adding modules](modules.md) - [Testbeds](testbeds.md) - [Style guide](styling.md) diff --git a/docs/src/development_environment.md b/docs/src/development_environment.md new file mode 100644 index 000000000..163671997 --- /dev/null +++ b/docs/src/development_environment.md @@ -0,0 +1,7 @@ +# Development Environment + +To enter the developer shell, run: + +```console +nix develop +``` diff --git a/flake.nix b/flake.nix index 1b5cf882b..1dd375b07 100644 --- a/flake.nix +++ b/flake.nix @@ -86,6 +86,10 @@ inherit (nixpkgs) lib; pkgs = nixpkgs.legacyPackages.${system}; in { + devShells.default = pkgs.mkShell { + packages = [ inputs.home-manager.packages.${system}.default ]; + }; + packages = let universalPackages = { docs = import ./docs { inherit pkgs inputs lib; }; From 6ef37ca6aaf82e59394d0a93acdc932af1739d58 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:16:56 +0200 Subject: [PATCH 02/18] treewide: leverage direnv to automatically enter developer shell Leverage direnv [1] to automatically enter the developer shell upon entering the project directory after running 'direnv allow'. [1]: https://direnv.net Link: https://github.com/danth/stylix/pull/519 --- .envrc | 1 + .gitignore | 1 + docs/src/development_environment.md | 7 +++++++ 3 files changed, 9 insertions(+) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 750baebf4..5b3a622ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/.direnv/ result result-* diff --git a/docs/src/development_environment.md b/docs/src/development_environment.md index 163671997..b90637db1 100644 --- a/docs/src/development_environment.md +++ b/docs/src/development_environment.md @@ -5,3 +5,10 @@ To enter the developer shell, run: ```console nix develop ``` + +To automatically enter the developer shell upon entering the project directory +with [`direnv`](https://direnv.net), run: + +```console +direnv allow +``` From 3c54cb3384116d430e2a83c5d3d3f0dd59eb9ff2 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:05:40 +0200 Subject: [PATCH 03/18] treewide: ignore unused arguments detected by deadnix Link: https://github.com/danth/stylix/pull/519 --- modules/gnome/nixos.nix | 2 +- modules/nixos-icons/nixos.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gnome/nixos.nix b/modules/gnome/nixos.nix index c10bf8a1a..7d0ce3d46 100644 --- a/modules/gnome/nixos.nix +++ b/modules/gnome/nixos.nix @@ -22,7 +22,7 @@ in { # which will then download the pack regardless of its exclusion below. environment.gnome.excludePackages = [ pkgs.gnome-backgrounds ]; - nixpkgs.overlays = [(self: super: { + nixpkgs.overlays = [(_: super: { gnome-shell = super.gnome-shell.overrideAttrs (oldAttrs: { # Themes are usually applied via an extension, but extensions are # not available on the login screen. The only way to change the diff --git a/modules/nixos-icons/nixos.nix b/modules/nixos-icons/nixos.nix index 75074d098..90f037c91 100644 --- a/modules/nixos-icons/nixos.nix +++ b/modules/nixos-icons/nixos.nix @@ -6,7 +6,7 @@ with config.lib.stylix.colors; options.stylix.targets.nixos-icons.enable = config.lib.stylix.mkEnableTarget "the NixOS logo" true; - config.nixpkgs.overlays = lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable) [(self: super: { + config.nixpkgs.overlays = lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable) [(_: super: { nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: { src = pkgs.applyPatches { inherit (oldAttrs) src; From 6085560893ae3620acf8d799dda138b207e6f5ed Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:56:50 +0200 Subject: [PATCH 04/18] stylix: add deadnix and statix pre-commit hooks Add the deadnix and statix pre-commit hooks used in the Lint GitHub workflow. Link: https://github.com/danth/stylix/pull/519 --- flake.lock | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 19 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/flake.lock b/flake.lock index 8c700b843..7486ec27a 100644 --- a/flake.lock +++ b/flake.lock @@ -118,6 +118,55 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "flake-compat" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731363552, + "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "gnome-shell": { "flake": false, "locked": { @@ -179,6 +228,7 @@ "base16-vim": "base16-vim", "flake-compat": "flake-compat", "flake-utils": "flake-utils", + "git-hooks": "git-hooks", "gnome-shell": "gnome-shell", "home-manager": "home-manager", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 1dd375b07..bdd89a8de 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,16 @@ url = "github:numtide/flake-utils"; }; + git-hooks = { + inputs = { + flake-compat.follows = "flake-compat"; + nixpkgs-stable.follows = "git-hooks/nixpkgs"; + nixpkgs.follows = "nixpkgs"; + }; + + url = "github:cachix/git-hooks.nix"; + }; + gnome-shell = { flake = false; @@ -86,6 +96,15 @@ inherit (nixpkgs) lib; pkgs = nixpkgs.legacyPackages.${system}; in { + checks.git-hooks = inputs.git-hooks.lib.${system}.run { + hooks = { + deadnix.enable = true; + statix.enable = true; + }; + + src = ./.; + }; + devShells.default = pkgs.mkShell { packages = [ inputs.home-manager.packages.${system}.default ]; }; From 0d0af5f4426104ed82b17d41f8763fcf84b2c0ea Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Tue, 31 Dec 2024 00:27:55 +0100 Subject: [PATCH 05/18] ci: consolidate Build and Lint workflows into single Check workflow Consolidate the separate Build and Lint workflows into a unified Check workflow, as linting is now integrated into the build process. Link: https://github.com/danth/stylix/pull/519 --- .github/workflows/{build.yml => check.yml} | 14 ++++---- .github/workflows/lint.yml | 42 ---------------------- 2 files changed, 7 insertions(+), 49 deletions(-) rename .github/workflows/{build.yml => check.yml} (79%) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/build.yml b/.github/workflows/check.yml similarity index 79% rename from .github/workflows/build.yml rename to .github/workflows/check.yml index f26fb3f5e..2162befd2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,4 @@ -name: Build +name: Check on: push: @@ -34,17 +34,17 @@ jobs: outputs: packages: ${{ steps.list-packages.outputs.packages }} - build: + check: needs: evaluate strategy: fail-fast: false matrix: - build: ${{ fromJSON(needs.evaluate.outputs.packages) }} + check: ${{ fromJSON(needs.evaluate.outputs.packages) }} - name: ${{ matrix.build.key }} on ${{ matrix.build.arch }} + name: ${{ matrix.check.key }} on ${{ matrix.check.arch }} - runs-on: ${{ matrix.build.os }} + runs-on: ${{ matrix.check.os }} steps: - name: Install Nix @@ -57,5 +57,5 @@ jobs: - name: Set up cache uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build ${{ matrix.build.key }} - run: nix -L build github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.build.type }}.${{ matrix.build.arch }}.${{ matrix.build.key }} --no-update-lock-file + - name: Check ${{ matrix.check.key }} + run: nix -L check github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.check.type }}.${{ matrix.check.arch }}.${{ matrix.check.key }} --no-update-lock-file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 1a965610b..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,42 +0,0 @@ -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)"' From b3230ef39814b1c3809ffbad20f6361c8b737731 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:33:52 +0200 Subject: [PATCH 06/18] stylix: integrate pre-commit hooks into developer shell Link: https://github.com/danth/stylix/pull/519 --- .gitignore | 1 + flake.nix | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5b3a622ec..0e15abe87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.direnv/ +/.pre-commit-config.yaml result result-* diff --git a/flake.nix b/flake.nix index bdd89a8de..2ae679cbf 100644 --- a/flake.nix +++ b/flake.nix @@ -106,7 +106,12 @@ }; devShells.default = pkgs.mkShell { - packages = [ inputs.home-manager.packages.${system}.default ]; + inherit (self.checks.${system}.git-hooks) shellHook; + + packages = [ + inputs.home-manager.packages.${system}.default + self.checks.${system}.git-hooks.enabledPackages + ]; }; packages = let From e56d332ca367bd021d3c584ac9130064916cd0c7 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Mon, 30 Dec 2024 19:22:07 +0100 Subject: [PATCH 07/18] stylix: add packages to checks output Link: https://github.com/danth/stylix/pull/519 --- flake.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 2ae679cbf..bfbff8009 100644 --- a/flake.nix +++ b/flake.nix @@ -96,14 +96,16 @@ inherit (nixpkgs) lib; pkgs = nixpkgs.legacyPackages.${system}; in { - checks.git-hooks = inputs.git-hooks.lib.${system}.run { - hooks = { - deadnix.enable = true; - statix.enable = true; - }; + checks = lib.attrsets.unionOfDisjoint { + git-hooks = inputs.git-hooks.lib.${system}.run { + hooks = { + deadnix.enable = true; + statix.enable = true; + }; - src = ./.; - }; + src = ./.; + }; + } self.packages.${system}; devShells.default = pkgs.mkShell { inherit (self.checks.${system}.git-hooks) shellHook; From a0838923e45f63b2b46a132eaa02c45e03e8818a Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:23:25 +0100 Subject: [PATCH 08/18] stylix: add nix-flake-check package Add the nix-flake-check package, which is a parallelized alternative to 'nix flake check', as it is not yet natively parallel: > In the near future, we will make more Nix subcommands multi-threaded, > such as 'nix flake check'. > > -- Eelco Dolstra, https://determinate.systems/posts/parallel-nix-eval On a 16-threaded machine, 'nix run .#nix-flake-check' runs three times faster (74s vs. 243s) than 'nix flake check'. Link: https://github.com/danth/stylix/pull/519 --- flake.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/flake.nix b/flake.nix index bfbff8009..60aab63c4 100644 --- a/flake.nix +++ b/flake.nix @@ -119,6 +119,30 @@ packages = let universalPackages = { docs = import ./docs { inherit pkgs inputs lib; }; + + nix-flake-check = pkgs.writeShellApplication { + meta.description = "A parallelized alternative to 'nix flake check'"; + name = "nix-flake-check"; + + runtimeInputs = with pkgs; [ + nix + parallel + ]; + + text = '' + nix flake show --json --no-update-lock-file | + jq --raw-output ' + ((.checks."${system}" // {}) | keys) as $checks | + ((.packages."${system}" // {}) | keys) as $packages | + (($checks - $packages)[] | "checks.${system}.\(.)"), + ($packages[] | "packages.${system}.\(.)") + ' | + parallel --halt now,fail=1 ' + nix build --no-update-lock-file --verbose .#{} + ' + ''; + }; + palette-generator = pkgs.callPackage ./palette-generator { }; }; From 1aa931f6f1eb85b4f8358e7ed3706ed82d3048ca Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:42:29 +0200 Subject: [PATCH 09/18] ci: lock workflow dependencies to increase reproducibility Link: https://github.com/danth/stylix/pull/519 --- .github/workflows/check.yml | 12 ++++++------ .github/workflows/docs.yml | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2162befd2..4a67331ee 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -13,23 +13,23 @@ permissions: jobs: evaluate: name: List packages - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main + uses: DeterminateSystems/nix-installer-action@v16 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 + uses: DeterminateSystems/magic-nix-cache-action@v8 - name: List packages id: list-packages run: | - nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-latest" else "macos-latest" end), key: .key})) | flatten) | flatten | "packages=\(.)"' >> $GITHUB_OUTPUT + nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-22.04" else "macos-14" end), key: .key})) | flatten) | flatten | "packages=\(.)"' >> $GITHUB_OUTPUT outputs: packages: ${{ steps.list-packages.outputs.packages }} @@ -48,14 +48,14 @@ jobs: steps: - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main + uses: DeterminateSystems/nix-installer-action@v16 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 + uses: DeterminateSystems/magic-nix-cache-action@v8 - name: Check ${{ matrix.check.key }} run: nix -L check github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.check.type }}.${{ matrix.check.arch }}.${{ matrix.check.key }} --no-update-lock-file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7f4971158..f5e6a9e29 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,18 +12,18 @@ jobs: permissions: contents: read - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main + uses: DeterminateSystems/nix-installer-action@v16 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 + uses: DeterminateSystems/magic-nix-cache-action@v8 - name: Build docs run: nix -L build github:${{ github.repository }}/${{ github.sha }}#docs @@ -49,7 +49,7 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Deploy docs to GitHub Pages From fe72c2306f517a865c23e9fc92fc72cc408c1ab7 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Sun, 29 Dec 2024 18:37:33 +0100 Subject: [PATCH 10/18] ci: update Ubuntu runner to ubuntu-24.04 Link: https://github.com/actions/runner-images/issues/10636 Link: https://github.com/danth/stylix/pull/519 --- .github/workflows/check.yml | 4 ++-- .github/workflows/docs.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4a67331ee..ca11210c9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -13,7 +13,7 @@ permissions: jobs: evaluate: name: List packages - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Install Nix @@ -29,7 +29,7 @@ jobs: - name: List packages id: list-packages run: | - nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-22.04" else "macos-14" end), key: .key})) | flatten) | flatten | "packages=\(.)"' >> $GITHUB_OUTPUT + nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-24.04" else "macos-14" end), key: .key})) | flatten) | flatten | "packages=\(.)"' >> $GITHUB_OUTPUT outputs: packages: ${{ steps.list-packages.outputs.packages }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f5e6a9e29..c9dc54adf 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,7 +12,7 @@ jobs: permissions: contents: read - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Install Nix @@ -49,7 +49,7 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Deploy docs to GitHub Pages From 2b85a562355c80e1ef2f9070a3a44befdd7c9764 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:14:01 +0200 Subject: [PATCH 11/18] ci: simplify workflows Link: https://github.com/danth/stylix/pull/519 --- .github/workflows/backport.yml | 13 +++----- .github/workflows/check.yml | 53 +++++++++---------------------- .github/workflows/docs.yml | 57 +++++++++++----------------------- 3 files changed, 37 insertions(+), 86 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index d7fa314ae..6a451ccb8 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -10,7 +10,6 @@ permissions: {} jobs: backport: - name: Backport runs-on: ubuntu-latest if: > @@ -23,23 +22,19 @@ jobs: steps: # Use a GitHub App rather than the default token so that GitHub Actions # workflows may run on the created pull request. - - name: Create GitHub access token - uses: actions/create-github-app-token@v1 + - uses: actions/create-github-app-token@v1 id: app-token with: app-id: ${{ vars.BACKPORT_APP_ID }} private-key: ${{ secrets.BACKPORT_PRIVATE_KEY }} - - name: Checkout original pull request - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} token: ${{ steps.app-token.outputs.token }} - - name: Create backport pull request - uses: korthout/backport-action@v3 + - uses: korthout/backport-action@v3 with: github_token: ${{ steps.app-token.outputs.token }} pull_title: "[${target_branch}] ${pull_title}" - pull_description: |- - This is an automated backport of #${pull_number}. + pull_description: "This is an automated backport of #${pull_number}." diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ca11210c9..5ff87ea41 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -2,60 +2,37 @@ name: Check on: push: - branches: - - master - - release-** - pull_request: permissions: contents: read jobs: - evaluate: - name: List packages + get-derivations: runs-on: ubuntu-24.04 steps: - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v16 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: | - extra-experimental-features = nix-command flakes - - - name: Set up cache - uses: DeterminateSystems/magic-nix-cache-action@v8 - - - name: List packages - id: list-packages + - uses: DeterminateSystems/nix-installer-action@v16 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + + - id: get-derivations run: | - nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-24.04" else "macos-14" end), key: .key})) | flatten) | flatten | "packages=\(.)"' >> $GITHUB_OUTPUT + nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-24.04" else "macos-14" end), key: .key})) | flatten) | flatten | "derivations=\(.)"' >> $GITHUB_OUTPUT outputs: - packages: ${{ steps.list-packages.outputs.packages }} + derivations: ${{ steps.get-derivations.outputs.derivations }} check: - needs: evaluate + runs-on: ${{ matrix.check.os }} + + name: ${{ matrix.check.key }} on ${{ matrix.check.arch }} + needs: get-derivations strategy: fail-fast: false matrix: - check: ${{ fromJSON(needs.evaluate.outputs.packages) }} - - name: ${{ matrix.check.key }} on ${{ matrix.check.arch }} - - runs-on: ${{ matrix.check.os }} + check: ${{ fromJSON(needs.get-derivations.outputs.derivations) }} steps: - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v16 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: | - extra-experimental-features = nix-command flakes - - - name: Set up cache - uses: DeterminateSystems/magic-nix-cache-action@v8 - - - name: Check ${{ matrix.check.key }} - run: nix -L check github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.check.type }}.${{ matrix.check.arch }}.${{ matrix.check.key }} --no-update-lock-file + - uses: DeterminateSystems/nix-installer-action@v16 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - run: nix -L check github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.check.type }}.${{ matrix.check.arch }}.${{ matrix.check.key }} --no-update-lock-file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c9dc54adf..ea2576824 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,3 +1,4 @@ +--- name: Docs on: @@ -5,53 +6,31 @@ on: branches: - master -jobs: - build: - name: Build - - permissions: - contents: read +concurrency: + cancel-in-progress: true + group: pages +jobs: + docs: runs-on: ubuntu-24.04 - steps: - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v16 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: | - extra-experimental-features = nix-command flakes - - - name: Set up cache - uses: DeterminateSystems/magic-nix-cache-action@v8 - - - name: Build docs - run: nix -L build github:${{ github.repository }}/${{ github.sha }}#docs - - - name: Prepare docs for upload - run: cp -r --dereference --no-preserve=mode,ownership result/ public/ - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: public/ - - deploy: - name: Deploy - - needs: build - permissions: - pages: write + contents: read id-token: write + pages: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-24.04 - steps: - - name: Deploy docs to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v16 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - run: nix build .#docs + + - uses: actions/upload-pages-artifact@v3 + with: + path: result + + - uses: actions/deploy-pages@v4 From 5ab7d0345a902f5f4c30f9c31ccf42c563ad6463 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:24:09 +0200 Subject: [PATCH 12/18] treewide: add and apply typos pre-commit hook Link: https://github.com/danth/stylix/pull/519 --- docs/src/styling.md | 2 +- flake.nix | 1 + palette-generator/Stylix/Output.hs | 2 +- palette-generator/Stylix/Palette.hs | 2 +- stylix/testbed.nix | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/src/styling.md b/docs/src/styling.md index 5d335d16e..f44a824b0 100644 --- a/docs/src/styling.md +++ b/docs/src/styling.md @@ -11,7 +11,7 @@ applications that don't fit into any of the groups below. In this case it is up to the committer to make sure said application fits in stylistically with the rest of the themed applications. -It is also importent to note that this is a growing theming guide and when theming an application and you find the guide to be lacking in any way in +It is also important to note that this is a growing theming guide and when theming an application and you find the guide to be lacking in any way in terms of direction, you are encouraged to open an issue regarding what you would like to see added to the style guide. ## Terms diff --git a/flake.nix b/flake.nix index 60aab63c4..f380cb080 100644 --- a/flake.nix +++ b/flake.nix @@ -101,6 +101,7 @@ hooks = { deadnix.enable = true; statix.enable = true; + typos.enable = true; }; src = ./.; diff --git a/palette-generator/Stylix/Output.hs b/palette-generator/Stylix/Output.hs index 9d4bb9c97..9d6733cfe 100644 --- a/palette-generator/Stylix/Output.hs +++ b/palette-generator/Stylix/Output.hs @@ -10,7 +10,7 @@ toHexNum :: Double -> Word8 toHexNum = truncate {- | -Convert a colour to a hexdecimal string. +Convert a colour to a hexadecimal string. >>> toHex (RGB 255 255 255) "ffffff" diff --git a/palette-generator/Stylix/Palette.hs b/palette-generator/Stylix/Palette.hs index 83d18596e..1102a3382 100644 --- a/palette-generator/Stylix/Palette.hs +++ b/palette-generator/Stylix/Palette.hs @@ -10,7 +10,7 @@ import Data.Vector ( (//) ) import qualified Data.Vector as V import System.Random ( randomRIO ) --- | Extract the primary scale from a pallete. +-- | Extract the primary scale from a palette. primary :: V.Vector a -> V.Vector a primary = V.take 8 diff --git a/stylix/testbed.nix b/stylix/testbed.nix index 7fc738373..adf4be536 100644 --- a/stylix/testbed.nix +++ b/stylix/testbed.nix @@ -14,7 +14,7 @@ let security.sudo.wheelNeedsPassword = false; # The state version can safely track the latest release because the disk - # image is ephermal. + # image is ephemeral. system.stateVersion = config.system.nixos.release; home-manager.users.${username}.home.stateVersion = config.system.nixos.release; From d3bdbf0c5b4656955be0019e821de6fa65a6bb78 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:23:56 +0200 Subject: [PATCH 13/18] treewide: add and apply yamllint pre-commit hook Link: https://github.com/danth/stylix/pull/519 --- .github/workflows/backport.yml | 12 ++++--- .github/workflows/check.yml | 59 ++++++++++++++++++++++++++++++++-- .github/workflows/docs.yml | 2 +- flake.nix | 1 + 4 files changed, 66 insertions(+), 8 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 6a451ccb8..84ba26a88 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,8 +1,9 @@ -# Derived from https://github.com/NixOS/nixpkgs/blob/2ab6f6d61630889491f86396b27a76ffb6fbc7bb/.github/workflows/backport.yml - +--- +# Derived from +# https://github.com/NixOS/nixpkgs/blob/2ab6f6d61630889491f86396b27a76ffb6fbc7bb/.github/workflows/backport.yml name: Backport -on: +on: # yamllint disable-line rule:truthy pull_request_target: types: [closed, labeled] @@ -16,7 +17,10 @@ jobs: ( github.repository_owner == 'danth' && github.event.pull_request.merged == true && - (github.event_name != 'labeled' || startsWith('backport', github.event.label.name)) + ( + github.event_name != 'labeled' || + startsWith('backport', github.event.label.name) + ) ) steps: diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5ff87ea41..a36d83812 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,6 +1,7 @@ +--- name: Check -on: +on: # yamllint disable-line rule:truthy push: permissions: @@ -16,7 +17,46 @@ jobs: - id: get-derivations run: | - nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-24.04" else "macos-14" end), key: .key})) | flatten) | flatten | "derivations=\(.)"' >> $GITHUB_OUTPUT + nix flake show --json \ + github:${{ + github.repository + }}/${{ + github.event.pull_request.head.sha || github.sha + }} | + jq --compact-output --raw-output ' + to_entries | + map( + .key as $type | + select($type == "checks" or $type == "packages") | + .value | + to_entries | + map( + .key as $arch | + select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | + .value | + to_entries | + map( + { + arch: $arch, + key: .key, + + os: ( + if $arch == "x86_64-linux" then + "ubuntu-24.04" + else + "macos-14" + end + ), + + type: $type, + } + ) + ) | + flatten + ) | + flatten | + "derivations=\(.)" + ' >> $GITHUB_OUTPUT outputs: derivations: ${{ steps.get-derivations.outputs.derivations }} @@ -35,4 +75,17 @@ jobs: steps: - uses: DeterminateSystems/nix-installer-action@v16 - uses: DeterminateSystems/magic-nix-cache-action@v8 - - run: nix -L check github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.check.type }}.${{ matrix.check.arch }}.${{ matrix.check.key }} --no-update-lock-file + + - run: | + nix build --no-update-lock-file --print-build-logs \ + github:${{ + github.repository + }}/${{ + github.event.pull_request.head.sha || github.sha + }}#${{ + matrix.check.type + }}.${{ + matrix.check.arch + }}.${{ + matrix.check.key + }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ea2576824..84343e7e7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,7 +1,7 @@ --- name: Docs -on: +on: # yamllint disable-line rule:truthy push: branches: - master diff --git a/flake.nix b/flake.nix index f380cb080..2a2108d7e 100644 --- a/flake.nix +++ b/flake.nix @@ -102,6 +102,7 @@ deadnix.enable = true; statix.enable = true; typos.enable = true; + yamllint.enable = true; }; src = ./.; From 4ceede75042e362d3270b52d4870702a99915bb0 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Tue, 31 Dec 2024 16:47:17 +0100 Subject: [PATCH 14/18] ci: prevent the Check workflow from running duplicated checks outputs Prevent the Check workflow from running duplicated checks outputs. The jq query should now be faster and arguably more readable. Link: https://github.com/danth/stylix/pull/519 --- .github/workflows/check.yml | 52 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a36d83812..e3d3f4536 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,38 +23,30 @@ jobs: }}/${{ github.event.pull_request.head.sha || github.sha }} | - jq --compact-output --raw-output ' - to_entries | - map( - .key as $type | - select($type == "checks" or $type == "packages") | - .value | - to_entries | - map( - .key as $arch | - select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | - .value | - to_entries | - map( - { - arch: $arch, - key: .key, + jq --raw-output ' + def format_output($arch; $type): + { + arch: $arch, + key: ., - os: ( - if $arch == "x86_64-linux" then - "ubuntu-24.04" - else - "macos-14" - end - ), + os: ( + if $arch == "x86_64-linux" then + "ubuntu-24.04" + else + "macos-14" + end + ), - type: $type, - } - ) - ) | - flatten - ) | - flatten | + type: $type + }; + + [ + ["x86_64-linux", "x86_64-darwin"][] as $arch | + (.checks[$arch] | keys) as $checks | + (.packages[$arch] | keys) as $packages | + (($checks - $packages)[] | format_output($arch; "checks")), + ($packages[] | format_output($arch; "packages")) + ] | "derivations=\(.)" ' >> $GITHUB_OUTPUT From 439c6cf24e89730d3271baf10e5706df1cdecedf Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:36:28 +0200 Subject: [PATCH 15/18] treewide: add and apply stylish-haskell Link: https://github.com/danth/stylix/pull/519 --- flake.nix | 1 + palette-generator/Ai/Evolutionary.hs | 14 +++++++------- palette-generator/Data/Colour.hs | 8 ++++---- palette-generator/Stylix/Main.hs | 20 ++++++++++---------- palette-generator/Stylix/Output.hs | 8 ++++---- palette-generator/Stylix/Palette.hs | 24 +++++++++++++----------- 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/flake.nix b/flake.nix index 2a2108d7e..c05fbfee9 100644 --- a/flake.nix +++ b/flake.nix @@ -101,6 +101,7 @@ hooks = { deadnix.enable = true; statix.enable = true; + stylish-haskell.enable = true; typos.enable = true; yamllint.enable = true; }; diff --git a/palette-generator/Ai/Evolutionary.hs b/palette-generator/Ai/Evolutionary.hs index 634bfd113..c6a0c8be3 100644 --- a/palette-generator/Ai/Evolutionary.hs +++ b/palette-generator/Ai/Evolutionary.hs @@ -2,12 +2,12 @@ module Ai.Evolutionary ( Species(..), evolve ) where -import Data.Ord ( Down(Down), comparing ) -import Data.Vector ( (!) ) -import qualified Data.Vector as V -import Data.Vector.Algorithms.Intro ( selectBy ) -import System.Random ( randomRIO ) -import Text.Printf ( printf ) +import Data.Ord (Down (Down), comparing) +import Data.Vector ((!)) +import qualified Data.Vector as V +import Data.Vector.Algorithms.Intro (selectBy) +import System.Random (randomRIO) +import Text.Printf (printf) numSurvivors :: Int numSurvivors = 500 @@ -96,7 +96,7 @@ selectSurvivors environment population = shouldContinue :: [Double] -- ^ Fitness history -> Bool shouldContinue (x:y:_) = x /= y -shouldContinue _ = True +shouldContinue _ = True evolutionLoop :: Species e g => e -- ^ Environment diff --git a/palette-generator/Data/Colour.hs b/palette-generator/Data/Colour.hs index db189062f..45dc33d38 100644 --- a/palette-generator/Data/Colour.hs +++ b/palette-generator/Data/Colour.hs @@ -1,13 +1,13 @@ module Data.Colour ( LAB(..), RGB(..), deltaE, lab2rgb, rgb2lab ) where data LAB = LAB { lightness :: Double - , channelA :: Double - , channelB :: Double + , channelA :: Double + , channelB :: Double } -data RGB = RGB { red :: Double +data RGB = RGB { red :: Double , green :: Double - , blue :: Double + , blue :: Double } -- Based on https://github.com/antimatter15/rgb-lab/blob/master/color.js diff --git a/palette-generator/Stylix/Main.hs b/palette-generator/Stylix/Main.hs index d4a49e609..2170d6243 100644 --- a/palette-generator/Stylix/Main.hs +++ b/palette-generator/Stylix/Main.hs @@ -1,13 +1,13 @@ -import Ai.Evolutionary ( evolve ) -import Codec.Picture ( DynamicImage, convertRGB8, readImage ) -import Data.Colour ( lab2rgb ) -import qualified Data.Vector as V -import Stylix.Output ( makeOutputTable ) -import Stylix.Palette ( ) -import System.Environment ( getArgs ) -import System.Exit ( die ) -import System.Random ( setStdGen, mkStdGen ) -import Text.JSON ( encode ) +import Ai.Evolutionary (evolve) +import Codec.Picture (DynamicImage, convertRGB8, readImage) +import Data.Colour (lab2rgb) +import qualified Data.Vector as V +import Stylix.Output (makeOutputTable) +import Stylix.Palette () +import System.Environment (getArgs) +import System.Exit (die) +import System.Random (mkStdGen, setStdGen) +import Text.JSON (encode) -- | Load an image file. loadImage :: String -- ^ Path to the file diff --git a/palette-generator/Stylix/Output.hs b/palette-generator/Stylix/Output.hs index 9d6733cfe..682d42123 100644 --- a/palette-generator/Stylix/Output.hs +++ b/palette-generator/Stylix/Output.hs @@ -1,10 +1,10 @@ module Stylix.Output ( makeOutputTable ) where -import Data.Colour ( RGB(RGB) ) +import Data.Colour (RGB (RGB)) import qualified Data.Vector as V -import Data.Word ( Word8 ) -import Text.JSON ( JSObject, toJSObject ) -import Text.Printf ( printf ) +import Data.Word (Word8) +import Text.JSON (JSObject, toJSObject) +import Text.Printf (printf) toHexNum :: Double -> Word8 toHexNum = truncate diff --git a/palette-generator/Stylix/Palette.hs b/palette-generator/Stylix/Palette.hs index 1102a3382..1b8b0d784 100644 --- a/palette-generator/Stylix/Palette.hs +++ b/palette-generator/Stylix/Palette.hs @@ -1,14 +1,16 @@ -{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} module Stylix.Palette ( ) where -import Ai.Evolutionary ( Species(..) ) -import Codec.Picture ( Image(imageWidth, imageHeight), PixelRGB8(PixelRGB8), pixelAt ) -import Data.Colour ( LAB(lightness), RGB(RGB), deltaE, rgb2lab ) -import Data.List ( delete ) -import Data.Vector ( (//) ) -import qualified Data.Vector as V -import System.Random ( randomRIO ) +import Ai.Evolutionary (Species (..)) +import Codec.Picture (Image (imageHeight, imageWidth), + PixelRGB8 (PixelRGB8), pixelAt) +import Data.Colour (LAB (lightness), RGB (RGB), deltaE, rgb2lab) +import Data.List (delete) +import Data.Vector ((//)) +import qualified Data.Vector as V +import System.Random (randomRIO) -- | Extract the primary scale from a palette. primary :: V.Vector a -> V.Vector a @@ -73,9 +75,9 @@ instance Species (String, Image PixelRGB8) (V.Vector LAB) where scheme = case polarity of "either" -> min lightScheme darkScheme - "light" -> lightScheme - "dark" -> darkScheme - _ -> error ("Invalid polarity: " ++ polarity) + "light" -> lightScheme + "dark" -> darkScheme + _ -> error ("Invalid polarity: " ++ polarity) {- For light themes, the background is bright and the text is dark. From 708b2147c095a60994f56714968f00de531f8deb Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:36:35 +0200 Subject: [PATCH 16/18] stylix: add hlint pre-commit hook Link: https://github.com/danth/stylix/pull/519 --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index c05fbfee9..a45d21850 100644 --- a/flake.nix +++ b/flake.nix @@ -100,6 +100,7 @@ git-hooks = inputs.git-hooks.lib.${system}.run { hooks = { deadnix.enable = true; + hlint.enable = true; statix.enable = true; stylish-haskell.enable = true; typos.enable = true; From 807c81894e9af60b105476c3dab679e9dc86686f Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:31:56 +0200 Subject: [PATCH 17/18] stylix: add ghc developer shell Link: https://github.com/danth/stylix/pull/519 --- flake.nix | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index a45d21850..60d7557b4 100644 --- a/flake.nix +++ b/flake.nix @@ -111,13 +111,20 @@ }; } self.packages.${system}; - devShells.default = pkgs.mkShell { - inherit (self.checks.${system}.git-hooks) shellHook; + devShells = { + default = pkgs.mkShell { + inherit (self.checks.${system}.git-hooks) shellHook; + + packages = [ + inputs.home-manager.packages.${system}.default + self.checks.${system}.git-hooks.enabledPackages + ]; + }; - packages = [ - inputs.home-manager.packages.${system}.default - self.checks.${system}.git-hooks.enabledPackages - ]; + ghc = pkgs.mkShell { + inputsFrom = [ self.devShells.${system}.default ]; + packages = [ pkgs.ghc ]; + }; }; packages = let From ad64260a75f0331d4d9b0db70f60634283e0aa5d Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:14:30 +0100 Subject: [PATCH 18/18] treewide: add and apply nixfmt pre-commit hook Link: https://github.com/danth/stylix/pull/519 --- default.nix | 15 +- docs/default.nix | 42 ++- flake.nix | 88 +++--- modules/alacritty/hm.nix | 92 +++--- modules/alacritty/testbed.nix | 22 +- modules/avizo/hm.nix | 31 ++- modules/bat/hm.nix | 5 +- modules/bemenu/hm.nix | 51 ++-- modules/bspwm/hm.nix | 3 +- modules/btop/hm.nix | 107 +++---- modules/cava/hm.nix | 27 +- modules/chromium/nixos.nix | 14 +- modules/chromium/testbed.nix | 8 +- modules/console/nixos.nix | 38 +-- modules/dunst/hm.nix | 7 +- modules/emacs/hm.nix | 90 +++--- modules/emacs/testbed.nix | 22 +- modules/fcitx5/hm.nix | 21 +- modules/feh/hm.nix | 65 +++-- modules/feh/nixos.nix | 56 ++-- modules/firefox/hm.nix | 53 ++-- modules/firefox/testbed.nix | 24 +- modules/fish/prompt.nix | 3 +- modules/foot/hm.nix | 13 +- modules/foot/testbed.nix | 22 +- modules/forge/hm.nix | 10 +- modules/fuzzel/hm.nix | 38 +-- modules/gedit/hm.nix | 3 +- modules/gedit/testbed.nix | 8 +- modules/ghostty/hm.nix | 97 +++---- modules/gitui/hm.nix | 3 +- modules/gnome/hm.nix | 50 ++-- modules/gnome/nixos.nix | 91 +++--- modules/gnome/theme.nix | 16 +- modules/grub/nixos.nix | 215 +++++++------- modules/gtk/hm.nix | 136 ++++----- modules/helix/hm.nix | 31 ++- modules/hyprland/hm.nix | 79 +++--- modules/hyprland/testbed.nix | 16 +- modules/hyprlock/hm.nix | 24 +- modules/hyprpaper/hm.nix | 16 +- modules/i3/hm.nix | 138 ++++----- modules/k9s/hm.nix | 13 +- modules/kde/hm.nix | 217 ++++++++------- modules/kitty/hm.nix | 7 +- modules/kitty/testbed.nix | 22 +- modules/kmscon/nixos.nix | 68 ++--- modules/kubecolor/hm.nix | 6 +- modules/lazygit/hm.nix | 46 +-- modules/lightdm/nixos.nix | 5 +- modules/mako/hm.nix | 56 ++-- modules/mangohud/hm.nix | 60 ++-- modules/micro/hm.nix | 18 +- modules/ncspot/hm.nix | 53 ++-- modules/neovim/hm.nix | 96 ++++--- modules/nixos-icons/nixos.nix | 41 +-- modules/nixvim/nixvim.nix | 177 ++++++++---- modules/nushell/hm.nix | 76 ++--- modules/plymouth/nixos.nix | 34 +-- modules/qutebrowser/hm.nix | 415 ++++++++++++++-------------- modules/qutebrowser/testbed.nix | 22 +- modules/regreet/nixos.nix | 31 ++- modules/river/hm.nix | 3 +- modules/rofi/hm.nix | 10 +- modules/spicetify/spicetify.nix | 89 +++--- modules/sway/hm.nix | 124 +++++---- modules/swaylock/hm.nix | 78 +++--- modules/swaync/hm.nix | 28 +- modules/sxiv/hm.nix | 3 +- modules/tmux/hm.nix | 5 +- modules/tofi/hm.nix | 14 +- modules/vesktop/hm.nix | 11 +- modules/vesktop/testbed.nix | 8 +- modules/vim/hm.nix | 79 +++--- modules/vscode/hm.nix | 87 +++--- modules/vscode/testbed.nix | 22 +- modules/waybar/hm.nix | 66 +++-- modules/wezterm/hm.nix | 246 +++++++++-------- modules/wezterm/testbed.nix | 22 +- modules/wob/hm.nix | 3 +- modules/wofi/hm.nix | 6 +- modules/wpaperd/hm.nix | 26 +- modules/xresources/hm.nix | 57 ++-- modules/yazi/hm.nix | 220 ++++++++------- modules/zathura/hm.nix | 71 ++--- modules/zathura/testbed.nix | 22 +- modules/zellij/hm.nix | 42 +-- palette-generator/default.nix | 17 +- stylix/autoload.nix | 21 +- stylix/cursor.nix | 32 +-- stylix/darwin/default.nix | 9 +- stylix/darwin/fonts.nix | 3 +- stylix/fonts.nix | 10 +- stylix/hm/cursor.nix | 10 +- stylix/hm/default.nix | 5 +- stylix/hm/fonts.nix | 3 +- stylix/hm/icon.nix | 42 +-- stylix/home-manager-integration.nix | 227 ++++++++++++--- stylix/icon.nix | 42 +-- stylix/nixos/cursor.nix | 3 +- stylix/nixos/default.nix | 9 +- stylix/nixos/fonts.nix | 3 +- stylix/opacity.nix | 42 +-- stylix/palette.nix | 64 +++-- stylix/pixel.nix | 3 +- stylix/target.nix | 27 +- stylix/templates.nix | 3 +- stylix/testbed.nix | 208 +++++++------- 108 files changed, 3125 insertions(+), 2353 deletions(-) diff --git a/default.nix b/default.nix index 80aeb4331..6466507b7 100644 --- a/default.nix +++ b/default.nix @@ -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 diff --git a/docs/default.nix b/docs/default.nix index 5b524cc61..5f005cf6c 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -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 @@ -35,9 +45,11 @@ let }; } ]; - }); + } + ); -in pkgs.stdenvNoCC.mkDerivation { +in +pkgs.stdenvNoCC.mkDerivation { name = "stylix-book"; src = ./.; diff --git a/flake.nix b/flake.nix index 60d7557b4..379adc7f7 100644 --- a/flake.nix +++ b/flake.nix @@ -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; @@ -127,7 +140,8 @@ }; }; - packages = let + packages = + let universalPackages = { docs = import ./docs { inherit pkgs inputs lib; }; @@ -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; + }) + ]; + }; }; } diff --git a/modules/alacritty/hm.nix b/modules/alacritty/hm.nix index e9974f31c..cdf950623 100644 --- a/modules/alacritty/hm.nix +++ b/modules/alacritty/hm.nix @@ -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; - }; - }; - }; - }; } diff --git a/modules/alacritty/testbed.nix b/modules/alacritty/testbed.nix index acc8d81c1..602273f5d 100644 --- a/modules/alacritty/testbed.nix +++ b/modules/alacritty/testbed.nix @@ -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; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.alacritty = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/avizo/hm.nix b/modules/avizo/hm.nix index e67a2d3f9..7ad1517fb 100644 --- a/modules/avizo/hm.nix +++ b/modules/avizo/hm.nix @@ -1,4 +1,9 @@ -{ config, lib, options, ... }: +{ + config, + lib, + options, + ... +}: with config.lib.stylix.colors; with config.stylix.fonts; @@ -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; + }; }; - }; - }); + }; + } + ); } diff --git a/modules/bat/hm.nix b/modules/bat/hm.nix index e38751e6a..64ba75505 100644 --- a/modules/bat/hm.nix +++ b/modules/bat/hm.nix @@ -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; diff --git a/modules/bemenu/hm.nix b/modules/bemenu/hm.nix index e629e4dbe..1b2e97ab2 100644 --- a/modules/bemenu/hm.nix +++ b/modules/bemenu/hm.nix @@ -3,8 +3,11 @@ with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; let - bemenuOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100); -in { + bemenuOpacity = lib.toHexString ( + ((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100 + ); +in +{ options.stylix.targets.bemenu = { enable = config.lib.stylix.mkEnableTarget "bemenu" true; @@ -25,27 +28,31 @@ in { }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.bemenu.enable) { - programs.bemenu.settings = with config.stylix.targets.bemenu; { - tb = "${base01}${bemenuOpacity}"; # Title bg - nb = "${base01}${bemenuOpacity}"; # Normal bg - fb = "${base01}${bemenuOpacity}"; # Filter bg - hb = "${base03}${bemenuOpacity}"; # Highlighted bg - sb = "${base03}${bemenuOpacity}"; # Selected bg - scb = "${base01}"; # Scrollbar bg + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.bemenu.enable) + { + programs.bemenu.settings = with config.stylix.targets.bemenu; { + tb = "${base01}${bemenuOpacity}"; # Title bg + nb = "${base01}${bemenuOpacity}"; # Normal bg + fb = "${base01}${bemenuOpacity}"; # Filter bg + hb = "${base03}${bemenuOpacity}"; # Highlighted bg + sb = "${base03}${bemenuOpacity}"; # Selected bg + scb = "${base01}"; # Scrollbar bg - hf = "${base0A}"; # Highlighted fg - sf = "${base0B}"; # Selected fg - tf = "${base05}"; # Title fg - ff = "${base05}"; # Filter fg - nf = "${base05}"; # Normal fg - scf = "${base03}"; # Scrollbar fg + hf = "${base0A}"; # Highlighted fg + sf = "${base0B}"; # Selected fg + tf = "${base05}"; # Title fg + ff = "${base05}"; # Filter fg + nf = "${base05}"; # Normal fg + scf = "${base03}"; # Scrollbar fg - ab = "${if alternate then base00 else base01}"; # Alternate bg - af = "${if alternate then base04 else base05}"; # Alternate fg + ab = "${if alternate then base00 else base01}"; # Alternate bg + af = "${if alternate then base04 else base05}"; # Alternate fg - # Font name - fn = "${sansSerif.name} ${lib.optionalString (fontSize != null) (builtins.toString fontSize)}"; - }; - }; + # Font name + fn = "${sansSerif.name} ${ + lib.optionalString (fontSize != null) (builtins.toString fontSize) + }"; + }; + }; } diff --git a/modules/bspwm/hm.nix b/modules/bspwm/hm.nix index 108f41f57..36d360d04 100644 --- a/modules/bspwm/hm.nix +++ b/modules/bspwm/hm.nix @@ -2,7 +2,8 @@ let colors = config.lib.stylix.colors.withHashtag; -in { +in +{ options.stylix.targets.bspwm.enable = config.lib.stylix.mkEnableTarget "bspwm" true; diff --git a/modules/btop/hm.nix b/modules/btop/hm.nix index 4c7a709a9..35281ff56 100644 --- a/modules/btop/hm.nix +++ b/modules/btop/hm.nix @@ -1,61 +1,70 @@ { config, lib, ... }: let - colors = config.lib.stylix.colors.withHashtag; -in { - options.stylix.targets.btop.enable = config.lib.stylix.mkEnableTarget "btop" true; + colors = config.lib.stylix.colors.withHashtag; +in +{ + options.stylix.targets.btop.enable = + config.lib.stylix.mkEnableTarget "btop" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.btop.enable && config.programs.btop.enable) { + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.btop.enable + && config.programs.btop.enable + ) + { programs.btop.settings = { - color_theme = "stylix"; - theme_background = lib.mkIf (config.stylix.opacity.terminal != 1.0) false; + color_theme = "stylix"; + theme_background = lib.mkIf (config.stylix.opacity.terminal != 1.0) false; }; xdg.configFile."btop/themes/stylix.theme".text = with colors; '' - #Generated by Stylix - theme[main_bg]="${base00}" - theme[main_fg]="${base05}" - theme[title]="${base05}" - theme[hi_fg]="${base0D}" - theme[selected_bg]="${base03}" - theme[selected_fg]="${base0D}" - theme[inactive_fg]="${base04}" - theme[graph_text]="${base06}" - theme[meter_bg]="${base03}" - theme[proc_misc]="${base06}" - theme[cpu_box]="${base0E}" - theme[mem_box]="${base0B}" - theme[net_box]="${base0C}" - theme[proc_box]="${base0D}" - theme[div_line]="${base01}" - theme[temp_start]="${base0B}" - theme[temp_mid]="${base0A}" - theme[temp_end]="${base08}" - theme[cpu_start]="${base0B}" - theme[cpu_mid]="${base0A}" - theme[cpu_end]="${base08}" - theme[free_start]="${base0B}" - theme[free_mid]="${base0A}" - theme[free_end]="${base08}" - theme[cached_start]="${base0B}" - theme[cached_mid]="${base0A}" - theme[cached_end]="${base08}" - theme[available_start]="${base0B}" - theme[available_mid]="${base0A}" - theme[available_end]="${base08}" - theme[used_start]="${base0B}" - theme[used_mid]="${base0A}" - theme[used_end]="${base08}" - theme[download_start]="${base0B}" - theme[download_mid]="${base0A}" - theme[download_end]="${base08}" - theme[upload_start]="${base0B}" - theme[upload_mid]="${base0A}" - theme[upload_end]="${base08}" - theme[process_start]="${base0B}" - theme[process_mid]="${base0A}" - theme[process_end]="${base08}" + #Generated by Stylix + theme[main_bg]="${base00}" + theme[main_fg]="${base05}" + theme[title]="${base05}" + theme[hi_fg]="${base0D}" + theme[selected_bg]="${base03}" + theme[selected_fg]="${base0D}" + theme[inactive_fg]="${base04}" + theme[graph_text]="${base06}" + theme[meter_bg]="${base03}" + theme[proc_misc]="${base06}" + theme[cpu_box]="${base0E}" + theme[mem_box]="${base0B}" + theme[net_box]="${base0C}" + theme[proc_box]="${base0D}" + theme[div_line]="${base01}" + theme[temp_start]="${base0B}" + theme[temp_mid]="${base0A}" + theme[temp_end]="${base08}" + theme[cpu_start]="${base0B}" + theme[cpu_mid]="${base0A}" + theme[cpu_end]="${base08}" + theme[free_start]="${base0B}" + theme[free_mid]="${base0A}" + theme[free_end]="${base08}" + theme[cached_start]="${base0B}" + theme[cached_mid]="${base0A}" + theme[cached_end]="${base08}" + theme[available_start]="${base0B}" + theme[available_mid]="${base0A}" + theme[available_end]="${base08}" + theme[used_start]="${base0B}" + theme[used_mid]="${base0A}" + theme[used_end]="${base08}" + theme[download_start]="${base0B}" + theme[download_mid]="${base0A}" + theme[download_end]="${base08}" + theme[upload_start]="${base0B}" + theme[upload_mid]="${base0A}" + theme[upload_end]="${base08}" + theme[process_start]="${base0B}" + theme[process_mid]="${base0A}" + theme[process_end]="${base08}" ''; }; } diff --git a/modules/cava/hm.nix b/modules/cava/hm.nix index fd88b7225..a0bd5dcda 100644 --- a/modules/cava/hm.nix +++ b/modules/cava/hm.nix @@ -1,11 +1,18 @@ { config, lib, ... }: -let +let - mkGradient = colors: lib.listToAttrs (lib.imap0 (i: c: lib.nameValuePair "gradient_color_${toString (i+1)}" "'#${c}'") colors) // { - gradient = 1; - gradient_count = builtins.length colors; - }; + mkGradient = + colors: + lib.listToAttrs ( + lib.imap0 ( + i: c: lib.nameValuePair "gradient_color_${toString (i + 1)}" "'#${c}'" + ) colors + ) + // { + gradient = 1; + gradient_count = builtins.length colors; + }; rainbowColors = with config.lib.stylix.colors; [ base0E @@ -17,15 +24,17 @@ let base08 ]; -in { +in +{ options.stylix.targets.cava = { enable = config.lib.stylix.mkEnableTarget "CAVA" true; rainbow.enable = config.lib.stylix.mkEnableTarget "rainbow gradient theming" false; }; - config = let - cfg = config.stylix.targets.cava; - in + config = + let + cfg = config.stylix.targets.cava; + in lib.mkIf (config.stylix.enable && cfg.enable) { programs.cava.settings.color = lib.mkIf cfg.rainbow.enable ( mkGradient rainbowColors diff --git a/modules/chromium/nixos.nix b/modules/chromium/nixos.nix index 8f193f272..a8fd3b8e5 100644 --- a/modules/chromium/nixos.nix +++ b/modules/chromium/nixos.nix @@ -4,11 +4,13 @@ options.stylix.targets.chromium.enable = config.lib.stylix.mkEnableTarget "Chromium, Google Chrome and Brave" true; - config.programs.chromium = lib.mkIf (config.stylix.enable && config.stylix.targets.chromium.enable) { - # This enables policies without installing the browser. Policies take up a - # negligible amount of space, so it's reasonable to have this always on. - enable = true; + config.programs.chromium = + lib.mkIf (config.stylix.enable && config.stylix.targets.chromium.enable) + { + # This enables policies without installing the browser. Policies take up a + # negligible amount of space, so it's reasonable to have this always on. + enable = true; - extraOpts.BrowserThemeColor = config.lib.stylix.colors.withHashtag.base00; - }; + extraOpts.BrowserThemeColor = config.lib.stylix.colors.withHashtag.base00; + }; } diff --git a/modules/chromium/testbed.nix b/modules/chromium/testbed.nix index 31475acd6..b45a18240 100644 --- a/modules/chromium/testbed.nix +++ b/modules/chromium/testbed.nix @@ -1,8 +1,10 @@ { pkgs, ... }: -let package = pkgs.chromium; +let + package = pkgs.chromium; -in { +in +{ stylix.testbed.application = { enable = true; name = "chromium-browser"; @@ -10,4 +12,4 @@ in { }; environment.systemPackages = [ package ]; -} \ No newline at end of file +} diff --git a/modules/console/nixos.nix b/modules/console/nixos.nix index b5b2b2b10..5f7b103a5 100644 --- a/modules/console/nixos.nix +++ b/modules/console/nixos.nix @@ -6,22 +6,24 @@ with config.lib.stylix.colors; options.stylix.targets.console.enable = config.lib.stylix.mkEnableTarget "the Linux kernel console" true; - config.console.colors = lib.mkIf (config.stylix.enable && config.stylix.targets.console.enable) [ - base00-hex - red - green - yellow - blue - magenta - cyan - base05-hex - base03-hex - red - green - yellow - blue - magenta - cyan - base06-hex - ]; + config.console.colors = + lib.mkIf (config.stylix.enable && config.stylix.targets.console.enable) + [ + base00-hex + red + green + yellow + blue + magenta + cyan + base05-hex + base03-hex + red + green + yellow + blue + magenta + cyan + base06-hex + ]; } diff --git a/modules/dunst/hm.nix b/modules/dunst/hm.nix index 7c4ad0ba0..85eeaffd3 100644 --- a/modules/dunst/hm.nix +++ b/modules/dunst/hm.nix @@ -3,8 +3,11 @@ with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; let - dunstOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100); -in { + dunstOpacity = lib.toHexString ( + ((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100 + ); +in +{ options.stylix.targets.dunst.enable = config.lib.stylix.mkEnableTarget "Dunst" true; diff --git a/modules/emacs/hm.nix b/modules/emacs/hm.nix index 32e187b43..c090f7a25 100644 --- a/modules/emacs/hm.nix +++ b/modules/emacs/hm.nix @@ -1,10 +1,17 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; let - emacsOpacity = builtins.toString (builtins.ceil (config.stylix.opacity.applications * 100)); + emacsOpacity = builtins.toString ( + builtins.ceil (config.stylix.opacity.applications * 100) + ); emacsSize = builtins.toString (sizes.terminal * 1.0); in { @@ -13,52 +20,51 @@ in config = lib.mkIf (config.stylix.enable && config.stylix.targets.emacs.enable) { programs.emacs = { - extraPackages = epkgs: - [ - (epkgs.trivialBuild { - pname = "base16-stylix-theme"; - version = "0.1.0"; - src = pkgs.writeText "base16-stylix-theme.el" '' - (require 'base16-theme) + extraPackages = epkgs: [ + (epkgs.trivialBuild { + pname = "base16-stylix-theme"; + version = "0.1.0"; + src = pkgs.writeText "base16-stylix-theme.el" '' + (require 'base16-theme) - (defvar base16-stylix-theme-colors - '(:base00 "${base00}" - :base01 "${base01}" - :base02 "${base02}" - :base03 "${base03}" - :base04 "${base04}" - :base05 "${base05}" - :base06 "${base06}" - :base07 "${base07}" - :base08 "${base08}" - :base09 "${base09}" - :base0A "${base0A}" - :base0B "${base0B}" - :base0C "${base0C}" - :base0D "${base0D}" - :base0E "${base0E}" - :base0F "${base0F}") - "All colors for Base16 stylix are defined here.") + (defvar base16-stylix-theme-colors + '(:base00 "${base00}" + :base01 "${base01}" + :base02 "${base02}" + :base03 "${base03}" + :base04 "${base04}" + :base05 "${base05}" + :base06 "${base06}" + :base07 "${base07}" + :base08 "${base08}" + :base09 "${base09}" + :base0A "${base0A}" + :base0B "${base0B}" + :base0C "${base0C}" + :base0D "${base0D}" + :base0E "${base0E}" + :base0F "${base0F}") + "All colors for Base16 stylix are defined here.") - ;; Define the theme - (deftheme base16-stylix) + ;; Define the theme + (deftheme base16-stylix) - ;; Add all the faces to the theme - (base16-theme-define 'base16-stylix base16-stylix-theme-colors) + ;; Add all the faces to the theme + (base16-theme-define 'base16-stylix base16-stylix-theme-colors) - ;; Mark the theme as provided - (provide-theme 'base16-stylix) + ;; Mark the theme as provided + (provide-theme 'base16-stylix) - ;; Add path to theme to theme-path - (add-to-list 'custom-theme-load-path - (file-name-directory - (file-truename load-file-name))) + ;; Add path to theme to theme-path + (add-to-list 'custom-theme-load-path + (file-name-directory + (file-truename load-file-name))) - (provide 'base16-stylix-theme) - ''; - packageRequires = [ epkgs.base16-theme ]; - }) - ]; + (provide 'base16-stylix-theme) + ''; + packageRequires = [ epkgs.base16-theme ]; + }) + ]; extraConfig = '' ;; ---- Generated by stylix ---- diff --git a/modules/emacs/testbed.nix b/modules/emacs/testbed.nix index c8812d564..ad4116ba6 100644 --- a/modules/emacs/testbed.nix +++ b/modules/emacs/testbed.nix @@ -1,18 +1,22 @@ { pkgs, ... }: -let package = pkgs.emacs; +let + package = pkgs.emacs; -in { +in +{ stylix.testbed.application = { enable = true; name = "emacs"; inherit package; }; - home-manager.sharedModules = [{ - programs.emacs = { - enable = true; - inherit package; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.emacs = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/fcitx5/hm.nix b/modules/fcitx5/hm.nix index 5ee1619f7..bef988502 100644 --- a/modules/fcitx5/hm.nix +++ b/modules/fcitx5/hm.nix @@ -2,7 +2,8 @@ config, lib, ... -}: let +}: +let # Adapted from https://github.com/sanweiya/fcitx5-mellow-themes under the BSD 2 license (compatible with this project's license (MIT)) theme = config.lib.stylix.colors { template = ./theme.conf.mustache; @@ -16,18 +17,18 @@ template = ./panel.svg.mustache; extension = "svg"; }; -in { +in +{ options.stylix.targets.fcitx5.enable = config.lib.stylix.mkEnableTarget "fcitx5" true; config = - lib.mkIf - (config.stylix.enable && config.stylix.targets.fcitx5.enable) - { - xdg.dataFile = { - "fcitx5/themes/stylix/highlight.svg".source = highlight; - "fcitx5/themes/stylix/panel.svg".source = panel; - "fcitx5/themes/stylix/theme.conf".source = theme; + lib.mkIf (config.stylix.enable && config.stylix.targets.fcitx5.enable) + { + xdg.dataFile = { + "fcitx5/themes/stylix/highlight.svg".source = highlight; + "fcitx5/themes/stylix/panel.svg".source = panel; + "fcitx5/themes/stylix/theme.conf".source = theme; + }; }; - }; } diff --git a/modules/feh/hm.nix b/modules/feh/hm.nix index 62fccb0a7..a10129943 100644 --- a/modules/feh/hm.nix +++ b/modules/feh/hm.nix @@ -1,35 +1,44 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: { options.stylix.targets.feh.enable = - config.lib.stylix.mkEnableTarget - "the desktop background using Feh" - true; + config.lib.stylix.mkEnableTarget "the desktop background using Feh" true; config.xsession.initExtra = - lib.mkIf ( - config.stylix.enable - && config.stylix.targets.feh.enable - && ( - with config.xsession.windowManager; - bspwm.enable - || herbstluftwm.enable - || i3.enable - || spectrwm.enable - || xmonad.enable + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.feh.enable + && ( + with config.xsession.windowManager; + bspwm.enable + || herbstluftwm.enable + || i3.enable + || spectrwm.enable + || xmonad.enable + ) ) - ) (let - inherit (config.stylix) imageScalingMode; - bg-arg = - if imageScalingMode == "fill" - then "--bg-fill" - else if imageScalingMode == "center" - then "--bg-center" - else if imageScalingMode == "tile" - then "--bg-tile" - else if imageScalingMode == "stretch" - then "--bg-scale" - # Fit - else "--bg-max"; - in "${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}"); + ( + let + inherit (config.stylix) imageScalingMode; + bg-arg = + if imageScalingMode == "fill" then + "--bg-fill" + else if imageScalingMode == "center" then + "--bg-center" + else if imageScalingMode == "tile" then + "--bg-tile" + else if imageScalingMode == "stretch" then + "--bg-scale" + # Fit + else + "--bg-max"; + in + "${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}" + ); } diff --git a/modules/feh/nixos.nix b/modules/feh/nixos.nix index 74f668858..64469e0ad 100644 --- a/modules/feh/nixos.nix +++ b/modules/feh/nixos.nix @@ -1,33 +1,37 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: { options.stylix.targets.feh.enable = - config.lib.stylix.mkEnableTarget - "the desktop background using Feh" - true; + config.lib.stylix.mkEnableTarget "the desktop background using Feh" true; config.services.xserver.displayManager.sessionCommands = - lib.mkIf ( - config.stylix.enable - && config.stylix.targets.feh.enable - && ( - with config.services.xserver.windowManager; - xmonad.enable - || i3.enable + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.feh.enable + && (with config.services.xserver.windowManager; xmonad.enable || i3.enable) ) - ) - (let - inherit (config.stylix) imageScalingMode; - bg-arg = - if imageScalingMode == "fill" - then "--bg-fill" - else if imageScalingMode == "center" - then "--bg-center" - else if imageScalingMode == "tile" - then "--bg-tile" - else if imageScalingMode == "stretch" - then "--bg-scale" - # Fit - else "--bg-max"; - in "${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}"); + ( + let + inherit (config.stylix) imageScalingMode; + bg-arg = + if imageScalingMode == "fill" then + "--bg-fill" + else if imageScalingMode == "center" then + "--bg-center" + else if imageScalingMode == "tile" then + "--bg-tile" + else if imageScalingMode == "stretch" then + "--bg-scale" + # Fit + else + "--bg-max"; + in + "${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}" + ); } diff --git a/modules/firefox/hm.nix b/modules/firefox/hm.nix index 379e46587..d4f30e43b 100644 --- a/modules/firefox/hm.nix +++ b/modules/firefox/hm.nix @@ -11,26 +11,43 @@ let "font.name.serif.x-western" = config.stylix.fonts.serif.name; }; }; - makeProfileSettingsPair = profileName: - lib.nameValuePair profileName profileSettings; + makeProfileSettingsPair = + profileName: lib.nameValuePair profileName profileSettings; derivatives = [ - {path = "firefox"; name = "Firefox";} - {path = "librewolf"; name = "LibreWolf";} + { + path = "firefox"; + name = "Firefox"; + } + { + path = "librewolf"; + name = "LibreWolf"; + } ]; -in { - options.stylix.targets = lib.listToAttrs (map (drv: lib.nameValuePair drv.path { - enable = - config.lib.stylix.mkEnableTarget drv.name true; +in +{ + options.stylix.targets = lib.listToAttrs ( + map ( + drv: + lib.nameValuePair drv.path { + enable = config.lib.stylix.mkEnableTarget drv.name true; - profileNames = lib.mkOption { - description = "The ${drv.name} profile names to apply styling on."; - type = lib.types.listOf lib.types.str; - default = [ ]; - }; - }) derivatives); + profileNames = lib.mkOption { + description = "The ${drv.name} profile names to apply styling on."; + type = lib.types.listOf lib.types.str; + default = [ ]; + }; + } + ) derivatives + ); - config = lib.mkMerge (map (drv: lib.mkIf (config.stylix.enable && config.stylix.targets.${drv.path}.enable) { - programs.${drv.path}.profiles = lib.listToAttrs - (map makeProfileSettingsPair config.stylix.targets.${drv.path}.profileNames); - }) derivatives); + config = lib.mkMerge ( + map ( + drv: + lib.mkIf (config.stylix.enable && config.stylix.targets.${drv.path}.enable) { + programs.${drv.path}.profiles = lib.listToAttrs ( + map makeProfileSettingsPair config.stylix.targets.${drv.path}.profileNames + ); + } + ) derivatives + ); } diff --git a/modules/firefox/testbed.nix b/modules/firefox/testbed.nix index 770c5901b..fb10610e4 100644 --- a/modules/firefox/testbed.nix +++ b/modules/firefox/testbed.nix @@ -1,21 +1,25 @@ { pkgs, ... }: -let package = pkgs.firefox; +let + package = pkgs.firefox; -in { +in +{ stylix.testbed.application = { enable = true; name = "firefox"; inherit package; }; - home-manager.sharedModules = [{ - programs.firefox = { - enable = true; - inherit package; - profiles.stylix.isDefault = true; - }; + home-manager.sharedModules = [ + { + programs.firefox = { + enable = true; + inherit package; + profiles.stylix.isDefault = true; + }; - stylix.targets.firefox.profileNames = [ "stylix" ]; - }]; + stylix.targets.firefox.profileNames = [ "stylix" ]; + } + ]; } diff --git a/modules/fish/prompt.nix b/modules/fish/prompt.nix index f3792808d..c07ea295f 100644 --- a/modules/fish/prompt.nix +++ b/modules/fish/prompt.nix @@ -4,7 +4,8 @@ let theme = config.lib.stylix.colors { templateRepo = config.lib.stylix.templates.base16-fish; }; -in '' +in +'' source ${theme} # See https://github.com/tomyun/base16-fish/issues/7 for why this condition exists diff --git a/modules/foot/hm.nix b/modules/foot/hm.nix index 8fa04af43..7c5526541 100644 --- a/modules/foot/hm.nix +++ b/modules/foot/hm.nix @@ -7,17 +7,18 @@ let templateRepo = config.lib.stylix.templates.tinted-foot; }; -in { +in +{ options.stylix.targets.foot.enable = config.lib.stylix.mkEnableTarget "Foot" true; config.programs.foot.settings = lib.mkIf cfg.enable { main = { - include = theme; - font = - with config.stylix.fonts; - "${monospace.name}:size=${toString sizes.terminal}"; - dpi-aware = "no"; + include = theme; + font = + with config.stylix.fonts; + "${monospace.name}:size=${toString sizes.terminal}"; + dpi-aware = "no"; }; colors.alpha = with config.stylix.opacity; terminal; }; diff --git a/modules/foot/testbed.nix b/modules/foot/testbed.nix index 891b7c9b3..072bc27db 100644 --- a/modules/foot/testbed.nix +++ b/modules/foot/testbed.nix @@ -1,18 +1,22 @@ { pkgs, ... }: -let package = pkgs.foot; +let + package = pkgs.foot; -in { +in +{ stylix.testbed.application = { enable = true; name = "foot"; inherit package; }; - home-manager.sharedModules = [{ - programs.foot = { - enable = true; - inherit package; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.foot = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/forge/hm.nix b/modules/forge/hm.nix index 3c5cab506..03b4932f0 100644 --- a/modules/forge/hm.nix +++ b/modules/forge/hm.nix @@ -5,9 +5,11 @@ config.lib.stylix.mkEnableTarget "Forge" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.forge.enable) { - xdg.configFile."forge/stylesheet/forge/stylesheet.css".source = config.lib.stylix.colors { - template = ./stylesheet.css.mustache; - extension = ".css"; - }; + xdg.configFile."forge/stylesheet/forge/stylesheet.css".source = + config.lib.stylix.colors + { + template = ./stylesheet.css.mustache; + extension = ".css"; + }; }; } diff --git a/modules/fuzzel/hm.nix b/modules/fuzzel/hm.nix index 6b4547cc1..af11b503b 100644 --- a/modules/fuzzel/hm.nix +++ b/modules/fuzzel/hm.nix @@ -5,28 +5,30 @@ with config.lib.stylix.colors; let opacity = lib.toHexString (builtins.ceil (config.stylix.opacity.popups * 255)); -in { +in +{ options.stylix.targets.fuzzel.enable = config.lib.stylix.mkEnableTarget "Fuzzel" true; config.programs.fuzzel.settings = - lib.mkIf (config.stylix.enable && config.stylix.targets.fuzzel.enable) { - colors = { - background = "${base00-hex}${opacity}"; - text = "${base05-hex}ff"; - placeholder = "${base03-hex}ff"; - prompt = "${base05-hex}ff"; - input = "${base05-hex}ff"; - match = "${base0A-hex}ff"; - selection = "${base03-hex}ff"; - selection-text = "${base05-hex}ff"; - selection-match = "${base0A-hex}ff"; - counter = "${base06-hex}ff"; - border = "${base0D-hex}ff"; - }; + lib.mkIf (config.stylix.enable && config.stylix.targets.fuzzel.enable) + { + colors = { + background = "${base00-hex}${opacity}"; + text = "${base05-hex}ff"; + placeholder = "${base03-hex}ff"; + prompt = "${base05-hex}ff"; + input = "${base05-hex}ff"; + match = "${base0A-hex}ff"; + selection = "${base03-hex}ff"; + selection-text = "${base05-hex}ff"; + selection-match = "${base0A-hex}ff"; + counter = "${base06-hex}ff"; + border = "${base0D-hex}ff"; + }; - main = { - font = "${config.stylix.fonts.sansSerif.name}:size=${toString config.stylix.fonts.sizes.popups}"; + main = { + font = "${config.stylix.fonts.sansSerif.name}:size=${toString config.stylix.fonts.sizes.popups}"; + }; }; - }; } diff --git a/modules/gedit/hm.nix b/modules/gedit/hm.nix index 4f974d5b4..03041d211 100644 --- a/modules/gedit/hm.nix +++ b/modules/gedit/hm.nix @@ -6,7 +6,8 @@ let extension = "xml"; }; -in { +in +{ options.stylix.targets.gedit.enable = config.lib.stylix.mkEnableTarget "GEdit" true; diff --git a/modules/gedit/testbed.nix b/modules/gedit/testbed.nix index c645a31dc..8e2e3eb17 100644 --- a/modules/gedit/testbed.nix +++ b/modules/gedit/testbed.nix @@ -1,8 +1,10 @@ { pkgs, ... }: -let package = pkgs.gedit; +let + package = pkgs.gedit; -in { +in +{ stylix.testbed.application = { enable = true; name = "org.gnome.gedit"; @@ -10,4 +12,4 @@ in { }; environment.systemPackages = [ package ]; -} \ No newline at end of file +} diff --git a/modules/ghostty/hm.nix b/modules/ghostty/hm.nix index ce8a77169..80518f7ff 100644 --- a/modules/ghostty/hm.nix +++ b/modules/ghostty/hm.nix @@ -3,53 +3,56 @@ # - `man 5 ghostty` { config, lib, ... }: { - options.stylix.targets.ghostty.enable = config.lib.stylix.mkEnableTarget "Ghostty" true; + options.stylix.targets.ghostty.enable = + config.lib.stylix.mkEnableTarget "Ghostty" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.ghostty.enable) { - programs.ghostty = { - settings = - let - inherit (config.stylix) fonts opacity; - in - { - theme = "stylix"; - font-family = [ - fonts.monospace.name - fonts.emoji.name - ]; - font-size = fonts.sizes.terminal; - background-opacity = opacity.terminal; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.ghostty.enable) + { + programs.ghostty = { + settings = + let + inherit (config.stylix) fonts opacity; + in + { + theme = "stylix"; + font-family = [ + fonts.monospace.name + fonts.emoji.name + ]; + font-size = fonts.sizes.terminal; + background-opacity = opacity.terminal; + }; + themes.stylix = + let + inherit (config.lib.stylix) colors; + inherit (config.lib.stylix.colors) withHashtag; + in + { + palette = [ + "0=${withHashtag.base03}" + "1=${withHashtag.base08}" + "2=${withHashtag.base0B}" + "3=${withHashtag.base0A}" + "4=${withHashtag.base0D}" + "5=${withHashtag.base0F}" + "6=${withHashtag.base0C}" + "7=${withHashtag.base05}" + "8=${withHashtag.base04}" + "9=${withHashtag.base08}" + "10=${withHashtag.base0B}" + "11=${withHashtag.base0A}" + "12=${withHashtag.base0D}" + "13=${withHashtag.base0F}" + "14=${withHashtag.base0C}" + "15=${withHashtag.base05}" + ]; + background = colors.base00; + foreground = colors.base05; + cursor-color = colors.base06; + selection-background = colors.base02; + selection-foreground = colors.base05; + }; }; - themes.stylix = - let - inherit (config.lib.stylix) colors; - inherit (config.lib.stylix.colors) withHashtag; - in - { - palette = [ - "0=${withHashtag.base03}" - "1=${withHashtag.base08}" - "2=${withHashtag.base0B}" - "3=${withHashtag.base0A}" - "4=${withHashtag.base0D}" - "5=${withHashtag.base0F}" - "6=${withHashtag.base0C}" - "7=${withHashtag.base05}" - "8=${withHashtag.base04}" - "9=${withHashtag.base08}" - "10=${withHashtag.base0B}" - "11=${withHashtag.base0A}" - "12=${withHashtag.base0D}" - "13=${withHashtag.base0F}" - "14=${withHashtag.base0C}" - "15=${withHashtag.base05}" - ]; - background = colors.base00; - foreground = colors.base05; - cursor-color = colors.base06; - selection-background = colors.base02; - selection-foreground = colors.base05; - }; - }; - }; + }; } diff --git a/modules/gitui/hm.nix b/modules/gitui/hm.nix index 9f742fcee..ec939f5bc 100644 --- a/modules/gitui/hm.nix +++ b/modules/gitui/hm.nix @@ -2,7 +2,8 @@ let inherit (config.lib.stylix) colors; - mkRgb = color: + mkRgb = + color: let r = colors."${color}-rgb-r"; g = colors."${color}-rgb-g"; diff --git a/modules/gnome/hm.nix b/modules/gnome/hm.nix index c0cfd2293..ac50b0753 100644 --- a/modules/gnome/hm.nix +++ b/modules/gnome/hm.nix @@ -1,11 +1,17 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let inherit (config.stylix.fonts) sansSerif serif monospace; fontSize = toString config.stylix.fonts.sizes.applications; documentFontSize = toString (config.stylix.fonts.sizes.applications - 1); -in { +in +{ options.stylix.targets.gnome.enable = config.lib.stylix.mkEnableTarget "GNOME" true; @@ -13,19 +19,21 @@ in { dconf.settings = { "org/gnome/desktop/background" = { color-shading-type = "solid"; - picture-options = let - inherit (config.stylix) imageScalingMode; - in - if imageScalingMode == "fit" - then "scaled" - else if imageScalingMode == "fill" - then "zoom" - else if imageScalingMode == "stretch" - then "stretched" - else if imageScalingMode == "center" - then "centered" + picture-options = + let + inherit (config.stylix) imageScalingMode; + in + if imageScalingMode == "fit" then + "scaled" + else if imageScalingMode == "fill" then + "zoom" + else if imageScalingMode == "stretch" then + "stretched" + else if imageScalingMode == "center" then + "centered" # Seemingly no tile support... :( - else "zoom"; + else + "zoom"; picture-uri = "file://${config.stylix.image}"; picture-uri-dark = "file://${config.stylix.image}"; }; @@ -35,9 +43,7 @@ in { # settings tile is removed. The value is still used by Epiphany to # request dark mode for websites which support it. color-scheme = - if config.stylix.polarity == "dark" - then "prefer-dark" - else "default"; + if config.stylix.polarity == "dark" then "prefer-dark" else "default"; # Some GTK apps will use these font settings if they exist. # i.e emacs-pgtk. @@ -51,10 +57,12 @@ in { xdg.dataFile."themes/Stylix/gnome-shell/gnome-shell.css" = { source = - let theme = pkgs.callPackage ./theme.nix { - inherit (config.lib.stylix) colors templates; - }; - in "${theme}/share/gnome-shell/gnome-shell.css"; + 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 gnome-extensions disable user-theme@gnome-shell-extensions.gcampax.github.com diff --git a/modules/gnome/nixos.nix b/modules/gnome/nixos.nix index 7d0ce3d46..63887a567 100644 --- a/modules/gnome/nixos.nix +++ b/modules/gnome/nixos.nix @@ -1,51 +1,68 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: let theme = pkgs.callPackage ./theme.nix { inherit (config.lib.stylix) colors templates; }; -in { +in +{ options.stylix.targets.gnome.enable = config.lib.stylix.mkEnableTarget "GNOME and GDM" true; - config = lib.mkIf ( - config.stylix.enable - && config.stylix.targets.gnome.enable - && (config.services.xserver.desktopManager.gnome.enable || - config.services.xserver.displayManager.gdm.enable) - ) { - # As Stylix is controlling the wallpaper, there is no need for this - # pack of default wallpapers to be installed. - # If you want to use one, you can set stylix.image to something like - # "${pkgs.gnome-backgrounds}/path/to/your/preferred/background" - # which will then download the pack regardless of its exclusion below. - environment.gnome.excludePackages = [ pkgs.gnome-backgrounds ]; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.gnome.enable + && ( + config.services.xserver.desktopManager.gnome.enable + || config.services.xserver.displayManager.gdm.enable + ) + ) + { + # As Stylix is controlling the wallpaper, there is no need for this + # pack of default wallpapers to be installed. + # If you want to use one, you can set stylix.image to something like + # "${pkgs.gnome-backgrounds}/path/to/your/preferred/background" + # which will then download the pack regardless of its exclusion below. + environment.gnome.excludePackages = [ pkgs.gnome-backgrounds ]; - nixpkgs.overlays = [(_: super: { - gnome-shell = super.gnome-shell.overrideAttrs (oldAttrs: { - # Themes are usually applied via an extension, but extensions are - # not available on the login screen. The only way to change the - # theme there is by replacing the default. - postFixup = (oldAttrs.postFixup or "") + '' - cp ${theme}/share/gnome-shell/gnome-shell-theme.gresource \ - $out/share/gnome-shell/gnome-shell-theme.gresource - ''; - patches = (oldAttrs.patches or []) ++ [ - ./shell_remove_dark_mode.patch + nixpkgs.overlays = [ + (_: super: { + gnome-shell = super.gnome-shell.overrideAttrs (oldAttrs: { + # Themes are usually applied via an extension, but extensions are + # not available on the login screen. The only way to change the + # theme there is by replacing the default. + postFixup = + (oldAttrs.postFixup or "") + + '' + cp ${theme}/share/gnome-shell/gnome-shell-theme.gresource \ + $out/share/gnome-shell/gnome-shell-theme.gresource + ''; + patches = (oldAttrs.patches or [ ]) ++ [ + ./shell_remove_dark_mode.patch + ]; + }); + }) ]; - }); - })]; - # Cursor settings are usually applied via Home Manager, - # but the login screen uses a separate database. - environment.systemPackages = [ config.stylix.cursor.package ]; - programs.dconf.profiles.gdm.databases = [{ - lockAll = true; - settings."org/gnome/desktop/interface" = { - cursor-theme = config.stylix.cursor.name; - cursor-size = lib.gvariant.mkInt32 config.stylix.cursor.size; + # Cursor settings are usually applied via Home Manager, + # but the login screen uses a separate database. + environment.systemPackages = [ config.stylix.cursor.package ]; + programs.dconf.profiles.gdm.databases = [ + { + lockAll = true; + settings."org/gnome/desktop/interface" = { + cursor-theme = config.stylix.cursor.name; + cursor-size = lib.gvariant.mkInt32 config.stylix.cursor.size; + }; + } + ]; }; - }]; - }; } diff --git a/modules/gnome/theme.nix b/modules/gnome/theme.nix index 6a6ea7c96..c4bd8c903 100644 --- a/modules/gnome/theme.nix +++ b/modules/gnome/theme.nix @@ -1,4 +1,10 @@ -{ stdenv, sass, glib, colors, templates }: +{ + stdenv, + sass, + glib, + colors, + templates, +}: let colorsScss = colors { @@ -6,7 +12,8 @@ let extension = "scss"; }; -in stdenv.mkDerivation { +in +stdenv.mkDerivation { name = "${colors.slug}-gnome-shell-theme"; src = templates.gnome-shell; patches = [ ./shell_colors.patch ]; @@ -15,7 +22,10 @@ in stdenv.mkDerivation { cp ${colorsScss} data/theme/gnome-shell-sass/_colors.scss ''; - nativeBuildInputs = [ sass glib.dev ]; + nativeBuildInputs = [ + sass + glib.dev + ]; buildPhase = '' sass data/theme/gnome-shell-light.scss \ >data/theme/gnome-shell-light.css diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix index c95b13652..d49cc1c49 100644 --- a/modules/grub/nixos.nix +++ b/modules/grub/nixos.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.lib.stylix; with config.stylix.fonts; @@ -7,34 +12,38 @@ with config.lib.stylix.colors.withHashtag; let # Grub requires fonts to be converted to "PFF2 format" # This function takes a font { name, package } and produces a .pf2 file - mkGrubFont = font: - pkgs.runCommand "${font.package.name}.pf2" { - FONTCONFIG_FILE = - pkgs.makeFontsConf { fontDirectories = [ font.package ]; }; - } '' - # Use fontconfig to select the correct .ttf or .otf file based on name - font=$( - ${lib.getExe' pkgs.fontconfig "fc-match"} \ - ${lib.escapeShellArg font.name} \ - --format=%{file} - ) - - # Convert to .pf2 - ${pkgs.grub2}/bin/grub-mkfont $font --output $out --size ${toString sizes.applications} - ''; + mkGrubFont = + font: + pkgs.runCommand "${font.package.name}.pf2" + { + FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [ font.package ]; }; + } + '' + # Use fontconfig to select the correct .ttf or .otf file based on name + font=$( + ${lib.getExe' pkgs.fontconfig "fc-match"} \ + ${lib.escapeShellArg font.name} \ + --format=%{file} + ) + + # Convert to .pf2 + ${pkgs.grub2}/bin/grub-mkfont $font --output $out --size ${toString sizes.applications} + ''; inherit (config.stylix) imageScalingMode; image-scale = - if imageScalingMode == "fill" - then "crop" - else if imageScalingMode == "fit" - then "fitheight" - else if imageScalingMode == "center" - then "padding" + if imageScalingMode == "fill" then + "crop" + else if imageScalingMode == "fit" then + "fitheight" + else if imageScalingMode == "center" then + "padding" # Grub doesn't seem to support tile - else "crop"; -in { + else + "crop"; +in +{ options.stylix.targets.grub = { enable = config.lib.stylix.mkEnableTarget "GRUB" true; @@ -45,79 +54,87 @@ in { }; }; - config.boot.loader.grub = lib.mkIf (config.stylix.enable && config.stylix.targets.grub.enable) { - backgroundColor = base00; - # Need to override the NixOS splash, this will match the background - splashImage = pixel "base00"; - - # This font will be used for the GRUB terminal - font = toString (mkGrubFont monospace); - - # TODO: Include OS icons - theme = pkgs.runCommand "stylix-grub" { - themeTxt = '' - desktop-image: "background.png" - desktop-image-scale-method: "${image-scale}" - desktop-color: "${base00}" - - title-text: "" - - terminal-left: "10%" - terminal-top: "20%" - terminal-width: "80%" - terminal-height: "60%" - - + progress_bar { - left = 25% - top = 80%+20 # 20 pixels below boot menu - width = 50% - height = 30 - - id = "__timeout__" - show_text = true - font = "${sansSerif.name}" - text = "@TIMEOUT_NOTIFICATION_MIDDLE@" - - border_color = "${base00}" - bg_color = "${base00}" - fg_color = "${base0B}" - text_color = "${base05}" - } - - + boot_menu { - left = 25% - top = 20% - width = 50% - height = 60% - menu_pixmap_style = "background_*.png" - - item_height = 40 - item_icon_space = 8 - item_spacing = 0 - item_padding = 0 - item_font = "${sansSerif.name}" - item_color = "${base05}" - - selected_item_color = "${base01}" - selected_item_pixmap_style = "selection_*.png" - } - ''; - passAsFile = [ "themeTxt" ]; - } '' - mkdir $out - cp $themeTxtPath $out/theme.txt - - ${if config.stylix.targets.grub.useImage - # Make sure the background image is .png by asking to convert it - then - "${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png" - else - "cp ${pixel "base00"} $out/background.png"} - - cp ${pixel "base01"} $out/background_c.png - cp ${pixel "base0B"} $out/selection_c.png - - cp ${mkGrubFont sansSerif} $out/sans_serif.pf2 - ''; - }; + config.boot.loader.grub = + lib.mkIf (config.stylix.enable && config.stylix.targets.grub.enable) + { + backgroundColor = base00; + # Need to override the NixOS splash, this will match the background + splashImage = pixel "base00"; + + # This font will be used for the GRUB terminal + font = toString (mkGrubFont monospace); + + # TODO: Include OS icons + theme = + pkgs.runCommand "stylix-grub" + { + themeTxt = '' + desktop-image: "background.png" + desktop-image-scale-method: "${image-scale}" + desktop-color: "${base00}" + + title-text: "" + + terminal-left: "10%" + terminal-top: "20%" + terminal-width: "80%" + terminal-height: "60%" + + + progress_bar { + left = 25% + top = 80%+20 # 20 pixels below boot menu + width = 50% + height = 30 + + id = "__timeout__" + show_text = true + font = "${sansSerif.name}" + text = "@TIMEOUT_NOTIFICATION_MIDDLE@" + + border_color = "${base00}" + bg_color = "${base00}" + fg_color = "${base0B}" + text_color = "${base05}" + } + + + boot_menu { + left = 25% + top = 20% + width = 50% + height = 60% + menu_pixmap_style = "background_*.png" + + item_height = 40 + item_icon_space = 8 + item_spacing = 0 + item_padding = 0 + item_font = "${sansSerif.name}" + item_color = "${base05}" + + selected_item_color = "${base01}" + selected_item_pixmap_style = "selection_*.png" + } + ''; + passAsFile = [ "themeTxt" ]; + } + '' + mkdir $out + cp $themeTxtPath $out/theme.txt + + ${ + if + config.stylix.targets.grub.useImage + # Make sure the background image is .png by asking to convert it + then + "${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png" + else + "cp ${pixel "base00"} $out/background.png" + } + + cp ${pixel "base01"} $out/background_c.png + cp ${pixel "base0B"} $out/selection_c.png + + cp ${mkGrubFont sansSerif} $out/sans_serif.pf2 + ''; + }; } diff --git a/modules/gtk/hm.nix b/modules/gtk/hm.nix index 70e49f4f4..e3e8d5964 100644 --- a/modules/gtk/hm.nix +++ b/modules/gtk/hm.nix @@ -1,4 +1,10 @@ -{ pkgs, config, lib, options, ... }: +{ + pkgs, + config, + lib, + options, + ... +}: let cfg = config.stylix.targets.gtk; @@ -8,14 +14,14 @@ let extension = "css"; }; - finalCss = pkgs.runCommandLocal "gtk.css" {} '' + finalCss = pkgs.runCommandLocal "gtk.css" { } '' cat ${baseCss} >>$out echo ${lib.escapeShellArg cfg.extraCss} >>$out ''; -in { +in +{ options.stylix.targets.gtk = { - enable = config.lib.stylix.mkEnableTarget - "all GTK3, GTK4 and Libadwaita apps" true; + enable = config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; extraCss = lib.mkOption { description = '' @@ -29,69 +35,75 @@ in { ''; }; - flatpakSupport.enable = - config.lib.stylix.mkEnableTarget "support for theming Flatpak apps" true; + flatpakSupport.enable = config.lib.stylix.mkEnableTarget "support for theming Flatpak apps" true; }; - config = lib.mkIf cfg.enable (lib.mkMerge [ - { - # programs.dconf.enable = true; required in system config - gtk = { - enable = true; - font = { - inherit (config.stylix.fonts.sansSerif) package name; - size = config.stylix.fonts.sizes.applications; - }; - theme = { - package = pkgs.adw-gtk3; - name = "adw-gtk3"; - }; - }; - - xdg.configFile = { - "gtk-3.0/gtk.css".source = finalCss; - "gtk-4.0/gtk.css".source = finalCss; - }; - } - - (lib.mkIf cfg.flatpakSupport.enable (lib.mkMerge [ + config = lib.mkIf cfg.enable ( + lib.mkMerge [ { - # Flatpak apps apparently don't consume the CSS config. This workaround appends it to the theme directly. - home.file.".themes/${config.gtk.theme.name}".source = pkgs.stdenvNoCC.mkDerivation { - name = "flattenedGtkTheme"; - src = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}"; + # programs.dconf.enable = true; required in system config + gtk = { + enable = true; + font = { + inherit (config.stylix.fonts.sansSerif) package name; + size = config.stylix.fonts.sizes.applications; + }; + theme = { + package = pkgs.adw-gtk3; + name = "adw-gtk3"; + }; + }; - installPhase = '' - cp --recursive . $out - cat ${finalCss} | tee --append $out/gtk-{3,4}.0/gtk.css - ''; + xdg.configFile = { + "gtk-3.0/gtk.css".source = finalCss; + "gtk-4.0/gtk.css".source = finalCss; }; } - ( - let - filesystem = "${config.home.homeDirectory}/.themes/${config.gtk.theme.name}:ro"; - theme = config.gtk.theme.name; - in - if options ? services.flatpak.overrides - then { - # Let Flatpak apps read the theme and force them to use it. - # This requires nix-flatpak to be imported externally. - services.flatpak.overrides.global = { - Context.filesystems = [filesystem]; - Environment.GTK_THEME = theme; - }; - } - else { - # This is likely incompatible with other modules that write to this file. - xdg.dataFile."flatpak/overrides/global".text = '' - [Context] - filesystems=${filesystem} - [Environment] - GTK_THEME=${theme} - ''; + (lib.mkIf cfg.flatpakSupport.enable ( + lib.mkMerge [ + { + # Flatpak apps apparently don't consume the CSS config. This workaround appends it to the theme directly. + home.file.".themes/${config.gtk.theme.name}".source = + pkgs.stdenvNoCC.mkDerivation + { + name = "flattenedGtkTheme"; + src = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}"; + + installPhase = '' + cp --recursive . $out + cat ${finalCss} | tee --append $out/gtk-{3,4}.0/gtk.css + ''; + }; } - ) - ])) - ]); + ( + let + filesystem = "${config.home.homeDirectory}/.themes/${config.gtk.theme.name}:ro"; + theme = config.gtk.theme.name; + in + if options ? services.flatpak.overrides then + { + # Let Flatpak apps read the theme and force them to use it. + # This requires nix-flatpak to be imported externally. + services.flatpak.overrides.global = { + Context.filesystems = [ filesystem ]; + Environment.GTK_THEME = theme; + }; + } + else + { + # This is likely incompatible with other modules that write to this file. + xdg.dataFile."flatpak/overrides/global".text = '' + [Context] + filesystems=${filesystem} + + [Environment] + GTK_THEME=${theme} + ''; + } + ) + ] + )) + ] + ); } diff --git a/modules/helix/hm.nix b/modules/helix/hm.nix index b1e7ee69e..5c137c624 100644 --- a/modules/helix/hm.nix +++ b/modules/helix/hm.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let theme = config.lib.stylix.colors { @@ -8,20 +13,26 @@ let # Removing the background exposes transparency from the terminal. The # background might be helpful if the terminal isn't themed, so we only # do this if transparency is actually enabled. - transparentTheme = pkgs.runCommandLocal "helix-transparent.toml" {} '' + transparentTheme = pkgs.runCommandLocal "helix-transparent.toml" { } '' sed 's/,\? bg = "base00"//g' <${theme} >$out ''; -in { +in +{ options.stylix.targets.helix.enable = config.lib.stylix.mkEnableTarget "Helix" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.helix.enable && config.programs.helix.enable) { - programs.helix.settings.theme = "stylix"; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.helix.enable + && config.programs.helix.enable + ) + { + programs.helix.settings.theme = "stylix"; - xdg.configFile."helix/themes/stylix.toml".source = - if config.stylix.opacity.terminal == 1.0 - then theme - else transparentTheme; - }; + xdg.configFile."helix/themes/stylix.toml".source = + if config.stylix.opacity.terminal == 1.0 then theme else transparentTheme; + }; } diff --git a/modules/hyprland/hm.nix b/modules/hyprland/hm.nix index 27baaf78a..ad3e5c602 100644 --- a/modules/hyprland/hm.nix +++ b/modules/hyprland/hm.nix @@ -6,50 +6,51 @@ hyprpaper.enable = config.lib.stylix.mkEnableTarget "Hyprpaper" true; }; - config = let - cfg = config.stylix.targets.hyprland; - in + config = + let + cfg = config.stylix.targets.hyprland; + in lib.mkIf - ( - config.stylix.enable - && cfg.enable - && config.wayland.windowManager.hyprland.enable - ) - ( - lib.mkMerge [ - { - wayland.windowManager.hyprland.settings = let - inherit (config.lib.stylix) colors; + ( + config.stylix.enable + && cfg.enable + && config.wayland.windowManager.hyprland.enable + ) + ( + lib.mkMerge [ + { + wayland.windowManager.hyprland.settings = + let + inherit (config.lib.stylix) colors; - rgb = color: "rgb(${color})"; - rgba = color: alpha: "rgba(${color}${alpha})"; - in { - decoration.shadow.color = rgba colors.base00 "99"; - general = { - "col.active_border" = rgb colors.base0D; - "col.inactive_border" = rgb colors.base03; - }; - group = { - "col.border_inactive" = rgb colors.base03; - "col.border_active" = rgb colors.base0D; - "col.border_locked_active" = rgb colors.base0C; + rgb = color: "rgb(${color})"; + rgba = color: alpha: "rgba(${color}${alpha})"; + in + { + decoration.shadow.color = rgba colors.base00 "99"; + general = { + "col.active_border" = rgb colors.base0D; + "col.inactive_border" = rgb colors.base03; + }; + group = { + "col.border_inactive" = rgb colors.base03; + "col.border_active" = rgb colors.base0D; + "col.border_locked_active" = rgb colors.base0C; - groupbar = { - text_color = rgb colors.base05; - "col.active" = rgb colors.base0D; - "col.inactive" = rgb colors.base03; + groupbar = { + text_color = rgb colors.base05; + "col.active" = rgb colors.base0D; + "col.inactive" = rgb colors.base03; + }; + }; + misc.background_color = rgb colors.base00; }; - }; - misc.background_color = rgb colors.base00; - }; - } + } - ( - lib.mkIf cfg.hyprpaper.enable { + (lib.mkIf cfg.hyprpaper.enable { services.hyprpaper.enable = true; stylix.targets.hyprpaper.enable = true; - } - ) - ] - ); + }) + ] + ); } diff --git a/modules/hyprland/testbed.nix b/modules/hyprland/testbed.nix index 36f0be0dd..12ce63c95 100644 --- a/modules/hyprland/testbed.nix +++ b/modules/hyprland/testbed.nix @@ -4,12 +4,14 @@ environment.loginShellInit = lib.getExe pkgs.hyprland; programs.hyprland.enable = true; - home-manager.sharedModules = [{ - wayland.windowManager.hyprland = { - enable = true; + home-manager.sharedModules = [ + { + wayland.windowManager.hyprland = { + enable = true; - # We need something to open a window so that we can check the window borders - settings.bind = [ "ALT, RETURN, exec, ${lib.getExe pkgs.foot}" ]; - }; - }]; + # We need something to open a window so that we can check the window borders + settings.bind = [ "ALT, RETURN, exec, ${lib.getExe pkgs.foot}" ]; + }; + } + ]; } diff --git a/modules/hyprlock/hm.nix b/modules/hyprlock/hm.nix index c54e46166..e3acef98e 100644 --- a/modules/hyprlock/hm.nix +++ b/modules/hyprlock/hm.nix @@ -4,16 +4,18 @@ with config.lib.stylix; { options.stylix.targets.hyprlock.enable = mkEnableTarget "Hyprlock" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.hyprlock.enable) { - programs.hyprlock.settings = { - background.path = "${config.stylix.image}"; - input-field = with colors; { - outer_color = "rgb(${base03})"; - inner_color = "rgb(${base00})"; - font_color = "rgb(${base05})"; - fail_color = "rgb(${base08})"; - check_color = "rgb(${base0A})"; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.hyprlock.enable) + { + programs.hyprlock.settings = { + background.path = "${config.stylix.image}"; + input-field = with colors; { + outer_color = "rgb(${base03})"; + inner_color = "rgb(${base00})"; + font_color = "rgb(${base05})"; + fail_color = "rgb(${base08})"; + check_color = "rgb(${base0A})"; + }; + }; }; - }; - }; } diff --git a/modules/hyprpaper/hm.nix b/modules/hyprpaper/hm.nix index dbb7b08a1..325f05018 100644 --- a/modules/hyprpaper/hm.nix +++ b/modules/hyprpaper/hm.nix @@ -1,14 +1,14 @@ -{ config, lib, ... }: { +{ config, lib, ... }: +{ options.stylix.targets.hyprpaper.enable = config.lib.stylix.mkEnableTarget "Hyprpaper" true; config = - lib.mkIf - (config.stylix.enable && config.stylix.targets.hyprpaper.enable) - { - services.hyprpaper.settings = { - preload = [ "${config.stylix.image}" ]; - wallpaper = [ ",${config.stylix.image}" ]; + lib.mkIf (config.stylix.enable && config.stylix.targets.hyprpaper.enable) + { + services.hyprpaper.settings = { + preload = [ "${config.stylix.image}" ]; + wallpaper = [ ",${config.stylix.image}" ]; + }; }; - }; } diff --git a/modules/i3/hm.nix b/modules/i3/hm.nix index 6004e1cce..794c8cd08 100644 --- a/modules/i3/hm.nix +++ b/modules/i3/hm.nix @@ -8,55 +8,59 @@ let focused = base0D; unfocused = base03; - fonts = let - inherit (config.stylix) fonts; - in { - names = [ fonts.sansSerif.name ]; - size = fonts.sizes.desktop * 1.0; - }; + fonts = + let + inherit (config.stylix) fonts; + in + { + names = [ fonts.sansSerif.name ]; + size = fonts.sizes.desktop * 1.0; + }; -in { - options.stylix.targets.i3.enable = - config.lib.stylix.mkEnableTarget "i3" true; +in +{ + options.stylix.targets.i3.enable = config.lib.stylix.mkEnableTarget "i3" true; config = lib.mkMerge [ (lib.mkIf config.stylix.targets.i3.enable { xsession.windowManager.i3.config = { inherit fonts; - colors = let - background = base00; - indicator = base0B; - in { - inherit background; - urgent = { - inherit background indicator text; - border = urgent; - childBorder = urgent; - }; - focused = { - inherit background indicator text; - border = focused; - childBorder = focused; - }; - focusedInactive = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - unfocused = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - placeholder = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; + colors = + let + background = base00; + indicator = base0B; + in + { + inherit background; + urgent = { + inherit background indicator text; + border = urgent; + childBorder = urgent; + }; + focused = { + inherit background indicator text; + border = focused; + childBorder = focused; + }; + focusedInactive = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + unfocused = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + placeholder = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; }; - }; -# output."*".bg = "${config.stylix.image} fill"; + # output."*".bg = "${config.stylix.image} fill"; }; }) @@ -65,33 +69,35 @@ in { lib.stylix.i3.bar = { inherit fonts; - colors = let - background = base00; - border = background; - in { - inherit background; - statusline = text; - separator = base03; - focusedWorkspace = { - inherit text background; - border = focused; - }; - activeWorkspace = { - inherit border background; - text = focused; - }; - inactiveWorkspace = { - inherit text border background; - }; - urgentWorkspace = { - inherit text background; - border = urgent; - }; - bindingMode = { - inherit text border; - background = urgent; + colors = + let + background = base00; + border = background; + in + { + inherit background; + statusline = text; + separator = base03; + focusedWorkspace = { + inherit text background; + border = focused; + }; + activeWorkspace = { + inherit border background; + text = focused; + }; + inactiveWorkspace = { + inherit text border background; + }; + urgentWorkspace = { + inherit text background; + border = urgent; + }; + bindingMode = { + inherit text border; + background = urgent; + }; }; - }; }; } ]; diff --git a/modules/k9s/hm.nix b/modules/k9s/hm.nix index 56f8b2729..0706ce331 100644 --- a/modules/k9s/hm.nix +++ b/modules/k9s/hm.nix @@ -3,8 +3,7 @@ with config.lib.stylix.colors.withHashtag; { - options.stylix.targets.k9s.enable = - config.lib.stylix.mkEnableTarget "k9s" true; + options.stylix.targets.k9s.enable = config.lib.stylix.mkEnableTarget "k9s" true; config = lib.mkIf config.stylix.targets.k9s.enable { programs.k9s.skins.skin = { @@ -77,8 +76,14 @@ with config.lib.stylix.colors.withHashtag; views = { charts = { bgColor = "default"; - defaultDialColors = [ base0C-hex base0D-hex ]; - defaultChartColors = [ base0C-hex base0D-hex ]; + defaultDialColors = [ + base0C-hex + base0D-hex + ]; + defaultChartColors = [ + base0C-hex + base0D-hex + ]; }; table = { diff --git a/modules/kde/hm.nix b/modules/kde/hm.nix index 931cd9447..f1db5d8d2 100644 --- a/modules/kde/hm.nix +++ b/modules/kde/hm.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.stylix.fonts; with config.lib.stylix.colors; @@ -6,12 +11,15 @@ with config.lib.stylix.colors; let cfg = config.stylix.targets.kde; - formatValue = value: - if builtins.isBool value - then if value then "true" else "false" - else builtins.toString value; + formatValue = + value: + if builtins.isBool value then + if value then "true" else "false" + else + builtins.toString value; - formatSection = path: data: + formatSection = + path: data: let header = lib.concatStrings (map (p: "[${p}]") path); formatChild = name: formatLines (path ++ [ name ]); @@ -20,23 +28,24 @@ let directChildren = partitioned.right; indirectChildren = partitioned.wrong; in - lib.optional (directChildren != []) header ++ - directChildren ++ - lib.flatten indirectChildren; - - formatLines = path: data: - if builtins.isAttrs data - then - if data?_immutable - then - if builtins.isAttrs data.value - then formatSection (path ++ [ "$i" ]) data.value - else "${lib.last path}[$i]=${formatValue data.value}" - else formatSection path data - else "${lib.last path}=${formatValue data}"; - - formatConfig = data: - lib.concatStringsSep "\n" (formatLines [] data); + lib.optional (directChildren != [ ]) header + ++ directChildren + ++ lib.flatten indirectChildren; + + formatLines = + path: data: + if builtins.isAttrs data then + if data ? _immutable then + if builtins.isAttrs data.value then + formatSection (path ++ [ "$i" ]) data.value + else + "${lib.last path}[$i]=${formatValue data.value}" + else + formatSection path data + else + "${lib.last path}=${formatValue data}"; + + formatConfig = data: lib.concatStringsSep "\n" (formatLines [ ] data); # Marking a setting as immutable should prevent it being overwritten # through the system settings menu. @@ -48,9 +57,9 @@ let # PascalCase is the standard naming for color scheme files. Schemes named # in kebab-case will load when selected manually, but don't work with a # look and feel package. - colorschemeSlug = lib.concatStrings - (builtins.filter builtins.isString - (builtins.split "[^a-zA-Z]" scheme)); + colorschemeSlug = lib.concatStrings ( + builtins.filter builtins.isString (builtins.split "[^a-zA-Z]" scheme) + ); colorEffect = { ColorEffect = 0; @@ -143,41 +152,44 @@ let # Contains a wallpaper package, a colorscheme file, and a look and feel # package which depends on both. - themePackage = pkgs.runCommandLocal "stylix-kde-theme" { - colorscheme = formatConfig colorscheme; - wallpaperMetadata = builtins.toJSON wallpaperMetadata; - wallpaperImage = config.stylix.image; - lookAndFeelMetadata = builtins.toJSON lookAndFeelMetadata; - lookAndFeelDefaults = formatConfig lookAndFeelDefaults; - } '' - write_text() { - mkdir --parents "$(dirname "$2")" - printf '%s\n' "$1" >"$2" - } - - PATH="${pkgs.imagemagick}/bin:$PATH" - - wallpaper="$out/share/wallpapers/stylix" - look_and_feel="$out/share/plasma/look-and-feel/stylix" - - mkdir --parents "$wallpaper/contents/images" - - magick \ - "$wallpaperImage" \ - -thumbnail 400x250 \ - "$wallpaper/contents/screenshot.png" - - dimensions="$(identify -ping -format '%wx%h' "$wallpaperImage")" - magick "$wallpaperImage" "$wallpaper/contents/images/$dimensions.png" - - write_text \ - "$colorscheme" \ - "$out/share/color-schemes/${colorschemeSlug}.colors" - - write_text "$wallpaperMetadata" "$wallpaper/metadata.json" - write_text "$lookAndFeelMetadata" "$look_and_feel/metadata.json" - write_text "$lookAndFeelDefaults" "$look_and_feel/contents/defaults" - ''; + themePackage = + pkgs.runCommandLocal "stylix-kde-theme" + { + colorscheme = formatConfig colorscheme; + wallpaperMetadata = builtins.toJSON wallpaperMetadata; + wallpaperImage = config.stylix.image; + lookAndFeelMetadata = builtins.toJSON lookAndFeelMetadata; + lookAndFeelDefaults = formatConfig lookAndFeelDefaults; + } + '' + write_text() { + mkdir --parents "$(dirname "$2")" + printf '%s\n' "$1" >"$2" + } + + PATH="${pkgs.imagemagick}/bin:$PATH" + + wallpaper="$out/share/wallpapers/stylix" + look_and_feel="$out/share/plasma/look-and-feel/stylix" + + mkdir --parents "$wallpaper/contents/images" + + magick \ + "$wallpaperImage" \ + -thumbnail 400x250 \ + "$wallpaper/contents/screenshot.png" + + dimensions="$(identify -ping -format '%wx%h' "$wallpaperImage")" + magick "$wallpaperImage" "$wallpaper/contents/images/$dimensions.png" + + write_text \ + "$colorscheme" \ + "$out/share/color-schemes/${colorschemeSlug}.colors" + + write_text "$wallpaperMetadata" "$wallpaper/metadata.json" + write_text "$lookAndFeelMetadata" "$look_and_feel/metadata.json" + write_text "$lookAndFeelDefaults" "$look_and_feel/contents/defaults" + ''; # The cursor theme can be configured through a look and feel package, # however its size cannot. @@ -211,17 +223,20 @@ let }; }; - configPackage = pkgs.runCommandLocal "stylix-kde-config" { - kcminputrc = formatConfig kcminputrc; - kded5rc = formatConfig kded5rc; - kdeglobals = formatConfig kdeglobals; - } '' - mkdir "$out" - - printf '%s\n' "$kcminputrc" >"$out/kcminputrc" - printf '%s\n' "$kded5rc" >"$out/kded5rc" - printf '%s\n' "$kdeglobals" >"$out/kdeglobals" - ''; + configPackage = + pkgs.runCommandLocal "stylix-kde-config" + { + kcminputrc = formatConfig kcminputrc; + kded5rc = formatConfig kded5rc; + kdeglobals = formatConfig kdeglobals; + } + '' + mkdir "$out" + + printf '%s\n' "$kcminputrc" >"$out/kcminputrc" + printf '%s\n' "$kded5rc" >"$out/kded5rc" + printf '%s\n' "$kdeglobals" >"$out/kdeglobals" + ''; # plasma-apply-wallpaperimage is necessary to change the wallpaper # after the first login. @@ -263,33 +278,37 @@ let ''; activateDocs = "https://stylix.danth.me/options/hm.html#stylixtargetskdeservice"; -in { +in +{ options.stylix.targets.kde.enable = config.lib.stylix.mkEnableTarget "KDE" true; - config = lib.mkIf (config.stylix.enable && cfg.enable && pkgs.stdenv.hostPlatform.isLinux) { - home = { - packages = [ themePackage ]; - - # This activation entry will run the theme activator when the homeConfiguration is activated - # Note: This only works in an already running Plasma session. - activation.stylixLookAndFeel = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - ${lib.getExe activator} || verboseEcho \ - "KDE theme setting failed. See `${activateDocs}`" - ''; - }; - - xdg = { - systemDirs.config = [ "${configPackage}" ]; - - # This desktop entry will run the theme activator when a new Plasma session is started - # Note: This doesn't run again if a new homeConfiguration is activated from a running Plasma session - configFile."autostart/stylix-activator.desktop".text = '' - [Desktop Entry] - Type=Application - Exec=${lib.getExe activator} - Name=Stylix Activator - X-KDE-AutostartScript=true - ''; - }; - }; + config = + lib.mkIf + (config.stylix.enable && cfg.enable && pkgs.stdenv.hostPlatform.isLinux) + { + home = { + packages = [ themePackage ]; + + # This activation entry will run the theme activator when the homeConfiguration is activated + # Note: This only works in an already running Plasma session. + activation.stylixLookAndFeel = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + ${lib.getExe activator} || verboseEcho \ + "KDE theme setting failed. See `${activateDocs}`" + ''; + }; + + xdg = { + systemDirs.config = [ "${configPackage}" ]; + + # This desktop entry will run the theme activator when a new Plasma session is started + # Note: This doesn't run again if a new homeConfiguration is activated from a running Plasma session + configFile."autostart/stylix-activator.desktop".text = '' + [Desktop Entry] + Type=Application + Exec=${lib.getExe activator} + Name=Stylix Activator + X-KDE-AutostartScript=true + ''; + }; + }; } diff --git a/modules/kitty/hm.nix b/modules/kitty/hm.nix index afd517682..b63da52a5 100644 --- a/modules/kitty/hm.nix +++ b/modules/kitty/hm.nix @@ -6,7 +6,8 @@ let templateRepo = config.lib.stylix.templates.tinted-kitty; target = if cfg.variant256Colors then "default-256" else "default"; }; -in { +in +{ options.stylix.targets.kitty = { enable = config.lib.stylix.mkEnableTarget "Kitty" true; @@ -26,7 +27,9 @@ in { inherit (config.stylix.fonts.monospace) package name; size = config.stylix.fonts.sizes.terminal; }; - settings.background_opacity = with config.stylix.opacity; "${builtins.toString terminal}"; + settings.background_opacity = + with config.stylix.opacity; + "${builtins.toString terminal}"; extraConfig = '' include ${theme} ''; diff --git a/modules/kitty/testbed.nix b/modules/kitty/testbed.nix index 225ccd621..3f610764d 100644 --- a/modules/kitty/testbed.nix +++ b/modules/kitty/testbed.nix @@ -1,18 +1,22 @@ { pkgs, ... }: -let package = pkgs.kitty; +let + package = pkgs.kitty; -in { +in +{ stylix.testbed.application = { enable = true; name = "kitty"; inherit package; }; - home-manager.sharedModules = [{ - programs.kitty = { - enable = true; - inherit package; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.kitty = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/kmscon/nixos.nix b/modules/kmscon/nixos.nix index 791894abf..c9ab88c04 100644 --- a/modules/kmscon/nixos.nix +++ b/modules/kmscon/nixos.nix @@ -3,39 +3,43 @@ options.stylix.targets.kmscon.enable = config.lib.stylix.mkEnableTarget "the kmscon virtual console" true; - config.services.kmscon = lib.mkIf (config.stylix.enable && config.stylix.targets.kmscon.enable) { - fonts = [config.stylix.fonts.monospace]; - extraConfig = - let - formatBase = name: - let - getComponent = comp: config.lib.stylix.colors."${name}-rgb-${comp}"; - in - "${getComponent "r"},${getComponent "g"},${getComponent "b"}"; - in '' - font-size=${builtins.toString config.stylix.fonts.sizes.terminal} + config.services.kmscon = + lib.mkIf (config.stylix.enable && config.stylix.targets.kmscon.enable) + { + fonts = [ config.stylix.fonts.monospace ]; + extraConfig = + let + formatBase = + name: + let + getComponent = comp: config.lib.stylix.colors."${name}-rgb-${comp}"; + in + "${getComponent "r"},${getComponent "g"},${getComponent "b"}"; + in + '' + font-size=${builtins.toString config.stylix.fonts.sizes.terminal} - palette=custom + palette=custom - palette-black=${formatBase "base00"} - palette-red=${formatBase "base08"} - palette-green=${formatBase "base0B"} - palette-yellow=${formatBase "base0A"} - palette-blue=${formatBase "base0D"} - palette-magenta=${formatBase "base0E"} - palette-cyan=${formatBase "base0C"} - palette-light-grey=${formatBase "base05"} - palette-dark-grey=${formatBase "base03"} - palette-light-red=${formatBase "base08"} - palette-light-green=${formatBase "base0B"} - palette-light-yellow=${formatBase "base0A"} - palette-light-blue=${formatBase "base0D"} - palette-light-magenta=${formatBase "base0E"} - palette-light-cyan=${formatBase "base0C"} - palette-white=${formatBase "base07"} + palette-black=${formatBase "base00"} + palette-red=${formatBase "base08"} + palette-green=${formatBase "base0B"} + palette-yellow=${formatBase "base0A"} + palette-blue=${formatBase "base0D"} + palette-magenta=${formatBase "base0E"} + palette-cyan=${formatBase "base0C"} + palette-light-grey=${formatBase "base05"} + palette-dark-grey=${formatBase "base03"} + palette-light-red=${formatBase "base08"} + palette-light-green=${formatBase "base0B"} + palette-light-yellow=${formatBase "base0A"} + palette-light-blue=${formatBase "base0D"} + palette-light-magenta=${formatBase "base0E"} + palette-light-cyan=${formatBase "base0C"} + palette-white=${formatBase "base07"} - palette-background=${formatBase "base00"} - palette-foreground=${formatBase "base05"} - ''; - }; + palette-background=${formatBase "base00"} + palette-foreground=${formatBase "base05"} + ''; + }; } diff --git a/modules/kubecolor/hm.nix b/modules/kubecolor/hm.nix index 378e3fcb5..942eee0ad 100644 --- a/modules/kubecolor/hm.nix +++ b/modules/kubecolor/hm.nix @@ -1,10 +1,12 @@ { config, lib, ... }: { - options.stylix.targets.kubecolor.enable = config.lib.stylix.mkEnableTarget "kubecolor" true; + options.stylix.targets.kubecolor.enable = + config.lib.stylix.mkEnableTarget "kubecolor" true; config = lib.mkIf config.stylix.targets.kubecolor.enable { programs.kubecolor.settings = { - preset = if config.stylix.polarity == "either" then "" else "${config.stylix.polarity}"; + preset = + if config.stylix.polarity == "either" then "" else "${config.stylix.polarity}"; theme = { base = { info = "fg=${config.lib.stylix.colors.withHashtag.base05-hex}"; diff --git a/modules/lazygit/hm.nix b/modules/lazygit/hm.nix index 94ea43808..59f6a0b70 100644 --- a/modules/lazygit/hm.nix +++ b/modules/lazygit/hm.nix @@ -2,25 +2,33 @@ config, lib, ... -}: let +}: +let colors = config.lib.stylix.colors.withHashtag; -in { - options.stylix.targets.lazygit.enable = config.lib.stylix.mkEnableTarget "lazygit" true; +in +{ + options.stylix.targets.lazygit.enable = + config.lib.stylix.mkEnableTarget "lazygit" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.lazygit.enable) { - programs.lazygit.settings.gui.theme = { - activeBorderColor = [ - colors.base07 - "bold" - ]; - inactiveBorderColor = [colors.base04]; - searchingActiveBorderColor = [colors.base02 "bold"]; - optionsTextColor = [colors.base06]; - selectedLineBgColor = [colors.base03]; - cherryPickedCommitBgColor = [colors.base02]; - cherryPickedCommitFgColor = [colors.base03]; - unstagedChangesColor = [colors.base08]; - defaultFgColor = [colors.base05]; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.lazygit.enable) + { + programs.lazygit.settings.gui.theme = { + activeBorderColor = [ + colors.base07 + "bold" + ]; + inactiveBorderColor = [ colors.base04 ]; + searchingActiveBorderColor = [ + colors.base02 + "bold" + ]; + optionsTextColor = [ colors.base06 ]; + selectedLineBgColor = [ colors.base03 ]; + cherryPickedCommitBgColor = [ colors.base02 ]; + cherryPickedCommitFgColor = [ colors.base03 ]; + unstagedChangesColor = [ colors.base08 ]; + defaultFgColor = [ colors.base05 ]; + }; + }; } diff --git a/modules/lightdm/nixos.nix b/modules/lightdm/nixos.nix index e0ea1d382..36873584a 100644 --- a/modules/lightdm/nixos.nix +++ b/modules/lightdm/nixos.nix @@ -4,6 +4,7 @@ options.stylix.targets.lightdm.enable = config.lib.stylix.mkEnableTarget "LightDM" true; - config.services.xserver.displayManager.lightdm.background = - lib.mkIf (config.stylix.enable && config.stylix.targets.lightdm.enable) config.stylix.image; + config.services.xserver.displayManager.lightdm.background = lib.mkIf ( + config.stylix.enable && config.stylix.targets.lightdm.enable + ) config.stylix.image; } diff --git a/modules/mako/hm.nix b/modules/mako/hm.nix index b999b8d38..2acbe1f36 100644 --- a/modules/mako/hm.nix +++ b/modules/mako/hm.nix @@ -1,33 +1,43 @@ -{ 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); -in { + makoOpacity = lib.toHexString ( + ((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100 + ); +in +{ options.stylix.targets.mako.enable = config.lib.stylix.mkEnableTarget "Mako" true; # Referenced https://github.com/stacyharper/base16-mako - config = lib.optionalAttrs (options.services ? mako) (lib.mkIf (config.stylix.enable && config.stylix.targets.mako.enable) { - services.mako = { - backgroundColor = base00 + makoOpacity; - borderColor = base0D; - textColor = base05; - progressColor = "over ${base02}"; - font = "${sansSerif.name} ${toString sizes.popups}"; - # I wish the mako hm module was like the dunst one - extraConfig = '' - [urgency=low] - background-color=${base00}${makoOpacity} - border-color=${base0D} - text-color=${base0A} + config = lib.optionalAttrs (options.services ? mako) ( + lib.mkIf (config.stylix.enable && config.stylix.targets.mako.enable) { + services.mako = { + backgroundColor = base00 + makoOpacity; + borderColor = base0D; + textColor = base05; + progressColor = "over ${base02}"; + font = "${sansSerif.name} ${toString sizes.popups}"; + # I wish the mako hm module was like the dunst one + extraConfig = '' + [urgency=low] + background-color=${base00}${makoOpacity} + border-color=${base0D} + text-color=${base0A} - [urgency=high] - background-color=${base00}${makoOpacity} - border-color=${base0D} - text-color=${base08} - ''; - }; - }); + [urgency=high] + background-color=${base00}${makoOpacity} + border-color=${base0D} + text-color=${base08} + ''; + }; + } + ); } diff --git a/modules/mangohud/hm.nix b/modules/mangohud/hm.nix index d13deedf1..53ee28808 100644 --- a/modules/mangohud/hm.nix +++ b/modules/mangohud/hm.nix @@ -1,37 +1,41 @@ { config, lib, ... }: let - inherit (config.stylix) fonts opacity; - inherit (config.lib.stylix) colors; -in { - options.stylix.targets.mangohud.enable = config.lib.stylix.mkEnableTarget "mangohud" true; + inherit (config.stylix) fonts opacity; + inherit (config.lib.stylix) colors; +in +{ + options.stylix.targets.mangohud.enable = + config.lib.stylix.mkEnableTarget "mangohud" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.mangohud.enable) { + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.mangohud.enable) + { programs.mangohud.settings = with colors; { - font_size = fonts.sizes.applications; - font_size_text = fonts.sizes.applications; - background_alpha = opacity.popups; - alpha = opacity.applications; - text_color = base05; - text_outline_color = base00; - background_color = base00; - gpu_color = base0B; - cpu_color = base0D; - vram_color = base0C; - media_player_color = base05; - engine_color = base0E; - wine_color = base0E; - frametime_color = base0B; - battery_color = base04; - io_color = base0A; - gpu_load_color = "${base0B}, ${base0A}, ${base08}"; - cpu_load_color = "${base0B}, ${base0A}, ${base08}"; - fps_color = "${base0B}, ${base0A}, ${base08}"; + font_size = fonts.sizes.applications; + font_size_text = fonts.sizes.applications; + background_alpha = opacity.popups; + alpha = opacity.applications; + text_color = base05; + text_outline_color = base00; + background_color = base00; + gpu_color = base0B; + cpu_color = base0D; + vram_color = base0C; + media_player_color = base05; + engine_color = base0E; + wine_color = base0E; + frametime_color = base0B; + battery_color = base04; + io_color = base0A; + gpu_load_color = "${base0B}, ${base0A}, ${base08}"; + cpu_load_color = "${base0B}, ${base0A}, ${base08}"; + fps_color = "${base0B}, ${base0A}, ${base08}"; - # TODO: Use the point unit: - # https://github.com/danth/stylix/issues/251. - font_scale = 1.33333; + # TODO: Use the point unit: + # https://github.com/danth/stylix/issues/251. + font_scale = 1.33333; }; - }; + }; } diff --git a/modules/micro/hm.nix b/modules/micro/hm.nix index fd1639571..540f4abb2 100644 --- a/modules/micro/hm.nix +++ b/modules/micro/hm.nix @@ -2,17 +2,15 @@ config, lib, ... -}: { +}: +{ options.stylix.targets.micro.enable = config.lib.stylix.mkEnableTarget "micro" true; - config = - lib.mkIf - (config.stylix.enable && config.stylix.targets.micro.enable) - { - # TODO: Provide a real colorscheme once [1] is resolved. - # - # [1]: https://github.com/danth/stylix/issues/249 - programs.micro.settings.colorscheme = "simple"; - }; + config = lib.mkIf (config.stylix.enable && config.stylix.targets.micro.enable) { + # TODO: Provide a real colorscheme once [1] is resolved. + # + # [1]: https://github.com/danth/stylix/issues/249 + programs.micro.settings.colorscheme = "simple"; + }; } diff --git a/modules/ncspot/hm.nix b/modules/ncspot/hm.nix index 42491c51d..592dc2fee 100644 --- a/modules/ncspot/hm.nix +++ b/modules/ncspot/hm.nix @@ -4,30 +4,33 @@ options.stylix.targets.ncspot.enable = config.lib.stylix.mkEnableTarget "Ncspot" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.ncspot.enable) { - programs.ncspot.settings = - let - colors = config.lib.stylix.colors.withHashtag; - in { - theme = with colors; { - background = base00; - primary = base05; - secondary = base03; - title = base06; - playing = base05; - playing_selected = base06; - playing_bg = base02; - highlight = base05; - highlight_bg = base02; - error = base07; - error_bg = base0F; - statusbar = base00; - statusbar_progress = base04; - statusbar_bg = base04; - cmdline = base05; - cmdline_bg = base00; - search_match = base05; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.ncspot.enable) + { + programs.ncspot.settings = + let + colors = config.lib.stylix.colors.withHashtag; + in + { + theme = with colors; { + background = base00; + primary = base05; + secondary = base03; + title = base06; + playing = base05; + playing_selected = base06; + playing_bg = base02; + highlight = base05; + highlight_bg = base02; + error = base07; + error_bg = base0F; + statusbar = base00; + statusbar_progress = base04; + statusbar_bg = base04; + cmdline = base05; + cmdline_bg = base00; + search_match = base05; + }; + }; }; - }; - }; } diff --git a/modules/neovim/hm.nix b/modules/neovim/hm.nix index da72dc112..024bed14a 100644 --- a/modules/neovim/hm.nix +++ b/modules/neovim/hm.nix @@ -1,10 +1,18 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: { options.stylix.targets.neovim = { enable = config.lib.stylix.mkEnableTarget "Neovim" true; plugin = lib.mkOption { - type = lib.types.enum [ "base16-nvim" "mini.base16" ]; + type = lib.types.enum [ + "base16-nvim" + "mini.base16" + ]; default = "mini.base16"; description = "Plugin used for the colorscheme"; }; @@ -14,50 +22,52 @@ }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.neovim.enable) { - programs.neovim = - let - cfg = config.stylix.targets.neovim; - in + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.neovim.enable) { - plugins = [ - (lib.mkIf (cfg.plugin == "base16-nvim") { - plugin = pkgs.vimPlugins.base16-nvim; - type = "lua"; - config = with config.lib.stylix.colors.withHashtag; '' - require('base16-colorscheme').setup({ - base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', - base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', - base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', - base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' + programs.neovim = + let + cfg = config.stylix.targets.neovim; + in + { + plugins = [ + (lib.mkIf (cfg.plugin == "base16-nvim") { + plugin = pkgs.vimPlugins.base16-nvim; + type = "lua"; + config = with config.lib.stylix.colors.withHashtag; '' + require('base16-colorscheme').setup({ + base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', + base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', + base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', + base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' + }) + ''; }) - ''; - }) - (lib.mkIf (cfg.plugin == "mini.base16") { - plugin = pkgs.vimPlugins.mini-nvim; - type = "lua"; - config = with config.lib.stylix.colors.withHashtag; '' - require('mini.base16').setup({ - palette = { - base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', - base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', - base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', - base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' - } + (lib.mkIf (cfg.plugin == "mini.base16") { + plugin = pkgs.vimPlugins.mini-nvim; + type = "lua"; + config = with config.lib.stylix.colors.withHashtag; '' + require('mini.base16').setup({ + palette = { + base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', + base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', + base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', + base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' + } + }) + ''; }) - ''; - }) - ]; + ]; - extraLuaConfig = lib.mkMerge [ - (lib.mkIf cfg.transparentBackground.main '' - vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" }) - vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" }) - '') - (lib.mkIf cfg.transparentBackground.signColumn '' - vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" }) - '') - ]; + extraLuaConfig = lib.mkMerge [ + (lib.mkIf cfg.transparentBackground.main '' + vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" }) + vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" }) + '') + (lib.mkIf cfg.transparentBackground.signColumn '' + vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" }) + '') + ]; + }; }; - }; } diff --git a/modules/nixos-icons/nixos.nix b/modules/nixos-icons/nixos.nix index 90f037c91..e2fc72148 100644 --- a/modules/nixos-icons/nixos.nix +++ b/modules/nixos-icons/nixos.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.lib.stylix.colors; @@ -6,20 +11,24 @@ with config.lib.stylix.colors; options.stylix.targets.nixos-icons.enable = config.lib.stylix.mkEnableTarget "the NixOS logo" true; - config.nixpkgs.overlays = lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable) [(_: super: { - nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: { - src = pkgs.applyPatches { - inherit (oldAttrs) src; - prePatch = '' - substituteInPlace logo/nix-snowflake-white.svg --replace-fail '#ffffff' '#${base05}' + config.nixpkgs.overlays = + lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable) + [ + (_: super: { + nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: { + src = pkgs.applyPatches { + inherit (oldAttrs) src; + prePatch = '' + substituteInPlace logo/nix-snowflake-white.svg --replace-fail '#ffffff' '#${base05}' - # Insert attribution comment after the XML prolog - sed \ - --in-place \ - '2i' \ - logo/nix-snowflake-white.svg - ''; - }; - }); - })]; + # Insert attribution comment after the XML prolog + sed \ + --in-place \ + '2i' \ + logo/nix-snowflake-white.svg + ''; + }; + }); + }) + ]; } diff --git a/modules/nixvim/nixvim.nix b/modules/nixvim/nixvim.nix index b7bc335d0..b87fb7c9e 100644 --- a/modules/nixvim/nixvim.nix +++ b/modules/nixvim/nixvim.nix @@ -3,13 +3,18 @@ lib, options, ... -}: let +}: +let cfg = config.stylix.targets.nixvim; -in { +in +{ options.stylix.targets.nixvim = { enable = config.lib.stylix.mkEnableTarget "nixvim" true; plugin = lib.mkOption { - type = lib.types.enum [ "base16-nvim" "mini.base16" ]; + type = lib.types.enum [ + "base16-nvim" + "mini.base16" + ]; default = "mini.base16"; description = "Plugin used for the colorscheme"; }; @@ -20,68 +25,118 @@ in { }; imports = [ - ( - lib.mkRenamedOptionModuleWith { - from = [ "stylix" "targets" "nixvim" "transparent_bg" "main" ]; - sinceRelease = 2411; - to = [ "stylix" "targets" "nixvim" "transparentBackground" "main" ]; - } - ) + (lib.mkRenamedOptionModuleWith { + from = [ + "stylix" + "targets" + "nixvim" + "transparent_bg" + "main" + ]; + sinceRelease = 2411; + to = [ + "stylix" + "targets" + "nixvim" + "transparentBackground" + "main" + ]; + }) - ( - lib.mkRenamedOptionModuleWith { - from = [ "stylix" "targets" "nixvim" "transparent_bg" "sign_column" ]; - sinceRelease = 2411; + (lib.mkRenamedOptionModuleWith { + from = [ + "stylix" + "targets" + "nixvim" + "transparent_bg" + "sign_column" + ]; + sinceRelease = 2411; - to = [ - "stylix" - "targets" - "nixvim" - "transparentBackground" - "signColumn" - ]; - } - ) + to = [ + "stylix" + "targets" + "nixvim" + "transparentBackground" + "signColumn" + ]; + }) ]; - config = lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixvim)) ( - lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) (lib.mkMerge [ - (lib.mkIf (cfg.plugin == "base16-nvim") { - programs.nixvim.colorschemes.base16 = { - enable = true; + config = + lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixvim)) + ( + lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) ( + lib.mkMerge [ + (lib.mkIf (cfg.plugin == "base16-nvim") { + programs.nixvim.colorschemes.base16 = { + enable = true; - colorscheme = { - inherit (config.lib.stylix.colors.withHashtag) - base00 base01 base02 base03 base04 base05 base06 base07 - base08 base09 base0A base0B base0C base0D base0E base0F; - }; - }; - }) - (lib.mkIf (cfg.plugin == "mini.base16") { - programs.nixvim.plugins.mini = { - enable = true; + colorscheme = { + inherit (config.lib.stylix.colors.withHashtag) + base00 + base01 + base02 + base03 + base04 + base05 + base06 + base07 + base08 + base09 + base0A + base0B + base0C + base0D + base0E + base0F + ; + }; + }; + }) + (lib.mkIf (cfg.plugin == "mini.base16") { + programs.nixvim.plugins.mini = { + enable = true; - modules.base16.palette = { - inherit (config.lib.stylix.colors.withHashtag) - base00 base01 base02 base03 base04 base05 base06 base07 - base08 base09 base0A base0B base0C base0D base0E base0F; - }; - }; - }) - { - programs.nixvim = { - highlight = let - transparent = { - bg = "none"; - ctermbg = "none"; - }; - in { - Normal = lib.mkIf cfg.transparentBackground.main transparent; - NonText = lib.mkIf cfg.transparentBackground.main transparent; - SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent; - }; - }; - } - ]) - ); + modules.base16.palette = { + inherit (config.lib.stylix.colors.withHashtag) + base00 + base01 + base02 + base03 + base04 + base05 + base06 + base07 + base08 + base09 + base0A + base0B + base0C + base0D + base0E + base0F + ; + }; + }; + }) + { + programs.nixvim = { + highlight = + let + transparent = { + bg = "none"; + ctermbg = "none"; + }; + in + { + Normal = lib.mkIf cfg.transparentBackground.main transparent; + NonText = lib.mkIf cfg.transparentBackground.main transparent; + SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent; + }; + }; + } + ] + ) + ); } diff --git a/modules/nushell/hm.nix b/modules/nushell/hm.nix index 9f5801c65..a355b33fd 100644 --- a/modules/nushell/hm.nix +++ b/modules/nushell/hm.nix @@ -7,42 +7,44 @@ with config.lib.stylix.colors.withHashtag; config.lib.stylix.mkEnableTarget "Nushell" true; # Adapted from https://www.nushell.sh/book/coloring_and_theming.html#theming - config.programs.nushell.extraConfig = lib.mkIf (config.stylix.enable && config.stylix.targets.nushell.enable) '' - $env.config.color_config = { - separator: "${base03}" - leading_trailing_space_bg: "${base04}" - header: "${base0B}" - date: "${base0E}" - filesize: "${base0D}" - row_index: "${base0C}" - bool: "${base08}" - int: "${base0B}" - duration: "${base08}" - range: "${base08}" - float: "${base08}" - string: "${base04}" - nothing: "${base08}" - binary: "${base08}" - cellpath: "${base08}" - hints: dark_gray + config.programs.nushell.extraConfig = + lib.mkIf (config.stylix.enable && config.stylix.targets.nushell.enable) + '' + $env.config.color_config = { + separator: "${base03}" + leading_trailing_space_bg: "${base04}" + header: "${base0B}" + date: "${base0E}" + filesize: "${base0D}" + row_index: "${base0C}" + bool: "${base08}" + int: "${base0B}" + duration: "${base08}" + range: "${base08}" + float: "${base08}" + string: "${base04}" + nothing: "${base08}" + binary: "${base08}" + cellpath: "${base08}" + hints: dark_gray - shape_garbage: { fg: "${base07}" bg: "${base08}" } - shape_bool: "${base0D}" - shape_int: { fg: "${base0E}" attr: b } - shape_float: { fg: "${base0E}" attr: b } - shape_range: { fg: "${base0A}" attr: b } - shape_internalcall: { fg: "${base0C}" attr: b } - shape_external: "${base0C}" - shape_externalarg: { fg: "${base0B}" attr: b } - shape_literal: "${base0D}" - shape_operator: "${base0A}" - shape_signature: { fg: "${base0B}" attr: b } - shape_string: "${base0B}" - shape_filepath: "${base0D}" - shape_globpattern: { fg: "${base0D}" attr: b } - shape_variable: "${base0E}" - shape_flag: { fg: "${base0D}" attr: b } - shape_custom: { attr: b } - } - ''; + shape_garbage: { fg: "${base07}" bg: "${base08}" } + shape_bool: "${base0D}" + shape_int: { fg: "${base0E}" attr: b } + shape_float: { fg: "${base0E}" attr: b } + shape_range: { fg: "${base0A}" attr: b } + shape_internalcall: { fg: "${base0C}" attr: b } + shape_external: "${base0C}" + shape_externalarg: { fg: "${base0B}" attr: b } + shape_literal: "${base0D}" + shape_operator: "${base0A}" + shape_signature: { fg: "${base0B}" attr: b } + shape_string: "${base0B}" + shape_filepath: "${base0D}" + shape_globpattern: { fg: "${base0D}" attr: b } + shape_variable: "${base0E}" + shape_flag: { fg: "${base0D}" attr: b } + shape_custom: { attr: b } + } + ''; } diff --git a/modules/plymouth/nixos.nix b/modules/plymouth/nixos.nix index 72a08f3ba..05369f9f5 100644 --- a/modules/plymouth/nixos.nix +++ b/modules/plymouth/nixos.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let cfg = config.stylix.targets.plymouth; @@ -18,19 +23,17 @@ let $themeDir/logo.png ${ - if cfg.logoAnimated - then "cp ${./theme.script} $themeDir/stylix.script" - else "cp ${./theme_still.script} $themeDir/stylix.script" + if cfg.logoAnimated then + "cp ${./theme.script} $themeDir/stylix.script" + else + "cp ${./theme_still.script} $themeDir/stylix.script" } - ${ - with config.lib.stylix.colors; - '' - substituteInPlace $themeDir/stylix.script \ - --replace-fail "%BASE00%" "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}" \ - --replace-fail "%BASE05%" "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}" - '' - } + ${with config.lib.stylix.colors; '' + substituteInPlace $themeDir/stylix.script \ + --replace-fail "%BASE00%" "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}" \ + --replace-fail "%BASE05%" "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}" + ''} echo " [Plymouth Theme] @@ -43,7 +46,8 @@ let " > $themeDir/stylix.plymouth ''; -in { +in +{ options.stylix.targets.plymouth = { enable = config.lib.stylix.mkEnableTarget "the Plymouth boot screen" true; @@ -68,9 +72,7 @@ in { }; imports = [ - ( - lib.mkRemovedOptionModule - [ "stylix" "targets" "plymouth" "blackBackground" ] + (lib.mkRemovedOptionModule [ "stylix" "targets" "plymouth" "blackBackground" ] "This was removed since it goes against the chosen color scheme. If you want this, consider disabling the target and configuring Plymouth by hand." ) ]; diff --git a/modules/qutebrowser/hm.nix b/modules/qutebrowser/hm.nix index 033ad4b7d..618342d8e 100644 --- a/modules/qutebrowser/hm.nix +++ b/modules/qutebrowser/hm.nix @@ -17,267 +17,270 @@ let secondary-info = base0C; warning = base0E; -in { +in +{ options.stylix.targets.qutebrowser.enable = config.lib.stylix.mkEnableTarget "Qutebrowser" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.qutebrowser.enable) { - programs.qutebrowser.settings = { - colors = { - completion = { - category = { - bg = background; - fg = info; - - border = { - bottom = background; - top = background; - }; - }; - - even.bg = background; - fg = foreground; - - item.selected = { - bg = selection-background; - - border = { - bottom = selection-background; - top = selection-background; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.qutebrowser.enable) + { + programs.qutebrowser.settings = { + colors = { + completion = { + category = { + bg = background; + fg = info; + + border = { + bottom = background; + top = background; + }; + }; - fg = foreground; - }; + even.bg = background; + fg = foreground; - match.fg = info; - odd.bg = secondary-background; + item.selected = { + bg = selection-background; - scrollbar = { - bg = background; - fg = foreground; - }; - }; + border = { + bottom = selection-background; + top = selection-background; + }; - contextmenu = { - disabled = { - bg = secondary-background; - fg = inverted-foreground; - }; + fg = foreground; + }; - menu = { - bg = background; - fg = foreground; - }; + match.fg = info; + odd.bg = secondary-background; - selected = { - bg = selection-background; - fg = foreground; - }; - }; + scrollbar = { + bg = background; + fg = foreground; + }; + }; - downloads = { - bar.bg = background; + contextmenu = { + disabled = { + bg = secondary-background; + fg = inverted-foreground; + }; - error = { - bg = error; - fg = inverted-foreground; - }; + menu = { + bg = background; + fg = foreground; + }; - start = { - bg = info; - fg = inverted-foreground; - }; + selected = { + bg = selection-background; + fg = foreground; + }; + }; - stop = { - bg = secondary-info; - fg = inverted-foreground; - }; - }; + downloads = { + bar.bg = background; - hints = { - bg = secondary-background; - fg = foreground; - match.fg = info; - }; + error = { + bg = error; + fg = inverted-foreground; + }; - keyhint = { - bg = background; - fg = foreground; - suffix.fg = foreground; - }; + start = { + bg = info; + fg = inverted-foreground; + }; - messages = { - error = { - bg = error; - fg = inverted-foreground; - border = error; - }; + stop = { + bg = secondary-info; + fg = inverted-foreground; + }; + }; - info = { - bg = info; - fg = inverted-foreground; - border = info; - }; + hints = { + bg = secondary-background; + fg = foreground; + match.fg = info; + }; - warning = { - bg = warning; - fg = inverted-foreground; - border = warning; - }; - }; + keyhint = { + bg = background; + fg = foreground; + suffix.fg = foreground; + }; - prompts = { - bg = background; - border = background; - fg = foreground; - selected.bg = secondary-background; - }; + messages = { + error = { + bg = error; + fg = inverted-foreground; + border = error; + }; - statusbar = { - caret = { - bg = selection-background; - fg = foreground; + info = { + bg = info; + fg = inverted-foreground; + border = info; + }; - selection = { - bg = selection-background; - fg = foreground; + warning = { + bg = warning; + fg = inverted-foreground; + border = warning; + }; }; - }; - - command = { - bg = background; - fg = foreground; - private = { - bg = secondary-background; + prompts = { + bg = background; + border = background; fg = foreground; + selected.bg = secondary-background; }; - }; - insert = { - bg = info; - fg = inverted-foreground; - }; + statusbar = { + caret = { + bg = selection-background; + fg = foreground; - normal = { - bg = background; - fg = foreground; - }; + selection = { + bg = selection-background; + fg = foreground; + }; + }; - passthrough = { - bg = secondary-info; - fg = inverted-foreground; - }; + command = { + bg = background; + fg = foreground; - private = { - bg = secondary-background; - fg = foreground; - }; + private = { + bg = secondary-background; + fg = foreground; + }; + }; - progress.bg = info; + insert = { + bg = info; + fg = inverted-foreground; + }; - url = { - error.fg = error; - fg = foreground; - hover.fg = foreground; + normal = { + bg = background; + fg = foreground; + }; - success = { - http.fg = secondary-info; - https.fg = info; - }; + passthrough = { + bg = secondary-info; + fg = inverted-foreground; + }; - warn.fg = warning; - }; - }; + private = { + bg = secondary-background; + fg = foreground; + }; - tabs = { - bar.bg = background; + progress.bg = info; - even = { - bg = secondary-background; - fg = foreground; - }; + url = { + error.fg = error; + fg = foreground; + hover.fg = foreground; - indicator = { - inherit error; - start = secondary-info; - stop = info; - }; + success = { + http.fg = secondary-info; + https.fg = info; + }; - odd = { - bg = background; - fg = foreground; - }; - - pinned = { - even = { - bg = info; - fg = inverted-foreground; + warn.fg = warning; + }; }; - odd = { - bg = secondary-info; - fg = inverted-foreground; - }; + tabs = { + bar.bg = background; - selected = { even = { - bg = selection-background; + bg = secondary-background; fg = foreground; }; + indicator = { + inherit error; + start = secondary-info; + stop = info; + }; + odd = { - bg = selection-background; + bg = background; fg = foreground; }; - }; - }; - selected = { - even = { - bg = selection-background; - fg = foreground; - }; + pinned = { + even = { + bg = info; + fg = inverted-foreground; + }; + + odd = { + bg = secondary-info; + fg = inverted-foreground; + }; + + selected = { + even = { + bg = selection-background; + fg = foreground; + }; + + odd = { + bg = selection-background; + fg = foreground; + }; + }; + }; - odd = { - bg = selection-background; - fg = foreground; + selected = { + even = { + bg = selection-background; + fg = foreground; + }; + + odd = { + bg = selection-background; + fg = foreground; + }; + }; }; - }; - }; - webpage = let - isDark = config.stylix.polarity == "dark"; - in { - darkmode.enabled = lib.mkIf isDark (lib.mkDefault true); + webpage = + let + isDark = config.stylix.polarity == "dark"; + in + { + darkmode.enabled = lib.mkIf isDark (lib.mkDefault true); - preferred_color_scheme = - lib.mkIf - isDark (lib.mkDefault config.stylix.polarity); - }; - }; + preferred_color_scheme = lib.mkIf isDark (lib.mkDefault config.stylix.polarity); + }; + }; + + fonts = { + default_family = sansSerif.name; + default_size = "${toString sizes.applications}pt"; + + web = { + family = { + cursive = serif.name; + fantasy = serif.name; + fixed = monospace.name; + sans_serif = sansSerif.name; + serif = serif.name; + standard = sansSerif.name; + }; - fonts = { - default_family = sansSerif.name; - default_size = "${toString sizes.applications}pt"; - - web = { - family = { - cursive = serif.name; - fantasy = serif.name; - fixed = monospace.name; - sans_serif = sansSerif.name; - serif = serif.name; - standard = sansSerif.name; + # TODO: Use the pixel unit: + # https://github.com/danth/stylix/issues/251. + size.default = builtins.floor (sizes.applications * 4 / 3 + 0.5); + }; }; - # TODO: Use the pixel unit: - # https://github.com/danth/stylix/issues/251. - size.default = builtins.floor (sizes.applications * 4 / 3 + 0.5); + hints.border = background; }; }; - - hints.border = background; - }; - }; } diff --git a/modules/qutebrowser/testbed.nix b/modules/qutebrowser/testbed.nix index 08b3e89ef..1ef1c6c77 100644 --- a/modules/qutebrowser/testbed.nix +++ b/modules/qutebrowser/testbed.nix @@ -1,18 +1,22 @@ { pkgs, ... }: -let package = pkgs.qutebrowser; +let + package = pkgs.qutebrowser; -in { +in +{ stylix.testbed.application = { enable = true; name = "org.qutebrowser.qutebrowser"; inherit package; }; - home-manager.sharedModules = [{ - programs.qutebrowser = { - enable = true; - inherit package; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.qutebrowser = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/regreet/nixos.nix b/modules/regreet/nixos.nix index 3b610c6b6..ac4b621bd 100644 --- a/modules/regreet/nixos.nix +++ b/modules/regreet/nixos.nix @@ -6,26 +6,33 @@ }: { - options.stylix.targets.regreet.enable = config.lib.stylix.mkEnableTarget "ReGreet" true; + options.stylix.targets.regreet.enable = + config.lib.stylix.mkEnableTarget "ReGreet" true; config = lib.mkIf - (config.stylix.enable && config.stylix.targets.regreet.enable && pkgs.stdenv.hostPlatform.isLinux) + ( + config.stylix.enable + && config.stylix.targets.regreet.enable + && pkgs.stdenv.hostPlatform.isLinux + ) { programs.regreet = { settings.background = { path = config.stylix.image; - fit = let - inherit (config.stylix) imageScalingMode; - in - if imageScalingMode == "fill" - then "Cover" - else if imageScalingMode == "fit" - then "Contain" - else if imageScalingMode == "stretch" - then "Fill" + fit = + let + inherit (config.stylix) imageScalingMode; + in + if imageScalingMode == "fill" then + "Cover" + else if imageScalingMode == "fit" then + "Contain" + else if imageScalingMode == "stretch" then + "Fill" # No other available options - else null; + else + null; }; font = { inherit (config.stylix.fonts.sansSerif) name package; diff --git a/modules/river/hm.nix b/modules/river/hm.nix index aa7d36fde..6794480b5 100644 --- a/modules/river/hm.nix +++ b/modules/river/hm.nix @@ -1,7 +1,8 @@ { config, lib, ... }: { - options.stylix.targets.river.enable = config.lib.stylix.mkEnableTarget "River" true; + options.stylix.targets.river.enable = + config.lib.stylix.mkEnableTarget "River" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.river.enable) { wayland.windowManager.river.settings = { diff --git a/modules/rofi/hm.nix b/modules/rofi/hm.nix index d13d7ad9f..c7a2fc20b 100644 --- a/modules/rofi/hm.nix +++ b/modules/rofi/hm.nix @@ -4,17 +4,19 @@ with config.stylix.fonts; let inherit (config.lib.formats.rasi) mkLiteral; - mkRgba = opacity: color: + mkRgba = + opacity: color: let c = config.lib.stylix.colors; r = c."${color}-rgb-r"; g = c."${color}-rgb-g"; b = c."${color}-rgb-b"; in - mkLiteral - "rgba ( ${r}, ${g}, ${b}, ${opacity} % )"; + mkLiteral "rgba ( ${r}, ${g}, ${b}, ${opacity} % )"; mkRgb = mkRgba "100"; - rofiOpacity = builtins.toString (builtins.ceil (config.stylix.opacity.popups * 100)); + rofiOpacity = builtins.toString ( + builtins.ceil (config.stylix.opacity.popups * 100) + ); in { options.stylix.targets.rofi.enable = diff --git a/modules/spicetify/spicetify.nix b/modules/spicetify/spicetify.nix index 2b73b4caf..83aadf341 100644 --- a/modules/spicetify/spicetify.nix +++ b/modules/spicetify/spicetify.nix @@ -1,45 +1,58 @@ -{ config, options, lib, pkgs, ... }: +{ + config, + options, + lib, + pkgs, + ... +}: { options.stylix.targets.spicetify.enable = config.lib.stylix.mkEnableTarget "Spicetify" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.spicetify.enable && (config.programs?spicetify)) ( - lib.optionalAttrs (builtins.hasAttr "spicetify" options.programs) { - programs.spicetify = { - theme = { - name = "stylix"; - src = pkgs.writeTextFile { - name = "color.ini"; - destination = "/color.ini"; - text = with config.lib.stylix.colors; '' - [base] - text = ${base05} - subtext = ${base05} - main = ${base00} - main-elevated = ${base02} - highlight = ${base02} - highlight-elevated = ${base03} - sidebar = ${base01} - player = ${base05} - card = ${base04} - shadow = ${base00} - selected-row = ${base05} - button = ${base05} - button-active = ${base05} - button-disabled = ${base04} - tab-active = ${base02} - notification = ${base02} - notification-error = ${base08} - equalizer = ${base0B} - misc = ${base02} - ''; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.spicetify.enable + && (config.programs ? spicetify) + ) + ( + lib.optionalAttrs (builtins.hasAttr "spicetify" options.programs) { + programs.spicetify = { + theme = { + name = "stylix"; + src = pkgs.writeTextFile { + name = "color.ini"; + destination = "/color.ini"; + text = with config.lib.stylix.colors; '' + [base] + text = ${base05} + subtext = ${base05} + main = ${base00} + main-elevated = ${base02} + highlight = ${base02} + highlight-elevated = ${base03} + sidebar = ${base01} + player = ${base05} + card = ${base04} + shadow = ${base00} + selected-row = ${base05} + button = ${base05} + button-active = ${base05} + button-disabled = ${base04} + tab-active = ${base02} + notification = ${base02} + notification-error = ${base08} + equalizer = ${base0B} + misc = ${base02} + ''; + }; + # Sidebar configuration is incompatible with the default navigation bar + sidebarConfig = false; + }; + colorScheme = "base"; }; - # Sidebar configuration is incompatible with the default navigation bar - sidebarConfig = false; - }; - colorScheme = "base"; - }; - } - ); + } + ); } diff --git a/modules/sway/hm.nix b/modules/sway/hm.nix index 6a201ccfb..8bbaba3bb 100644 --- a/modules/sway/hm.nix +++ b/modules/sway/hm.nix @@ -13,7 +13,8 @@ let size = config.stylix.fonts.sizes.desktop + 0.0; }; -in { +in +{ options.stylix.targets.sway.enable = config.lib.stylix.mkEnableTarget "Sway" true; @@ -22,40 +23,43 @@ in { wayland.windowManager.sway.config = { inherit fonts; - colors = let - background = base00; - indicator = base0B; - in { - inherit background; - urgent = { - inherit background indicator text; - border = urgent; - childBorder = urgent; + colors = + let + background = base00; + indicator = base0B; + in + { + inherit background; + urgent = { + inherit background indicator text; + border = urgent; + childBorder = urgent; + }; + focused = { + inherit background indicator text; + border = focused; + childBorder = focused; + }; + focusedInactive = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + unfocused = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + placeholder = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; }; - focused = { - inherit background indicator text; - border = focused; - childBorder = focused; - }; - focusedInactive = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - unfocused = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - placeholder = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - }; output."*".bg = "${config.stylix.image} ${config.stylix.imageScalingMode}"; - seat."*".xcursor_theme = ''"${config.stylix.cursor.name}" ${toString config.stylix.cursor.size}''; + seat."*".xcursor_theme = + ''"${config.stylix.cursor.name}" ${toString config.stylix.cursor.size}''; }; }) @@ -64,34 +68,36 @@ in { lib.stylix.sway.bar = { inherit fonts; - colors = let - background = base01; - border = background; - in { - inherit background; - statusline = text; - separator = base03; - focusedWorkspace = { - inherit text border; - background = focused; - }; - activeWorkspace = { - inherit text border; - background = unfocused; - }; - inactiveWorkspace = { - inherit text border; - background = unfocused; - }; - urgentWorkspace = { - inherit text border; - background = urgent; - }; - bindingMode = { - inherit text border; - background = urgent; + colors = + let + background = base01; + border = background; + in + { + inherit background; + statusline = text; + separator = base03; + focusedWorkspace = { + inherit text border; + background = focused; + }; + activeWorkspace = { + inherit text border; + background = unfocused; + }; + inactiveWorkspace = { + inherit text border; + background = unfocused; + }; + urgentWorkspace = { + inherit text border; + background = urgent; + }; + bindingMode = { + inherit text border; + background = urgent; + }; }; - }; }; } ]; diff --git a/modules/swaylock/hm.nix b/modules/swaylock/hm.nix index ad10cc676..1f0bdfb74 100644 --- a/modules/swaylock/hm.nix +++ b/modules/swaylock/hm.nix @@ -1,4 +1,10 @@ -{ pkgs, options, config, lib, ... }: +{ + pkgs, + options, + config, + lib, + ... +}: with config.lib.stylix.colors; @@ -10,7 +16,8 @@ let positive = base0B-hex; negative = base08-hex; -in { +in +{ options.stylix.targets.swaylock = { enable = config.lib.stylix.mkEnableTarget "Swaylock" true; useImage = lib.mkOption { @@ -23,33 +30,42 @@ in { }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.swaylock.enable && pkgs.stdenv.hostPlatform.isLinux) { - programs.swaylock.settings = { - color = outside; - scaling = config.stylix.imageScalingMode; - inside-color = inside; - inside-clear-color = inside; - inside-caps-lock-color = inside; - inside-ver-color = inside; - inside-wrong-color = inside; - key-hl-color = positive; - layout-bg-color = inside; - layout-border-color = ring; - layout-text-color = text; - line-uses-inside = true; - ring-color = ring; - ring-clear-color = negative; - ring-caps-lock-color = ring; - ring-ver-color = positive; - ring-wrong-color = negative; - separator-color = "00000000"; - text-color = text; - text-clear-color = text; - text-caps-lock-color = text; - text-ver-color = text; - text-wrong-color = text; - } // lib.optionalAttrs config.stylix.targets.swaylock.useImage { - image = "${config.stylix.image}"; - }; - }; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.swaylock.enable + && pkgs.stdenv.hostPlatform.isLinux + ) + { + programs.swaylock.settings = + { + color = outside; + scaling = config.stylix.imageScalingMode; + inside-color = inside; + inside-clear-color = inside; + inside-caps-lock-color = inside; + inside-ver-color = inside; + inside-wrong-color = inside; + key-hl-color = positive; + layout-bg-color = inside; + layout-border-color = ring; + layout-text-color = text; + line-uses-inside = true; + ring-color = ring; + ring-clear-color = negative; + ring-caps-lock-color = ring; + ring-ver-color = positive; + ring-wrong-color = negative; + separator-color = "00000000"; + text-color = text; + text-clear-color = text; + text-caps-lock-color = text; + text-ver-color = text; + text-wrong-color = text; + } + // lib.optionalAttrs config.stylix.targets.swaylock.useImage { + image = "${config.stylix.image}"; + }; + }; } diff --git a/modules/swaync/hm.nix b/modules/swaync/hm.nix index 205f7d42e..4433c9206 100644 --- a/modules/swaync/hm.nix +++ b/modules/swaync/hm.nix @@ -12,18 +12,22 @@ with config.stylix.fonts; enable = config.lib.stylix.mkEnableTarget "SwayNC" true; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.swaync.enable) { - services.swaync.style = '' - @define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03}; - @define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07}; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.swaync.enable) + { + services.swaync.style = + '' + @define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03}; + @define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07}; - @define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B}; - @define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F}; + @define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B}; + @define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F}; - * { - font-family: "${sansSerif.name}"; - font-size: ${builtins.toString sizes.desktop}pt; - } - '' + (builtins.readFile ./base.css); - }; + * { + font-family: "${sansSerif.name}"; + font-size: ${builtins.toString sizes.desktop}pt; + } + '' + + (builtins.readFile ./base.css); + }; } diff --git a/modules/sxiv/hm.nix b/modules/sxiv/hm.nix index a1695030c..827fc4f0d 100644 --- a/modules/sxiv/hm.nix +++ b/modules/sxiv/hm.nix @@ -3,7 +3,8 @@ let inherit (config.lib.stylix) colors; inherit (config.stylix) fonts; -in { +in +{ options.stylix.targets.sxiv.enable = config.lib.stylix.mkEnableTarget "Sxiv" true; diff --git a/modules/tmux/hm.nix b/modules/tmux/hm.nix index 249f2ccf1..ad3b86945 100644 --- a/modules/tmux/hm.nix +++ b/modules/tmux/hm.nix @@ -6,13 +6,14 @@ let target = "base16"; }; -in { +in +{ options.stylix.targets.tmux.enable = config.lib.stylix.mkEnableTarget "Tmux" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.tmux.enable) { programs.tmux.extraConfig = '' - source-file ${theme} + source-file ${theme} ''; }; } diff --git a/modules/tofi/hm.nix b/modules/tofi/hm.nix index ce7e4f67c..fe0560199 100644 --- a/modules/tofi/hm.nix +++ b/modules/tofi/hm.nix @@ -1,16 +1,20 @@ -{ config -, lib -, ... +{ + config, + lib, + ... }: with config.stylix.fonts; -with config.lib.stylix.colors.withHashtag; { +with config.lib.stylix.colors.withHashtag; +{ options.stylix.targets.tofi.enable = config.lib.stylix.mkEnableTarget "Tofi" true; 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; diff --git a/modules/vesktop/hm.nix b/modules/vesktop/hm.nix index 6ffdb68f8..ded10d526 100644 --- a/modules/vesktop/hm.nix +++ b/modules/vesktop/hm.nix @@ -6,9 +6,12 @@ let }; in { - options.stylix.targets.vesktop.enable = config.lib.stylix.mkEnableTarget "Vesktop" true; + options.stylix.targets.vesktop.enable = + config.lib.stylix.mkEnableTarget "Vesktop" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.vesktop.enable) { - xdg.configFile."vesktop/themes/stylix.theme.css".source = themeFile; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.vesktop.enable) + { + xdg.configFile."vesktop/themes/stylix.theme.css".source = themeFile; + }; } diff --git a/modules/vesktop/testbed.nix b/modules/vesktop/testbed.nix index 68b8c3e09..8035545eb 100644 --- a/modules/vesktop/testbed.nix +++ b/modules/vesktop/testbed.nix @@ -1,8 +1,10 @@ { pkgs, ... }: -let package = pkgs.vesktop; +let + package = pkgs.vesktop; -in { +in +{ stylix.testbed.application = { enable = true; name = "vesktop"; @@ -10,4 +12,4 @@ in { }; environment.systemPackages = [ package ]; -} \ No newline at end of file +} diff --git a/modules/vim/hm.nix b/modules/vim/hm.nix index e74cc3888..ddf68d2ce 100644 --- a/modules/vim/hm.nix +++ b/modules/vim/hm.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let themeFile = config.lib.stylix.colors { @@ -18,41 +23,45 @@ let ''; }; - vimOptions = let - inherit (config.stylix) fonts; - in { - plugins = [ themePlugin ]; - extraConfig = with config.lib.stylix.colors.withHashtag; '' - set termguicolors - colorscheme base16-stylix - unlet g:colors_name - - let g:stylix_colors = { - \ 'base00': '${base00}', - \ 'base01': '${base01}', - \ 'base02': '${base02}', - \ 'base03': '${base03}', - \ 'base04': '${base04}', - \ 'base05': '${base05}', - \ 'base06': '${base06}', - \ 'base07': '${base07}', - \ 'base08': '${base08}', - \ 'base09': '${base09}', - \ 'base0A': '${base0A}', - \ 'base0B': '${base0B}', - \ 'base0C': '${base0C}', - \ 'base0D': '${base0D}', - \ 'base0E': '${base0E}', - \ 'base0F': '${base0F}', - \ } - - set guifont=${lib.escape [" "] fonts.monospace.name}:h${toString fonts.sizes.terminal} - ''; - }; + vimOptions = + let + inherit (config.stylix) fonts; + in + { + plugins = [ themePlugin ]; + extraConfig = with config.lib.stylix.colors.withHashtag; '' + set termguicolors + colorscheme base16-stylix + unlet g:colors_name + + let g:stylix_colors = { + \ 'base00': '${base00}', + \ 'base01': '${base01}', + \ 'base02': '${base02}', + \ 'base03': '${base03}', + \ 'base04': '${base04}', + \ 'base05': '${base05}', + \ 'base06': '${base06}', + \ 'base07': '${base07}', + \ 'base08': '${base08}', + \ 'base09': '${base09}', + \ 'base0A': '${base0A}', + \ 'base0B': '${base0B}', + \ 'base0C': '${base0C}', + \ 'base0D': '${base0D}', + \ 'base0E': '${base0E}', + \ 'base0F': '${base0F}', + \ } + + set guifont=${ + lib.escape [ " " ] fonts.monospace.name + }:h${toString fonts.sizes.terminal} + ''; + }; -in { - options.stylix.targets.vim.enable = - config.lib.stylix.mkEnableTarget "Vim" true; +in +{ + options.stylix.targets.vim.enable = config.lib.stylix.mkEnableTarget "Vim" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.vim.enable) { programs.vim = vimOptions; diff --git a/modules/vscode/hm.nix b/modules/vscode/hm.nix index 590a4548c..bbcffe477 100644 --- a/modules/vscode/hm.nix +++ b/modules/vscode/hm.nix @@ -1,4 +1,9 @@ -{pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.stylix.fonts; @@ -8,48 +13,54 @@ let extension = ".json"; }; - themeExtension = pkgs.runCommandLocal "stylix-vscode" { - vscodeExtUniqueId = "stylix.stylix"; - vscodeExtPublisher = "stylix"; - version = "0.0.0"; - } '' - mkdir -p "$out/share/vscode/extensions/$vscodeExtUniqueId/themes" - ln -s ${./package.json} "$out/share/vscode/extensions/$vscodeExtUniqueId/package.json" - ln -s ${themeFile} "$out/share/vscode/extensions/$vscodeExtUniqueId/themes/stylix.json" - ''; + themeExtension = + pkgs.runCommandLocal "stylix-vscode" + { + vscodeExtUniqueId = "stylix.stylix"; + vscodeExtPublisher = "stylix"; + version = "0.0.0"; + } + '' + mkdir -p "$out/share/vscode/extensions/$vscodeExtUniqueId/themes" + ln -s ${./package.json} "$out/share/vscode/extensions/$vscodeExtUniqueId/package.json" + ln -s ${themeFile} "$out/share/vscode/extensions/$vscodeExtUniqueId/themes/stylix.json" + ''; -in { +in +{ options.stylix.targets.vscode.enable = config.lib.stylix.mkEnableTarget "VSCode" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.vscode.enable) { - programs.vscode = { - extensions = [ themeExtension ]; - userSettings = { - "workbench.colorTheme" = "Stylix"; - "editor.fontFamily" = monospace.name; - "editor.inlayHints.fontFamily" = monospace.name; - "editor.inlineSuggest.fontFamily" = monospace.name; - "scm.inputFontFamily" = monospace.name; - "debug.console.fontFamily" = monospace.name; - "markdown.preview.fontFamily" = sansSerif.name; - "chat.editor.fontFamily" = monospace.name; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.vscode.enable) + { + programs.vscode = { + extensions = [ themeExtension ]; + userSettings = { + "workbench.colorTheme" = "Stylix"; + "editor.fontFamily" = monospace.name; + "editor.inlayHints.fontFamily" = monospace.name; + "editor.inlineSuggest.fontFamily" = monospace.name; + "scm.inputFontFamily" = monospace.name; + "debug.console.fontFamily" = monospace.name; + "markdown.preview.fontFamily" = sansSerif.name; + "chat.editor.fontFamily" = monospace.name; - # 4/3 factor used for pt to px; - "editor.fontSize" = sizes.terminal * 4.0 / 3.0; - "debug.console.fontSize" = sizes.terminal * 4.0 / 3.0; - "markdown.preview.fontSize" = sizes.terminal * 4.0 / 3.0; - "terminal.integrated.fontSize" = sizes.terminal * 4.0 / 3.0; - "chat.editor.fontSize" = sizes.terminal * 4.0 / 3.0; + # 4/3 factor used for pt to px; + "editor.fontSize" = sizes.terminal * 4.0 / 3.0; + "debug.console.fontSize" = sizes.terminal * 4.0 / 3.0; + "markdown.preview.fontSize" = sizes.terminal * 4.0 / 3.0; + "terminal.integrated.fontSize" = sizes.terminal * 4.0 / 3.0; + "chat.editor.fontSize" = sizes.terminal * 4.0 / 3.0; - # other factors (9/14, 13/14, 56/14) based on default for given value - # divided by default for `editor.fontSize` (14) from - # https://code.visualstudio.com/docs/getstarted/settings#_default-settings. - "editor.minimap.sectionHeaderFontSize" = sizes.terminal * 4.0 / 3.0 * 9.0 / 14.0; - "scm.inputFontSize" = sizes.terminal * 4.0 / 3.0 * 13.0 / 14.0; - "screencastMode.fontSize" = sizes.terminal * 4.0 / 3.0 * 56.0 / 14.0; + # other factors (9/14, 13/14, 56/14) based on default for given value + # divided by default for `editor.fontSize` (14) from + # https://code.visualstudio.com/docs/getstarted/settings#_default-settings. + "editor.minimap.sectionHeaderFontSize" = + sizes.terminal * 4.0 / 3.0 * 9.0 / 14.0; + "scm.inputFontSize" = sizes.terminal * 4.0 / 3.0 * 13.0 / 14.0; + "screencastMode.fontSize" = sizes.terminal * 4.0 / 3.0 * 56.0 / 14.0; + }; + }; }; - }; - }; } - diff --git a/modules/vscode/testbed.nix b/modules/vscode/testbed.nix index 671fa52d5..54085738d 100644 --- a/modules/vscode/testbed.nix +++ b/modules/vscode/testbed.nix @@ -1,19 +1,23 @@ { pkgs, ... }: # We are using VSCodium because VSCode is an unfree package -let package = pkgs.vscodium; +let + package = pkgs.vscodium; -in { +in +{ stylix.testbed.application = { enable = true; name = "codium"; inherit package; }; - home-manager.sharedModules = [{ - programs.vscode = { - enable = true; - inherit package; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.vscode = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/waybar/hm.nix b/modules/waybar/hm.nix index c39f83fa1..6bbf0b120 100644 --- a/modules/waybar/hm.nix +++ b/modules/waybar/hm.nix @@ -32,31 +32,51 @@ in }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.waybar.enable) { - programs.waybar.style = '' - @define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03}; - @define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07}; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.waybar.enable) + { + programs.waybar.style = + '' + @define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03}; + @define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07}; - @define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B}; - @define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F}; + @define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B}; + @define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F}; - * { - font-family: "${sansSerif.name}"; - font-size: ${builtins.toString sizes.desktop}pt; - } + * { + font-family: "${sansSerif.name}"; + font-size: ${builtins.toString sizes.desktop}pt; + } - window#waybar, tooltip { - background: alpha(@base00, ${with config.stylix.opacity; builtins.toString desktop}); - color: @base05; - } + window#waybar, tooltip { + background: alpha(@base00, ${ + with config.stylix.opacity; builtins.toString desktop + }); + color: @base05; + } - tooltip { - border-color: @base0D; - } - '' - + (builtins.readFile ./base.css) - + (if config.stylix.targets.waybar.enableLeftBackColors then (import ./colors.nix "left") else colorlessModules "left") - + (if config.stylix.targets.waybar.enableCenterBackColors then (import ./colors.nix "center") else colorlessModules "center") - + (if config.stylix.targets.waybar.enableRightBackColors then (import ./colors.nix "right") else colorlessModules "right"); - }; + tooltip { + border-color: @base0D; + } + '' + + (builtins.readFile ./base.css) + + ( + if config.stylix.targets.waybar.enableLeftBackColors then + (import ./colors.nix "left") + else + colorlessModules "left" + ) + + ( + if config.stylix.targets.waybar.enableCenterBackColors then + (import ./colors.nix "center") + else + colorlessModules "center" + ) + + ( + if config.stylix.targets.waybar.enableRightBackColors then + (import ./colors.nix "right") + else + colorlessModules "right" + ); + }; } diff --git a/modules/wezterm/hm.nix b/modules/wezterm/hm.nix index ab0deea5a..c5a450276 100644 --- a/modules/wezterm/hm.nix +++ b/modules/wezterm/hm.nix @@ -1,122 +1,148 @@ { config, lib, ... }: -let colors = config.lib.stylix.colors.withHashtag; -in { +let + colors = config.lib.stylix.colors.withHashtag; +in +{ options.stylix.targets.wezterm.enable = config.lib.stylix.mkEnableTarget "wezterm" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.wezterm.enable && config.programs.wezterm.enable) { + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.wezterm.enable + && config.programs.wezterm.enable + ) + { - programs.wezterm.colorSchemes.stylix = with colors; { - ansi = [ base00 base08 base0B base0A base0D base0E base0C base05 ]; - brights = [ base03 base08 base0B base0A base0D base0E base0C base07 ]; - background = base00; - cursor_bg = base05; - cursor_fg = base00; - compose_cursor = base06; - foreground = base05; - scrollbar_thumb = base01; - selection_bg = base05; - selection_fg = base00; - split = base03; - visual_bell = base09; - tab_bar = { - background = base01; - inactive_tab_edge = base01; - active_tab = { - bg_color = base00; - fg_color = base05; + programs.wezterm.colorSchemes.stylix = with colors; { + ansi = [ + base00 + base08 + base0B + base0A + base0D + base0E + base0C + base05 + ]; + brights = [ + base03 + base08 + base0B + base0A + base0D + base0E + base0C + base07 + ]; + background = base00; + cursor_bg = base05; + cursor_fg = base00; + compose_cursor = base06; + foreground = base05; + scrollbar_thumb = base01; + selection_bg = base05; + selection_fg = base00; + split = base03; + visual_bell = base09; + tab_bar = { + background = base01; + inactive_tab_edge = base01; + active_tab = { + bg_color = base00; + fg_color = base05; + }; + inactive_tab = { + bg_color = base03; + fg_color = base05; + }; + inactive_tab_hover = { + bg_color = base05; + fg_color = base00; + }; + new_tab = { + bg_color = base03; + fg_color = base05; + }; + new_tab_hover = { + bg_color = base05; + fg_color = base00; + }; + }; }; - inactive_tab = { - bg_color = base03; - fg_color = base05; - }; - inactive_tab_hover = { - bg_color = base05; - fg_color = base00; - }; - new_tab = { - bg_color = base03; - fg_color = base05; - }; - new_tab_hover = { - bg_color = base05; - fg_color = base00; - }; - }; - }; - xdg.configFile."wezterm/wezterm.lua".text = with colors; - with config.stylix.fonts; - lib.mkForce '' - -- Generated by Stylix - local wezterm = require("wezterm") - wezterm.add_to_config_reload_watch_list(wezterm.config_dir) - local function stylix_wrapped_config() - ${config.programs.wezterm.extraConfig} - end - local stylix_base_config = wezterm.config_builder() - local stylix_user_config = stylix_wrapped_config() - stylix_base_config = { - color_scheme = "stylix", - font = wezterm.font_with_fallback { - "${monospace.name}", - "${emoji.name}", - }, - font_size = ${builtins.toString sizes.terminal}, - window_background_opacity = ${ - builtins.toString config.stylix.opacity.terminal - }, - window_frame = { - active_titlebar_bg = "${base03}", - active_titlebar_fg = "${base05}", - active_titlebar_border_bottom = "${base03}", - border_left_color = "${base01}", - border_right_color = "${base01}", - border_bottom_color = "${base01}", - border_top_color = "${base01}", - button_bg = "${base01}", - button_fg = "${base05}", - button_hover_bg = "${base05}", - button_hover_fg = "${base03}", - inactive_titlebar_bg = "${base01}", - inactive_titlebar_fg = "${base05}", - inactive_titlebar_border_bottom = "${base03}", - }, - colors = { - tab_bar = { - background = "${base01}", - inactive_tab_edge = "${base01}", - active_tab = { - bg_color = "${base00}", - fg_color = "${base05}", - }, - inactive_tab = { - bg_color = "${base03}", - fg_color = "${base05}", + xdg.configFile."wezterm/wezterm.lua".text = + with colors; + with config.stylix.fonts; + lib.mkForce '' + -- Generated by Stylix + local wezterm = require("wezterm") + wezterm.add_to_config_reload_watch_list(wezterm.config_dir) + local function stylix_wrapped_config() + ${config.programs.wezterm.extraConfig} + end + local stylix_base_config = wezterm.config_builder() + local stylix_user_config = stylix_wrapped_config() + stylix_base_config = { + color_scheme = "stylix", + font = wezterm.font_with_fallback { + "${monospace.name}", + "${emoji.name}", }, - inactive_tab_hover = { - bg_color = "${base05}", - fg_color = "${base00}", + font_size = ${builtins.toString sizes.terminal}, + window_background_opacity = ${builtins.toString config.stylix.opacity.terminal}, + window_frame = { + active_titlebar_bg = "${base03}", + active_titlebar_fg = "${base05}", + active_titlebar_border_bottom = "${base03}", + border_left_color = "${base01}", + border_right_color = "${base01}", + border_bottom_color = "${base01}", + border_top_color = "${base01}", + button_bg = "${base01}", + button_fg = "${base05}", + button_hover_bg = "${base05}", + button_hover_fg = "${base03}", + inactive_titlebar_bg = "${base01}", + inactive_titlebar_fg = "${base05}", + inactive_titlebar_border_bottom = "${base03}", }, - new_tab = { - bg_color = "${base03}", - fg_color = "${base05}", + colors = { + tab_bar = { + background = "${base01}", + inactive_tab_edge = "${base01}", + active_tab = { + bg_color = "${base00}", + fg_color = "${base05}", + }, + inactive_tab = { + bg_color = "${base03}", + fg_color = "${base05}", + }, + inactive_tab_hover = { + bg_color = "${base05}", + fg_color = "${base00}", + }, + new_tab = { + bg_color = "${base03}", + fg_color = "${base05}", + }, + new_tab_hover = { + bg_color = "${base05}", + fg_color = "${base00}", + }, + }, }, - new_tab_hover = { - bg_color = "${base05}", - fg_color = "${base00}", - }, - }, - }, - command_palette_bg_color = "${base01}", - command_palette_fg_color = "${base05}", - command_palette_font_size = ${builtins.toString sizes.popups}, - } - for key, value in pairs(stylix_user_config) do - stylix_base_config[key] = value - end - return stylix_base_config - ''; - }; + command_palette_bg_color = "${base01}", + command_palette_fg_color = "${base05}", + command_palette_font_size = ${builtins.toString sizes.popups}, + } + for key, value in pairs(stylix_user_config) do + stylix_base_config[key] = value + end + return stylix_base_config + ''; + }; } diff --git a/modules/wezterm/testbed.nix b/modules/wezterm/testbed.nix index 6c7f45f28..67a88638f 100644 --- a/modules/wezterm/testbed.nix +++ b/modules/wezterm/testbed.nix @@ -1,18 +1,22 @@ { pkgs, ... }: -let package = pkgs.wezterm; +let + package = pkgs.wezterm; -in { +in +{ stylix.testbed.application = { enable = true; name = "org.wezfurlong.wezterm"; inherit package; }; - home-manager.sharedModules = [{ - programs.wezterm = { - enable = true; - inherit package; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.wezterm = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/wob/hm.nix b/modules/wob/hm.nix index e4f221b0b..ad68738c9 100644 --- a/modules/wob/hm.nix +++ b/modules/wob/hm.nix @@ -1,8 +1,7 @@ { config, lib, ... }: { - options.stylix.targets.wob.enable = - config.lib.stylix.mkEnableTarget "wob" true; + options.stylix.targets.wob.enable = config.lib.stylix.mkEnableTarget "wob" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.wob.enable) { services.wob.settings = { diff --git a/modules/wofi/hm.nix b/modules/wofi/hm.nix index a614935fe..1db9114c8 100644 --- a/modules/wofi/hm.nix +++ b/modules/wofi/hm.nix @@ -3,9 +3,11 @@ lib, ... }: -with config.stylix.fonts; let +with config.stylix.fonts; +let colors = config.lib.stylix.colors.withHashtag; -in { +in +{ options.stylix.targets.wofi.enable = config.lib.stylix.mkEnableTarget "wofi" config.programs.wofi.enable; diff --git a/modules/wpaperd/hm.nix b/modules/wpaperd/hm.nix index c117d6f61..d8ff92b71 100644 --- a/modules/wpaperd/hm.nix +++ b/modules/wpaperd/hm.nix @@ -1,17 +1,19 @@ { config, lib, ... }: { - options.stylix.targets.wpaperd.enable = config.lib.stylix.mkEnableTarget "wpaperd" true; + options.stylix.targets.wpaperd.enable = + config.lib.stylix.mkEnableTarget "wpaperd" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable) { - programs.wpaperd.settings.any = { - path = "${config.stylix.image}"; - mode = let - inherit (config.stylix) imageScalingMode; - in - if imageScalingMode == "fill" - then "fit" - else imageScalingMode; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable) + { + programs.wpaperd.settings.any = { + path = "${config.stylix.image}"; + mode = + let + inherit (config.stylix) imageScalingMode; + in + if imageScalingMode == "fill" then "fit" else imageScalingMode; + }; + }; } diff --git a/modules/xresources/hm.nix b/modules/xresources/hm.nix index 7d640ed98..1bfc504f9 100644 --- a/modules/xresources/hm.nix +++ b/modules/xresources/hm.nix @@ -4,30 +4,35 @@ options.stylix.targets.xresources.enable = config.lib.stylix.mkEnableTarget "Xresources" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.xresources.enable) { - xresources.properties = with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; { - "*.faceName" = monospace.name; - "*.faceSize" = toString sizes.terminal; - "*.renderFont" = true; - "*foreground" = base05; - "*background" = base00; - "*cursorColor" = base05; - "*color0" = base00; - "*color1" = base08; - "*color2" = base0B; - "*color3" = base0A; - "*color4" = base0D; - "*color5" = base0E; - "*color6" = base0C; - "*color7" = base05; - "*color8" = base03; - "*color9" = base09; - "*color10" = base01; - "*color11" = base02; - "*color12" = base04; - "*color13" = base06; - "*color14" = base0F; - "*color15" = base07; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.xresources.enable) + { + xresources.properties = + with config.lib.stylix.colors.withHashtag; + with config.stylix.fonts; + { + "*.faceName" = monospace.name; + "*.faceSize" = toString sizes.terminal; + "*.renderFont" = true; + "*foreground" = base05; + "*background" = base00; + "*cursorColor" = base05; + "*color0" = base00; + "*color1" = base08; + "*color2" = base0B; + "*color3" = base0A; + "*color4" = base0D; + "*color5" = base0E; + "*color6" = base0C; + "*color7" = base05; + "*color8" = base03; + "*color9" = base09; + "*color10" = base01; + "*color11" = base02; + "*color12" = base04; + "*color13" = base06; + "*color14" = base0F; + "*color15" = base07; + }; + }; } diff --git a/modules/yazi/hm.nix b/modules/yazi/hm.nix index 7ff40c561..1db383b77 100644 --- a/modules/yazi/hm.nix +++ b/modules/yazi/hm.nix @@ -3,125 +3,141 @@ config, lib, ... -}: { +}: +{ options.stylix.targets.yazi = { enable = config.lib.stylix.mkEnableTarget "Yazi" true; }; config = lib.mkIf (config.stylix.enable && config.stylix.targets.yazi.enable) { - programs.yazi.theme = with config.lib.stylix.colors.withHashtag; let - mkFg = fg: {inherit fg;}; - mkBg = bg: {inherit bg;}; - mkBoth = fg: bg: {inherit fg bg;}; - mkSame = c: (mkBoth c c); - in { - manager = rec { - # Reusing bat themes, since it's suggested in the stying guide - # https://yazi-rs.github.io/docs/configuration/theme#manager - syntect_theme = config.lib.stylix.colors { - template = ../bat/base16-stylix.mustache; - extension = ".tmTheme"; - }; + programs.yazi.theme = + with config.lib.stylix.colors.withHashtag; + let + mkFg = fg: { inherit fg; }; + mkBg = bg: { inherit bg; }; + mkBoth = fg: bg: { inherit fg bg; }; + mkSame = c: (mkBoth c c); + in + { + manager = rec { + # Reusing bat themes, since it's suggested in the stying guide + # https://yazi-rs.github.io/docs/configuration/theme#manager + syntect_theme = config.lib.stylix.colors { + template = ../bat/base16-stylix.mustache; + extension = ".tmTheme"; + }; - cwd = mkFg cyan; - hovered = (mkBoth base05 base03) // {bold = true;}; - preview_hovered = hovered; - find_keyword = (mkFg green) // {bold = true;}; - find_position = mkFg base05; - marker_selected = mkSame yellow; - marker_copied = mkSame green; - marker_cut = mkSame red; - tab_active = mkBoth base00 blue; - tab_inactive = mkBoth base05 base01; - border_style = mkFg base04; - }; + cwd = mkFg cyan; + hovered = (mkBoth base05 base03) // { + bold = true; + }; + preview_hovered = hovered; + find_keyword = (mkFg green) // { + bold = true; + }; + find_position = mkFg base05; + marker_selected = mkSame yellow; + marker_copied = mkSame green; + marker_cut = mkSame red; + tab_active = mkBoth base00 blue; + tab_inactive = mkBoth base05 base01; + border_style = mkFg base04; + }; - mode = { - normal_main = (mkBoth base00 blue) // {bold = true;}; - normal_alt = mkBoth blue base00; - select_main = (mkBoth base00 green) // {bold = true;}; - select_alt = mkBoth green base00; - unset_main = (mkBoth base00 brown) // {bold = true;}; - unset_alt = mkBoth brown base00; - }; + mode = { + normal_main = (mkBoth base00 blue) // { + bold = true; + }; + normal_alt = mkBoth blue base00; + select_main = (mkBoth base00 green) // { + bold = true; + }; + select_alt = mkBoth green base00; + unset_main = (mkBoth base00 brown) // { + bold = true; + }; + unset_alt = mkBoth brown base00; + }; - status = { - progress_label = mkBoth base05 base00; - progress_normal = mkBoth base05 base00; - progress_error = mkBoth red base00; - perm_type = mkFg blue; - perm_read = mkFg yellow; - perm_write = mkFg red; - perm_exec = mkFg green; - perm_sep = mkFg cyan; - }; + status = { + progress_label = mkBoth base05 base00; + progress_normal = mkBoth base05 base00; + progress_error = mkBoth red base00; + perm_type = mkFg blue; + perm_read = mkFg yellow; + perm_write = mkFg red; + perm_exec = mkFg green; + perm_sep = mkFg cyan; + }; - pick = { - border = mkFg blue; - active = mkFg magenta; - inactive = mkFg base05; - }; + pick = { + border = mkFg blue; + active = mkFg magenta; + inactive = mkFg base05; + }; - input = { - border = mkFg blue; - title = mkFg base05; - value = mkFg base05; - selected = mkBg base03; - }; + input = { + border = mkFg blue; + title = mkFg base05; + value = mkFg base05; + selected = mkBg base03; + }; - completion = { - border = mkFg blue; - active = mkBoth magenta base03; - inactive = mkFg base05; - }; + completion = { + border = mkFg blue; + active = mkBoth magenta base03; + inactive = mkFg base05; + }; - tasks = { - border = mkFg blue; - title = mkFg base05; - hovered = mkBoth base05 base03; - }; + tasks = { + border = mkFg blue; + title = mkFg base05; + hovered = mkBoth base05 base03; + }; - which = { - mask = mkBg base02; - cand = mkFg cyan; - rest = mkFg brown; - desc = mkFg base05; - separator_style = mkFg base04; - }; + which = { + mask = mkBg base02; + cand = mkFg cyan; + rest = mkFg brown; + desc = mkFg base05; + separator_style = mkFg base04; + }; - help = { - on = mkFg magenta; - run = mkFg cyan; - desc = mkFg base05; - hovered = mkBoth base05 base03; - footer = mkFg base05; - }; + help = { + on = mkFg magenta; + run = mkFg cyan; + desc = mkFg base05; + hovered = mkBoth base05 base03; + footer = mkFg base05; + }; - # https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml - filetype.rules = let - mkRule = mime: fg: {inherit mime fg;}; - in [ - (mkRule "image/*" cyan) - (mkRule "video/*" yellow) - (mkRule "audio/*" yellow) + # https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml + filetype.rules = + let + mkRule = mime: fg: { inherit mime fg; }; + in + [ + (mkRule "image/*" cyan) + (mkRule "video/*" yellow) + (mkRule "audio/*" yellow) - (mkRule "application/zip" magenta) - (mkRule "application/gzip" magenta) - (mkRule "application/tar" magenta) - (mkRule "application/bzip" magenta) - (mkRule "application/bzip2" magenta) - (mkRule "application/7z-compressed" magenta) - (mkRule "application/rar" magenta) - (mkRule "application/xz" magenta) + (mkRule "application/zip" magenta) + (mkRule "application/gzip" magenta) + (mkRule "application/tar" magenta) + (mkRule "application/bzip" magenta) + (mkRule "application/bzip2" magenta) + (mkRule "application/7z-compressed" magenta) + (mkRule "application/rar" magenta) + (mkRule "application/xz" magenta) - (mkRule "application/doc" green) - (mkRule "application/pdf" green) - (mkRule "application/rtf" green) - (mkRule "application/vnd.*" green) + (mkRule "application/doc" green) + (mkRule "application/pdf" green) + (mkRule "application/rtf" green) + (mkRule "application/vnd.*" green) - ((mkRule "inode/directory" blue) // {bold = true;}) - (mkRule "*" base05) - ]; - }; + ((mkRule "inode/directory" blue) // { bold = true; }) + (mkRule "*" base05) + ]; + }; }; } diff --git a/modules/zathura/hm.nix b/modules/zathura/hm.nix index 35124deef..3c2f74751 100644 --- a/modules/zathura/hm.nix +++ b/modules/zathura/hm.nix @@ -4,35 +4,44 @@ options.stylix.targets.zathura.enable = config.lib.stylix.mkEnableTarget "Zathura" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.zathura.enable) { - programs.zathura.options = let - highlightTransparency = "0.5"; - getColorCh = colorName: channel: config.lib.stylix.colors."${colorName}-rgb-${channel}"; - rgb = color: ''rgb(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"})''; - rgba = color: ''rgba(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"}, ${highlightTransparency})''; - in { - # Taken from here: - # https://github.com/doenerkebap/base16-zathura - default-bg = rgb "base00"; - default-fg = rgb "base01"; - statusbar-fg = rgb "base04"; - statusbar-bg = rgb "base02"; - inputbar-bg = rgb "base00"; - inputbar-fg = rgb "base07"; - notification-bg = rgb "base00"; - notification-fg = rgb "base07"; - notification-error-bg = rgb "base00"; - notification-error-fg = rgb "base08"; - notification-warning-bg = rgb "base00"; - notification-warning-fg = rgb "base08"; - highlight-color = rgba "base0A"; - highlight-active-color = rgba "base0D"; - completion-bg = rgb "base01"; - completion-fg = rgb "base0D"; - completion-highlight-fg = rgb "base07"; - completion-highlight-bg = rgb "base0D"; - recolor-lightcolor = rgb "base00"; - recolor-darkcolor = rgb "base06"; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.zathura.enable) + { + programs.zathura.options = + let + highlightTransparency = "0.5"; + getColorCh = + colorName: channel: config.lib.stylix.colors."${colorName}-rgb-${channel}"; + rgb = + color: + ''rgb(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"})''; + rgba = + color: + ''rgba(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"}, ${highlightTransparency})''; + in + { + # Taken from here: + # https://github.com/doenerkebap/base16-zathura + default-bg = rgb "base00"; + default-fg = rgb "base01"; + statusbar-fg = rgb "base04"; + statusbar-bg = rgb "base02"; + inputbar-bg = rgb "base00"; + inputbar-fg = rgb "base07"; + notification-bg = rgb "base00"; + notification-fg = rgb "base07"; + notification-error-bg = rgb "base00"; + notification-error-fg = rgb "base08"; + notification-warning-bg = rgb "base00"; + notification-warning-fg = rgb "base08"; + highlight-color = rgba "base0A"; + highlight-active-color = rgba "base0D"; + completion-bg = rgb "base01"; + completion-fg = rgb "base0D"; + completion-highlight-fg = rgb "base07"; + completion-highlight-bg = rgb "base0D"; + recolor-lightcolor = rgb "base00"; + recolor-darkcolor = rgb "base06"; + }; + }; } diff --git a/modules/zathura/testbed.nix b/modules/zathura/testbed.nix index 7e61e507c..861bfa088 100644 --- a/modules/zathura/testbed.nix +++ b/modules/zathura/testbed.nix @@ -1,18 +1,22 @@ { pkgs, ... }: -let package = pkgs.zathura; +let + package = pkgs.zathura; -in { +in +{ stylix.testbed.application = { enable = true; name = "org.pwmt.zathura"; inherit package; }; - home-manager.sharedModules = [{ - programs.zathura = { - enable = true; - inherit package; - }; - }]; -} \ No newline at end of file + home-manager.sharedModules = [ + { + programs.zathura = { + enable = true; + inherit package; + }; + } + ]; +} diff --git a/modules/zellij/hm.nix b/modules/zellij/hm.nix index 2c2dc27fb..9e461f7a8 100644 --- a/modules/zellij/hm.nix +++ b/modules/zellij/hm.nix @@ -1,29 +1,35 @@ { config, lib, ... }: { - options.stylix.targets.zellij.enable = config.lib.stylix.mkEnableTarget "zellij" true; + options.stylix.targets.zellij.enable = + config.lib.stylix.mkEnableTarget "zellij" true; config = lib.mkIf - (config.stylix.enable && config.stylix.targets.zellij.enable && config.programs.zellij.enable) + ( + config.stylix.enable + && config.stylix.targets.zellij.enable + && config.programs.zellij.enable + ) { - xdg.configFile."zellij/themes/stylix.kdl".text = with config.lib.stylix.colors.withHashtag; '' - themes { - default { - bg "${base03}"; - fg "${base05}"; - red "${base01}"; - green "${base0B}"; - blue "${base0D}"; - yellow "${base0A}"; - magenta "${base0E}"; - orange "${base09}"; - cyan "${base0C}"; - black "${base00}"; - white "${base07}"; + xdg.configFile."zellij/themes/stylix.kdl".text = + with config.lib.stylix.colors.withHashtag; '' + themes { + default { + bg "${base03}"; + fg "${base05}"; + red "${base01}"; + green "${base0B}"; + blue "${base0D}"; + yellow "${base0A}"; + magenta "${base0E}"; + orange "${base09}"; + cyan "${base0C}"; + black "${base00}"; + white "${base07}"; + } } - } - ''; + ''; }; } diff --git a/palette-generator/default.nix b/palette-generator/default.nix index 0bde88779..99a7c2487 100644 --- a/palette-generator/default.nix +++ b/palette-generator/default.nix @@ -1,12 +1,14 @@ { haskellPackages, stdenvNoCC }: let - ghc = haskellPackages.ghcWithPackages (ps: with ps; [ - JuicyPixels - json - random - vector-algorithms - ]); + ghc = haskellPackages.ghcWithPackages ( + ps: with ps; [ + JuicyPixels + json + random + vector-algorithms + ] + ); # `nix build .#palette-generator.passthru.docs` and open in a web browser docs = stdenvNoCC.mkDerivation { @@ -22,7 +24,8 @@ let dontFixup = true; }; -in stdenvNoCC.mkDerivation { +in +stdenvNoCC.mkDerivation { name = "palette-generator"; src = ./.; diff --git a/stylix/autoload.nix b/stylix/autoload.nix index 8610ebcac..c549e42fb 100644 --- a/stylix/autoload.nix +++ b/stylix/autoload.nix @@ -3,12 +3,15 @@ # string -> [ path ] # List include path for either nixos modules or hm modules for: - builtins.concatLists - (lib.mapAttrsToList - (path: kind: - if kind == "directory" - then let - file = "${inputs.self}/modules/${path}/${for}.nix"; - in if builtins.pathExists file then [ file ] else [ ] - else [ ]) - (builtins.readDir "${inputs.self}/modules")) +builtins.concatLists ( + lib.mapAttrsToList ( + path: kind: + if kind == "directory" then + let + file = "${inputs.self}/modules/${path}/${for}.nix"; + in + if builtins.pathExists file then [ file ] else [ ] + else + [ ] + ) (builtins.readDir "${inputs.self}/modules") +) diff --git a/stylix/cursor.nix b/stylix/cursor.nix index fadbd3670..412cf6782 100644 --- a/stylix/cursor.nix +++ b/stylix/cursor.nix @@ -1,21 +1,21 @@ { pkgs, lib, ... }: { - options.stylix.cursor = { - name = lib.mkOption { - description = "The cursor name within the package."; - type = lib.types.str; - default = "Vanilla-DMZ"; - }; - package = lib.mkOption { - description = "Package providing the cursor theme."; - type = lib.types.package; - default = pkgs.vanilla-dmz; - }; - size = lib.mkOption { - description = "The cursor size."; - type = lib.types.int; - default = 32; - }; + options.stylix.cursor = { + name = lib.mkOption { + description = "The cursor name within the package."; + type = lib.types.str; + default = "Vanilla-DMZ"; }; + package = lib.mkOption { + description = "Package providing the cursor theme."; + type = lib.types.package; + default = pkgs.vanilla-dmz; + }; + size = lib.mkOption { + description = "The cursor size."; + type = lib.types.int; + default = 32; + }; + }; } diff --git a/stylix/darwin/default.nix b/stylix/darwin/default.nix index a4eca70ca..6a85d5e80 100644 --- a/stylix/darwin/default.nix +++ b/stylix/darwin/default.nix @@ -1,10 +1,15 @@ inputs: -{ palette-generator, base16, homeManagerModule }: +{ + palette-generator, + base16, + homeManagerModule, +}: { lib, ... }: let autoload = import ../autoload.nix { inherit lib inputs; } "darwin"; -in { +in +{ imports = [ ../pixel.nix ../target.nix diff --git a/stylix/darwin/fonts.nix b/stylix/darwin/fonts.nix index eff55ea30..ed72158ff 100644 --- a/stylix/darwin/fonts.nix +++ b/stylix/darwin/fonts.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.fonts; -in { +in +{ imports = [ ../fonts.nix ]; config.fonts = lib.mkIf config.stylix.enable { inherit (cfg) packages; diff --git a/stylix/fonts.nix b/stylix/fonts.nix index 74eac7923..d2b63d78e 100644 --- a/stylix/fonts.nix +++ b/stylix/fonts.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.stylix.fonts; @@ -17,7 +22,8 @@ let }; }; -in { +in +{ options.stylix.fonts = { serif = lib.mkOption { description = "Serif font."; diff --git a/stylix/hm/cursor.nix b/stylix/hm/cursor.nix index dd2794710..a8217427a 100644 --- a/stylix/hm/cursor.nix +++ b/stylix/hm/cursor.nix @@ -1,9 +1,15 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.stylix.cursor; -in { +in +{ imports = [ ../cursor.nix ]; config = lib.mkIf (config.stylix.enable && pkgs.stdenv.hostPlatform.isLinux) { diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index e81e5910c..d160a0327 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -4,14 +4,15 @@ inputs: let autoload = import ../autoload.nix { inherit lib inputs; } "hm"; -in { +in +{ imports = [ ../pixel.nix ../target.nix ../opacity.nix ./cursor.nix ./fonts.nix - ./icon.nix + ./icon.nix (import ./palette.nix { inherit palette-generator base16; }) (import ../templates.nix inputs) ] ++ autoload; diff --git a/stylix/hm/fonts.nix b/stylix/hm/fonts.nix index 98f572c57..a7b46e6f2 100644 --- a/stylix/hm/fonts.nix +++ b/stylix/hm/fonts.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.fonts; -in { +in +{ imports = [ ../fonts.nix ]; config = lib.mkIf config.stylix.enable { fonts.fontconfig.enable = true; diff --git a/stylix/hm/icon.nix b/stylix/hm/icon.nix index c0d9fddbe..e47e75de9 100644 --- a/stylix/hm/icon.nix +++ b/stylix/hm/icon.nix @@ -1,22 +1,28 @@ { config, lib, ... }: let - cfg = config.stylix.iconTheme; - inherit (config.stylix) polarity; -in { - imports = [ ../icon.nix ]; - config = lib.mkIf (config.stylix.enable && cfg.enable) { - gtk = { - iconTheme = { - inherit (cfg) package; - name = builtins.head (lib.filter (x: null != x) [ - ({ - inherit (cfg) dark light; - }."${polarity}" or null) - cfg.dark - cfg.light - ]); - }; - }; - }; + cfg = config.stylix.iconTheme; + inherit (config.stylix) polarity; +in +{ + imports = [ ../icon.nix ]; + config = lib.mkIf (config.stylix.enable && cfg.enable) { + gtk = { + iconTheme = { + inherit (cfg) package; + name = builtins.head ( + lib.filter (x: null != x) [ + ( + { + inherit (cfg) dark light; + } + ."${polarity}" or null + ) + cfg.dark + cfg.light + ] + ); + }; + }; + }; } diff --git a/stylix/home-manager-integration.nix b/stylix/home-manager-integration.nix index 5afe202b1..eb4a3bb02 100644 --- a/stylix/home-manager-integration.nix +++ b/stylix/home-manager-integration.nix @@ -1,46 +1,183 @@ homeManagerModule: -{ lib, config, options, ... }: +{ + lib, + config, + options, + ... +}: let - copyModules = builtins.map - ( - { path, condition ? lib.const true }: - { config, osConfig, ... }: - lib.mkIf (condition config) - (lib.setAttrByPath path (lib.mkDefault (lib.getAttrFromPath path osConfig))) - ) - [ - { path = [ "stylix" "autoEnable" ]; } - { - path = [ "stylix" "base16Scheme" ]; - condition = homeConfig: config.stylix.image == homeConfig.stylix.image; - } - { path = [ "stylix" "cursor" "name" ]; } - { path = [ "stylix" "cursor" "package" ]; } - { path = [ "stylix" "cursor" "size" ]; } - { path = [ "stylix" "enable" ]; } - { path = [ "stylix" "fonts" "serif" ]; } - { path = [ "stylix" "fonts" "sansSerif" ]; } - { path = [ "stylix" "fonts" "monospace" ]; } - { path = [ "stylix" "fonts" "emoji" ]; } - { path = [ "stylix" "fonts" "sizes" "desktop" ]; } - { path = [ "stylix" "fonts" "sizes" "applications" ]; } - { path = [ "stylix" "fonts" "sizes" "terminal" ]; } - { path = [ "stylix" "fonts" "sizes" "popups" ]; } - { path = [ "stylix" "image" ]; } - { path = [ "stylix" "imageScalingMode" ]; } - { path = [ "stylix" "opacity" "desktop" ]; } - { path = [ "stylix" "opacity" "applications" ]; } - { path = [ "stylix" "opacity" "terminal" ]; } - { path = [ "stylix" "opacity" "popups" ]; } - { - path = [ "stylix" "override" ]; - condition = homeConfig: config.stylix.base16Scheme == homeConfig.stylix.base16Scheme; - } - { path = [ "stylix" "polarity" ]; } - ]; + copyModules = + builtins.map + ( + { + path, + condition ? lib.const true, + }: + { config, osConfig, ... }: + lib.mkIf (condition config) ( + lib.setAttrByPath path (lib.mkDefault (lib.getAttrFromPath path osConfig)) + ) + ) + [ + { + path = [ + "stylix" + "autoEnable" + ]; + } + { + path = [ + "stylix" + "base16Scheme" + ]; + condition = homeConfig: config.stylix.image == homeConfig.stylix.image; + } + { + path = [ + "stylix" + "cursor" + "name" + ]; + } + { + path = [ + "stylix" + "cursor" + "package" + ]; + } + { + path = [ + "stylix" + "cursor" + "size" + ]; + } + { + path = [ + "stylix" + "enable" + ]; + } + { + path = [ + "stylix" + "fonts" + "serif" + ]; + } + { + path = [ + "stylix" + "fonts" + "sansSerif" + ]; + } + { + path = [ + "stylix" + "fonts" + "monospace" + ]; + } + { + path = [ + "stylix" + "fonts" + "emoji" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "desktop" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "applications" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "terminal" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "popups" + ]; + } + { + path = [ + "stylix" + "image" + ]; + } + { + path = [ + "stylix" + "imageScalingMode" + ]; + } + { + path = [ + "stylix" + "opacity" + "desktop" + ]; + } + { + path = [ + "stylix" + "opacity" + "applications" + ]; + } + { + path = [ + "stylix" + "opacity" + "terminal" + ]; + } + { + path = [ + "stylix" + "opacity" + "popups" + ]; + } + { + path = [ + "stylix" + "override" + ]; + condition = + homeConfig: config.stylix.base16Scheme == homeConfig.stylix.base16Scheme; + } + { + path = [ + "stylix" + "polarity" + ]; + } + ]; -in { +in +{ options.stylix.homeManagerIntegration = { followSystem = lib.mkOption { description = '' @@ -69,11 +206,11 @@ in { }; }; - config = - lib.optionalAttrs (options ? home-manager) - (lib.mkIf config.stylix.homeManagerIntegration.autoImport { + config = lib.optionalAttrs (options ? home-manager) ( + lib.mkIf config.stylix.homeManagerIntegration.autoImport { home-manager.sharedModules = - [ homeManagerModule ] ++ - (lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules); - }); + [ homeManagerModule ] + ++ (lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules); + } + ); } diff --git a/stylix/icon.nix b/stylix/icon.nix index 02dfbcb40..cb7b8db4f 100644 --- a/stylix/icon.nix +++ b/stylix/icon.nix @@ -1,26 +1,26 @@ { lib, ... }: { - options.stylix.iconTheme = { - enable = lib.mkOption { - description = "enable/disable icon theming."; - type = lib.types.bool; - default = false; - }; - package = lib.mkOption { - description = "Package providing the icon theme."; - type = lib.types.nullOr lib.types.package; - default = null; - }; - light = lib.mkOption { - description = "Light icon theme name."; - type = lib.types.nullOr lib.types.str; - default = null; - }; - dark = lib.mkOption { - description = "Dark icon theme name."; - type = lib.types.nullOr lib.types.str; - default = null; - }; + options.stylix.iconTheme = { + enable = lib.mkOption { + description = "enable/disable icon theming."; + type = lib.types.bool; + default = false; }; + package = lib.mkOption { + description = "Package providing the icon theme."; + type = lib.types.nullOr lib.types.package; + default = null; + }; + light = lib.mkOption { + description = "Light icon theme name."; + type = lib.types.nullOr lib.types.str; + default = null; + }; + dark = lib.mkOption { + description = "Dark icon theme name."; + type = lib.types.nullOr lib.types.str; + default = null; + }; + }; } diff --git a/stylix/nixos/cursor.nix b/stylix/nixos/cursor.nix index bc200e4a0..576ad544a 100644 --- a/stylix/nixos/cursor.nix +++ b/stylix/nixos/cursor.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.cursor; -in { +in +{ imports = [ ../cursor.nix ]; config = lib.mkIf config.stylix.enable { environment.variables.XCURSOR_SIZE = toString cfg.size; diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index eba040588..49046fe0b 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -1,10 +1,15 @@ inputs: -{ palette-generator, base16, homeManagerModule }: +{ + palette-generator, + base16, + homeManagerModule, +}: { lib, ... }: let autoload = import ../autoload.nix { inherit lib inputs; } "nixos"; -in { +in +{ imports = [ ../pixel.nix ../target.nix diff --git a/stylix/nixos/fonts.nix b/stylix/nixos/fonts.nix index 495c842cd..571a527b7 100644 --- a/stylix/nixos/fonts.nix +++ b/stylix/nixos/fonts.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.fonts; -in { +in +{ imports = [ ../fonts.nix ]; config.fonts = lib.mkIf config.stylix.enable { inherit (cfg) packages; diff --git a/stylix/opacity.nix b/stylix/opacity.nix index 88d68392a..5fe4871ab 100644 --- a/stylix/opacity.nix +++ b/stylix/opacity.nix @@ -1,26 +1,26 @@ { lib, ... }: { - options.stylix.opacity = { - desktop = lib.mkOption { - description = "The opacity of the windows of bars/widgets, the amount of applications supported is currently limited"; - type = lib.types.float; - default = 1.0; - }; - applications = lib.mkOption { - description = "The opacity of the windows of applications, the amount of applications supported is currently limited"; - type = lib.types.float; - default = 1.0; - }; - terminal = lib.mkOption { - description = "The opacity of the windows of terminals, this works across all terminals supported by stylix"; - type = lib.types.float; - default = 1.0; - }; - popups = lib.mkOption { - description = "The opacity of the windows of notifications/popups, the amount of applications supported is currently limited"; - type = lib.types.float; - default = 1.0; - }; + options.stylix.opacity = { + desktop = lib.mkOption { + description = "The opacity of the windows of bars/widgets, the amount of applications supported is currently limited"; + type = lib.types.float; + default = 1.0; }; + applications = lib.mkOption { + description = "The opacity of the windows of applications, the amount of applications supported is currently limited"; + type = lib.types.float; + default = 1.0; + }; + terminal = lib.mkOption { + description = "The opacity of the windows of terminals, this works across all terminals supported by stylix"; + type = lib.types.float; + default = 1.0; + }; + popups = lib.mkOption { + description = "The opacity of the windows of notifications/popups, the amount of applications supported is currently limited"; + type = lib.types.float; + default = 1.0; + }; + }; } diff --git a/stylix/palette.nix b/stylix/palette.nix index e299d68dc..86518b789 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -1,29 +1,41 @@ { palette-generator, base16 }: -{ pkgs, lib, config, ... }: +{ + pkgs, + lib, + config, + ... +}: let cfg = config.stylix; - paletteJSON = let - generatedJSON = pkgs.runCommand "palette.json" { } '' - ${palette-generator}/bin/palette-generator \ - "${cfg.polarity}" \ - ${lib.escapeShellArg "${cfg.image}"} \ - "$out" - ''; - palette = lib.importJSON generatedJSON; - scheme = base16.mkSchemeAttrs palette; - json = scheme { - template = ./palette.json.mustache; - extension = ".json"; - }; - in json; + paletteJSON = + let + generatedJSON = pkgs.runCommand "palette.json" { } '' + ${palette-generator}/bin/palette-generator \ + "${cfg.polarity}" \ + ${lib.escapeShellArg "${cfg.image}"} \ + "$out" + ''; + palette = lib.importJSON generatedJSON; + scheme = base16.mkSchemeAttrs palette; + json = scheme { + template = ./palette.json.mustache; + extension = ".json"; + }; + in + json; generatedScheme = lib.importJSON paletteJSON; -in { +in +{ options.stylix = { polarity = lib.mkOption { - type = lib.types.enum [ "either" "light" "dark" ]; + type = lib.types.enum [ + "either" + "light" + "dark" + ]; default = "either"; description = '' Use this option to force a light or dark theme. @@ -45,7 +57,13 @@ in { }; imageScalingMode = lib.mkOption { - type = lib.types.enum [ "stretch" "fill" "fit" "center" "tile" ]; + type = lib.types.enum [ + "stretch" + "fill" + "fit" + "center" + "tile" + ]; default = "fill"; description = '' Scaling mode for the wallpaper image. @@ -98,7 +116,13 @@ in { This can be a path to a file, a string of YAML, or an attribute set. ''; - type = with lib.types; oneOf [ path lines attrs ]; + type = + with lib.types; + oneOf [ + path + lines + attrs + ]; default = generatedScheme; defaultText = lib.literalMD '' The colors used in the theming. @@ -117,7 +141,7 @@ in { to override. ''; type = lib.types.attrs; - default = {}; + default = { }; }; }; diff --git a/stylix/pixel.nix b/stylix/pixel.nix index 7c1049286..212933fe6 100644 --- a/stylix/pixel.nix +++ b/stylix/pixel.nix @@ -2,7 +2,8 @@ { # Generate a PNG image containing a named color - config.lib.stylix.pixel = color: + config.lib.stylix.pixel = + color: pkgs.runCommand "${color}-pixel.png" { color = config.lib.stylix.colors.withHashtag.${color}; } "${pkgs.imagemagick}/bin/convert xc:$color png32:$out"; diff --git a/stylix/target.nix b/stylix/target.nix index c1908da82..a3d5056e4 100644 --- a/stylix/target.nix +++ b/stylix/target.nix @@ -31,18 +31,17 @@ }; }; - config.lib.stylix.mkEnableTarget = let - cfg = config.stylix; - in - humanName: - autoEnable: - lib.mkEnableOption - "theming for ${humanName}" - // { - default = cfg.enable && cfg.autoEnable && autoEnable; - example = !autoEnable; - } - // lib.optionalAttrs autoEnable { - defaultText = lib.literalMD "same as [`stylix.autoEnable`](#stylixautoenable)"; - }; + config.lib.stylix.mkEnableTarget = + let + cfg = config.stylix; + in + humanName: autoEnable: + lib.mkEnableOption "theming for ${humanName}" + // { + default = cfg.enable && cfg.autoEnable && autoEnable; + example = !autoEnable; + } + // lib.optionalAttrs autoEnable { + defaultText = lib.literalMD "same as [`stylix.autoEnable`](#stylixautoenable)"; + }; } diff --git a/stylix/templates.nix b/stylix/templates.nix index a3457d0de..7c779d4e1 100644 --- a/stylix/templates.nix +++ b/stylix/templates.nix @@ -1,5 +1,4 @@ -inputs: -{ +inputs: { config.lib.stylix.templates = { inherit (inputs) base16-fish diff --git a/stylix/testbed.nix b/stylix/testbed.nix index adf4be536..a0a710e35 100644 --- a/stylix/testbed.nix +++ b/stylix/testbed.nix @@ -1,97 +1,107 @@ -{ pkgs, inputs, lib, ... }: +{ + pkgs, + inputs, + lib, + ... +}: let username = "guest"; - commonModule = { config, ... }: { - users.users.${username} = { - description = "Guest"; - hashedPassword = ""; - isNormalUser = true; - extraGroups = [ "wheel" ]; - }; + commonModule = + { config, ... }: + { + users.users.${username} = { + description = "Guest"; + hashedPassword = ""; + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; - security.sudo.wheelNeedsPassword = false; + security.sudo.wheelNeedsPassword = false; - # The state version can safely track the latest release because the disk - # image is ephemeral. - system.stateVersion = config.system.nixos.release; - home-manager.users.${username}.home.stateVersion = config.system.nixos.release; + # The state version can safely track the latest release because the disk + # image is ephemeral. + system.stateVersion = config.system.nixos.release; + home-manager.users.${username}.home.stateVersion = config.system.nixos.release; - virtualisation.vmVariant.virtualisation = { - # This is a maximum limit; the VM should still work if the host has fewer cores. - cores = 4; - memorySize = lib.mkDefault 2048; - }; - }; - - applicationModule = { config, lib, ... }: { - options.stylix.testbed.application = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - description = '' - Whether to enable a standard configuration for testing individual - applications. - - This will automatically log in as the `${username}` user, then launch - the application from its desktop entry. - - This is currently based on GNOME, but the specific desktop environment - used may change in the future. - ''; + virtualisation.vmVariant.virtualisation = { + # This is a maximum limit; the VM should still work if the host has fewer cores. + cores = 4; + memorySize = lib.mkDefault 2048; }; + }; - name = lib.mkOption { - type = lib.types.str; - description = '' - The name of the desktop entry for the application, without the - `.desktop` extension. - ''; - }; + applicationModule = + { config, lib, ... }: + { + options.stylix.testbed.application = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Whether to enable a standard configuration for testing individual + applications. + + This will automatically log in as the `${username}` user, then launch + the application from its desktop entry. + + This is currently based on GNOME, but the specific desktop environment + used may change in the future. + ''; + }; - package = lib.mkOption { - type = lib.types.package; - description = '' - The application being tested. - ''; - }; - }; + name = lib.mkOption { + type = lib.types.str; + description = '' + The name of the desktop entry for the application, without the + `.desktop` extension. + ''; + }; - config = lib.mkIf config.stylix.testbed.application.enable { - services.xserver = { - enable = true; - displayManager.gdm.enable = true; - desktopManager.gnome.enable = true; + package = lib.mkOption { + type = lib.types.package; + description = '' + The application being tested. + ''; + }; }; - services.displayManager.autoLogin = { - enable = true; - user = username; - }; + config = lib.mkIf config.stylix.testbed.application.enable { + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; + + services.displayManager.autoLogin = { + enable = true; + user = username; + }; - # Disable the GNOME tutorial which pops up on first login. - environment.gnome.excludePackages = [ pkgs.gnome-tour ]; + # Disable the GNOME tutorial which pops up on first login. + environment.gnome.excludePackages = [ pkgs.gnome-tour ]; - environment.systemPackages = [ - (pkgs.makeAutostartItem { - inherit (config.stylix.testbed.application) name package; - }) - ]; + environment.systemPackages = [ + (pkgs.makeAutostartItem { + inherit (config.stylix.testbed.application) name package; + }) + ]; + }; }; - }; - autoload = builtins.concatLists - (lib.mapAttrsToList - (name: _: - let testbed = { + autoload = builtins.concatLists ( + lib.mapAttrsToList ( + name: _: + let + testbed = { inherit name; module = "${inputs.self}/modules/${name}/testbed.nix"; }; - in - lib.optional (builtins.pathExists testbed.module) testbed - ) - (builtins.readDir "${inputs.self}/modules")); + in + lib.optional (builtins.pathExists testbed.module) testbed + ) (builtins.readDir "${inputs.self}/modules") + ); makeTestbed = testbed: stylix: @@ -134,31 +144,33 @@ let ''; }; in - lib.nameValuePair name script; + lib.nameValuePair name script; # This generates a copy of each testbed for each of the following themes. - makeTestbeds = testbed: map (makeTestbed testbed) [ - { - enable = true; - image = pkgs.fetchurl { - name = "three-bicycles.jpg"; - url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true"; - hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA="; - }; - base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml"; - polarity = "light"; - } - { - enable = true; - image = pkgs.fetchurl { - name = "mountains.jpg"; - url = "https://unsplash.com/photos/ZqLeQDjY6fY/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzY1NDY4fA&force=true"; - hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58="; - }; - base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml"; - polarity = "dark"; - } - ]; + makeTestbeds = + testbed: + map (makeTestbed testbed) [ + { + enable = true; + image = pkgs.fetchurl { + name = "three-bicycles.jpg"; + url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true"; + hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA="; + }; + base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml"; + polarity = "light"; + } + { + enable = true; + image = pkgs.fetchurl { + name = "mountains.jpg"; + url = "https://unsplash.com/photos/ZqLeQDjY6fY/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzY1NDY4fA&force=true"; + hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58="; + }; + base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml"; + polarity = "dark"; + } + ]; in - lib.listToAttrs (lib.flatten (map makeTestbeds autoload)) +lib.listToAttrs (lib.flatten (map makeTestbeds autoload))