Added nh, added some options such as username and hardware config

This commit is contained in:
Aleksandr Lebedev 2024-11-30 18:44:18 +01:00
parent b4f3add8ea
commit ca216ad1dc
6 changed files with 46 additions and 25 deletions

View file

@ -36,11 +36,20 @@
#};
arm = "aarch64-linux";
x86 = "x86_64-linux";
username = "kylekrein";
in
{
nixosConfigurations = {
homepc = nixpkgs.lib.nixosSystem {
specialArgs = { hostname = "nixosbtw"; system = x86; inherit inputs; };
"${username}-homepc" = nixpkgs.lib.nixosSystem {
specialArgs = {
hwconfig = {
hostname = "${username}-homepc";
isLaptop = false;
system = x86;
};
inherit username;
inherit inputs; };
system = x86;
#pkgs = import nixpkgs {
@ -61,8 +70,16 @@
#nix-flatpak.nixosModules.default
];
};
mac = nixpkgs.lib.nixosSystem {
specialArgs = { hostname = "nixos-macbook-kylekrein"; system = arm; inherit inputs; };
"${username}-mac" = nixpkgs.lib.nixosSystem {
specialArgs = {
hwconfig = {
hostname = "${username}-mac";
isLaptop = true;
system = arm;
};
inherit username;
inherit inputs; };
system = arm;
#pkgs = import nixpkgs {
# system = arm;

View file

@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, stylix, hostname, system, nixvim, inputs, ... }:
{ config, pkgs, stylix, hwconfig, username, nixvim, inputs, ... }:
{
imports =
@ -14,9 +14,9 @@
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = if hostname == "nixosbtw" then true else false;
boot.loader.efi.canTouchEfiVariables = if hwconfig.hostname == "${username}-homepc" then true else false;
networking.hostName = hostname;
networking.hostName = hwconfig.hostname;
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
@ -55,7 +55,7 @@
services.udisks2.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.kylekrein = {
users.users.${username} = {
isNormalUser = true;
description = "Aleksandr Lebedev";
extraGroups = [ "networkmanager" "wheel" ];
@ -69,7 +69,7 @@
};
# Allow unfree packages
nixpkgs.system = system;
nixpkgs.system = hwconfig.system;
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowBroken = true;
@ -182,6 +182,13 @@
shiftwidth = 4;
};
};
programs.nh = {
enable = true;
clean.enable = true;
clean.extraArgs = "--keep-since 4d --keep 3";
flake = "/home/${username}/nixos-config";
};
#https://discourse.nixos.org/t/dolphin-does-not-have-mime-associations/48985/3
# This fixes the unpopulated MIME menus
#environment.etc."/xdg/menus/plasma-applications.menu".text = builtins.readFile "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";
@ -234,7 +241,7 @@
programs.steam = {
enable = if system == "x86_64-linux" then true else false;
enable = if hwconfig.system == "x86_64-linux" then true else false;
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
@ -261,9 +268,9 @@
};
home-manager = {
extraSpecialArgs = {inherit pkgs; inherit hostname; inherit nixvim; inherit inputs;};
extraSpecialArgs = {inherit pkgs; inherit hwconfig; inherit username; inherit nixvim; inherit inputs;};
users = {
"kylekrein" = import ./home.nix;
"${username}" = import ./home.nix;
};
};
stylix = {
@ -323,7 +330,7 @@
programs.hyprland = {
enable = true;
package = inputs.hyprland.packages."${system}".hyprland;
package = inputs.hyprland.packages."${hwconfig.system}".hyprland;
xwayland.enable = true;
systemd.setPath.enable = true;
};

View file

@ -1,4 +1,4 @@
{ config, pkgs, stylix, hostname, inputs, ... }:
{ config, pkgs, stylix, hwconfig, username, inputs, ... }:
let
#nur = import (builtins.fetchTarball {
@ -19,11 +19,10 @@
];
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "kylekrein";
home.homeDirectory = "/home/kylekrein";
home.username = username;
home.homeDirectory = "/home/${username}";
stylix = {
enable = true;
targets.hyprlock.enable = true;
};
qt = {
enable = true;

View file

@ -1,4 +1,4 @@
{ pkgs, lib, hostname, ... }:
{ pkgs, lib, hwconfig, username, ... }:
let
toggle_monitors = ./toggle_monitors.sh;
wallpaper-image = ./wallpaper.jpg;
@ -13,7 +13,7 @@ in
enable = true;
xwayland.enable = true;
settings = {
monitor = if hostname == "nixosbtw" then [
monitor = if hwconfig.hostname == "${username}-homepc" then [
"DP-1,2560x1440@75,1600x0,1.6"
"DP-3,2560x1440@75,0x0,1.6"
] else ",highres,auto,1.6";
@ -23,6 +23,7 @@ in
};
exec-once = [
"${if hwconfig.isLaptop then "brightnessctl set 25%" else ""}"
"dbus-update-activation-environment --systemd --all"
"${pkgs.waybar}/bin/waybar &"
"${pkgs.networkmanagerapplet}/bin/nm-applet &"

View file

@ -1,4 +1,4 @@
{ pkgs, lib, hostname, ... }:
{ pkgs, lib, hwconfig, ... }:
{
programs.waybar = {
@ -34,7 +34,7 @@
#"memory"
#"temperature"
"hyprland/language"
] ++ (if hostname != "nixosbtw" then [ "battery" ] else [ ])
] ++ (if hwconfig.isLaptop then [ "battery" ] else [ ])
++ [
"tray"
"custom/notification"

View file

@ -1,7 +1,4 @@
{ pkgs, ... }:
let
username = "kylekrein";
in
{ pkgs, username, ... }:
{
virtualisation = {
libvirtd = {