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-04-30 14:47:04 -07:00
parent 238bc85b1d
commit 8d8d4425f3
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF

View file

@ -10,24 +10,15 @@
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
}; };
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`
@ -35,7 +26,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
@ -59,7 +50,8 @@
}); });
env = pkgs: { env = pkgs: {
GRAPEVINE_VERSION_EXTRA = self.shortRev or self.dirtyShortRev; GRAPEVINE_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";
} }
@ -152,7 +144,7 @@
)); ));
package = pkgs: builder pkgs { package = pkgs: builder pkgs {
src = nix-filter { src = inputs.nix-filter {
root = ./.; root = ./.;
include = [ include = [
"src" "src"
@ -193,7 +185,7 @@
{ {
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;
} }
// //
builtins.listToAttrs builtins.listToAttrs
@ -203,7 +195,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;
@ -222,7 +214,7 @@
name = "oci-image-${crossSystem}"; name = "oci-image-${crossSystem}";
value = mkOciImage value = mkOciImage
pkgsCrossStatic pkgsCrossStatic
self.packages.${system}.${binaryName}; inputs.self.packages.${system}.${binaryName};
} }
] ]
) )
@ -247,7 +239,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; [