From 308170f655c4dbbeaae9473f732e97037b8f728e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 30 Sep 2023 09:31:51 +0200 Subject: Make repository a flake Signed-off-by: Matthias Beyer --- .gitignore | 1 + flake.lock | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 105 +++++++++++++++++++++++++++++++++++ 3 files changed, 288 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index b10a97a..c015882 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target +/result* .idea .vscode .test-projects diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4e7da36 --- /dev/null +++ b/flake.lock @@ -0,0 +1,182 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1695511445, + "narHash": "sha256-mnE14re43v3/Jc50Jv0BKPMtEk7FEtDSligP6B5HwlI=", + "owner": "ipetkov", + "repo": "crane", + "rev": "3de322e06fc88ada5e3589dc8a375b73e749f512", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1695825837, + "narHash": "sha256-4Ne11kNRnQsmSJCRSSNkFRSnHC4Y5gPDBIQGjjPfJiU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5cfafa12d57374f48bcc36fda3274ada276cf69e", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-23.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay_2" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1695003086, + "narHash": "sha256-d1/ZKuBRpxifmUf7FaedCqhy0lyVbqj44Oc2s+P5bdA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "b87a14abea512d956f0b89d0d8a1e9b41f3e20ff", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1696039808, + "narHash": "sha256-7TbAr9LskWG6ISPhUdyp6zHboT7FsFrME5QsWKybPTA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "a4c3c904ab29e04a20d3a6da6626d66030385773", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "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", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..037d269 --- /dev/null +++ b/flake.nix @@ -0,0 +1,105 @@ +{ + description = "The pixi package manager"; + inputs = { + nixpkgs.url = "nixpkgs/nixos-23.05"; + flake-utils.url = "github:numtide/flake-utils"; + crane = { + url = "github:ipetkov/crane"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + }; + + outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; + + rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustTarget; + tomlInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; }; + src = pkgs.nix-gitignore.gitignoreSource [ ] ./.; + + cargoArtifacts = craneLib.buildDepsOnly { + inherit src; + inherit (tomlInfo) pname version; + + buildInputs = [ + pkgs.pkg-config + pkgs.openssl + pkgs.cmake + ]; + }; + + pixi = craneLib.buildPackage { + inherit cargoArtifacts src; + inherit (tomlInfo) pname version; + + cargoExtraArgs = "--all-features"; + + buildInputs = [ + pkgs.pkg-config + pkgs.openssl + pkgs.cmake + ]; + + doCheck = false; + }; + in + rec { + checks = { + inherit pixi; + + pixi-clippy = craneLib.cargoClippy { + inherit cargoArtifacts src; + inherit (tomlInfo) pname version; + cargoClippyExtraArgs = "--benches --examples --tests --all-features -- --deny warnings"; + }; + + pixi-clippy-no-features = craneLib.cargoClippy { + inherit cargoArtifacts src; + inherit (tomlInfo) pname version; + cargoClippyExtraArgs = "--benches --examples --tests --no-default-features -- --deny warnings"; + }; + + pixi-fmt = craneLib.cargoFmt { + inherit cargoArtifacts src; + inherit (tomlInfo) pname version; + }; + }; + + packages = { + default = packages.pixi; + inherit pixi; + }; + + apps = { + pixi = inputs.flake-utils.lib.mkApp { + drv = pixi; + }; + }; + + devShells.default = devShells.pixi; + devShells.pixi = pkgs.mkShell { + buildInputs = [ + pkgs.pkg-config + pkgs.openssl + pkgs.cmake + ]; + + nativeBuildInputs = [ + rustTarget + ]; + }; + } + ); +} -- cgit v1.2.3