Major rewrite to system config

Move home-manager setup back into being NixOS module where possible

Parameterise common elements of system config to minimise rewriting and
pass as function to all places needed
This commit is contained in:
Evie Litherland-Smith 2023-08-31 12:22:29 +01:00
parent 22929fa5d8
commit 8c5ba7f4c3
9 changed files with 115 additions and 146 deletions

135
flake.nix
View file

@ -22,11 +22,32 @@
};
};
outputs = { self, nixpkgs, home-manager, hyprland, anyrun, wallpapers, tokyonight, }:
let shell = "zsh";
in {
nixosConfigurations = let
userConfig = {
outputs =
{ self, nixpkgs, home-manager, hyprland, anyrun, wallpapers, tokyonight, }:
let
systemConfig =
{ hostName, user ? "xenia", system ? "x86_64-linux", shell ? "zsh" }:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
(final: prev: {
waybar = prev.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ];
});
})
];
};
in nixpkgs.lib.nixosSystem {
inherit pkgs;
specialArgs = { inherit hostName user shell hyprland; };
modules = [
./hosts/${hostName}/configuration.nix
./services/${hostName}.nix
{
networking = { inherit hostName; };
users.users.${user} = {
isNormalUser = true;
description = "Evie Litherland-Smith";
group = "users";
@ -34,71 +55,57 @@
shell = pkgs.${shell};
openssh.authorizedKeys.keys = import ./auth/authorized_keys.nix;
};
specialArgs = { inherit shell userConfig hyprland; };
waybar-experimental-overlay = final: prev: {
waybar = prev.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ];
});
};
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ waybar-experimental-overlay ];
};
in {
Legion = let hostname = "Legion";
in nixpkgs.lib.nixosSystem {
inherit pkgs specialArgs;
modules = [ ./hosts/${hostname}/configuration.nix ];
};
Vanguard = let hostname = "Vanguard";
in nixpkgs.lib.nixosSystem {
inherit pkgs specialArgs;
modules = [ ./hosts/${hostname}/configuration.nix ];
};
Ronin = let hostname = "Ronin";
in nixpkgs.lib.nixosSystem {
inherit pkgs specialArgs;
modules = [ ./hosts/${hostname}/configuration.nix ];
};
};
homeConfigurations = let
}
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
extraSpecialArgs = {
inherit hyprland anyrun wallpapers tokyonight;
inherit user hyprland anyrun wallpapers tokyonight;
shellConfig = ./home/shell/${shell}.nix;
};
in {
# NixOS home configurations
"xenia@Vanguard" = let
hostname = "Vanguard";
pkgs = self.nixosConfigurations.${hostname}.pkgs;
in home-manager.lib.homeManagerConfiguration {
inherit pkgs extraSpecialArgs;
modules = [ ./hosts/${hostname}/home.nix ];
users.${user} = import ./hosts/${hostName}/home.nix;
};
"xenia@Legion" = let
hostname = "Legion";
pkgs = self.nixosConfigurations.${hostname}.pkgs;
in home-manager.lib.homeManagerConfiguration {
inherit pkgs extraSpecialArgs;
modules = [ ./hosts/${hostname}/home.nix ];
}
];
};
"elitherl@Ronin" = let
hostname = "Ronin";
pkgs = self.nixosConfigurations.${hostname}.pkgs;
in home-manager.lib.homeManagerConfiguration {
inherit pkgs extraSpecialArgs;
modules = [ ./hosts/${hostname}/home.nix ];
};
# Legacy home configurations
"tux@Monarch" = let
hostname = "Monarch";
system = "aarch64-darwin";
homeConfig = { hostName, user, system ? "x86_64-linux", shell ? "zsh" }:
home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
in home-manager.lib.homeManagerConfiguration {
inherit pkgs extraSpecialArgs;
modules = [ ./hosts/${hostname}/home.nix ];
extraSpecialArgs = {
inherit user shell hyprland anyrun wallpapers tokyonight;
shellConfig = ./home/shell/${shell}.nix;
};
modules = [ ./hosts/${hostName}/home.nix ];
};
in {
nixosConfigurations = {
Legion = systemConfig {
hostName = "Legion";
user = "elitherl";
system = "x86_64-linux";
shell = "zsh";
};
Ronin = systemConfig {
hostName = "Ronin";
user = "elitherl";
system = "x86_64-linux";
shell = "zsh";
};
Vanguard = systemConfig {
hostName = "Vanguard";
user = "xenia";
system = "x86_64-linux";
shell = "zsh";
};
};
homeConfigurations = {
"tux@Monarch" = homeConfig {
hostName = "Monarch";
user = "tux";
system = "aarch64-darwin";
shell = "zsh";
};
};
};

View file

