users/foo-dogsquared: try out home-manager-user-specific module structuring

This commit is contained in:
Gabriel Arazas 2023-12-12 09:43:25 +08:00
parent f53ac7e8b9
commit a249db9b1a
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
11 changed files with 493 additions and 407 deletions

View File

@ -5,13 +5,23 @@ let
getDotfiles = path: "${dotfilesAsStorePath}/${path}";
in
{
imports = [
./modules/browser.nix
./modules/email.nix
./modules/keys.nix
./modules/git.nix
./modules/music.nix
];
imports = [ ./modules ];
# All of the home-manager-user-specific setup are here.
users.foo-dogsquared = {
music.enable = true;
programs = {
browsers.brave.enable = true;
browsers.firefox.enable = true;
browsers.misc.enable = true;
email.enable = true;
email.thunderbird.enable = true;
git.enable = true;
keys.gpg.enable = true;
keys.ssh.enable = true;
};
};
# The keyfile required to decrypt the secrets.
sops.age.keyFile = "${config.xdg.configHome}/age/user";

View File

@ -0,0 +1,11 @@
# Only optional modules should be imported here.
{
imports = [
./music-setup.nix
./programs/browsers.nix
./programs/email.nix
./programs/git.nix
./programs/keys.nix
];
}

View File

@ -1,138 +0,0 @@
{ config, lib, pkgs, ... }:
{
accounts.email.accounts = {
# TODO: Enable offlineimap once maildir support is stable in Thunderbird.
personal = {
address = "foodogsquared@foodogsquared.one";
aliases = [
"admin@foodogsquared.one"
"webmaster@foodogsquared.one"
"hostmaster@foodogsquared.one"
"postmaster@foodogsquared.one"
];
primary = true;
realName = "Gabriel Arazas";
userName = "foodogsquared@mailbox.org";
signature = {
delimiter = "--<----<---->---->--";
text = ''
foodogsquared at foodogsquared dot one
'';
};
passwordCommand = "gopass show personal/websites/mailbox.org/foodogsquared@mailbox.org | head -n 1";
# Set up the ingoing mails.
imap = {
host = "imap.mailbox.org";
port = 993;
tls.enable = true;
};
# Set up the outgoing mails.
smtp = {
host = "smtp.mailbox.org";
port = 465;
tls.enable = true;
};
# GPG settings... wablamo.
gpg = {
key = "0xADE0C41DAB221FCC";
encryptByDefault = false;
signByDefault = false;
};
};
old_personal = {
address = "foo.dogsquared@gmail.com";
realName = config.accounts.email.accounts.personal.realName;
userName = "foo.dogsquared@gmail.com";
flavor = "gmail.com";
passwordCommand = "gopass show personal/websites/accounts.google.com/foo.dogsquared | head -n 1";
};
};
programs.thunderbird = {
enable = true;
profiles.personal = {
isDefault = true;
settings = {
"mail.identity.default.archive_enabled" = true;
"mail.identity.default.archive_keep_folder_structure" = true;
"mail.identity.default.compose_html" = false;
"mail.identity.default.protectSubject" = true;
"mail.identity.default.reply_on_top" = 1;
"mail.identity.default.sig_on_reply" = true;
"mail.server.default.canDelete" = true;
};
};
settings = {
# Some general settings.
"mail.server.default.allow_utf8_accept" = true;
"mail.server.default.max_articles" = 1000;
"mail.server.default.check_all_folders_for_new" = true;
"mail.show_headers" = 1;
# Show some metadata.
"mailnews.headers.showMessageId" = true;
"mailnews.headers.showOrganization" = true;
"mailnews.headers.showReferences" = true;
"mailnews.headers.showUserAgent" = true;
# Sort mails and news in descending order.
"mailnews.default_sort_order" = 2;
"mailnews.default_news_sort_order" = 2;
# Sort mails and news by date.
"mailnews.default_sort_type" = 18;
"mailnews.default_news_sort_type" = 18;
# Sort them by the newest reply in thread.
"mailnews.sort_threads_by_root" = true;
# Show time. :)
"mail.ui.display.dateformat.default" = 1;
# Sanitize it to UTC to prevent leaking local time.
"mail.sanitize_date_header" = true;
# Trust positives from server spam filter.
"mail.server.default.serverFilterName" = "SpamAssassin";
"mail.server.default.serverFilterFlags" = 1;
# Email composing QoL.
"mail.identity.default.auto_quote" = true;
"mail.identity.default.attachPgpKey" = true;
# RSS feeds options.
"rss.max_concurrent_feeds" = 30;
"rss.disable_feeds_on_update_failure" = false;
# Open web page on default browser on select.
"rss.message.loadWebPageOnSelect" = 0;
# Load the summary on display.
"rss.show.summary" = 1;
# Open the web page on new window.
"rss.show.content-base" = 0;
# Don't tease me with the updates, man.
"app.update.auto" = false;
"privacy.donottrackheader.enabled" = true;
};
};
services.bleachbit.cleaners = [
"thunderbird.cache"
"thunderbird.cookies"
"thunderbird.index"
"thunderbird.passwords"
"thunderbird.sessionjson"
"thunderbird.vacuum"
];
}

View File

@ -1,68 +0,0 @@
{ config, lib, pkgs, ... }:
{
home.packages = with pkgs; [
tea # So you don't have to see some teas, I guess.
hut # So you don't have to see Sourcehut's brutalist design, I guess.
];
# My Git credentials.
programs.git = {
enable = true;
package = pkgs.gitFull;
lfs.enable = true;
signing.key = "ADE0C41DAB221FCC";
extraConfig = {
user = {
name = config.accounts.email.accounts.personal.realName;
email = config.accounts.email.accounts.personal.address;
};
alias = {
unstage = "reset HEAD --";
quick-rebase = "rebase --interactive --autostash --committer-date-is-author-date";
quick-clone = "clone --depth=1 --recurse-submodules --shallow-submodules";
};
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:" ];
};
status = {
showPatch = true;
showStash = true;
};
submodule.fetchJobs = 0;
};
};
# My GitHub CLI setup.
programs.gh = {
enable = true;
extensions = with pkgs; [
gh-eco
gh-dash
gh-actions-cache
];
settings = {
git_protocol = "ssh";
prompt = "enabled";
aliases = {
pc = "pr checkout";
pv = "pr view";
};
};
};
}

