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