diff --git a/backup/modules/users/applications/rofi.nix b/backup/modules/users/applications/rofi.nix index c607d0d..4341075 100644 --- a/backup/modules/users/applications/rofi.nix +++ b/backup/modules/users/applications/rofi.nix @@ -13,7 +13,7 @@ in config = mkIf (cfg.enable) { programs.rofi = { enable = true; - package = myPkgs.rofi-wayland; + package = pkgs.rofi-wayland; }; }; } diff --git a/flake.nix b/flake.nix index 816d6ba..f9e526a 100644 --- a/flake.nix +++ b/flake.nix @@ -42,32 +42,8 @@ ]; }; - # nixosUsers = [{ - # name = "erwin"; - # groups = [ "wheel" "networkmanager" "video" ]; - # uid = 1000; - # shell = pkgs.fish; - # openssh.authorizedKeys.keys = [ - # "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMNoTcRsAxDwpiIj6nhUXwzSQjtcgKCR0RDlzP57wi0W erwin@horusvr-ws2" - # ]; - # }]; - in { - # homeManagerConfigurations = { - # erwin = user.mkHMUser { - # userConfig = { - # git.enable = true; - # ssh.enable = true; - # applications.enable = true; - # gpg.enable = true; - # fish.enable = true; - # sway.enable = true; - # }; - # username = "erwin"; - # }; - # }; - overlay = final: prev: (import ./overlays) final prev; # overlay = final: prev: { # unstable = import nixpkgs { @@ -84,33 +60,6 @@ (builtins.attrNames (builtins.readDir ./modules))); nixosConfigurations = { - # vm1 = host.mkHost { - # name = "vm1"; - # NICs = [ "enp1s0" ]; - # kernelPackage = pkgs.linuxPackages; - # initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; - # kernelMods = [ "kvm-amd" ]; - # kernelParams = [ ]; - # systemConfig = vm1UefiConfig; - - # users = nixosUsers; - - # cpuCores = 6; - # }; - - # vm2 = host.mkHost { - # name = "vm2"; - # NICs = [ "enp1s0" ]; - # kernelPackage = pkgs.linuxPackages; - # initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; - # kernelMods = [ "kvm-amd" ]; - # kernelParams = [ ]; - # systemConfig = vm2Config; - - # users = nixosUsers; - - # cpuCores = 4; - # }; vm1 = defSystem "x86_64-linux" { imports = [ (import (./machines/vm1/configuration.nix) { inherit self; }) @@ -130,7 +79,7 @@ }; } // - (flake-utils.lib.eachSystem [ "x86_64-linux" ]) + (flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ]) (system: let pkgs = import nixpkgs { diff --git a/home-manager/modules/rofi/default.nix b/home-manager/modules/rofi/default.nix index f2a7208..5dc5b2e 100644 --- a/home-manager/modules/rofi/default.nix +++ b/home-manager/modules/rofi/default.nix @@ -10,6 +10,7 @@ in programs.rofi = { enable = true; + package = pkgs.rofi-wayland; theme = ./launch.rasi; }; }; diff --git a/home-manager/modules/rofi/config.rasi b/home-manager/modules/rofi/launch.rasi similarity index 100% rename from home-manager/modules/rofi/config.rasi rename to home-manager/modules/rofi/launch.rasi diff --git a/krops.nix b/krops.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/krops.nix @@ -0,0 +1 @@ +{ } diff --git a/machines/vm1/configuration.nix b/machines/vm1/configuration.nix index 769d1c3..f9e4c1f 100644 --- a/machines/vm1/configuration.nix +++ b/machines/vm1/configuration.nix @@ -17,7 +17,7 @@ networking = { hostName = "vm2"; useDHCP = false; - interfaces.enp1s.useDHCP = true; + interfaces.enp1s0.useDHCP = true; }; # nix = { diff --git a/machines/vm2/configuration.nix b/machines/vm2/configuration.nix index 769d1c3..795c890 100644 --- a/machines/vm2/configuration.nix +++ b/machines/vm2/configuration.nix @@ -7,6 +7,9 @@ enable = true; home-manager = true; }; + nix-common = { + enable = true; + }; }; boot.loader.systemd-boot.enable = true; @@ -17,7 +20,7 @@ networking = { hostName = "vm2"; useDHCP = false; - interfaces.enp1s.useDHCP = true; + interfaces.enp1s0.useDHCP = true; }; # nix = { diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 82f5fbc..bf5170e 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -41,13 +41,23 @@ in home.packages = with pkgs; [ (nerdfonts.override { fonts = [ "CascadiaCode" "FantasqueSansMono" "FiraCode" "Iosevka" "JetBrainsMono" "Meslo" "Noto" "SourceCodePro" ]; }) + (callPackage ../../pkgs/pamedia { }) ]; imports = [ + { + nixpkgs.overlays = [ self-overlay ]; + } ../../home-manager/modules/sway ../../home-manager/modules/waybar ../../home-manager/modules/rofi ]; }; + + services.pipewire = { + enable = true; + pulse.enable = true; + media-session.enable = true; + }; }; } diff --git a/modules/nix-common/default.nix b/modules/nix-common/default.nix new file mode 100644 index 0000000..c7fdad7 --- /dev/null +++ b/modules/nix-common/default.nix @@ -0,0 +1,33 @@ +{ lib, pkgs, config, ... }: +with lib; +let cfg = config.eboskma.nix-common; +in +{ + options.eboskma.nix-common = { + enable = mkEnableOption "activate nix-common"; + disable-cache = mkEnableOption "no not use binary cache"; + }; + + config = mkIf cfg.enable { + nixpkgs = { + config.allowUnfree = true; + }; + + nix = { + package = pkgs.nixFlakes; + extraOptions = '' + experimental-features = nix-command flakes ca-references + ''; + + autoOptimiseStore = true; + + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than=30d"; + }; + + allowedUsers = [ "root" ]; + }; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix index 6fa401a..89bf8a4 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,4 +1,11 @@ -self: super: { - rofi = super.pkgs.callPackage ../pkgs/rofi-wayland { }; - pamedia = super.pkgs.callPackage ../pkgs/pamedia { }; +final: prev: { + rofi-wayland = prev.pkgs.callPackage ../pkgs/rofi-wayland { }; + pamedia = prev.pkgs.callPackage ../pkgs/pamedia { + buildPythonPackage = prev.pkgs.python3.pkgs.buildPythonPackage; + pulsectl = prev.pkgs.python39Packages.pulsectl; + pygobject3 = prev.pkgs.python39Packages.pygobject3; + gobject-introspection = prev.pkgs.gobject-introspection; + libnotify = prev.pkgs.libnotify; + lib = prev.pkgs.lib; + }; } diff --git a/pkgs/pamedia/default.nix b/pkgs/pamedia/default.nix index 0b00f16..20eccb8 100644 --- a/pkgs/pamedia/default.nix +++ b/pkgs/pamedia/default.nix @@ -1,4 +1,10 @@ -{ buildPythonPackage, lib, pulsectl }: +{ pkgs, ... }: +with pkgs; +let + buildPythonPackage = python3.pkgs.buildPythonPackage; + pulsectl = python3.pkgs.pulsectl; + pygobject3 = python3.pkgs.pygobject3; +in buildPythonPackage rec { pname = "pamedia"; version = "0.1.0"; @@ -7,13 +13,11 @@ buildPythonPackage rec { propagatedBuildInputs = [ pulsectl + pygobject3 + gobject-introspection + libnotify ]; - installPhase = '' - install -d $out/bin - install -m 0755 $src/pamedia $out/bin/pamedia - ''; - meta = { description = "Change volume of the PulseAudio default sink"; license = lib.licenses.mit; diff --git a/pkgs/pamedia/src/pamedia b/pkgs/pamedia/src/pamedia/__init__.py similarity index 56% rename from pkgs/pamedia/src/pamedia rename to pkgs/pamedia/src/pamedia/__init__.py index c880b89..0cdaf73 100755 --- a/pkgs/pamedia/src/pamedia +++ b/pkgs/pamedia/src/pamedia/__init__.py @@ -4,7 +4,7 @@ import argparse import pulsectl import gi -gi.require_version('Notify', '0.7') +gi.require_version("Notify", "0.7") from gi.repository import GLib from gi.repository import Notify @@ -12,19 +12,22 @@ from gi.repository import Notify class PAMedia: def __init__(self, sink=None): - self.client = pulsectl.Pulse('volumectl') + self.client = pulsectl.Pulse("volumectl") sinks = self.client.sink_list() if sink == None: self.sink = self.client.get_sink_by_name( - self.client.server_info().default_sink_name) + self.client.server_info().default_sink_name + ) else: if sink > len(sinks): notification = Notify.Notification.new( - 'Volume', f'Unknown sink index \'{sink}\', using default sink') + "Volume", f"Unknown sink index '{sink}', using default sink" + ) notification.show() self.sink = self.client.get_sink_by_name( - self.client.server_info().default_sink_name) + self.client.server_info().default_sink_name + ) self.sink = sinks[sink] @@ -45,31 +48,31 @@ class PAMedia: def list_sinks(self): for num, sink in enumerate(self.client.sink_list()): - print(f'[{num}] {sink.description}') + print(f"[{num}] {sink.description}") def icon(self): if self.sink.mute: - return 'muted' + return "muted" elif self.sink.volume.value_flat <= 0.3: - return 'low' + return "low" elif self.sink.volume.value_flat <= 0.7: - return 'medium' + return "medium" else: - return 'high' + return "high" def notify(self): - icon = f'audio-volume-{self.icon()}' - title = f'Volume' + icon = f"audio-volume-{self.icon()}" + title = f"Volume" if self.sink.mute: - title = 'Muted' + title = "Muted" - notification = Notify.Notification.new(title, '', icon) + notification = Notify.Notification.new(title, "", icon) if not self.sink.mute: notification.set_hint( - 'x-canonical-private-synchronous', GLib.Variant.new_string('audio')) - notification.set_hint( - 'value', GLib.Variant.new_int32(round(self.volume()))) + "x-canonical-private-synchronous", GLib.Variant.new_string("audio") + ) + notification.set_hint("value", GLib.Variant.new_int32(round(self.volume()))) notification.show() @@ -79,33 +82,37 @@ class PAMedia: def volume_format(self): volume = round(self.volume()) - return f'{volume}%' + return f"{volume}%" -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='PulseAudio volume control') - parser.add_argument('-s', '--sink', type=int, - help='Select output sink to control') - parser.add_argument('command', metavar='CMD', type=str, - nargs='+', help='Command, one of: mute, up, down, set, get, sinks') +def main(): + parser = argparse.ArgumentParser(description="PulseAudio volume control") + parser.add_argument("-s", "--sink", type=int, help="Select output sink to control") + parser.add_argument( + "command", + metavar="CMD", + type=str, + nargs="+", + help="Command, one of: mute, up, down, set, get, sinks", + ) args = parser.parse_args() ctl = PAMedia(sink=args.sink) - Notify.init('volumectl') + Notify.init("volumectl") - if args.command[0] == 'mute': + if args.command[0] == "mute": ctl.toggle_mute() - elif args.command[0] == 'up': + elif args.command[0] == "up": ctl.volume_up() - elif args.command[0] == 'down': + elif args.command[0] == "down": ctl.volume_down() - elif args.command[0] == 'get': - print(f'Volume: {ctl.volume_format()}') + elif args.command[0] == "get": + print(f"Volume: {ctl.volume_format()}") exit(0) - elif args.command[0] == 'set' and len(args.command) >= 2: + elif args.command[0] == "set" and len(args.command) >= 2: ctl.volume_set(args.command[1]) - elif args.command[0] == 'sinks': + elif args.command[0] == "sinks": ctl.list_sinks() exit(0) else: diff --git a/pkgs/pamedia/src/pamedia/__main__.py b/pkgs/pamedia/src/pamedia/__main__.py new file mode 100644 index 0000000..daf5509 --- /dev/null +++ b/pkgs/pamedia/src/pamedia/__main__.py @@ -0,0 +1,5 @@ +from . import main + + +if __name__ == '__main__': + main() diff --git a/pkgs/pamedia/src/pyproject.toml b/pkgs/pamedia/src/pyproject.toml new file mode 100644 index 0000000..07de284 --- /dev/null +++ b/pkgs/pamedia/src/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/pkgs/pamedia/src/setup.cfg b/pkgs/pamedia/src/setup.cfg new file mode 100644 index 0000000..85b55b8 --- /dev/null +++ b/pkgs/pamedia/src/setup.cfg @@ -0,0 +1,15 @@ +[metadata] +name = pamedia +version = 0.1.0 +description = Small utility to control the volume of the default PulseAudio sink, including notifications. Also compatible with Pipewire with the PulseAudio compatibility interface +author = "Erwin Boskma " + +[options] +packages = pamedia +install_requires = + pulsectl + PyGObject + +[options.entry_points] +console_scripts = + pamedia = pamedia:main \ No newline at end of file diff --git a/pkgs/pamedia/src/setup.py b/pkgs/pamedia/src/setup.py new file mode 100644 index 0000000..7f1a176 --- /dev/null +++ b/pkgs/pamedia/src/setup.py @@ -0,0 +1,4 @@ +from setuptools import setup + +if __name__ == "__main__": + setup() diff --git a/pkgs/rofi-wayland/default.nix b/pkgs/rofi-wayland/default.nix index 07b0877..e58576c 100644 --- a/pkgs/rofi-wayland/default.nix +++ b/pkgs/rofi-wayland/default.nix @@ -32,6 +32,7 @@ stdenv.mkDerivation rec { xorg.libxcb xorg.xcbutil xorg.xcbutilwm + xcb-util-cursor xcbutilxrm which wayland-protocols