From d35c3aa18a125d0d4866dcecf3b3114ac67b83dc Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 30 Oct 2021 01:18:04 +0200 Subject: [PATCH] flakify --- flake.lock | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 131 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..174fc97 --- /dev/null +++ b/flake.lock @@ -0,0 +1,79 @@ +{ + "nodes": { + "mozillapkgs": { + "flake": false, + "locked": { + "lastModified": 1634833229, + "narHash": "sha256-uDbVCkW91/AY87mTwm8XrX2E133LTFqwYsYNNxBcY9M=", + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "rev": "6070a8ee799f629cb1d0004821f77ceed94d3992", + "type": "github" + }, + "original": { + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1635444951, + "narHash": "sha256-1y3YkERwoYDIZjGow7HLAR8K3C/9VBPCBy8VpftMPsM=", + "owner": "nmattia", + "repo": "naersk", + "rev": "0d2ce479df4633dbeb53a8ea96e5098ed37fbcc6", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1635547145, + "narHash": "sha256-qhyl0MMqBal5io91P6Qu7Lb20NM5Y1+2Y4TkUCN1nJQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ecebf0602cb068c784f386dd7f0bbeba57d619e4", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "mozillapkgs": "mozillapkgs", + "naersk": "naersk", + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "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..803932e --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +{ + inputs = { + utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nmattia/naersk"; + mozillapkgs.url = "github:mozilla/nixpkgs-mozilla"; + mozillapkgs.flake = false; + }; + + outputs = { self, nixpkgs, utils, naersk, mozillapkgs }: + utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages."${system}"; + mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") {}; + rust = (mozilla.rustChannelOf { + channel = "stable"; + date = "2021-10-04"; + sha256 = "0swglfa63i14fpgg98agx4b5sz0nckn6phacfy3k6imknsiv8mrg"; + }).rust; + + # Override the version used in naersk + naersk-lib = naersk.lib."${system}".override { + cargo = rust; + rustc = rust; + }; + in rec { + # `nix build` + packages.heliwatch = naersk-lib.buildPackage { + pname = "heliwatch"; + root = builtins.filterSource (path: type: + builtins.elem (baseNameOf path) [ + "src" + "Cargo.toml" + "Cargo.lock" + ] || baseNameOf (dirOf path) == "src" + ) ./.; + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ openssl ]; + }; + defaultPackage = packages.heliwatch; + + # `nix run` + apps.heliwatch = utils.lib.mkApp { + drv = packages.heliwatch; + }; + defaultApp = apps.heliwatch; + + # `nix develop` + devShell = pkgs.mkShell { + nativeBuildInputs = with defaultPackage; + nativeBuildInputs ++ buildInputs; + }; + }); +}