View File

@ -1,46 +0,0 @@
{ 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
VisualHostKey yes
'';
};
# Make all of the initial SSH identities configuration here. It should assume
# I have other SSH identities configuration that are not committed here for
# whatever reason.
home.file.".ssh/config.d" = {
source = ../config/ssh;
recursive = true;
};
# 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;
};
};
}

View File

@ -0,0 +1,152 @@
{ config, lib, pkgs, ... }:
let
userCfg = config.users.foo-dogsquared;
cfg = userCfg.music;
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
{
options.users.foo-dogsquared.music = {
enable = lib.mkEnableOption "foo-dogsquared's music setup";
mpd.enable = lib.mkEnableOption "foo-dogsquared's MPD server setup";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
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";
}
];
};
};
};
# Add more cleaners.
services.bleachbit.cleaners = [
"audacious.log"
"audacious.cache"
"audacious.mru"
"vlc.memory_dump"
"vlc.mru"
];
}
(lib.mkIf cfg.mpd.enable {
services.mopidy = {
enable = true;
extensionPackages = with pkgs; [
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;
};
})
]);
}

View File

@ -1,138 +0,0 @@
{ 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-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;
};
# Add more cleaners.
services.bleachbit.cleaners = [
"audacious.log"
"audacious.cache"
"audacious.mru"
"vlc.memory_dump"
"vlc.mru"
];
}

View File

