72 lines
2 KiB
Nix
72 lines
2 KiB
Nix
# Nix flake for reproducible builds & development environments.
|
|
# TL;DR:
|
|
# either `curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install`
|
|
# or https://github.com/DeterminateSystems/nix-installer
|
|
# and then `nix build` or `nix develop`
|
|
|
|
{
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
|
|
# Dev tools
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
};
|
|
# inputs.systems.url = "./flake.systems.nix";
|
|
# inputs.systems.flake = false;
|
|
|
|
outputs =
|
|
inputs:
|
|
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
|
systems = [ "x86_64-linux" ];
|
|
imports = [
|
|
inputs.treefmt-nix.flakeModule
|
|
];
|
|
perSystem =
|
|
{
|
|
config,
|
|
self',
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
nonRustDeps = [];
|
|
rust-toolchain = pkgs.symlinkJoin {
|
|
name = "rust-toolchain";
|
|
paths = [
|
|
pkgs.rustc
|
|
pkgs.clippy
|
|
pkgs.cargo
|
|
pkgs.cargo-watch
|
|
pkgs.rustPlatform.rustcSrc
|
|
];
|
|
};
|
|
in
|
|
{
|
|
# Rust package
|
|
packages.default = pkgs.rustPlatform.buildRustPackage {
|
|
inherit (cargoToml.package) name version;
|
|
nativeBuildInputs = nonRustDeps;
|
|
buildInputs = nonRustDeps;
|
|
src = ./.;
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
postInstall = ''
|
|
install -Dm644 http.1 $out/share/man/man1/http.1
|
|
ln -s http $out/bin/https
|
|
'';
|
|
};
|
|
|
|
# Add your auto-formatters here.
|
|
# cf. https://numtide.github.io/treefmt/
|
|
treefmt.config = {
|
|
projectRootFile = "flake.nix";
|
|
programs = {
|
|
nixpkgs-fmt.enable = true;
|
|
rustfmt.enable = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|