ditch crate2nix, use fenix instead of oxalica/rust-overlay

This commit is contained in:
xenofem 2022-12-09 16:06:50 -05:00
parent c4019f7b74
commit 61653794e1
2 changed files with 70 additions and 85 deletions

View file

@ -1,43 +1,47 @@
{ {
"nodes": { "nodes": {
"crate2nix": { "fenix": {
"flake": false, "inputs": {
"nixpkgs": "nixpkgs",
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": { "locked": {
"lastModified": 1668031227, "lastModified": 1670566996,
"narHash": "sha256-WSiooiJ2gtQGkZE0JBJkkqVz5wi3SETwygU4NuBHdgw=", "narHash": "sha256-M+KsSE2D8ByDf3HZhnvLRpytg8aXScoWhg+NrdHjeeE=",
"owner": "kolloch", "owner": "nix-community",
"repo": "crate2nix", "repo": "fenix",
"rev": "ad27c9f88eca7fcbaaa25194d51787715041ec30", "rev": "ab24d0ad17a733624b99f5d6466e71b8c239a001",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "kolloch", "owner": "nix-community",
"repo": "crate2nix", "repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1667991831, "lastModified": 1670332253,
"narHash": "sha256-DHgEsLZI044B9T4AjA3K6+yB9/DqLr4dyA7OIx0FG7o=", "narHash": "sha256-O5SmhlIUt1s+vK4NXeGYqwcBIMwbBPAEZ3GHE3XT28c=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1c9ffcf70786f0966982ce0fc76ec05df2e1dec2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1670507980,
"narHash": "sha256-riNZa0xzM1it3pzxciwALeMs+0CsBMWIW2FqulzK8vM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "872fceeed60ae6b7766cc0a4cd5bf5901b9098ec", "rev": "2787fc7d1e51404678614bf0fe92fc296746eec0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -47,46 +51,27 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1665296151,
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"crate2nix": "crate2nix", "fenix": "fenix",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay",
"utils": "utils" "utils": "utils"
} }
}, },
"rust-overlay": { "rust-analyzer-src": {
"inputs": { "flake": false,
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": { "locked": {
"lastModified": 1668048396, "lastModified": 1670426523,
"narHash": "sha256-SUWQlSa/H5XKPeuF9XmWzmwIJrgK42Lak6/1jBAwyd0=", "narHash": "sha256-Zh+pAuj4PmBmISXCz+54yVSwSXZwbn+ZELgM85xVUE0=",
"owner": "oxalica", "owner": "rust-lang",
"repo": "rust-overlay", "repo": "rust-analyzer",
"rev": "859fefb532bb957f51a9b5e8e3ba2e48394c9353", "rev": "6e8a54d0f68702cf7981c8299357838eb0f4d5b2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "oxalica", "owner": "rust-lang",
"repo": "rust-overlay", "ref": "nightly",
"repo": "rust-analyzer",
"type": "github" "type": "github"
} }
}, },

View file

@ -4,14 +4,10 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay"; fenix.url = "github:nix-community/fenix";
crate2nix = {
url = "github:kolloch/crate2nix";
flake = false;
};
}; };
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix }: let outputs = { self, nixpkgs, utils, fenix }: let
name = "transbeam"; name = "transbeam";
in in
utils.lib.eachDefaultSystem utils.lib.eachDefaultSystem
@ -19,22 +15,13 @@
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ overlays = [ fenix.overlays.default ];
rust-overlay.overlays.default };
(final: prev: { fenixStable = fenix.packages.${system}.stable;
rustc = final.rust-bin.stable.latest.default; fenixPlatform = pkgs.makeRustPlatform {
cargo = final.rust-bin.stable.latest.default; cargo = fenixStable.toolchain;
}) rustc = fenixStable.toolchain;
];
}; };
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; })
generatedCargoNix;
project = import
(generatedCargoNix {
inherit name;
src = ./.;
})
{ inherit pkgs; };
in rec { in rec {
packages.${name} = pkgs.symlinkJoin { packages.${name} = pkgs.symlinkJoin {
inherit name; inherit name;
@ -49,7 +36,14 @@
defaultPackage = packages.${name}; defaultPackage = packages.${name};
packages."${name}-unwrapped" = project.rootCrate.build; packages."${name}-unwrapped" = let
cargoTOML = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in fenixPlatform.buildRustPackage {
pname = name;
inherit (cargoTOML.package) version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
packages."${name}-cli" = with pkgs.python3Packages; buildPythonApplication { packages."${name}-cli" = with pkgs.python3Packages; buildPythonApplication {
pname = "${name}-cli"; pname = "${name}-cli";
@ -61,11 +55,18 @@
src = ./cli; src = ./cli;
}; };
devShell = pkgs.mkShell { devShell = with pkgs; let
nativeBuildInputs = with pkgs; [ fenixWith = fenixStable.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
];
in mkShell {
nativeBuildInputs = [
stdenv.cc stdenv.cc
rustc fenixWith
cargo
cargo-audit cargo-audit
cargo-flamegraph cargo-flamegraph
(python3.withPackages (p: with p; [ (python3.withPackages (p: with p; [
@ -73,7 +74,6 @@
websockets websockets
])) ]))
]; ];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}; };
} }
); );