surtur
4b6e655ebf
All checks were successful
continuous-integration/drone/push Build is passing
* add 'version' command - "go-xkcdreader version" returns a formatted version of the app * test (among other things) that the version in flake.nix matches the version hardcoded in app's go code (cmd/version.go)
167 lines
5.0 KiB
Nix
167 lines
5.0 KiB
Nix
{
|
|
description = "an offline-capable xkcd webcomic reader written in Go";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
nixgl.url = "github:guibou/nixGL";
|
|
nixgl.inputs.nixpkgs.follows = "nixpkgs";
|
|
flake-compat = {
|
|
url = "github:edolstra/flake-compat";
|
|
flake = false;
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixgl, 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;
|
|
version = "v0.0.0";
|
|
|
|
# System types to support.
|
|
supportedSystems =
|
|
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
|
|
|
# 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; overlays = [ ]; });
|
|
in
|
|
rec {
|
|
packages = forAllSystems (system:
|
|
let
|
|
pkgs = nixpkgsFor.${system};
|
|
inherit (pkgs) lib;# -> lib = pkgs.lib;
|
|
in
|
|
rec {
|
|
go-xkcdreader = with pkgs; buildGoModule rec {
|
|
pname = "go-xkcdreader";
|
|
buildInputs = [
|
|
gcc
|
|
libglvnd # instead of libGL
|
|
wayland
|
|
libxkbcommon
|
|
xorg.libX11
|
|
xorg.libXcursor
|
|
xorg.libXfixes
|
|
xorg.libXrandr
|
|
xorg.libXrender
|
|
xorg.xrandr
|
|
xorg.libXinerama
|
|
xorg.xinput
|
|
xorg.libXi
|
|
xorg.libXxf86vm
|
|
# xorg.xorgserver
|
|
];
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
inherit version;
|
|
doCheck = false;
|
|
# use go.mod for managing go deps, instead of vendor-only dir
|
|
proxyVendor = true;
|
|
tags = [ "wayland" ]; # go "-tags" to build with
|
|
ldflags = [
|
|
"-s"
|
|
"-w"
|
|
"-X cmd.version=${version}"
|
|
];
|
|
|
|
modSha256 = lib.fakeSha256;
|
|
# vendorSha256 = "";
|
|
vendorSha256 = "sha256-i6VOX1O/IqIOWUzgc/2U/a95KhzAG0/NOIG/D8E0BEk=";
|
|
|
|
# In 'nix develop', we don't need a copy of the source tree
|
|
# in the Nix store.
|
|
src = lib.cleanSource ./.;
|
|
|
|
meta = {
|
|
description = "an offline-capable xkcd webcomic reader written in Go";
|
|
homepage = "https://git.dotya.ml/wanderer/go-xkcdreader";
|
|
license = lib.licenses.gpl3;
|
|
maintainers = [ "wanderer" ];
|
|
platforms = lib.platforms.linux ++ lib.platforms.darwin;
|
|
};
|
|
};
|
|
default = go-xkcdreader;
|
|
});
|
|
|
|
|
|
apps = forAllSystems (system: rec {
|
|
go-xkcdreader = {
|
|
type = "app";
|
|
program =
|
|
"${self.packages.${system}.go-xkcdreader}/bin/go-xkcdreader";
|
|
};
|
|
default = go-xkcdreader;
|
|
});
|
|
|
|
devShells = forAllSystems (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ nixgl.overlay ];
|
|
};
|
|
in
|
|
{
|
|
default = with pkgs; mkShell
|
|
{
|
|
name = "go-xkcdreader-" + version;
|
|
|
|
GOFLAGS = "-buildmode=pie -trimpath -mod=readonly -modcacherw";
|
|
GOLDFLAGS = "-s -w -X cmd.version=${version}";
|
|
CGO_CFLAGS = "-g2 -Og -mtune=generic";
|
|
CGO_LDFLAGS = "-Wl,-O1,-sort-common,-as-needed,-z,relro,-z,now,-flto -pthread";
|
|
|
|
shellHook = ''
|
|
echo " -- in go-xkcdreader shell..."
|
|
'';
|
|
|
|
nativeBuildInputs = [
|
|
## uncomment the line below if using an Intel GPU when
|
|
## developing
|
|
# pkgs.nixgl.nixGLIntel
|
|
|
|
## this won't work without passing --impure, doesn't care what
|
|
## GPU vendor you use, it figures it out automatically
|
|
# pkgs.nixgl.auto.nixGLDefault # requires --impure
|
|
];
|
|
packages = [
|
|
go
|
|
gopls
|
|
gofumpt
|
|
go-tools
|
|
golangci-lint
|
|
nixpkgs-fmt
|
|
] ++ (if stdenv.isLinux then [
|
|
|
|
pkgconfig
|
|
|
|
# fyne deps
|
|
libglvnd # instead of libGL
|
|
wayland
|
|
libxkbcommon
|
|
xorg.libX11
|
|
xorg.libXcursor
|
|
xorg.libXfixes
|
|
xorg.libXrandr
|
|
xorg.libXrender
|
|
xorg.xrandr
|
|
xorg.libXinerama
|
|
xorg.xinput
|
|
xorg.libXi
|
|
xorg.libXxf86vm
|
|
xorg.xorgserver
|
|
|
|
] else [ ]);
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|