Skip to content

Commit

Permalink
build(nix): drop fenix
Browse files Browse the repository at this point in the history
we don't need specific/newer versions of rustc. nixpkgs' rust toolchain
has also gotten a lot better
  • Loading branch information
getchoo committed Aug 7, 2024
1 parent 4f5b408 commit c32e81c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 54 deletions.
24 changes: 2 additions & 22 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

fenix = {
url = "github:nix-community/fenix";
inputs = {
nixpkgs.follows = "nixpkgs";
rust-analyzer-src.follows = "";
};
};

treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -22,7 +14,6 @@
{
self,
nixpkgs,
fenix,
treefmt-nix,
}:
let
Expand Down Expand Up @@ -86,19 +77,8 @@
pkgs = nixpkgsFor.${system};
packages' = self.packages.${system};

mkStatic = pkgs.callPackage ./nix/static.nix {
inherit (packages') refraction;
fenix = fenix.packages.${system};
};

containerize =
refraction:
pkgs.dockerTools.buildLayeredImage {
name = "refraction";
tag = "latest-${refraction.passthru.architecture}";
config.Cmd = [ (lib.getExe refraction) ];
inherit (refraction.passthru) architecture;
};
mkStatic = pkgs.callPackage ./nix/static.nix { };
containerize = pkgs.callPackage ./nix/containerize.nix { };
in
{
refraction = pkgs.callPackage ./nix/derivation.nix { };
Expand Down
9 changes: 9 additions & 0 deletions nix/containerize.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ lib, dockerTools }:
refraction:

dockerTools.buildLayeredImage {
name = "refraction";
tag = "latest-${refraction.passthru.architecture}";
config.Cmd = [ (lib.getExe refraction) ];
inherit (refraction.passthru) architecture;
}
34 changes: 2 additions & 32 deletions nix/static.nix
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
{
lib,
pkgsCross,
fenix,
refraction,
}:
{ lib, pkgsCross }:
let
crossPlatformFor = with pkgsCross; {
x86_64 = musl64.pkgsStatic;
aarch64 = aarch64-multiplatform.pkgsStatic;
};

toolchain = fenix.combine (
[ fenix.stable.minimalToolchain ]
++ lib.mapAttrsToList (
_: pkgs: fenix.targets.${pkgs.stdenv.hostPlatform.rust.rustcTarget}.stable.rust-std
) crossPlatformFor
);

rustPlatformFor = lib.mapAttrs (
_: pkgs:
pkgs.makeRustPlatform (
lib.genAttrs [
"cargo"
"rustc"
] (_: toolchain)
)
) crossPlatformFor;
in
{ arch }:
(refraction.override {
rustPlatform = rustPlatformFor.${arch};
optimizeSize = true;
}).overrideAttrs
(old: {
passthru = old.passthru or { } // {
inherit toolchain;
};
})
crossPlatformFor.${arch}.callPackage ./derivation.nix { optimizeSize = true; }

0 comments on commit c32e81c

Please sign in to comment.