Write a Nix expression for building the binary

Update the tooling as well
This commit is contained in:
Vojtěch Káně
2021-04-20 12:09:19 +02:00
parent 688f87922d
commit de7b9072ef
3 changed files with 1820 additions and 7 deletions

1803
deps.nix Normal file

File diff suppressed because it is too large Load Diff

8
flake.lock generated
View File

@@ -2,16 +2,16 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1611053426,
"narHash": "sha256-ZYcn9Jz7S3Ib3PPcPsn6lE9HGtH5ofacOYsu/puZd9o=",
"lastModified": 1618886496,
"narHash": "sha256-kbNz7N1/3L94Inco0F6avWd65pn1dcOX/xccNdVf+nY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "646f528cce6db1f89f6e635a7589bf1be6169ffb",
"rev": "b1476f41ec26c72f23fa617141a653484b319b89",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-20.09",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}

View File

@@ -1,15 +1,25 @@
{
description = "Tinyquiz an open source online quiz platform";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.09";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
buildCmd = name:
(pkgs.buildGoPackage {
pname = "tinyquiz-${name}";
version = "dev";
src = ./.;
goDeps = ./deps.nix;
preBuild = "go generate vkane.cz/tinyquiz/...";
goPackagePath = "vkane.cz/tinyquiz";
subPackages = [ "cmd/${name}" ];
});
in
{
defaultPackage.x86_64-linux = self.packages.x86_64-linux.tinyquiz;
packages.x86_64-linux.tinyquiz = pkgs.hello; # TODO
defaultPackage.x86_64-linux = self.packages.x86_64-linux.tinyquiz-web;
packages.x86_64-linux.tinyquiz-web = buildCmd "web";
packages.x86_64-linux.dev = pkgs.writeShellScriptBin "dev" ''
echo "This dev script must be run from the project root, otherwise unexpected behavior might occur."
read -p "Are you in the right directory and shall I continue? (y/n): " ack