Skip to content

Commit

Permalink
Merge pull request #147 from DeterminateSystems/rust-stable
Browse files Browse the repository at this point in the history
Switch to stable Rust
  • Loading branch information
lucperkins authored Dec 6, 2024
2 parents 7df9350 + f831109 commit ca7cfb3
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
nix develop -c \
cargo run -- \
--condition "supportedRefs.contains(gitRef) && numDaysOld < 30 && owner == 'NixOS'" \
--condition "supportedRefs.contains(gitRef) && numDaysOld > 30 && owner == 'NixOS'" \
./tests/flake.cel.0.lock
check-flake-dirty:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flake-checker"
version = "0.2.2"
version = "0.2.3"
edition = "2021"

[workspace]
Expand Down
108 changes: 0 additions & 108 deletions crane.nix

This file was deleted.

95 changes: 65 additions & 30 deletions flake.lock

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

87 changes: 66 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,54 +1,99 @@
{
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*";
rust-overlay = {
url = "https://flakehub.com/f/oxalica/rust-overlay/*";
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2411.*";

fenix = {
url = "https://flakehub.com/f/nix-community/fenix/0.1.*";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "https://flakehub.com/f/ipetkov/crane/0.19.*";

naersk.url = "https://flakehub.com/f/nix-community/naersk/0.1.*";
};

outputs = { self, ... }@inputs:
let
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
version = "${builtins.substring 0 8 lastModifiedDate}-${self.shortRev or "dirty"}";

supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: inputs.nixpkgs.lib.genAttrs supportedSystems (system: f rec {

forSystems = s: f: inputs.nixpkgs.lib.genAttrs s (system: f rec {
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.rust-overlay.overlays.default
];
};

cranePkgs = pkgs.callPackage ./crane.nix {
inherit (inputs) crane;
inherit supportedSystems;
overlays = [ self.overlays.default ];
};
});

forAllSystems = forSystems supportedSystems;
in
{
packages = forAllSystems ({ cranePkgs, ... }: rec {
inherit (cranePkgs) flake-checker;
overlays.default = final: prev:
let
inherit (final.stdenv.hostPlatform) system;

rustToolchain = with inputs.fenix.packages.${system};
combine ([
stable.clippy
stable.rustc
stable.cargo
stable.rustfmt
stable.rust-src
] ++ inputs.nixpkgs.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std
] ++ inputs.nixpkgs.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std
]);
in
{
inherit rustToolchain;

naerskLib = final.callPackage inputs.naersk {
cargo = rustToolchain;
rustc = rustToolchain;
};
};

packages = forAllSystems ({ pkgs, system }: rec {
default = flake-checker;

flake-checker = pkgs.naerskLib.buildPackage
({
name = "flake-checker-${version}";
src = self;
doCheck = true;
buildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration ]);
nativeBuildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
CARGO_BUILD_TARGET =
if system == "x86_64-linux" then
"x86_64-unknown-linux-musl"
else if system == "aarch64-linux" then
"aarch64-unknown-linux-musl"
else
throw "Unsupported Linux system: ${system}";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
});
});

devShells = forAllSystems ({ pkgs, cranePkgs }: {
devShells = forAllSystems ({ pkgs, ... }: {
default =
let
check-nixpkgs-fmt = pkgs.writeShellApplication {
name = "check-nixpkgs-fmt";
runtimeInputs = with pkgs; [ git nixpkgs-fmt ];
text = ''
git ls-files '*.nix' | xargs nixpkgs-fmt --check
nixpkgs-fmt --check "$(git ls-files '*.nix')"
'';
};
check-rustfmt = pkgs.writeShellApplication {
name = "check-rustfmt";
runtimeInputs = [ cranePkgs.rustNightly ];
runtimeInputs = with pkgs; [ rustToolchain ];
text = "cargo fmt --check";
};
get-allowed-refs = pkgs.writeShellApplication {
name = "get-allowed-refs";
runtimeInputs = [ cranePkgs.rustNightly ];
runtimeInputs = with pkgs; [ rustToolchain ];
text = "cargo run --features allowed-refs -- --get-allowed-refs";
};
in
Expand All @@ -57,7 +102,7 @@
bashInteractive

# Rust
cranePkgs.rustNightly
rustToolchain
cargo-bloat
cargo-edit
cargo-machete
Expand All @@ -77,7 +122,7 @@

env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${cranePkgs.rustNightly}/lib/rustlib/src/rust/library";
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
};
};
});
Expand Down

0 comments on commit ca7cfb3

Please sign in to comment.