always go through inputs

This way we don't have to modify the destructuring of outputs' argument when adding or removing inputs.
This commit is contained in:
Charles Hall 2024-05-04 10:03:49 +01:00 committed by Matthias Ahouansou
parent 3ecf835b50
commit c9ee4a920e
No known key found for this signature in database

View file

@ -19,24 +19,15 @@
attic.url = "github:zhaofengli/attic?ref=main"; attic.url = "github:zhaofengli/attic?ref=main";
}; };
outputs = outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system:
{ self
, nixpkgs
, flake-utils
, nix-filter
, fenix
, crane
, ...
}: flake-utils.lib.eachDefaultSystem (system:
let let
pkgsHost = nixpkgs.legacyPackages.${system}; pkgsHost = inputs.nixpkgs.legacyPackages.${system};
# Nix-accessible `Cargo.toml` # Nix-accessible `Cargo.toml`
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
# The Rust toolchain to use # The Rust toolchain to use
toolchain = fenix.packages.${system}.fromToolchainFile { toolchain = inputs.fenix.packages.${system}.fromToolchainFile {
file = ./rust-toolchain.toml; file = ./rust-toolchain.toml;
# See also `rust-toolchain.toml` # See also `rust-toolchain.toml`
@ -44,7 +35,7 @@
}; };
builder = pkgs: builder = pkgs:
((crane.mkLib pkgs).overrideToolchain toolchain).buildPackage; ((inputs.crane.mkLib pkgs).overrideToolchain toolchain).buildPackage;
nativeBuildInputs = pkgs: [ nativeBuildInputs = pkgs: [
# bindgen needs the build platform's libclang. Apparently due to # bindgen needs the build platform's libclang. Apparently due to
@ -68,7 +59,8 @@
}); });
env = pkgs: { env = pkgs: {
CONDUIT_VERSION_EXTRA = self.shortRev or self.dirtyShortRev; CONDUIT_VERSION_EXTRA =
inputs.self.shortRev or inputs.self.dirtyShortRev;
ROCKSDB_INCLUDE_DIR = "${rocksdb' pkgs}/include"; ROCKSDB_INCLUDE_DIR = "${rocksdb' pkgs}/include";
ROCKSDB_LIB_DIR = "${rocksdb' pkgs}/lib"; ROCKSDB_LIB_DIR = "${rocksdb' pkgs}/lib";
} }
@ -161,7 +153,7 @@
)); ));
package = pkgs: builder pkgs { package = pkgs: builder pkgs {
src = nix-filter { src = inputs.nix-filter {
root = ./.; root = ./.;
include = [ include = [
"src" "src"
@ -202,17 +194,17 @@
{ {
packages = { packages = {
default = package pkgsHost; default = package pkgsHost;
oci-image = mkOciImage pkgsHost self.packages.${system}.default; oci-image = mkOciImage pkgsHost inputs.self.packages.${system}.default;
book = book =
let let
package = self.packages.${system}.default; package = inputs.self.packages.${system}.default;
in in
pkgsHost.stdenv.mkDerivation { pkgsHost.stdenv.mkDerivation {
pname = "${package.pname}-book"; pname = "${package.pname}-book";
version = package.version; version = package.version;
src = nix-filter { src = inputs.nix-filter {
root = ./.; root = ./.;
include = [ include = [
"book.toml" "book.toml"
@ -241,7 +233,7 @@
let let
binaryName = "static-${crossSystem}"; binaryName = "static-${crossSystem}";
pkgsCrossStatic = pkgsCrossStatic =
(import nixpkgs { (import inputs.nixpkgs {
inherit system; inherit system;
crossSystem = { crossSystem = {
config = crossSystem; config = crossSystem;
@ -260,7 +252,7 @@
name = "oci-image-${crossSystem}"; name = "oci-image-${crossSystem}";
value = mkOciImage value = mkOciImage
pkgsCrossStatic pkgsCrossStatic
self.packages.${system}.${binaryName}; inputs.self.packages.${system}.${binaryName};
} }
] ]
) )
@ -285,7 +277,7 @@
# #
# This needs to come before `toolchain` in this list, otherwise # This needs to come before `toolchain` in this list, otherwise
# `$PATH` will have stable rustfmt instead. # `$PATH` will have stable rustfmt instead.
fenix.packages.${system}.latest.rustfmt inputs.fenix.packages.${system}.latest.rustfmt
toolchain toolchain
] ++ (with pkgsHost; [ ] ++ (with pkgsHost; [