From 2ed3c2b790eddd74c082e24dd7abc4e858251b82 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 4 Jul 2023 08:55:49 +0800 Subject: [PATCH] users/foo-dogsquared: modularize config --- users/home-manager/foo-dogsquared/default.nix | 218 +----------------- .../foo-dogsquared/modules/git.nix | 59 +++++ .../foo-dogsquared/modules/keys.nix | 37 +++ .../foo-dogsquared/modules/music.nix | 131 +++++++++++ 4 files changed, 233 insertions(+), 212 deletions(-) create mode 100644 users/home-manager/foo-dogsquared/modules/git.nix create mode 100644 users/home-manager/foo-dogsquared/modules/keys.nix create mode 100644 users/home-manager/foo-dogsquared/modules/music.nix diff --git a/users/home-manager/foo-dogsquared/default.nix b/users/home-manager/foo-dogsquared/default.nix index 3ff229d4..c91e4e3e 100644 --- a/users/home-manager/foo-dogsquared/default.nix +++ b/users/home-manager/foo-dogsquared/default.nix @@ -1,26 +1,20 @@ { config, options, lib, pkgs, ... }: let - ytdlpAudio = pkgs.writeScriptBin "yt-dlp-audio" '' - ${pkgs.yt-dlp}/bin/yt-dlp --config-location "${./config/yt-dlp-audio.conf}" $@ - ''; - dotfilesAsStorePath = config.lib.file.mkOutOfStoreSymlink config.home.mutableFile."library/dotfiles".path; getDotfiles = path: "${dotfilesAsStorePath}/${path}"; - - musicDir = config.xdg.userDirs.music; - playlistsDir = "${musicDir}/playlists"; in { + imports = [ + ./modules/keys.nix + ./modules/git.nix + ./modules/music.nix + ]; + home.packages = with pkgs; [ vscodium-fhs # Visual Studio-lite and for those who suffer from Visual Studio withdrawal. hledger # Trying to be a good accountant. hledger-utils # For extra trying to be a better accountant. - - # My music-related tools. - songrec # SHAZAM! - ytdlpAudio # My custom script for downloading music with yt-dlp. - picard # Graphical beets. ]; fonts.fontconfig.enable = true; @@ -35,211 +29,12 @@ in programs.bash.sessionVariables.PATH = "${config.home.mutableFile."library/dotfiles".path}/bin\${PATH:+:$PATH}"; - # My SSH client configuration. It is encouraged to keep matches and extra - # configurations included in a separate `config.d/` directory. This enables - # it to easily backup the certain files which is most likely what we're - # mostly configuring anyways. - programs.ssh = { - enable = true; - includes = [ "config.d/*" ]; - extraConfig = '' - AddKeysToAgent confirm 15m - ForwardAgent no - ''; - }; - - # My GPG client. It has to make sure the keys are not generated and has to be - # backed up somewhere. - # - # If you want to know how to manage GPG PROPERLY for the nth time, read the - # following document: - # https://alexcabal.com/creating-the-perfect-gpg-keypair - programs.gpg = { - enable = true; - - # This is just made to be a starting point, per se. - mutableKeys = true; - mutableTrust = true; - - settings = { - default-key = "0xADE0C41DAB221FCC"; - keyid-format = "0xlong"; - with-fingerprint = true; - no-comments = false; - }; - }; - - # My Git credentials. - programs.git = { - enable = true; - package = pkgs.gitFull; - lfs.enable = true; - userName = "Gabriel Arazas"; - userEmail = "foodogsquared@foodogsquared.one"; - signing.key = "ADE0C41DAB221FCC"; - extraConfig = { - # This is taken from the official Git book, for future references. - sendemail = { - smtpserver = "smtp.mailbox.org"; - smtpencryption = "tls"; - smtpserverport = 587; - smtpuser = "foodogsquared@mailbox.org"; - }; - - alias = { - unstage = "reset HEAD --"; - quick-rebase = "rebase --interactive --autostash --committer-date-is-author-date"; - }; - - init.defaultBranch = "main"; - - # Shorthand for popular forges ala-Nix flake URL inputs. It's just a fun - # little part of the config. - url = { - "https://github.com/".insteadOf = [ "gh:" "github:" ]; - "https://gitlab.com/".insteadOf = [ "gl:" "gitlab:" ]; - "https://gitlab.gnome.org/".insteadOf = [ "gnome:" ]; - "https://invent.kde.org/".insteadOf = [ "kde:" ]; - "https://git.sr.ht/".insteadOf = [ "sh:" "sourcehut:" ]; - "https://git.savannah.nongnu.org/git/".insteadOf = [ "sv:" "savannah:" ]; - }; - }; - }; - - # My GitHub CLI setup. - programs.gh = { - enable = true; - extensions = with pkgs; [ - gh-eco - gh-dash - ]; - - settings = { - git_protocol = "ssh"; - prompt = "enabled"; - - aliases = { - pc = "pr checkout"; - pv = "pr view"; - }; - }; - }; - # Making my favorite terminal multiplexer right now. programs.zellij.settings = { default_layout = "editor"; layout_dir = builtins.toString ./config/zellij/layouts; }; - # My music player setup, completely configured with Nix! - programs.beets = { - enable = true; - settings = { - library = "${musicDir}/library.db"; - plugins = [ - "acousticbrainz" - "chroma" - "edit" - "export" - "fetchart" - "fromfilename" - "fuzzy" - "mbsync" - "playlist" - "scrub" - "smartplaylist" - ]; - ignore_hidden = true; - directory = musicDir; - ui.color = true; - - import = { - move = true; - link = false; - resume = true; - incremental = true; - group_albums = true; - log = "beets.log"; - }; - - match.ignore_video_tracks = true; - - # Plugins configuration. - fuzzy.prefix = "-"; - scrub.auto = true; - smartplaylist = { - relative_to = musicDir; - playlist_dir = playlistsDir; - playlists = [ - { - name = "all.m3u8"; - query = ""; - } - { - name = "released-in-$year.m3u8"; - query = "year:2000..2023"; - } - ]; - }; - }; - }; - - services.mopidy = { - enable = true; - extensionPackages = with pkgs; [ - mopidy-beets - mopidy-funkwhale - mopidy-internetarchive - mopidy-iris - mopidy-local - mopidy-mpd - mopidy-mpris - mopidy-youtube - ]; - - settings = { - http = { - hostname = "127.0.0.1"; - port = 6680; - default_app = "iris"; - }; - - file = { - enabled = true; - media_dirs = [ - "$XDG_MUSIC_DIR|Music" - "~/library/music|Library" - ]; - }; - - internetarchive = { - enabled = true; - browse_limit = 150; - search_limit = 150; - collections = [ - "fav-foo-dogsquared" - "audio" - "etree" - "audio_music" - "audio_foreign" - ]; - }; - - m3u = { - enabled = true; - base_dir = musicDir; - playlists_dir = playlistsDir; - default_encoding = "utf-8"; - default_extension = ".m3u8"; - }; - }; - }; - - programs.ncmpcpp = { - enable = true; - mpdMusicDir = musicDir; - }; - # My preferred file indexing service. services.recoll = { enable = true; @@ -269,7 +64,6 @@ in desktop = { enable = true; graphics.enable = true; - audio.enable = true; video.enable = true; documents.enable = true; }; diff --git a/users/home-manager/foo-dogsquared/modules/git.nix b/users/home-manager/foo-dogsquared/modules/git.nix new file mode 100644 index 00000000..e98b08eb --- /dev/null +++ b/users/home-manager/foo-dogsquared/modules/git.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +{ + # My Git credentials. + programs.git = { + enable = true; + package = pkgs.gitFull; + lfs.enable = true; + userName = config.accounts.email.accounts.personal.realName; + userEmail = config.accounts.email.accounts.personal.address; + signing.key = "ADE0C41DAB221FCC"; + extraConfig = { + # This is taken from the official Git book, for future references. + sendemail = { + smtpserver = "smtp.mailbox.org"; + smtpencryption = "tls"; + smtpserverport = 587; + smtpuser = "foodogsquared@mailbox.org"; + }; + + alias = { + unstage = "reset HEAD --"; + quick-rebase = "rebase --interactive --autostash --committer-date-is-author-date"; + }; + + init.defaultBranch = "main"; + + # Shorthand for popular forges ala-Nix flake URL inputs. It's just a fun + # little part of the config. + url = { + "https://github.com/".insteadOf = [ "gh:" "github:" ]; + "https://gitlab.com/".insteadOf = [ "gl:" "gitlab:" ]; + "https://gitlab.gnome.org/".insteadOf = [ "gnome:" ]; + "https://invent.kde.org/".insteadOf = [ "kde:" ]; + "https://git.sr.ht/".insteadOf = [ "sh:" "sourcehut:" ]; + "https://git.savannah.nongnu.org/git/".insteadOf = [ "sv:" "savannah:" ]; + }; + }; + }; + + # My GitHub CLI setup. + programs.gh = { + enable = true; + extensions = with pkgs; [ + gh-eco + gh-dash + ]; + + settings = { + git_protocol = "ssh"; + prompt = "enabled"; + + aliases = { + pc = "pr checkout"; + pv = "pr view"; + }; + }; + }; +} diff --git a/users/home-manager/foo-dogsquared/modules/keys.nix b/users/home-manager/foo-dogsquared/modules/keys.nix new file mode 100644 index 00000000..81d15196 --- /dev/null +++ b/users/home-manager/foo-dogsquared/modules/keys.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +{ + # My SSH client configuration. It is encouraged to keep matches and extra + # configurations included in a separate `config.d/` directory. This enables + # it to easily backup the certain files which is most likely what we're + # mostly configuring anyways. + programs.ssh = { + enable = true; + includes = [ "config.d/*" ]; + extraConfig = '' + AddKeysToAgent confirm 15m + ForwardAgent no + ''; + }; + + # My GPG client. It has to make sure the keys are not generated and has to be + # backed up somewhere. + # + # If you want to know how to manage GPG PROPERLY for the nth time, read the + # following document: + # https://alexcabal.com/creating-the-perfect-gpg-keypair + programs.gpg = { + enable = true; + + # This is just made to be a starting point, per se. + mutableKeys = true; + mutableTrust = true; + + settings = { + default-key = "0xADE0C41DAB221FCC"; + keyid-format = "0xlong"; + with-fingerprint = true; + no-comments = false; + }; + }; +} diff --git a/users/home-manager/foo-dogsquared/modules/music.nix b/users/home-manager/foo-dogsquared/modules/music.nix new file mode 100644 index 00000000..7f8aff0f --- /dev/null +++ b/users/home-manager/foo-dogsquared/modules/music.nix @@ -0,0 +1,131 @@ +{ config, lib, pkgs, ... }: + +let + ytdlpAudio = pkgs.writeScriptBin "yt-dlp-audio" '' + ${pkgs.yt-dlp}/bin/yt-dlp --config-location "${./config/yt-dlp-audio.conf}" $@ + ''; + + musicDir = config.xdg.userDirs.music; + playlistsDir = "${musicDir}/playlists"; +in +{ + home.packages = with pkgs; [ + songrec # SHAZAM! + ytdlpAudio # My custom script for downloading music with yt-dlp. + picard # Graphical beets. + ]; + + # Enable the desktop audio profile for extra auditorial goodies. + profiles.desktop.audio.enable = true; + + # My music player setup, completely configured with Nix! + programs.beets = { + enable = true; + settings = { + library = "${musicDir}/library.db"; + plugins = [ + "acousticbrainz" + "chroma" + "edit" + "export" + "fetchart" + "fromfilename" + "fuzzy" + "mbsync" + "playlist" + "scrub" + "smartplaylist" + ]; + ignore_hidden = true; + directory = musicDir; + ui.color = true; + + import = { + move = true; + link = false; + resume = true; + incremental = true; + group_albums = true; + log = "beets.log"; + }; + + match.ignore_video_tracks = true; + + # Plugins configuration. + fuzzy.prefix = "-"; + scrub.auto = true; + smartplaylist = { + relative_to = musicDir; + playlist_dir = playlistsDir; + playlists = [ + { + name = "all.m3u8"; + query = ""; + } + { + name = "released-in-$year.m3u8"; + query = "year:2000..2023"; + } + ]; + }; + }; + }; + + services.mopidy = { + enable = true; + extensionPackages = with pkgs; [ + mopidy-beets + mopidy-funkwhale + mopidy-internetarchive + mopidy-iris + mopidy-local + mopidy-mpd + mopidy-mpris + mopidy-youtube + ]; + + settings = { + http = { + hostname = "127.0.0.1"; + port = 6680; + default_app = "iris"; + }; + + file = { + enabled = true; + media_dirs = [ + "$XDG_MUSIC_DIR|Music" + "~/library/music|Library" + ]; + }; + + internetarchive = { + enabled = true; + browse_limit = 150; + search_limit = 150; + collections = [ + "fav-foo-dogsquared" + "audio" + "etree" + "audio_music" + "audio_foreign" + ]; + }; + + m3u = { + enabled = true; + base_dir = musicDir; + playlists_dir = playlistsDir; + default_encoding = "utf-8"; + default_extension = ".m3u8"; + }; + }; + }; + + # Configure a MPD client. + programs.ncmpcpp = { + enable = true; + mpdMusicDir = musicDir; + }; + +}