polyglot-zip/flake.nix

110 lines
3.2 KiB
Nix

# {
# inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# };
# outputs = { self, nixpkgs }: let
# supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
# forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system nixpkgs.legacyPackages.${system});
# in {
# devShells = forAllSystems (system: pkgs: {
# default = let
# rustPlatform = pkgs.rust.packages.stable.rustPlatform;
# in pkgs.mkShell {
# packages = with pkgs; [
# cargo
# clippy
# rust-analyzer
# rustc
# rustfmt
# ];
# RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
# };
# });
# packages = (forAllSystems (system: pkgs: {
# default = pkgs.rustPlatform.buildRustPackage rec {
# pname = "polyglot-zip";
# version = (pkgs.lib.importTOML ./Cargo.toml).package.version;
# src = ./.;
# cargoSha256 = "sha256-3oHEH6DlooWg0sQ+oIvsYoU6FAs7gP9PRwv1xJjGDYA=";
# meta = with pkgs.lib; {
# description = "A tool to convert and extract zip files with non-UTF-8 contents";
# homepage = "https://github.com/h7x4/polyglot-zip";
# license = licenses.mit;
# platforms = supportedSystems;
# };
# };
# }));
# };
# }
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, fenix }@inputs:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
toolchain = fenix.packages.${system}.complete;
pkgs = import nixpkgs {
inherit system;
overlays = [
(_: super: let pkgs = fenix.inputs.nixpkgs.legacyPackages.${system}; in fenix.overlays.default pkgs pkgs)
];
};
in f system pkgs toolchain);
in {
apps = forAllSystems (system: pkgs: _: let
mkApp = program: {
type = "app";
program = "${nixpkgs.lib.getExe program}";
};
in {
default = mkApp self.packages.${system}.default;
});
devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell {
packages = [
(toolchain.withComponents [
"cargo" "rustc" "rustfmt" "clippy"
])
pkgs.openssl
pkgs.pkg-config
];
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/";
});
overlays.default = final: prev: self.packages.${final.system};
packages = (forAllSystems (system: pkgs: _: {
default = pkgs.rustPlatform.buildRustPackage rec {
pname = "polyglot-zip";
version = (pkgs.lib.importTOML ./Cargo.toml).package.version;
src = ./.;
cargoSha256 = "sha256-3oHEH6DlooWg0sQ+oIvsYoU6FAs7gP9PRwv1xJjGDYA=";
meta = with pkgs.lib; {
description = "A tool to convert and extract zip files with non-UTF-8 contents";
homepage = "https://github.com/h7x4/polyglot-zip";
license = licenses.mit;
platforms = systems;
mainProgram = "polyzip";
};
};
}));
};
}