feat(home-manager): service defs and fmt

fmt: reformatted using nixpkgs-fmt prettifier
mpd: created configuration
hypr: add window rules
commons: add usingMusicPlayerDaemon variable
This commit is contained in:
Zhongheng Liu 2025-01-08 14:12:29 +02:00
commit 7d88765f5d
Signed by: steven
GPG key ID: 805A28B071DAD84B
67 changed files with 633 additions and 573 deletions

View file

@ -1,15 +1,17 @@
{ { config
config, , pkgs
pkgs, , lib
lib, , ...
... }:
}: let let
monitorMaxBrightness = "255"; monitorMaxBrightness = "255";
monitorMinBrightness = "32"; monitorMinBrightness = "32";
in { in
{
# Type definitions for nix variables used in this configuration # Type definitions for nix variables used in this configuration
options = with lib; options = with lib;
with types; { with types; {
usingMusicPlayerDaemon = mkOption { type = bool; };
defaultApplications = { defaultApplications = {
fileManager = mkOption { type = str; }; fileManager = mkOption { type = str; };
appLauncher = mkOption { type = str; }; appLauncher = mkOption { type = str; };
@ -54,5 +56,6 @@ in {
fileManager = "${pkgs.nemo}/bin/nemo"; fileManager = "${pkgs.nemo}/bin/nemo";
appLauncher = "${pkgs.walker}/bin/walker"; appLauncher = "${pkgs.walker}/bin/walker";
}; };
usingMusicPlayerDaemon = true;
}; };
} }

View file

@ -1,10 +1,4 @@
{ { pkgs, lib, config, inputs, ... }: {
pkgs,
lib,
config,
inputs,
...
}: {
# https://devenv.sh/basics/ # https://devenv.sh/basics/
env.GREET = "devenv"; env.GREET = "devenv";
cachix.enable = false; cachix.enable = false;
@ -15,7 +9,7 @@
# languages.rust.enable = true; # languages.rust.enable = true;
languages.nix.enable = true; languages.nix.enable = true;
pre-commit.hooks = { pre-commit.hooks = {
alejandra.enable = true; nixpkgs-fmt.enable = true;
shellcheck.enable = true; shellcheck.enable = true;
commitizen.enable = true; commitizen.enable = true;
}; };
@ -38,9 +32,7 @@
# https://devenv.sh/tests/ # https://devenv.sh/tests/
enterTest = enterTest =
/* # shell
shell
*/
'' ''
echo "Running tests" echo "Running tests"
git --version | grep --color=auto "${pkgs.git.version}" git --version | grep --color=auto "${pkgs.git.version}"

View file

@ -30,18 +30,20 @@
hyprland-qtutils.url = "github:hyprwm/hyprland-qtutils"; hyprland-qtutils.url = "github:hyprwm/hyprland-qtutils";
}; };
outputs = { outputs =
self, { self
nixpkgs, , nixpkgs
home-manager, , home-manager
stylix, , stylix
spicetify-nix, , spicetify-nix
... , ...
} @ inputs: let } @ inputs:
let
inherit (self) outputs; inherit (self) outputs;
myHostName = "nixos-msi"; myHostName = "nixos-msi";
stevenUserName = "stvnliu"; stevenUserName = "stvnliu";
in { in
{
# NixOS configuration entrypoint # NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname' # Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = { nixosConfigurations = {

View file

@ -1,7 +1,7 @@
const hyprland = await Service.import("hyprland") const hyprland = await Service.import("hyprland")
const dispatch = ws => hyprland.messageAsync(`dispatch workspace ${ws}`); const dispatch = ws => hyprland.messageAsync(`dispatch workspace ${ws}`);
const wsSymbols = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] const wsSymbols = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]
const Workspaces = () => Widget.EventBox({ const Workspaces = () => Widget.EventBox({
onScrollUp: () => dispatch('+1'), onScrollUp: () => dispatch('+1'),
onScrollDown: () => dispatch('-1'), onScrollDown: () => dispatch('-1'),

View file

@ -0,0 +1,17 @@
const mpris = await Service.import('mpris')
/**
* @param {import('types/service/mpris').MprisPlayer} player
* */
const Player = (player, count) => Widget.Button({
onClicked: () => player.playPause(),
child: Widget.Label().hook(player, label => {
const { track_artists, track_title } = player;
label.label = `${count} PLAYING`;
}),
})
export const players = Widget.Box({
children: mpris.bind('players').as(p => p.map(
(this_player, index, array) => { return Player(this_player, array.length) }))
})

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
config = { config = {
home.file = { home.file = {

View file

@ -1,7 +1,5 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
... }: { }
}: {
}

View file

@ -1,8 +1,7 @@
{ { lib
lib, , pkgs
pkgs, , config
config, , ...
...
}: { }: {
imports = [ imports = [
#./vscode.nix #./vscode.nix
@ -11,8 +10,13 @@
programs.nixvim = import ./nixvim; programs.nixvim = import ./nixvim;
# dependencies for nixvim configuration # dependencies for nixvim configuration
home.packages = with pkgs; [ ripgrep fd ]; home.packages = with pkgs; [ ripgrep fd ];
programs.helix = {
enable = true;
};
/*
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.vscode.fhs; package = pkgs.vscode.fhs;
}; };
*/
} }

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
gtk = { gtk = {
enable = true; enable = true;

View file

@ -1,9 +1,8 @@
{ { inputs
inputs, , lib
lib, , config
config, , pkgs
pkgs, , ...
...
}: { }: {
imports = [ imports = [
./hypr ./hypr
@ -69,6 +68,7 @@
teams-for-linux teams-for-linux
sxiv sxiv
heroic heroic
vscodium-fhs
]; ];
myAutostartCommands = [ myAutostartCommands = [
#"${pkgs.clash-verge-rev}/bin/clash-verge" #"${pkgs.clash-verge-rev}/bin/clash-verge"

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
imports = [ imports = [
./hyprland ./hyprland

View file

@ -1,6 +1,8 @@
{pkgs, ...}: let { pkgs, ... }:
let
timeoutSeconds = 600; timeoutSeconds = 600;
in { in
{
services.hypridle = { services.hypridle = {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,8 +1,8 @@
{ { config
config, , pkgs
pkgs, , ...
... }:
}: let let
terminalCmd = config.defaultApplications.terminal; terminalCmd = config.defaultApplications.terminal;
screenshotLocation = "/home/${config.myUserName}/Screenshots/$(date '+%Y-%m-%d-%H-%M-%S').png"; screenshotLocation = "/home/${config.myUserName}/Screenshots/$(date '+%Y-%m-%d-%H-%M-%S').png";
in in
@ -34,7 +34,7 @@ in
TODO Fix floating window rule TODO Fix floating window rule
*/ */
# "$mod, N, exec, [float] ${terminalCmd} ${pkgs.networkmanager}/bin/nmtui" # "$mod, N, exec, [float] ${terminalCmd} ${pkgs.networkmanager}/bin/nmtui"
"$mod, M, exec, [float] ${terminalCmd} ${pkgs.zenith}/bin/zenith" #"$mod, M, exec, [float] ${terminalCmd} ${pkgs.zenith}/bin/zenith"
# vimkeys navigation # vimkeys navigation
"$mod, H, movefocus, l" "$mod, H, movefocus, l"
@ -42,6 +42,9 @@ in
"$mod, K, movefocus, u" "$mod, K, movefocus, u"
"$mod, L, movefocus, r" "$mod, L, movefocus, r"
] ]
++ (
if config.services.mpd.enable then [ "$mod, M, exec, ${terminalCmd} --title=ncmpc ${pkgs.ncmpc}/bin/ncmpc -h 127.0.0.1" ] else [ ]
)
++ ( ++ (
if config.services.swaync.enable if config.services.swaync.enable
then [ "$mod, N, exec, ${pkgs.swaynotificationcenter}/bin/swaync-client -t" ] then [ "$mod, N, exec, ${pkgs.swaynotificationcenter}/bin/swaync-client -t" ]
@ -50,11 +53,23 @@ in
++ ( ++ (
# workspaces # workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10} # binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
builtins.concatLists (builtins.genList (x: let builtins.concatLists (builtins.genList
(x:
let
ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10)); ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10));
in [ in
[
"$mod, ${ws}, workspace, ${toString (x + 1)}" "$mod, ${ws}, workspace, ${toString (x + 1)}"
"$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}" "$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
]) ]) 10)
10) # workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
/*
builtins.concatLists (builtins.genList (x:
let ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10));
in [
"$mod M, ${ws}, workspace, ${toString (x + 10 + 1)}"
"$mod SHIFT M, ${ws}, movetoworkspace, ${toString (x + 10 + 1)}"
]) 10)
*/
) )

View file

@ -1,20 +1,13 @@
{ { inputs, config, pkgs, lib, ... }: {
inputs, home.packages =
config, [ inputs.hyprland-qtutils.packages.x86_64-linux.default pkgs.foot ];
pkgs,
lib,
...
}: {
home.packages = [
inputs.hyprland-qtutils.packages.x86_64-linux.default
pkgs.foot
];
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
# Whether to enable Hyprland wayland compositor # Whether to enable Hyprland wayland compositor
enable = true; enable = true;
# The hyprland package to use # The hyprland package to use
package = pkgs.hyprland; package = pkgs.hyprland;
plugins = with pkgs.hyprlandPlugins; [ plugins = with pkgs.hyprlandPlugins;
[
# hyprfocus # hyprfocus
# hycov # hycov
]; ];
@ -37,7 +30,7 @@
gaps_out = 5; gaps_out = 5;
allow_tearing = true; allow_tearing = true;
}; };
windowrulev2 = ["immediate, class:^(cs2)$"]; windowrulev2 = import ./window_rules.nix;
decoration = { rounding = 5; }; decoration = { rounding = 5; };
input = { input = {
# xset rate 250 50 replacement on wayland... # xset rate 250 50 replacement on wayland...
@ -46,13 +39,10 @@
repeat_delay = 250; repeat_delay = 250;
accel_profile = "flat"; accel_profile = "flat";
}; };
exec-once = exec-once = config.myAutostartCommands ++ import ./hypr_autostart.nix {
config.myAutostartCommands inherit pkgs;
++ [ inherit config;
# future hyprland-specific exec commands };
#"${config.programs.firefox.package}/bin/firefox"
#"${pkgs.thunderbird}/bin/thunderbird"
];
misc = { misc = {
disable_hyprland_logo = true; disable_hyprland_logo = true;
disable_splash_rendering = true; disable_splash_rendering = true;

View file

@ -0,0 +1,8 @@
{ pkgs, config }:
let
term = config.defaultApplications.terminal;
shell = config.myShells.defaultShell;
in
[
"${term} --title=autorun ${shell}"
]

View file

@ -0,0 +1,7 @@
[
"workspace special silent, class:^(foot.*)$, title:autorun"
"float, tag:floats"
"float, title:ncmpc"
"size 50% 50%, title:ncmpc"
"immediate, class:^(cs2)$"
]

View file

@ -1,6 +1,6 @@
{ { pkgs
pkgs, , config
config, ,
}: [ }: [
", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause" ", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause"
", XF86AudioStop, exec, ${pkgs.playerctl}/bin/playerctl stop" ", XF86AudioStop, exec, ${pkgs.playerctl}/bin/playerctl stop"

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
programs.hyprlock = { programs.hyprlock = {
enable = true; enable = true;

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
services.hyprpaper = { services.hyprpaper = {
enable = true; enable = true;

View file

@ -1,10 +1,11 @@
{ { pkgs
pkgs, , lib
lib, , ...
... }:
}: let let
defaultTimeoutMillis = 5 * 1000; defaultTimeoutMillis = 5 * 1000;
in { in
{
services.mako = { services.mako = {
enable = true; enable = true;
defaultTimeout = defaultTimeoutMillis; defaultTimeout = defaultTimeoutMillis;

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
imports = [ imports = [
./util-programs.nix ./util-programs.nix
@ -11,5 +10,6 @@
./wayland-utils.nix ./wayland-utils.nix
./pentesting.nix ./pentesting.nix
./dev.nix ./dev.nix
./gaming.nix
]; ];
} }

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
home.packages = with pkgs; [ home.packages = with pkgs; [
wget wget

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
home.packages = with pkgs; [ vesktop ]; home.packages = with pkgs; [ vesktop ];
xdg.desktopEntries.discord = { xdg.desktopEntries.discord = {

View file

@ -0,0 +1,4 @@
{ pkgs, config, ... }:
{
home.packages = with pkgs; [ bottles ];
}

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
home.packages = with pkgs; [ home.packages = with pkgs; [
libreoffice libreoffice

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
home.packages = with pkgs; [ home.packages = with pkgs; [
openvpn openvpn

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
home.packages = with pkgs; [ home.packages = with pkgs; [
bottom bottom

View file

@ -0,0 +1,4 @@
{ pkgs, config, ... }: {
home.packages = with pkgs; [ vscodium-fhs ];
xdg.desktopEntries.codium = { };
}

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
home.packages = with pkgs; [ wl-clipboard ]; home.packages = with pkgs; [ wl-clipboard ];
} }

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
imports = [ imports = [
./git.nix ./git.nix

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
programs.foot = { programs.foot = {
enable = true; enable = true;

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
programs.git = { programs.git = {
enable = true; enable = true;

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
programs.rofi = { programs.rofi = {
enable = true; enable = true;

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
programs.tmux = { programs.tmux = {
enable = true; enable = true;

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
programs.walker = { programs.walker = {
enable = true; enable = true;

View file

@ -1,7 +1,6 @@
{ { config
config, , pkgs
pkgs, , ...
...
}: { }: {
home.packages = [ home.packages = [
(import ./heic-to-jpg.script.nix { inherit pkgs; }) (import ./heic-to-jpg.script.nix { inherit pkgs; })

View file

@ -1,7 +1,8 @@
{ { pkgs
pkgs, , config
config, ,
}: let }:
let
git = config.programs.git.package; git = config.programs.git.package;
# checks for any Git repositories with uncommitted changes # checks for any Git repositories with uncommitted changes
# used because I am too lazy # used because I am too lazy

View file

@ -1,7 +1,8 @@
{ { pkgs
pkgs, , config
config, ,
}: let }:
let
tmux = config.programs.tmux.package; tmux = config.programs.tmux.package;
windowName = "code-mode"; windowName = "code-mode";
in in

View file

@ -1,9 +1,9 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
imports = [ imports = [
./swaync.nix ./swaync.nix
./mpd.nix
]; ];
} }

View file

@ -0,0 +1,29 @@
{ pkgs, config, lib, ... }:
lib.mkIf config.usingMusicPlayerDaemon {
home.packages = [ pkgs.ncmpc ];
services.mpd = {
enable = true;
network.listenAddress = "any";
network.port = 6600;
extraConfig = ''
audio_output {
type "pipewire"
name "my pipewire output"
}
audio_output {
type "httpd"
name "My HTTP Stream"
encoder "vorbis" # optional, vorbis or lame
port "8000"
# bind_to_address "0.0.0.0" # optional, IPv4 or IPv6
quality "5.0" # do not define if bitrate is defined
# bitrate "128" # do not define if quality is defined
format "44100:16:1"
max_clients "5" # optional 0=no limit
}
'';
};
services.mpd-mpris = {
enable = true;
};
}

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
services.swaync = { services.swaync = {
enable = true; enable = true;

View file

@ -1,9 +1,9 @@
{ { pkgs
pkgs, , lib
lib, , config
config, , ...
... }:
}: let let
cfg = config.myShells; cfg = config.myShells;
in in
with lib; { with lib; {

View file

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , config
config, , ...
...
}: { }: {
EDITOR = "nvim"; EDITOR = "nvim";
} }

View file

@ -1,9 +1,9 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
... }:
}: let let
cfg = config.myShells.fish; cfg = config.myShells.fish;
in in
with lib; { with lib; {

View file

@ -1,9 +1,9 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
... }:
}: let let
cfg = config.myShells.nushell; cfg = config.myShells.nushell;
in in
with lib; { with lib; {

View file

@ -1,9 +1,9 @@
{ { lib
lib, , pkgs
pkgs, , config
config, , ...
... }:
}: let let
cfg = config.myShells.prompts.starship; cfg = config.myShells.prompts.starship;
in in
with lib; { with lib; {

View file

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
...
}: { }: {
programs.zoxide = { programs.zoxide = {
enable = true; enable = true;

View file

@ -1,9 +1,9 @@
{ { pkgs
pkgs, , lib
lib, , config
config, , ...
... }:
}: let let
cfg = config.shell.zsh; cfg = config.shell.zsh;
in in
with lib; { with lib; {

View file

@ -1,11 +1,12 @@
{ { pkgs
pkgs, , lib
lib, , inputs
inputs, , ...
... }:
}: let let
spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.system}; spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.system};
in { in
{
# allow spotify to be installed if you don't have unfree enabled already # allow spotify to be installed if you don't have unfree enabled already
nixpkgs.config.allowUnfreePredicate = pkg: nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [ builtins.elem (lib.getName pkg) [

View file

@ -1,10 +1,11 @@
{ { pkgs
pkgs, , config
config, , ...
... }:
}: let let
globalOpacity = 0.75; globalOpacity = 0.75;
in { in
{
stylix = { stylix = {
enable = true; enable = true;
autoEnable = true; autoEnable = true;

View file

@ -1,6 +1,7 @@
{ pkgs, ... }: { { pkgs, ... }: {
xdg = { xdg = {
enable = true; enable = true;
userDirs.enable = true;
mimeApps = { mimeApps = {
enable = true; enable = true;
defaultApplications = { defaultApplications = {