From 9e83f87c024e052f6aedfd81a9f5b41931d46010 Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Wed, 18 Oct 2023 17:27:17 -0700 Subject: [PATCH 1/4] Drop public flake-compat dependency --- flake.lock | 17 ----------------- flake.nix | 5 ----- shell.nix | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/flake.lock b/flake.lock index 62ea97f8..147f982f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "nodes": { - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -52,7 +36,6 @@ }, "root": { "inputs": { - "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" diff --git a/flake.nix b/flake.nix index 91c4c4b1..89d09bb4 100644 --- a/flake.nix +++ b/flake.nix @@ -4,11 +4,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - flake-utils.url = "github:numtide/flake-utils"; rust-overlay = { diff --git a/shell.nix b/shell.nix index daec5c99..ea1a8f73 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,5 @@ let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); + lock = builtins.fromJSON (builtins.readFile ./test/flake.lock); locked = lock.nodes.flake-compat.locked; compat = fetchTarball { url = "https://github.com/${locked.owner}/${locked.repo}/archive/${locked.rev}.tar.gz"; From 7806e3301ff744f1bfad5f685f1f6805602afbb6 Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Wed, 18 Oct 2023 17:33:56 -0700 Subject: [PATCH 2/4] Drop public rust-overlay dependency --- flake.lock | 26 +------------------------- flake.nix | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/flake.lock b/flake.lock index 147f982f..fdf2e45b 100644 --- a/flake.lock +++ b/flake.lock @@ -37,31 +37,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1697595136, - "narHash": "sha256-9honwiIeMbBKi7FzfEy89f1ShUiXz/gVxZSS048pKyc=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "a2ccfb2134622b28668a274e403ba6f075ae1223", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index 89d09bb4..b72a83f6 100644 --- a/flake.nix +++ b/flake.nix @@ -5,14 +5,6 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; - - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs = { - flake-utils.follows = "flake-utils"; - nixpkgs.follows = "nixpkgs"; - }; - }; }; nixConfig = { @@ -20,11 +12,21 @@ extra-trusted-public-keys = [ "crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk=" ]; }; - outputs = { nixpkgs, flake-utils, rust-overlay, ... }: + outputs = { nixpkgs, flake-utils, ... }: let mkLib = pkgs: import ./lib { inherit (pkgs) lib newScope; }; + + nodes = (builtins.fromJSON (builtins.readFile ./test/flake.lock)).nodes; + inputFromLock = name: + let + locked = nodes.${name}.locked; + in + fetchTarball { + url = "https://github.com/${locked.owner}/${locked.repo}/archive/${locked.rev}.tar.gz"; + sha256 = locked.narHash; + }; in { inherit mkLib; @@ -102,7 +104,7 @@ pkgsChecks = import nixpkgs { inherit system; overlays = [ - rust-overlay.overlays.default + (import (inputFromLock "rust-overlay")) ]; }; in From 8e75a96bfbcf57543eb5fc37fa614e8401db8c4e Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Wed, 18 Oct 2023 17:41:44 -0700 Subject: [PATCH 3/4] Drop flake-utils from public dependencies --- .../flake.nix | 2 +- .../flake.nix | 2 +- extra-tests/fetch-cargo-git/flake.nix | 2 +- flake.lock | 34 ------------------- flake.nix | 34 +++++++++++++++---- 5 files changed, 30 insertions(+), 44 deletions(-) diff --git a/extra-tests/dummy-does-not-depend-on-flake-source-via-path/flake.nix b/extra-tests/dummy-does-not-depend-on-flake-source-via-path/flake.nix index 1c5841a8..6725f9fc 100644 --- a/extra-tests/dummy-does-not-depend-on-flake-source-via-path/flake.nix +++ b/extra-tests/dummy-does-not-depend-on-flake-source-via-path/flake.nix @@ -2,7 +2,7 @@ inputs = { crane.url = "github:ipetkov/crane"; nixpkgs.follows = "crane/nixpkgs"; - flake-utils.follows = "crane/flake-utils"; + flake-utils.url = "github:numtide/flake-utils"; }; outputs = { flake-utils, crane, ... }: flake-utils.lib.eachDefaultSystem diff --git a/extra-tests/dummy-does-not-depend-on-flake-source-via-self/flake.nix b/extra-tests/dummy-does-not-depend-on-flake-source-via-self/flake.nix index 9ab9c175..bb77e53e 100644 --- a/extra-tests/dummy-does-not-depend-on-flake-source-via-self/flake.nix +++ b/extra-tests/dummy-does-not-depend-on-flake-source-via-self/flake.nix @@ -2,7 +2,7 @@ inputs = { crane.url = "github:ipetkov/crane"; nixpkgs.follows = "crane/nixpkgs"; - flake-utils.follows = "crane/flake-utils"; + flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, flake-utils, crane, ... }: flake-utils.lib.eachDefaultSystem diff --git a/extra-tests/fetch-cargo-git/flake.nix b/extra-tests/fetch-cargo-git/flake.nix index f0e6ca6b..52c78100 100644 --- a/extra-tests/fetch-cargo-git/flake.nix +++ b/extra-tests/fetch-cargo-git/flake.nix @@ -1,7 +1,7 @@ { inputs = { crane.url = "github:ipetkov/crane"; - flake-utils.follows = "crane/flake-utils"; + flake-utils.url = "github:numtide/flake-utils"; }; outputs = { flake-utils, crane, ... }: flake-utils.lib.eachDefaultSystem diff --git a/flake.lock b/flake.lock index fdf2e45b..fcb773a7 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1697379843, @@ -36,24 +18,8 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index b72a83f6..c029267e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,18 +1,14 @@ { description = "A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching."; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - flake-utils.url = "github:numtide/flake-utils"; - }; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixConfig = { extra-substituters = [ "https://crane.cachix.org" ]; extra-trusted-public-keys = [ "crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk=" ]; }; - outputs = { nixpkgs, flake-utils, ... }: + outputs = { nixpkgs, ... }: let mkLib = pkgs: import ./lib { inherit (pkgs) lib newScope; @@ -27,6 +23,30 @@ url = "https://github.com/${locked.owner}/${locked.repo}/archive/${locked.rev}.tar.gz"; sha256 = locked.narHash; }; + + eachSystem = systems: f: + let + # Merge together the outputs for all systems. + op = attrs: system: + let + ret = f system; + op = attrs: key: attrs // + { + ${key} = (attrs.${key} or { }) + // { ${system} = ret.${key}; }; + } + ; + in + builtins.foldl' op attrs (builtins.attrNames ret); + in + builtins.foldl' op { } systems; + + eachDefaultSystem = eachSystem [ + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + "x86_64-linux" + ]; in { inherit mkLib; @@ -85,7 +105,7 @@ path = ./examples/trunk-workspace; }; }; - } // flake-utils.lib.eachDefaultSystem (system: + } // eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; From a41d040246fd349dadf685f99481986d312aa25b Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Wed, 18 Oct 2023 17:52:18 -0700 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a0479a0..380e85e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. approach to avoid redundancy. Old behavior (taking a full snapshot of the cargo artifacts) can be achieved by setting `doCompressAndInstallFullArchive = true`. +* All dependencies (outside of `nixpkgs`) have been dropped from the (main) + flake.lock file so they do not pollute downstream projects' lock files. ## [0.14.3] - 2023-10-17