{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
naersk.url = "github:nix-community/naersk";
fenix.url = "github:nix-community/fenix/monthly";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, naersk, fenix, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
name = "imapctl";
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.${system}.default ];
};
# Toolchain for use in development shell
toolchainFull = with fenix.packages.${system}; combine [
complete.rustc
complete.cargo
complete.clippy
complete.rustfmt
complete.rust-analyzer
targets.x86_64-unknown-linux-musl.latest.rust-std
];
naerskNightly = naersk.lib.${system}.override {
cargo = toolchainFull;
rustc = toolchainFull;
clippy = toolchainFull;
};
nativePackage = naerskNightly.buildPackage {
src = ./.;
nativeBuildInputs = with pkgs; [
stdenv.cc
openssl
];
};
dockerImage = pkgs.dockerTools.buildImage {
name = "${name}";
tag = "latest";
config = {
Entrypoint = "${nativePackage}/bin/${name}";
};
};
in rec {
packages = {
default = nativePackage;
native = nativePackage;
docker = dockerImage;
};
overlays.default = final: prev: {
${name} = nativePackage;
};
devShells.default = pkgs.mkShell {
inputsFrom = with packages; [ nativePackage ];
buildInputs = with pkgs; [
just
];
shellHook = ''
user_shell=$(getent passwd "$(whoami)" |cut -d: -f 7)
exec "$user_shell"
'';
};
}
);
}