@ -1,15 +1,20 @@
# WHOA! Even browsers with extensions can be declarative!
{ config, lib, pkgs, ... }@attrs:
let
userCfg = config.users.foo-dogsquared;
cfg = userCfg.programs.browsers;
in
{
config = lib.mkMerge [
{
home.packages = with pkgs; [
google-chrome
nyxt
];
options.users.foo-dogsquared.programs.browsers = {
firefox.enable = lib.mkEnableOption "foo-dogsquared's Firefox setup";
brave.enable = lib.mkEnableOption "foo-dogsquared's Brave setup";
misc.enable = lib.mkEnableOption "foo-dogsquared's miscellaneous browsers setup";
};
# The only browser to give me money.
config = lib.mkMerge [
# The only browser to give me money.
(lib.mkIf cfg.brave.enable {
programs.brave = {
enable = true;
commandLineArgs = [
@ -33,10 +38,10 @@
{ id = "nglaklhklhcoonedhgnpgddginnjdadi"; } # ActivityWatch Web Watcher
];
};
}
})
# Despite the name, it isn't a browser for furries.
(lib.mkIf (attrs ? osConfig -> !attrs.osConfig.programs.firefox.enable) {
# Despite the name, it isn't a browser for furries.
programs.firefox = {
enable = true;
@ -175,7 +180,15 @@
};
# Configuring Tridactyl.
xdg.configFile.tridactyl.source = ../config/tridactyl;
xdg.configFile.tridactyl.source = ../../config/tridactyl;
})
# Goes with whatever you want to.
(lib.mkIf cfg.misc.enable {
home.packages = with pkgs; [
google-chrome
nyxt
];
})
];
}

View File

@ -0,0 +1,153 @@
{ config, lib, pkgs, ... }:
let
userCfg = config.users.foo-dogsquared;
cfg = userCfg.programs.email;
in
{
options.users.foo-dogsquared.programs.email = {
enable = lib.mkEnableOption "foo-dogsquared's email setup";
thunderbird.enable = lib.mkEnableOption "foo-dogsquared's Thunderbird configuration";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
accounts.email.accounts = {
# TODO: Enable offlineimap once maildir support is stable in Thunderbird.
personal = {
address = "foodogsquared@foodogsquared.one";
aliases = [
"admin@foodogsquared.one"
"webmaster@foodogsquared.one"
"hostmaster@foodogsquared.one"
"postmaster@foodogsquared.one"
];
primary = true;
realName = "Gabriel Arazas";
userName = "foodogsquared@mailbox.org";
signature = {
delimiter = "--<----<---->---->--";
text = ''
foodogsquared at foodogsquared dot one
'';
};
passwordCommand = "gopass show personal/websites/mailbox.org/foodogsquared@mailbox.org | head -n 1";
# Set up the ingoing mails.
imap = {
host = "imap.mailbox.org";
port = 993;
tls.enable = true;
};
# Set up the outgoing mails.
smtp = {
host = "smtp.mailbox.org";
port = 465;
tls.enable = true;
};
# GPG settings... wablamo.
gpg = {
key = "0xADE0C41DAB221FCC";
encryptByDefault = false;
signByDefault = false;
};
};
old_personal = {
address = "foo.dogsquared@gmail.com";
realName = config.accounts.email.accounts.personal.realName;
userName = "foo.dogsquared@gmail.com";
flavor = "gmail.com";
passwordCommand = "gopass show personal/websites/accounts.google.com/foo.dogsquared | head -n 1";
};
};
}
(lib.mkIf cfg.thunderbird.enable {
programs.thunderbird = {
enable = true;
profiles.personal = {
isDefault = true;
settings = {
"mail.identity.default.archive_enabled" = true;
"mail.identity.default.archive_keep_folder_structure" = true;
"mail.identity.default.compose_html" = false;
"mail.identity.default.protectSubject" = true;
"mail.identity.default.reply_on_top" = 1;
"mail.identity.default.sig_on_reply" = true;
"mail.server.default.canDelete" = true;
};
};
settings = {
# Some general settings.
"mail.server.default.allow_utf8_accept" = true;
"mail.server.default.max_articles" = 1000;
"mail.server.default.check_all_folders_for_new" = true;
"mail.show_headers" = 1;
# Show some metadata.
"mailnews.headers.showMessageId" = true;
"mailnews.headers.showOrganization" = true;
"mailnews.headers.showReferences" = true;
"mailnews.headers.showUserAgent" = true;
# Sort mails and news in descending order.
"mailnews.default_sort_order" = 2;
"mailnews.default_news_sort_order" = 2;
# Sort mails and news by date.
"mailnews.default_sort_type" = 18;
"mailnews.default_news_sort_type" = 18;
# Sort them by the newest reply in thread.
"mailnews.sort_threads_by_root" = true;
# Show time. :)
"mail.ui.display.dateformat.default" = 1;
# Sanitize it to UTC to prevent leaking local time.
"mail.sanitize_date_header" = true;
# Trust positives from server spam filter.
"mail.server.default.serverFilterName" = "SpamAssassin";
"mail.server.default.serverFilterFlags" = 1;
# Email composing QoL.
"mail.identity.default.auto_quote" = true;
"mail.identity.default.attachPgpKey" = true;
# RSS feeds options.
"rss.max_concurrent_feeds" = 30;
"rss.disable_feeds_on_update_failure" = false;
# Open web page on default browser on select.
"rss.message.loadWebPageOnSelect" = 0;
# Load the summary on display.
"rss.show.summary" = 1;
# Open the web page on new window.
"rss.show.content-base" = 0;
# Don't tease me with the updates, man.
"app.update.auto" = false;
"privacy.donottrackheader.enabled" = true;
};
};
services.bleachbit.cleaners = [
"thunderbird.cache"
"thunderbird.cookies"
"thunderbird.index"
"thunderbird.passwords"
"thunderbird.sessionjson"
"thunderbird.vacuum"
];
})
]);
}

