refactor: add modules
This commit is contained in:
parent
be802492e9
commit
6778b8dac3
28 changed files with 203 additions and 139 deletions
|
@ -404,7 +404,7 @@
|
|||
"nur": "nur",
|
||||
"pre-commit-hooks": "pre-commit-hooks",
|
||||
"vscode-server": "vscode-server",
|
||||
"wsl": "wsl"
|
||||
"nixos-wsl": "nixos-wsl"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
|
@ -488,7 +488,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"wsl": {
|
||||
"nixos-wsl": {
|
||||
"inputs": {
|
||||
"flake-compat": [],
|
||||
"flake-utils": [
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
system = "x86_64-linux";
|
||||
username = "winston";
|
||||
isGraphical = false;
|
||||
extraModules = [ inputs.wsl.nixosModules.default ];
|
||||
extraModules = [ inputs.nixos-wsl.nixosModules.default ];
|
||||
}
|
||||
];
|
||||
imports = [ inputs.pre-commit-hooks.flakeModule ];
|
||||
|
@ -65,9 +65,6 @@
|
|||
RULES = "./home/secrets/secrets.nix";
|
||||
buildInputs =
|
||||
(with pkgs; [
|
||||
dhall
|
||||
dhall-lsp-server
|
||||
dhall-yaml
|
||||
just
|
||||
nix-output-monitor
|
||||
nixd
|
||||
|
@ -132,7 +129,7 @@
|
|||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
wsl = {
|
||||
nixos-wsl = {
|
||||
url = "github:nix-community/nixos-wsl";
|
||||
inputs.flake-compat.follows = "";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
osConfig,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
@ -43,9 +44,10 @@ in
|
|||
watchexec
|
||||
]
|
||||
++ lib.optionals (config.isGraphical && isLinux) [
|
||||
_1password-gui
|
||||
uhk-agent
|
||||
(_1password-gui.override { polkitPolicyOwners = [ osConfig.dotfiles.username ]; })
|
||||
neovide
|
||||
nextcloud-client
|
||||
uhk-agent
|
||||
]
|
||||
);
|
||||
sessionVariables.SSH_AUTH_SOCK = lib.optionalString isDarwin "${config.programs.gpg.homedir}/S.gpg-agent.ssh";
|
||||
|
|
14
home/lib.nix
14
home/lib.nix
|
@ -6,6 +6,7 @@
|
|||
}:
|
||||
rec {
|
||||
inherit (pkgs.stdenv) isLinux isDarwin;
|
||||
inherit (pkgs.lib) mkDefault mkOption types;
|
||||
|
||||
extraSpecialArgs = {
|
||||
flakePath =
|
||||
|
@ -21,10 +22,10 @@ rec {
|
|||
"/Users/${username}"
|
||||
else
|
||||
throw "Unsupported system";
|
||||
home.username = username;
|
||||
isGraphical = false;
|
||||
targets.genericLinux.enable = isLinux;
|
||||
xdg.mime.enable = isLinux;
|
||||
home.username = mkDefault username;
|
||||
isGraphical = mkDefault false;
|
||||
targets.genericLinux.enable = mkDefault isLinux;
|
||||
xdg.mime.enable = mkDefault isLinux;
|
||||
};
|
||||
|
||||
modules =
|
||||
|
@ -36,10 +37,7 @@ rec {
|
|||
])
|
||||
++ [
|
||||
(
|
||||
{ osConfig, lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{ osConfig, ... }:
|
||||
{
|
||||
options = {
|
||||
isGraphical = mkOption {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
|
@ -66,6 +65,7 @@
|
|||
builtins.concatStringsSep "\n" (map (app: ''yabai -m rule --add app="${app}" ${options}'') apps);
|
||||
unmanaged = apps: mkRules apps "manage=off";
|
||||
in
|
||||
# bash
|
||||
''
|
||||
# auto-inject scripting additions
|
||||
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
|
||||
|
@ -119,6 +119,7 @@
|
|||
)
|
||||
);
|
||||
in
|
||||
# bash
|
||||
''
|
||||
#!/usr/bin/env sh
|
||||
# focus window
|
||||
|
@ -157,11 +158,9 @@
|
|||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.jankyborders ];
|
||||
launchd.user.agents.jankyborders.serviceConfig = {
|
||||
ProgramArguments = [ "${pkgs.jankyborders}/bin/borders" ];
|
||||
ProgramArguments = [ (lib.getExe pkgs.jankyborders) ];
|
||||
KeepAlive = true;
|
||||
RunAtLoad = true;
|
||||
EnvironmentVariables.PATH = "${pkgs.jankyborders}/bin:${config.environment.systemPath}";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ let
|
|||
);
|
||||
binary =
|
||||
{
|
||||
swayfx = "sway";
|
||||
hyprland = "Hyprland";
|
||||
sway = "sway";
|
||||
hyprland = "hypr";
|
||||
swayfx = "sway";
|
||||
}
|
||||
.${desktop} or (throw "greetd: desktop not supported");
|
||||
in
|
||||
|
@ -25,7 +25,7 @@ in
|
|||
config = lib.mkIf condition {
|
||||
services.greetd = {
|
||||
enable = true;
|
||||
settings.default_session.command = "${lib.getExe pkgs.greetd.tuigreet} --cmd '${pkgs.dbus}/bin/dbus-run-session ${binary}'";
|
||||
settings.default_session.command = "${lib.getExe pkgs.greetd.tuigreet} --remember --cmd ${binary}";
|
||||
};
|
||||
services.gnome.gnome-keyring.enable = true;
|
||||
security.pam.services.greetd = {
|
|
@ -37,23 +37,24 @@ in
|
|||
|
||||
programs.sway = {
|
||||
enable = true;
|
||||
package = lib.mkIf (config.dotfiles.desktop == "swayfx") pkgs.swayfx;
|
||||
package = if (config.dotfiles.desktop == "swayfx") then pkgs.swayfx else pkgs.sway;
|
||||
extraPackages = with pkgs; [
|
||||
swaylock-effects
|
||||
swayidle
|
||||
];
|
||||
extraSessionCommands = ''
|
||||
# session
|
||||
export XDG_SESSION_TYPE=wayland
|
||||
export XDG_SESSION_DESKTOP=sway
|
||||
export XDG_CURRENT_DESKTOP=sway
|
||||
# wayland
|
||||
export NIXOS_OZONE_WL=1
|
||||
export MOZ_ENABLE_WAYLAND=1
|
||||
export QT_QPA_PLATFORM=wayland
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||
'';
|
||||
extraSessionCommands = # bash
|
||||
''
|
||||
# session
|
||||
export XDG_SESSION_TYPE=wayland
|
||||
export XDG_SESSION_DESKTOP=sway
|
||||
export XDG_CURRENT_DESKTOP=sway
|
||||
# wayland
|
||||
export NIXOS_OZONE_WL=1
|
||||
export MOZ_ENABLE_WAYLAND=1
|
||||
export QT_QPA_PLATFORM=wayland
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||
'';
|
||||
wrapperFeatures = {
|
||||
base = true;
|
||||
gtk = true;
|
|
@ -1,18 +0,0 @@
|
|||
{ lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib) mkForce;
|
||||
in
|
||||
{
|
||||
services = {
|
||||
kanata.enable = mkForce false;
|
||||
dnsmasq.enable = mkForce false;
|
||||
mullvad-vpn.enable = mkForce false;
|
||||
stubby.enable = mkForce false;
|
||||
};
|
||||
virtualisation.podman.enable = mkForce false;
|
||||
|
||||
system = {
|
||||
build.installBootLoader = mkForce "${pkgs.coreutils}/bin/true";
|
||||
stateVersion = "23.11";
|
||||
};
|
||||
}
|
|
@ -2,7 +2,10 @@
|
|||
{
|
||||
imports = [ ./hardware.nix ];
|
||||
|
||||
dotfiles.desktop = "sway";
|
||||
dotfiles = {
|
||||
desktop = "sway";
|
||||
gaming.enable = true;
|
||||
};
|
||||
|
||||
networking = {
|
||||
networkmanager.enable = true;
|
||||
|
@ -17,54 +20,31 @@
|
|||
time.timeZone = "Europe/Vienna";
|
||||
|
||||
services = {
|
||||
flatpak.enable = true;
|
||||
openssh.enable = true;
|
||||
pcscd.enable = true;
|
||||
transmission.enable = true;
|
||||
transmission.openFirewall = true;
|
||||
};
|
||||
|
||||
virtualisation.podman.enable = true;
|
||||
virtualisation.libvirtd.enable = true;
|
||||
virtualisation = {
|
||||
libvirtd.enable = true;
|
||||
podman.enable = true;
|
||||
};
|
||||
|
||||
users.users."${config.dotfiles.username}".extraGroups = [
|
||||
"libvirtd"
|
||||
"transmission"
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
cabextract
|
||||
discover-overlay
|
||||
lutris-free
|
||||
mangohud
|
||||
(pkgs.wrapOBS {
|
||||
plugins = with pkgs.obs-studio-plugins; [
|
||||
obs-backgroundremoval
|
||||
obs-composite-blur
|
||||
obs-pipewire-audio-capture
|
||||
wlrobs
|
||||
];
|
||||
})
|
||||
virt-manager
|
||||
wineWowPackages.staging
|
||||
winetricks
|
||||
virtiofsd
|
||||
];
|
||||
|
||||
programs = {
|
||||
gamemode = {
|
||||
enable = true;
|
||||
settings = {
|
||||
custom = {
|
||||
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
|
||||
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
|
||||
};
|
||||
};
|
||||
};
|
||||
steam = {
|
||||
enable = true;
|
||||
package = pkgs.steam.override {
|
||||
extraEnv.MANGOHUD = 1;
|
||||
extraPkgs =
|
||||
p: with p; [
|
||||
corefonts
|
||||
protontricks
|
||||
gamescope
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
system.stateVersion = "22.11";
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ rec {
|
|||
hmCommonConfig =
|
||||
{ username }:
|
||||
(
|
||||
{ config, pkgs, ... }:
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
homeLib = import ../home/lib.nix { inherit inputs username pkgs; };
|
||||
in
|
||||
|
@ -34,6 +34,9 @@ rec {
|
|||
extraModules ? [ ],
|
||||
}:
|
||||
let
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) lib;
|
||||
|
||||
ldTernary =
|
||||
l: d:
|
||||
if pkgs.stdenv.isLinux then
|
||||
|
@ -42,17 +45,16 @@ rec {
|
|||
d
|
||||
else
|
||||
throw "Unsupported system";
|
||||
target = ldTernary "nixosConfigurations" "darwinConfigurations";
|
||||
builder = ldTernary inputs.nixpkgs.lib.nixosSystem inputs.darwin.lib.darwinSystem;
|
||||
hostPlatform = ldTernary "nixos" "darwin";
|
||||
module = ldTernary "nixosModules" "darwinModules";
|
||||
hostPlatform = ldTernary "linux" "darwin";
|
||||
target = ldTernary "nixosConfigurations" "darwinConfigurations";
|
||||
|
||||
linuxModules = [ inputs.nixos-cosmic.nixosModules.default ];
|
||||
darwinModules = [ inputs.nekowinston-nur.darwinModules.default ];
|
||||
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) lib;
|
||||
inherit (pkgs.lib) mkOption types;
|
||||
linuxModules = [
|
||||
inputs.nixos-cosmic.nixosModules.default
|
||||
inputs.nixos-wsl.nixosModules.default
|
||||
];
|
||||
in
|
||||
{
|
||||
${target}."${host}" = builder {
|
||||
|
@ -60,43 +62,25 @@ rec {
|
|||
modules =
|
||||
[
|
||||
{
|
||||
options = {
|
||||
config = {
|
||||
dotfiles = {
|
||||
username = mkOption {
|
||||
type = types.str;
|
||||
default = username;
|
||||
description = "The username of the user";
|
||||
};
|
||||
desktop = mkOption {
|
||||
type = types.nullOr (
|
||||
types.enum [
|
||||
"cosmic"
|
||||
"gnome"
|
||||
"hyprland"
|
||||
"sway"
|
||||
"swayfx"
|
||||
]
|
||||
);
|
||||
default = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null;
|
||||
description = "The desktop environment to use";
|
||||
};
|
||||
};
|
||||
isGraphical = mkOption {
|
||||
type = types.bool;
|
||||
default = isGraphical;
|
||||
description = "Whether the system is a graphical target";
|
||||
username = lib.mkDefault username;
|
||||
desktop = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null;
|
||||
};
|
||||
isGraphical = lib.mkDefault isGraphical;
|
||||
networking.hostName = lib.mkDefault host;
|
||||
};
|
||||
config.networking.hostName = host;
|
||||
}
|
||||
../modules/shared
|
||||
../modules/${hostPlatform}
|
||||
./common/shared
|
||||
./common/${hostPlatform}
|
||||
./${host}
|
||||
inputs.home-manager.${module}.home-manager
|
||||
(hmCommonConfig { inherit username; })
|
||||
]
|
||||
++ lib.optionals pkgs.stdenv.isLinux linuxModules
|
||||
++ lib.optionals pkgs.stdenv.isDarwin darwinModules
|
||||
++ lib.optionals pkgs.stdenv.isLinux linuxModules
|
||||
++ extraModules;
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
imports = [ ../common/wsl ];
|
||||
dotfiles.wsl.enable = true;
|
||||
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
location = {
|
||||
|
@ -8,10 +8,5 @@
|
|||
};
|
||||
time.timeZone = "Europe/Vienna";
|
||||
|
||||
wsl = {
|
||||
enable = true;
|
||||
defaultUser = "winston";
|
||||
startMenuLaunchers = true;
|
||||
useWindowsDriver = true;
|
||||
};
|
||||
system.stateVersion = "23.11";
|
||||
}
|
||||
|
|
1
modules/darwin/default.nix
Normal file
1
modules/darwin/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ }
|
6
modules/nixos/default.nix
Normal file
6
modules/nixos/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./gaming.nix
|
||||
./wsl.nix
|
||||
];
|
||||
}
|
41
modules/nixos/gaming.nix
Normal file
41
modules/nixos/gaming.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.dotfiles.gaming;
|
||||
gamePkgs =
|
||||
pkgs: with pkgs; [
|
||||
corefonts
|
||||
gamescope
|
||||
mangohud
|
||||
];
|
||||
in
|
||||
{
|
||||
options.dotfiles.gaming.enable = lib.mkEnableOption "gaming configuration";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
discover-overlay
|
||||
(lutris.override { extraPkgs = gamePkgs; })
|
||||
];
|
||||
|
||||
programs = {
|
||||
gamemode = {
|
||||
enable = true;
|
||||
settings = {
|
||||
custom = {
|
||||
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
|
||||
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
|
||||
};
|
||||
};
|
||||
};
|
||||
steam = {
|
||||
enable = true;
|
||||
package = pkgs.steam.override { extraPkgs = gamePkgs; };
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
37
modules/nixos/wsl.nix
Normal file
37
modules/nixos/wsl.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.dotfiles.wsl;
|
||||
inherit (lib) mkDefault mkForce;
|
||||
in
|
||||
{
|
||||
options.dotfiles.wsl.enable = lib.mkEnableOption "NixOS-WSL specific options";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# disable services that are not needed in WSL
|
||||
services = {
|
||||
dnsmasq.enable = mkForce false;
|
||||
kanata.enable = mkForce false;
|
||||
mullvad-vpn.enable = mkForce false;
|
||||
stubby.enable = mkForce false;
|
||||
};
|
||||
|
||||
# podman runs on native Windows
|
||||
virtualisation.podman.enable = mkForce false;
|
||||
|
||||
# main WSL defaults
|
||||
wsl = {
|
||||
enable = mkDefault true;
|
||||
defaultUser = mkDefault config.dotfiles.username;
|
||||
startMenuLaunchers = mkDefault true;
|
||||
useWindowsDriver = mkDefault true;
|
||||
};
|
||||
|
||||
# skip installing the bootloader
|
||||
system.build.installBootLoader = mkForce "${pkgs.coreutils}/bin/true";
|
||||
};
|
||||
}
|
36
modules/shared/config.nix
Normal file
36
modules/shared/config.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) types;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
dotfiles = lib.mkOption {
|
||||
type = types.submodule {
|
||||
options = {
|
||||
desktop = lib.mkOption {
|
||||
description = "The desktop environment to use";
|
||||
type = types.nullOr (
|
||||
types.enum [
|
||||
"cosmic"
|
||||
"gnome"
|
||||
"hyprland"
|
||||
"sway"
|
||||
"swayfx"
|
||||
]
|
||||
);
|
||||
};
|
||||
username = lib.mkOption {
|
||||
description = "The username of the user";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
isGraphical = lib.mkEnableOption "" // {
|
||||
description = "Whether the system is a graphical target";
|
||||
};
|
||||
};
|
||||
}
|
5
modules/shared/default.nix
Normal file
5
modules/shared/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -4,15 +4,15 @@
|
|||
(
|
||||
final: prev:
|
||||
let
|
||||
srcs = prev.callPackages ../_sources/generated.nix { };
|
||||
srcs = final.callPackages ../_sources/generated.nix { };
|
||||
in
|
||||
{
|
||||
nushellPlugins = (prev.nushellPlugins or { }) // {
|
||||
clipboard = prev.callPackage ./nu_plugin_clipboard.nix { };
|
||||
clipboard = final.callPackage ./nu_plugin_clipboard.nix { };
|
||||
};
|
||||
starship = prev.starship.overrideAttrs (old: {
|
||||
patches = [
|
||||
(prev.fetchpatch {
|
||||
(final.fetchpatch {
|
||||
url = "https://github.com/starship/starship/pull/4439.patch";
|
||||
sha256 = "sha256-BKH3elz96Oa424Oz5UIKA2/BOpkym1LTestvccFinnc=";
|
||||
})
|
||||
|
@ -22,10 +22,10 @@
|
|||
inherit (srcs.yabai) version src;
|
||||
});
|
||||
nur = import inputs.nur {
|
||||
nurpkgs = prev;
|
||||
pkgs = prev;
|
||||
nurpkgs = final;
|
||||
pkgs = final;
|
||||
repoOverrides = {
|
||||
nekowinston = inputs.nekowinston-nur.packages.${prev.stdenv.system};
|
||||
nekowinston = inputs.nekowinston-nur.packages.${final.stdenv.system};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue