Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stylix: init droid #778

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@ 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 the [Home
Manager][nix-hm] modules for you.

## Nix-on-Droid

You can install Stylix into your
[Nix-on-Droid](https://github.com/nix-community/nix-on-droid) configuration in
a similar fashion to NixOS via [Flakes][nix-flakes].

```nix
{
inputs = {
nix-on-droid = {
url = "github:nix-community/nix-on-droid/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
stylix.url = "github:danth/stylix";
};

outputs = { nix-on-droid, nixpkgs, stylix, ... }: {
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
pkgs = nixpkgs.legacyPackages."aarch64-linux";
modules = [ stylix.nixOnDroidModules.stylix ./nix-on-droid.nix ];
};
};
}
```
<small>Minimal `flake.nix` for a Nix-on-Droid configuration.</small>

This will apply your configured color scheme and monospace font to the
nix-on-droid terminal. If [Home Manager integration for
Nix-on-Droid](https://github.com/nix-community/nix-on-droid#home-manager-integration)
is used, Stylix will automatically set up the [Home Manager][nix-hm] modules for
you.

## Home Manager

If you would prefer to use the standalone version of Home Manager, you can
Expand Down
1 change: 1 addition & 0 deletions docs/src/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The following platforms are supported:
- NixOS (`nixos`)
- Home Manager (`hm`)
- Nix-Darwin (`darwin`)
- Nix-on-Droid (`droid`)

Correctly named modules will be imported automatically.

Expand Down
12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,17 @@
}
];
};

nixOnDroidModules.stylix =
{ pkgs, ... }@args:
{
imports = [
(import ./stylix/droid inputs {
inherit (self.packages.${pkgs.system}) palette-generator;
base16 = base16.lib args;
homeManagerModule = self.homeManagerModules.stylix;
})
];
};
};
}
28 changes: 28 additions & 0 deletions stylix/droid/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
inputs:
{
palette-generator,
base16,
homeManagerModule,
}:
{ lib, ... }:

let
autoload = import ../autoload.nix { inherit lib inputs; } "droid";
in
{
imports = [
../pixel.nix
../target.nix
../opacity.nix
./fonts.nix
./terminal.nix
(import ./palette.nix { inherit palette-generator base16 lib; })
(import ../templates.nix inputs)
(import ../home-manager-integration.nix homeManagerModule)
] ++ autoload;

# See https://github.com/nix-community/nix-on-droid/issues/436
options.lib = lib.mkOption {
type = with lib.types; attrsOf attrs;
};
}
30 changes: 30 additions & 0 deletions stylix/droid/fonts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
config,
lib,
pkgs,
...
}:

let
mkFont =
font:
pkgs.runCommand "stylix-font-${font.package.name}"
{
FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [ font.package ]; };
}
''
font="$(
${lib.getExe' pkgs.fontconfig "fc-match"} \
${lib.escapeShellArg font.name} \
--format %{file}
)"

cp "$font" "$out"
'';
terminalFont = mkFont config.stylix.fonts.monospace;
in
{
imports = [ ../fonts.nix ];

config.terminal.font = lib.mkIf config.stylix.enable terminalFont;
}
10 changes: 10 additions & 0 deletions stylix/droid/palette.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
args:
{ config, lib, ... }:

{
imports = [ (import ../palette.nix args) ];

config = lib.mkIf config.stylix.enable {
environment.etc = config.stylix.generated.fileTree;
};
}
31 changes: 31 additions & 0 deletions stylix/droid/terminal.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{ config, lib, ... }:

{
config = lib.mkIf config.stylix.enable {
terminal.colors = with config.lib.stylix.colors.withHashtag; rec {
background = base00;
foreground = base05;
cursor = base05;

# normal
color0 = base00;
color1 = base08;
color2 = base0B;
color3 = base0A;
color4 = base0D;
color5 = base0E;
color6 = base0C;
color7 = base05;

# bright
color8 = base02;
color9 = color1;
color10 = color2;
color11 = color3;
color12 = color4;
color13 = color5;
color14 = color6;
color15 = base07;
};
};
}