Skip to content

Commit

Permalink
Drop dependency on nixpkgs (#692)
Browse files Browse the repository at this point in the history
Callers should use `mkLib` with an instantiation of `pkgs` instead of
using `crane.lib.${system}` directly
  • Loading branch information
ipetkov committed Aug 29, 2024
1 parent 95b4209 commit 6f7504a
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 117 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- install_url: https://releases.nixos.org/nix/nix-2.18.2/install
# The 24.05 branch ships with Nix 2.18.2
- install_url: https://releases.nixos.org/nix/nix-2.18.2/install
nixpkgs-override: "--override-input nixpkgs $(./ci/ref-from-lock.sh ./test#nixpkgs)"
nixpkgs-override: "--override-input nixpkgs $(./ci/ref-from-lock.sh ./test#nixpkgs-latest-release)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
# "opt-out" of our lockfile .gitignore
run: |
rm ./examples/.gitignore
nix develop .# --accept-flake-config --command ./ci/check-example.sh ./examples/${{ matrix.example }} ".#nixpkgs"
nix develop .# --accept-flake-config --command ./ci/check-example.sh ./examples/${{ matrix.example }} "./test#nixpkgs"
examples-darwin:
strategy:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* `downloadCargoPackageFromGit` will now set `fetchLFS = true` when fetching git
repos with defined output hashes

### Removed
* The deprecated top-level (flake) attribute `lib` no longer exists. Please use
`mkLib` with an instance of `pkgs` instead.

## [0.18.1] - 2024-08-22

### Fixed
Expand Down
1 change: 0 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ following contents at the root of your cargo workspace:
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
Expand Down
1 change: 0 additions & 1 deletion docs/introduction/artifact-reuse.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Here's how we can set up our flake to achieve our goals:
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
Expand Down
1 change: 0 additions & 1 deletion docs/introduction/sequential-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ build.
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
Expand Down
5 changes: 1 addition & 4 deletions docs/local_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ Sample `flake.nix`:
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
Expand Down
10 changes: 2 additions & 8 deletions docs/overriding_derivations.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ craneLib.buildPackage {
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
Expand Down Expand Up @@ -107,10 +104,7 @@ If you need to change behavior that way, consider using a combination of
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
};
outputs = { self, nixpkgs, crane, fenix, flake-utils, advisory-db, ... }:
Expand Down
5 changes: 1 addition & 4 deletions examples/alt-registry/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils = {
url = "github:numtide/flake-utils";
Expand Down
5 changes: 1 addition & 4 deletions examples/build-std/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

Expand Down
5 changes: 1 addition & 4 deletions examples/cross-musl/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

Expand Down
5 changes: 1 addition & 4 deletions examples/cross-rust-overlay/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

Expand Down
5 changes: 1 addition & 4 deletions examples/cross-windows/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

fenix = {
url = "github:nix-community/fenix";
Expand Down
5 changes: 1 addition & 4 deletions examples/custom-toolchain/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

Expand Down
5 changes: 1 addition & 4 deletions examples/end-to-end-testing/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

Expand Down
5 changes: 1 addition & 4 deletions examples/quick-start-simple/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";
};
Expand Down
5 changes: 1 addition & 4 deletions examples/quick-start-workspace/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

fenix = {
url = "github:nix-community/fenix";
Expand Down
5 changes: 1 addition & 4 deletions examples/quick-start/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

fenix = {
url = "github:nix-community/fenix";
Expand Down
5 changes: 1 addition & 4 deletions examples/sqlx/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";
};
Expand Down
5 changes: 1 addition & 4 deletions examples/trunk-workspace/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
# Update this to include the version you need
nixpkgs-for-wasm-bindgen.url = "github:NixOS/nixpkgs/4e6868b1aa3766ab1de169922bb3826143941973";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

Expand Down
5 changes: 1 addition & 4 deletions examples/trunk/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
# Update this to include the version you need
nixpkgs-for-wasm-bindgen.url = "github:NixOS/nixpkgs/4e6868b1aa3766ab1de169922bb3826143941973";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

Expand Down
2 changes: 1 addition & 1 deletion extra-tests/alt-store/flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
nixpkgs.follows = "crane/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

Expand Down
5 changes: 4 additions & 1 deletion extra-tests/alt-store/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ set -eu
scriptDir=$(dirname "$0")
cd "${scriptDir}"

nixpkgsOverride="$(../../ci/ref-from-lock.sh ../../test#nixpkgs)"
craneOverride="--override-input crane ../.. --override-input nixpkgs ${nixpkgsOverride}"

case "$(nix --version)" in
"nix (Nix) 2.21.0" | "nix (Nix) 2.21.1")
echo 'skipping test: https://github.com/NixOS/nix/issues/10267'
;;

*) nix build .#default --override-input crane ../.. --store $(pwd)/alt-store
*) nix build .#default ${craneOverride} --store $(pwd)/alt-store
;;
esac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
nixpkgs.follows = "crane/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ set -eu
scriptDir=$(dirname "$0")
cd "${scriptDir}"

craneOverride="--override-input crane ../.."
nixpkgsOverride="$(../../ci/ref-from-lock.sh ../../test#nixpkgs)"
craneOverride="--override-input crane ../.. --override-input nixpkgs ${nixpkgsOverride}"
flakeSrc=$(nix flake metadata ${craneOverride} --json 2>/dev/null | jq -r '.path')

# Get information about the default derivation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
nixpkgs.follows = "crane/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ set -eu
scriptDir=$(dirname "$0")
cd "${scriptDir}"

craneOverride="--override-input crane ../.."
nixpkgsOverride="$(../../ci/ref-from-lock.sh ../../test#nixpkgs)"
craneOverride="--override-input crane ../.. --override-input nixpkgs ${nixpkgsOverride}"
flakeSrc=$(nix flake metadata ${craneOverride} --json 2>/dev/null | jq -r '.path')

# Get information about the default derivation
Expand Down
2 changes: 1 addition & 1 deletion extra-tests/fetch-cargo-git/flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
nixpkgs.follows = "crane/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

Expand Down
3 changes: 2 additions & 1 deletion extra-tests/fetch-cargo-git/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ set -eu
scriptDir=$(dirname "$0")
cd "${scriptDir}"

craneOverride="--override-input crane ../.."
nixpkgsOverride="$(../../ci/ref-from-lock.sh ../../test#nixpkgs)"
craneOverride="--override-input crane ../.. --override-input nixpkgs ${nixpkgsOverride}"

# Try fetching the git verision of cargo
nix build ${craneOverride} .#cargo-git
22 changes: 1 addition & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6f7504a

Please sign in to comment.