From 1c85aca12069bd39a7ee51d165c969e0c95732c8 Mon Sep 17 00:00:00 2001 From: Max Niederman Date: Wed, 24 Apr 2024 22:44:31 -0700 Subject: [PATCH] build: run nix builds with a nightly compiler and add devshell --- .envrc | 1 + .gitignore | 5 ++++ flake.lock | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++--- flake.nix | 26 +++++++++++++++--- garnix.yaml | 3 ++- 5 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore index ea8c4bf..234ef27 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ /target + +result +result-* + +.direnv \ No newline at end of file diff --git a/flake.lock b/flake.lock index 5ced86a..595770b 100644 --- a/flake.lock +++ b/flake.lock @@ -201,6 +201,24 @@ "type": "github" } }, + "flake-utils_5": { + "inputs": { + "systems": "systems_5" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -271,15 +289,31 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1713926177, - "narHash": "sha256-AFgpVLDaAgdpNjUtzzUjXJLLv+pXAqJwaSzpyr/5j2Q=", + "lastModified": 1714015586, + "narHash": "sha256-eQNuqOC59bf21QOrP62aUldtNAUVG/VbNuA1EhBwa9s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f9565232ec31ebd4318de09b46366cab1ccb8914", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1c108068d22f4e386d0bea43e328890d6dd59228", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -319,7 +353,27 @@ "inputs": { "crate2nix": "crate2nix", "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_3", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1714011248, + "narHash": "sha256-vKk9IOxZJ52Ao3uIRIjHRYYe+IpVOY6NzwToSxaO1J0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "9a2a11479b94afaf1ecc46384b27abda0d3d5f9d", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "systems": { @@ -381,6 +435,21 @@ "repo": "default", "type": "github" } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 198efde..021c717 100644 --- a/flake.nix +++ b/flake.nix @@ -5,16 +5,36 @@ nixpkgs.url = "github:NixOS/nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; crate2nix.url = "github:nix-community/crate2nix"; + rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = { self, nixpkgs, flake-utils, crate2nix }: + nixConfig = { + extra-trusted-public-keys = "eigenvalue.cachix.org-1:ykerQDDa55PGxU25CETy9wF6uVDpadGGXYrFNJA3TUs="; + extra-substituters = "https://eigenvalue.cachix.org"; + allow-import-from-derivation = true; + }; + + outputs = { self, nixpkgs, flake-utils, crate2nix, rust-overlay }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; - cargoNix = crate2nix.tools.${system}.appliedCargoNix { + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + }; + + rust = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default); + + cargoNixPath = crate2nix.tools.${system}.generatedCargoNix { name = "centipede"; src = ./.; }; + cargoNix = import cargoNixPath { + inherit pkgs; + buildRustCrateForPkgs = pkgs: pkgs.buildRustCrate.override { + cargo = rust; + rustc = rust; + }; + }; in { checks = { diff --git a/garnix.yaml b/garnix.yaml index 7ca5785..b01ca30 100644 --- a/garnix.yaml +++ b/garnix.yaml @@ -1,3 +1,4 @@ builds: include: - - packages.*.* \ No newline at end of file + - packages.*.* + - checks.*.* \ No newline at end of file