build: Add cargo2nix

This commit is contained in:
Charlotte 🦝 Delenk 2022-02-01 11:57:30 +01:00
parent 760312e834
commit f782f94292
Signed by: darkkirb
GPG key ID: 015E3768A70AFBC5
7 changed files with 197 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View file

@ -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"

47
Cargo.nix Normal file
View file

@ -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;
});
}

8
Cargo.toml Normal file
View file

@ -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]

94
flake.lock Normal file
View file

@ -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
}

37
flake.nix Normal file
View file

@ -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;
};
}
);
}

3
src/main.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}