mirror of
https://github.com/nix-community/home-manager
synced 2024-09-05 02:46:30 +02:00
This makes definitions like home.activation.foo = mkIf false "bar" work, where previously they would complain about `home.activation.foobar.data` being used but not defined. The crucial part is that we don't call `convertAllToDags` in `dagOf.merge`, because we need to process `mkIf`/`mkMerge` properties first. So we let `attrEquivalent.merge` do its job normally, but give it a type `dagEntryOf` that does the conversion. Ideally this shouldn't require so much boilerplate; I'd like to implement something like types.changeInto dagContentType elemType dagEntryAnywhere in Nixpkgs.
36 lines
850 B
Nix
36 lines
850 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) concatStringsSep hm mkIf mkMerge mkOption types;
|
|
|
|
dag = lib.hm.dag;
|
|
|
|
result = let
|
|
sorted = dag.topoSort config.tested.dag;
|
|
data = map (e: "${e.name}:${e.data}") sorted.result;
|
|
in concatStringsSep "\n" data + "\n";
|
|
|
|
in {
|
|
options.tested.dag = mkOption { type = hm.types.dagOf types.str; };
|
|
|
|
config = {
|
|
tested.dag = mkMerge [
|
|
{ never = mkIf false "never"; }
|
|
{ after = mkMerge [ "after" (mkIf false "neither") ]; }
|
|
{ before = dag.entryBefore [ "after" ] (mkIf true "before"); }
|
|
{
|
|
between =
|
|
mkIf true (dag.entryBetween [ "after" ] [ "before" ] "between");
|
|
}
|
|
];
|
|
|
|
home.file."result.txt".text = result;
|
|
|
|
nmt.script = ''
|
|
assertFileContent \
|
|
home-files/result.txt \
|
|
${./dag-merge-result.txt}
|
|
'';
|
|
};
|
|
}
|