nix: add flake

This commit is contained in:
Bruno BELANYI 2021-10-08 14:30:53 +02:00
parent 6a1f55d420
commit 962b762909
2 changed files with 190 additions and 0 deletions

69
flake.lock Normal file
View file

@ -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
}

121
flake.nix Normal file
View file

@ -0,0 +1,121 @@
{
description = "A CLI drag-and-drop tool";
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.0.0";
src = self;
buildInputs = [
libsForQt5.qt5.qtbase
];
nativeBuildInputs = [
libsForQt5.qt5.wrapQtAppsHook
];
configurePhase = ''
qmake
'';
installPhase = ''
mkdir -p $out/bin
cp dragger $out/bin
'';
meta = with lib; {
description = "A CLI drag-and-drop tool";
homepage = "https://gitea.belanyi.fr/ambroisie/dragger";
license = licenses.mit;
maintainers = [ ambroisie ];
platforms = platforms.all;
};
};
};
};
}