From f0772f9b996ef0359cd597ff1f8abcfc6cd80cce Mon Sep 17 00:00:00 2001 From: Tasia Iso Date: Sun, 12 May 2024 20:12:50 +0200 Subject: [PATCH 1/4] build(nix): add Nix support --- .gitignore | 1 + default.nix | 48 +++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 +++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 4dd27d0b..e4bb4fb4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ out *.swo *.swp .zsign_cache/ +result diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..b8965954 --- /dev/null +++ b/default.nix @@ -0,0 +1,48 @@ +{ + pkgs ? import {}, + lib ? import , +}: +pkgs.stdenv.mkDerivation rec { + pname = "tildefriends"; + version = "0.0.19"; + + src = pkgs.fetchFromGitea { + domain = "dev.tildefriends.net"; + owner = "cory"; + repo = "tildefriends"; + # rev = "v${version}"; + rev = "47838d5e482cb4aac40190fa0414f08b8cf94d40"; + hash = "sha256-mb5KYvWPIqgV64FOaXKHm2ownBJiiSRtdH8+YWiXwvE="; # 47838d5e482cb4aac40190fa0414f08b8cf94d40 + fetchSubmodules = true; + }; + + nativeBuildInputs = with pkgs; [ + gnumake + openssl + which + ]; + + buildInputs = with pkgs; [ + openssl + which + ]; + + buildPhase = '' + make -j $NIX_BUILD_CORES release + ''; + + installPhase = '' + mkdir -p $out/bin + cp -r out/release/tildefriends $out/bin + ''; + + doCheck = false; + + meta = with pkgs; { + homepage = "https://tildefriends.net"; + description = "Make apps and friends from the comfort of your web browser."; + mainProgram = "tildefriends"; + license = with lib.licenses; [mit]; + platforms = lib.platforms.all; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..0aebcb80 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1715395895, + "narHash": "sha256-DreMqi6+qa21ffLQqhMQL2XRUkAGt3N7iVB5FhJKie4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "71bae31b7dbc335528ca7e96f479ec93462323ff", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..08106c3e --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "Tilde Friends is a platform for making, running, and sharing web applications"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + }; + in rec + { + # Nix formatter, run using `$ nix fmt` + formatter = pkgs.alejandra; + + # Exports the tildefriends package + packages.default = pkgs.callPackage ./default.nix {}; + + # Creates a shell with the necessary dependencies + # Enter using `$ nix develop` + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + openssl + llvmPackages_17.clang-unwrapped + unzip + ]; + }; + }); +} From 22a4bce3c86d5bb2871e034624a9145c0d9c90e5 Mon Sep 17 00:00:00 2001 From: Tasia Iso Date: Sun, 12 May 2024 21:11:31 +0200 Subject: [PATCH 2/4] docs(nix): add documentation in default.nix --- default.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/default.nix b/default.nix index b8965954..0c8ba3a3 100644 --- a/default.nix +++ b/default.nix @@ -1,3 +1,23 @@ +# How to upgrade to a newer version +# - Comment `src.hash` +# - Change `version` +# - Run `$ nix build` +# This will fetch the source code +# Since `hash` is not provided, nix will stop building and throw an error: +# +# error: hash mismatch in fixed-output derivation '/nix/store/fghi3ljs6fhz8pwm3dh73j5fwjpq5wbz-source.drv': +# specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= +# got: sha256-+uthA1w8CmZfW+WOK9wYGl2fUl/k10ufOc8W+Pwa9iQ= +# error: 1 dependencies of derivation '/nix/store/imcwsw5r74vkd8r0qa2k7cys2xfgraaz-tildefriends-0.0.18.drv' failed to build +# +# - Change `src.hash` to the new one, ie `sha256-+uthA1w8CmZfW+WOK9wYGl2fUl/k10ufOc8W+Pwa9iQ=` +# - Uncomment `src.hash` +# - Build again, this time it should work. +# - Check the release notes, if there's a new dependency or a change to `GNUMakefile`, this file might need to be changed too. +# For more details, contact tasiaiso @ https://tilde.club/~tasiaiso/ +# +# WARNING: currently it is pinned to `47838d5e482cb4aac40190fa0414f08b8cf94d40`. I couldn't get v0.0.18 to work for some reason. +# I'll change this in the next release - tasiaiso { pkgs ? import {}, lib ? import , From 4ebd6c24a92aaa6e15fad0fa3f13d034bbb3a719 Mon Sep 17 00:00:00 2001 From: Tasia Iso Date: Sun, 12 May 2024 21:15:30 +0200 Subject: [PATCH 3/4] chore: missing period in description --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 08106c3e..13b8a5fb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Tilde Friends is a platform for making, running, and sharing web applications"; + description = "Tilde Friends is a platform for making, running, and sharing web applications."; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; From 3b36496dac42185717bedad53e010e6cd1f97ae8 Mon Sep 17 00:00:00 2001 From: Tasia Iso Date: Sun, 12 May 2024 21:17:38 +0200 Subject: [PATCH 4/4] chore: a bit more doc --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 13b8a5fb..2a5a072b 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,7 @@ formatter = pkgs.alejandra; # Exports the tildefriends package + # Build with `$ nix build` packages.default = pkgs.callPackage ./default.nix {}; # Creates a shell with the necessary dependencies