-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
35 lines (35 loc) · 1.27 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
description = "Networks client setups";
outputs =
{ self, nixpkgs }:
let
networks = import ./networks;
sh = {
export = env:
# exports flat list of attrs as env variables
builtins.foldl' (a: b: "${a}${b}") "" (nixpkgs.lib.mapAttrsToList
(name: value: "export ${name}=${builtins.toString value};")
env);
};
lib = {
inherit sh networks;
};
gen = networks:
''
echo '${builtins.toJSON networks}' | jq . --sort-keys > networks.autogenerated.json
git add .
git commit --message "Update networks client setup"
git push
'';
in
rec {
packages.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.writeShellScriptBin "default" (gen networks);
packages.x86_64-darwin.default = nixpkgs.legacyPackages.x86_64-darwin.writeShellScriptBin "default" (gen networks);
packages.aarch64-linux.default = nixpkgs.legacyPackages.aarch64-linux.writeShellScriptBin "default" (gen networks);
packages.aarch64-darwin.default = nixpkgs.legacyPackages.aarch64-darwin.writeShellScriptBin "default" (gen networks);
overlays.default = final: prev: {
networksLib = lib;
};
inherit lib;
};
}