Migrating to module usage

This commit is contained in:
Nathan Anderson 2023-12-15 15:50:45 -07:00
parent ed505c448e
commit c0cde19714
4 changed files with 209 additions and 55 deletions

View File

@ -23,6 +23,7 @@
system = "x86_64-linux";
userName = "nate";
hostName = "winmax";
desktop = "sway";
pkgs = nixpkgs.legacyPackages.${system};
stablePkgs = import nixpkgs-stable {
legacyPackages = system;
@ -31,6 +32,27 @@
in
{
nixosConfigurations = {
default = nixpkgs.lib.nixosSystem {
# Pass args to sway_configuration
specialArgs = {
inherit inputs;
inherit userName;
inherit hostName;
};
modules = [
./modules/sway/sway_conf.nix
# Setup home manager
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${userName} = import ./modules/home-manager/home.nix;
home-manager.extraSpecialArgs = {
inherit inputs outputs userName hostName;
};
}
];
}
nixServer = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [

View File

@ -0,0 +1,99 @@
{ lib, config, pkgs, ... }:
{
options.swaywm = {
enable = lib.mkEnableOption "Enable sway window manager.";
useNonFree = lib.mkOption {
default = false;
example = true;
description = "Whether to enable non-free software in the sway config";
};
systemPackages = lib.mkOption {
default = [];
description = "Add any additional packages desired. Merged with sway defaults.";
};
};
config = lib.mkIf config.swaywm.enable {
nixpkgs.config.allowUnfree = config.swaywm.useNonFree;
###
## XDG portal setup
###
xdg.portal = {
config = {
common = {
default = [
"wlr"
];
};
};
extraPortals = with pkgs; [
# xdg-desktop-portal-kde
xdg-desktop-portal-gtk
];
wlr.enable = true;
enable = true;
};
xdg.sounds.enable = true;
###
## System Packages
###
environment.systemPackages = with pkgs; lib.mkMerge [
[
git
glib # gsettings
grim
pavucontrol
slurp
swaylock
swayidle
wget
wl-clipboard
xdg-utils
zsh
]
config.swaywm.systemPackages
];
programs.zsh.enable = true;
programs.steam.enable = true;
###
## Services
###
services.openssh.enable = true;
services.dbus.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
};
# Firewall
networking.firewall = {
enable = true;
allowedTCPPortRanges = [
{from = 1714; to = 1764;} # KDE Connnect
];
allowedUDPPortRanges = [
{from = 1714; to = 1764;} # KDE Connnect
];
};
###
## Misc
###
sound.enable = true;
# Necessary for home-manager sway setup
security.polkit.enable = true;
hardware.opengl = {
enable = true;
driSupport = true;
};
};
}

24
nixos/default.nix Normal file
View File

@ -0,0 +1,24 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, userName, hostName, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./sway_configuration.nix
# ../modules/user/main_user.nix
# ../modules/sway/sway_conf.nix
];
# Enable flakes feature
nix.settings.experimental-features = [
"nix-command" "flakes"
];
system.stateVersion = "23.11"; # Did you read the comment?
}

View File

@ -9,6 +9,7 @@
[ # Include the results of the hardware scan.
./hardware-configuration.nix
../modules/user/main_user.nix
../modules/sway/sway_conf.nix
];
# Enable flakes feature
@ -16,7 +17,7 @@
"nix-command" "flakes"
];
nixpkgs.config.allowUnfree = true;
# nixpkgs.config.allowUnfree = true;
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
@ -54,37 +55,37 @@
# Enable CUPS to print documents.
# services.printing.enable = true;
sound.enable = true;
# sound.enable = true;
# hardware.pulseaudio.enable = true;
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# enable polkit for sway in home-manager
security.polkit.enable = true;
# security.polkit.enable = true;
hardware.opengl = {
enable = true;
driSupport = true;
};
# hardware.opengl = {
# enable = true;
# driSupport = true;
# };
# Setup xdg portal for screen share
xdg.portal = {
config = {
common = {
default = [
"wlr"
];
};
};
extraPortals = with pkgs; [
# xdg-desktop-portal-kde
xdg-desktop-portal-gtk
];
wlr.enable = true;
enable = true;
};
xdg.sounds.enable = true;
# xdg.portal = {
# config = {
# common = {
# default = [
# "wlr"
# ];
# };
# };
# extraPortals = with pkgs; [
# # xdg-desktop-portal-kde
# xdg-desktop-portal-gtk
# ];
# wlr.enable = true;
# enable = true;
# };
# xdg.sounds.enable = true;
main_user = {
enable = true;
@ -92,47 +93,55 @@
isDesktopUser = true;
};
programs.zsh.enable = true;
programs.steam.enable = true;
swaywm = {
enable = true;
useNonFree = true;
systemPackages = with pkgs; [
# corectrl
];
};
# programs.zsh.enable = true;
# programs.steam.enable = true;
# Corectrl from stable branch
# inputs.nixpkgs-stable.lib.nixosSystem.programs.corectrl.enable = true;
# programs.corectrl.enable = true;
environment.systemPackages = with pkgs; [
git
glib # gsettings
grim
pavucontrol
slurp
swaylock
swayidle
wget
wl-clipboard
xdg-utils
zsh
];
# environment.systemPackages = with pkgs; [
# git
# glib # gsettings
# grim
# pavucontrol
# slurp
# swaylock
# swayidle
# wget
# wl-clipboard
# xdg-utils
# zsh
# ];
# Services
services.flatpak.enable = true;
services.openssh.enable = true;
services.dbus.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
};
# services.flatpak.enable = true;
# services.openssh.enable = true;
# services.dbus.enable = true;
# services.pipewire = {
# enable = true;
# alsa.enable = true;
# pulse.enable = true;
# };
# Firewall
networking.firewall = {
enable = true;
allowedTCPPortRanges = [
{from = 1714; to = 1764;} # KDE Connnect
];
allowedUDPPortRanges = [
{from = 1714; to = 1764;} # KDE Connnect
];
};
# networking.firewall = {
# enable = true;
# allowedTCPPortRanges = [
# {from = 1714; to = 1764;} # KDE Connnect
# ];
# allowedUDPPortRanges = [
# {from = 1714; to = 1764;} # KDE Connnect
# ];
# };
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you