From 3ae3af556f3a904774620306e2236e02deb55f6d Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sat, 15 Apr 2023 22:29:12 -0500 Subject: [PATCH] feat: enable dual use for subflakes until is fixed https://github.com/NixOS/nix/issues/6352 --- README.md | 19 +++++++++++++++++++ default.nix | 2 ++ flake.nix | 1 + 3 files changed, 22 insertions(+) create mode 100644 flake.nix diff --git a/README.md b/README.md index 8added0..178d546 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,22 @@ Afterwards, create a `default.nix` file containing the following: ``` If you would like a `shell.nix` file, create one containing the above, replacing `defaultNix` with `shellNix`. + + +## Call Parent Flake (second use) + +To use, add the following to your subflake's flake.nix: + +```nix +{ + inputs.flake-compat.url = "github:edolstra/flake-compat"; +} +``` + +Afterwards, you can use it to call a flake from anywhere, including a parent directory, as follows: + +```nix +{ + parent = flake-compat ../.; +} +``` diff --git a/default.nix b/default.nix index 3fef1dd..579a723 100644 --- a/default.nix +++ b/default.nix @@ -188,6 +188,8 @@ let in rec { + inherit result; # consumed by flake.nix + defaultNix = (builtins.removeAttrs result ["__functor"]) // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}) diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ad8ceaf --- /dev/null +++ b/flake.nix @@ -0,0 +1 @@ +{ outputs = _: { __functor = _: src: (import ./. {inherit src;}).result; }; }