diff --git a/README.md b/README.md index 44b58389..fee0a287 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,10 @@ ## About Stylix is a theming framework for [NixOS](https://nixos.org), [Home -Manager](https://nix-community.github.io/home-manager#ch-introduction), and -[nix-darwin](https://github.com/LnL7/nix-darwin#readme) that applies color -schemes, wallpapers, and fonts to a wide range of applications. +Manager](https://nix-community.github.io/home-manager#ch-introduction), +[nix-darwin](https://github.com/LnL7/nix-darwin#readme), and +[Nix-on-Droid](https://github.com/nix-community/nix-on-droid) that applies +color schemes, wallpapers, and fonts to a wide range of applications. Unlike color scheme utilities such as [base16.nix](https://github.com/SenchoPens/base16.nix) or diff --git a/docs/src/installation.md b/docs/src/installation.md index b0326e2f..0ca42e04 100644 --- a/docs/src/installation.md +++ b/docs/src/installation.md @@ -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 ]; + }; + }; +} +``` +Minimal `flake.nix` for a Nix-on-Droid configuration. + +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 diff --git a/docs/src/modules.md b/docs/src/modules.md index 914787b1..ff1c41aa 100644 --- a/docs/src/modules.md +++ b/docs/src/modules.md @@ -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. diff --git a/flake.nix b/flake.nix index 145998d6..4504c4e0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Theming framework for NixOS, Home Manager, and nix-darwin"; + description = "Theming framework for NixOS, Home Manager, nix-darwin and Nix-on-Droid"; inputs = { base16-fish = { @@ -260,5 +260,20 @@ } ]; }; + + nixOnDroidModules.stylix = + { pkgs, ... }@args: + { + imports = [ + (import ./stylix/droid inputs) + { + stylix = { + paletteGenerator = self.packages.${pkgs.system}.palette-generator; + base16 = base16.lib args; + homeManagerIntegration.module = self.homeManagerModules.stylix; + }; + } + ]; + }; }; } diff --git a/modules/console/droid.nix b/modules/console/droid.nix new file mode 100644 index 00000000..9e934ef8 --- /dev/null +++ b/modules/console/droid.nix @@ -0,0 +1,36 @@ +{ config, lib, ... }: + +{ + options.stylix.targets.console.enable = + config.lib.stylix.mkEnableTarget "the Nix-on-Droid console" true; + + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.console.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; + }; + }; +} diff --git a/stylix/droid/default.nix b/stylix/droid/default.nix new file mode 100644 index 00000000..cc6e0757 --- /dev/null +++ b/stylix/droid/default.nix @@ -0,0 +1,21 @@ +inputs: +{ lib, ... }: + +let + autoload = import ../autoload.nix { inherit lib inputs; } "droid"; +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" + ] ++ autoload; + + # See https://github.com/nix-community/nix-on-droid/issues/436 + options.lib = lib.mkOption { + type = with lib.types; attrsOf attrs; + }; +} diff --git a/stylix/droid/fonts.nix b/stylix/droid/fonts.nix new file mode 100644 index 00000000..91384faf --- /dev/null +++ b/stylix/droid/fonts.nix @@ -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; +} diff --git a/stylix/droid/palette.nix b/stylix/droid/palette.nix new file mode 100644 index 00000000..23c299f6 --- /dev/null +++ b/stylix/droid/palette.nix @@ -0,0 +1,10 @@ +args: +{ config, lib, ... }: + +{ + imports = [ (import ../palette.nix args) ]; + + config = lib.mkIf config.stylix.enable { + environment.etc = config.stylix.generated.fileTree; + }; +}