Skip to content

Commit

Permalink
Add pistol-static and more
Browse files Browse the repository at this point in the history
Use the same nixpkgs input for gomod2nix.
  • Loading branch information
doronbehar committed Mar 18, 2021
1 parent 080369b commit 2e645a0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 50 deletions.
40 changes: 13 additions & 27 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 45 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
description = "General purpose file previewer designed for Ranger, Lf to make scope.sh redundant";

# To make user overrides of the nixpkgs flake not take effect
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";

# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
gomod2nix-flake = {
url = "github:tweag/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

inputs.gomod2nix-flake.url = "github:tweag/gomod2nix";

outputs = { self
, nixpkgs
, flake-utils
Expand All @@ -28,36 +31,55 @@
inherit system;
config = {};
};
nativeBuildInputs = [
pkgs.gomod2nix
];
checkInputs = [
pkgs.elinks
pkgs.bat
# For tput
pkgs.ncurses
];
buildInputs = [
pkgs.file
];
pistol = pkgs.buildGoApplication rec {
pname = "pistol";
version = "${pkgs.lib.strings.removeSuffix "\n" (builtins.readFile ./VERSION)}-flake";
src = builtins.filterSource
(path: type: type != "directory" || baseNameOf path != ".git")
./.;
modules = ./gomod2nix.toml;
inherit (pkgs.pistol)
meta
passthru
subPackages
buildInputs
;
inherit (pkgs.pistol) meta;
subPackages = [ "cmd/pistol" ];
# We don't do a check in every build (yet) so we don't need to inherit
# checkInputs as of yet.
inherit buildInputs;
CGO_ENABLED = "1";
buildFlagsArray = [ "-ldflags=-s -w -X main.Version=${version}" ];
};
in rec {
devShell = pkgs.mkShell {
buildInputs = [
pkgs.file
pkgs.elinks
pkgs.gomod2nix
pistol-static = pistol.overrideAttrs(oldAttrs: {
pname = "pistol-static";
buildInputs = buildInputs ++ [
pkgs.glibc.static
pkgs.pkgsStatic.file
];
CFLAGS = "-I${pkgs.glibc.dev}/include";
LDFLAGS = "-I${pkgs.glibc}/lib";
});
in {
devShell = pkgs.mkShell {
inherit buildInputs nativeBuildInputs checkInputs;
};
packages = {
inherit pistol pistol-static;
};
packages.pistol = pistol;
defaultPackage = pistol;
apps.pistol = {
type = "app";
program = "${pistol}/bin/pistol";
};
defaultApp = apps.pistol;
defaultApp = self.apps.pistol;
}
);
}

0 comments on commit 2e645a0

Please sign in to comment.