From f6ee9d535f0b8fd760774c137612d423c30274fd Mon Sep 17 00:00:00 2001 From: zimbatm Date: Sat, 11 Apr 2020 16:45:25 +0200 Subject: [PATCH] adds forAllSupported --- default.nix | 26 ++++++++++++++++++++++++++ flake.nix | 7 +++++++ 2 files changed, 33 insertions(+) create mode 100644 default.nix create mode 100644 flake.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..2f4c5d4 --- /dev/null +++ b/default.nix @@ -0,0 +1,26 @@ +rec { + # copied from + genAttrs = names: f: + builtins.listToAttrs (map (n: { name = n; value = f n; }) names); + + # The list of systems supported by nixpkgs and hydra + supportedSystems = [ + "aarch64-linux" + "i686-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + + # Returns an attribute set with all the supported systems as keys and the + # output of the passed function with each system passed to it. + # + # This is useful in the flake outputs because the outputs return static sets + # that map to the different systems. + # + # Example: + # forAllSupported (x: null) + # > { aarch64-linux = null; i686-linux = null; x86_64-darwin = null; + # > x86_64-linux = null; } + # (system -> attrs) -> attrs + forAllSupported = genAttrs supportedSystems; +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b565074 --- /dev/null +++ b/flake.nix @@ -0,0 +1,7 @@ +{ + description = "Pure Nix flake utility functions"; + edition = 201909; + outputs = { self }: { + lib = import ./.; + }; +}