Skip to content

Commit

Permalink
Add Nix flake (#44)
Browse files Browse the repository at this point in the history
* Add flake

* document nix flake
  • Loading branch information
pinpox authored Dec 6, 2024
1 parent 2a91b86 commit a893ef8
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/
.DS_Store
result
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ $ brew install foto

Or download the binary from [here](https://github.com/waynezhang/foto/releases)

### Nix/NixOS

for Nix users, a Flake is provided. It can be used to run the application
directly or add the package to your configuration as flake input.

It also allows to try out foto, without permanent installation.

```sh
nix run github:waynezhang/foto
```

Consult the [Nix
manual](https://nix.dev/manual/nix/2.25/command-ref/new-cli/nix3-flake.html) for
details.

### Other platforms

Download the binary from [here](https://github.com/waynezhang/foto/releases)
Expand Down
26 changes: 26 additions & 0 deletions flake.lock

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

61 changes: 61 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
description = "Publishing tool for minimalist photographers";

# Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";

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"
"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; });

in
{

# Provide some binary packages for selected system types.
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
lib = pkgs.lib;
in
rec {
foto = pkgs.buildGoModule {
pname = "foto";
inherit version;
src = ./.;
vendorHash = "sha256-GiCLg/b+ZF5nAXZh/yIH34yyRFPh2LxEKfXiCp929LI=";

meta = with lib;{
homepage = "https://github.com/waynezhang/foto";
description = "Yet another publishing tool for minimalist photographers";
license = licenses.mit;
mainProgram = "foto";
maintainers = with maintainers; [ pinpox ];
};
};

default = foto;
}
);
};
}

0 comments on commit a893ef8

Please sign in to comment.