Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Various flake improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal S committed Sep 7, 2022
1 parent 36ae640 commit 306ffc5
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 47 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
Cargo.lock
/.direnv
59 changes: 43 additions & 16 deletions flake.lock

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

88 changes: 58 additions & 30 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,66 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, utils, naersk }:
utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}";
naersk-lib = naersk.lib."${system}";
in rec
{
packages.jade = naersk-lib.buildPackage {
pname = "jade";
root = ./.;
};

packages.default = packages.jade;
outputs = {
self,
nixpkgs,
utils,
naersk,
fenix,
...
}:
utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages."${system}";
toolchain = with fenix.packages."${system}";
combine [
latest.rustc
latest.cargo
latest.clippy
latest.rustfmt
latest.rust-analyzer
latest.rust-src
];
naersk-lib = naersk.lib."${system}".override {
cargo = toolchain;
rustc = toolchain;
clippy = toolchain;
rustfmt = toolchain;
rust-analyzer = toolchain;
rust-src = toolchain;
};
in rec
{
packages.jade = naersk-lib.buildPackage {
pname = "Jade";
root = ./.;
};

apps.jade = utils.lib.mkApp {
drv = packages.jade;
};

apps.default = apps.jade;
packages.default = packages.jade;

devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustc
cargo
rustfmt
cargo-audit
clippy
];
};
});
}
apps.jade = utils.lib.mkApp {
drv = packages.jade;
};

apps.default = apps.jade;

devShells.default = pkgs.mkShell {
nativeBuildInputs = [
toolchain
];
# For rust-analyzer
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};

formatter = pkgs.alejandra;
});
}

0 comments on commit 306ffc5

Please sign in to comment.