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", user ? "xenia",
system ? "x86_64-linux", system ? "x86_64-linux",
stateVersion ? "23.05", stateVersion ? "23.05",
systemModules ? [./system/hyprland.nix], systemModules ? [],
homeModules ? [./home/hyprland/default.nix], homeModules ? [],
}: let }: let
shell = "zsh"; shell = "zsh";
specialArgs = { specialArgs = {
@ -37,30 +37,12 @@
inherit system specialArgs; inherit system specialArgs;
modules = modules =
[ [
./hosts/${hostName}/configuration.nix
./hosts/${hostName}/hardware-configuration.nix
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
stylix.nixosModules.stylix stylix.nixosModules.stylix
({pkgs, ...}: let ./hosts/${hostName}/configuration.nix
flakeURL = "https://git.xenia.me.uk/xenia/nixos.git?ref=main"; ./hosts/${hostName}/hardware-configuration.nix
in { ./system/default.nix
boot.loader = { ({pkgs, ...}: {
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
'';
};
};
nix = { nix = {
enable = true; enable = true;
settings = { settings = {
@ -70,39 +52,7 @@
}; };
channel.enable = true; channel.enable = true;
nixPath = ["nixpkgs=${pkgs.path}"]; nixPath = ["nixpkgs=${pkgs.path}"];
registry = { registry.nixpkgs.flake = nixpkgs;
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";
};
};
};
gc = { gc = {
automatic = true; automatic = true;
options = "--delete-older-than 7d"; options = "--delete-older-than 7d";
@ -116,77 +66,9 @@
''; '';
}; };
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
system = { system = {inherit stateVersion;};
inherit stateVersion; networking = {inherit hostName;};
autoUpgrade = { programs.${shell}.enable = true;
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;
};
users = { users = {
defaultUserShell = pkgs.${shell}; defaultUserShell = pkgs.${shell};
users = let users = let
@ -257,8 +139,7 @@
systemConfig { systemConfig {
inherit hostName user system; inherit hostName user system;
systemModules = [ systemModules = [
./system/default.nix ./system/autoupgrade.nix
./services/adguardhome.nix
./services/caddy.nix ./services/caddy.nix
./services/gitea.nix ./services/gitea.nix
./services/grafana.nix ./services/grafana.nix
@ -278,7 +159,12 @@
in in
systemConfig { systemConfig {
inherit hostName user system; 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 Vanguard = let
@ -288,7 +174,12 @@
in in
systemConfig { systemConfig {
inherit hostName user system; 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 ## Work
@ -298,14 +189,28 @@
user = "elitherl"; user = "elitherl";
system = "x86_64-linux"; system = "x86_64-linux";
in 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 Scorch = let
hostName = "Scorch"; hostName = "Scorch";
user = "elitherl"; user = "elitherl";
system = "x86_64-linux"; system = "x86_64-linux";
in 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, ...}: { {pkgs, ...}: {
imports = [./registry.nix];
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
networking = { networking = {
networkmanager.enable = true; networkmanager.enable = true;
firewall.enable = true;
nameservers = ["9.9.9.9"]; nameservers = ["9.9.9.9"];
}; };
environment = { environment = {
@ -26,7 +32,19 @@
localBinInPath = true; localBinInPath = true;
}; };
console.keyMap = "uk"; 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 = { services = {
passSecretService.enable = true; passSecretService.enable = true;
upower.enable = true; upower.enable = true;
@ -55,4 +73,15 @@
LC_TIME = locale; 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, user,
... ...
}: { }: {
imports = [./default.nix]; imports = [./default.nix ./stylix.nix];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
libnotify libnotify
libcamera 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;
};
}