From 09b9574bbf6f66421aead94b2af58e1123305ff1 Mon Sep 17 00:00:00 2001 From: Michal S Date: Mon, 5 Sep 2022 21:49:56 +0100 Subject: [PATCH 1/2] Fix flake.nix and update flake.lock --- flake.lock | 18 +++++++++--------- flake.nix | 20 ++++++-------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/flake.lock b/flake.lock index c0638ca..e0e49f0 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1659610603, - "narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=", + "lastModified": 1662220400, + "narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=", "owner": "nix-community", "repo": "naersk", - "rev": "c6a45e4277fa58abd524681466d3450f896dc094", + "rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1660551188, - "narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=", + "lastModified": 1662096612, + "narHash": "sha256-R+Q8l5JuyJryRPdiIaYpO5O3A55rT+/pItBrKcy7LM4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65", + "rev": "21de2b973f9fee595a7a1ac4693efff791245c34", "type": "github" }, "original": { @@ -34,11 +34,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1660566196, - "narHash": "sha256-mjObRMshcxAyK7J5ZJ5/nP0uEu8Ym5trrVsj1253nUc=", + "lastModified": 1662410893, + "narHash": "sha256-jmZjdA/n92OpUdaEjU7QJNsa1np+u+JWDj300x3K3XY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "07a564964c0dfb1fa15f9be701b2fba55b252a9d", + "rev": "680818a51b7fb6886db8900e2fb1582305b45f77", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e7601f6..b0a4131 100644 --- a/flake.nix +++ b/flake.nix @@ -12,23 +12,18 @@ naersk-lib = naersk.lib."${system}"; in rec { - packages.amethyst = naersk-lib.buildPackage { - pname = "ame"; + packages.jade = naersk-lib.buildPackage { + pname = "jade"; root = ./.; - nativeBuildInputs = with pkgs; [ - openssl - sqlite - pkg-config - ]; }; - packages.default = packages.amethyst; + packages.default = packages.jade; - apps.amethyst = utils.lib.mkApp { - drv = packages.amethyst; + apps.jade = utils.lib.mkApp { + drv = packages.jade; }; - apps.default = apps.amethyst; + apps.default = apps.jade; devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ @@ -37,9 +32,6 @@ rustfmt cargo-audit clippy - openssl - sqlite - pkg-config ]; }; }); From 500600cb05717502c9edf8a78450571baef56188 Mon Sep 17 00:00:00 2001 From: Michal S Date: Wed, 7 Sep 2022 20:03:48 +0100 Subject: [PATCH 2/2] Various flake improvements --- .envrc | 1 + .gitignore | 2 +- flake.lock | 59 ++++++++++++++++++++++++++---------- flake.nix | 88 +++++++++++++++++++++++++++++++++++------------------- 4 files changed, 103 insertions(+), 47 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 869df07..1edb211 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /target -Cargo.lock \ No newline at end of file +/.direnv \ No newline at end of file diff --git a/flake.lock b/flake.lock index e0e49f0..426d108 100644 --- a/flake.lock +++ b/flake.lock @@ -1,8 +1,31 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1662533965, + "narHash": "sha256-56td0N02VeIOuzyesNWLCwTcoVwP0wuQauUbzh6RpMg=", + "owner": "nix-community", + "repo": "fenix", + "rev": "b5b70debeb3c2f93186eaed7de13674b9783b9d2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "naersk": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1662220400, @@ -19,20 +42,6 @@ } }, "nixpkgs": { - "locked": { - "lastModified": 1662096612, - "narHash": "sha256-R+Q8l5JuyJryRPdiIaYpO5O3A55rT+/pItBrKcy7LM4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "21de2b973f9fee595a7a1ac4693efff791245c34", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1662410893, "narHash": "sha256-jmZjdA/n92OpUdaEjU7QJNsa1np+u+JWDj300x3K3XY=", @@ -49,11 +58,29 @@ }, "root": { "inputs": { + "fenix": "fenix", "naersk": "naersk", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "utils": "utils" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1662377094, + "narHash": "sha256-0bvOQxEe8nzk/VlhHBrUn/Mz3DlE92Us7JqveVjTe0A=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "6dfd8aebdfa1ee1824446f01daf5bdb229b32f92", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1659877975, diff --git a/flake.nix b/flake.nix index b0a4131..f332f15 100644 --- a/flake.nix +++ b/flake.nix @@ -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; + }); +}