feat(nix): align Flakes setup with other repositories

This commit is contained in:
Harsh Shandilya 2023-07-01 13:05:32 +05:30
parent f8daba4de4
commit 6a9d08388b
No known key found for this signature in database
3 changed files with 89 additions and 55 deletions

View File

@ -43,6 +43,29 @@
"type": "github" "type": "github"
} }
}, },
"devshell": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1687944744,
"narHash": "sha256-4ZtRVG/5yWHPZpkit1Ak5Mo1DDnkx1AG1HpNu/P+n5U=",
"owner": "numtide",
"repo": "devshell",
"rev": "3864857b2754ab0e16c7c7c626f0e5a1d4e42f38",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"fenix": { "fenix": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -67,15 +90,15 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1673956053, "lastModified": 1688025799,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "narHash": "sha256-ktpB4dRtnksm9F5WawoIkEneh1nrEvuxb5lJFt1iOyw=",
"owner": "edolstra", "owner": "nix-community",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "rev": "8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "edolstra", "owner": "nix-community",
"repo": "flake-compat", "repo": "flake-compat",
"type": "github" "type": "github"
} }
@ -115,10 +138,12 @@
"inputs": { "inputs": {
"advisory-db": "advisory-db", "advisory-db": "advisory-db",
"crane": "crane", "crane": "crane",
"devshell": "devshell",
"fenix": "fenix", "fenix": "fenix",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"systems": "systems"
} }
}, },
"rust-analyzer-src": { "rust-analyzer-src": {
@ -162,6 +187,21 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1687694171,
"narHash": "sha256-m4E0xN69qKj/oKOj8OtiZcSFpFlO8paI6E3Wo5oXDJc=",
"owner": "msfjarvis",
"repo": "flake-systems",
"rev": "7876462a5f60841e8b2712ad20dc18470f448e8d",
"type": "github"
},
"original": {
"owner": "msfjarvis",
"repo": "flake-systems",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -1,53 +1,50 @@
{ {
description = "text-editor"; description = "text-editor";
inputs = { inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs = {url = "github:NixOS/nixpkgs/nixpkgs-unstable";};
fenix = { inputs.systems.url = "github:msfjarvis/flake-systems";
url = "github:nix-community/fenix";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
flake-utils = {url = "github:numtide/flake-utils";}; inputs.advisory-db.url = "github:rustsec/advisory-db";
inputs.advisory-db.flake = false;
flake-compat = { inputs.crane.url = "github:ipetkov/crane";
url = "github:edolstra/flake-compat"; inputs.crane.inputs.flake-compat.follows = "flake-compat";
flake = false; inputs.crane.inputs.flake-utils.follows = "flake-utils";
}; inputs.crane.inputs.nixpkgs.follows = "nixpkgs";
crane = { inputs.devshell.url = "github:numtide/devshell";
url = "github:ipetkov/crane"; inputs.devshell.inputs.nixpkgs.follows = "nixpkgs";
inputs = { inputs.devshell.inputs.systems.follows = "systems";
flake-compat.follows = "flake-compat";
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
advisory-db = { inputs.fenix.url = "github:nix-community/fenix";
url = "github:rustsec/advisory-db"; inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
flake = false;
}; inputs.flake-utils.url = "github:numtide/flake-utils";
}; inputs.flake-utils.inputs.systems.follows = "systems";
inputs.flake-compat.url = "github:nix-community/flake-compat";
inputs.flake-compat.flake = false;
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
fenix,
crane,
flake-utils,
advisory-db, advisory-db,
crane,
devshell,
fenix,
flake-utils,
... ...
}: }:
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;}; pkgs = import nixpkgs {
inherit system;
overlays = [devshell.overlays.default];
};
rustStable = (import fenix {inherit pkgs;}).fromToolchainFile { rustStable = (import fenix {inherit pkgs;}).fromToolchainFile {
file = ./rust-toolchain.toml; file = ./rust-toolchain.toml;
sha256 = "sha256-eMJethw5ZLrJHmoN2/l0bIyQjoTX1NsvalWSscTixpI="; sha256 = "sha256-gdYqng0y9iHYzYPAdkC/ka3DRny3La/S5G8ASj0Ayyc=";
}; };
craneLib = (crane.mkLib pkgs).overrideToolchain rustStable; craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
@ -66,32 +63,29 @@
}); });
text-editor-fmt = craneLib.cargoFmt (commonArgs // {}); text-editor-fmt = craneLib.cargoFmt (commonArgs // {});
text-editor-audit = craneLib.cargoAudit (commonArgs // {inherit advisory-db;}); text-editor-audit = craneLib.cargoAudit (commonArgs // {inherit advisory-db;});
text-editor-nextest = craneLib.cargoNextest (commonArgs
// {
inherit cargoArtifacts;
src = ./.;
partitions = 1;
partitionType = "count";
});
in { in {
checks = { checks = {
inherit text-editor text-editor-audit text-editor-clippy text-editor-fmt text-editor-nextest; inherit text-editor text-editor-audit text-editor-clippy text-editor-fmt;
}; };
packages.default = text-editor; packages.default = text-editor;
apps.default = flake-utils.lib.mkApp {drv = text-editor;}; apps.default = flake-utils.lib.mkApp {drv = text-editor;};
devShells.default = pkgs.mkShell { devShells.default = pkgs.devshell.mkShell {
inputsFrom = builtins.attrValues self.checks; bash = {interactive = "";};
nativeBuildInputs = with pkgs; [ env = [
cargo-nextest {
cargo-release name = "DEVSHELL_NO_MOTD";
rustStable value = 1;
}
]; ];
CARGO_REGISTRIES_CRATES_IO_PROTOCOL = "sparse"; packages = with pkgs; [
cargo-nextest
rustStable
];
}; };
}); });
} }

View File

@ -1,5 +1,5 @@
[toolchain] [toolchain]
channel = "stable" channel = "1.70.0"
components = [ "clippy", "rustfmt", "rust-src" ] components = ["clippy", "rustfmt", "rust-src"]
targets = [ "x86_64-unknown-linux-gnu" ] targets = ["x86_64-unknown-linux-gnu"]
profile = "minimal" profile = "minimal"