Rename misc to config and change:

- GTK2 config is now placed in XDG config dir
- XDG user dirs is overridden
This commit is contained in:
2022-08-19 12:53:48 +02:00
parent 0fc1d15c35
commit 594b3f986d
5 changed files with 39 additions and 19 deletions

18
home/config/gtk.nix Normal file
View File

@@ -0,0 +1,18 @@
{ pkgs, config, ... }:
{
gtk = pkgs.lib.mkIf (!config.machineVars.headless) {
enable = true;
font = {
name = "Droid Sans";
};
iconTheme = {
package = pkgs.papirus-icon-theme;
name = "Papirus";
};
theme = {
package = pkgs.vimix-gtk-themes;
name = "VimixDark";
};
gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
};
}

View File

@@ -0,0 +1,92 @@
{ pkgs, secrets, ... }:
let
inherit (pkgs) lib;
inherit (secrets.ssh.users.pvv) normalUser adminUser;
# http://www.pvv.ntnu.no/pvv/Maskiner
normalMachines = [
[ "hildring" "pvv-login" "pvv" ]
"demiurgen"
"eirin"
[ "jokum" "pvv-nix" ]
"isvegg"
[ "microbel" "pvv-users" "pvv-mail" ]
];
rootMachines = [
[ "knakelibrak" "pvv-databases" ]
[ "spikkjeposche" "pvv-web" "pvv-wiki" "pvv-webmail" ]
"sleipner"
"fenris"
"balduzius"
"joshua"
"skrotnisse"
"principal"
"tom"
"monty"
{
names = ["dvask"];
proxyJump = "monty";
}
[ "innovation" "pvv-minecraft" ]
];
# Either( String [String] AttrSet{String} ) -> AttrSet{String}
normalizeValueType = let
inherit (lib.strings) isString;
inherit (lib.lists) isList;
inherit (lib.attrsets) filterAttrs;
in
machine:
if (isString machine) then { names = [machine]; }
else if (isList machine) then { names = machine; }
else machine;
# [String] -> AttrSet
machineWithNames = let
inherit (lib.lists) head;
inherit (lib.strings) split;
in
names: { hostname = "${head names}.pvv.org"; };
# AttrSet -> AttrSet -> AttrSet
convertMachineWithDefaults = defaults: normalizedMachine: let
inherit (lib.attrsets) nameValuePair;
inherit (lib.strings) concatStringsSep;
inherit (normalizedMachine) names;
name = concatStringsSep " " names;
value =
(machineWithNames names)
// defaults
// removeAttrs normalizedMachine ["names"];
in
nameValuePair name value;
# AttrSet -> AttrSet
convertNormalMachine = convertMachineWithDefaults { user = normalUser; };
# AttrSet -> AttrSet
convertAdminMachine =
convertMachineWithDefaults { user = adminUser; proxyJump = "hildring"; };
# [ Either(String [String] AttrSet{String}) ] -> (AttrSet -> AttrSet) -> AttrSet
convertMachinesWith = convertMachineFunction: let
inherit (lib.attrsets) listToAttrs;
inherit (lib.trivial) pipe;
pipeline = [
(map normalizeValueType)
(map convertMachineFunction)
listToAttrs
];
in
machines: pipe machines pipeline;
in
{
programs.ssh.matchBlocks = lib.attrsets.concatAttrs [
(convertMachinesWith convertNormalMachine normalMachines)
(convertMachinesWith convertAdminMachine rootMachines)
];
}

View File

@@ -0,0 +1,18 @@
{ config, ... }:
{
imports = [ ./mimetypes.nix ];
xdg = {
enable = true;
userDirs = {
enable = true;
desktop = "${config.home.homeDirectory}/Desktop";
documents = "${config.home.homeDirectory}/Documents";
download = "${config.home.homeDirectory}/Downloads";
music = "${config.home.homeDirectory}/music";
pictures = "${config.home.homeDirectory}/Pictures";
publicShare = "${config.home.homeDirectory}/public";
templates = "${config.home.homeDirectory}/templates";
videos = "${config.home.homeDirectory}/Videos";
};
};
}

View File

