Remove flake-utils, update flake.lock, and reformat Nix sources

This commit is contained in:
Luc Perkins 2023-06-22 11:19:49 -07:00
parent bad7e4c102
commit f0a578b8f7
No known key found for this signature in database
GPG key ID: 4F102D0C16E232F2
4 changed files with 234 additions and 197 deletions

View file

@ -23,11 +23,14 @@ let
# For easy cross-compilation in devShells # For easy cross-compilation in devShells
# We are just composing the pkgsCross.*.stdenv.cc together # We are just composing the pkgsCross.*.stdenv.cc together
crossPlatforms = let crossPlatforms =
makeCrossPlatform = crossSystem: let let
makeCrossPlatform = crossSystem:
let
pkgsCross = pkgsCross =
if crossSystem == system then pkgs if crossSystem == system then pkgs
else import pkgs.path { else
import pkgs.path {
inherit system crossSystem; inherit system crossSystem;
overlays = [ ]; overlays = [ ];
}; };
@ -39,7 +42,8 @@ let
cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring
ccbin = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc"; ccbin = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
in { in
{
name = crossSystem; name = crossSystem;
value = { value = {
inherit rustTargetSpec; inherit rustTargetSpec;
@ -56,7 +60,8 @@ let
# Cross from aarch64-darwin -> x86_64-darwin doesn't work yet # Cross from aarch64-darwin -> x86_64-darwin doesn't work yet
# Hopefully the situation will improve with the SDK bumps # Hopefully the situation will improve with the SDK bumps
++ lib.optional (system == "x86_64-darwin") "aarch64-darwin"; ++ lib.optional (system == "x86_64-darwin") "aarch64-darwin";
in builtins.listToAttrs (map makeCrossPlatform systems); in
builtins.listToAttrs (map makeCrossPlatform systems);
cargoTargets = lib.mapAttrsToList (_: p: p.rustTargetSpec) crossPlatforms; cargoTargets = lib.mapAttrsToList (_: p: p.rustTargetSpec) crossPlatforms;
cargoCrossEnvs = lib.foldl (acc: p: acc // p.env) { } (builtins.attrValues crossPlatforms); cargoCrossEnvs = lib.foldl (acc: p: acc // p.env) { } (builtins.attrValues crossPlatforms);
@ -67,7 +72,8 @@ let
(libiconv.override { enableStatic = true; enableShared = false; }) (libiconv.override { enableStatic = true; enableShared = false; })
]; ];
buildFor = system: let buildFor = system:
let
crossPlatform = crossPlatforms.${system}; crossPlatform = crossPlatforms.${system};
inherit (crossPlatform) pkgs; inherit (crossPlatform) pkgs;
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly; craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
@ -100,8 +106,10 @@ let
# The resulting executable must be standalone # The resulting executable must be standalone
allowedRequisites = [ ]; allowedRequisites = [ ];
}); });
in crate; in
in { crate;
in
{
inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly; inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly;
nix-actions-cache = buildFor system; nix-actions-cache = buildFor system;

View file

@ -5,20 +5,18 @@
"flake-compat": [ "flake-compat": [
"flake-compat" "flake-compat"
], ],
"flake-utils": [ "flake-utils": "flake-utils",
"flake-utils"
],
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1683505101, "lastModified": 1687310026,
"narHash": "sha256-VBU64Jfu2V4sUR5+tuQS9erBRAe/QEYUxdVMcJGMZZs=", "narHash": "sha256-20RHFbrnC+hsG4Hyeg/58LvQAK7JWfFItTPFAFamu8E=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "7b5bd9e5acb2bb0cfba2d65f34d8568a894cdb6c", "rev": "116b32c30b5ff28e49f4fcbeeb1bbe3544593204",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -47,6 +45,24 @@
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
}, },
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": { "locked": {
"lastModified": 1681202837, "lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
@ -63,11 +79,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1684049129, "lastModified": 1686960236,
"narHash": "sha256-7WB9LpnPNAS8oI7hMoHeKLNhRX7k3CI9uWBRSfmOCCE=", "narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "0470f36b02ef01d4f43c641bbf07020bcab71bf1", "rev": "04af42f3b31dba0ef742d254456dc4c14eedac86",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -81,7 +97,6 @@
"inputs": { "inputs": {
"crane": "crane", "crane": "crane",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay_2" "rust-overlay": "rust-overlay_2"
} }
@ -98,11 +113,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1683080331, "lastModified": 1685759304,
"narHash": "sha256-nGDvJ1DAxZIwdn6ww8IFwzoHb2rqBP4wv/65Wt5vflk=", "narHash": "sha256-I3YBH6MS3G5kGzNuc1G0f9uYfTcNY9NYoRc3QsykLk4=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "d59c3fa0cba8336e115b376c2d9e91053aa59e56", "rev": "c535b4f3327910c96dcf21851bbdd074d0760290",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -113,19 +128,17 @@
}, },
"rust-overlay_2": { "rust-overlay_2": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": "flake-utils_2",
"flake-utils"
],
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1683512408, "lastModified": 1687400833,
"narHash": "sha256-QMJGp/37En+d5YocJuSU89GL14bBYkIJQ6mqhRfqkkc=", "narHash": "sha256-rVENiSupjAE8o1+ZXNRIqewUzM2brm+aeme8MUrwl0U=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "75b07756c3feb22cf230e75fb064c1b4c725b9bc", "rev": "fc0a266e836c079a9131108f4334e5af219dbb93",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -148,6 +161,21 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -3,19 +3,16 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = { rust-overlay = {
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
}; };
crane = { crane = {
url = "github:ipetkov/crane"; url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-compat.follows = "flake-compat"; inputs.flake-compat.follows = "flake-compat";
inputs.flake-utils.follows = "flake-utils";
}; };
flake-compat = { flake-compat = {
@ -24,27 +21,31 @@
}; };
}; };
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: let outputs = { self, nixpkgs, ... }@inputs:
supportedSystems = flake-utils.lib.defaultSystems; let
in flake-utils.lib.eachSystem supportedSystems (system: let overlays = [ inputs.rust-overlay.overlays.default ];
pkgs = import nixpkgs { supportedSystems = [
inherit system; "aarch64-linux"
overlays = [ "x86_64-linux"
rust-overlay.overlay "aarch64-darwin"
"x86_64-darwin"
]; ];
}; forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
pkgs = import nixpkgs { inherit overlays system; };
inherit (pkgs) lib;
cranePkgs = pkgs.callPackage ./crane.nix { cranePkgs = pkgs.callPackage ./crane.nix {
inherit crane supportedSystems; inherit supportedSystems;
inherit (inputs) crane;
}; };
in { inherit (pkgs) lib;
packages = rec { });
in
{
packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec {
inherit (cranePkgs) nix-actions-cache; inherit (cranePkgs) nix-actions-cache;
default = nix-actions-cache; default = nix-actions-cache;
}; });
devShells = {
devShells = forEachSupportedSystem ({ pkgs, cranePkgs, lib }: {
default = pkgs.mkShell ({ default = pkgs.mkShell ({
inputsFrom = [ cranePkgs.nix-actions-cache ]; inputsFrom = [ cranePkgs.nix-actions-cache ];
packages = with pkgs; [ packages = with pkgs; [
@ -54,17 +55,15 @@
cargo-bloat cargo-bloat
cargo-edit cargo-edit
cargo-udeps cargo-udeps
cargo-watch
age age
]; ];
shellHook =
# We _can_ cross-compile to multiple systems with one shell :) let
#
# Currently stdenv isn't set up to do that, but we can invoke
# the setup mechinary in a sub-shell then compose the results.
shellHook = let
crossSystems = lib.filter (s: s != pkgs.system) (builtins.attrNames cranePkgs.crossPlatforms); crossSystems = lib.filter (s: s != pkgs.system) (builtins.attrNames cranePkgs.crossPlatforms);
in '' in
''
# Returns compiler environment variables for a platform # Returns compiler environment variables for a platform
# #
# getTargetFlags "suffixSalt" "nativeBuildInputs" "buildInputs" # getTargetFlags "suffixSalt" "nativeBuildInputs" "buildInputs"
@ -134,11 +133,12 @@
unset NIX_LDFLAGS unset NIX_LDFLAGS
''; '';
} // cranePkgs.cargoCrossEnvs); } // cranePkgs.cargoCrossEnvs);
keygen = pkgs.mkShellNoCC { keygen = pkgs.mkShellNoCC {
packages = with pkgs; [ packages = with pkgs; [
age age
]; ];
}; };
};
}); });
};
} }

View file

@ -13,4 +13,5 @@ let
shell = flake.shellNix.default // { shell = flake.shellNix.default // {
reproduce = flake.defaultNix.outputs.reproduce.${builtins.currentSystem}; reproduce = flake.defaultNix.outputs.reproduce.${builtins.currentSystem};
}; };
in shell in
shell