Skip to content

Commit

Permalink
refactor: remove cranix from nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed Oct 22, 2024
1 parent 17ae3cd commit b1b7a36
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 110 deletions.
78 changes: 4 additions & 74 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 18 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,41 @@
description = "Standar cross compile flake for Rust Lang Projects";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
cranix.url = "github:Lemin-n/cranix/2af6b2e71577bb8836b10e28f3267f2c5342a8fd";
crane.url = "github:ipetkov/crane";
fenix.url = "github:nix-community/fenix";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
# Iterate over Arm, x86 for MacOs 🍎 and Linux 🐧
flake-utils.lib.eachSystem (flake-utils.lib.defaultSystems) (
system: let
pkgs = nixpkgs.legacyPackages.${system};
crane = inputs.crane.mkLib pkgs;
fenix = inputs.fenix.packages;
sssBundle = import ./nix {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
crane = inputs.crane.lib;
cranix = inputs.cranix.lib;
fenix = inputs.fenix.packages;
inherit system pkgs crane fenix;
};
in {
inherit (sssBundle) apps packages devShells;
}
)
// {
# Overlays
overlays.default = import ./nix/overlay.nix {
crane = inputs.crane.lib;
cranix = inputs.cranix.lib;
fenix = inputs.fenix.packages;
};
# nixosModules
nixosModules = {
default = import ./nix/nixos-module.nix {
crane = inputs.crane.lib;
cranix = inputs.cranix.lib;
fenix = inputs.fenix.packages;

# Overlays
overlays.default = import ./nix/overlay.nix {
inherit crane fenix;
};
home-manager = import ./nix/hm-module.nix {
crane = inputs.crane.lib;
cranix = inputs.cranix.lib;
fenix = inputs.fenix.packages;
# nixosModules
nixosModules = {
default = import ./nix/nixos-module.nix {
inherit crane fenix;
};
home-manager = import ./nix/hm-module.nix {
inherit crane fenix;
};
};
};
};
}
);
}
20 changes: 12 additions & 8 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ in
pkgs ? import (getFlake "nixpkgs") {localSystem = {inherit system;};},
lib ? pkgs.lib,
crane,
cranix,
fenix,
stdenv ? pkgs.stdenv,
...
Expand All @@ -30,9 +29,7 @@ in
sha256 = "sha256-yMuSb5eQPO/bHv+Bcf/US8LVMbf/G/0MSfiPwBhiPpk=";
};
# crane: cargo and artifacts manager
craneLib = crane.${system}.overrideToolchain toolchain;
# cranix: extends crane building system with workspace bin building and Mold + Cranelift integrations
cranixLib = craneLib.overrideScope (cranix.${system}.craneOverride);
craneLib = crane.overrideToolchain toolchain;

# buildInputs for SSS
buildInputs = with pkgs; [
Expand All @@ -54,7 +51,7 @@ in
};

# sss artifacts
sssDeps = cranixLib.buildCranixDepsOnly commonArgs;
sssDeps = craneLib.buildDepsOnly commonArgs;

# Lambda for build packages with cached artifacts
packageArgs = targetName:
Expand All @@ -67,9 +64,16 @@ in
workspaceTargetName = targetName;
};

genBuild = name: rec {
pkg = craneLib.buildPackage (packageArgs name);
app = {
type = "app";
program = "${pkg}${pkg.passthru.exePath or "/bin/${pkg.pname or pkg.name}"}";
};
};
# Build packages and `nix run` apps
sss = cranixLib.buildCranixBundle (packageArgs "sss");
sssCode = cranixLib.buildCranixBundle (packageArgs "sss_code");
sss = genBuild "sss";
sssCode = genBuild "sss_code";
in {
# `nix run`
apps = rec {
Expand All @@ -84,7 +88,7 @@ in
default = cli;
};
# `nix develop`
devShells.default = cranixLib.devShell {
devShells.default = craneLib.devShell {
packages = with pkgs;
[
toolchain
Expand Down

0 comments on commit b1b7a36

Please sign in to comment.