Skip to content

Commit

Permalink
Switch to flakes
Browse files Browse the repository at this point in the history
Use VERSION file to define version for both Makefile and flake.nix.
  • Loading branch information
doronbehar committed Nov 20, 2020
1 parent 627cb2a commit 4bdff9d
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
# End of https://www.gitignore.io/api/go
/cmd/pistol/pistol
/pistol
result
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

NAME := pistol
VERSION := v0.1.6
VERSION := v$(shell cat VERSION)-git

build:
go build -ldflags "-X 'main.Version=$(VERSION)'" ./cmd/pistol
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.6
9 changes: 9 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).defaultNix
60 changes: 60 additions & 0 deletions flake.lock

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

40 changes: 40 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
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;
};

outputs = { self, nixpkgs, flake-utils, flake-compat }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
pistol = pkgs.pistol.overrideAttrs(oldAttrs: rec {
version = "${builtins.readFile ./VERSION}-flake";
buildFlagsArray = [
"-ldflags=-s -w -X main.Version=${version}"
];
});
in rec {
devShell = pkgs.mkShell {
buildInputs = pistol.buildInputs ++ [
pkgs.w3m
];
};
packages.pistol = pistol;
defaultPackage = pistol;
apps.pistol = {
type = "app";
program = "${pistol}/bin/pistol";
};
defaultApp = apps.pistol;
}
);
}

0 comments on commit 4bdff9d

Please sign in to comment.