Move some things into separate files, add laptop power management

Move autoUpgrade, nix registry and stylix settings to their own files, only
import autoUpgrade on desktops and server

Add laptop system file to control power management

Move some bits from flake.nix to default.nix and desktop.nix where
appropriate
This commit is contained in:
Evie Litherland-Smith 2024-02-25 06:32:13 +00:00
parent 811829e958
commit 9e92c21fbd
7 changed files with 179 additions and 136 deletions

173
flake.nix
View file

@ -24,8 +24,8 @@
user ? "xenia",
system ? "x86_64-linux",
stateVersion ? "23.05",
systemModules ? [./system/hyprland.nix],
homeModules ? [./home/hyprland/default.nix],
systemModules ? [],
homeModules ? [],
}: let
shell = "zsh";
specialArgs = {
@ -37,30 +37,12 @@
inherit system specialArgs;
modules =
[
./hosts/${hostName}/configuration.nix
./hosts/${hostName}/hardware-configuration.nix
home-manager.nixosModules.home-manager
stylix.nixosModules.stylix
({pkgs, ...}: let
flakeURL = "https://git.xenia.me.uk/xenia/nixos.git?ref=main";
in {
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
programs = {
${shell}.enable = true;
command-not-found.enable = false;
nano = {
enable = true;
syntaxHighlight = true;
nanorc = ''
set nowrap
set tabstospaces
set tabsize 2
'';
};
};
./hosts/${hostName}/configuration.nix
./hosts/${hostName}/hardware-configuration.nix
./system/default.nix
({pkgs, ...}: {
nix = {
enable = true;
settings = {
@ -70,39 +52,7 @@
};
channel.enable = true;
nixPath = ["nixpkgs=${pkgs.path}"];
registry = {
nixpkgs.flake = nixpkgs;
nixos = {
from = {
type = "indirect";
id = "nixos";
};
to = {
type = "git";
url = flakeURL;
};
};
pyenv = {
from = {
type = "indirect";
id = "pyenv";
};
to = {
type = "git";
url = "https://git.xenia.me.uk/utils/pyenv.git";
};
};
jupyter = {
from = {
type = "indirect";
id = "jupyter";
};
to = {
type = "git";
url = "https://git.xenia.me.uk/xenia/nix-jupyter.git";
};
};
};
registry.nixpkgs.flake = nixpkgs;
gc = {
automatic = true;
options = "--delete-older-than 7d";
@ -116,77 +66,9 @@
'';
};
nixpkgs.config.allowUnfree = true;
system = {
inherit stateVersion;
autoUpgrade = {
enable = true;
flake = "git+${flakeURL}";
flags = [
"--update-input"
"nixpkgs"
"--no-write-lock-file"
"-L" # print build logs
];
dates = "02:00";
};
};
networking = {
inherit hostName;
firewall.enable = true;
};
stylix = {
base16Scheme = ./schemes/modus-vivendi-tinted.yaml;
autoEnable = false;
targets = {
chromium.enable = true;
console.enable = true;
fish.enable = true;
};
image = ./wallpapers/default.jpg;
polarity = "dark";
opacity = {
applications = 0.85;
desktop = 1.0;
popups = 0.5;
terminal = 0.85;
};
cursor = {
package = pkgs.volantes-cursors;
name = "volantes_cursors";
size = 24;
};
fonts = rec {
sizes = {
applications = 16;
desktop = 18;
popups = 18;
terminal = 16;
};
serif = monospace;
sansSerif = monospace;
monospace = {
name = "Iosevka Nerd Font";
package =
pkgs.nerdfonts.override {fonts = ["Iosevka"];};
};
emoji = {
name = "Noto Color Emoji";
package = pkgs.noto-fonts-emoji;
};
};
homeManagerIntegration.followSystem = true;
};
fonts = {
packages = with pkgs; [
(nerdfonts.override {fonts = ["NerdFontsSymbolsOnly"];})
emacs-all-the-icons-fonts
weather-icons
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
];
fontconfig.enable = true;
};
system = {inherit stateVersion;};
networking = {inherit hostName;};
programs.${shell}.enable = true;
users = {
defaultUserShell = pkgs.${shell};
users = let
@ -257,8 +139,7 @@
systemConfig {
inherit hostName user system;
systemModules = [
./system/default.nix
./services/adguardhome.nix
./system/autoupgrade.nix
./services/caddy.nix
./services/gitea.nix
./services/grafana.nix
@ -278,7 +159,12 @@
in
systemConfig {
inherit hostName user system;
systemModules = [./system/hyprland.nix ./system/games.nix];
systemModules = [
./system/laptop.nix
./system/hyprland.nix
./system/games.nix
];
homeModules = [./home/hyprland/default.nix];
};
Vanguard = let
@ -288,7 +174,12 @@
in
systemConfig {
inherit hostName user system;
systemModules = [./system/hyprland.nix ./system/games.nix];
systemModules = [
./system/autoupgrade.nix
./system/hyprland.nix
./system/games.nix
];
homeModules = [./home/hyprland/default.nix];
};
## Work
@ -298,14 +189,28 @@
user = "elitherl";
system = "x86_64-linux";
in
systemConfig {inherit hostName user system;};
systemConfig {
inherit hostName user system;
systemModules = [
./system/laptop.nix
./system/hyprland.nix
];
homeModules = [./home/hyprland/default.nix];
};
Scorch = let
hostName = "Scorch";
user = "elitherl";
system = "x86_64-linux";
in
systemConfig {inherit hostName user system;};
systemConfig {
inherit hostName user system;
systemModules = [
./system/autoupgrade.nix
./system/hyprland.nix
];
homeModules = [./home/hyprland/default.nix];
};
};
};
}

15
system/autoupgrade.nix Normal file
View file

@ -0,0 +1,15 @@
{config, ...}: let
flakeURL = config.registry.nixos.to.url;
in {
system.autoUpgrade = {
enable = true;
flake = "git+${flakeURL}";
flags = [
"--update-input"
"nixpkgs"
"--no-write-lock-file"
"-L" # print build logs
];
dates = "02:00";
};
}

View file

@ -1,6 +1,12 @@
{pkgs, ...}: {
imports = [./registry.nix];
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
networking = {
networkmanager.enable = true;
firewall.enable = true;
nameservers = ["9.9.9.9"];
};
environment = {
@ -26,7 +32,19 @@
localBinInPath = true;
};
console.keyMap = "uk";
programs.ssh.startAgent = true;
programs = {
command-not-found.enable = false;
ssh.startAgent = true;
nano = {
enable = true;
syntaxHighlight = true;
nanorc = ''
set nowrap
set tabstospaces
set tabsize 2
'';
};
};
services = {
passSecretService.enable = true;
upower.enable = true;
@ -55,4 +73,15 @@
LC_TIME = locale;
};
};
fonts = {
packages = with pkgs; [
(nerdfonts.override {fonts = ["NerdFontsSymbolsOnly"];})
emacs-all-the-icons-fonts
weather-icons
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
];
fontconfig.enable = true;
};
}

View file

@ -3,7 +3,7 @@
user,
...
}: {
imports = [./default.nix];
imports = [./default.nix ./stylix.nix];
environment.systemPackages = with pkgs; [
libnotify
libcamera

16
system/laptop.nix Normal file
View file

@ -0,0 +1,16 @@
{...}: {
powerManagement.enable = true;
services.auto-cpufreq = {
enable = true;
settings = {
battery = {
governor = "powersave";
turbo = "never";
};
charger = {
governor = "performance";
turbo = "auto";
};
};
};
}

34
system/registry.nix Normal file
View file

@ -0,0 +1,34 @@
{...}: {
nix.registry = {
nixos = {
from = {
type = "indirect";
id = "nixos";
};
to = {
type = "git";
url = "https://git.xenia.me.uk/xenia/nixos.git?ref=main";
};
};
pyenv = {
from = {
type = "indirect";
id = "pyenv";
};
to = {
type = "git";
url = "https://git.xenia.me.uk/utils/pyenv.git";
};
};
jupyter = {
from = {
type = "indirect";
id = "jupyter";
};
to = {
type = "git";
url = "https://git.xenia.me.uk/xenia/nix-jupyter.git";
};
};
};
}

44
system/stylix.nix Normal file
View file

@ -0,0 +1,44 @@
{pkgs, ...}: {
stylix = {
base16Scheme = ../schemes/modus-vivendi-tinted.yaml;
autoEnable = false;
targets = {
chromium.enable = true;
console.enable = true;
fish.enable = true;
};
image = ../wallpapers/default.jpg;
polarity = "dark";
opacity = {
applications = 0.85;
desktop = 1.0;
popups = 0.5;
terminal = 0.85;
};
cursor = {
package = pkgs.volantes-cursors;
name = "volantes_cursors";
size = 24;
};
fonts = rec {
sizes = {
applications = 16;
desktop = 18;
popups = 18;
terminal = 16;
};
serif = monospace;
sansSerif = monospace;
monospace = {
name = "Iosevka Nerd Font";
package =
pkgs.nerdfonts.override {fonts = ["Iosevka"];};
};
emoji = {
name = "Noto Color Emoji";
package = pkgs.noto-fonts-emoji;
};
};
homeManagerIntegration.followSystem = true;
};
}