Skip to content

Instantly share code, notes, and snippets.

@ryantm
Created September 15, 2020 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryantm/422df749e70871568d4c56b20421a764 to your computer and use it in GitHub Desktop.
Save ryantm/422df749e70871568d4c56b20421a764 to your computer and use it in GitHub Desktop.
Nix activation script
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