Skip to content

Commit

Permalink
stylix: don't split autoloaded modules into a separate derivation (#631)
Browse files Browse the repository at this point in the history
Apparently `../modules` is creating a separate derivation that contains
only that folder, so it's now separate from the flake source. But this
transient derivation isn't mentioned explicitly anywhere in the flake
outputs. It makes it impossible to target those modules in
`disabledModules` directive.

For example, after this change is applied, users can solve issues like
#577 locally, by just adding the
following snippet to their configuration:

    disabledModules = [ "${inputs.stylix}/modules/regreet/nixos.nix" ];

Reviewed-by: Daniel Thwaites <[email protected]>
Reviewed-by: NAHO <[email protected]>
  • Loading branch information
binarin authored Nov 17, 2024
1 parent cf5be81 commit 9b61cc3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
22 changes: 22 additions & 0 deletions docs/src/tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,25 @@ Which is neatly implemented as a single function in `lib.stylix.pixel`:
};
}
```

## Completely disabling some stylix targets

Nixpkgs module system sometimes works in non-intuitive ways, e.g. parts
of the configuration guarded by `lib.mkIf` are still being descended
into. This means that every **loaded** (and not enabled) module must
be compatible with others - in the sense that **every** option that is
mentioned in the disabled parts of the configuration still needs to be
defined somewhere.

Sometimes that can be a problem, when your particular configuration
diverges enough from what stylix expects. In that case you can try
stubbing all the missing options in your configuration.

Or in a much clearer fashion you can just disable offending stylix targets
by adding the following `disableModules` line next to importing stylix
itself:

```nix
imports = [ flake.inputs.stylix.nixosModules.stylix ];
disabledModules = [ "${flake.inputs.stylix}/modules/<some-module>/nixos.nix" ];
```
6 changes: 3 additions & 3 deletions stylix/autoload.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib }:
{ lib, inputs }:

# string -> [ path ]
# List include path for either nixos modules or hm modules
Expand All @@ -8,7 +8,7 @@ for:
(path: kind:
if kind == "directory"
then let
file = "${../modules}/${path}/${for}.nix";
file = "${inputs.self}/modules/${path}/${for}.nix";
in if builtins.pathExists file then [ file ] else [ ]
else [ ])
(builtins.readDir ../modules))
(builtins.readDir "${inputs.self}/modules"))
2 changes: 1 addition & 1 deletion stylix/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inputs:
{ lib, ... }:

let
autoload = import ../autoload.nix { inherit lib; } "darwin";
autoload = import ../autoload.nix { inherit lib inputs; } "darwin";
in {
imports = [
../pixel.nix
Expand Down
2 changes: 1 addition & 1 deletion stylix/hm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inputs:
{ lib, ... }:

let
autoload = import ../autoload.nix { inherit lib; } "hm";
autoload = import ../autoload.nix { inherit lib inputs; } "hm";
in {
imports = [
../pixel.nix
Expand Down
2 changes: 1 addition & 1 deletion stylix/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inputs:
{ lib, ... }:

let
autoload = import ../autoload.nix { inherit lib; } "nixos";
autoload = import ../autoload.nix { inherit lib inputs; } "nixos";
in {
imports = [
../pixel.nix
Expand Down
4 changes: 2 additions & 2 deletions stylix/testbed.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ let
(name: _:
let testbed = {
inherit name;
module = "${../modules}/${name}/testbed.nix";
module = "${inputs.self}/modules/${name}/testbed.nix";
};
in
lib.optional (builtins.pathExists testbed.module) testbed
)
(builtins.readDir ../modules));
(builtins.readDir "${inputs.self}/modules"));

makeTestbed =
testbed: stylix:
Expand Down

0 comments on commit 9b61cc3

Please sign in to comment.