From b3aab86e8a4746d14a29b6ea377d28f41f39c1af Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 2 Nov 2022 21:49:16 +0100 Subject: [PATCH] nixify --- flake.lock | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 47 +++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c0488c4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,101 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1667370833, + "narHash": "sha256-Xqfhr+G34C6YkcwUPFYVTMN+Sbjog14XBbx7ohe/pX4=", + "owner": "nix-community", + "repo": "fenix", + "rev": "5fe1e430e990d5b0715f82dbd8b6c0cb7086c7e1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1662220400, + "narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=", + "owner": "nmattia", + "repo": "naersk", + "rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1667292599, + "narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ef2f213d9659a274985778bff4ca322f3ef3ac68", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "naersk": "naersk", + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1667322067, + "narHash": "sha256-PmIrDg9fAZl0XYlSdwMqhutIQxsQpP5YVEiaBeI3NB8=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "c1305fa5d92640ce847dc8e6aeefd53cb6302dbf", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "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..c29b86f --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + inputs = { + utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nmattia/naersk"; + naersk.inputs.nixpkgs.follows = "nixpkgs"; + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, utils, fenix, naersk }: { + # nixosModule = self.nixosModules.caveman; + # nixosModules.caveman = import ./nixos-module.nix { inherit self; }; + } // + utils.lib.eachSystem (with utils.lib.system; [ x86_64-linux aarch64-linux ]) (system: let + pkgs = nixpkgs.legacyPackages.${system}; + + rust = fenix.packages.${system}.stable.withComponents [ + "cargo" + "rustc" + "rust-src" # just for rust-analyzer + "clippy" + ]; + + # Override the version used in naersk + naersk-lib = naersk.lib."${system}".override { + cargo = rust; + rustc = rust; + }; + + in rec { + packages.default = self.packages.${system}.caveman; + + packages.caveman = naersk-lib.buildPackage { + src = ./.; + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ openssl ]; + }; + + # `nix develop` + devShells.default = pkgs.mkShell { + nativeBuildInputs = [ + fenix.packages.${system}.rust-analyzer + ] ++ + (with packages.default; nativeBuildInputs ++ buildInputs); + }; + }); +}