From 25db37406f3f9e81c6bef840c5aae57d2aaccfff Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 17 Jan 2021 10:17:42 +0530 Subject: convert to nix flake --- .gitignore | 2 ++ flake.lock | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 46 +++++++++++++++++++++++++++++++ shell.nix | 11 -------- 4 files changed, 139 insertions(+), 11 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index c4f4e38..0e9a52c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ *.vim .envrc +.direnv +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6aa7a69 --- /dev/null +++ b/flake.lock @@ -0,0 +1,91 @@ +{ + "nodes": { + "mozillapkgs": { + "flake": false, + "locked": { + "lastModified": 1603906276, + "narHash": "sha256-RsNPnEKd7BcogwkqhaV5kI/HuNC4flH/OQCC/4W5y/8=", + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "rev": "8c007b60731c07dd7a052cce508de3bb1ae849b4", + "type": "github" + }, + "original": { + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1610392286, + "narHash": "sha256-3wFl5y+4YZO4SgRYK8WE7JIS3p0sxbgrGaQ6RMw+d98=", + "owner": "nmattia", + "repo": "naersk", + "rev": "d7bfbad3304fd768c0f93a4c3b50976275e6d4be", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1610850544, + "narHash": "sha256-6GnsJuulJNdSrZNP98rRTRX/zJbxdC7m3qaH6WwsOuY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fbc36f3d891c86ae34dc0414bc78e74e8911218", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1610850544, + "narHash": "sha256-6GnsJuulJNdSrZNP98rRTRX/zJbxdC7m3qaH6WwsOuY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fbc36f3d891c86ae34dc0414bc78e74e8911218", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "mozillapkgs": "mozillapkgs", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1610051610, + "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a046490 --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + inputs = { + utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nmattia/naersk"; + mozillapkgs = { + url = "github:mozilla/nixpkgs-mozilla"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, utils, naersk, mozillapkgs }: + utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages."${system}"; + + # Get a specific rust version + mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") {}; + rust = (mozilla.rustChannelOf { + date = "2020-12-23"; + channel = "nightly"; + sha256 = "LbKHsCOFXWpg/SEyACfzZuWjKbkXdH6EJKOPSGoO01E="; # set zeros after modifying channel or date + }).rust; + + naersk-lib = naersk.lib."${system}".override { + cargo = rust; + rustc = rust; + }; + in rec { + packages.my-project = naersk-lib.buildPackage { + pname = "dijo"; + root = ./.; + }; + defaultPackage = packages.my-project; + apps.my-project = utils.lib.mkApp { + drv = packages.my-project; + }; + defaultApp = apps.my-project; + devShell = pkgs.mkShell { + nativeBuildInputs = [ + rust + pkgs.cargo + pkgs.cargo + pkgs.ncurses + ]; + }; + }); + } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index f6e0283..0000000 --- a/shell.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - name = "rust-env"; - nativeBuildInputs = with pkgs; [ - rustc cargo - ]; - buildInputs = with pkgs; [ ncurses openssl ]; - - RUST_BACKTRACE = 1; -} -- cgit v1.2.3