From 521e3ad7ab4fd35d5d04d407fc3c545cd11b934a Mon Sep 17 00:00:00 2001 From: WeetHet Date: Tue, 11 Mar 2025 14:00:37 +0200 Subject: [PATCH 1/3] Remove flake-compat This allows non-flake users to pass their own instances of rust-overlay/pkgs/crane and avoid duplication --- default.nix | 28 +++++++++++++++++----------- flake.nix | 1 - shell.nix | 35 ++++++++++++++++++++++++----------- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/default.nix b/default.nix index 1d976a357629dd..facf23995d1c8b 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,17 @@ -(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 +{ + system ? builtins.currentSystem, + lock ? builtins.fromJSON (builtins.readFile ./flake.lock), + rust-overlay ? import (builtins.fetchTarball { + url = "github:oxalica/rust-overlay/${lock.nodes.rust-overlay.locked.rev}"; + sha256 = lock.nodes.rust-overlay.locked.narHash; + }), + pkgs ? import { inherit system; overlays = [ rust-overlay ]; }, + crane ? import (builtins.fetchTarball { + url = "github:ipetkov/crane/${lock.nodes.crane.locked.rev}"; + sha256 = lock.nodes.crane.locked.narHash; + }) { inherit pkgs; } +}: +pkgs.callPackage ./nix/build.nix { + inherit crane; + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; +} \ No newline at end of file diff --git a/flake.nix b/flake.nix index 69060662601843..101e69e72db1d6 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,6 @@ inputs.nixpkgs.follows = "nixpkgs"; }; crane.url = "github:ipetkov/crane"; - flake-compat.url = "github:edolstra/flake-compat"; }; outputs = diff --git a/shell.nix b/shell.nix index d1783071f97941..ee6f9c1dfc05b9 100644 --- a/shell.nix +++ b/shell.nix @@ -1,11 +1,24 @@ -(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 = ./.; }).shellNix +{ + system ? builtins.currentSystem, + lock ? builtins.fromJSON (builtins.readFile ./flake.lock), + rust-overlay ? import ( + builtins.fetchTarball { + url = "github:oxalica/rust-overlay/${lock.nodes.rust-overlay.locked.rev}"; + sha256 = lock.nodes.rust-overlay.locked.narHash; + } + ), + pkgs ? import { + inherit system; + overlays = [ rust-overlay ]; + }, + crane ? import (builtins.fetchTarball { + url = "github:ipetkov/crane/${lock.nodes.crane.locked.rev}"; + sha256 = lock.nodes.crane.locked.narHash; + }) { inherit pkgs; }, +}: +let + zed-editor = import ./default.nix { inherit pkgs crane; }; +in +pkgs.callPackage ./nix/shell.nix { + inherit zed-editor; +} From 78109a2f55b5889870d9fe0365f0f2525000c842 Mon Sep 17 00:00:00 2001 From: WeetHet Date: Tue, 11 Mar 2025 14:05:19 +0200 Subject: [PATCH 2/3] nix flake lock --- flake.lock | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/flake.lock b/flake.lock index 34bd71dc6c1c59..4f2fad8d90505a 100644 --- a/flake.lock +++ b/flake.lock @@ -15,21 +15,6 @@ "type": "github" } }, - "flake-compat": { - "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1741379970, @@ -49,7 +34,6 @@ "root": { "inputs": { "crane": "crane", - "flake-compat": "flake-compat", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } From 8f4645ae9687a19a03886afaa86cb0fe5f94b5b7 Mon Sep 17 00:00:00 2001 From: WeetHet Date: Tue, 11 Mar 2025 15:14:55 +0200 Subject: [PATCH 3/3] Use nixpkgs from flake.lock --- default.nix | 25 +++++++++++++++++-------- shell.nix | 6 +++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/default.nix b/default.nix index facf23995d1c8b..65bf61d6796db9 100644 --- a/default.nix +++ b/default.nix @@ -1,17 +1,26 @@ -{ +{ system ? builtins.currentSystem, lock ? builtins.fromJSON (builtins.readFile ./flake.lock), - rust-overlay ? import (builtins.fetchTarball { - url = "github:oxalica/rust-overlay/${lock.nodes.rust-overlay.locked.rev}"; - sha256 = lock.nodes.rust-overlay.locked.narHash; - }), - pkgs ? import { inherit system; overlays = [ rust-overlay ]; }, + rust-overlay ? import ( + builtins.fetchTarball { + url = "github:oxalica/rust-overlay/${lock.nodes.rust-overlay.locked.rev}"; + sha256 = lock.nodes.rust-overlay.locked.narHash; + } + ), + nixpkgs ? builtins.fetchTarball { + url = "github:NixOS/nixpkgs/${lock.nodes.nixpkgs.locked.rev}"; + sha256 = lock.nodes.nixpkgs.locked.narHash; + }, + pkgs ? import nixpkgs { + inherit system; + overlays = [ rust-overlay ]; + }, crane ? import (builtins.fetchTarball { url = "github:ipetkov/crane/${lock.nodes.crane.locked.rev}"; sha256 = lock.nodes.crane.locked.narHash; - }) { inherit pkgs; } + }) { inherit pkgs; }, }: pkgs.callPackage ./nix/build.nix { inherit crane; rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; -} \ No newline at end of file +} diff --git a/shell.nix b/shell.nix index ee6f9c1dfc05b9..5fe2e1fff2e3ef 100644 --- a/shell.nix +++ b/shell.nix @@ -7,7 +7,11 @@ sha256 = lock.nodes.rust-overlay.locked.narHash; } ), - pkgs ? import { + nixpkgs ? builtins.fetchTarball { + url = "github:NixOS/nixpkgs/${lock.nodes.nixpkgs.locked.rev}"; + sha256 = lock.nodes.nixpkgs.locked.narHash; + }, + pkgs ? import nixpkgs { inherit system; overlays = [ rust-overlay ]; },