mirror of
https://github.com/danth/stylix
synced 2025-02-16 21:38:40 +00:00
Add darwinModules (#71)
This commit is contained in:
parent
8125194ab8
commit
dd33836655
5 changed files with 147 additions and 6 deletions
44
README.md
44
README.md
|
@ -13,9 +13,9 @@ a library which processes themes created for
|
|||
|
||||
### NixOS
|
||||
|
||||
You can install Stylix into your NixOS configuration using
|
||||
[Flakes](https://nixos.wiki/wiki/Flakes). This will provide theming for system
|
||||
level programs such as bootloaders, splash screens, and display managers.
|
||||
You can install Stylix into your NixOS configuration using [Flakes][nix-flakes].
|
||||
This will provide theming for system level programs such as bootloaders, splash
|
||||
screens, and display managers.
|
||||
|
||||
```nix
|
||||
{
|
||||
|
@ -35,8 +35,8 @@ level programs such as bootloaders, splash screens, and display managers.
|
|||
<small>Minimal `flake.nix` for a NixOS configuration.</small>
|
||||
|
||||
Many applications cannot be configured system wide, so Stylix will also need
|
||||
[Home Manager](https://github.com/nix-community/home-manager) to be able to
|
||||
change their settings within your home directory.
|
||||
[Home Manager][nix-hm] to be able to change their settings within your home
|
||||
directory.
|
||||
|
||||
[Installing Home Manager as a NixOS module](https://nix-community.github.io/home-manager/index.html#sec-install-nixos-module)
|
||||
is highly recommended if you don't use it already. This will combine it with
|
||||
|
@ -49,6 +49,37 @@ its Home Manager modules if it detects that Home Manager is available. You can
|
|||
theoretically use it without installing Home Manager, however most features
|
||||
will be unavailable.
|
||||
|
||||
### nix-darwin
|
||||
|
||||
You can install Stylix intor your nix-darwin configuration in a similar fashion
|
||||
to NixOS via [Flakes][nix-flakes].
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
darwin = {
|
||||
url = "github:LnL7/nix-darwin";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
stylix.url = "github:danth/stylix";
|
||||
};
|
||||
|
||||
outputs = { darwin, nixpkgs, stylix, ... }: {
|
||||
darwinConfigurations."«hostname»" = darwin.lib.darwinSystem {
|
||||
system = "aarch64-darwin";
|
||||
modules = [ stylix.darwinModules.stylix ./configuration.nix ];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
While this won't have an effect on the looks of macOS, since we don't have the
|
||||
controls to theme it like we do NixOS, it will automatically set up its [Home
|
||||
Manager][nix-hm] modules if it detects that Home Manager is available. You can
|
||||
theoretically use it without installing Home Manager, however most features will
|
||||
be unavailable.
|
||||
|
||||
### Home Manager
|
||||
|
||||
If you would prefer to use the standalone version of Home Manager, you can
|
||||
|
@ -297,3 +328,6 @@ The Stylix website has a list of the available targets
|
|||
and
|
||||
[for Home Manager](https://danth.github.io/stylix/options-hm.html)
|
||||
respectively.
|
||||
|
||||
[nix-flakes]: https://nixos.wiki/wiki/Flakes
|
||||
[nix-hm]: https://github.com/nix-community/home-manager
|
||||
|
|
12
flake.nix
12
flake.nix
|
@ -34,7 +34,7 @@
|
|||
};
|
||||
|
||||
in recursiveUpdate docsOutputs {
|
||||
packages = genAttrs [ "aarch64-linux" "i686-linux" "x86_64-linux" ] (
|
||||
packages = genAttrs [ "aarch64-darwin" "aarch64-linux" "i686-linux" "x86_64-darwin" "x86_64-linux" ] (
|
||||
system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
|
@ -60,5 +60,15 @@
|
|||
})
|
||||
];
|
||||
};
|
||||
|
||||
darwinModules.stylix = { pkgs, ... }@args: {
|
||||
imports = [
|
||||
(import ./stylix/darwin {
|
||||
inherit (self.package.${pkgs.system}) palette-generator;
|
||||
base16 = base16.lib args;
|
||||
homeManagerModule = self.homeManagerModules.stylix;
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
46
stylix/darwin/default.nix
Normal file
46
stylix/darwin/default.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{ palette-generator, base16, homeManagerModule }:
|
||||
{ options, config, lib, ... }:
|
||||
|
||||
let
|
||||
hm = config.stylix.homeManagerIntegration;
|
||||
autoload = import ../autoload.nix { inherit lib; } "darwin";
|
||||
in {
|
||||
imports = [
|
||||
../pixel.nix
|
||||
../target.nix
|
||||
./fonts.nix
|
||||
(import ./palette.nix { inherit palette-generator base16; })
|
||||
] ++ autoload;
|
||||
|
||||
options.stylix.homeManagerIntegration = {
|
||||
followSystem = lib.mkOption {
|
||||
description = ''
|
||||
When this option is <literal>true</literal>, Home Manager will follow
|
||||
the system theme by default, rather than requiring a theme to be set.
|
||||
|
||||
This will only affect Home Manager configurations which are built
|
||||
within the nix-darwin configuration.
|
||||
'';
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
autoImport = lib.mkOption {
|
||||
description = ''
|
||||
Whether to enable Stylix automatically for every user.
|
||||
|
||||
This only applies to users for which Home Manager is set up within the
|
||||
nix-darwin configuration.
|
||||
'';
|
||||
type = lib.types.bool;
|
||||
default = options ? home-manager;
|
||||
defaultText = lib.literalDocBook ''
|
||||
<literal>true</literal> when Home Manager is present.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf hm.autoImport {
|
||||
home-manager.sharedModules = [ homeManagerModule ];
|
||||
};
|
||||
}
|
17
stylix/darwin/fonts.nix
Normal file
17
stylix/darwin/fonts.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ config, ... }:
|
||||
|
||||
let
|
||||
cfg = config.stylix.fonts;
|
||||
in {
|
||||
imports = [ ../fonts.nix ];
|
||||
config.fonts = {
|
||||
fontDir.enable = true;
|
||||
|
||||
fonts = [
|
||||
cfg.monospace.package
|
||||
cfg.serif.package
|
||||
cfg.sansSerif.package
|
||||
cfg.emoji.package
|
||||
];
|
||||
};
|
||||
}
|
34
stylix/darwin/palette.nix
Normal file
34
stylix/darwin/palette.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
args:
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
imports = [ (import ../palette.nix args) ];
|
||||
|
||||
config = {
|
||||
environment.etc = {
|
||||
# Making palette.json part of the system closure will protect it from
|
||||
# garbage collection, so future configurations can be evaluated without
|
||||
# having to generate the palette again. The generator is not kept, only
|
||||
# the palette which came from it, so this uses very little disk space.
|
||||
# The extra indirection should prevent the palette generator from running
|
||||
# when the theme is manually specified. generated.json is necessary in
|
||||
# the presence of overrides.
|
||||
"stylix/generated.json".source = config.lib.stylix.scheme {
|
||||
template = builtins.readFile ../palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
|
||||
"stylix/palette.json".source = config.lib.stylix.colors {
|
||||
template = builtins.readFile ../palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
|
||||
# We also provide a HTML version which is useful for viewing the colors
|
||||
# during development.
|
||||
"stylix/palette.html".source = config.lib.stylix.colors {
|
||||
template = builtins.readFile ../palette.html.mustache;
|
||||
extension = ".html";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue