From a893ef819c43b3fbdf07cbca0340b5f03cb524c7 Mon Sep 17 00:00:00 2001 From: Pablo Ovelleiro Corral Date: Fri, 6 Dec 2024 02:49:24 +0100 Subject: [PATCH] Add Nix flake (#44) * Add flake * document nix flake --- .gitignore | 1 + README.md | 15 ++++++++++++++ flake.lock | 26 +++++++++++++++++++++++ flake.nix | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 00b41c6..0829fcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin/ .DS_Store +result diff --git a/README.md b/README.md index dadd9a9..329b981 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ed92882 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1732014248, + "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0e4ae87 --- /dev/null +++ b/flake.nix @@ -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; + } + ); + }; +}