add flake that builds itd and itctl

This commit is contained in:
Vivian Lim 2022-08-13 01:34:55 -07:00
commit cfa0d909f8
2 changed files with 101 additions and 0 deletions

26
itd/flake.lock Normal file
View File

@ -0,0 +1,26 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1660318005,
"narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.05",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

75
itd/flake.nix Normal file
View File

@ -0,0 +1,75 @@
{
description = "A simple Go package";
# Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "nixpkgs/nixos-22.05";
outputs = { self, nixpkgs }:
let
# to work with older version of flakes
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
# Generate a user-friendly version number.
version = builtins.substring 0 8 lastModifiedDate;
# System types to support.
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
# Provide some binary packages for selected system types.
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
itd = pkgs.buildGoModule {
pname = "itd";
inherit version;
# In 'nix develop', we don't need a copy of the source tree
# in the Nix store.
src = pkgs.fetchgit {
url = "https://gitea.arsenm.dev/Arsen6331/itd.git";
rev = "19bacf29b2";
sha256 = "sha256-bitonBODEU5zIhN0mZ1Oe8uyIAkeNgY8YZiq64yCQ7Q=";
};
buildInputs = with pkgs; [ git bluez ];
excludedPackages = [ "itgui" ];
patchPhase = ''
# workaround a bug where $HOME is set to a non-writable dir
export HOME=$(pwd)
export DESTDIR=$(pwd)
make version.txt
'';
# This hash locks the dependencies of this package. It is
# necessary because of how Go requires network access to resolve
# VCS. See https://www.tweag.io/blog/2021-03-04-gomod2nix/ for
# details. Normally one can build with a fake sha256 and rely on native Go
# mechanisms to tell you what the hash should be or determine what
# it should be "out-of-band" with other tooling (eg. gomod2nix).
# To begin with it is recommended to set this, but one must
# remeber to bump this hash when your dependencies change.
#vendorSha256 = pkgs.lib.fakeSha256;
vendorSha256 = "sha256-+dS7wDh0RH9dEmhlOGYqE83Re5AjTtKvidAes+OjCOA=";
};
});
# The default package for 'nix build'. This makes sense if the
# flake provides only one package or there is a clear "main"
# package.
defaultPackage = forAllSystems (system: self.packages.${system}.itd);
};
}