mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-24 15:18:53 +00:00
nix: replace manual system iteration by flake-utils
Let's not reinvent the wheel. This makes the flake more readable, and also would detect typos in the system list.
This commit is contained in:
parent
3c0eb21ed1
commit
29db607e10
2 changed files with 25 additions and 20 deletions
11
flake.lock
generated
11
flake.lock
generated
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -31,13 +31,16 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
|
|
34
flake.nix
34
flake.nix
|
@ -1,30 +1,32 @@
|
|||
{
|
||||
description = "jujutsu";
|
||||
description = "Jujutsu VCS, a Git-compatible DVCS that is both simple and powerful";
|
||||
|
||||
inputs = {
|
||||
# For listing and iterating nix systems
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# For installing non-standard rustc versions
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.inputs.flake-utils.follows = "flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, ... }:
|
||||
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
"i686-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
systems = with flake-utils.lib.system; [
|
||||
aarch64-linux
|
||||
aarch64-darwin
|
||||
i686-linux
|
||||
x86_64-darwin
|
||||
x86_64-linux
|
||||
];
|
||||
foreachSystem = f: lib.foldl' (attrs: system: lib.recursiveUpdate attrs (f system)) { } systems;
|
||||
in
|
||||
{
|
||||
overlays.default = (final: prev: {
|
||||
jujutsu = self.packages.${final.system}.jujutsu;
|
||||
});
|
||||
} //
|
||||
(foreachSystem (system:
|
||||
(flake-utils.lib.eachSystem systems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
|
@ -34,7 +36,7 @@
|
|||
};
|
||||
in
|
||||
{
|
||||
packages.${system} = {
|
||||
packages = {
|
||||
jujutsu = pkgs.rustPlatform.buildRustPackage rec {
|
||||
pname = "jujutsu";
|
||||
version = "unstable-${self.shortRev or "dirty"}";
|
||||
|
@ -70,19 +72,19 @@
|
|||
};
|
||||
default = self.packages.${system}.jujutsu;
|
||||
};
|
||||
apps.${system}.default = {
|
||||
apps.default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.jujutsu}/bin/jj";
|
||||
};
|
||||
checks.${system}.jujutsu = self.packages.${system}.jujutsu.overrideAttrs ({ ... }: {
|
||||
checks.jujutsu = self.packages.${system}.jujutsu.overrideAttrs ({ ... }: {
|
||||
cargoBuildType = "debug";
|
||||
cargoCheckType = "debug";
|
||||
preCheck = ''
|
||||
export RUST_BACKTRACE=1
|
||||
'';
|
||||
});
|
||||
formatter.${system} = pkgs.nixpkgs-fmt;
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
# Using the minimal profile with explicit "clippy" extension to avoid
|
||||
# two versions of rustfmt
|
||||
|
|
Loading…
Reference in a new issue