View File

@ -0,0 +1,76 @@
{ config, lib, pkgs, ... }:
let
userCfg = config.users.foo-dogsquared;
cfg = userCfg.programs.git;
in
{
options.users.foo-dogsquared.programs.git.enable = lib.mkEnableOption "foo-dogsquared's Git setup";
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
tea # So you don't have to see some teas, I guess.
hut # So you don't have to see Sourcehut's brutalist design, I guess.
];
# My Git credentials.
programs.git = {
enable = true;
package = pkgs.gitFull;
lfs.enable = true;
signing.key = "ADE0C41DAB221FCC";
extraConfig = {
user = {
name = config.accounts.email.accounts.personal.realName;
email = config.accounts.email.accounts.personal.address;
};
alias = {
unstage = "reset HEAD --";
quick-rebase = "rebase --interactive --autostash --committer-date-is-author-date";
quick-clone = "clone --depth=1 --recurse-submodules --shallow-submodules";
};
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:" ];
};
status = {
showPatch = true;
showStash = true;
};
submodule.fetchJobs = 0;
};
};
# So you don't have to use GitHub, I guess.
programs.gh = {
enable = true;
extensions = with pkgs; [
gh-eco
gh-dash
gh-actions-cache
];
settings = {
git_protocol = "ssh";
prompt = "enabled";
aliases = {
pc = "pr checkout";
pv = "pr view";
};
};
};
};
}

View File

@ -0,0 +1,61 @@
{ config, lib, pkgs, ... }:
let
userCfg = config.users.foo-dogsquared;
cfg = userCfg.programs.keys;
in
{
options.users.foo-dogsquared.programs.keys = {
ssh.enable = lib.mkEnableOption "foo-dogsquared's SSH config";
gpg.enable = lib.mkEnableOption "foo-dogsquared's GPG config";
};
config = lib.mkMerge [
# 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.
(lib.mkIf cfg.ssh.enable {
programs.ssh = {
enable = true;
includes = [ "config.d/*" ];
extraConfig = ''
AddKeysToAgent confirm 15m
ForwardAgent no
VisualHostKey yes
'';
};
# Make all of the initial SSH identities configuration here. It should assume
# I have other SSH identities configuration that are not committed here for
# whatever reason.
home.file.".ssh/config.d" = {
source = ../../config/ssh;
recursive = true;
};
})
# 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
(lib.mkIf cfg.gpg.enable {
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;
};
};
})
];
}