Boilerplate reduction (I understand strings in nix now!)

This commit is contained in:
Emmet 2023-06-22 14:53:10 -05:00
parent c7f3327147
commit b4a0d72a92
17 changed files with 136 additions and 144 deletions

View file

@ -21,10 +21,10 @@ My system-level Nix modules are organized into this directory:
Variables can be imported from [[../flake.nix][flake.nix]] by setting the =specialArgs= block inside the flake (see [[../flake.nix][my flake]] for more details). This allows variables to merely be managed in one place ([[../flake.nix][flake.nix]]) rather than having to manage them in multiple locations.
I currently import the following variables to the system config:
- =myName= - Username
- =myHostname= - Hostname for machine
- =myTimezone= - Timezone for machine
- =myLocale= - Locale for machine
- =myTheme= - base16 theme stored in ../themes to be used
- =myBackgroundUrl= - Direct link to background wallpaper (used for login screen)
- =myBackgroundSha256= - Checksum for background image used when downloading
- =username= - Username
- =hostname= - Hostname for machine
- =timezone= - Timezone for machine
- =locale= - Locale for machine
- =theme= - base16 theme stored in ../themes to be used
- =backgroundUrl= - Direct link to background wallpaper (used for login screen)
- =backgroundSha256= - Checksum for background image used when downloading

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, myName, storageDriver ? null, ... }:
{ config, lib, pkgs, username, storageDriver ? null, ... }:
assert lib.asserts.assertOneOf "storageDriver" storageDriver [
null
@ -17,5 +17,5 @@ assert lib.asserts.assertOneOf "storageDriver" storageDriver [
storageDriver = storageDriver;
autoPrune.enable = true;
};
users.users.${myName}.extraGroups = [ "docker" ];
users.users.${username}.extraGroups = [ "docker" ];
}

View file

@ -1,11 +1,11 @@
{ config, myName, pkgs, ... }:
{ config, username, pkgs, ... }:
{
# Doas instead of sudo
security.doas.enable = true;
security.sudo.enable = false;
security.doas.extraRules = [{
users = [ "${myName}" ];
users = [ "${username}" ];
keepEnv = true;
persist = true;
}];

View file

@ -1,33 +1,34 @@
{ config, pkgs, stylix, myTheme, myThemePolarity, myBackgroundUrl, myBackgroundSha256, ... }:
{ config, lib, pkgs, stylix, theme, font, fontPkg, ... }:
let
myFont = "Inconsolata";
myFontPkg = pkgs.inconsolata;
myThemePath = "../../../themes/"+myTheme+"/"+myTheme+".yaml";
myLightDMTheme = if myThemePolarity == "light" then "Adwaita" else "Adwaita-dark";
themePath = "../../../themes/"+theme+"/"+theme+".yaml";
themePolarity = lib.removeSuffix "\n" (builtins.readFile (./. + "../../../themes"+("/"+theme)+"/polarity.txt"));
myLightDMTheme = if themePolarity == "light" then "Adwaita" else "Adwaita-dark";
backgroundUrl = builtins.readFile (./. + "../../../themes"+("/"+theme)+"/backgroundurl.txt");
backgroundSha256 = builtins.readFile (./. + "../../../themes/"+("/"+theme)+"/backgroundsha256.txt");
in
{
imports = [ stylix.nixosModules.stylix ];
stylix.autoEnable = false;
stylix.polarity = myThemePolarity;
stylix.polarity = themePolarity;
stylix.image = pkgs.fetchurl {
url = myBackgroundUrl;
sha256 = myBackgroundSha256;
url = backgroundUrl;
sha256 = backgroundSha256;
};
stylix.base16Scheme = ./. + myThemePath;
stylix.base16Scheme = ./. + themePath;
stylix.fonts = {
monospace = {
name = myFont;
package = myFontPkg;
name = font;
package = fontPkg;
};
serif = {
name = myFont;
package = myFontPkg;
name = font;
package = fontPkg;
};
sansSerif = {
name = myFont;
package = myFontPkg;
name = font;
package = fontPkg;
};
emoji = {
name = "Noto Color Emoji";