-
Notifications
You must be signed in to change notification settings - Fork 37
/
flake.nix
110 lines (93 loc) · 3.05 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# WARNING!
# This file is provided as a courtesy and comes with no guarantees that it will
# continue to work in the future.
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/24.05";
flake-utils.url = "github:numtide/flake-utils";
opam-nix-integration = {
url = "github:vapourismo/opam-nix-integration";
inputs.opam-repository.follows = "opam-repository";
};
opam-repository = {
flake = false;
url = "github:ocaml/opam-repository";
};
rust-overlay.url = "github:oxalica/rust-overlay/38c2f156fca1868c8be7195ddac150522752f6ab";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
outputs = {
self,
nixpkgs,
flake-utils,
opam-nix-integration,
opam-repository,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
overlays = [
opam-nix-integration.overlays.default
rust-overlay.overlays.default
];
inherit system;
};
sources = {
inherit pkgs opam-repository;
riscv64Pkgs = import nixpkgs {
crossSystem.config = "riscv64-unknown-linux-gnu";
inherit system;
};
};
in {
packages.default = import ./default.nix {inherit sources;};
devShells.default = import ./shell.nix {inherit sources;};
apps.ci-check-version-sh-lock = {
type = "app";
program = let
jq = "${pkgs.jq}/bin/jq";
checkFlakeLock = pkgs.writeShellScript "check-flake-lock.sh" ''
set -e
inputPath=$1
inputSpec=$2
inputName=$3
wantedPath=$(nix flake prefetch --quiet --json $inputSpec | ${jq} -r .storePath)
# Compare the two Nix store paths, if they're different then our lock file
# is out of date.
if [[ "$wantedPath" != "$inputPath" ]]; then
echo "Input '$inputName' is out-of-date!"
echo
echo "Run the following to update your lock file."
echo
echo -e "\t nix flake lock --override-input '$inputName' '$inputSpec'"
echo
exit 1
fi
'';
script = pkgs.writeShellScript "check-version.sh" ''
set -e
source ${self}/scripts/version.sh
opam_repo_flake="github:ocaml/opam-repository/$opam_repository_tag"
if ! ( ${checkFlakeLock} ${opam-repository} $opam_repo_flake opam-repository );
then
nix flake lock \
--override-input opam-repository $opam_repo_flake \
2> /dev/null > /dev/null
echo Or copy the 'flake.lock' from CI artifacts.
echo
exit 1
fi
'';
in
builtins.toString script;
};
}
)
// {
hydraJobs = {
inherit (self) packages devShells;
};
};
}