@ -1,24 +1,17 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running `nixos-help`).
{userConfig, ...}: let
user = "xenia";
hostName = "Legion";
in {
{ ... }: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
../common.nix
../../services/${hostName}.nix
];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking = {
hostName = hostName; # Define your hostname.
nameservers = ["192.168.1.230" "127.0.0.1" "9.9.9.9"];
};
networking.nameservers = [ "192.168.1.230" "127.0.0.1" "9.9.9.9" ];
system.autoUpgrade = {
enable = true;
dates = "02:00";
@ -28,7 +21,6 @@ in {
upper = "05:00";
};
};
users.users.${user} = userConfig;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions

View file

@ -1,7 +1,5 @@
{ pkgs, shellConfig, ... }:
let
username = "xenia";
homeDirectory = "/home/${username}";
{ pkgs, user, shellConfig, ... }:
let homeDirectory = "/home/${user}";
in {
imports = [
shellConfig
@ -11,7 +9,8 @@ in {
../../home/tui
];
home = {
inherit username homeDirectory;
inherit homeDirectory;
username = user;
stateVersion = "22.11";
};
programs = {

View file

@ -1,10 +1,8 @@
{ pkgs, ... }:
let
username = "tux";
homeDirectory = "/Users/${username}";
{ pkgs, user, shell ? "zsh", ... }:
let homeDirectory = "/Users/${user}";
in {
imports = [
../../home/shell/zsh.nix
../../home/shell/${shell}.nix
../../home/git
../../home/ssh
../../home/tui
@ -13,7 +11,8 @@ in {
../../home/emacs
];
home = {
inherit username homeDirectory;
inherit homeDirectory;
username = user;
stateVersion = "23.05";
packages = with pkgs; [ coreutils-prefixed ];
};

View file

@ -1,16 +1,11 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ userConfig, ... }:
let
user = "elitherl";
hostName = "Ronin";
in {
{ ... }: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
../hyprland.nix
../../services/${hostName}.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
@ -25,20 +20,11 @@ in {
boot.initrd.luks.devices."luks-761eeb11-3091-4142-9232-4fb33165eccd".keyFile =
"/crypto_keyfile.bin";
networking.hostName = hostName; # Define your hostname.
hardware.bluetooth.enable = true;
environment.etc."ppp/options".text = ''
ipcp-accept-remote
'';
programs.light.enable = true;
users.users.${user} = userConfig;
services.greetd = {
enable = true;
settings = {
default_session.user = user;
initial_session.user = user;
};
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions

View file

@ -1,11 +1,10 @@
{ pkgs, lib, shellConfig, ... }:
let
username = "elitherl";
homeDirectory = "/home/${username}";
{ pkgs, lib, user, shellConfig, ... }:
let homeDirectory = "/home/${user}";
in {
imports = [ shellConfig ../../home ];
home = {
inherit username homeDirectory;
inherit homeDirectory;
username = user;
stateVersion = "22.11";
packages = with pkgs; [
openfortivpn

View file

@ -1,25 +1,17 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ pkgs, userConfig, ... }:
let
user = "xenia";
hostName = "Vanguard";
in {
{ pkgs, ... }: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
../hyprland.nix
../../services/${hostName}.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking = {
hostName = hostName; # Define your hostname.
nameservers = [ "192.168.1.230" "9.9.9.9" ];
};
networking.nameservers = [ "192.168.1.230" "9.9.9.9" ];
environment.systemPackages = with pkgs; [ mesa ];
hardware = {
bluetooth.enable = true;
@ -32,15 +24,6 @@ in {
dedicatedServer.openFirewall = true;
};
users.users.${user} = userConfig;
services.greetd = {
enable = true;
settings = {
default_session.user = user;
initial_session.user = user;
};
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave

View file

@ -1,15 +1,10 @@
{ shellConfig, ... }:
let
username = "xenia";
homeDirectory = "/home/${username}";
in
{
imports = [
shellConfig
../../home
];
{ user, shellConfig, ... }:
let homeDirectory = "/home/${user}";
in {
imports = [ shellConfig ../../home ];
home = {
inherit username homeDirectory;
inherit homeDirectory;
username = user;
stateVersion = "22.11";
};
programs.home-manager.enable = true;

View file

@ -1,4 +1,4 @@
{ pkgs, hyprland, ... }: {
{ pkgs, hyprland, user ? "xenia", ... }: {
imports = [ ./desktop.nix hyprland.nixosModules.default ];
environment.systemPackages = with pkgs; [
xdg-utils
@ -21,9 +21,18 @@
blueman.enable = true;
gvfs.enable = true;
tumbler.enable = true;
greetd.settings = {
default_session.command = "Hyprland";
initial_session.command = "Hyprland";
greetd = {
enable = true;
settings = {
default_session = {
inherit user;
command = "Hyprland";
};
initial_session = {
inherit user;
command = "Hyprland";
};
};
};
};
fonts = {