@@ -0,0 +1,142 @@
{ lib, ... }:
let
# Applications
google-chrome = "google-chrome.desktop";
gimp = "gimp.desktop";
inkscape = "org.inkscape.Inkscape.desktop";
vscode = "code.desktop";
mpv = "mpv.desktop";
zathura = "org.pwmt.zathura.desktop";
sxiv = "sxiv.desktop";
font-viewer = "org.gnome.font-viewer.desktop";
# Formats
"3g2-audio" = "audio/3gpp";
"3g2-video" = "video/3gpp";
"3gp-audio" = "audio/3gpp";
"3gp-video" = "video/3gpp";
aac = "audio/aac";
avi = "video/x-msvideo";
bmp = "image/bmp";
cbr = "application/vnd.comicbook+rar";
cbrx = "application/x-cbr";
cbz = "application/vnd.comicbook+zip";
cbzx = "application/x-cbz";
djvu = "image/vnd.djvu";
epub = "application/epub+zip";
flv = "video/x-flv";
gif = "image/gif";
html = "text/html";
http = "x-scheme-handler/http";
https = "x-scheme-handler/https";
ico = "image/vnd.microsoft.icon";
icox = "image/x-icon";
ini = "application/x-wine-extension-ini";
jpg = "image/jpeg";
m4v = "video/x-m4v";
mkv = "video/x-matroska";
mov = "video/quicktime";
mp3 = "audio/mpeg";
mp4 = "video/mp4";
mpeg = "video/mpeg";
ogg = "audio/ogg";
ogv = "video/ogg";
opus = "audio/opus";
otf = "font/otf";
pdf = "application/pdf";
pic = "image/x-pict";
png = "image/png";
psd = "image/vnd.adobe.photoshop";
svg = "image/svg+xml";
tiff = "image/tiff";
ttf = "font/ttf";
txt = "text/plain";
url = "application/x-mswinurl";
wav = "audio/wav";
wavx = "audio/x-wav";
webm-audio = "audio/webm";
webm-video = "video/webm";
webp = "image/webp";
wmv = "video/x-ms-wmv";
woff = "font/woff";
woff2 = "font/woff2";
xbm = "image/x-xbitmap";
xcf = "image/x-xcf";
xhtml = "application/xhtml+xml";
xml = "text/xml";
xpm = "image/x-xpixmap";
# Generalizations
audio-player = mpv;
gui-text-editor = vscode;
image-viewer = sxiv;
pdf-viewer = zathura;
video-player = mpv;
web-browser = google-chrome;
in {
xdg.mimeApps = {
enable = true;
# associations.added = {};
# associations.removed = {};
defaultApplications = {
${"3g2-audio"} = audio-player;
${"3g2-video"} = video-player;
${"3gp-audio"} = audio-player;
${"3gp-video"} = video-player;
${aac} = audio-player;
${avi} = video-player;
${bmp} = image-viewer;
${cbrx} = zathura;
${cbr} = zathura;
${cbzx} = zathura;
${cbz} = zathura;
${djvu} = pdf-viewer;
${epub} = zathura;
${flv} = video-player;
${gif} = image-viewer;
${html} = web-browser;
${https} = web-browser;
${http} = web-browser;
${icox} = image-viewer;
${ico} = image-viewer;
${jpg} = image-viewer;
${m4v} = video-player;
${mkv} = video-player;
${mov} = video-player;
${mp3} = audio-player;
${mp4} = video-player;
${mpeg} = video-player;
${ogg} = audio-player;
${ogv} = video-player;
${opus} = audio-player;
${otf} = font-viewer;
${pdf} = pdf-viewer;
${pic} = image-viewer;
${png} = image-viewer;
${psd} = gimp;
${svg} = image-viewer;
${tiff} = image-viewer;
${ttf} = font-viewer;
${txt} = gui-text-editor;
${url} = web-browser;
${wav} = audio-player;
${webm-audio} = audio-player;
${webm-video} = video-player;
${webp} = image-viewer;
${wmv} = video-player;
${woff2} = font-viewer;
${woff} = font-viewer;
${xbm} = image-viewer;
${xcf} = gimp;
${xhtml} = web-browser;
${xml} = gui-text-editor;
${xpm} = image-viewer;
};
};
}