Try crate2nix (#3)

* WIP

* Fix and add gitignore

* Finish it
This commit is contained in:
Sridhar Ratnakumar 2021-04-07 22:39:02 -04:00 committed by GitHub
parent 75b9ec55c2
commit 92d9de855a
Failed to generate hash of commit
2 changed files with 52 additions and 97 deletions

View file

@ -1,5 +1,22 @@
{
"nodes": {
"crate2nix": {
"flake": false,
"locked": {
"lastModified": 1608814925,
"narHash": "sha256-GdFBG2LmpbY4C1OJBFfWLMKXzGyFq4mJBK+SVMNNE+8=",
"owner": "balsoft",
"repo": "crate2nix",
"rev": "68be3d90f31bf0bfd525da77e0ae6e89f48abd24",
"type": "github"
},
"original": {
"owner": "balsoft",
"ref": "tools-nix-version-comparison",
"repo": "crate2nix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -16,54 +33,23 @@
"type": "github"
}
},
"flake-utils": {
"gitignore": {
"flake": false,
"locked": {
"lastModified": 1614513358,
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
"lastModified": 1611672876,
"narHash": "sha256-qHu3uZ/o9jBHiA3MEKHJ06k7w4heOhA+4HCSIvflRxo=",
"owner": "hercules-ci",
"repo": "gitignore",
"rev": "211907489e9f198594c0eb0ca9256a1949c9d412",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1614785451,
"narHash": "sha256-TPw8kQvr2UNCuvndtY+EjyXp6Q5GEW2l9UafXXh1XmI=",
"owner": "nmattia",
"repo": "naersk",
"rev": "e0fe990b478a66178a58c69cf53daec0478ca6f9",
"type": "github"
},
"original": {
"owner": "nmattia",
"repo": "naersk",
"owner": "hercules-ci",
"repo": "gitignore",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1617833390,
"narHash": "sha256-puAjU8RcmfqrPYnOuDvESPgA+QtaszUKJZ7jrjnk7iU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "87df3e15f029f44a3dca474907a3c02bcbe03414",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1617636226,
"narHash": "sha256-iZhBWrOR2DoDs1C+0FlnM9AQLMol/qoGQ+d+S43CKJM=",
@ -79,49 +65,15 @@
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1617325113,
"narHash": "sha256-GksR0nvGxfZ79T91UUtWjjccxazv6Yh/MvEJ82v1Xmw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "54c1e44240d8a527a8f4892608c4bce5440c3ecb",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"crate2nix": "crate2nix",
"flake-compat": "flake-compat",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1617762447,
"narHash": "sha256-bv1e5VRZnSswnVtBH2Nc1omInZSRgASsS8xO+Fg9whc=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "08263e3fa955acbcb6612c00d920d45e517b242d",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1617631617,

View file

@ -3,43 +3,46 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nmattia/naersk";
gitignore = {
url = "github:hercules-ci/gitignore";
flake=false;
};
crate2nix = {
url = "github:balsoft/crate2nix/tools-nix-version-comparison";
flake = false;
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, utils, rust-overlay, naersk, ... }:
outputs = { self, nixpkgs, utils, gitignore, crate2nix, ... }:
utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlay
(self: super: {
# Because rust-overlay bundles multple rust packages into one
# derivation, specify that mega-bundle here, so that naersk
# will use them automatically.
rustc = self.rust-bin.stable.latest.default;
cargo = self.rust-bin.stable.latest.default;
})
];
pkgs = import nixpkgs { inherit system; };
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; })
generatedCargoNix;
inherit (import gitignore { inherit (pkgs) lib; }) gitignoreSource;
project = pkgs.callPackage (generatedCargoNix {
name = "bouncy";
src = gitignoreSource ./.;
}) {
# Individual crate overrides go here
# Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50
};
naersk-lib = naersk.lib."${system}";
packages = builtins.mapAttrs (name: member: member.build) project.workspaceMembers;
in rec {
inherit packages;
# `nix build`
packages.bouncy = naersk-lib.buildPackage {
pname = "bouncy";
root = ./.;
};
defaultPackage = packages.bouncy;
# `nix run`
apps.bouncy = utils.lib.mkApp {
name = "bouncy";
drv = packages.bouncy;
};
defaultApp = apps.bouncy;