Created
September 15, 2020 02:00
-
-
Save ryantm/422df749e70871568d4c56b20421a764 to your computer and use it in GitHub Desktop.
Nix activation script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
pkgs = import <nixpkgs> {}; | |
lib = pkgs.lib; | |
addAttributeName = with lib; mapAttrs (a: v: v // { | |
text = '' | |
${v.text} | |
''; | |
}); | |
in | |
with lib; | |
(evalModules { | |
modules = [ | |
{ | |
options.aS = mkOption { | |
default = {}; | |
type = types.attrsOf types.unspecified; | |
apply = set: { | |
script = | |
'' | |
${ | |
let | |
set' = mapAttrs (n: v: if isString v then noDepEntry v else v) set; | |
withHeadlines = addAttributeName set'; | |
in textClosureMap id (withHeadlines) (attrNames withHeadlines) | |
} | |
''; | |
}; | |
}; | |
} | |
# when this is before instead of after, it works | |
# { | |
# aS.c = "c"; | |
# aS.a.deps = [ "c" ]; | |
# } | |
{ | |
aS.a = stringAfter ["b"] "a"; | |
aS.b = "b"; | |
} | |
{ | |
aS.c = "c"; | |
aS.a.deps = mkOverride 0 [ "c" ]; | |
} | |
]; | |
}).config.aS.script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment