Use specialisation to switch themes on NixOS
This commit is contained in:
parent
b94e030619
commit
6b00a19d0c
|
@ -3,7 +3,8 @@ let
|
||||||
# Currently last commit in https://github.com/danth/stylix/pull/194
|
# Currently last commit in https://github.com/danth/stylix/pull/194
|
||||||
stylix = builtins.fetchTarball "https://github.com/willemml/stylix/archive/2ed2b0086b41d582aca26e083c19c0e47c8991e3.tar.gz";
|
stylix = builtins.fetchTarball "https://github.com/willemml/stylix/archive/2ed2b0086b41d582aca26e083c19c0e47c8991e3.tar.gz";
|
||||||
polarityFile = "${config.xdg.stateHome}/theme_polarity";
|
polarityFile = "${config.xdg.stateHome}/theme_polarity";
|
||||||
polarity = if builtins.pathExists polarityFile then lib.strings.fileContents polarityFile else "light";
|
polarityFromFile = if builtins.pathExists polarityFile then lib.strings.fileContents polarityFile else "light";
|
||||||
|
polarity = if config.frogeye.polarity == "dynamic" then polarityFromFile else config.frogeye.polarity;
|
||||||
phases = [
|
phases = [
|
||||||
{ command = "jour"; polarity = "light"; }
|
{ command = "jour"; polarity = "light"; }
|
||||||
{ command = "crepuscule"; polarity = "dark"; }
|
{ command = "crepuscule"; polarity = "dark"; }
|
||||||
|
@ -59,7 +60,9 @@ in
|
||||||
then
|
then
|
||||||
home-manager switch
|
home-manager switch
|
||||||
else
|
else
|
||||||
sudo nixos-rebuild switch
|
# In two steps to get the visual changes slightly earlier
|
||||||
|
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration test
|
||||||
|
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration boot
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
options.frogeye = {
|
options.frogeye = {
|
||||||
extra = lib.mkEnableOption "Big software";
|
extra = lib.mkEnableOption "Big software";
|
||||||
gaming = lib.mkEnableOption "Games";
|
gaming = lib.mkEnableOption "Games";
|
||||||
|
polarity = lib.mkOption {
|
||||||
|
default = "dynamic";
|
||||||
|
description = "Whether to use light theme or dark theme.";
|
||||||
|
type = lib.types.enum [ "dynamic" "light" "dark" ];
|
||||||
|
};
|
||||||
desktop = {
|
desktop = {
|
||||||
xorg = lib.mkEnableOption "Enable X11 support";
|
xorg = lib.mkEnableOption "Enable X11 support";
|
||||||
numlock = lib.mkEnableOption "Auto-enable numlock";
|
numlock = lib.mkEnableOption "Auto-enable numlock";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, config, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
<home-manager/nixos>
|
<home-manager/nixos>
|
||||||
|
@ -32,6 +32,12 @@
|
||||||
useGlobalPkgs = true;
|
useGlobalPkgs = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
specialisation = {
|
||||||
|
dark.configuration.frogeye.polarity = "dark";
|
||||||
|
light.configuration.frogeye.polarity = "light";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
# Because everything is encrypted and I'm the only user, this is fine.
|
# Because everything is encrypted and I'm the only user, this is fine.
|
||||||
services.xserver.displayManager.autoLogin.user = "geoffrey";
|
services.xserver.displayManager.autoLogin.user = "geoffrey";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue