From 6a97fade36281346cafc73a52793603da276bc07 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 8 Oct 2021 14:30:53 +0200 Subject: [PATCH] nix: add flake --- flake.lock | 69 +++++++++++++++++++++++++++++++++ flake.nix | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 181 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..00c49b4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,69 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "owner": "numtide", + "ref": "master", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1633329294, + "narHash": "sha256-0LpQLS4KMgxslMgmDHmxG/5twFlXDBW9z4Or1iOrCvU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ee084c02040e864eeeb4cf4f8538d92f7c675671", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1631170176, + "narHash": "sha256-RLN/kur2Kpxt0cJp0Fms8ixuGpT8IHX0OpeQ8u8f0X4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "3ed0e618cebc1ff291c27b749cf7568959cac028", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "master", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..42cfda1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,112 @@ +{ + description = "A simple calculator"; + + inputs = { + flake-utils = { + type = "github"; + owner = "numtide"; + repo = "flake-utils"; + ref = "master"; + }; + + nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixpkgs-unstable"; + }; + + pre-commit-hooks = { + type = "github"; + owner = "cachix"; + repo = "pre-commit-hooks.nix"; + ref = "master"; + inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = + { self + , flake-utils + , nixpkgs + , pre-commit-hooks + }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + }; + in + rec { + apps = { + dragger = flake-utils.lib.mkApp { drv = packages.dragger; }; + }; + + checks = { + pre-commit = pre-commit-hooks.lib.${system}.run { + src = self; + + hooks = { + clang-format = { + enable = true; + name = "clang-format"; + entry = "${pkgs.clang-tools}/bin/clang-format -style=file -i"; + types = [ "text" "c++" ]; + language = "system"; + }; + + nixpkgs-fmt = { + enable = true; + }; + }; + }; + }; + + defaultApp = apps.dragger; + + defaultPackage = packages.dragger; + + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ ] + ++ defaultPackage.nativeBuildInputs + ++ defaultPackage.buildInputs + ; + + inherit (checks.pre-commit) shellHook; + }; + + packages = { + inherit (pkgs) dragger; + }; + }) // { + overlay = final: prev: { + dragger = with final; stdenv.mkDerivation { + pname = "dragger"; + version = "0.1.0"; + + src = self; + + buildInputs = [ + libsForQt5.qt5.qtbase + ]; + nativeBuildInputs = [ + libsForQt5.qt5.wrapQtAppsHook + ]; + + configurePhase = '' + qmake + ''; + + installPhase = '' + mkdir -p $out/bin + cp dragger $out/bin + ''; + }; + }; + }; +}