From b1a152c6390f3ba27670e7d1dd92d9a9b4654364 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:16:00 +0100 Subject: [PATCH 01/10] flake: drop unnecessary use of `self` --- flake/modules.nix | 8 ++++---- flake/packages.nix | 13 ++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/flake/modules.nix b/flake/modules.nix index f1f16d72..8c0bce96 100644 --- a/flake/modules.nix +++ b/flake/modules.nix @@ -10,7 +10,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply "${self}/stylix/nixos" inputs) + (lib.modules.importApply ../stylix/nixos inputs) { stylix = { inherit inputs; @@ -27,7 +27,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply "${self}/stylix/hm" inputs) + (lib.modules.importApply ../stylix/hm inputs) { stylix = { inherit inputs; @@ -43,7 +43,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply "${self}/stylix/darwin" inputs) + (lib.modules.importApply ../stylix/darwin inputs) { stylix = { inherit inputs; @@ -60,7 +60,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply "${self}/stylix/droid" inputs) + (lib.modules.importApply ../stylix/droid inputs) { stylix = { paletteGenerator = diff --git a/flake/packages.nix b/flake/packages.nix index 53f57637..6b371cf6 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -1,9 +1,4 @@ -{ - lib, - inputs, - self, - ... -}: +{ lib, inputs, ... }: { perSystem = @@ -17,17 +12,17 @@ # Testbeds are virtual machines based on NixOS, therefore they are # only available for Linux systems. (lib.mkIf pkgs.stdenv.hostPlatform.isLinux ( - import "${self}/stylix/testbed/default.nix" { + import ../stylix/testbed/default.nix { inherit pkgs inputs lib; } )) { - docs = pkgs.callPackage "${self}/doc" { + docs = pkgs.callPackage ../doc { inherit inputs; inherit (inputs.nixpkgs.lib) nixosSystem; inherit (inputs.home-manager.lib) homeManagerConfiguration; }; - palette-generator = pkgs.callPackage "${self}/palette-generator" { }; + palette-generator = pkgs.callPackage ../palette-generator { }; } ]; }; From eaa38e0591497565b097f740512bd7bbe00280e7 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:34:53 +0100 Subject: [PATCH 02/10] doc: drop unnecessary use of `self` --- doc/default.nix | 67 +++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/doc/default.nix b/doc/default.nix index af51265d..f337d8ee 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -13,6 +13,9 @@ }: let + # Prefix to remove from option declaration file paths. + rootPrefix = toString ../. + "/"; + nixosConfiguration = nixosSystem { inherit system; modules = [ @@ -50,7 +53,7 @@ let }; }; - metadata = callPackage "${inputs.self}/stylix/meta.nix" { inherit inputs; }; + metadata = callPackage ../stylix/meta.nix { inherit inputs; }; # We construct an index of all Stylix options, using the following format: # @@ -119,15 +122,10 @@ let option, }: # Only include options which are declared by a module within Stylix. - if lib.hasPrefix "${inputs.self}/" declaration then + if lib.hasPrefix rootPrefix declaration then let - # Part of this string may become an attribute name in the index, and - # attribute names aren't allowed to have string context. The context - # comes from `${inputs.self}`, which is removed by `removePrefix`. - # Therefore, this use of `unsafeDiscardStringContext` is safe. - pathWithContext = lib.removePrefix "${inputs.self}/" declaration; - path = builtins.unsafeDiscardStringContext pathWithContext; - pathComponents = lib.splitString "/" path; + subPath = lib.removePrefix rootPrefix (toString declaration); + pathComponents = lib.splitString "/" subPath; in # Options declared in the modules directory go to the Modules section, # otherwise they're assumed to be shared between modules, and go to the @@ -236,29 +234,30 @@ let }; } else - insert { - inherit index platform option; + let page = "src/options/platforms/${platform}.md"; + path = ./. + "/${page}"; + in + insert { + inherit + index + platform + page + option + ; emptyPage = { referenceSection = "Platforms"; readme = - let - path = "${inputs.self}/doc/src/options/platforms/${platform}.md"; - - # This doesn't count as IFD because ${inputs.self} is a flake input - mainText = - if builtins.pathExists path then - builtins.readFile path - else - '' - # ${platform.name} - > [!NOTE] - > Documentation is not available for this platform. Its - > main options are listed below, and you may find more - > specific options in the documentation for each module. - ''; - in - mainText; + if builtins.pathExists path then + builtins.readFile path + else + '' + # ${platform.name} + > [!NOTE] + > Documentation is not available for this platform. Its + > main options are listed below, and you may find more + > specific options in the documentation for each module. + ''; # Platform pages only initialise that platform, since showing other # platforms here would be nonsensical. @@ -339,9 +338,6 @@ let else throw "unexpected value type: ${builtins.typeOf value}"; - # Prefix to remove from file paths when listing where an option is declared. - declarationPrefix = "${inputs.self}"; - # Permalink to view a source file on GitHub. If the commit isn't known, # then fall back to the latest commit. declarationCommit = inputs.self.rev or "master"; @@ -354,12 +350,11 @@ let declaration: let declarationString = toString declaration; - filePath = lib.removePrefix "${declarationPrefix}/" declarationString; + subPath = lib.removePrefix rootPrefix declarationString; in - if lib.hasPrefix declarationPrefix declarationString then - "- [${filePath}](${declarationPermalink}/${filePath})" - else - throw "declaration not in ${declarationPrefix}: ${declarationString}"; + lib.throwIfNot (lib.hasPrefix rootPrefix declarationString) + "declaration not in ${rootPrefix}: ${declarationString}" + "- [${subPath}](${declarationPermalink}/${subPath})"; # You can embed HTML inside a Markdown document, but to render further # Markdown between the HTML tags, it must be surrounded by blank lines: From 91755e0f1c9bdc52b338b1db64d0814294371c0d Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 03/10] stylix: drop unnecessary use of `self` in testbed --- stylix/testbed/default.nix | 61 ++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/stylix/testbed/default.nix b/stylix/testbed/default.nix index 12ba1727..bcb61484 100644 --- a/stylix/testbed/default.nix +++ b/stylix/testbed/default.nix @@ -8,43 +8,40 @@ let isEnabled = pkgs.callPackage ./is-enabled.nix { }; - autoload = - let - directory = "testbeds"; - modules = "${inputs.self}/modules"; - in - lib.pipe modules [ - builtins.readDir - builtins.attrNames - (builtins.concatMap ( - module: + autoload = lib.pipe ../../modules [ + builtins.readDir + builtins.attrNames + (builtins.concatMap ( + module: + let + testbeds = ../../modules/${module}/testbeds; + files = lib.optionalAttrs (builtins.pathExists testbeds) ( + builtins.readDir testbeds + ); + in + lib.mapAttrsToList ( + testbed: type: let - testbeds = "${modules}/${module}/${directory}"; - files = lib.optionalAttrs (builtins.pathExists testbeds) ( - builtins.readDir testbeds - ); + path = testbeds + "/${testbed}"; + pathStr = toString path; in - lib.mapAttrsToList ( - testbed: type: - if type != "regular" then - throw "${testbed} must be regular: ${type}" + if type != "regular" then + throw "${pathStr} must be regular: ${type}" - else if !lib.hasSuffix ".nix" testbed then - throw "testbed must be a Nix file: ${testbeds}/${testbed}" + else if !lib.hasSuffix ".nix" testbed then + throw "testbed must be a Nix file: ${pathStr}" - else if testbed == ".nix" then - throw "testbed must have a name: ${testbed}" + else if testbed == ".nix" then + throw "testbed must have a name: ${pathStr}" - else - { - inherit module; - - name = lib.removeSuffix ".nix" testbed; - path = "${testbeds}/${testbed}"; - } - ) files - )) - ]; + else + { + inherit module path; + name = lib.removeSuffix ".nix" testbed; + } + ) files + )) + ]; makeTestbed = testbed: themeName: themeModule: From 9fb268f3a601d1799fa6a41d04964dacab16ce6f Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 04/10] stylix: drop unnecessary use of `self` in autoload.nix --- stylix/autoload.nix | 10 +++++----- stylix/darwin/default.nix | 4 ++-- stylix/droid/default.nix | 4 ++-- stylix/hm/default.nix | 4 ++-- stylix/nixos/default.nix | 4 ++-- stylix/overlays.nix | 3 +-- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/stylix/autoload.nix b/stylix/autoload.nix index 5d952e05..34782fbd 100644 --- a/stylix/autoload.nix +++ b/stylix/autoload.nix @@ -1,13 +1,13 @@ -{ lib, inputs }: +{ lib }: # string -> [ path ] # List include path for either nixos modules or hm modules -for: +platform: builtins.concatLists ( lib.mapAttrsToList ( - path: kind: + target: kind: let - file = "${inputs.self}/modules/${path}/${for}.nix"; + file = ../modules/${target}/${platform}.nix; module = import file; # Detect whether the file's value has an argument named `mkTarget` @@ -47,5 +47,5 @@ builtins.concatLists ( else file ) - ) (builtins.readDir "${inputs.self}/modules") + ) (builtins.readDir ../modules) ) diff --git a/stylix/darwin/default.nix b/stylix/darwin/default.nix index fc9e3e1c..de957bf2 100644 --- a/stylix/darwin/default.nix +++ b/stylix/darwin/default.nix @@ -10,7 +10,7 @@ inputs: # documentation. let - autoload = import ../autoload.nix { inherit lib inputs; } "darwin"; + autoload = import ../autoload.nix { inherit lib; } "darwin"; in { imports = [ @@ -23,7 +23,7 @@ in "${inputs.self}/stylix/pixel.nix" "${inputs.self}/stylix/target.nix" "${inputs.self}/stylix/release.nix" - (lib.modules.importApply "${inputs.self}/stylix/overlays.nix" inputs) + "${inputs.self}/stylix/overlays.nix" ] ++ autoload; config.warnings = lib.mkIf diff --git a/stylix/droid/default.nix b/stylix/droid/default.nix index 80cdeba9..9a70dc9e 100644 --- a/stylix/droid/default.nix +++ b/stylix/droid/default.nix @@ -2,7 +2,7 @@ inputs: { lib, ... }: let - autoload = import ../autoload.nix { inherit lib inputs; } "droid"; + autoload = import ../autoload.nix { inherit lib; } "droid"; in { imports = [ @@ -12,7 +12,7 @@ in "${inputs.self}/stylix/palette.nix" "${inputs.self}/stylix/pixel.nix" "${inputs.self}/stylix/target.nix" - (lib.modules.importApply "${inputs.self}/stylix/overlays.nix" inputs) + "${inputs.self}/stylix/overlays.nix" ] ++ autoload; # See https://github.com/nix-community/nix-on-droid/issues/436 diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index 0c7e5ae8..976bb123 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -10,7 +10,7 @@ inputs: # documentation. let - autoload = import ../autoload.nix { inherit lib inputs; } "hm"; + autoload = import ../autoload.nix { inherit lib; } "hm"; in { imports = [ @@ -26,7 +26,7 @@ in "${inputs.self}/stylix/pixel.nix" "${inputs.self}/stylix/target.nix" "${inputs.self}/stylix/release.nix" - (lib.modules.importApply "${inputs.self}/stylix/overlays.nix" inputs) + "${inputs.self}/stylix/overlays.nix" ] ++ autoload; config.warnings = lib.mkIf diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index d08b5314..77f163ba 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -10,7 +10,7 @@ inputs: # documentation. let - autoload = import ../autoload.nix { inherit lib inputs; } "nixos"; + autoload = import ../autoload.nix { inherit lib; } "nixos"; in { imports = [ @@ -25,7 +25,7 @@ in "${inputs.self}/stylix/pixel.nix" "${inputs.self}/stylix/target.nix" "${inputs.self}/stylix/release.nix" - (lib.modules.importApply "${inputs.self}/stylix/overlays.nix" inputs) + "${inputs.self}/stylix/overlays.nix" ] ++ autoload; config.warnings = lib.mkIf diff --git a/stylix/overlays.nix b/stylix/overlays.nix index aefb45e4..3285c2f5 100644 --- a/stylix/overlays.nix +++ b/stylix/overlays.nix @@ -1,4 +1,3 @@ -inputs: { lib, pkgs, @@ -33,5 +32,5 @@ inputs: attrs.overlay ]; } - ) (import ./autoload.nix { inherit lib inputs; } "overlay"); + ) (import ./autoload.nix { inherit lib; } "overlay"); } From 950483a5d09d5ae9bbb8ff38942471b1f1535cfd Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 05/10] stylix: drop unnecessary use of `self` in nixos --- flake/modules.nix | 2 +- stylix/nixos/default.nix | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/flake/modules.nix b/flake/modules.nix index 8c0bce96..08586de1 100644 --- a/flake/modules.nix +++ b/flake/modules.nix @@ -10,7 +10,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply ../stylix/nixos inputs) + ../stylix/nixos { stylix = { inherit inputs; diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index 77f163ba..d5988bce 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -1,31 +1,26 @@ -inputs: { lib, config, ... }: -# Imported modules which define new options must use an absolute path based -# on ${inputs.self}, otherwise those options will not appear in the generated -# documentation. - let autoload = import ../autoload.nix { inherit lib; } "nixos"; in { imports = [ - "${inputs.self}/stylix/cursor.nix" - "${inputs.self}/stylix/fonts.nix" - "${inputs.self}/stylix/home-manager-integration.nix" - "${inputs.self}/stylix/nixos/cursor.nix" - "${inputs.self}/stylix/nixos/fonts.nix" - "${inputs.self}/stylix/nixos/palette.nix" - "${inputs.self}/stylix/opacity.nix" - "${inputs.self}/stylix/palette.nix" - "${inputs.self}/stylix/pixel.nix" - "${inputs.self}/stylix/target.nix" - "${inputs.self}/stylix/release.nix" - "${inputs.self}/stylix/overlays.nix" + ./cursor.nix + ./fonts.nix + ./palette.nix + ../cursor.nix + ../fonts.nix + ../home-manager-integration.nix + ../opacity.nix + ../palette.nix + ../pixel.nix + ../target.nix + ../release.nix + ../overlays.nix ] ++ autoload; config.warnings = lib.mkIf From 5fa31498d281f6863d4a316fba3db3d1b847f77a Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 06/10] stylix: drop unnecessary use of `self` in home-manager --- flake/modules.nix | 2 +- stylix/hm/default.nix | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/flake/modules.nix b/flake/modules.nix index 08586de1..c8a93bd2 100644 --- a/flake/modules.nix +++ b/flake/modules.nix @@ -27,7 +27,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply ../stylix/hm inputs) + ../stylix/hm { stylix = { inherit inputs; diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index 976bb123..773881ce 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -1,32 +1,27 @@ -inputs: { lib, config, ... }: -# Imported modules which define new options must use an absolute path based -# on ${inputs.self}, otherwise those options will not appear in the generated -# documentation. - let autoload = import ../autoload.nix { inherit lib; } "hm"; in { imports = [ - "${inputs.self}/stylix/cursor.nix" - "${inputs.self}/stylix/fonts.nix" - "${inputs.self}/stylix/hm/cursor.nix" - "${inputs.self}/stylix/hm/fonts.nix" - "${inputs.self}/stylix/hm/icon.nix" - "${inputs.self}/stylix/hm/palette.nix" - "${inputs.self}/stylix/icon.nix" - "${inputs.self}/stylix/opacity.nix" - "${inputs.self}/stylix/palette.nix" - "${inputs.self}/stylix/pixel.nix" - "${inputs.self}/stylix/target.nix" - "${inputs.self}/stylix/release.nix" - "${inputs.self}/stylix/overlays.nix" + ./cursor.nix + ./fonts.nix + ./icon.nix + ./palette.nix + ../cursor.nix + ../fonts.nix + ../icon.nix + ../opacity.nix + ../palette.nix + ../pixel.nix + ../target.nix + ../release.nix + ../overlays.nix ] ++ autoload; config.warnings = lib.mkIf From 9cb8a57eac918273319d771981874bf5a025fb7f Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 07/10] stylix: drop unnecessary use of `self` in darwin --- flake/modules.nix | 2 +- stylix/darwin/default.nix | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/flake/modules.nix b/flake/modules.nix index c8a93bd2..1ab1ddc2 100644 --- a/flake/modules.nix +++ b/flake/modules.nix @@ -43,7 +43,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply ../stylix/darwin inputs) + ../stylix/darwin { stylix = { inherit inputs; diff --git a/stylix/darwin/default.nix b/stylix/darwin/default.nix index de957bf2..499ff7bf 100644 --- a/stylix/darwin/default.nix +++ b/stylix/darwin/default.nix @@ -1,29 +1,24 @@ -inputs: { lib, config, ... }: -# Imported modules which define new options must use an absolute path based -# on ${inputs.self}, otherwise those options will not appear in the generated -# documentation. - let autoload = import ../autoload.nix { inherit lib; } "darwin"; in { imports = [ - "${inputs.self}/stylix/darwin/fonts.nix" - "${inputs.self}/stylix/darwin/palette.nix" - "${inputs.self}/stylix/fonts.nix" - "${inputs.self}/stylix/home-manager-integration.nix" - "${inputs.self}/stylix/opacity.nix" - "${inputs.self}/stylix/palette.nix" - "${inputs.self}/stylix/pixel.nix" - "${inputs.self}/stylix/target.nix" - "${inputs.self}/stylix/release.nix" - "${inputs.self}/stylix/overlays.nix" + ./fonts.nix + ./palette.nix + ../fonts.nix + ../home-manager-integration.nix + ../opacity.nix + ../palette.nix + ../pixel.nix + ../target.nix + ../release.nix + ../overlays.nix ] ++ autoload; config.warnings = lib.mkIf From 23e3013b6257c8fc9556f5e3a25047f30bcd8fdc Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 08/10] stylix: drop unnecessary use of `self` in droid --- flake/modules.nix | 2 +- stylix/droid/default.nix | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/flake/modules.nix b/flake/modules.nix index 1ab1ddc2..adf315a6 100644 --- a/flake/modules.nix +++ b/flake/modules.nix @@ -60,7 +60,7 @@ { pkgs, ... }@args: { imports = [ - (lib.modules.importApply ../stylix/droid inputs) + ../stylix/droid { stylix = { paletteGenerator = diff --git a/stylix/droid/default.nix b/stylix/droid/default.nix index 9a70dc9e..1f21cebe 100644 --- a/stylix/droid/default.nix +++ b/stylix/droid/default.nix @@ -1,4 +1,3 @@ -inputs: { lib, ... }: let @@ -6,13 +5,13 @@ let in { imports = [ - "${inputs.self}/stylix/fonts.nix" - "${inputs.self}/stylix/home-manager-integration.nix" - "${inputs.self}/stylix/opacity.nix" - "${inputs.self}/stylix/palette.nix" - "${inputs.self}/stylix/pixel.nix" - "${inputs.self}/stylix/target.nix" - "${inputs.self}/stylix/overlays.nix" + ../fonts.nix + ../home-manager-integration.nix + ../opacity.nix + ../palette.nix + ../pixel.nix + ../target.nix + ../overlays.nix ] ++ autoload; # See https://github.com/nix-community/nix-on-droid/issues/436 From 03748a36d5926bfd4bc084e8ba579d7a9c91922b Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 09/10] stylix: drop unnecessary use of `self` in meta.nix --- doc/default.nix | 2 +- stylix/meta.nix | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/default.nix b/doc/default.nix index f337d8ee..39ee9e6c 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -53,7 +53,7 @@ let }; }; - metadata = callPackage ../stylix/meta.nix { inherit inputs; }; + metadata = callPackage ../stylix/meta.nix { }; # We construct an index of all Stylix options, using the following format: # diff --git a/stylix/meta.nix b/stylix/meta.nix index 4bedd1b2..20315d7b 100644 --- a/stylix/meta.nix +++ b/stylix/meta.nix @@ -1,8 +1,6 @@ { pkgs, lib, - inputs, - ... }: builtins.mapAttrs ( @@ -21,9 +19,9 @@ builtins.mapAttrs ) ( lib.concatMapAttrs ( - path: kind: + target: kind: lib.optionalAttrs (kind == "directory") { - ${path} = import "${inputs.self}/modules/${path}/meta.nix"; + ${target} = import ../modules/${target}/meta.nix; } - ) (builtins.readDir "${inputs.self}/modules") + ) (builtins.readDir ../modules) ) From 99130f414dc51bb8fd3980efc9005ca6596e123b Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 28 May 2025 18:42:59 +0100 Subject: [PATCH 10/10] stylix: minor meta.nix cleanup --- stylix/meta.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stylix/meta.nix b/stylix/meta.nix index 20315d7b..9a6763a6 100644 --- a/stylix/meta.nix +++ b/stylix/meta.nix @@ -5,10 +5,10 @@ builtins.mapAttrs ( _: value: - if (builtins.typeOf value == "lambda") then + if builtins.isFunction value then (value { inherit pkgs; - lib = pkgs.lib.extend ( + lib = lib.extend ( _: prev: { maintainers = lib.attrsets.unionOfDisjoint prev.maintainers (import ./maintainers.nix); }