2022-10-15 20:02:13 +00:00
|
|
|
{
|
2024-04-30 21:46:04 +00:00
|
|
|
# Keep sorted
|
2023-04-04 23:56:51 +00:00
|
|
|
inputs = {
|
2024-04-30 21:46:04 +00:00
|
|
|
attic.url = "github:zhaofengli/attic?ref=main";
|
|
|
|
crane = { url = "github:ipetkov/crane?ref=master"; inputs.nixpkgs.follows = "nixpkgs"; };
|
|
|
|
fenix = { url = "github:nix-community/fenix?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; };
|
|
|
|
flake-compat = { url = "github:edolstra/flake-compat?ref=master"; flake = false; };
|
2024-04-30 21:42:54 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils?ref=main";
|
|
|
|
nix-filter.url = "github:numtide/nix-filter?ref=main";
|
2024-04-30 21:46:04 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
2024-08-13 04:22:05 +00:00
|
|
|
|
|
|
|
rust-manifest = {
|
|
|
|
# Keep version in sync with rust-toolchain.toml
|
2024-09-05 18:35:24 +00:00
|
|
|
url = "https://static.rust-lang.org/dist/channel-rust-1.81.0.toml";
|
2024-08-13 04:22:05 +00:00
|
|
|
flake = false;
|
|
|
|
};
|
2023-04-04 23:56:51 +00:00
|
|
|
};
|
|
|
|
|
2024-04-30 23:00:19 +00:00
|
|
|
outputs = inputs:
|
2023-04-04 23:56:51 +00:00
|
|
|
let
|
2024-04-30 23:00:19 +00:00
|
|
|
# Keep sorted
|
|
|
|
mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: {
|
|
|
|
craneLib =
|
|
|
|
(inputs.crane.mkLib pkgs).overrideToolchain self.toolchain;
|
2023-04-04 23:56:51 +00:00
|
|
|
|
2024-04-30 23:00:19 +00:00
|
|
|
default = self.callPackage ./nix/pkgs/default {};
|
2023-04-04 23:56:51 +00:00
|
|
|
|
2024-04-30 23:00:19 +00:00
|
|
|
inherit inputs;
|
2023-04-04 23:56:51 +00:00
|
|
|
|
2024-05-30 07:44:30 +00:00
|
|
|
# Return a new scope with overrides applied to the 'default' package
|
|
|
|
overrideDefaultPackage = args: self.overrideScope (final: prev: {
|
|
|
|
default = prev.default.override args;
|
|
|
|
});
|
|
|
|
|
2024-04-30 23:00:19 +00:00
|
|
|
shell = self.callPackage ./nix/shell.nix {};
|
2023-12-24 05:12:42 +00:00
|
|
|
|
2024-04-30 23:00:19 +00:00
|
|
|
# The Rust toolchain to use
|
2024-08-13 04:22:05 +00:00
|
|
|
# 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;
|
2024-08-17 18:16:15 +00:00
|
|
|
fenix = inputs.fenix.packages.${pkgs.stdenv.buildPlatform.system};
|
2024-08-13 04:22:05 +00:00
|
|
|
in
|
|
|
|
fenix.combine (builtins.map
|
|
|
|
(target:
|
|
|
|
(fenix.targets.${target}.fromManifestFile inputs.rust-manifest)
|
|
|
|
.withComponents components)
|
|
|
|
targets);
|
2024-04-30 23:00:19 +00:00
|
|
|
});
|
2024-01-26 03:36:17 +00:00
|
|
|
in
|
2024-04-30 23:00:19 +00:00
|
|
|
inputs.flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
2024-08-17 18:45:51 +00:00
|
|
|
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;
|
|
|
|
};
|
2024-04-30 23:00:19 +00:00
|
|
|
in
|
|
|
|
{
|
2024-09-13 06:49:44 +00:00
|
|
|
packages = rec {
|
2024-04-30 23:00:19 +00:00
|
|
|
default = (mkScope pkgs).default;
|
2024-09-13 06:49:44 +00:00
|
|
|
oci-image = pkgs.dockerTools.buildImage {
|
|
|
|
name = default.pname;
|
|
|
|
tag = "next";
|
|
|
|
copyToRoot = [
|
|
|
|
pkgs.dockerTools.caCertificates
|
|
|
|
];
|
|
|
|
config = {
|
|
|
|
# Use the `tini` init system so that signals (e.g. ctrl+c/SIGINT)
|
|
|
|
# are handled as expected
|
|
|
|
Entrypoint = [
|
|
|
|
"${pkgs.lib.getExe' pkgs.tini "tini"}"
|
|
|
|
"--"
|
|
|
|
"${pkgs.lib.getExe default}"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-04-30 23:00:19 +00:00
|
|
|
}
|
|
|
|
//
|
|
|
|
builtins.listToAttrs
|
|
|
|
(builtins.concatLists
|
|
|
|
(builtins.map
|
|
|
|
(crossSystem:
|
|
|
|
let
|
|
|
|
binaryName = "static-${crossSystem}";
|
|
|
|
pkgsCrossStatic =
|
|
|
|
(import inputs.nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
crossSystem = {
|
|
|
|
config = crossSystem;
|
|
|
|
};
|
2024-08-17 18:45:51 +00:00
|
|
|
|
|
|
|
# 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;
|
2024-04-30 23:00:19 +00:00
|
|
|
}).pkgsStatic;
|
|
|
|
in
|
|
|
|
[
|
|
|
|
# An output for a statically-linked binary
|
|
|
|
{
|
|
|
|
name = binaryName;
|
|
|
|
value = (mkScope pkgsCrossStatic).default;
|
|
|
|
}
|
|
|
|
]
|
|
|
|
)
|
2024-01-29 23:34:16 +00:00
|
|
|
[
|
2024-04-30 23:00:19 +00:00
|
|
|
"x86_64-unknown-linux-musl"
|
|
|
|
"aarch64-unknown-linux-musl"
|
2024-01-29 23:34:16 +00:00
|
|
|
]
|
|
|
|
)
|
2024-04-30 23:00:19 +00:00
|
|
|
);
|
2024-01-23 06:48:58 +00:00
|
|
|
|
2024-04-30 23:00:19 +00:00
|
|
|
devShells.default = (mkScope pkgs).shell;
|
2024-05-30 07:44:30 +00:00
|
|
|
devShells.all-features = ((mkScope pkgs).overrideDefaultPackage {
|
|
|
|
all-features = true;
|
|
|
|
}).shell;
|
2024-04-30 23:00:19 +00:00
|
|
|
}
|
2024-04-30 23:53:20 +00:00
|
|
|
)
|
|
|
|
//
|
|
|
|
{
|
|
|
|
nixosModules.default = import ./nix/modules/default inputs;
|
|
|
|
};
|
2022-10-15 20:02:13 +00:00
|
|
|
}
|