From b640d1826b70172605c3c8e18a4a7c7fecaf28b0 Mon Sep 17 00:00:00 2001 From: Piper McCorkle Date: Thu, 30 Dec 2021 17:50:53 -0500 Subject: [PATCH 1/6] Add a README.md containing copy & paste helpers --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6ecc7de --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# flake-compat + +## Usage + +To use, add the following to your `flake.nix`: + +```nix +inputs.flake-compat = { + url = github:edolstra/flake-compat; + flake = false; +}; +``` + +Afterwards, create a `default.nix` file containing the following: + +```nix +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).defaultNix +``` + +If you would like a `shell.nix` file, create one containing the above, replacing `defaultNix` with `shellNix`. -- 2.44.1 From 3b935d922dddd81b0bf77f3d55b4561a0dc14ab8 Mon Sep 17 00:00:00 2001 From: Charles Baynham Date: Sat, 19 Mar 2022 23:30:58 +0000 Subject: [PATCH 2/6] Pass along submodules flag to fetchGit --- default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/default.nix b/default.nix index 1ffef45..bca7014 100644 --- a/default.nix +++ b/default.nix @@ -33,6 +33,7 @@ let ({ url = info.url; } // (if info ? rev then { inherit (info) rev; } else {}) // (if info ? ref then { inherit (info) ref; } else {}) + // (if info ? submodules then { inherit (info) submodules; } else {}) ); lastModified = info.lastModified; lastModifiedDate = formatSecondsSinceEpoch info.lastModified; -- 2.44.1 From aee797a673956f9ac563ce8495db0ff7204cbaa3 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 25 Mar 2022 04:45:45 +0200 Subject: [PATCH 3/6] add support for new style of defaults --- default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 1ffef45..eb9d1c3 100644 --- a/default.nix +++ b/default.nix @@ -189,9 +189,11 @@ in rec { defaultNix = result - // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}); + // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}) + // (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {}); shellNix = defaultNix - // (if result ? devShell.${system} then { default = result.devShell.${system}; } else {}); + // (if result ? devShell.${system} then { default = result.devShell.${system}; } else {}) + // (if result ? devShells.${system}.default then { default = result.devShells.${system}.default; } else {}); } -- 2.44.1 From 246e8851305963be549af62095d4b7211a742db0 Mon Sep 17 00:00:00 2001 From: Sandro Date: Tue, 19 Apr 2022 13:59:50 +0200 Subject: [PATCH 4/6] Quote url literal --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ecc7de..8added0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ To use, add the following to your `flake.nix`: ```nix inputs.flake-compat = { - url = github:edolstra/flake-compat; + url = "github:edolstra/flake-compat"; flake = false; }; ``` -- 2.44.1 From 6f56392cc453c14b05060a1e08add387b767a847 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Mon, 14 Nov 2022 20:27:18 -0500 Subject: [PATCH 5/6] fix: top level functors break legacy nix commands see: https://github.com/divnix/std/issues/186 --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index f8af091..3fef1dd 100644 --- a/default.nix +++ b/default.nix @@ -189,7 +189,7 @@ let in rec { defaultNix = - result + (builtins.removeAttrs result ["__functor"]) // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}) // (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {}); -- 2.44.1 From 43bfa87aa2f32792b32b84e00ec9af91a4c79e85 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 16 Jan 2023 19:59:47 +0100 Subject: [PATCH 6/6] Apply nix#7207 `_type = "flake";` https://github.com/NixOS/nix/pull/7207 adds this attribute in order to help identify flake outputs for the purpose of type checking. --- default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 1ffef45..c6557f9 100644 --- a/default.nix +++ b/default.nix @@ -166,7 +166,8 @@ let outputs = flake.outputs (inputs // { self = result; }); - result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; }; + result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; _type = "flake"; }; + in if node.flake or true then assert builtins.isFunction flake.outputs; -- 2.44.1