{ # Keep sorted inputs = { attic.url = "github:zhaofengli/attic?ref=main"; crane.url = "github:ipetkov/crane?ref=master"; fenix = { url = "github:nix-community/fenix?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; }; flake-compat = { url = "github:edolstra/flake-compat?ref=master"; flake = false; }; flake-utils.url = "github:numtide/flake-utils?ref=main"; nix-filter.url = "github:numtide/nix-filter?ref=main"; nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; rocksdb = { url = "github:facebook/rocksdb?ref=v10.4.2"; flake = false; }; }; outputs = inputs: let rust-manifest = builtins.fetchurl { # Keep version in sync with rust-toolchain.toml url = "https://static.rust-lang.org/dist/channel-rust-1.88.0.toml"; sha256 = "sha256-Qxt8XAuaUR2OMdKbN4u8dBJOhSHxS+uS06Wl9+flVEk="; }; # Keep sorted mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: { craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (_: self.toolchain); default = self.callPackage ./nix/pkgs/default {}; inherit inputs; # Return a new scope with overrides applied to the 'default' package overrideDefaultPackage = args: self.overrideScope (final: prev: { default = prev.default.override args; }); rocksdb = self.callPackage ./nix/pkgs/rocksdb { inherit (pkgs) rocksdb; }; shell = self.callPackage ./nix/shell.nix {}; # The Rust toolchain to use # Using fromManifestFile and parsing the toolchain file with importTOML # instead of fromToolchainFile to avoid IFD toolchain = let toolchainFile = pkgs.lib.importTOML ./rust-toolchain.toml; defaultProfileComponents = [ "rustc" "cargo" "rust-docs" "rustfmt" "clippy" ]; components = defaultProfileComponents ++ toolchainFile.toolchain.components; targets = toolchainFile.toolchain.targets; fenix = inputs.fenix.packages.${pkgs.stdenv.buildPlatform.system}; nativeToolchain = (fenix.fromManifestFile rust-manifest) .withComponents components; crossComponents = builtins.map (target: (fenix.targets.${target}.fromManifestFile rust-manifest) .rust-std) targets; in fenix.combine ([nativeToolchain] ++ crossComponents); website-root = self.callPackage ./nix/pkgs/website-root {}; }); in inputs.flake-utils.lib.eachDefaultSystem (system: let pkgs = import inputs.nixpkgs { inherit system; # Some users find it useful to set this on their Nixpkgs instance and # we want to support that use case, so we set it here too to help us # test/ensure that this works. config.allowAliases = false; }; in { packages = { default = (mkScope pkgs).default; website-root = (mkScope pkgs).website-root; } // builtins.listToAttrs (builtins.concatLists (builtins.map (crossSystem: let binaryName = "static-${crossSystem}"; pkgsCrossStatic = (import inputs.nixpkgs { inherit system; crossSystem = { config = crossSystem; }; # Some users find it useful to set this on their Nixpkgs # instance and we want to support that use case, so we set # it here too to help us test/ensure that this works. config.allowAliases = false; }).pkgsStatic; in [ # An output for a statically-linked binary { name = binaryName; value = (mkScope pkgsCrossStatic).default; } ] ) [ "x86_64-unknown-linux-musl" "aarch64-unknown-linux-musl" ] ) ); devShells.default = (mkScope pkgs).shell; } ) // { nixosModules.default = import ./nix/modules/default inputs; }; }