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

149
flake.nix
View file

@ -22,83 +22,90 @@
}; };
}; };
outputs = { self, nixpkgs, home-manager, hyprland, anyrun, wallpapers, tokyonight, }: outputs =
let shell = "zsh"; { 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";
extraGroups = [ "networkmanager" "wheel" "video" ];
shell = pkgs.${shell};
openssh.authorizedKeys.keys = import ./auth/authorized_keys.nix;
};
}
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
extraSpecialArgs = {
inherit user hyprland anyrun wallpapers tokyonight;
shellConfig = ./home/shell/${shell}.nix;
};
users.${user} = import ./hosts/${hostName}/home.nix;
};
}
];
};
homeConfig = { hostName, user, system ? "x86_64-linux", shell ? "zsh" }:
home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
extraSpecialArgs = {
inherit user shell hyprland anyrun wallpapers tokyonight;
shellConfig = ./home/shell/${shell}.nix;
};
modules = [ ./hosts/${hostName}/home.nix ];
};
in { in {
nixosConfigurations = let nixosConfigurations = {
userConfig = { Legion = systemConfig {
isNormalUser = true; hostName = "Legion";
description = "Evie Litherland-Smith"; user = "elitherl";
group = "users"; system = "x86_64-linux";
extraGroups = [ "networkmanager" "wheel" "video" ]; shell = "zsh";
shell = pkgs.${shell};
openssh.authorizedKeys.keys = import ./auth/authorized_keys.nix;
}; };
specialArgs = { inherit shell userConfig hyprland; }; Ronin = systemConfig {
waybar-experimental-overlay = final: prev: { hostName = "Ronin";
waybar = prev.waybar.overrideAttrs (oldAttrs: { user = "elitherl";
mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ]; system = "x86_64-linux";
}); shell = "zsh";
}; };
system = "x86_64-linux"; Vanguard = systemConfig {
pkgs = import nixpkgs { hostName = "Vanguard";
inherit system; user = "xenia";
config.allowUnfree = true; system = "x86_64-linux";
overlays = [ waybar-experimental-overlay ]; shell = "zsh";
};
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 homeConfigurations = {
extraSpecialArgs = { "tux@Monarch" = homeConfig {
inherit hyprland anyrun wallpapers tokyonight; hostName = "Monarch";
shellConfig = ./home/shell/${shell}.nix; user = "tux";
};
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 ];
};
"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"; system = "aarch64-darwin";
pkgs = nixpkgs.legacyPackages.${system}; shell = "zsh";
in home-manager.lib.homeManagerConfiguration {
inherit pkgs extraSpecialArgs;
modules = [ ./hosts/${hostname}/home.nix ];
}; };
}; };
}; };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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