Move xdg stuff into a separate module

This commit is contained in:
Alexander Bantyev 2021-06-11 14:52:11 +03:00
parent acac53cccd
commit 6ea593aeda
Signed by: balsoft
GPG Key ID: E081FF12ADCB4AD5
9 changed files with 167 additions and 141 deletions

View File

@ -1,5 +1,4 @@
{ pkgs, config, lib, ... }:
{
{ pkgs, config, lib, ... }: {
options.defaultApplications = lib.mkOption {
type = lib.types.attrs;
description = "Preferred applications";
@ -11,7 +10,8 @@
desktop = "alacritty";
};
editor = {
cmd = "${config.home-manager.users.balsoft.programs.emacs.finalPackage}/bin/emacsclient -c $@";
cmd =
"${config.home-manager.users.balsoft.programs.emacs.finalPackage}/bin/emacsclient -c $@";
desktop = "emacsclient";
};
browser = {
@ -53,10 +53,16 @@
VISUAL = config.defaultApplications.editor.cmd;
};
home-manager.users.balsoft.xdg.mimeApps = {
home-manager.users.balsoft = {
home.activation."mimeapps-remove" = {
before = [ "checkLinkTargets" ];
after = [ ];
data = "rm -f /home/balsoft/.config/mimeapps.list";
};
xdg.mimeApps = {
enable = true;
defaultApplications =
with config.defaultApplications;
defaultApplications = with config.defaultApplications;
builtins.mapAttrs (name: value:
if value ? desktop then [ "${value.desktop}.desktop" ] else value) {
"text/html" = browser;
@ -82,4 +88,5 @@
};
};
};
};
}

View File

@ -2,7 +2,7 @@
let
cfg = config.persist;
takeAll = what: builtins.concatMap (x: x.${what});
takeAll = what: concatMap (x: x.${what});
persists = with cfg; [ state derivative cache ];
@ -15,10 +15,14 @@ let
allEtcFiles = absoluteEtcFiles (takeAll "etcFiles" persists);
allDirectories = takeAll "directories" persists;
inherit (builtins) concatMap;
inherit (lib) mkIf;
in {
options = with lib;
with types;
let
options = let
inherit (lib) mkOption mkEnableOption;
inherit (lib.types) listOf path str;
common = {
directories = mkOption {
type = listOf path;
@ -94,7 +98,7 @@ in {
})
];
config = lib.mkIf cfg.enable {
config = mkIf cfg.enable {
environment.persistence.${cfg.persistRoot} = {
directories = allDirectories;
files = allEtcFiles;
@ -106,10 +110,9 @@ in {
fsType = "tmpfs";
};
boot.initrd.postMountCommands = assert
config.fileSystems ? ${cfg.persistRoot}
&& config.fileSystems.${cfg.persistRoot}.neededForBoot;
''
boot.initrd.postMountCommands = assert config.fileSystems
? ${cfg.persistRoot}
&& config.fileSystems.${cfg.persistRoot}.neededForBoot; ''
mkdir -p /mnt-root/nix
mount --bind /mnt-root${cfg.persistRoot}/nix /mnt-root/nix
chmod 755 /mnt-root

View File

@ -0,0 +1,14 @@
{ config, pkgs, lib, ... }: {
home-manager.users.balsoft = {
programs.command-not-found = {
enable = true;
dbPath = ../../misc/programs.sqlite;
};
};
environment.sessionVariables = {
NIX_AUTO_RUN = "1";
};
}

View File

@ -0,0 +1,8 @@
{ config, pkgs, lib, ... }: {
home-manager.users.balsoft = {
programs.direnv.enable = true;
programs.direnv.enableNixDirenvIntegration = true;
};
persist.state.directories =
[ "/home/balsoft/.local/share/direnv" ];
}

View File

@ -13,31 +13,28 @@
gnome-online-miners.enable = true;
};
environment.sessionVariables.XDG_CURRENT_DESKTOP = "X-Generic";
persist.state.directories = map (x: "/home/balsoft/${x}") [
"Pictures"
"Documents"
"Downloads"
"Music"
"projects"
"Videos"
];
services.gvfs.enable = true;
services.geoclue2.enable = true;
fileSystems = with config.persist;
lib.mkIf enable (builtins.listToAttrs (map (name: {
inherit name;
value.options = [ "x-gvfs-hide" ];
}) (state.directories ++ cache.directories ++ derivative.directories)));
home-manager.users.balsoft = {
xdg.userDirs.enable = true;
home.activation.gnome = ''
$DRY_RUN_CMD mkdir -p "$XDG_DATA_HOME/keyrings"
$DRY_RUN_CMD ln -sf ${config.secrets-envsubst.gnome-keyring} "$XDG_DATA_HOME/keyrings/Default_keyring.keyring"
echo "Default_keyring" > "$XDG_DATA_HOME/keyrings/default"
$DRY_RUN_CMD mkdir -p "$XDG_CONFIG_HOME/goa-1.0"
$DRY_RUN_CMD ln -sf ${./accounts.conf} "$XDG_CONFIG_HOME/goa-1.0/accounts.conf"
$DRY_RUN_CMD ln -sf ${
./accounts.conf
} "$XDG_CONFIG_HOME/goa-1.0/accounts.conf"
$DRY_RUN_CMD mkdir -p "$XDG_CONFIG_HOME/evolution/sources"
$DRY_RUN_CMD ln -sf ${./nextcloud.source} "$XDG_CONFIG_HOME/evolution/sources/nextcloud.source"
$DRY_RUN_CMD ln -sf ${
./nextcloud.source
} "$XDG_CONFIG_HOME/evolution/sources/nextcloud.source"
'';
dconf.settings = {
@ -71,13 +68,9 @@
thumbnail-limit = 10;
};
"org/gnome/desktop/interface" = {
cursor-theme = "default";
};
"org/gnome/desktop/interface" = { cursor-theme = "default"; };
"org/gnome/evince/default" = {
inverted-colors = true;
};
"org/gnome/evince/default" = { inverted-colors = true; };
"org/gnome/maps" = {
night-mode = true;

View File

@ -6,7 +6,6 @@ with pkgs.my-lib; {
services.udev.packages = [ pkgs.libmtp pkgs.media-player-info ];
environment.sessionVariables = {
DESKTOP_SESSION = "kde";
QT_XFT = "true";
QT_SELECT = "5";
KDE_SESSION_VERSION = "5";

View File

@ -1,49 +1,28 @@
{ pkgs, lib, config, inputs, ... }: {
systemd.coredump.enable = true;
systemd.services.systemd-timesyncd.wantedBy = [ "multi-user.target" ];
systemd.timers.systemd-timesyncd = {
timerConfig.OnCalendar = "hourly";
};
environment.sessionVariables =
config.home-manager.users.balsoft.home.sessionVariables // rec {
NIX_AUTO_RUN = "1";
LESS = "MR";
SYSTEMD_LESS = LESS;
DE = "generic";
};
home-manager.users.balsoft = {
xdg.enable = true;
home.activation."mimeapps-remove" = {
before = [ "linkGeneration" ];
after = [ ];
data = "rm -f /home/balsoft/.config/mimeapps.list";
};
news.display = "silent";
programs.command-not-found = {
enable = true;
dbPath = ../../misc/programs.sqlite;
};
systemd.user.startServices = true;
programs.direnv.enable = true;
programs.direnv.enableNixDirenvIntegration = true;
systemd.user.startServices = true;
home.stateVersion = "20.09";
};
persist.cache.directories = [ "/home/balsoft/.cache" "/var/cache" ];
persist.state.directories =
[ "/home/balsoft/.local/share/direnv" "/var/lib/nixos" "/var/lib/systemd" ];
services.avahi.enable = true;
persist.state.directories = [ "/var/lib/nixos" "/var/lib/systemd" ];
system.stateVersion = "18.03";
systemd.services.systemd-timesyncd.wantedBy = [ "multi-user.target" ];
systemd.timers.systemd-timesyncd = { timerConfig.OnCalendar = "hourly"; };
services.avahi.enable = true;
}

20
modules/workspace/xdg.nix Normal file
View File

@ -0,0 +1,20 @@
{ config, pkgs, lib, ... }: {
home-manager.users.balsoft = {
xdg.enable = true;
xdg.userDirs.enable = true;
};
environment.sessionVariables = {
XDG_CURRENT_DESKTOP = "X-Generic";
DE = "generic";
};
persist.state.directories = map (x: "/home/balsoft/${x}") [
"Pictures"
"Documents"
"Downloads"
"Music"
"projects"
"Videos"
];
}

View File

@ -6,6 +6,9 @@
secrets
secrets-envsubst
autoRun
xdg
devices
git
gpg