Skip to content

Commit

Permalink
Update flake
Browse files Browse the repository at this point in the history
  • Loading branch information
afajl committed Mar 8, 2024
1 parent 13cbe28 commit 2d021f7
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 51 deletions.
88 changes: 50 additions & 38 deletions flake.lock

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

68 changes: 55 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,64 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
crane = {
url = "github:ipetkov/crane";
inputs = { nixpkgs.follows = "nixpkgs"; };
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile
./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = craneLib.cleanCargoSource ./.;
nativeBuildInputs = with pkgs; [ rustToolchain pkg-config ];

outputs = { self, flake-utils, naersk, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) { inherit system; };
buildInputs = with pkgs;
[ ] ++ lib.optionals stdenv.isDarwin [ libiconv ];

naersk' = pkgs.callPackage naersk { };
commonArgs = {
pname = "mob";
version = "0.1.0";
inherit src buildInputs nativeBuildInputs;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
mob =
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
in
{
packages = {
inherit mob;
default = mob;
};

in rec {
defaultPackage = naersk'.buildPackage { src = ./.; };
devShells.default = craneLib.devShell {
inputsFrom = [ mob ];
packages = [ pkgs.hyperfine ];

devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustc cargo plantuml cargo-release ];
};
});
shellHook = ''
echo
echo "👋 Hi."
'';
};
}) // {
overlays.default = final: _: {
inherit (self.packages.${final.system}) frind;
};
};
}

4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "beta"
components = ["rustfmt", "clippy", "rust-src", "rust-analyzer"]
profile = "minimal"

0 comments on commit 2d021f7

Please sign in to comment.