quicfs/flake.nix

104 lines
2.7 KiB
Nix
Raw Normal View History

2023-09-21 12:17:01 +01:00
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
rust-overlay.url = "github:oxalica/rust-overlay";
2024-08-02 18:26:30 +01:00
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
rootdir = {
url = "file+file:///dev/null";
flake = false;
};
2023-09-21 12:17:01 +01:00
};
2024-08-02 18:26:30 +01:00
outputs =
inputs@{
nixpkgs, flake-parts, rust-overlay, crane,
devenv,
rootdir,
...
}:
2023-09-21 12:17:01 +01:00
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
2024-08-02 18:26:30 +01:00
devenv.flakeModule
2023-09-21 12:17:01 +01:00
];
systems = [ "x86_64-linux" ];
2024-08-02 18:26:30 +01:00
debug = true;
perSystem = { inputs', system, lib, pkgs, config, ... }:
2023-09-21 12:17:01 +01:00
let
2024-08-02 18:26:30 +01:00
inherit (lib) genAttrs;
rustToolchain' = ps: ps.rust-bin.stable."1.80.0".default;
rustToolchain = rustToolchain' pkgs;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain';
src = craneLib.cleanCargoSource ./.;
commonArgs = {
inherit src;
strictDeps = true;
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
fuse3
2023-09-24 10:41:54 +01:00
];
2023-09-21 12:17:01 +01:00
};
2024-08-02 18:26:30 +01:00
# Build *just* the cargo dependencies, so we can reuse
# all of that work when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
2023-09-21 12:17:01 +01:00
in
{
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
];
};
overlayAttrs = {
inherit (config.packages) quicfs;
};
packages = rec {
2024-08-02 18:26:30 +01:00
quicfs = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
2023-09-21 12:17:01 +01:00
default = quicfs;
};
2024-08-02 18:26:30 +01:00
devenv.shells.default = devenvArgs:
let
cfg = devenvArgs.config;
rootdirOpt =
let
rootFileContent = builtins.readFile rootdir.outPath;
in
pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
in
{
devenv.root = rootdirOpt;
packages = with pkgs; [
fuse3
cargo-outdated
2023-09-21 12:17:01 +01:00
];
2024-08-02 18:26:30 +01:00
languages = {
c.enable = true;
rust = {
enable = true;
channel = "nixpkgs";
# HACK: This devenv module expects each component in a separate package,
# but rust-overlay isn't really set up that way
toolchain = genAttrs cfg.languages.rust.components (_: rustToolchain);
};
};
2023-09-21 12:17:01 +01:00
};
};
};
}