From dcbe894bea41567e4d751367666b249cfd489704 Mon Sep 17 00:00:00 2001 From: traxys Date: Thu, 15 Feb 2024 22:51:26 +0100 Subject: [PATCH] Fix issue with non flake import (#1102) * Update flake compat * tests: Add a test without flakes --- default.nix | 21 +++++++++++++-------- flake-modules/tests.nix | 6 ++++++ flake.lock | 17 ++++++++++++++++- flake.nix | 2 ++ tests/no-flake.nix | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 tests/no-flake.nix diff --git a/default.nix b/default.nix index 3321d7df..2b625713 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,14 @@ -(import ( - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz"; - sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h"; - } - ) { - src = ./.; - }) +( + import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + {src = ./.;} +) .defaultNix diff --git a/flake-modules/tests.nix b/flake-modules/tests.nix index 8458e62b..c3ad6995 100644 --- a/flake-modules/tests.nix +++ b/flake-modules/tests.nix @@ -30,6 +30,12 @@ inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule; }; + no-flake = import ../tests/no-flake.nix { + inherit system; + inherit (self.lib.${system}.check) mkTestDerivationFromNvim; + nixvim = "${self}"; + }; + lib-tests = import ../tests/lib-tests.nix { inherit pkgs helpers; inherit (pkgs) lib; diff --git a/flake.lock b/flake.lock index fab83771..2c9d65e2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,6 +1,20 @@ { "nodes": { "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1696426674, @@ -133,7 +147,7 @@ }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "flake-utils": "flake-utils", "gitignore": "gitignore", "nixpkgs": [ @@ -159,6 +173,7 @@ }, "root": { "inputs": { + "flake-compat": "flake-compat", "flake-parts": "flake-parts", "home-manager": "home-manager", "nix-darwin": "nix-darwin", diff --git a/flake.nix b/flake.nix index 94d00112..95c51c26 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,8 @@ inputs.nixpkgs-lib.follows = "nixpkgs"; }; + flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; + pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/tests/no-flake.nix b/tests/no-flake.nix new file mode 100644 index 00000000..a0510b7b --- /dev/null +++ b/tests/no-flake.nix @@ -0,0 +1,32 @@ +{ + system, + nixvim, + mkTestDerivationFromNvim, +}: let + # This simulates the `default.nix`, but in a pure way so because we are currently in a flake. + nixvim' = + ( + import + ( + let + lock = builtins.fromJSON (builtins.readFile ../flake.lock); + in + fetchTarball { + url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + {src = nixvim;} + ) + .defaultNix; + + config = { + colorschemes.gruvbox.enable = true; + }; + + nvim = nixvim'.legacyPackages."${system}".makeNixvim config; +in + mkTestDerivationFromNvim { + name = "no-flakes"; + inherit nvim; + }