Skip to content

Commit

Permalink
try: install nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed Jan 19, 2024
1 parent 31db13d commit 7a17c65
Showing 1 changed file with 51 additions and 96 deletions.
147 changes: 51 additions & 96 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,106 +1,61 @@
{
description = "Standar cross compile flake for Rust Lang Projects";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
flake-utils.url = "github:numtide/flake-utils";
fenix.url = "github:nix-community/fenix/monthly";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane.url = "github:ipetkov/crane";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
inputs @ { flake-parts
, fenix
{ self
, nixpkgs
, flake-utils
, crane
, self
, ...
}: {
,
}:
let
# inherit (pkgs) lib;
genSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
pkgsFor = nixpkgs.legacyPackages;

# Toolchain
# toolchain = with fenix.packages.${system};
# fromToolchainFile {
# file = ./rust-toolchain.toml;
# sha256 = "sha256-U2yfueFohJHjif7anmJB5vZbpP7G6bICH4ZsjtufRoU=";
# };
# craneLib = crane.lib.${system}.overrideToolchain toolchain;

# # src = craneLib.cleanCargoSource (craneLib.path ./.);
# buildInputs = with pkgs; [
# pkg-config
# fontconfig

# dbus
# wayland
# wayland-protocols
# libxkbcommon
# xorg.libXcursor
# xorg.libxcb
# xorg.libX11
# xorg.libXi
# xorg.libXrandr
# ];
in
{
overlays.default = _: prev: {
sss = prev.callPackage ./crates/sss_cli { };
sss_code = prev.callPackage ./crates/sss_code { };
};
} //
inputs.flake-parts.lib.mkFlake
{
inherit inputs;
}
{
systems = [ "x86_64-linux" ];
perSystem =
{ config
, pkgs
, system
, ...
}:
let
inherit (pkgs) lib;
# Toolchain
toolchain = with fenix.packages.${system};
fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-U2yfueFohJHjif7anmJB5vZbpP7G6bICH4ZsjtufRoU=";
};
craneLib = crane.lib.${system}.overrideToolchain toolchain;

src = craneLib.cleanCargoSource (craneLib.path ./.);
buildInputs = with pkgs; [
pkg-config
fontconfig
packages = genSystems (system: self.overlays.default null pkgsFor.${system});

dbus
wayland
wayland-protocols
libxkbcommon
xorg.libXcursor
xorg.libxcb
xorg.libX11
xorg.libXi
xorg.libXrandr
];
commonArgs = {
inherit src;
inherit buildInputs;
};
# Compile all artifacts for x86_64-unknown-linux-gnu
linuxArtifacts = craneLib.buildDepsOnly (commonArgs
// {
CARGO_BUILD_TARGET = "x86_64-unknown-linux-gnu";
doCheck = false;
});

# Compile app for x86_64-unknown-linux-gnu
linuxApp = craneLib.buildPackage (
commonArgs
// {
doCheck = false;
cargoArtifacts = linuxArtifacts;
}
);
in
{
# nix build
packages = {
default = linuxApp;
};

# nix run
apps = {
default = flake-utils.lib.mkApp {
drv = linuxApp;
};
};

# nix develop
devShells.default = craneLib.devShell {
packages = with pkgs; [
toolchain
oranda
cargo-dist
cargo-release
] ++ buildInputs;
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
};
};
};
# inputs.flake-parts.lib.mkFlake {
# # nix develop
# devShells.default = craneLib.devShell {
# packages = with pkgs; [
# toolchain
# oranda
# cargo-dist
# cargo-release
# ] ++ buildInputs;
# LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
# };
#};
};
}

0 comments on commit 7a17c65

Please sign in to comment.