parent
dd538c2969
commit
d06bcf4c97
|
@ -1443,6 +1443,22 @@ in
|
||||||
'services.picom' as soon as possible.
|
'services.picom' as soon as possible.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2020-04-08T09:33:05+00:00";
|
||||||
|
condition = hostPlatform.isLinux;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'targets.genericLinux'.
|
||||||
|
|
||||||
|
When enabled, this module will configure various settings
|
||||||
|
and environment variables to make Home Manager and programs
|
||||||
|
installed through Nix work better on GNU/Linux distributions
|
||||||
|
other than NixOS.
|
||||||
|
|
||||||
|
It should not be enabled if your Home Manager configuration
|
||||||
|
is deployed on a NixOS host.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,7 @@ let
|
||||||
(loadModule ./services/xscreensaver.nix { })
|
(loadModule ./services/xscreensaver.nix { })
|
||||||
(loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; })
|
(loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; })
|
||||||
(loadModule ./systemd.nix { })
|
(loadModule ./systemd.nix { })
|
||||||
|
(loadModule ./targets/generic-linux.nix { condition = hostPlatform.isLinux; })
|
||||||
(loadModule ./xcursor.nix { })
|
(loadModule ./xcursor.nix { })
|
||||||
(loadModule ./xresources.nix { })
|
(loadModule ./xresources.nix { })
|
||||||
(loadModule ./xsession.nix { })
|
(loadModule ./xsession.nix { })
|
||||||
|
|
39
modules/targets/generic-linux.nix
Normal file
39
modules/targets/generic-linux.nix
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
profileDirectory = config.home.profileDirectory;
|
||||||
|
|
||||||
|
in {
|
||||||
|
options.targets.genericLinux.enable = mkEnableOption "" // {
|
||||||
|
description = ''
|
||||||
|
Whether to enable settings that make Home Manager work better on
|
||||||
|
GNU/Linux distributions other than NixOS.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf config.targets.genericLinux.enable {
|
||||||
|
home.sessionVariables = let
|
||||||
|
profiles = [ "/nix/var/nix/profiles/default" profileDirectory ];
|
||||||
|
dataDirs =
|
||||||
|
concatStringsSep ":" (map (profile: "${profile}/share") profiles);
|
||||||
|
in { XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"; };
|
||||||
|
|
||||||
|
home.sessionVariablesExtra = ''
|
||||||
|
. "${pkgs.nix}/etc/profile.d/nix.sh"
|
||||||
|
'';
|
||||||
|
|
||||||
|
# We need to source both nix.sh and hm-session-vars.sh as noted in
|
||||||
|
# https://github.com/rycee/home-manager/pull/797#issuecomment-544783247
|
||||||
|
programs.bash.initExtra = ''
|
||||||
|
. "${pkgs.nix}/etc/profile.d/nix.sh"
|
||||||
|
. "${profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
||||||
|
'';
|
||||||
|
|
||||||
|
systemd.user.sessionVariables = {
|
||||||
|
NIX_PATH = "$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -57,5 +57,6 @@ import nmt {
|
||||||
./modules/services/sxhkd
|
./modules/services/sxhkd
|
||||||
./modules/services/window-managers/i3
|
./modules/services/window-managers/i3
|
||||||
./modules/systemd
|
./modules/systemd
|
||||||
|
./modules/targets
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
1
tests/modules/targets/default.nix
Normal file
1
tests/modules/targets/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ targets-generic-linux = ./generic-linux.nix; }
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Only source this once.
|
||||||
|
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||||
|
export __HM_SESS_VARS_SOURCED=1
|
||||||
|
|
||||||
|
export XDG_DATA_DIRS="/nix/var/nix/profiles/default/share:/homeless-shelter/.nix-profile/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"
|
||||||
|
. "@nix@/etc/profile.d/nix.sh"
|
23
tests/modules/targets/generic-linux.nix
Normal file
23
tests/modules/targets/generic-linux.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
home.homeDirectory = "/homeless-shelter";
|
||||||
|
|
||||||
|
targets.genericLinux.enable = true;
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
|
||||||
|
assertFileContent \
|
||||||
|
home-path/etc/profile.d/hm-session-vars.sh \
|
||||||
|
${
|
||||||
|
pkgs.substituteAll {
|
||||||
|
src = ./generic-linux-session-vars-expected.txt;
|
||||||
|
nix = pkgs.nix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue