Add lib.generators.toPreserves
This commit is contained in:
parent
040294dbf2
commit
079be99183
|
@ -0,0 +1,2 @@
|
||||||
|
result
|
||||||
|
result-*
|
|
@ -4,11 +4,15 @@
|
||||||
inputs.rust.url = "github:oxalica/rust-overlay";
|
inputs.rust.url = "github:oxalica/rust-overlay";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, rust }:
|
outputs = { self, nixpkgs, rust }:
|
||||||
let forEachSystem = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
|
let
|
||||||
|
forEachSystem = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
|
||||||
|
libOverlay = import ./lib.nix;
|
||||||
in {
|
in {
|
||||||
|
lib = nixpkgs.lib.extend libOverlay;
|
||||||
|
|
||||||
overlay = final: prev:
|
overlay = final: prev:
|
||||||
with final; {
|
with final; {
|
||||||
|
lib = lib.extend libOverlay;
|
||||||
syndicate-rs = callPackage ./syndicate-rs {
|
syndicate-rs = callPackage ./syndicate-rs {
|
||||||
rust = rust-bin.nightly.latest.default;
|
rust = rust-bin.nightly.latest.default;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
final: prev:
|
||||||
|
let lib = final;
|
||||||
|
in with lib; {
|
||||||
|
|
||||||
|
generators = with final.generators;
|
||||||
|
prev.generators // {
|
||||||
|
toPreserves = { }@args:
|
||||||
|
v:
|
||||||
|
let concatItems = lib.strings.concatStringsSep " ";
|
||||||
|
in if isAttrs v then
|
||||||
|
"{ ${
|
||||||
|
concatItems (lib.attrsets.mapAttrsToList
|
||||||
|
(key: val: "${key}: ${toPreserves args val}") v)
|
||||||
|
} }"
|
||||||
|
else if isList v then
|
||||||
|
"[ ${concatItems (map (toPreserves args) v)} ]"
|
||||||
|
else if isBool v then
|
||||||
|
(if v then "#t" else "#f")
|
||||||
|
else if isFunction v then
|
||||||
|
abort "generators.toPreserves: cannot convert a function to Preserves"
|
||||||
|
else if isNull v then
|
||||||
|
"null"
|
||||||
|
else
|
||||||
|
builtins.toJSON v;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue