Add dag library to config.lib
Also replace all imports of `dag.nix` by the entry in `config.lib`.
This commit is contained in:
parent
7dd09cecda
commit
f0d207f380
|
@ -1,12 +1,13 @@
|
||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ./lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.home.file;
|
cfg = config.home.file;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
homeDirectory = config.home.homeDirectory;
|
homeDirectory = config.home.homeDirectory;
|
||||||
|
|
||||||
fileType = (import lib/file-type.nix {
|
fileType = (import lib/file-type.nix {
|
||||||
|
@ -51,7 +52,7 @@ in
|
||||||
|
|
||||||
# This verifies that the links we are about to create will not
|
# This verifies that the links we are about to create will not
|
||||||
# overwrite an existing file.
|
# overwrite an existing file.
|
||||||
home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] (
|
home.activation.checkLinkTargets = dag.entryBefore ["writeBoundary"] (
|
||||||
let
|
let
|
||||||
check = pkgs.writeText "check" ''
|
check = pkgs.writeText "check" ''
|
||||||
. ${./lib-bash/color-echo.sh}
|
. ${./lib-bash/color-echo.sh}
|
||||||
|
@ -107,7 +108,7 @@ in
|
||||||
# and a failure during the intermediate state FA ∩ FB will not
|
# and a failure during the intermediate state FA ∩ FB will not
|
||||||
# result in lost links because this set of links are in both the
|
# result in lost links because this set of links are in both the
|
||||||
# source and target generation.
|
# source and target generation.
|
||||||
home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] (
|
home.activation.linkGeneration = dag.entryAfter ["writeBoundary"] (
|
||||||
let
|
let
|
||||||
link = pkgs.writeText "link" ''
|
link = pkgs.writeText "link" ''
|
||||||
newGenFiles="$1"
|
newGenFiles="$1"
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ./lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.home;
|
cfg = config.home;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
languageSubModule = types.submodule {
|
languageSubModule = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
base = mkOption {
|
base = mkOption {
|
||||||
|
@ -241,9 +242,9 @@ in
|
||||||
|
|
||||||
# A dummy entry acting as a boundary between the activation
|
# A dummy entry acting as a boundary between the activation
|
||||||
# script's "check" and the "write" phases.
|
# script's "check" and the "write" phases.
|
||||||
home.activation.writeBoundary = dagEntryAnywhere "";
|
home.activation.writeBoundary = dag.entryAnywhere "";
|
||||||
|
|
||||||
home.activation.installPackages = dagEntryAfter ["writeBoundary"] ''
|
home.activation.installPackages = dag.entryAfter ["writeBoundary"] ''
|
||||||
$DRY_RUN_CMD nix-env -i ${cfg.path}
|
$DRY_RUN_CMD nix-env -i ${cfg.path}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -253,7 +254,7 @@ in
|
||||||
noteEcho Activating ${res.name}
|
noteEcho Activating ${res.name}
|
||||||
${res.data}
|
${res.data}
|
||||||
'';
|
'';
|
||||||
sortedCommands = dagTopoSort cfg.activation;
|
sortedCommands = dag.topoSort cfg.activation;
|
||||||
activationCmds =
|
activationCmds =
|
||||||
if sortedCommands ? result then
|
if sortedCommands ? result then
|
||||||
concatStringsSep "\n" (map mkCmd sortedCommands.result)
|
concatStringsSep "\n" (map mkCmd sortedCommands.result)
|
||||||
|
|
18
modules/lib/default.nix
Normal file
18
modules/lib/default.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{ lib }:
|
||||||
|
|
||||||
|
{
|
||||||
|
dag =
|
||||||
|
let
|
||||||
|
d = import ./dag.nix { inherit lib; };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
empty = d.emptyDag;
|
||||||
|
isDag = d.isDag;
|
||||||
|
topoSort = d.dagTopoSort;
|
||||||
|
map = d.dagMap;
|
||||||
|
entryAnywhere = d.dagEntryAnywhere;
|
||||||
|
entryBetween = d.dagEntryBetween;
|
||||||
|
entryAfter = d.dagEntryAfter;
|
||||||
|
entryBefore = d.dagEntryBefore;
|
||||||
|
};
|
||||||
|
}
|
|
@ -75,6 +75,7 @@ let
|
||||||
config._module.args.baseModules = modules;
|
config._module.args.baseModules = modules;
|
||||||
config._module.args.pkgs = lib.mkDefault pkgs;
|
config._module.args.pkgs = lib.mkDefault pkgs;
|
||||||
config._module.check = check;
|
config._module.check = check;
|
||||||
|
config.lib = import ./lib { inherit lib; };
|
||||||
config.nixpkgs.system = mkDefault pkgs.system;
|
config.nixpkgs.system = mkDefault pkgs.system;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ../lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.programs.gnome-terminal;
|
cfg = config.programs.gnome-terminal;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
profileColorsSubModule = types.submodule (
|
profileColorsSubModule = types.submodule (
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
options = {
|
options = {
|
||||||
|
@ -181,7 +182,7 @@ in
|
||||||
home.packages = [ pkgs.gnome3.gnome_terminal ];
|
home.packages = [ pkgs.gnome3.gnome_terminal ];
|
||||||
|
|
||||||
# The dconf service needs to be installed and prepared.
|
# The dconf service needs to be installed and prepared.
|
||||||
home.activation.gnomeTerminal = dagEntryAfter ["installPackages"] (
|
home.activation.gnomeTerminal = dag.entryAfter ["installPackages"] (
|
||||||
let
|
let
|
||||||
iniText = toDconfIni (buildIniSet cfg);
|
iniText = toDconfIni (buildIniSet cfg);
|
||||||
iniFile = pkgs.writeText "gnome-terminal.ini" iniText;
|
iniFile = pkgs.writeText "gnome-terminal.ini" iniText;
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ../lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.programs.home-manager;
|
cfg = config.programs.home-manager;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -42,7 +43,7 @@ in
|
||||||
# Uninstall manually installed home-manager, if such exists.
|
# Uninstall manually installed home-manager, if such exists.
|
||||||
# Without this a file collision error will be printed.
|
# Without this a file collision error will be printed.
|
||||||
home.activation.uninstallHomeManager =
|
home.activation.uninstallHomeManager =
|
||||||
dagEntryBetween [ "installPackages" ] [ "writeBoundary" ] ''
|
dag.entryBetween [ "installPackages" ] [ "writeBoundary" ] ''
|
||||||
if nix-env -q | grep -q "^home-manager$" ; then
|
if nix-env -q | grep -q "^home-manager$" ; then
|
||||||
$DRY_RUN_CMD nix-env -e home-manager
|
$DRY_RUN_CMD nix-env -e home-manager
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ../lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.programs.info;
|
cfg = config.programs.info;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
# Indexes info files found in this location
|
# Indexes info files found in this location
|
||||||
homeInfoPath = "$HOME/.nix-profile/share/info";
|
homeInfoPath = "$HOME/.nix-profile/share/info";
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ in
|
||||||
home.sessionVariables.INFOPATH =
|
home.sessionVariables.INFOPATH =
|
||||||
"${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}";
|
"${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}";
|
||||||
|
|
||||||
home.activation.createHomeInfoDir = dagEntryAfter ["installPackages"] ''
|
home.activation.createHomeInfoDir = dag.entryAfter ["installPackages"] ''
|
||||||
oPATH=$PATH
|
oPATH=$PATH
|
||||||
export PATH="${lib.makeBinPath [ pkgs.gzip ]}''${PATH:+:}$PATH"
|
export PATH="${lib.makeBinPath [ pkgs.gzip ]}''${PATH:+:}$PATH"
|
||||||
$DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}"
|
$DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}"
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ../lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.services.polybar;
|
cfg = config.services.polybar;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
toPolybarIni = generators.toINI {
|
toPolybarIni = generators.toINI {
|
||||||
mkKeyValue = key: value:
|
mkKeyValue = key: value:
|
||||||
let
|
let
|
||||||
|
@ -131,7 +132,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
home.activation.checkPolybar = dagEntryBefore [ "linkGeneration" ] ''
|
home.activation.checkPolybar = dag.entryBefore [ "linkGeneration" ] ''
|
||||||
if ! cmp --quiet \
|
if ! cmp --quiet \
|
||||||
"${configFile}" \
|
"${configFile}" \
|
||||||
"$HOME/.config/polybar/config"; then
|
"$HOME/.config/polybar/config"; then
|
||||||
|
@ -139,7 +140,7 @@ in
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.activation.applyPolybar = dagEntryAfter [ "reloadSystemD" ] ''
|
home.activation.applyPolybar = dag.entryAfter [ "reloadSystemD" ] ''
|
||||||
if [[ -v polybarChanged && -v DISPLAY ]]; then
|
if [[ -v polybarChanged && -v DISPLAY ]]; then
|
||||||
echo "Restarting polybar"
|
echo "Restarting polybar"
|
||||||
${config.systemd.user.systemctlPath} --user restart polybar.service
|
${config.systemd.user.systemctlPath} --user restart polybar.service
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ../../lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.xsession.windowManager.i3;
|
cfg = config.xsession.windowManager.i3;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
startupModule = types.submodule {
|
startupModule = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
command = mkOption {
|
command = mkOption {
|
||||||
|
@ -621,7 +622,7 @@ in
|
||||||
xsession.windowManager.command = "${cfg.package}/bin/i3";
|
xsession.windowManager.command = "${cfg.package}/bin/i3";
|
||||||
xdg.configFile."i3/config".source = configFile;
|
xdg.configFile."i3/config".source = configFile;
|
||||||
|
|
||||||
home.activation.checkI3 = dagEntryBefore [ "linkGeneration" ] ''
|
home.activation.checkI3 = dag.entryBefore [ "linkGeneration" ] ''
|
||||||
if ! cmp --quiet \
|
if ! cmp --quiet \
|
||||||
"${configFile}" \
|
"${configFile}" \
|
||||||
"${config.xdg.configHome}/i3/config"; then
|
"${config.xdg.configHome}/i3/config"; then
|
||||||
|
@ -629,7 +630,7 @@ in
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.activation.reloadI3 = dagEntryAfter [ "linkGeneration" ] ''
|
home.activation.reloadI3 = dag.entryAfter [ "linkGeneration" ] ''
|
||||||
if [[ -v i3Changed && -v DISPLAY ]]; then
|
if [[ -v i3Changed && -v DISPLAY ]]; then
|
||||||
echo "Reloading i3"
|
echo "Reloading i3"
|
||||||
${cfg.package}/bin/i3-msg reload 1>/dev/null
|
${cfg.package}/bin/i3-msg reload 1>/dev/null
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ../../lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.xsession.windowManager.xmonad;
|
cfg = config.xsession.windowManager.xmonad;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
xmonad = pkgs.xmonad-with-packages.override {
|
xmonad = pkgs.xmonad-with-packages.override {
|
||||||
ghcWithPackages = cfg.haskellPackages.ghcWithPackages;
|
ghcWithPackages = cfg.haskellPackages.ghcWithPackages;
|
||||||
packages = self:
|
packages = self:
|
||||||
|
@ -90,13 +91,13 @@ in
|
||||||
(mkIf (cfg.config != null) {
|
(mkIf (cfg.config != null) {
|
||||||
home.file.".xmonad/xmonad.hs".source = cfg.config;
|
home.file.".xmonad/xmonad.hs".source = cfg.config;
|
||||||
|
|
||||||
home.activation.checkXmonad = dagEntryBefore [ "linkGeneration" ] ''
|
home.activation.checkXmonad = dag.entryBefore [ "linkGeneration" ] ''
|
||||||
if ! cmp --quiet "${cfg.config}" "$HOME/.xmonad/xmonad.hs"; then
|
if ! cmp --quiet "${cfg.config}" "$HOME/.xmonad/xmonad.hs"; then
|
||||||
xmonadChanged=1
|
xmonadChanged=1
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.activation.applyXmonad = dagEntryAfter [ "linkGeneration" ] ''
|
home.activation.applyXmonad = dag.entryAfter [ "linkGeneration" ] ''
|
||||||
if [[ -v xmonadChanged ]]; then
|
if [[ -v xmonadChanged ]]; then
|
||||||
echo "Recompiling xmonad"
|
echo "Recompiling xmonad"
|
||||||
${config.xsession.windowManager.command} --recompile
|
${config.xsession.windowManager.command} --recompile
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ./lib/dag.nix { inherit lib; };
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.systemd.user;
|
cfg = config.systemd.user;
|
||||||
|
|
||||||
|
dag = config.lib.dag;
|
||||||
|
|
||||||
enabled = cfg.services != {}
|
enabled = cfg.services != {}
|
||||||
|| cfg.sockets != {}
|
|| cfg.sockets != {}
|
||||||
|| cfg.targets != {}
|
|| cfg.targets != {}
|
||||||
|
@ -144,7 +145,7 @@ in
|
||||||
(buildServices "timer" cfg.timers)
|
(buildServices "timer" cfg.timers)
|
||||||
);
|
);
|
||||||
|
|
||||||
home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] (
|
home.activation.reloadSystemD = dag.entryAfter ["linkGeneration"] (
|
||||||
if cfg.startServices then
|
if cfg.startServices then
|
||||||
''
|
''
|
||||||
PATH=${dirOf cfg.systemctlPath} \
|
PATH=${dirOf cfg.systemctlPath} \
|
||||||
|
|
Loading…
Reference in a new issue