From 3ab72a09dd7caa5923a5e8eb70f0b40abd31cb69 Mon Sep 17 00:00:00 2001 From: Dmitriy Holkin Date: Mon, 10 Feb 2020 20:06:45 +0400 Subject: [PATCH] wip --- modules/packages.nix | 34 +++++++++++-- modules/services.nix | 51 +------------------ modules/sound/default.nix | 40 ++------------- modules/sound/mopidy.nix | 55 +++++++++++++++++++++ modules/sound/pulseaudio.nix | 38 ++++++++++++++ modules/workspace/i3status-rust/default.nix | 1 + nix/sources.json | 36 +++++++++----- 7 files changed, 153 insertions(+), 102 deletions(-) create mode 100644 modules/sound/mopidy.nix create mode 100644 modules/sound/pulseaudio.nix diff --git a/modules/packages.nix b/modules/packages.nix index 02d30b5..31fd1df 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -9,6 +9,8 @@ in { rec { inherit imports; + # naersk = pkgs.callPackage pkgs.imports.naersk {}; + youtube-to-mpv = pkgs.callPackage ./applications/youtube-to-mpv.nix { }; wg-conf = pkgs.callPackage ./applications/wg-conf.nix { }; @@ -18,14 +20,38 @@ in { xonar-fp = pkgs.callPackage ./applications/xonar-fp.nix { }; git-with-libsecret = super.git.override { withLibsecret = true; }; + + spotifyd = super.spotifyd.override { withPulseAudio = true; }; + + # spotify-tui = pkgs.callPackage ./applications/spotify-tui.nix { }; + + # spotify-tui = naersk.buildPackage { + # name = "spotify-tui"; + # src = pkgs.imports.spotify-tui; + # buildInputs = [ pkgs.pkgconf pkgs.openssl ]; + # }; + + # mopidy = super.mopidy.overridePythonAttrs (oa: { + # src = imports.mopidy; + # propagatedBuildInputs = with self.python27Packages; [ + # gst-python + # pygobject3 + # pykka + # tornado_4 + # requests + # setuptools + # dbus-python + # protobuf + # ]; + # }); } ) ]; - nixpkgs.config.packageOverrides = pkgs: { - spotifyd = pkgs.spotifyd.override { withPulseAudio = true; }; - spotify-tui = pkgs.callPackage ./applications/spotify-tui.nix { }; - }; + # nixpkgs.config.packageOverrides = pkgs: { + # spotifyd = pkgs.spotifyd.override { withPulseAudio = true; }; + # spotify-tui = pkgs.callPackage ./applications/spotify-tui.nix { }; + # }; nixpkgs.pkgs = import imports.nixpkgs { config.allowUnfree = true; diff --git a/modules/services.nix b/modules/services.nix index 1696ecc..16fd776 100644 --- a/modules/services.nix +++ b/modules/services.nix @@ -3,57 +3,8 @@ let device = config.devices.${config.device}; in { - # services.acpid.enable = true; - # users.users.mopidy = { - # isNormalUser = false; - # extraGroups = [ - # "smbgrp" - # ]; - # }; - # services.mopidy = { - # enable = true; - # extensionPackages = with pkgs; [ mopidy-local-sqlite ]; - # configuration = '' - # [local] - # enabled = true - # library = sqlite - # media_dir = /media/files/Music - # scan_timeout = 1000 - # scan_flush_threshold = 100 - # scan_follow_symlinks = false + services.acpid.enable = true; - # [local-sqlite] - # enabled = true - - # [audio] - # output = pulsesink server=127.0.0.1 - - # [mpd] - # hostname = 0.0.0.0 - # ''; - # }; - # home-manager.users.alukard.home.file.".ncmpcpp/config".text = '' - # mpd_host = 127.0.0.1 - # mpd_port = 6600 - # mpd_music_dir = "/media/files/Music" - # ''; - - # services.mopidy = { - # enable = true; - - # extensionPackages = with pkgs; [ mopidy-gmusic ]; - # configuration = (if (!isNull config.secrets.gpmusic) then '' - # [gmusic] - # username = ${config.secrets.gpmusic.user} - # password = ${config.secrets.gpmusic.password} - # deviceid = ${config.secrets.gpmusic.deviceid} - # bitrate = 128 - # '' else - # "") + '' - # [mpd] - # hostname = 0.0.0.0 - # ''; - # }; services.redshift = { enable = true; temperature.day = 5500; diff --git a/modules/sound/default.nix b/modules/sound/default.nix index 0cf33fe..c18a38a 100644 --- a/modules/sound/default.nix +++ b/modules/sound/default.nix @@ -1,42 +1,10 @@ { config, lib, pkgs, ... }: { sound.enable = true; - hardware.pulseaudio = { - enable = true; - # package = pkgs.pulseaudioFull; - support32Bit = true; - # systemWide = true; - tcp = { - enable = true; - anonymousClients.allowedIpRanges = ["127.0.0.1"]; - }; + imports = [ + ./pulseaudio.nix + ./mopidy.nix + ]; - extraConfig = '' - avoid-resampling = yes - high-priority = yes - nice-level = -17 - - realtime-scheduling = yes - realtime-priority = 9 - - resample-method = speex-float-8 - avoid-resampling = yes - enable-lfe-remixing = no - - flat-volumes = no - rlimit-rtprio = 9 - - default-sample-format = float32le - default-sample-rate = 44100 - alternate-sample-rate = 96000 - default-sample-channels = 2 - default-channel-map = front-left,front-right - - default-fragments = 2 - default-fragment-size-msec = 125 - - deferred-volume-safety-margin-usec = 1 - ''; - }; } \ No newline at end of file diff --git a/modules/sound/mopidy.nix b/modules/sound/mopidy.nix new file mode 100644 index 0000000..9163ec0 --- /dev/null +++ b/modules/sound/mopidy.nix @@ -0,0 +1,55 @@ +{ pkgs, config, lib, ... }: { + services.mopidy = { + enable = true; + # extensionPackages = with pkgs; [ mopidy-gmusic mopidy-youtube ]; + configuration = '' + [mpd] + hostname = 0.0.0.0 + [audio] + output = pulsesink server=127.0.0.1 + [local] + enabled = true + library = json + media_dir = /home/alukard/Music + scan_timeout = 1000 + scan_flush_threshold = 100 + scan_follow_symlinks = false + ''; + }; + + systemd.services.mopidy = { + after = [ "network-online.target" ]; + }; + + # users.users.mopidy = { + # isNormalUser = false; + # extraGroups = [ + # "smbgrp" + # ]; + # }; + # services.mopidy = { + # enable = true; + # # extensionPackages = with pkgs; [ mopidy-local ]; + # configuration = '' + # [local] + # enabled = true + # library = json + # media_dir = /home/alukard/Music + # scan_timeout = 1000 + # scan_flush_threshold = 100 + # scan_follow_symlinks = false + + # [audio] + # output = pulsesink server=127.0.0.1 + + # [mpd] + # hostname = 0.0.0.0 + # ''; + # }; + # home-manager.users.alukard.home.file.".ncmpcpp/config".text = '' + # mpd_host = 127.0.0.1 + # mpd_port = 6600 + # mpd_music_dir = "/media/files/Music" + # ''; + +} \ No newline at end of file diff --git a/modules/sound/pulseaudio.nix b/modules/sound/pulseaudio.nix new file mode 100644 index 0000000..5f6035b --- /dev/null +++ b/modules/sound/pulseaudio.nix @@ -0,0 +1,38 @@ +{ config, pkgs, lib, ... }: { + hardware.pulseaudio = { + enable = true; + # package = pkgs.pulseaudioFull; + support32Bit = true; + # systemWide = true; + tcp = { + enable = true; + anonymousClients.allowedIpRanges = ["127.0.0.1"]; + }; + daemon.config = { + avoid-resampling = "yes"; + + high-priority = "yes"; + nice-level = "-17"; + + realtime-scheduling = "yes"; + realtime-priority = "9"; + + resample-method = "speex-float-8"; + enable-lfe-remixing = "no"; + + flat-volumes = "no"; + rlimit-rtprio = "9"; + + default-sample-format = "float32le"; + default-sample-rate = "44100"; + alternate-sample-rate = "96000"; + default-sample-channels = "2"; + default-channel-map = "front-left,front-right"; + + default-fragments = "2"; + default-fragment-size-msec = "125"; + + deferred-volume-safety-margin-usec = "1"; + }; + }; +} \ No newline at end of file diff --git a/modules/workspace/i3status-rust/default.nix b/modules/workspace/i3status-rust/default.nix index 85aa7f7..32046c3 100644 --- a/modules/workspace/i3status-rust/default.nix +++ b/modules/workspace/i3status-rust/default.nix @@ -58,6 +58,7 @@ in { [[block]] block = "sound" + driver = "pulseaudio" [[block]] block = "cpu" diff --git a/nix/sources.json b/nix/sources.json index 4abaf09..08c290f 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -17,10 +17,10 @@ "homepage": "", "owner": "rycee", "repo": "home-manager", - "rev": "6cc4fd6ede4909226cb81d3475834251ed1b7210", - "sha256": "123wb940yw8k0qr3gmhdxi4ilzp9d2a7jsb6br6ybz7082dknlx8", + "rev": "f0fe18cd22f8daededa54892f8ba8d363c1ea1d9", + "sha256": "0pi9m95szvrsclj5jizjw35b996fnhr2fvkdapfv14ijkqd5cn0v", "type": "tarball", - "url": "https://github.com/rycee/home-manager/archive/6cc4fd6ede4909226cb81d3475834251ed1b7210.tar.gz", + "url": "https://github.com/rycee/home-manager/archive/f0fe18cd22f8daededa54892f8ba8d363c1ea1d9.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "i3lock-fancy-rapid": { @@ -47,16 +47,28 @@ "url": "https://github.com/nana-4/materia-theme/archive/b1e4c563146ae34fff6a697393b6a1bc66b612f5.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, + "mopidy": { + "branch": "develop", + "description": "Mopidy is an extensible music server written in Python", + "homepage": "https://mopidy.com", + "owner": "mopidy", + "repo": "mopidy", + "rev": "292d90b0a8218230f1be1e7a9fbcef15e32c8998", + "sha256": "1n6hgg0xb54vb6rp3f9vs9vzq18ir67454zslyfxhp7ykcqxvv1q", + "type": "tarball", + "url": "https://github.com/mopidy/mopidy/archive/292d90b0a8218230f1be1e7a9fbcef15e32c8998.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "naersk": { "branch": "master", "description": "Build rust crates in Nix. No configuration, no code generation. IFD and sandbox friendly.", "homepage": "", "owner": "nmattia", "repo": "naersk", - "rev": "4225dfaff988ce0713bc1cbf9a2a6dab8982df15", - "sha256": "13qbd5yjpw2qbsn2wxhzmjznqb8hf7sch1fdnjw904gj88wmnqnw", + "rev": "206cf17e20337b054dcf63a7355f50b0d712ec44", + "sha256": "1y4wc9w3icf7xg39yqdyzj0pkax9qs106nzsbsvs31w5spij9vfs", "type": "tarball", - "url": "https://github.com/nmattia/naersk/archive/4225dfaff988ce0713bc1cbf9a2a6dab8982df15.tar.gz", + "url": "https://github.com/nmattia/naersk/archive/206cf17e20337b054dcf63a7355f50b0d712ec44.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "niv": { @@ -77,10 +89,10 @@ "homepage": "https://github.com/NixOS/nixpkgs", "owner": "NixOS", "repo": "nixpkgs-channels", - "rev": "a21c2fa3ea2b88e698db6fc151d9c7259ae14d96", - "sha256": "1z3kxlbz6bqx1dlagcazg04vhk67r8byihzf959c3m0laf2a1w7y", + "rev": "8130f3c1c2bb0e533b5e150c39911d6e61dcecc2", + "sha256": "154nrhmm3dk5kmga2w5f7a2l6j79dvizrg4wzbrcwlbvdvapdgkb", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs-channels/archive/a21c2fa3ea2b88e698db6fc151d9c7259ae14d96.tar.gz", + "url": "https://github.com/NixOS/nixpkgs-channels/archive/8130f3c1c2bb0e533b5e150c39911d6e61dcecc2.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs-mozilla": { @@ -89,10 +101,10 @@ "homepage": null, "owner": "mozilla", "repo": "nixpkgs-mozilla", - "rev": "5300241b41243cb8962fad284f0004afad187dad", - "sha256": "1h3g3817anicwa9705npssvkwhi876zijyyvv4c86qiklrkn5j9w", + "rev": "36455d54de0b40d9432bba6d8207a5582210b3eb", + "sha256": "0ll0ws3jpidhrcz70hzq1l46y0bbzm87spw03x4zdpacq0n1yqrn", "type": "tarball", - "url": "https://github.com/mozilla/nixpkgs-mozilla/archive/5300241b41243cb8962fad284f0004afad187dad.tar.gz", + "url": "https://github.com/mozilla/nixpkgs-mozilla/archive/36455d54de0b40d9432bba6d8207a5582210b3eb.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "spotify-tui": {