Skip to content

Commit

Permalink
tests: Derive nixpkgs/flake-parts rev fromexample/flake.lock (#254)
Browse files Browse the repository at this point in the history
* create example/flake.lock

* nixci: read overrides from example lock

* common.sh: use example lock pins
  • Loading branch information
srid authored Feb 29, 2024
1 parent 3a8c1b5 commit 098bf00
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 44 deletions.
80 changes: 80 additions & 0 deletions example/flake.lock

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

88 changes: 46 additions & 42 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,61 @@

# CI spec
# https://github.com/srid/nixci
nixci.default = {
dev = {
dir = "dev";
overrideInputs."haskell-flake" = ./.;
};
nixci.default =
let
exampleLock = builtins.fromJSON (builtins.readFile ./example/flake.lock);
nixpkgs = "github:nixos/nixpkgs/" + exampleLock.nodes.nixpkgs.locked.rev;
flake-parts = "github:hercules-ci/flake-parts/" + exampleLock.nodes.flake-parts.locked.rev;
in
{
dev = {
dir = "dev";
overrideInputs."haskell-flake" = ./.;
};

doc = {
dir = "doc";
overrideInputs = {
"haskell-flake" = ./.;
"flake-parts-website" = "github:hercules-ci/flake.parts-website";
doc = {
dir = "doc";
overrideInputs = {
"haskell-flake" = ./.;
"flake-parts-website" = "github:hercules-ci/flake.parts-website";
};
};
};

example = {
dir = "example";
overrideInputs."haskell-flake" = ./.;
};
example = {
dir = "example";
overrideInputs."haskell-flake" = ./.;
};

# Tests
haskell-parsers-test = {
dir = ./nix/haskell-parsers/test;
overrideInputs."haskell-parsers" = ./nix/haskell-parsers;
};
# Tests
haskell-parsers-test = {
dir = ./nix/haskell-parsers/test;
overrideInputs."haskell-parsers" = ./nix/haskell-parsers;
};

test-simple = {
dir = "test/simple";
overrideInputs = {
"haskell-flake" = ./.;
"flake-parts" = "github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f";
"nixpkgs" = "github:nixos/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0";
test-simple = {
dir = "test/simple";
overrideInputs = {
inherit nixpkgs flake-parts;
"haskell-flake" = ./.;
};
};
};

test-project-module = {
dir = "test/project-module";
overrideInputs = {
"haskell-flake" = ./.;
"flake-parts" = "github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f";
"nixpkgs" = "github:nixos/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0";
test-project-module = {
dir = "test/project-module";
overrideInputs = {
inherit nixpkgs flake-parts;
"haskell-flake" = ./.;
};
};
};

# Legacy shell script test
legacy-test = {
dir = "test";
overrideInputs."haskell-flake" = ./.;
# Can't build on Linux until https://github.com/srid/haskell-flake/issues/241
# TODO: Do the above, and get rid of this test.
systems = [ "aarch64-darwin" "x86_64-darwin" ];
# Legacy shell script test
legacy-test = {
dir = "test";
overrideInputs."haskell-flake" = ./.;
# Can't build on Linux until https://github.com/srid/haskell-flake/issues/241
# TODO: Do the above, and get rid of this test.
systems = [ "aarch64-darwin" "x86_64-darwin" ];
};
};
};
};
}
6 changes: 4 additions & 2 deletions test/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ HASKELL_FLAKE=${DIR_OF_COMMON_SH}/..
OVERRIDE_HASKELL_FLAKE="--override-input haskell-flake path:${HASKELL_FLAKE}"

# Let's pin both nixpkgs and flake-parts across all tests, to save up on CI time.
NIXPKGS_URL="github:nixos/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0"
NIXPKGS_REV=$(jq -r '.nodes."nixpkgs".locked.rev' < ${HASKELL_FLAKE}/example/flake.lock)
NIXPKGS_URL="github:nixos/nixpkgs/${NIXPKGS_REV}"
OVERRIDE_NIXPKGS="--override-input nixpkgs ${NIXPKGS_URL}"
OVERRIDE_FLAKE_PARTS="--override-input flake-parts github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f"
FLAKE_PARTS_REV=$(jq -r '.nodes."flake-parts".locked.rev' < ${HASKELL_FLAKE}/example/flake.lock)
OVERRIDE_FLAKE_PARTS="--override-input flake-parts github:hercules-ci/flake-parts/${FLAKE_PARTS_REV}"

OVERRIDE_ALL="${OVERRIDE_HASKELL_FLAKE} ${OVERRIDE_FLAKE_PARTS} ${OVERRIDE_NIXPKGS}"

Expand Down
1 change: 1 addition & 0 deletions test/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
git
which
gawk
jq
];
} ''
export HOME=$(mktemp -d)
Expand Down

0 comments on commit 098bf00

Please sign in to comment.