-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from ipetkov/fix-dummy-invalidation
mkDummySrc: fix cache invalidation if src is flake root
- Loading branch information
Showing
14 changed files
with
253 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/examples/*/flake.lock | ||
/result* | ||
target/ | ||
/extra-tests/*/flake.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
extra-tests/dummy-does-not-depend-on-flake-source-via-path/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
extra-tests/dummy-does-not-depend-on-flake-source-via-path/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "simple" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
byteorder = "*" |
14 changes: 14 additions & 0 deletions
14
extra-tests/dummy-does-not-depend-on-flake-source-via-path/flake.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
inputs = { | ||
crane.url = "github:ipetkov/crane"; | ||
nixpkgs.follows = "crane/nixpkgs"; | ||
flake-utils.follows = "crane/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, crane }: flake-utils.lib.eachDefaultSystem | ||
(system: { | ||
packages.dummy = crane.lib.${system}.mkDummySrc { | ||
src = ./.; | ||
}; | ||
}); | ||
} |
22 changes: 22 additions & 0 deletions
22
extra-tests/dummy-does-not-depend-on-flake-source-via-path/test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
scriptDir=$(dirname "$0") | ||
cd "${scriptDir}" | ||
|
||
craneOverride="--override-input crane ../.." | ||
flakeSrc=$(nix flake metadata ${craneOverride} --json 2>/dev/null | jq -r '.path') | ||
|
||
# Get information about the default derivation | ||
# Then pull out any input sources | ||
drvSrcs=$(nix show-derivation ${craneOverride} '.#dummy' 2>/dev/null | | ||
jq -r 'to_entries[].value.inputSrcs[]') | ||
|
||
# And lastly make sure we DO NOT find the flake root source listed | ||
# or else the dummy derivation will depend on _too much_ (and get | ||
# invalidated with irrelevant changes) | ||
if echo "${drvSrcs}" | grep -q -F "${flakeSrc}"; then | ||
echo "error: dummy derivation depends on flake source" | ||
exit 1 | ||
fi |
16 changes: 16 additions & 0 deletions
16
extra-tests/dummy-does-not-depend-on-flake-source-via-self/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
extra-tests/dummy-does-not-depend-on-flake-source-via-self/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "simple" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
byteorder = "*" |
14 changes: 14 additions & 0 deletions
14
extra-tests/dummy-does-not-depend-on-flake-source-via-self/flake.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
inputs = { | ||
crane.url = "github:ipetkov/crane"; | ||
nixpkgs.follows = "crane/nixpkgs"; | ||
flake-utils.follows = "crane/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, crane }: flake-utils.lib.eachDefaultSystem | ||
(system: { | ||
packages.dummy = crane.lib.${system}.mkDummySrc { | ||
src = self; | ||
}; | ||
}); | ||
} |
22 changes: 22 additions & 0 deletions
22
extra-tests/dummy-does-not-depend-on-flake-source-via-self/test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
scriptDir=$(dirname "$0") | ||
cd "${scriptDir}" | ||
|
||
craneOverride="--override-input crane ../.." | ||
flakeSrc=$(nix flake metadata ${craneOverride} --json 2>/dev/null | jq -r '.path') | ||
|
||
# Get information about the default derivation | ||
# Then pull out any input sources | ||
drvSrcs=$(nix show-derivation ${craneOverride} '.#dummy' 2>/dev/null | | ||
jq -r 'to_entries[].value.inputSrcs[]') | ||
|
||
# And lastly make sure we DO NOT find the flake root source listed | ||
# or else the dummy derivation will depend on _too much_ (and get | ||
# invalidated with irrelevant changes) | ||
if echo "${drvSrcs}" | grep -q -F "${flakeSrc}"; then | ||
echo "error: dummy derivation depends on flake source" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
anyFailed=0 | ||
|
||
runTest() { | ||
local testPath="$1" | ||
|
||
if ${testPath}; then | ||
echo "pass: ${testPath}" | ||
else | ||
echo "fail: ${testPath}" | ||
anyFailed=1 | ||
fi | ||
} | ||
|
||
scriptPath=$(dirname "$0") | ||
cd "${scriptPath}" | ||
|
||
runTest ./dummy-does-not-depend-on-flake-source-via-path/test.sh | ||
runTest ./dummy-does-not-depend-on-flake-source-via-self/test.sh | ||
|
||
exit ${anyFailed} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
|
||
devShell = pkgs.mkShell { | ||
nativeBuildInputs = with pkgs; [ | ||
jq | ||
nixpkgs-fmt | ||
]; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters