From f782f94292b7126a30dc76e9017181704b5f1a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Tue, 1 Feb 2022 11:57:30 +0100 Subject: [PATCH] build: Add cargo2nix --- .gitignore | 1 + Cargo.lock | 7 ++++ Cargo.nix | 47 +++++++++++++++++++++++++++ Cargo.toml | 8 +++++ flake.lock | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 37 +++++++++++++++++++++ src/main.rs | 3 ++ 7 files changed, 197 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.nix create mode 100644 Cargo.toml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..0e593c7 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "fdidx" +version = "0.1.0" diff --git a/Cargo.nix b/Cargo.nix new file mode 100644 index 0000000..5d4b3dd --- /dev/null +++ b/Cargo.nix @@ -0,0 +1,47 @@ +# This file was @generated by cargo2nix 0.10.0. +# It is not intended to be manually edited. + +args@{ + release ? true, + rootFeatures ? [ + "fdidx/default" + ], + rustPackages, + buildRustPackages, + hostPlatform, + hostPlatformCpu ? null, + hostPlatformFeatures ? [], + target ? null, + codegenOpts ? null, + profileOpts ? null, + mkRustCrate, + rustLib, + lib, + workspaceSrc, +}: +let + workspaceSrc = if args.workspaceSrc == null then ./. else args.workspaceSrc; +in let + inherit (rustLib) fetchCratesIo fetchCrateLocal fetchCrateGit fetchCrateAlternativeRegistry expandFeatures decideProfile genDrvsByProfile; + profilesByName = { + }; + rootFeatures' = expandFeatures rootFeatures; + overridableMkRustCrate = f: + let + drvs = genDrvsByProfile profilesByName ({ profile, profileName }: mkRustCrate ({ inherit release profile hostPlatformCpu hostPlatformFeatures target profileOpts codegenOpts; } // (f profileName))); + in { compileMode ? null, profileName ? decideProfile compileMode release }: + let drv = drvs.${profileName}; in if compileMode == null then drv else drv.override { inherit compileMode; }; +in +{ + cargo2nixVersion = "0.10.0"; + workspace = { + fdidx = rustPackages.unknown.fdidx."0.1.0"; + }; + "unknown".fdidx."0.1.0" = overridableMkRustCrate (profileName: rec { + name = "fdidx"; + version = "0.1.0"; + registry = "unknown"; + src = fetchCrateLocal workspaceSrc; + }); + +} diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..571571a --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "fdidx" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7356edb --- /dev/null +++ b/flake.lock @@ -0,0 +1,94 @@ +{ + "nodes": { + "cargo2nix": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": [ + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1638423893, + "narHash": "sha256-+NTV613zwK1G4UIKrj0gh1fYDvi85qO0wxy6h11azuY=", + "owner": "cargo2nix", + "repo": "cargo2nix", + "rev": "ae8a5e699f57b446f9507b97a3c97a4e9fe06aa3", + "type": "github" + }, + "original": { + "owner": "cargo2nix", + "ref": "master", + "repo": "cargo2nix", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1643652773, + "narHash": "sha256-g16mlg5N6i80Cdu6gkuOhWmHX8ocpb2kCPpRmR+Qzx8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4b39f7108f1f066646754d54dbae46bcb836f11c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "cargo2nix": "cargo2nix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1642838864, + "narHash": "sha256-pHnhm3HWwtvtOK7NdNHwERih3PgNlacrfeDwachIG8E=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "9fb49daf1bbe1d91e6c837706c481f9ebb3d8097", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ffb978b --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + inputs = { + nixpkgs.url = github:NixOS/nixpkgs; + cargo2nix.url = "github:cargo2nix/cargo2nix/master"; + cargo2nix.inputs.nixpkgs.follows = "nixpkgs"; + cargo2nix.inputs.flake-utils.follows = "flake-utils"; + cargo2nix.inputs.rust-overlay.follows = "rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; + rust-overlay.inputs.flake-utils.follows = "flake-utils"; + }; + outputs = { self, nixpkgs, cargo2nix, flake-utils, rust-overlay, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ + cargo2nix.overlay.${system} + rust-overlay.overlay + ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + rustPkgs = pkgs.rustBuilder.makePackageSet' { + packageFun = import ./Cargo.nix; + rustChannel = "1.58.1"; + packageOverrides = pkgs: pkgs.rustBuilder.overrides.all; + }; + in + rec { + devShell = rustPkgs.workspaceShell { }; + + packages = { + shell = devShell; + }; + } + ); +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}